Skip to content

Commit 3c56016

Browse files
committed
[ADD] estate: Created Link module between account and estate
estate_account linking module created, now follows chapter 13 guidelines
1 parent 6f9cc29 commit 3c56016

File tree

6 files changed

+47
-6
lines changed

6 files changed

+47
-6
lines changed

estate/models/estate_property.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -103,15 +103,13 @@ def action_property_cancel(self):
103103
for single_property in self:
104104
if single_property.state == "sold":
105105
raise UserError("Sold properties cannot be cancelled!")
106-
return False
107106
single_property.state = "cancelled"
108107
return True
109108

110109
def action_property_sold(self):
111110
for single_property in self:
112111
if single_property.state == "cancelled":
113112
raise UserError("Cancelled properties cannot be sold!")
114-
return False
115113
single_property.state = "sold"
116114
return True
117115

@@ -127,6 +125,7 @@ def check_selling_price_in_range(self):
127125
raise ValidationError(
128126
"Selling price cannot be lower than 90%% of Expected price"
129127
)
128+
return True
130129

131130
@api.ondelete(at_uninstall=False)
132131
def _unlink_check_property_state(self):
@@ -135,3 +134,4 @@ def _unlink_check_property_state(self):
135134
raise UserError(
136135
"Property cannot be deleted unless it is new or cancelled"
137136
)
137+
return True

estate/models/estate_property_offer.py

+5-4
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,9 @@ def action_offer_refuse(self):
8181

8282
@api.model_create_multi
8383
def create(self, vals):
84-
single_property = self.env["estate.property"].browse(vals["property_id"])
85-
if vals["price"] < single_property.best_price:
86-
raise UserError("An offer cannot be lower than an existing offer")
87-
single_property.state = "offer-received"
84+
for val in vals:
85+
single_property = self.env["estate.property"].browse(val["property_id"])
86+
if val["price"] < single_property.best_price:
87+
raise UserError("An offer cannot be lower than an existing offer")
88+
single_property.state = "offer-received"
8889
return super().create(vals)

estate_account/__init__.py

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from . import models

estate_account/__manifest__.py

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"name": "Real Estate Account",
3+
"license": "LGPL-3",
4+
"application": True,
5+
"depends": ["estate", "account"],
6+
}

estate_account/models/__init__.py

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from . import estate_property
+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
from odoo import models, Command
2+
3+
4+
class EstateProperty(models.Model):
5+
_inherit = "estate.property"
6+
7+
def action_property_sold(self):
8+
result_super = super().action_property_sold()
9+
for single_property in self:
10+
self.env["account.move"].create(
11+
{
12+
"partner_id": single_property.buyer_id.id,
13+
"move_type": "out_invoice",
14+
"invoice_line_ids": [
15+
Command.create(
16+
{
17+
"name": "6%% of the selling price",
18+
"quantity": 1,
19+
"price_unit": 0.06 * single_property.selling_price,
20+
}
21+
),
22+
Command.create(
23+
{
24+
"name": "Administrative fees",
25+
"quantity": 1,
26+
"price_unit": 100.0,
27+
}
28+
),
29+
],
30+
}
31+
)
32+
return result_super

0 commit comments

Comments
 (0)