Skip to content

Commit 65040a4

Browse files
committed
[IMP]: estate: add kanban view
1 parent 492a823 commit 65040a4

File tree

5 files changed

+33
-12
lines changed

5 files changed

+33
-12
lines changed

estate/models/estate_property.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,8 @@ def _check_selling_price(self):
105105
raise ValidationError(
106106
"The selling price cannot be lower than 90 precent of the expected price."
107107
)
108+
108109
@api.ondelete(at_uninstall=False)
109110
def _unlink_if_valid_state(self):
110111
if any(record.state not in ('new', 'cancelled') for record in self):
111-
raise UserError("Can't delete a property that is not New or Cancelled!")
112+
raise UserError("Can't delete a property that is not New or Cancelled!")

estate/models/estate_property_offer.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class EstatePropertyOffer(models.Model):
1919
property_id = fields.Many2one('estate.property', string='Estate Property', required=True)
2020
validity = fields.Integer('Validity', default=7)
2121
date_deadline = fields.Datetime('Deadline', compute='_compute_date_deadline', inverse='_inverse_date_deadline')
22-
property_type_id = fields.Many2one(related='property_id.property_type_id', store=True)
22+
property_type_id = fields.Many2one(related='property_id.property_type_id', store=True)
2323
_check_positive_price = models.Constraint(
2424
'CHECK(price >= 0)',
2525
'The price must be positive.',
@@ -56,7 +56,7 @@ def action_refuse_offer(self):
5656
def create(self, vals):
5757
for val in vals:
5858
linked_property = self.env['estate.property'].browse(val['property_id'])
59-
if val['price']< linked_property.best_price:
59+
if val['price'] < linked_property.best_price:
6060
raise exceptions.UserError("An offer with a higher price already exists")
6161
linked_property.state = 'offer_received'
62-
return super(EstatePropertyOffer, self).create(vals)
62+
return super().create(vals)

estate/models/estate_user.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
from odoo import models, fields
22

3+
34
class EstateUser(models.Model):
45
_inherit = 'res.users'
56

67
property_ids = fields.One2many(
78
'estate.property', 'sales_person_id',
89
string='Real Estate Properties',
9-
domain=[('state', 'in', ('new','cancelled', 'offer_received'))]
10-
)
10+
domain=[('state', 'in', ('new', 'cancelled', 'offer_received'))]
11+
)

estate/views/estate_property_views.xml

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
</record>
2323

2424
<record id="estate_property_view_form" model="ir.ui.view">
25-
<field name="name">estate.property.form</field>
25+
<field name="name">estate.property.view.form</field>
2626
<field name="model">estate.property</field>
2727
<field name="arch" type="xml">
2828
<form string="Estate Property">
@@ -84,8 +84,26 @@
8484
</field>
8585
</record>
8686

87-
<record id="estate_property_view_tree" model="ir.ui.view">
88-
<field name="name">estate.property.list</field>
87+
<record id="estate_property_view_kanban" model="ir.ui.view">
88+
<field name="name">estate.property.view.kanban</field>
89+
<field name="model">estate.property</field>
90+
<field name="arch" type="xml">
91+
<kanban>
92+
<templates>
93+
<t t-name="card">
94+
<div>
95+
<strong>
96+
<field name="name" />
97+
</strong>
98+
</div>
99+
</t>
100+
</templates>
101+
</kanban>
102+
</field>
103+
</record>
104+
105+
<record id="estate_property_view_list" model="ir.ui.view">
106+
<field name="name">estate.property.view.list</field>
89107
<field name="model">estate.property</field>
90108
<field name="arch" type="xml">
91109
<list string="Properties"
@@ -107,7 +125,7 @@
107125
<record id="estate_property_action" model="ir.actions.act_window">
108126
<field name="name">Estate Property</field>
109127
<field name="res_model">estate.property</field>
110-
<field name="view_mode">list,form</field>
128+
<field name="view_mode">list,kanban,form</field>
111129
<field name="help" type="html">
112130
<p class="o_view_nocontent_smiling_face">
113131
List all your properties

estate_account/models/estate_property.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
11
from odoo import models, Command
22

3+
34
class EstateProperty(models.Model):
45
_inherit = 'estate.property'
56

67
def action_sold_property(self):
78
invoice_vals = {
8-
"name": "INV° "+ str(self.id),
9+
"name": "INV° " + str(self.id),
910
'partner_id': self.buyer_id.id,
1011
'move_type': 'out_invoice',
1112
"line_ids": [
1213
Command.create({
1314
"name": "6% of the selling price",
1415
"quantity": "1",
15-
"price_unit": self.selling_price*0.06,
16+
"price_unit": self.selling_price * 0.06,
1617
}),
1718
Command.create({
1819
"name": "administrative fees",

0 commit comments

Comments
 (0)