Skip to content

Commit da40c46

Browse files
author
Martin Doyen
committed
[ADD] estate account: link estate and invoicing
1 parent ad19653 commit da40c46

File tree

6 files changed

+44
-0
lines changed

6 files changed

+44
-0
lines changed

estate/models/estate_property.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@ def action_set_sold(self):
7474

7575
record.state = 'sold'
7676

77+
return True
78+
7779
def action_set_cancelled(self):
7880
for record in self:
7981
if self.state == 'sold':
@@ -82,6 +84,8 @@ def action_set_cancelled(self):
8284
record.state = 'cancelled'
8385
record.active = False
8486

87+
return True
88+
8589
@api.constrains('selling_price')
8690
def _check_selling_price(self):
8791
for record in self:

estate/models/res_users.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from odoo import fields, models
22

3+
34
class ResUsers(models.Model):
45
_inherit = 'res.users'
56

estate_account/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from . import models

estate_account/__manifest__.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
'name': "Estate Accounting",
3+
'version': '1.0',
4+
'depends': ['base', 'account', 'estate'],
5+
'data': [
6+
],
7+
'application': True,
8+
'license': 'LGPL-3',
9+
}

estate_account/models/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from . import estate_property
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
from odoo import Command, models
2+
3+
4+
class EstateProperty(models.Model):
5+
_inherit = 'estate.property'
6+
7+
def action_set_sold(self):
8+
result = super().action_set_sold()
9+
10+
for record in self:
11+
self.env['account.move'].create({
12+
'partner_id': record.partner_id.id,
13+
'move_type': 'out_invoice',
14+
'invoice_line_ids': [
15+
Command.create({
16+
'name': f"Down payment for {record.name}",
17+
'quantity': 1,
18+
'price_unit': record.selling_price * 0.06,
19+
}),
20+
Command.create({
21+
'name': "Administrative fees",
22+
'quantity': 1,
23+
'price_unit': 100,
24+
}),
25+
],
26+
})
27+
28+
return result

0 commit comments

Comments
 (0)