Skip to content

Commit 94dda9a

Browse files
committed
[ADD] estate_account: create customer invoice when property is sold
Create a link module between estate and account. Extend estate.property action_sold to generate a customer invoice with two invoice lines: • 6% commission on selling price • Fixed administrative fee of 100.00
1 parent f547706 commit 94dda9a

File tree

7 files changed

+43
-6
lines changed

7 files changed

+43
-6
lines changed

estate/models/estate_property.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,15 +88,13 @@ def action_sold_property(self):
8888
raise exceptions.UserError("Properties which are Cancelled cannot be Sold")
8989
else:
9090
record.state = "sold"
91-
return True
9291

9392
def action_cancel_offer(self):
9493
for record in self:
9594
if record.state == "sold":
9695
raise exceptions.UserError("Properties which are Sold cannot be Cancelled")
9796
else:
9897
record.state = "cancelled"
99-
return True
10098

10199
@api.constrains("selling_price", "expected_price")
102100
def _check_selling_price_percentage_criteria(self):

estate/models/estate_property_offer.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,12 @@ def action_accept(self):
4040
record.property_id.state = "offer_accepted"
4141
record.property_id.selling_price = record.price
4242
record.property_id.customer = record.partner_id
43-
return True
4443

4544
def action_refuse(self):
4645
for record in self:
4746
record.status = "refused"
4847
record.property_id.selling_price = 0.00
4948
record.property_id.customer = None
50-
return True
5149

5250
@api.model
5351
def create(self, vals):

estate/views/estate_property_views.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<field name="name">estate.property.list</field>
55
<field name="model">estate.property</field>
66
<field name="arch" type="xml">
7-
<list string="Properties" decoration-success="state in ('offer_accepted')" decoration-bf="state in ('offer_accepted')" decoration-muted="state in ('sold')">
7+
<list string="Properties" decoration-success="state in ('offer_accepted', 'offer_received')" decoration-bf="state in ('offer_accepted')" decoration-muted="state in ('sold')">
88
<field name="name" string="Title"/>
99
<field name="property_type_id"/>
1010
<field name="postcode"/>
@@ -88,7 +88,7 @@
8888
<field name="postcode" />
8989
<field name="expected_price" />
9090
<field name="bedrooms" />
91-
<field name="living_area" string="Living Area (sqm)" />
91+
<field name="living_area" string="Living Area (sqm)" filter_domain="[('living_area', '&gt;=', self)]" />
9292
<field name="facades" />
9393
<filter string="Available" name="available" domain="[('state', '=', 'new')]"/>
9494
<filter string="Archived" name="inactive" domain="[('active', '=', False)]"/>

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: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"name": "Estate Account",
3+
"description": "Estate Account",
4+
"version": "1.0",
5+
"depends": ["estate", "account"],
6+
"author": "snrav-odoo",
7+
"category": "Category",
8+
"license": "LGPL-3",
9+
"data": [],
10+
}

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

0 commit comments

Comments
 (0)