-
Notifications
You must be signed in to change notification settings - Fork 3.3k
[ADD] : Creation of the new module #1412
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
b41bda0
a6b3d75
feee2db
e637945
c6c24d0
84e3360
e5f83fc
de60fce
ada43a3
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,17 @@ | ||
| { | ||
| 'name': 'Real Estate', | ||
| 'version': '1.0', | ||
| 'depends': ['base'], | ||
| 'application': True, | ||
| 'installable': True, | ||
| 'data': [ | ||
| 'security/ir.model.access.csv', | ||
| 'views/estate_property_views.xml', | ||
| 'views/estate_property_type_views.xml', | ||
| 'views/estate_property_tag_views.xml', | ||
| 'views/estate_property_offer_views.xml', | ||
| 'views/estate_menu.xml', | ||
| ], | ||
| 'author': 'macai', | ||
| 'license': 'LGPL-3', | ||
| } |
| 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 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| from odoo import models, fields | ||
|
|
||
|
|
||
| class EstateProperty(models.Model): | ||
| _name = 'estate.property' | ||
| _description = 'Real Estate property model' | ||
|
|
||
| # Property information | ||
| name = fields.Char('Name', required=True) | ||
| description = fields.Text('Description') | ||
| postcode = fields.Char('Postcode', required=True) | ||
| date_availability = fields.Date('Availability', copy=False, 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') | ||
| facades = fields.Integer('Facades') | ||
| has_garage = fields.Boolean('Garage') | ||
| has_garden = fields.Boolean('Garden') | ||
| garden_area = fields.Integer('Garden Area') | ||
| garden_orientation = fields.Selection( | ||
| string='Garden Orientation', | ||
| selection=[('north', 'North'), | ||
| ('south', 'South'), | ||
| ('east', 'East'), | ||
| ('west', 'West'), | ||
| ] | ||
| ) | ||
| active = fields.Boolean('Active', default=True) | ||
| state = fields.Selection( | ||
| string='State', | ||
| 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.type", string='Property Type') | ||
|
|
||
| # Other Information | ||
| salesman_id = fields.Many2one('res.users', string='Salesman', default=lambda self: self.env.user) | ||
| buyer_id = fields.Many2one('res.partner', string='Buyer', copy=False) | ||
|
|
||
| # Tags | ||
| tag_ids = fields.Many2many('estate.property.tag', string='Tags') | ||
|
|
||
| # Offers | ||
| offer_ids = fields.One2many('estate.property.offer', 'property_id', string='Offer') | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| from odoo import models, fields | ||
|
|
||
|
|
||
| class EstatePropertyOffer(models.Model): | ||
| _name = 'estate.property.offer' | ||
| _description = 'Estate Property Offer' | ||
|
|
||
| price = fields.Float(string='Price') | ||
| status = fields.Selection([ | ||
| ('accepted', 'Accepted'), | ||
| ('refused', 'Refused') | ||
| ], copy=False, string='Status') | ||
| partner_id = fields.Many2one('res.partner', required=True, string='Partner') | ||
| property_id = fields.Many2one('estate.property', required=True) |
| 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 Tag' | ||
|
|
||
| name = fields.Char(string='Name', required=True) |
| 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.type' | ||
| _description = 'Define the Real Estate Property Type' | ||
|
|
||
| name = fields.Char(string='Name', 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_estate_property_user,access.estate.property,model_estate_property,base.group_user,1,1,1,1 | ||
| access_estate_property_type_user,access.estate.property.type,model_estate_property_type,base.group_user,1,1,1,1 | ||
| access_estate_property_tag_user,access.estate.property.tag,model_estate_property_tag,base.group_user,1,1,1,1 | ||
| access_estate_property_offer_user,access.estate.property.offer,model_estate_property_offer,base.group_user,1,1,1,1 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| <?xml version="1.0"?> | ||
| <odoo> | ||
| <menuitem id="estate_application_menu_root" name="Real Estate"> | ||
| <menuitem id="estate_advertisement_menu" name="Advertisements" sequence="1"> | ||
| <menuitem id="estate_menu_action" action="estate_property_action"/> | ||
| </menuitem> | ||
| <menuitem id="setting_menu" name="Settings" sequence="2"> | ||
| <menuitem id="estate_property_type_menu_action" action="estate_property_type_action"/> | ||
| <menuitem id="estate_property_tag_menu_action" action="estate_property_tag_action"/> | ||
| </menuitem> | ||
| </menuitem> | ||
| </odoo> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| <?xml version="1.0"?> | ||
| <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"/> | ||
| </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> | ||
| <group> | ||
| <field name="price"/> | ||
| <field name="partner_id"/> | ||
| <field name="status"/> | ||
| </group> | ||
| </form> | ||
| </field> | ||
| </record> | ||
|
|
||
| </odoo> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| <?xml version="1.0"?> | ||
| <odoo> | ||
|
|
||
| <record id="estate_property_tag_action" model="ir.actions.act_window"> | ||
| <field name="name">Tags</field> | ||
| <field name="res_model">estate.property.tag</field> | ||
| <field name="view_mode">list,form</field> | ||
| </record> | ||
|
|
||
| </odoo> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| <?xml version="1.0"?> | ||
| <odoo> | ||
|
|
||
| <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,form</field> | ||
| </record> | ||
|
|
||
| </odoo> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,107 @@ | ||
| <?xml version="1.0"?> | ||
| <odoo> | ||
|
|
||
| <record id="estate_property_action" model="ir.actions.act_window"> | ||
| <field name="name">Properties</field> | ||
| <field name="res_model">estate.property</field> | ||
| <field name="view_mode">list,form,search</field> | ||
| </record> | ||
|
|
||
| <record id="estate_property_view_list" model="ir.ui.view"> | ||
| <field name="name">estate.properties.list</field> | ||
| <field name="model">estate.property</field> | ||
| <field name="arch" type="xml"> | ||
| <list> | ||
| <field name="name" string="Title"/> | ||
| <field name="postcode" string="Postcode"/> | ||
| <field name="tag_ids" string="Tags" widget="many2many_tags"/> | ||
| <field name="bedrooms" string="Bedrooms"/> | ||
| <field name="living_area" string="Living Area (sqm)"/> | ||
| <field name="expected_price" string="Expected Price"/> | ||
| <field name="selling_price" string="Selling Price"/> | ||
| <field name="date_availability" string="Available From"/> | ||
| </list> | ||
| </field> | ||
| </record> | ||
|
|
||
| <record id="estate_property_view_form" model="ir.ui.view"> | ||
| <field name="name">estate.properties.form</field> | ||
| <field name="model">estate.property</field> | ||
| <field name="arch" type="xml"> | ||
| <form string="Properties"> | ||
| <sheet> | ||
| <h1> | ||
| <field name="name"/> | ||
| </h1> | ||
| <h2> | ||
| <field name="tag_ids" widget="many2many_tags"/> | ||
| </h2> | ||
| <div class="row align-items-start"> | ||
| <div class="col"> | ||
| <group> | ||
| <field name="property_type_id"/> | ||
| <field name="postcode" string="Postcode"/> | ||
| <field name="date_availability" string="Available From"/> | ||
| </group> | ||
| </div> | ||
| <div class="col"> | ||
| <group> | ||
| <field name="expected_price" string="Expected Price"/> | ||
| <field name="selling_price" string="Selling Price"/> | ||
| </group> | ||
| </div> | ||
| </div> | ||
| <notebook> | ||
| <page string="Description"> | ||
| <group> | ||
| <field name="description" string="Description"/> | ||
| <field name="bedrooms" string="Bedrooms"/> | ||
| <field name="living_area" string="Living Area (sqm)"/> | ||
| <field name="facades" string="Facades"/> | ||
|
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. it's totally correct to have |
||
| <field name="has_garage" string="Garage"/> | ||
| <field name="has_garden" string="Garden"/> | ||
| <field name="garden_area" string="Garden Area (sqm)"/> | ||
| <field name="garden_orientation" string="Garden Orientation"/> | ||
| <field name="state" string="State"/> | ||
| </group> | ||
| </page> | ||
| <page string="Offers"> | ||
| <list> | ||
| <field name="offer_ids"/> | ||
| </list> | ||
| </page> | ||
| <page string="Other Info"> | ||
| <group> | ||
| <field name="salesman_id"/> | ||
| <field name="buyer_id"/> | ||
| </group> | ||
| </page> | ||
| </notebook> | ||
| </sheet> | ||
| </form> | ||
| </field> | ||
| </record> | ||
|
|
||
| <record id="estate_property_view_search" model="ir.ui.view"> | ||
| <field name="name">estate.properties.search</field> | ||
| <field name="model">estate.property</field> | ||
| <field name="arch" type="xml"> | ||
| <search string="Properties"> | ||
| <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 (sqm)"/> | ||
| <field name="facades" string="Facades"/> | ||
| <separator/> | ||
| <filter name="active" string="Available" domain="[('state', 'in', ('new', 'offer_received'))]"/> | ||
| <separator/> | ||
| <group> | ||
| <filter string="Postcode" name="postcode" context="{'group_by':'postcode'}"/> | ||
| </group> | ||
| </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.
The one line on the selection field is okay but when you have many values, it's better to have it like this.
Also, it's preferable to have the key as all small letters, so no confusion happens when they are used inside the code in
ifstatements for example.nitpick: some teams might stick to single quotes being only on technical strings (the ones that the user don't see) and double quotes are for the strings that the user can see)
so for example the selection can be ('east', "East") instead of ('east', 'East') but some teams don't do this, they just stick to their own convention which is all single quotes (if possible) or all double quotes
But I see you have all single quotes so good for me but thought to mention it so you know.