-
Notifications
You must be signed in to change notification settings - Fork 2.8k
[ADD] Estate Module (Python Framework Training) #1068
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
base: 19.0
Are you sure you want to change the base?
Changes from all commits
e6f8dbd
4a69d2f
e47cf30
bf9de48
ce471ef
0225b68
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| from . import models |
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,10 @@ | ||||||||||||||
| { | ||||||||||||||
| "name": "real estate", | ||||||||||||||
| "description": "real estate renting management system", | ||||||||||||||
| "category": "Tutorials", | ||||||||||||||
| "version": "1.1", | ||||||||||||||
| "application": True, | ||||||||||||||
| "data": ["security/ir.model.access.csv", "views/views.xml", "views/menus.xml"], | ||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please split your data files (same comment for as many lists as possible):
Suggested change
If someone has to add a file, it will be way easier and keep a clear overview (with git history) of the changes. |
||||||||||||||
| "author": "OMKHA", | ||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
As you are developing for Odoo, the company is the author of the file. |
||||||||||||||
| "license": "LGPL-3", | ||||||||||||||
| } | ||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| from . import buildings_model | ||
| from . import building_type_model | ||
| from . import tags_model | ||
| from . import offers_model |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,8 @@ | ||||||
| from odoo import models, fields | ||||||
|
|
||||||
|
|
||||||
| class building_type_model(models.Model): | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The class name should match the file name (for most cases) and follow the PascalCase convention.
Suggested change
|
||||||
| _name = "estate.building_type" | ||||||
| _description = "Building Type Model" | ||||||
|
|
||||||
| name = fields.Char(required=True) | ||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| from odoo import models, fields | ||
| from datetime import timedelta | ||
|
|
||
|
|
||
| class buildings_model(models.Model): | ||
| _name = "estate.buildings" | ||
| _description = "Buildings Model" | ||
|
|
||
| name = fields.Char() | ||
| description = fields.Text() | ||
| value = fields.Integer(copy=False) | ||
| availability_date = fields.Date( | ||
| default=fields.Date.today() + timedelta(days=90), copy=False | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use a lambda function or call a compute method because this will fix the default date to the server starting date |
||
| ) | ||
| number_of_rooms = fields.Integer(default=2) | ||
| garden_orientation = fields.Selection( | ||
| [("north", "North"), ("south", "South"), ("east", "East"), ("west", "West")], | ||
| "garden Orientation", | ||
| ) | ||
| active = fields.Boolean(default=True) | ||
| state = fields.Selection( | ||
| [ | ||
| ("new", "New"), | ||
| ("offer received", "Offer Received"), | ||
| ("offer accepted", "Offer Accepted"), | ||
| ("sold", "Sold"), | ||
| ("canceled", "Canceled"), | ||
| ], | ||
| default="new", | ||
| ) | ||
| post_code = fields.Integer(default=1000) | ||
| building_type_id = fields.Many2one("estate.building_type", string="Building Type") | ||
| buyer_id = fields.Many2one("res.partner", string="Buyer") | ||
| salesperson_id = fields.Many2one( | ||
| "res.users", string="Salesperson", default=lambda self: self.env.user | ||
| ) | ||
| tag_ids = fields.Many2many("estate.building_tags", string="Tags") | ||
| offer_ids = fields.One2many("estate.offers", "building_id", string="Offers") | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| from odoo import models, fields | ||
|
|
||
|
|
||
| class offers_model(models.Model): | ||
| _name = "estate.offers" | ||
| _description = "Offers Model" | ||
|
|
||
| price = fields.Integer(required=True) | ||
| status = fields.Selection( | ||
| [("accepted", "Accepted"), ("refused", "Refused")], | ||
| string="Status", | ||
| required=True, | ||
| ) | ||
| building_id = fields.Many2one("estate.buildings", string="Building") | ||
| partner_id = fields.Many2one("res.partner", string="Partner") |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| from odoo import models, fields | ||
|
|
||
|
|
||
| class building_tags_model(models.Model): | ||
| _name = "estate.building_tags" | ||
| _description = "Building Tags Model" | ||
|
|
||
| name = fields.Char(required=True) |
| 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_first_model,access_first_model,model_estate_buildings,base.group_user,1,1,1,1 | ||
| access_building_type_model,access_building_type_model,model_estate_building_type,base.group_user,1,1,1,1 | ||
| access_building_tags_model,access_building_tags_model,model_estate_building_tags,base.group_user,1,1,1,1 | ||
| access_offers_model,access_offers_model,model_estate_offers,base.group_user,1,1,1,1 | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don't forget Unix conventions on text files' structure based on a line definition (cf. https://peps.python.org/pep-0008/ and https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap03.html#tag_03_206) Check all XML files too |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| <?xml version="1.0" encoding="utf-8"?> | ||
| <odoo> | ||
| <menuitem id="test_menu_root" name="Estate FelBeit"> | ||
| <menuitem id="test_first_level_menu" name="First Level"> | ||
| <menuitem id="test_model_menu_action" action="some_model_action_1"/> | ||
| </menuitem> | ||
| </menuitem> | ||
| </odoo> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,85 @@ | ||
| <?xml version="1.0" encoding="utf-8"?> | ||
| <odoo> | ||
| <record id="some_model_action_1" model="ir.actions.act_window"> | ||
| <field name="name">Test action 1</field> | ||
| <field name="res_model">estate.buildings</field> | ||
| <field name="view_mode">list,form</field> | ||
| </record> | ||
| <record id="list_view" model="ir.ui.view"> | ||
| <field name="name">estate.buildings.list</field> | ||
| <field name="model">estate.buildings</field> | ||
| <field name="arch" type="xml"> | ||
| <list string="test_list"> | ||
| <field name="name"/> | ||
| <field name="number_of_rooms"/> | ||
| <field name="value"/> | ||
| <field name="state"/> | ||
| <field name="building_type_id"/> | ||
| </list> | ||
| </field> | ||
| </record> | ||
|
|
||
| <record id="first_form_view" model="ir.ui.view"> | ||
| <field name="name">estate.buildings.form</field> | ||
| <field name="model">estate.buildings</field> | ||
| <field name="arch" type="xml"> | ||
| <form string="Test"> | ||
| <sheet> | ||
| <group> | ||
| <group> | ||
| <field name="name"/> | ||
| <field name="tag_ids" widget="many2many_tags"/> | ||
| <field name="value"/> | ||
| <field name="state"/> | ||
| <field name="availability_date"/> | ||
| <field name="building_type_id"/> | ||
| </group> | ||
| <group> | ||
| <field name="number_of_rooms"/> | ||
| <field name="garden_orientation"/> | ||
| <field name="post_code"/> | ||
| </group> | ||
| </group> | ||
| <notebook> | ||
| <page string="Description"> | ||
| <group> | ||
| <field name="description"/> | ||
| </group> | ||
| </page> | ||
| <page string="Info"> | ||
| <group> | ||
| <field name="buyer_id"/> | ||
| <field name="salesperson_id"/> | ||
| </group> | ||
| </page> | ||
| <page string="Offers"> | ||
| <field name="offer_ids"> | ||
| <list> | ||
| <field name="price"/> | ||
| <field name="status"/> | ||
| <field name="partner_id"/> | ||
| </list> | ||
| </field> | ||
| </page> | ||
| </notebook> | ||
| </sheet> | ||
| </form> | ||
| </field> | ||
| </record> | ||
|
|
||
| <record id="first_search_view" model="ir.ui.view"> | ||
| <field name="name">estate.buildings.search</field> | ||
| <field name="model">estate.buildings</field> | ||
| <field name="arch" type="xml"> | ||
| <search string="test_search"> | ||
| <field name="name"/> | ||
| <field name="value"/> | ||
| <separator/> | ||
| <filter string="Available" name="Available" domain="['|', ('state', '=', 'new' ), ('state', '=', 'offer received')]"/> | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe try something like |
||
| <filter string="postcode" name="postcode" context="{'group_by':'post_code'}"/> | ||
| </search> | ||
|
|
||
| </field> | ||
| </record> | ||
|
|
||
| </odoo> | ||
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.
I would have capitalized these lines