Skip to content

Commit a41e581

Browse files
committed
[ADD] estate_account: override sold action to create invoice for buyer
1 parent 6f34f69 commit a41e581

6 files changed

Lines changed: 51 additions & 2 deletions

File tree

estate/models/estate_property_offer.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ def create(self, vals):
6767

6868
existing_prices = property_record.offer_ids.mapped("price")
6969
max_property_offers = max(existing_prices) if existing_prices else 0
70-
print(max_property_offers)
7170
if float_compare(val.get("price"), max_property_offers, precision_digits=2) <= 0:
7271
raise UserError(f"The offer must be higher than {max_property_offers}")
7372
offer = super().create(vals)

estate/models/res_users.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ class ResUsers(models.Model):
1111
# -------------------------------------------------------------------------
1212
# Field declarations
1313
# -------------------------------------------------------------------------
14-
property_ids = fields.One2many("estate.property", "salesman_id", string="Properties", domain="[('state', 'in', ('new', 'offer_received'))]")
14+
property_ids = fields.One2many("estate.property", "salesman_id", string="Estate Properties", domain="[('state', 'in', ('new', 'offer_received'))]")

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: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
'name': 'Estate Account',
3+
'version': '0.0',
4+
'summary': 'Real Estate Management with Account',
5+
'depends': [
6+
'base',
7+
'estate',
8+
'account',
9+
],
10+
'data': [
11+
12+
],
13+
'application': True,
14+
'author': 'Odoo S.A.',
15+
'license': 'LGPL-3',
16+
}

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: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
from odoo import models
2+
from odoo.orm.commands import Command
3+
4+
5+
class EstateProperty(models.Model):
6+
7+
# -------------------------------------------------------------------------
8+
# Private attributes
9+
# -------------------------------------------------------------------------
10+
_inherit = "estate.property"
11+
12+
# -------------------------------------------------------------------------
13+
# Action methods
14+
# -------------------------------------------------------------------------
15+
def action_sold_property(self):
16+
self.env["account.move"].create({
17+
"partner_id": self.buyer_id.id,
18+
"move_type": "out_invoice",
19+
"invoice_line_ids": [
20+
Command.create({
21+
"name": self.name,
22+
"quantity": 0.06,
23+
"price_unit": self.selling_price,
24+
}),
25+
Command.create({
26+
"name": "Administrative fees",
27+
"quantity": 1,
28+
"price_unit": 100.00,
29+
})
30+
],
31+
})
32+
return super().action_sold_property()

0 commit comments

Comments
 (0)