-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[IMP] estate: added computed fields, onchanges, error handling and co…
…nstrains Day 4: - Implemented computed field total_area as the sum of living_area and garden_area in estate.property. - Added total_area to estate_property_views.xml. - Used computed field with mapped() to define best_price as the maximum offer price in estate.property. - Added inverse method for date_deadline in estate.property.offer - date_deadline is computed as create_date + validity days. - Implemented inverse method to update validity based on date_deadline. - Added onchange method to auto-set garden_area (10) and orientation (North) when garden is True, and reset values when unset. - Implemented property state transitions: added functionality to cancel and mark a property as sold. - Used UserError for validation and error handling in business logic. - Applied SQL constraints: - estate.property: applied expected_price > 0, selling_price ≥ 0. - estate.property.offer: applied offer_price > 0. - Implemented unique constraints on estate.property.tag and estate.property.type names. - Implemented Python constraint in estate.property to ensure selling_price is at least 90% of expected_price.
- Loading branch information
Showing
7 changed files
with
138 additions
and
18 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
# Part of Odoo. See LICENSE file for full copyright and licensing details. | ||
|
||
from . import estate_property | ||
from . import estate_property | ||
from . import estate_property_type | ||
from . import estate_property_tag | ||
from . import estate_property_offer |
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 |
---|---|---|
@@ -1,10 +1,13 @@ | ||
# Part of Odoo. See LICENSE file for full copyright and licensing details. | ||
|
||
from odoo import models,fields | ||
from odoo import models, fields | ||
|
||
|
||
class EstatePropertyTag(models.Model): | ||
_name = "estate.property.tag" | ||
_description = "tags attached to property" | ||
|
||
name = fields.Char(string="Property Tag" , required=True) | ||
_sql_constraints = [ | ||
("unique_tag_name", "UNIQUE(name)", "Property tag name must be unique."), | ||
] | ||
|
||
name = fields.Char(string="Property Tag", required=True) |
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