Skip to content

Commit 32ad5b7

Browse files
committed
[FIX] estate_account: fixed check style and tutorial changes
fixed check style and tutorial changes in estate_account and estate_property
1 parent 56ea6cc commit 32ad5b7

File tree

5 files changed

+25
-32
lines changed

5 files changed

+25
-32
lines changed

estate_account/__manifest__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
{
22
'name': 'Estate Accounting',
33
'version': '1.0',
4-
'depends': ['base','real_estate', 'account'],
4+
'depends': ['real_estate', 'account'],
55
'category': 'Real Estate',
6+
'license': 'LGPL-3',
67
'installable': True,
78
'application': False,
89
}

real_estate/models/estate_property.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from odoo import fields, models, api
22
from datetime import date, timedelta
3-
from odoo.exceptions import UserError,ValidationError
3+
from odoo.exceptions import UserError, ValidationError
44
from odoo.tools.float_utils import float_compare, float_is_zero
55

66

@@ -32,7 +32,7 @@ class EstateProperty(models.Model):
3232
('south', 'South'),
3333
('east', 'East'),
3434
('west', 'West')
35-
],
35+
],
3636
string="Garden Orientation"
3737
)
3838
last_seen = fields.Datetime("Last Seen", default=fields.Datetime.now)
@@ -44,9 +44,9 @@ class EstateProperty(models.Model):
4444
('offer_accepted', 'Offer Accepted'),
4545
('sold', 'Sold'),
4646
('cancelled', 'Cancelled'),
47-
],
48-
required=True,
49-
copy=False,
47+
],
48+
required=True,
49+
copy=False,
5050
default='new'
5151
)
5252
property_type_id = fields.Many2one('estate.property.type', string="Property Type")
@@ -102,6 +102,6 @@ def action_sold(self):
102102

103103
@api.ondelete(at_uninstall=False)
104104
def _check_deletion(self):
105-
for record in self:
106-
if record.state not in ['new', 'cancelled']:
107-
raise UserError("You can only delete a property if its state is 'New' or 'Cancelled'.")
105+
for record in self:
106+
if record.state not in ['new', 'cancelled']:
107+
raise UserError("You can only delete a property if its state is 'New' or 'Cancelled'.")

real_estate/models/estate_property_offer.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ def action_accept(self):
4545
raise UserError("An offer has already been accepted.")
4646
offer.state = 'accepted'
4747
offer.property_id.write({
48-
'selling_price': offer.price,
49-
'buyer_id': offer.partner_id.id,
48+
'selling_price': offer.price,
49+
'buyer_id': offer.partner_id.id,
5050
'state': 'offer_accepted'
5151
})
5252
return True
@@ -57,13 +57,13 @@ def action_refuse(self):
5757
return True
5858

5959
@api.model_create_multi
60-
def create(self, vals):
61-
property_id = vals.get('property_id')
62-
price = vals.get('price')
63-
property_obj = self.env['estate.property'].browse(property_id)
64-
existing_offers = property_obj.offer_ids.filtered(lambda o: o.price >= price)
65-
if existing_offers:
66-
raise ValidationError("You cannot create an offer with a lower or equal price than existing offers.")
67-
property_obj.state = 'offer_received'
60+
def create(self, vals_list):
61+
for vals in vals_list:
62+
price = vals.get('price')
63+
property_obj = self.env['estate.property'].browse(vals.get('property_id'))
64+
existing_offers = property_obj.offer_ids.filtered(lambda o: o.price >= price)
65+
if existing_offers:
66+
raise ValidationError("You cannot create an offer with a lower or equal price than existing offers.")
67+
property_obj.state = 'offer_received'
6868

69-
return super().create(vals)
69+
return super().create(vals_list)

real_estate/view/estate_property_offer_views.xml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,9 @@
1414
<form string="Property Offer">
1515
<header>
1616
<button name="action_accept" string="Accept" type="object"
17-
class="btn-primary"
1817
invisible="state != 'accepted'"/>
1918

2019
<button name="action_refuse" string="Refuse" type="object"
21-
class="btn-secondary"
2220
invisible="state == 'accepted'"/>
2321
</header>
2422

@@ -42,7 +40,6 @@
4240
decoration-success="state == 'accepted'">
4341
<field name="price"/>
4442
<field name="partner_id"/>
45-
<field name="state" invisible="1"/>
4643
<button name="action_accept" type="object" string="" icon="fa-check"/>
4744
<button name="action_refuse" type="object" string="" icon="fa-times"/>
4845
</list>

real_estate/view/estate_property_views.xml

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
<field name="state"/>
1515
<field name="expected_price"/>
1616
<field name="selling_price"/>
17-
<field name="availability_date" optional="show" invisible="1"/>
1817
<field name="state"/>
1918
<field name="bedrooms"/>
2019
<field name="availability_date"/>
@@ -33,11 +32,9 @@
3332
<form string="Estate Property">
3433
<header>
3534
<button name="action_sold" string="Sold" type="object"
36-
class="btn-primary"
3735
invisible="state != 'offer_accepted'"/>
3836

3937
<button name="action_cancel" string="Cancel" type="object"
40-
class="btn-secondary"
4138
invisible="state in ('sold', 'cancelled')"/>
4239
<field name="state" widget="statusbar"/>
4340
</header>
@@ -86,18 +83,16 @@
8683
<field name="offer_ids">
8784
<list editable="bottom"
8885
decoration-success="state == 'accepted'"
89-
decoration-danger="state == 'refused'">
86+
decoration-danger="state == 'refused'">
9087
<field name="price"/>
9188
<field name="partner_id"/>
9289
<field name="state"/>
9390
<field name="validity"/>
9491
<field name="date_deadline"/>
9592
<button name="action_accept" string="Accept" type="object"
96-
class="btn-primary"
97-
invisible="state in ('accepted','refused')"/>
98-
<button name="action_refuse" string="Refuse" type="object"
99-
class="btn-secondary"
100-
invisible="state in ('accepted','refused')"/>
93+
invisible="state in ('accepted','refused')"/>
94+
<button name="action_refuse" string="Refuse" type="object"
95+
invisible="state in ('accepted','refused')"/>
10196
</list>
10297
</field>
10398

0 commit comments

Comments
 (0)