Skip to content

Commit b722b3e

Browse files
committed
[ADD] estate: invoicing (chapter 13)
1 parent 220923d commit b722b3e

File tree

6 files changed

+58
-3
lines changed

6 files changed

+58
-3
lines changed

estate/__manifest__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
'version': '1.0',
44
'depends': ['base'],
55
'author': "taskv",
6-
'category': 'Category',
6+
'category': 'Tutorials',
77
'description': """
88
Tutorial Project
99
""",

estate/models/estate_property.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,13 +94,13 @@ def property_sold(self):
9494
if record.state != 'cancelled':
9595
record.state = 'sold'
9696
else:
97-
raise exceptions.UserError("Sold properties cannot be cancelled.")
97+
raise exceptions.UserError("Cancelled properties cannot be sold.")
9898
return True
9999

100100
def property_cancelled(self):
101101
for record in self:
102102
if record.state != 'sold':
103103
record.state = 'cancelled'
104104
else:
105-
raise exceptions.UserError("Cancelled properties cannot be sold.")
105+
raise exceptions.UserError("Sold properties cannot be cancelled.")
106106
return True

estate_account/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Part of Odoo. See LICENSE file for full copyright and licensing details.
2+
3+
from . import models

estate_account/__manifest__.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
2+
{
3+
'name': "Real Estate Invoicing",
4+
'version': '1.0',
5+
'depends': ['estate', 'account'],
6+
'author': "taskv",
7+
'category': 'Tutorials',
8+
'description': """
9+
Tutorial Project
10+
""",
11+
'data': [
12+
],
13+
'demo': [
14+
],
15+
'installable': True,
16+
'application': True,
17+
'license': 'LGPL-3',
18+
}

estate_account/models/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Part of Odoo. See LICENSE file for full copyright and licensing details.
2+
3+
from . import estate_property
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Part of Odoo. See LICENSE file for full copyright and licensing details.
2+
3+
from odoo import models, Command
4+
5+
6+
class EstateProperty(models.Model):
7+
_inherit = 'estate.property'
8+
9+
def property_sold(self):
10+
invoice_vals_list = []
11+
for record in self:
12+
if record.state == 'offer_accepted' and record.buyer_id:
13+
invoice_vals = {
14+
'move_type': 'out_invoice',
15+
'partner_id': record.buyer_id.id,
16+
'invoice_line_ids': [
17+
Command.create({
18+
"name": "Commission 6%",
19+
"quantity": 1,
20+
"price_unit": record.selling_price * 0.06,
21+
}),
22+
Command.create({
23+
"name": "Administrative fees",
24+
"quantity": 1,
25+
"price_unit": 100.,
26+
}),
27+
],
28+
}
29+
invoice_vals_list.append(invoice_vals)
30+
self.env['account.move'].sudo().create(invoice_vals_list)
31+
return super().property_sold()

0 commit comments

Comments
 (0)