Skip to content

Commit efb3fa5

Browse files
committed
[ADD] estate: added Estate Account Module
created Estate Account module and necessary files. added invoicing functionality by using inherit method. added UserError on sold button if no offer are accepted.
1 parent 46bf355 commit efb3fa5

File tree

5 files changed

+55
-2
lines changed

5 files changed

+55
-2
lines changed

estate/models/estate_property.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,15 +89,15 @@ def _onchange_garden(self):
8989
def action_sold_property(self):
9090
for record in self:
9191
if record.state == "cancelled":
92-
raise exceptions.UserError("Cancelled Property cannot be Sold")
92+
raise UserError("Cancelled Property cannot be Sold")
9393
else:
9494
record.state = "sold"
9595
return True
9696

9797
def action_cancel_offer(self):
9898
for record in self:
9999
if record.state == "sold":
100-
raise exceptions.UserError("Sold Property cannot be Cancelled")
100+
raise UserError("Sold Property cannot be Cancelled")
101101
else:
102102
record.state = "cancelled"
103103
return True

estate_account/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/usr/bin/env python3
2+
from . import models

estate_account/__manifest__.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/usr/bin/env python3
2+
{
3+
"name": "Estate Account",
4+
"description": """
5+
Estate account module to manage Estate Customers and Salesman.
6+
""",
7+
"version": "1.0",
8+
"depends": ["estate", "account"],
9+
"author": "danal",
10+
"category": "Category",
11+
"license": "LGPL-3",
12+
"data": [],
13+
}

estate_account/models/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/usr/bin/env python3
2+
from . import estate_property
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#!/usr/bin/env python3
2+
from odoo.exceptions import UserError
3+
4+
from odoo import fields, models, Command
5+
6+
7+
class EstatePropertyInherit(models.Model):
8+
_inherit = "estate.property"
9+
10+
def action_sold_property(self):
11+
for record in self:
12+
if record.selling_price == 0:
13+
raise UserError("Cannot sell Property without any accepted offer")
14+
self.env["account.move"].create(
15+
{
16+
"partner_id": self.customer.id,
17+
"move_type": "out_invoice",
18+
"invoice_line_ids": [
19+
Command.create(
20+
{
21+
"name": "6% of the selling price",
22+
"quantity": 1,
23+
"price_unit": record.selling_price * 0.06,
24+
}
25+
),
26+
Command.create(
27+
{
28+
"name": "an additional 100.00 from administrative fees",
29+
"quantity": 1,
30+
"price_unit": 100,
31+
}
32+
),
33+
],
34+
}
35+
)
36+
return super().action_sold_property()

0 commit comments

Comments
 (0)