Skip to content

Commit 716c663

Browse files
committed
[IMP] estate: Add stat button
1 parent 1d69faf commit 716c663

File tree

4 files changed

+29
-2
lines changed

4 files changed

+29
-2
lines changed

estate/models/estate_property_offer.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ class EstatePropertyOffer(models.Model):
2525
property_id = fields.Many2one("estate.property", string="Property", required=True)
2626
validity = fields.Integer("Validity (days)")
2727
deadline = fields.Date("Deadline", compute="_compute_deadline", inverse="_inverse_deadline")
28+
property_type_id = fields.Many2one(
29+
"estate.property.type", related="property_id.property_type_id", string="Property Type")
2830

2931
@api.depends("validity")
3032
def _compute_deadline(self):

estate/models/estate_property_type.py

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

33

44
class EstatePropertyType(models.Model):
@@ -13,3 +13,15 @@ class EstatePropertyType(models.Model):
1313
name = fields.Char("Name", required=True)
1414
sequence = fields.Integer("Sequence", default=10)
1515
property_ids = fields.One2many("estate.property", "property_type_id", string="Properties")
16+
offer_ids = fields.One2many("estate.property.offer", "property_type_id", string="Offers")
17+
offer_count = fields.Integer(string="Offers Count", compute="_compute_offer_count")
18+
19+
@api.depends('offer_ids')
20+
def _compute_offer_count(self):
21+
for record in self:
22+
record.offer_count = len(record.offer_ids)
23+
24+
def action_view_offers(self):
25+
res = self.env.ref("estate.estate_property_offer_action").read()[0]
26+
res["domain"] = [("id", "in", self.offer_ids.ids)]
27+
return res

estate/views/estate_property_offer_views.xml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
<odoo>
2-
<record id="estate_property_offer_view_list" model="ir.ui.view">
2+
<record id="estate_property_offer_action" model="ir.actions.act_window">
3+
<field name="name">Property Offers</field>
4+
<field name="res_model">estate.property.offer</field>
5+
<field name="view_mode">list,form</field>
6+
</record>
7+
<record id="estate_property_offer_list" model="ir.ui.view">
38
<field name="name">estate.property.offer.list</field>
49
<field name="model">estate.property.offer</field>
510
<field name="arch" type="xml">

estate/views/estate_property_type_views.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,14 @@
1515
<field name="name"/>
1616
</h1>
1717
</div>
18+
<div class="oe_button_box" name="button_box">
19+
<button name="action_view_offers"
20+
type="object"
21+
class="oe_stat_button"
22+
icon="fa-tags">
23+
<field name="offer_count" widget="statinfo" string="Offers"/>
24+
</button>
25+
</div>
1826
<notebook>
1927
<page string="Properties">
2028
<field name="property_ids">

0 commit comments

Comments
 (0)