Skip to content

Commit

Permalink
[IMP] estate: added the sprinkles
Browse files Browse the repository at this point in the history
invisible attribute
added order
  • Loading branch information
niku-odoo committed Aug 13, 2024
1 parent 773fa81 commit f25b821
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 3 deletions.
4 changes: 2 additions & 2 deletions estate/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
'view/estate_property_views.xml',
'view/estate_property_type_view.xml',
'view/estate_property_tag_view.xml',
'view/estate_menus.xml',
'view/estate_property_offer_view.xml'
'view/estate_property_offer_view.xml',
'view/estate_menus.xml'
],
'installable': True,
'application': True,
Expand Down
2 changes: 2 additions & 0 deletions estate/models/estate_property_offer.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ class EstatePropertyOffer(models.Model):
)
property_id = fields.Many2one(
'estate.property', string='Property', required=True)
property_type_id = fields.Many2one(
"estate.property.type", store=True, related='property_id.property_type_id')

@api.depends('create_date', 'validity')
def _computed_date_deadline(self):
Expand Down
14 changes: 13 additions & 1 deletion estate/models/estate_property_type.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from odoo import models, fields
from odoo import models, fields, api


class EstatePropertytype(models.Model):
Expand All @@ -15,3 +15,15 @@ class EstatePropertytype(models.Model):
]
property_ids = fields.One2many('estate.property', "property_type_id")
sequence = fields.Integer('Sequence')

offer_ids = fields.One2many(
"estate.property.offer", string="Offer", inverse_name='property_type_id')
offer_count = fields.Integer(
string="Offer Count",
compute='_compute_offer_count'
)

@api.depends("offer_ids")
def _compute_offer_count(self):
for record in self:
record.offer_count = len(record.offer_ids)
7 changes: 7 additions & 0 deletions estate/view/estate_property_offer_view.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
<?xml version="1.0"?>
<odoo>
<record id="estate_property_offer_action" model="ir.actions.act_window">
<field name="name">Estate Properties Offer</field>
<field name="res_model">estate.property.offer</field>
<field name="view_mode">tree,form</field>
<field name="domain">[('property_type_id', '=', active_id)]</field>
</record>

<record id="estate_property_offer_tree" model="ir.ui.view">
<field name="name">estate.property.offer.tree</field>
<field name="model">estate.property.offer</field>
Expand Down
6 changes: 6 additions & 0 deletions estate/view/estate_property_type_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@
<field name="arch" type="xml">
<form string="Estate Property Type">
<sheet>
<div name="button_box">
<button name="%(estate.estate_property_offer_action)d" type="action"
class="oe_stat_button" icon="oi-view-list">
<field name="offer_count" widget="statinfo" string="Offers" />
</button>
</div>
<group>
<field name="name" />
</group>
Expand Down

0 comments on commit f25b821

Please sign in to comment.