Skip to content

Commit 1cc199b

Browse files
committed
[ADD] estate: Chapter 13 - add a link module.
Initial implementation of estate module with property management features
1 parent d8b4942 commit 1cc199b

File tree

5 files changed

+77
-0
lines changed

5 files changed

+77
-0
lines changed

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: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"name": "Estate",
3+
"version": "1.0",
4+
"author": "Joyep",
5+
"license": "LGPL-3",
6+
"depends": ["base"],
7+
"data": [
8+
"data/ir.model.access.csv",
9+
"views/estate_property_views.xml",
10+
"views/estate_property_type_views.xml",
11+
"views/estate_property_tag_views.xml",
12+
"views/estate_menus.xml",
13+
"views/inherited_users_views.xml",
14+
],
15+
"installable": True,
16+
"application": True,
17+
"auto_install": False,
18+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
2+
access_estate_property_account,access_estate_property_account,model_estate_property,,1,0,0,0

estate_account/models/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from . import (
2+
estate_property,
3+
)
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
from odoo import fields, models
2+
from odoo.exceptions import UserError
3+
4+
5+
class EstateProperty(models.Model):
6+
_inherit = "estate.property"
7+
8+
def action_set_sold(self):
9+
# Check if the property is canceled
10+
for record in self:
11+
if record.status == "canceled":
12+
msg = "A cancelled property cannot be set as sold."
13+
raise UserError(msg)
14+
record.status = "sold"
15+
16+
# Create invoice
17+
self.env["account.move"].create(
18+
{
19+
"partner_id": self.partner_id.id,
20+
"move_type": "out_invoice",
21+
"invoice_line_ids": [
22+
(
23+
0,
24+
0,
25+
{
26+
"name": self.name,
27+
"quantity": 1,
28+
"price_unit": self.selling_price,
29+
},
30+
),
31+
(
32+
0,
33+
0,
34+
{
35+
"name": "6% commission on selling price",
36+
"quantity": 1,
37+
"price_unit": self.selling_price * 0.06,
38+
},
39+
),
40+
(
41+
0,
42+
0,
43+
{
44+
"name": "Administrative fees",
45+
"quantity": 1,
46+
"price_unit": 100.00,
47+
},
48+
),
49+
],
50+
}
51+
)
52+
53+
return super(EstateProperty, self).action_set_sold()

0 commit comments

Comments
 (0)