Skip to content

Commit 635f492

Browse files
committed
[IMP] estate: kanban view for properties
1 parent 7c34470 commit 635f492

File tree

7 files changed

+48
-13
lines changed

7 files changed

+48
-13
lines changed

estate/models/estate_property.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from odoo import api, fields, models, _
1+
from odoo import api, fields, models
22
from odoo.exceptions import UserError, ValidationError
33
from odoo.tools.float_utils import float_compare, float_is_zero
44
from dateutil.relativedelta import relativedelta
@@ -63,7 +63,7 @@ class EstateProperty(models.Model):
6363
def _check_selling_price(self):
6464
for record in self:
6565
if not float_is_zero(record.selling_price, precision_digits=2) and float_compare(record.selling_price, record.expected_price * 0.9, precision_digits=2) <= 0:
66-
raise ValidationError("The selling price cannot be lower than 90 percent of the expected price.")
66+
raise ValidationError(self.env._("The selling price cannot be lower than 90 percent of the expected price."))
6767

6868

6969
@api.depends('living_area', 'garden_area')
@@ -81,7 +81,7 @@ def _compute_best_price(self):
8181
def _prevent_property_deletion(self):
8282
for record in self:
8383
if record.state not in ('new', 'cancelled'):
84-
raise UserError(_("Only new or cancelled properties can be deleted."))
84+
raise UserError(self.env._("Only new or cancelled properties can be deleted."))
8585

8686
@api.onchange('garden')
8787
def _onchange_garden(self):
@@ -97,13 +97,13 @@ def action_set_sold(self):
9797
if record.state != 'cancelled':
9898
record.state = 'sold'
9999
else:
100-
raise UserError(_("Sold properties cannot be cancelled."))
100+
raise UserError(self.env._("Sold properties cannot be cancelled."))
101101
return True
102102

103103
def action_set_cancelled(self):
104104
for record in self:
105105
if record.state != 'sold':
106106
record.state = 'cancelled'
107107
else:
108-
raise UserError(_("Sold properties cannot be cancelled."))
108+
raise UserError(self.env._("Sold properties cannot be cancelled."))
109109
return True

estate/models/estate_property_offer.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from odoo import api, fields, models, _
1+
from odoo import api, fields, models
22
from odoo.exceptions import UserError
33
from dateutil.relativedelta import relativedelta
44

@@ -32,9 +32,9 @@ def _compute_date_deadline(self):
3232
def create(self, vals_list):
3333
for vals in vals_list:
3434
if self.price < self.env['estate.property'].browse(vals['property_id']).best_price:
35-
raise UserError(_("You cannot put in an offer that is lower than the current best price."))
35+
raise UserError(self.env_("You cannot put in an offer that is lower than the current best price."))
3636
self.env['estate.property'].browse(vals['property_id']).state = 'offer_received'
37-
return super(EstatePropertyOffer, self).create(vals_list)
37+
return super().create(vals_list)
3838

3939
def _inverse_date_deadline(self):
4040
for record in self:

estate/security/ir.model.access.csv

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ id,name,model_id/id,group_id/id,perm_read,perm_write,perm_create,perm_unlink
22
estate.access_estate_property,access_estate_property,estate.model_estate_property,base.group_user,1,1,1,1
33
estate.access_estate_property_type,access_estate_property_type,estate.model_estate_property_type,base.group_user,1,1,1,1
44
estate.access_estate_property_tag,access_estate_property_tag,estate.model_estate_property_tag,base.group_user,1,1,1,1
5-
estate.access_estate_property_offer,access_estate_property_offer,estate.model_estate_property_offer,base.group_user,1,1,1,1
5+
estate.access_estate_property_offer,access_estate_property_offer,estate.model_estate_property_offer,base.group_user,1,1,1,1

estate/views/estate_property_views.xml

+36-1
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,41 @@
100100
</field>
101101
</record>
102102

103+
<record id="estate_property_view_kanban" model="ir.ui.view">
104+
<field name="name">estate.property.kanban</field>
105+
<field name="model">estate.property</field>
106+
<field name="arch" type="xml">
107+
<kanban default_group_by="property_type_id">
108+
<field name="state"/>
109+
<templates>
110+
<t t-name="kanban-box">
111+
<div>
112+
<strong class="o_kanban_record_title">
113+
<field name="name"/>
114+
</strong>
115+
<div class="o_kanban_record_subtitle">
116+
Expected Price:
117+
<field name="expected_price" widget="monetary"/>
118+
</div>
119+
<t t-debug=""/>
120+
<div t-if="record.state.raw_value == 'offer_received'" class="o_kanban_record_subtitle">
121+
Best Price:
122+
<field name="best_price" widget="monetary"/>
123+
</div>
124+
<div t-if="['offer_accepted','sold'].includes(record.state.raw_value)" class="o_kanban_record_subtitle">
125+
Selling Price:
126+
<field name="selling_price" widget="monetary"/>
127+
</div>
128+
<div>
129+
<field name="property_tag_ids"/>
130+
</div>
131+
</div>
132+
</t>
133+
</templates>
134+
</kanban>
135+
</field>
136+
</record>
137+
103138
<record id="estate_property_view_search" model="ir.ui.view">
104139
<field name="name">estate.property.search</field>
105140
<field name="model">estate.property</field>
@@ -134,7 +169,7 @@
134169
<record id="estate_property_action" model="ir.actions.act_window">
135170
<field name="name">Estate Property</field>
136171
<field name="res_model">estate.property</field>
137-
<field name="view_mode">list,form</field>
172+
<field name="view_mode">list,form,kanban</field>
138173
<field name="context">{'search_default_state':True}</field>
139174
</record>
140175

estate_account/__init__.py

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

estate_account/models/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
from . import estate_property
1+
from . import estate_property

estate_account/models/estate_property.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,4 @@ def action_set_sold(self):
2323
]
2424
}
2525
self.env['account.move'].create(invoice_values)
26-
return super(EstateProperty, self).action_set_sold()
26+
return super().action_set_sold()

0 commit comments

Comments
 (0)