Skip to content

Commit 47bb63a

Browse files
author
KAEI
committed
[ADD] estate: Server Framework 101
[ADD] estate: All features added [FIX] estate fixed format [FIX] estate: formating [FIX] estate: format errors [FIX] estate: format errors [FIX] estate: parse error [FIX] estate: parse error [FIX] estate: format errors Followed the changes in the pr
1 parent 6ca2c82 commit 47bb63a

18 files changed

+76
-62
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,3 +127,5 @@ dmypy.json
127127

128128
# Pyre type checker
129129
.pyre/
130+
131+
.vscode/

estate/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
21
from . import models

estate/__manifest__.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,21 @@
33
'depends': ['base'],
44
'application': True,
55
'installable': True,
6+
<<<<<<< HEAD
67
'data': [
8+
=======
9+
'data': [
10+
>>>>>>> e2f153c ([ADD] estate: Server Framework 101)
711
'security/ir.model.access.csv',
812
'views/estate_property_views.xml',
913
'views/estate_property_type_views.xml',
1014
'views/estate_property_tag_views.xml',
1115
'views/estate_property_offer_views.xml',
1216
'views/res_user_views.xml',
1317
'views/estate_menus.xml',
18+
<<<<<<< HEAD
1419
]
20+
=======
21+
]
22+
>>>>>>> e2f153c ([ADD] estate: Server Framework 101)
1523
}

estate/models/__init__.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
21
from . import estate_property
3-
from . import estate_property_type
4-
from . import estate_property_tag
52
from . import estate_property_offer
3+
from . import estate_property_tag
4+
from . import estate_property_type
65
from . import res_users

estate/models/estate_property.py

Lines changed: 32 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
from odoo import api, fields, models, exceptions
2-
from odoo.exceptions import ValidationError
3-
from odoo.tools import float_utils
41
from dateutil import relativedelta
52

3+
from odoo import api, fields, models
4+
from odoo.exceptions import UserError, ValidationError
5+
from odoo.tools import float_utils
6+
67

78
class EstateProperty(models.Model):
89
_name = "estate.property"
@@ -22,13 +23,25 @@ class EstateProperty(models.Model):
2223
garden = fields.Boolean()
2324
garden_area = fields.Integer()
2425
garden_orientation = fields.Selection(
25-
selection=[('North', 'North'), ('South', 'South'), ('East', 'East'), ('West', 'West')])
26+
selection=[
27+
('north', 'North'),
28+
('south', 'South'),
29+
('east', 'East'),
30+
('west', 'West')
31+
],
32+
)
2633
active = fields.Boolean(default=True)
2734
status = fields.Selection(
28-
selection=[('New', 'New'), ('Offer Received', 'Offer Received'),
29-
('Offer Accepted', 'Offer Accepted'), ('Sold', 'Sold'), ('Cancelled', 'Cancelled')],
30-
default='New')
31-
property_type_id = fields.Many2one("estate.property.type", string="Property Type")
35+
selection=[
36+
('new', 'New'),
37+
('offer_received', 'Offer Received'),
38+
('offer_accepted', 'Offer Accepted'),
39+
('sold', 'Sold'),
40+
('cancelled', 'Cancelled')
41+
],
42+
default='New',
43+
)
44+
property_type_id = fields.Many2one('estate.property.type', string='Property Type')
3245
buyer_id = fields.Many2one('res.partner', string='Buyer', copy=False)
3346
salesperson_id = fields.Many2one('res.users', string='Salesperson', default=lambda self: self.env.user)
3447
tag_ids = fields.Many2many('estate.property.tag', string='Tags')
@@ -54,32 +67,32 @@ def _compute_best_price(self):
5467
def _onchange_garden(self):
5568
if self.garden:
5669
self.garden_area = 10
57-
self.garden_orientation = 'North'
70+
self.garden_orientation = 'north'
5871
else:
5972
self.garden_area = 0
60-
self.garden_orientation = None
73+
self.garden_orientation = False
6174

6275
def action_sold(self):
63-
if self.status != 'Cancelled':
64-
self.status = 'Sold'
76+
if self.status != 'cancelled':
77+
self.status = 'sold'
6578
else:
66-
raise exceptions.UserError('Cancelled properties can not be sold')
79+
raise UserError("Cancelled properties can not be sold")
6780
return True
6881

6982
def action_cancel(self):
70-
if self.status != 'Sold':
71-
self.status = 'Cancelled'
83+
if self.status != 'sold':
84+
self.status = 'cancelled'
7285
else:
73-
raise exceptions.UserError('Sold properties can not be cancelled')
86+
raise UserError("Sold properties can not be cancelled")
7487
return True
7588

7689
@api.constrains('selling_price')
7790
def _check_date_end(self):
7891
for record in self:
79-
if (record.status != 'New') & (float_utils.float_compare(record.selling_price, 0.9 * record.expected_price, 1) == -1):
92+
if (record.status != 'new') & (float_utils.float_compare(record.selling_price, 0.9 * record.expected_price, 1) == -1):
8093
raise ValidationError("selling price cannot be lower than 90% of the expected price.")
8194

8295
@api.ondelete(at_uninstall=False)
8396
def _unlink_if_user_inactive(self):
84-
if (self.status == 'Cancelled') | (self.status == 'New'):
85-
raise exceptions.UserError("Can't delete new or cancelled property")
97+
if (self.status == 'cancelled') | (self.status == 'new'):
98+
raise UserError("Can't delete new or cancelled property")

estate/models/estate_property_offer.py

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
from odoo import api, fields, models, exceptions
2-
from odoo.tools import float_utils
31
from dateutil import relativedelta
42

3+
from odoo import api, fields, models
4+
from odoo.exceptions import UserError
5+
from odoo.tools import float_utils
6+
57

68
class EstatePropertyOffer(models.Model):
79
_name = "estate.property.offer"
@@ -10,8 +12,9 @@ class EstatePropertyOffer(models.Model):
1012

1113
price = fields.Float()
1214
status = fields.Selection(
13-
selection=[('Accepted', 'Accepted'), ('Refused', 'Refused')],
14-
copy=False)
15+
selection=[('accepted', 'Accepted'), ('refused', 'Refused')],
16+
copy=False,
17+
)
1518
partner_id = fields.Many2one('res.partner', required=True)
1619
property_id = fields.Many2one('estate.property', required=True)
1720
validity = fields.Integer(default=7)
@@ -36,24 +39,20 @@ def _inverse_deadline_date(self):
3639

3740
def action_offer_accept(self):
3841
if float_utils.float_is_zero(self.property_id.selling_price, 1):
39-
self.status = 'Accepted'
42+
self.status = 'accepted'
4043
self.property_id.selling_price = self.price
4144
self.property_id.buyer_id = self.partner_id
4245
else:
43-
raise exceptions.UserError('You already accepted an offer for this property')
44-
return True
46+
raise UserError("You already accepted an offer for this property")
4547

4648
def action_offer_refuse(self):
4749
if not self.status:
48-
self.status = 'Refused'
49-
return True
50+
self.status = 'refused'
5051

51-
# @api.model
5252
def create(self, vals):
5353
current_property = self.env['estate.property'].browse(vals['property_id'])
54-
if current_property.status == 'New':
55-
current_property.status = 'Offer Received'
56-
# print(vals['price'], " ", current_property.best_price)
54+
if current_property.status == 'new':
55+
current_property.status = 'offer_received'
5756
if (vals['price'] < current_property.best_price):
58-
raise exceptions.UserError("This property already has better offers")
57+
raise UserError("This property already has better offers")
5958
return super().create(vals)

estate/models/estate_property_type.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from odoo import fields, models, api
1+
from odoo import api, fields, models
22

33

44
class EstatePropertyType(models.Model):

estate/models/res_users.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ class ResUsers(models.Model):
55
_inherit = "res.users"
66

77
property_ids = fields.One2many('estate.property', 'salesperson_id',
8-
domain="['|',('status', '=', 'New'),('status', '=', 'Offer Received')]")
8+
domain="['|',('status', '=', 'new'),('status', '=', 'offer_received')]")

estate/views/estate_menus.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@
88
</menuitem>
99
</menuitem>
1010
</data>
11-
</odoo>
11+
</odoo>

estate/views/estate_property_offer_views.xml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,13 @@
1212
<field name="model">estate.property.offer</field>
1313
<field name="arch" type="xml">
1414
<list string="Offer" editable="bottom"
15-
decoration-success="status=='Accepted'" decoration-danger="status=='Refused'">
15+
decoration-success="status=='accepted'" decoration-danger="status=='refused'">
1616
<field name="price"/>
1717
<field name="partner_id"/>
1818
<field name="validity"/>
1919
<field name="date_deadline" string="Deadline Date"/>
2020
<button name="action_offer_accept" string="Accept" type="object" icon="fa-check" invisible="status"/>
2121
<button name="action_offer_refuse" string="Refuse" type="object" icon="fa-times" invisible="status"/>
22-
<!-- <field name="status"/> -->
2322
</list>
2423
</field>
2524
</record>
@@ -42,4 +41,4 @@
4241
</field>
4342
</record>
4443
</data>
45-
</odoo>
44+
</odoo>

0 commit comments

Comments
 (0)