-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ADD] estate: Added inheritance to extend the functionality of curren…
…t model Chapter-12: Implement inheritance for CRUD methods and model extensions - Added custom business logic to prevent property deletion if the state is not 'New' or 'Canceled'. - Modified property state to 'Offer Received' upon offer creation. - Prevented creation of offers with a lower price than existing ones. - Extended `res.users` model by adding `property_ids` field to display salesperson's properties. - Implemented view inheritance to include the new field in the user form view.
- Loading branch information
Showing
6 changed files
with
60 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
from odoo import models, fields | ||
|
||
|
||
class ResUser(models.Model): | ||
_inherit = "res.users" | ||
|
||
property_ids = fields.One2many( | ||
"estate.property", | ||
"salesman_id", | ||
domain="['|', ('state', '=', 'new'), ('state', '=', 'offer received')]" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?xml version="1.0"?> | ||
<odoo> | ||
<record id="view_users_form_inherited" model="ir.ui.view"> | ||
<field name="name">res.users.form.inherit.properties</field> | ||
<field name="model">res.users</field> | ||
<field name="inherit_id" ref="base.view_users_form"/> | ||
<field name="arch" type="xml"> | ||
<xpath expr="//notebook" position="inside"> | ||
<page string="Properties"> | ||
<field name="property_ids"> | ||
<tree string="Properties"> | ||
<field name="name"/> | ||
<field name="property_type_id"/> | ||
<field name="state" /> | ||
<field name="postcode"/> | ||
<field name="tag_ids" widget="many2many_tags" /> | ||
<field name="bedrooms"/> | ||
<field name="living_area"/> | ||
<field name="expected_price"/> | ||
<field name="selling_price"/> | ||
</tree> | ||
</field> | ||
</page> | ||
</xpath> | ||
</field> | ||
</record> | ||
</odoo> |