Skip to content

Commit 191f8cc

Browse files
committed
[IMP] estate: create new module estate account
created a new module to connect Real Estate with accounting features. create invoice when property sold
1 parent 78e37cc commit 191f8cc

File tree

9 files changed

+46
-23
lines changed

9 files changed

+46
-23
lines changed

estate/__manifest__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
'data': [
77
'security/ir.model.access.csv',
88
'views/estate_property_views.xml',
9+
'views/estate_property_offer_views.xml',
910
'views/estate_property_type_views.xml',
1011
'views/estate_property_tag_views.xml',
11-
'views/estate_property_offer_views.xml',
1212
'views/res_users_views.xml',
1313
'views/estate_menus.xml'
1414
],

estate/models/estate_property.py

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ def _onchange_garden(self):
6969
self.garden_orientation = 'north'
7070
else:
7171
self.garden_area = 0
72-
self.garden_orientation = None
72+
self.garden_orientation = False
7373

7474
def cancel_property(self):
7575
for record in self:
@@ -107,15 +107,3 @@ def _unlink_check_state_of_property(self):
107107
for record in self:
108108
if record.state in ('offer_received', 'offer_accepted', 'sold'):
109109
raise UserError("You cannot delete a new or cancelled property !")
110-
111-
@api.model
112-
def write(self, vals):
113-
for record in self:
114-
if 'state' in vals:
115-
new_state = vals['state']
116-
current_state = record.state
117-
if current_state == 'sold' and new_state == 'cancelled':
118-
raise UserError("sold property cannot be cancelled.")
119-
if current_state == 'cancelled' and new_state == 'sold':
120-
raise UserError("cancelled property cannot be sold.")
121-
return super().write(vals)

estate/models/estate_property_offer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def action_refuse(self):
5656
)
5757

5858
@api.model
59-
def create(self,value):
59+
def create(self, value):
6060
for record in value:
6161
property = self.env['estate.property'].browse(record['property_id'])
6262
if property.state == 'new':

estate/views/estate_property_offer_views.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,11 @@
3030
</form>
3131
</field>
3232
</record>
33+
34+
<record id="estate_property_offer_action" model="ir.actions.act_window">
35+
<field name="name">Property type Offer</field>
36+
<field name="res_model">estate.property.offer</field>
37+
<field name="view_mode">list</field>
38+
<field name="domain">[("property_id.type_id", "=", active_id)]</field>
39+
</record>
3340
</odoo>

estate/views/estate_property_type_views.xml

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
<form>
1818
<sheet>
1919
<div class="oe_button_box" name="button_box">
20-
<button name="%(estate.estate_property_offer_action)d" type="action" class="oe_stat_button" icon="fa-money">
20+
<button class="oe_stat_button" name="%(estate.estate_property_offer_action)d" type="action" icon="fa-money">
2121
<field name="offer_count" widget="statinfo" string="Offers"/>
2222
</button>
2323
</div>
@@ -43,11 +43,4 @@
4343
<field name="res_model">estate.property.type</field>
4444
<field name="view_mode">list,form</field>
4545
</record>
46-
47-
<record id="estate_property_offer_action" model="ir.actions.act_window">
48-
<field name="name">Property type Offer</field>
49-
<field name="res_model">estate.property.offer</field>
50-
<field name="view_mode">list</field>
51-
<field name="domain">[("property_id.type_id", "=", active_id)]</field>
52-
</record>
5346
</odoo>

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: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
'author': 'Odoo S.A.',
3+
'name': 'Estate Account',
4+
'depends': ['estate', 'account'],
5+
'license': 'LGPL-3',
6+
'application': True,
7+
'installable': True
8+
}

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: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
from odoo import models, Command
2+
3+
4+
class EstateProperty(models.Model):
5+
_inherit = "estate.property"
6+
7+
def sold_property(self):
8+
for record in self:
9+
self.env['account.move'].create({
10+
'partner_id': self.buyer.id,
11+
'move_type': 'out_invoice',
12+
'invoice_line_ids': [
13+
Command.create({
14+
'name': '6% of the selling price',
15+
'quantity': 1,
16+
'price_unit': record.selling_price * 0.06,
17+
}),
18+
Command.create({
19+
'name': 'an additional 100.00 from administrative fees',
20+
'quantity': 1,
21+
'price_unit': 100
22+
})
23+
]
24+
})
25+
return super().sold_property()

0 commit comments

Comments
 (0)