Skip to content

Commit 39b2683

Browse files
committed
[FIX] fix style
1 parent 7530203 commit 39b2683

File tree

7 files changed

+25
-36
lines changed

7 files changed

+25
-36
lines changed

estate/__init__.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1 @@
1-
# -*- coding: utf-8 -*-
2-
3-
41
from . import models

estate/__manifest__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
'views/estate_property_type.xml',
1515
'views/estate_property_views.xml',
1616
'views/res_users_views.xml',
17-
'views/menu_views.xml',
17+
'views/menu_views.xml',
1818
],
1919
'application': True,
2020
'license': 'LGPL-3',

estate/models/estate_property.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ class EstateProperty(models.Model):
1515
_order = "id desc"
1616

1717
_check_expected_price = models.Constraint(
18-
'CHECK(expected_price >= 0)', 'The expected price must be strictly positive.')
18+
'CHECK(expected_price >= 0)', 'The expected price must be strictly positive.')
1919

2020
_check_selling_price = models.Constraint(
21-
'CHECK(selling_price > 0)', 'The selling price must be positive.')
21+
'CHECK(selling_price > 0)', 'The selling price must be positive.')
2222

2323
# ---------------------------------------- Fields Declaration ---------------------------------
2424

@@ -66,12 +66,12 @@ class EstateProperty(models.Model):
6666
@api.depends('living_area', 'garden_area')
6767
def _compute_total_area(self):
6868
for property in self:
69-
property.total_area = property.living_area + property.garden_area
69+
property.total_area = property.living_area + property.garden_area
7070

7171
@api.depends('offer_ids.price')
7272
def _compute_best_price(self):
7373
for record in self:
74-
record.best_price = max(record.offer_ids.mapped('price')) if record.offer_ids else 0
74+
record.best_price = max(record.offer_ids.mapped('price')) if record.offer_ids else 0
7575

7676
# ----------------------------------- Constrains and Onchanges --------------------------------
7777

@@ -83,7 +83,6 @@ def _check_selling_price_expected_price(self):
8383
if float_compare(record.selling_price, 0.9 * record.expected_price, precision_digits=2) == -1:
8484
raise UserError("The selling price must be at least 90% of the expected price.")
8585

86-
8786
@api.onchange('garden')
8887
def _onchange_garden(self):
8988
if self.garden:
@@ -102,7 +101,6 @@ def _onchange_offers(self):
102101

103102
if not has_offers and not any(offer.status == 'accepted' for offer in record.offer_ids) and record.state in ('offer_received',):
104103
record.state = 'offer_receive'
105-
106104
# ------------------------------------------ CRUD Methods -------------------------------------
107105

108106
@api.ondelete(at_uninstall=False)
@@ -113,7 +111,6 @@ def _if_new_or_canceled(self):
113111
# ---------------------------------------- Action Methods -------------------------------------
114112

115113
def action_set_sold(self):
116-
print(self.state)
117114
if self.state == "cancelled":
118115
raise UserError("A cancelled property can not be sold")
119116
self.state = "sold"

estate/models/estate_property_offer.py

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,7 @@ class EstatePropertyOffer(models.Model):
1616
# --------------------------------------- Fields Declaration ----------------------------------
1717

1818
price = fields.Float(string='price', required=True)
19-
status = fields.Selection(selection=[('accepted', 'Accepted'),
20-
('refused', 'Refused')],
21-
string="Status",
22-
copy=False,
23-
# default='accepted',
24-
)
19+
status = fields.Selection(selection=[('accepted', 'Accepted'), ('refused', 'Refused')], string="Status", copy=False)
2520
validity = fields.Integer(string='Validity(days)', default=7)
2621
partner_id = fields.Many2one('res.partner', string='Partner', required=True)
2722
property_id = fields.Many2one('estate.property', required=True)
@@ -43,32 +38,35 @@ def create(self, vals_list):
4338
for vals in vals_list:
4439
if vals.get("property_id") and vals.get("price"):
4540
prop = self.env["estate.property"].browse(vals["property_id"])
46-
41+
4742
if float_compare(vals["price"], prop.expected_price * 0.9, precision_rounding=0.01) < 0:
48-
raise UserError("The offer price must be at least 90%% of the expected price.")
43+
raise UserError(
44+
"The offer price must be at least 90%% of the expected price.")
4945

5046
if prop.offer_ids:
5147
max_offer = max(prop.mapped("offer_ids.price"))
5248
if float_compare(vals["price"], max_offer, precision_rounding=0.01) <= 0:
53-
raise UserError("The offer must be higher than %.2f" % max_offer)
49+
raise UserError(
50+
"The offer must be higher than %.2f" % max_offer)
5451

5552
new_offers = super().create(vals_list)
5653

5754
for offer in new_offers:
5855
offer.property_id.state = "offer_received"
59-
56+
6057
return new_offers
6158

6259
# ---------------------------------------- Action Methods -------------------------------------
6360

6461
def action_accept(self):
65-
print("Accepting offer...")
6662
for offer in self:
6763
if any(prop_offer.status == 'accepted' for prop_offer in offer.property_id.offer_ids):
68-
raise UserError("An offer has already been accepted for this property.")
64+
raise UserError(
65+
"An offer has already been accepted for this property.")
66+
6967
if offer.status == 'refused':
7068
raise UserError("A refused offer cannot be accepted.")
71-
else:
69+
7270
offer.status = 'accepted'
7371
offer.property_id.write({
7472
'state': 'offer_accepted',
@@ -78,7 +76,7 @@ def action_accept(self):
7876
return True
7977

8078
def action_refuse(self):
81-
if any(offer.status == 'accepted' for offer in self):
82-
raise UserError("An accepted offer cannot be refused.")
83-
self.status = 'refused'
84-
return True
79+
if any(offer.status == 'accepted' for offer in self):
80+
raise UserError("An accepted offer cannot be refused.")
81+
self.status = 'refused'
82+
return True

estate/models/res_users.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ class ResUsers(models.Model):
77

88
property_ids = fields.One2many(
99
"estate.property", "salesman_id", string="Available Properties", domain=[("state", "in", ["new", "offer_received"])]
10-
)
10+
)

estate_account/__manifest__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
'name': "Tutorial Real Estate Accounting",
33
'description': 'model links the estate and account modules',
44
'version': '1.0',
5-
'depends': ['estate','account',],
6-
'data':[],
5+
'depends': ['estate', 'account'],
6+
'data': [],
77
'auto_install': True,
88
'author': 'Hazei',
99
'license': 'LGPL-3',

estate_account/models/estate_property.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,17 @@
11
from odoo import models, Command
2-
from odoo.exceptions import UserError
32
import logging
43

54
_logger = logging.getLogger(__name__)
65

6+
77
class EstateProperty(models.Model):
8-
9-
# ---------------------------------------- Private Attributes ---------------------------------
108

9+
# ---------------------------------------- Private Attributes ---------------------------------
1110
_inherit = "estate.property"
1211

1312
# ---------------------------------------- Action Methods -------------------------------------
1413

1514
def action_set_sold(self):
16-
print("top")
1715
res = super().action_set_sold()
1816
journal = self.env["account.journal"].search([("type", "=", "sale")], limit=1)
1917
for prop in self:
@@ -36,5 +34,4 @@ def action_set_sold(self):
3634
],
3735
}
3836
)
39-
print("bottom")
4037
return res

0 commit comments

Comments
 (0)