-
Notifications
You must be signed in to change notification settings - Fork 2.8k
[ADD] estate: module with property model and corresponding views. (framework 101) #1082
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
farahdawod
wants to merge
3
commits into
odoo:19.0
Choose a base branch
from
odoo-dev:19.0-tut-ahmfa
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.
+238
−0
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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,2 @@ | ||
|
|
||
| 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': 'Estate', | ||
| 'category': 'Sales', | ||
| 'sequence': 1, | ||
| 'summary': 'Sell and bid on the hottest real estate properties.', | ||
| 'website': 'https://www.odoo.com/app/estate', | ||
| 'depends': [ | ||
| 'base_setup', | ||
| 'web', | ||
| ], | ||
| 'data': [ | ||
| 'security/ir.model.access.csv', | ||
| 'views/estate_property_views.xml', | ||
| 'views/estate_menus.xml', | ||
| ], | ||
| 'application': 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,3 @@ | ||
|
|
||
| from . import estate_property | ||
| from . import estate_property_type |
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,49 @@ | ||
| from odoo import fields, models | ||
| from dateutil.relativedelta import relativedelta | ||
|
|
||
|
|
||
| class EstateProperty(models.Model): | ||
| _name = 'estate.property' | ||
| _description = "Real Estate Property" | ||
|
|
||
| name = fields.Char("Title", required=True, translate=True) | ||
| property_type_id = fields.Many2one( | ||
| 'estate.property.type', | ||
| string="Property Type", | ||
| ) | ||
| postcode = fields.Char("Postcode", required=True) | ||
| availability = fields.Date( | ||
| "Available From", | ||
| required=True, | ||
| copy=False, | ||
| default=lambda self: fields.Date.today() + relativedelta(months=3), | ||
| ) | ||
| description = fields.Text("Description") | ||
| bedrooms = fields.Integer("Bedrooms", required=True, default=2) | ||
| living_area = fields.Integer("Living Area (sqm)", required=True) | ||
| currency_id = fields.Many2one('res.currency', string="Currency", default=lambda self: self.env.company.currency_id.id) | ||
| expected_price = fields.Monetary("Expected Price", required=True) | ||
| selling_price = fields.Monetary("Selling Price", readonly=True, copy=False) | ||
| # best_offer_id = fields.Many2one('estate.property.offer', string='Best Offer', readonly=True) | ||
| facades = fields.Integer("Facades", default=False) | ||
| garage = fields.Boolean("Garage", default=False) | ||
| garden = fields.Boolean("Garden", default=False) | ||
| garden_area = fields.Integer("Garden Area (sqm)", required=False) | ||
| garden_orientation = fields.Selection(selection=[('north', "North"), ('south', "South"), ('east', "East"), ('west', "West")], string="Garden Orientation") | ||
| total_area = fields.Integer("Total Area (sqm)") | ||
|
|
||
| state = fields.Selection( | ||
| string="Status", | ||
| selection=[('new', "New"), ('offer_received', "Offer Received"), ('offer_accepted', "Offer Accepted"), ('sold', "Sold"), ('canceled', "Canceled")], | ||
| required=True, | ||
| copy=False, | ||
| default='new', | ||
| ) | ||
| active = fields.Boolean("Active", default=True) | ||
| buyer_id = fields.Many2one('res.partner', string="Buyer", copy=False) | ||
| seller_id = fields.Many2one('res.users', string="Salesperson", default=lambda self: self.env.user) | ||
|
|
||
| # _check_expected_price = models.Constraint( | ||
| # 'CHECK(expected_price) >= 0', | ||
| # "The expected price can't be negative", | ||
| # ) |
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,11 @@ | ||
| from odoo import fields, models | ||
|
|
||
|
|
||
| class EstateProperty(models.Model): | ||
| _name = 'estate.property.type' | ||
| _description = "Real Estate Property Type" | ||
|
|
||
| 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,3 @@ | ||
| id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink | ||
| access_estate_property,estate.property,model_estate_property,base.group_user,1,1,1,1 | ||
| access_estate_property_type,estate.property.type,model_estate_property_type,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,11 @@ | ||
| <?xml version="1.0" encoding="utf-8"?> | ||
| <odoo> | ||
| <menuitem id="estate_menu_root" name="Estate"> | ||
| <menuitem id="estate_first_level_menu" name="Advertisements"> | ||
| <menuitem id="estate_property_menu_action" action="estate_property_action"/> | ||
| </menuitem> | ||
| <menuitem id="estate_second_level_menu" name="Settings"> | ||
| <menuitem id="estate_property_type_menu_action" action="estate_property_type_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,98 @@ | ||
| <?xml version="1.0" encoding="utf-8"?> | ||
| <odoo> | ||
|
|
||
farahdawod marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| <record id="estate_property_list_view" model="ir.ui.view"> | ||
| <field name="name">estate.property.list.view</field> | ||
| <field name="model">estate.property</field> | ||
| <field name="arch" type="xml"> | ||
| <list string="Properties"> | ||
| <field name="name"/> | ||
| <field name="postcode"/> | ||
| <field name="bedrooms"/> | ||
| <field name="living_area"/> | ||
| <field name="expected_price"/> | ||
| <field name="selling_price"/> | ||
| <field name="availability"/> | ||
| </list> | ||
| </field> | ||
| </record> | ||
|
|
||
| <record id="estate_property_form_view" model="ir.ui.view"> | ||
| <field name="name">estate.property.form.view</field> | ||
| <field name="model">estate.property</field> | ||
| <field name="arch" type="xml"> | ||
| <form string="My New House"> | ||
| <sheet> | ||
| <div class="oe_title mw-100"> | ||
| <div class="d-flex justify-content-between align-items-center"> | ||
| <h1 class="flex-grow-1"> | ||
| <field class="text-break" options="{'line_breaks': False}" widget="text" name="name" placeholder="My New House"/> | ||
| </h1> | ||
| </div> | ||
| </div> | ||
| <group> | ||
| <field name="property_type_id"/> | ||
| <field name="postcode"/> | ||
| <field name="availability"/> | ||
| <field name="expected_price"/> | ||
| <field name="selling_price"/> | ||
| </group> | ||
| <notebook> | ||
| <page name="estate_attributes" string="Description"> | ||
| <group> | ||
| <field name="description"/> | ||
| <field name="bedrooms"/> | ||
| <field name="living_area"/> | ||
| <field name="facades"/> | ||
| <field name="garage"/> | ||
| <field name="garden"/> | ||
| <field name="garden_area"/> | ||
| <field name="garden_orientation"/> | ||
| </group> | ||
| </page> | ||
| <page name="estate_contacts" string="Other Info"> | ||
| <group> | ||
| <field name="seller_id"/> | ||
| <field name="buyer_id"/> | ||
| </group> | ||
| </page> | ||
| </notebook> | ||
| </sheet> | ||
| </form> | ||
| </field> | ||
| </record> | ||
|
|
||
| <record id="estate_property_action" model="ir.actions.act_window"> | ||
| <field name="name">Property</field> | ||
| <field name="res_model">estate.property</field> | ||
| <field name="view_mode">list,form</field> | ||
| </record> | ||
|
|
||
| <record id="estate_property_search_view" model="ir.ui.view"> | ||
| <field name="name">estate.property.search</field> | ||
| <field name="model">estate.property</field> | ||
| <field name="arch" type="xml"> | ||
| <search string="Estate Property"> | ||
| <field name="name" string="Title"/> | ||
| <field name="postcode" string="Postcode"/> | ||
| <field name="expected_price" string="Expected Price"/> | ||
| <field name="bedrooms" string="Bedrooms"/> | ||
| <field name="living_area" string="Living Area"/> | ||
| <field name="facades" string="Facades"/> | ||
| <field name="seller_id" string="Salesperson"/> | ||
| <separator/> | ||
| <filter name="state" string="Available" domain="[('state','in', ['new','offer_received'])]"/> | ||
| <group> | ||
| <filter name="postcode" string="Postcode" context="{'group_by':'postcode', 'residual_visible': True}"/> | ||
| <filter name="seller_id" string="Salesperson" context="{'group_by':'seller_id', 'residual_visible': True}"/> | ||
| </group> | ||
| </search> | ||
| </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.type</field> | ||
| <field name="view_mode">list</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,44 @@ | ||
| # Exclude a variety of commonly ignored directories. | ||
| exclude = [ | ||
| ".bzr", | ||
| ".direnv", | ||
| ".eggs", | ||
| ".git", | ||
| ".git-rewrite", | ||
| ".hg", | ||
| ".ipynb_checkpoints", | ||
| ".mypy_cache", | ||
| ".nox", | ||
| ".pants.d", | ||
| ".pyenv", | ||
| ".pytest_cache", | ||
| ".pytype", | ||
| ".ruff_cache", | ||
| ".svn", | ||
| ".tox", | ||
| ".venv", | ||
| ".vscode", | ||
| "__pypackages__", | ||
| "_build", | ||
| "buck-out", | ||
| "build", | ||
| "dist", | ||
| "node_modules", | ||
| "site-packages", | ||
| "venv", | ||
| ] | ||
|
|
||
| # Assume Python 3.12 | ||
| target-version = "py312" | ||
|
|
||
| line-length = 255 | ||
| [lint] | ||
| # Enable Pyflakes (`F`) and a subset of the pycodestyle (`E`) codes by default. | ||
| select = ["ALL"] | ||
| ignore = ["A","ARG","ANN","B","C901","D","DTZ","DOC","E501","ERA001","FBT","N","PD","PERF","PIE790","PLR","PT","Q","RSE102","RUF001","RUF012","S","SIM102","SIM108","SLF001","TID252","UP031","TRY003","TRY300","E713","SIM117","PGH003","RUF005","FIX","TD","TRY400","C408","PLW2901","PTH","EM102","INP001","CPY001","E266","PIE808","PLC2701","RUF100","FA100","FURB","C420","COM812","TRY002","B904","EM101","I001","UP006","UP007","RET","RUF021","E741","FAST","ASYNC","AIR","DJ","NPY","FA102","F401"] | ||
|
|
||
| # Allow fix for all enabled rules (when `--fix`) is provided. | ||
| fixable = ["ALL"] | ||
| unfixable = ["A","ARG","ANN","B","C901","D","DTZ","DOC","E501","ERA001","FBT","N","PD","PERF","PIE790","PLR","PT","Q","RSE102","RUF001","RUF012","S","SIM102","SIM108","SLF001","TID252","UP031","TRY003","TRY300","E713","SIM117","PGH003","RUF005","FIX","TD","TRY400","C408","PLW2901","PTH","EM102","INP001","CPY001","E266","PIE808","PLC2701","RUF100","FA100","FURB","C420","COM812","TRY002","B904","EM101","I001","UP006","UP007","RET","RUF021","E741","FAST","ASYNC","AIR","DJ","NPY","FA102","F401"] | ||
| [format] | ||
| quote-style = "preserve" |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could explain that in your pr message for instance