-
Notifications
You must be signed in to change notification settings - Fork 3.3k
19.0 tutorials makan #1353
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
Draft
Zopsss
wants to merge
17
commits into
odoo:19.0
Choose a base branch
from
odoo-dev:19.0-tutorial-makan
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.
Draft
19.0 tutorials makan #1353
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
047322c
[ADD] estate: implement module for Real Estate businesses
Zopsss 87187bf
[FIX] estate: added missing license in __manifest__.py
Zopsss 8d20b43
[IMP] estate: added estate_property model
Zopsss a37edf0
[FIX] estate: fix ['estate.property'] have no access rules warning
Zopsss 58b0e7c
[IMP] estate: add basic UI
Zopsss 0d9c3a1
[IMP] estate: add basic views like custom form, list, search filters …
Zopsss fd8b061
[FIX] estate: fix property state and menu configuration
Zopsss e49442a
[ADD] estate: add estate_property_type model
Zopsss b6cddcd
[ADD] estate: add estate_property_tag model
Zopsss ff4b4ee
[ADD] estate: add estate_property_offer model and split view files in…
Zopsss 80c719f
[IMP] estate: replace relativedelta_proxy() with add() for date_avail…
Zopsss fd94fa5
[IMP] estate: add total area field in property form
Zopsss 531dd94
[IMP] estate: add best price to estate property
Zopsss 7a3f91e
[FIX] estate: add menuitem for property tag and improve record ids
Zopsss 90439eb
[IMP] estate: track offer validity deadline
Zopsss e4166cb
[IMP] estate: simplify garden information entry
Zopsss 34aef43
[IMP] estate: allow properties to be sold or cancelled
Zopsss 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 @@ | ||
| 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,17 @@ | ||
| { | ||
| "name": "Real Estate", | ||
| "version": "1.0", | ||
| "license": "LGPL-3", | ||
| "author": "Mauryan Kansara", | ||
| "category": "Tutorials", | ||
| "depends": ["base"], | ||
| "application": True, | ||
| "installable": True, | ||
| "data": [ | ||
| "security/ir.model.access.csv", | ||
| "views/estate_property_offer.xml", | ||
| "views/estate_property_search.xml", | ||
| "views/estate_property_views.xml", | ||
| "views/estate_menus.xml", | ||
| ] | ||
| } |
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,4 @@ | ||
| 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,88 @@ | ||
| from odoo import models, fields, api, exceptions | ||
|
|
||
|
|
||
| class EstateProperty(models.Model): | ||
| _name = "estate.property" | ||
| _description = "Real Estate properties" | ||
|
|
||
| title = fields.Char(required=True, default="Unknown") | ||
| last_seen = fields.Datetime("Last Seen", default=fields.Datetime.now) | ||
| description = fields.Text() | ||
| postcode = fields.Char("Postcode") | ||
| status = fields.Char("Status", readonly=True, default="New") | ||
| date_availability = fields.Date("Available From", | ||
| default=lambda self: fields.Date.add(fields.Date.today(), months=3) | ||
| ) | ||
| expected_price = fields.Float("Expected Price", required=True) | ||
| selling_price = fields.Float("Selling Price", readonly=True, copy=False) | ||
| bedrooms = fields.Integer("Bedrooms", default=2) | ||
| living_area = fields.Integer("Living Area (sqm)") | ||
| facades = fields.Integer() | ||
| garage = fields.Boolean() | ||
| garden = fields.Boolean() | ||
| active = fields.Boolean(default=True) | ||
| garden_area = fields.Integer("Garden Area (sqm)") | ||
| garden_orientation = fields.Selection( | ||
| selection=[('north', 'North'), ('south', 'South'), ('east', 'East')], | ||
| ) | ||
| state = fields.Selection( | ||
| [ | ||
| ("new", "New"), | ||
| ("offer_received", "Offer Received"), | ||
| ("offer_accepted", "Offer Accepted"), | ||
| ("sold", "Sold"), | ||
| ("cancelled", "Cancelled"), | ||
| ], | ||
| required=True, | ||
| copy=False, | ||
| default="new", | ||
| ) | ||
| property_type_id = fields.Many2one("estate.property.types", string="Property Type") | ||
| buyer_id = fields.Many2one("res.partner", string="Buyer", copy=False) | ||
| seller_id = fields.Many2one("res.users", string="Seller", default=lambda self: self.env.user) | ||
| tags_id = fields.Many2many("estate.property.tag", string="Tags") | ||
| offer_ids = fields.One2many("estate.property.offer", "property_id", string="Offers") | ||
| total_area = fields.Integer( | ||
| "Total Area (sqm)", | ||
| compute="_compute_total_area", | ||
| ) | ||
| best_price = fields.Integer( | ||
| "Best Price", | ||
| compute="_compute_best_price" | ||
| ) | ||
|
|
||
| @api.depends("living_area", "garden_area") | ||
| def _compute_total_area(self): | ||
| for record in self: | ||
| record.total_area = record.living_area + record.garden_area | ||
|
|
||
| @api.depends("offer_ids.price") | ||
| def _compute_best_price(self): | ||
| for record in self: | ||
| record.best_price = max( | ||
| record.offer_ids.mapped("price"), | ||
| default=0 | ||
| ) | ||
|
|
||
| @api.onchange("garden") | ||
| def _onchange_garden(self): | ||
| if self.garden: | ||
| self.garden_orientation = "north" | ||
| self.garden_area = 10 | ||
| else: | ||
| self.garden_orientation = "" | ||
| self.garden_area = 0 | ||
|
|
||
| def action_sell_property(self): | ||
| for record in self: | ||
| if record.status == "Cancelled": | ||
| raise exceptions.UserError("Cancelled properties cannot be sold") | ||
| record.status = "Sold" | ||
| return True | ||
|
|
||
| def action_cancel_property(self): | ||
| for record in self: | ||
| if record.status == "Sold": | ||
| raise exceptions.UserError("Sold properties cannot be cancelled") | ||
| record.status = "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,25 @@ | ||
| from odoo import models, fields, api | ||
|
|
||
|
|
||
| class EstatePropertyOffer(models.Model): | ||
| _name = "estate.property.offer" | ||
| _description = "Estate Property Offer" | ||
|
|
||
| price = fields.Integer() | ||
| status = fields.Selection([("accepted", "Accepted"), ("refused", "Refused")], copy=False) | ||
| partner_id = fields.Many2one("res.partner", required=True) | ||
| property_id = fields.Many2one("estate.property", required=True, readonly=True) | ||
| validity = fields.Integer("Validity", default=7) | ||
| date_deadline = fields.Date("Deadline", compute="_compute_deadline", inverse="_inverse_deadline") | ||
|
|
||
| @api.depends("create_date", "validity") | ||
| def _compute_deadline(self): | ||
| for record in self: | ||
| record.date_deadline = fields.Date.add( | ||
| fields.Date.today(), | ||
| days=record.validity, | ||
| ) | ||
|
|
||
| def _inverse_deadline(self): | ||
| for record in self: | ||
| record.validity = (record.date_deadline - fields.Date.today()).days |
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,8 @@ | ||
| from odoo import models, fields | ||
|
|
||
|
|
||
| class EstatePropertyTag(models.Model): | ||
| _name = "estate.property.tag" | ||
| _description = "Estate Property Tags" | ||
|
|
||
| name = fields.Char("Name", required=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,8 @@ | ||
| from odoo import models, fields | ||
|
|
||
|
|
||
| class EstatePropertyType(models.Model): | ||
| _name = "estate.property.types" | ||
| _description = "Estate Property Types" | ||
|
|
||
| name = fields.Char("Property Type", required=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,6 @@ | ||
| id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink | ||
| access_estate_model,access_estate_property,model_estate_property,base.group_user,1,1,1,1 | ||
| estate.access_estate_property_types,access_estate_property_types,estate.model_estate_property_types,base.group_user,1,1,1,1 | ||
| estate.access_estate_property_tag, access_estate_property_tag,estate.model_estate_property_tag,base.group_user,1,1,1,1 | ||
| estate.access_estate_property_offer, access_estate_property_offer,estate.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,12 @@ | ||
| <?xml version="1.0" encoding="utf-8"?> | ||
| <odoo> | ||
| <menuitem id="estate.property_menu_root" name="Real Estate"> | ||
| <menuitem id="estate.property_first_level_menu" name="Advertisements"> | ||
| <menuitem id="estate.property_model_menu_action" action="estate.property_model_action"/> | ||
| </menuitem> | ||
| <menuitem id="estate.property_settings" name="Settings"> | ||
| <menuitem id="estate.property_type_model_menu_action" action="estate.property_type_action" /> | ||
| <menuitem id="estate.property_tag_model_menu_action" action="estate.property_tag_action" /> | ||
| </menuitem> | ||
| </menuitem> | ||
| </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,34 @@ | ||
| <?xml version="1.0" encoding="utf-8"?> | ||
| <odoo> | ||
| <record id="estate_property_offer_view_list" model="ir.ui.view"> | ||
| <field name="name">estate.property.offer.list</field> | ||
| <field name="model">estate.property.offer</field> | ||
| <field name="arch" type="xml"> | ||
| <list> | ||
| <field name="price"/> | ||
| <field name="partner_id" /> | ||
| <field name="status" /> | ||
| <field name="validity" /> | ||
| <field name="date_deadline" /> | ||
| </list> | ||
| </field> | ||
| </record> | ||
|
|
||
| <record id="estate_property_offer_view_form" model="ir.ui.view"> | ||
| <field name="name">estate.property.offer.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="status" /> | ||
| <field name="validity" /> | ||
| <field name="date_deadline" /> | ||
| </group> | ||
| </sheet> | ||
| </form> | ||
| </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,32 @@ | ||
| <?xml version="1.0" encoding="utf-8"?> | ||
| <odoo> | ||
| <record id="estate.property_view_search" model="ir.ui.view"> | ||
| <field name="name">estate.property.search</field> | ||
| <field name="model">estate.property</field> | ||
| <field name="arch" type="xml"> | ||
| <search string="Searchbar"> | ||
| <field name="title"/> | ||
| <field name="postcode"/> | ||
| <field name="expected_price"/> | ||
| <field name="bedrooms"/> | ||
| <field name="living_area"/> | ||
| <field name="facades"/> | ||
|
|
||
| <separator /> | ||
| <filter | ||
| string="Available" | ||
| name="available" | ||
| domain="['|', | ||
| ('state', '=', 'new'), | ||
| ('state', '=', 'offer_received') | ||
| ]"/> | ||
|
|
||
| <separator /> | ||
| <filter | ||
| string="Postcode" | ||
| name="group_by_postcode" | ||
| context="{'group_by': 'postcode'}"/> | ||
| </search> | ||
| </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,97 @@ | ||
| <?xml version="1.0" encoding="utf-8"?> | ||
| <odoo> | ||
| <record id="estate.property_model_action" model="ir.actions.act_window"> | ||
| <field name="name">Properties</field> | ||
| <field name="res_model">estate.property</field> | ||
| <field name="view_mode">list,form</field> | ||
| </record> | ||
|
|
||
| <record id="estate.property_type_action" model="ir.actions.act_window"> | ||
| <field name="name">Property Types</field> | ||
| <field name="res_model">estate.property.types</field> | ||
| <field name="view_mode">list,form</field> | ||
| </record> | ||
|
|
||
| <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> | ||
|
|
||
| <record id="estate.property_view_tree" model="ir.ui.view"> | ||
| <field name="name">estate.property.list</field> | ||
| <field name="model">estate.property</field> | ||
| <field name="arch" type="xml"> | ||
| <list string="Tests"> | ||
| <field name="title"/> | ||
| <field name="postcode"/> | ||
| <field name="bedrooms"/> | ||
| <field name="living_area"/> | ||
| <field name="expected_price"/> | ||
| <field name="selling_price"/> | ||
| <field name="date_availability"/> | ||
| <field name="tags_id" widget="many2many_tags" /> | ||
| </list> | ||
| </field> | ||
| </record> | ||
|
|
||
| <record id="estate.property_view_form" model="ir.ui.view"> | ||
| <field name="name">estate.property.form</field> | ||
| <field name="model">estate.property</field> | ||
| <field name="arch" type="xml"> | ||
| <form string="Property Form"> | ||
| <header> | ||
| <button type="object" name="action_sell_property" class="btn-primary">Sold</button> | ||
| <button type="object" name="action_cancel_property">Cancel</button> | ||
| </header> | ||
| <sheet> | ||
| <group> | ||
| <h1><field name="title"/></h1> | ||
| </group> | ||
| <group> | ||
| <field name="status" /> | ||
| </group> | ||
| <group> | ||
| <field name="tags_id" widget="many2many_tags"/> | ||
| </group> | ||
| <group> | ||
| <group> | ||
| <field name="postcode" /> | ||
| <field name="date_availability" /> | ||
| </group> | ||
| <group> | ||
| <field name="expected_price"/> | ||
| <field name="selling_price"/> | ||
| <field name="best_price" /> | ||
| </group> | ||
| </group> | ||
| <notebook> | ||
| <page string="Description"> | ||
| <group> | ||
| <field name="description"/> | ||
| <field name="bedrooms"/> | ||
| <field name="living_area"/> | ||
| <field name="garden_area"/> | ||
| <field name="facades"/> | ||
| <field name="garage"/> | ||
| <field name="garden"/> | ||
| <field name="garden_orientation"/> | ||
| <field name="state"/> | ||
| <field name="total_area"/> | ||
| </group> | ||
| </page> | ||
| <page string="Offers"> | ||
| <field name="offer_ids" /> | ||
| </page> | ||
| <page string="Other Info"> | ||
| <group> | ||
| <field name="seller_id"/> | ||
| <field name="buyer_id"/> | ||
| </group> | ||
| </page> | ||
| </notebook> | ||
| </sheet> | ||
| </form> | ||
| </field> | ||
| </record> | ||
| </odoo> |
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.