Skip to content

Commit ea91619

Browse files
committed
[IMP] estate: Created estate_account module and generate invoices on sale
Chapter 13 : Create estate_account link module to connect estate and account Extend property sold action to create a customer invoice Add invoice lines for commission and administrative fees on sale
1 parent e577a81 commit ea91619

File tree

6 files changed

+44
-1
lines changed

6 files changed

+44
-1
lines changed

estate/models/estate_property_offer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def _inverse_date_deadline(self):
5454
def action_accept(self):
5555
for offer in self:
5656
if offer.property_id.buyer_id:
57-
raise UserError('Only one offer can be accepted for a property.')
57+
raise exceptions.UserError(_('Only one offer can be accepted for a property.'))
5858
offer.status = 'accepted'
5959
offer.property_id.selling_price = offer.price
6060
offer.property_id.buyer_id = offer.partner_id

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 models, fields
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: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"name": "Estate Account",
3+
"description": "Link real estate properties with invoicing",
4+
"version": "1.0",
5+
"category": "Real Estate",
6+
"depends": ["estate", "account"],
7+
"author": "Harsh Maniya",
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: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
from odoo import models, Command
2+
3+
4+
class EstateProperty(models.Model):
5+
_inherit = "estate.property"
6+
7+
def action_set_sold(self):
8+
self.env["account.move"].create(
9+
{
10+
"move_type": "out_invoice",
11+
"partner_id": self.buyer_id.id,
12+
"invoice_line_ids": [
13+
Command.create(
14+
{
15+
"name": "6% of selling price",
16+
"quantity": 1,
17+
"price_unit": self.selling_price * 0.6,
18+
}
19+
),
20+
Command.create(
21+
{
22+
"name": "Administrative fees",
23+
"quantity": 1,
24+
"price_unit": 100.0,
25+
}
26+
),
27+
],
28+
}
29+
)
30+
return super().action_set_sold()

0 commit comments

Comments
 (0)