-
Notifications
You must be signed in to change notification settings - Fork 2.8k
19.0 app traning raibr #1074
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
ramezlahzy
wants to merge
15
commits into
odoo:19.0
Choose a base branch
from
odoo-dev:19.0-app-traning-raibr
base: 19.0
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
19.0 app traning raibr #1074
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
9078a4d
[ADD] estate: Initial module setup
b46dc7d
[ADD] estate: Complete Chapter 1 requirements
9d3e35d
[ADD] estate: Complete Chapter 2 requirements
afbf975
[ADD] estate: Complete Chapter 3 requirements
c79e559
[ADD] estate: Minimum security configuration (Chapter 4)
ramezlahzy 27d7a39
[ADD] estate: Property views and menus (Chapter 5)
ramezlahzy fbb6c5e
[ADD] estate: Search filters and grouping options (Chapter 6)
ramezlahzy 06b0b67
[FIX] estate: Chapter 7 fixes
ramezlahzy e76dbf5
[FIX] estate: Chapter 7 corrections
23dc969
[ADD] estate: Implement property offers with computed fields and onch…
7d28247
[ADD] estate(Chapter 9): Add property state workflow with sold/cancel…
fcbae9f
[IMP] estate: Add .DS_Store to .gitignore
90bef7f
[IMP] estate: Fix ruff linting issues
806e103
[FIX] estate: replace invalid models.Constraint with _sql_constraints
f073fa7
[FIX] estate: replace invalid models.Constraint with _sql_constraints
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,3 @@ | ||
| # Part of Odoo. See LICENSE file for full copyright and licensing details. | ||
|
|
||
| from . import models |
This file contains hidden or 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,28 @@ | ||
| # Part of Odoo. See LICENSE file for full copyright and licensing details. | ||
| { | ||
| "name": "Real Estate Advertisement", | ||
| "author": "Odoo", | ||
| "category": "Sales/Real Estate", | ||
| "sequence": 15, | ||
| "summary": "Manage property listings and real estate advertisements", | ||
| "description": """ | ||
| Real Estate Advertisement Management | ||
| ==================================== | ||
| This module allows you to manage real estate properties, including: | ||
| * Property listings with detailed information | ||
| * Property types and tags | ||
| * Property offers and negotiations | ||
| * Sales tracking | ||
| """, | ||
| "depends": ["base"], | ||
| "data": [ | ||
| "security/ir.model.access.csv", | ||
| "views/estate_property_views.xml", | ||
| "views/estate_property_offer_views.xml", | ||
| "views/estate_property_type_views.xml", | ||
| "views/estate_property_tag_views.xml", | ||
| "views/estate_menus.xml", | ||
| ], | ||
| "application": True, | ||
| "license": "LGPL-3", | ||
| } |
This file contains hidden or 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,6 @@ | ||
| # Part of Odoo. See LICENSE file for full copyright and licensing details. | ||
|
|
||
| from . import estate_property | ||
| from . import estate_property_type | ||
| from . import estate_property_tag | ||
| from . import estate_property_offer |
This file contains hidden or 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,100 @@ | ||
| # Part of Odoo. See LICENSE file for full copyright and licensing details. | ||
|
|
||
| from odoo import api, fields, models | ||
| from odoo.exceptions import UserError, ValidationError | ||
| from odoo.tools.float_utils import float_compare, float_is_zero | ||
|
|
||
|
|
||
| class EstateProperty(models.Model): | ||
| _name = 'estate.property' | ||
| _description = "Real Estate Property" | ||
| _order = 'id desc' | ||
| _check_expected_price = models.Constraint('Check(expected_price > 0)', "The expected price must be strictly positive.") | ||
| _check_selling_price = models.Constraint('Check(selling_price >= 0)', "The selling price must be positive.") | ||
|
|
||
| name = fields.Char(required=True, string="Name") | ||
| description = fields.Text(string="Description") | ||
| postcode = fields.Char(string="Postcode") | ||
| date_availability = fields.Date(string="Available From") | ||
| expected_price = fields.Float(required=True, string="Expected Price") | ||
| selling_price = fields.Float(string="Selling Price") | ||
| bedrooms = fields.Integer(string="Bedrooms") | ||
| living_area = fields.Integer(string="Living Area (sqm)") | ||
| facades = fields.Integer(string="Facades") | ||
| garage = fields.Boolean(string="Garage") | ||
| garden = fields.Boolean(string="Garden") | ||
| garden_area = fields.Integer(string="Garden Area (sqm)") | ||
| garden_orientation = fields.Selection( | ||
| selection=[ | ||
| ('north', "North"), | ||
| ('south', "South"), | ||
| ('east', "East"), | ||
| ('west', "West"), | ||
| ], | ||
| string="Garden Orientation", | ||
| ) | ||
| state = fields.Selection( | ||
| selection=[ | ||
| ('new', "New"), | ||
| ('offer_received', "Offer Received"), | ||
| ('offer_accepted', "Offer Accepted"), | ||
| ('sold', "Sold"), | ||
| ('cancelled', "Cancelled"), | ||
| ], | ||
| default='new', | ||
| required=True, | ||
| string="Status", | ||
| ) | ||
| buyer_id = fields.Many2one(comodel_name='res.partner', string="Buyer") | ||
| property_type_id = fields.Many2one(comodel_name='estate.property.type', string="Property Type") | ||
| tag_ids = fields.Many2many(comodel_name='estate.property.tag', string="Tags") | ||
| offer_ids = fields.One2many( | ||
| comodel_name='estate.property.offer', | ||
| inverse_name='property_id', | ||
| string="Offers", | ||
| ) | ||
| total_area = fields.Integer(compute='_compute_total_area', string="Total Area (sqm)") | ||
| best_price = fields.Float(compute='_compute_best_price', string="Best Offer Price") | ||
|
|
||
| @api.depends('living_area', 'garden_area') | ||
| def _compute_total_area(self): | ||
| for property in self: | ||
| property.total_area = property.living_area + property.garden_area | ||
|
|
||
| @api.depends('offer_ids.price') | ||
| def _compute_best_price(self): | ||
| for property in self: | ||
| if property.offer_ids: | ||
| property.best_price = max(property.offer_ids.mapped('price')) | ||
| else: | ||
| property.best_price = 0.0 | ||
|
|
||
| @api.onchange('garden') | ||
| def _onchange_garden(self): | ||
| if self.garden: | ||
| self.garden_area = 10 | ||
| self.garden_orientation = 'north' | ||
| else: | ||
| self.garden_area = 0 | ||
| self.garden_orientation = False | ||
|
|
||
| @api.constrains('selling_price', 'expected_price') | ||
| def _check_selling_price(self): | ||
| for property in self: | ||
| if not float_is_zero(property.selling_price, precision_digits=2): | ||
| if float_compare(property.selling_price, property.expected_price * 0.9, precision_digits=2) < 0: | ||
| raise ValidationError(self.env._("The selling price cannot be lower than 90% of the expected price.")) | ||
|
|
||
| def action_sold(self): | ||
| for property in self: | ||
| if property.state == 'cancelled': | ||
| raise UserError(self.env._("Cancelled property cannot be sold.")) | ||
| property.state = 'sold' | ||
| return True | ||
|
|
||
| def action_cancel(self): | ||
| for property in self: | ||
| if property.state == 'sold': | ||
| raise UserError(self.env._("Sold property cannot be cancelled.")) | ||
| property.state = 'cancelled' | ||
| return True |
This file contains hidden or 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,57 @@ | ||
| # Part of Odoo. See LICENSE file for full copyright and licensing details. | ||
|
|
||
| from datetime import timedelta | ||
| from odoo import api, fields, models | ||
| from odoo.exceptions import UserError | ||
|
|
||
|
|
||
| class EstatePropertyOffer(models.Model): | ||
| _name = 'estate.property.offer' | ||
| _description = "Real Estate Property Offer" | ||
| _order = 'price desc' | ||
|
|
||
| price = fields.Float(required=True, string="Price") | ||
| _check_price = models.Constraint('Check(price > 0)', "The offer price must be strictly positive.") | ||
| status = fields.Selection(selection=[('accepted', "Accepted"), ('refused', "Refused")], copy=False, string="Status") | ||
| partner_id = fields.Many2one(comodel_name='res.partner', string="Partner", required=True) | ||
| property_id = fields.Many2one(comodel_name='estate.property', string="Property", required=True) | ||
| validity = fields.Integer(default=7, string="Validity (days)") | ||
| date_deadline = fields.Date( | ||
| compute='_compute_date_deadline', | ||
| inverse='_inverse_date_deadline', | ||
| store=True, | ||
| string="Deadline", | ||
| ) | ||
|
|
||
| # self.property_id.status = 'offer_received' when offer is created | ||
| @api.model | ||
| def create(self, vals): | ||
| offer = super().create(vals) | ||
| if offer.property_id.state == 'new': | ||
| offer.property_id.state = 'offer_received' | ||
| return offer | ||
|
|
||
| @api.depends('validity') | ||
| def _compute_date_deadline(self): | ||
| for offer in self: | ||
| offer.date_deadline = fields.Date.today() + timedelta(days=offer.validity) | ||
|
|
||
| def _inverse_date_deadline(self): | ||
| for offer in self: | ||
| if offer.date_deadline: | ||
| offer.validity = (offer.date_deadline - fields.Date.today()).days | ||
|
|
||
| def action_accept(self): | ||
| for offer in self: | ||
| if offer.property_id.offer_ids.filtered(lambda o: o.status == 'accepted' and o.id != offer.id): | ||
| raise UserError(self.env._("Only one offer can be accepted per property.")) | ||
| offer.status = 'accepted' | ||
| offer.property_id.buyer_id = offer.partner_id | ||
| offer.property_id.selling_price = offer.price | ||
| offer.property_id.state = 'offer_accepted' | ||
| return True | ||
|
|
||
| def action_refuse(self): | ||
| for offer in self: | ||
| offer.status = 'refused' | ||
| return True |
This file contains hidden or 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,14 @@ | ||
| # Part of Odoo. See LICENSE file for full copyright and licensing details. | ||
|
|
||
| from odoo import fields, models | ||
|
|
||
|
|
||
| class EstatePropertyTag(models.Model): | ||
| _name = 'estate.property.tag' | ||
| _description = "Real Estate Property Tag" | ||
| _order = 'name' | ||
|
|
||
| _check_unique_name = models.Constraint('UNIQUE(name)', "The tag name must be unique.") | ||
|
|
||
| name = fields.Char(required=True, string="Name") | ||
| color = fields.Integer(string="Color") |
This file contains hidden or 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,19 @@ | ||
| # Part of Odoo. See LICENSE file for full copyright and licensing details. | ||
|
|
||
| from odoo import fields, models | ||
|
|
||
|
|
||
| class EstatePropertyType(models.Model): | ||
| _name = 'estate.property.type' | ||
| _description = "Real Estate Property Type" | ||
| _order = 'name' | ||
| _check_unique_name = models.Constraint('UNIQUE(name)', "The type name must be unique.") | ||
|
|
||
| name = fields.Char(required=True, string="Name") | ||
| sequence = fields.Integer(default=1, string="Sequence") | ||
| property_ids = fields.One2many(comodel_name='estate.property', inverse_name='property_type_id', string="Properties") | ||
| offer_count = fields.Integer(compute='_compute_offer_count', string="Offer Count") | ||
|
|
||
| def _compute_offer_count(self): | ||
| for property_type in self: | ||
| property_type.offer_count = sum(property_type.property_ids.mapped(lambda p: len(p.offer_ids))) |
This file contains hidden or 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,5 @@ | ||
| id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink | ||
| access_estate_property,access_estate_property,model_estate_property,base.group_user,1,1,1,1 | ||
| access_estate_property_type,access_estate_property_type,model_estate_property_type,base.group_user,1,1,1,1 | ||
| access_estate_property_tag,access_estate_property_tag,model_estate_property_tag,base.group_user,1,1,1,1 | ||
| access_estate_property_offer,access_estate_property_offer,model_estate_property_offer,base.group_user,1,1,1,1 | ||
This file contains hidden or 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,35 @@ | ||
| <?xml version="1.0" encoding="utf-8"?> | ||
| <odoo> | ||
| <!-- Main menu --> | ||
| <menuitem id="estate_menu_root" name="Real Estate"/> | ||
|
|
||
| <!-- Properties menu --> | ||
| <menuitem id="estate_property_menu" | ||
| name="Advertisements" | ||
| parent="estate_menu_root"/> | ||
|
|
||
| <menuitem id="estate_property_menu_action" | ||
| name="Properties" | ||
| parent="estate_property_menu" | ||
| action="estate_property_action"/> | ||
|
|
||
| <!-- Settings menu --> | ||
| <menuitem id="estate_settings_menu" | ||
| name="Settings" | ||
| parent="estate_menu_root"/> | ||
|
|
||
| <menuitem id="estate_property_type_menu_action" | ||
| name="Property Types" | ||
| parent="estate_settings_menu" | ||
| action="estate_property_type_action"/> | ||
|
|
||
| <menuitem id="estate_property_tag_menu_action" | ||
| name="Property Tags" | ||
| parent="estate_settings_menu" | ||
| action="estate_property_tag_action"/> | ||
|
|
||
| <menuitem id="estate_property_offer_menu_action" | ||
ramezlahzy marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| name="Property Offers" | ||
| parent="estate_settings_menu" | ||
| action="estate_property_offer_action"/> | ||
| </odoo> | ||
This file contains hidden or 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,53 @@ | ||
| <?xml version="1.0" encoding="utf-8"?> | ||
| <odoo> | ||
| <!-- List View --> | ||
| <record id="estate_property_offer_view_list" model="ir.ui.view"> | ||
| <field name="name">estate.property.offer.view.list</field> | ||
| <field name="model">estate.property.offer</field> | ||
| <field name="arch" type="xml"> | ||
| <list editable="bottom" decoration-danger="status == 'refused'" | ||
| decoration-success="status == 'accepted'"> | ||
| <field name="price" /> | ||
| <field name="partner_id" /> | ||
| <field name="property_id" /> | ||
| <field name="property_id" /> | ||
| <field name="validity" /> | ||
| <field name="date_deadline" /> | ||
| <field name="status" /> | ||
| <button name="action_accept" type="object" icon="fa-check" title="Accept" /> | ||
| <button name="action_refuse" type="object" icon="fa-times" title="Refuse" /> | ||
|
|
||
|
|
||
| </list> | ||
| </field> | ||
| </record> | ||
|
|
||
| <!-- Form View --> | ||
| <record id="estate_property_offer_view_form" model="ir.ui.view"> | ||
| <field name="name">estate.property.offer.view.form</field> | ||
| <field name="model">estate.property.offer</field> | ||
| <field name="arch" type="xml"> | ||
| <form> | ||
| <sheet> | ||
| <group> | ||
| <field name="price" /> | ||
| <field name="partner_id" /> | ||
| <field name="property_id" /> | ||
| <field name="validity" /> | ||
| <field name="date_deadline" /> | ||
| <field name="status" /> | ||
| </group> | ||
| </sheet> | ||
| </form> | ||
| </field> | ||
| </record> | ||
|
|
||
| <!-- Action --> | ||
| <record id="estate_property_offer_action" model="ir.actions.act_window"> | ||
| <field name="name">Property Offers</field> | ||
| <field name="res_model">estate.property.offer</field> | ||
| <field name="view_mode">list,form</field> | ||
| <field name="domain">[('property_id.property_type_id', '=', active_id)]</field> | ||
| <field name="domain">[('property_id.property_type_id', '=', active_id)]</field> | ||
| </record> | ||
| </odoo> |
This file contains hidden or 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,35 @@ | ||
| <?xml version="1.0" encoding="utf-8"?> | ||
| <odoo> | ||
| <!-- List view --> | ||
| <record id="estate_property_tag_view_list" model="ir.ui.view"> | ||
| <field name="name">estate.property.tag.view.list</field> | ||
| <field name="model">estate.property.tag</field> | ||
| <field name="arch" type="xml"> | ||
| <list string="Property Tags" editable="bottom"> | ||
| <field name="name"/> | ||
| </list> | ||
| </field> | ||
| </record> | ||
|
|
||
| <!-- Form view --> | ||
| <record id="estate_property_tag_view_form" model="ir.ui.view"> | ||
| <field name="name">estate.property.tag.view.form</field> | ||
| <field name="model">estate.property.tag</field> | ||
| <field name="arch" type="xml"> | ||
| <form string="Property Tag"> | ||
| <sheet> | ||
| <group> | ||
| <field name="name"/> | ||
| </group> | ||
| </sheet> | ||
| </form> | ||
| </field> | ||
| </record> | ||
|
|
||
| <!-- Action --> | ||
| <record id="estate_property_tag_action" model="ir.actions.act_window"> | ||
| <field name="name">Property Tags</field> | ||
| <field name="res_model">estate.property.tag</field> | ||
| <field name="view_mode">list,form</field> | ||
| </record> | ||
| </odoo> |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.