-
Notifications
You must be signed in to change notification settings - Fork 2.1k
[ADD] estate: create real estate module #783
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: 18.0
Are you sure you want to change the base?
Conversation
4b7b110
to
821971f
Compare
821971f
to
3e0c64e
Compare
3e0c64e
to
6181942
Compare
b357377
to
88c49fd
Compare
f3aee3d
to
be3fe3d
Compare
…es and set properties as sold/cancelled
be3fe3d
to
5d8670f
Compare
5d8670f
to
3d66c40
Compare
…heritance and add a page in User to see Properties linked to salesperson
ea014ea
to
4bddac7
Compare
77e21d7
to
4bc26bc
Compare
…ideline and clear some typos This commit will refactor estate_property in estate.property as recommended. Some file name especially those who deals with inhertiance are changed accoridng to the guideline.
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.
Good work overall. One general remark: There are inconsistencies with the use of single/double quotes. We generally use different quote signs to distinguishes between technical strings (single quotes) and user-facing strings (double quotes).
estate/models/estate_properties.py
Outdated
date_availability = fields.Date( | ||
"Date availability", | ||
copy=False, | ||
default=fields.Date.today() + relativedelta(months=3)) |
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.
default=fields.Date.today() + relativedelta(months=3)) | |
default=lambda: fields.Date.today() + relativedelta(months=3)) |
As it is now, fields.Date.today() + relativedelta(months=3)
is evaluated once when the class is loaded, not each time a record is created. Use a function returning the value so it's evaluated on each record creation.
estate/security/ir.model.access.csv
Outdated
estate.access_estate_property,access_estate_property,estate.model_estate_property,base.group_user,1,1,1,1 | ||
estate.access_estate_property_type,access_estate_property_type,estate.model_estate_property_type,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 |
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.
estate.access_estate_property_offer,access_estate_property_offer,estate.model_estate_property_offer,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 | |
Remember to leave an empty line at the end of files. While it seems trivial, it ensures compatibility with many tools and version control systems.
estate/views/estate_menus.xml
Outdated
<menuitem id="estate_tag_menu_action" action="estate_property_tag_action"/> | ||
</menuitem> | ||
</menuitem> | ||
</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.
</odoo> | |
</odoo> | |
estate/views/res_user.xml
Outdated
</xpath> | ||
</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.
</odoo> | |
</odoo> | |
estate/models/estate_property.py
Outdated
date_availability = fields.Date( | ||
"Date availability", | ||
copy=False, | ||
default=fields.Date.today() + relativedelta(months=3)) |
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.
date_availability = fields.Date( | |
"Date availability", | |
copy=False, | |
default=fields.Date.today() + relativedelta(months=3)) | |
date_availability = fields.Date( | |
"Date availability", | |
copy=False, | |
default=lambda: fields.Date.today() + relativedelta(months=3)) |
As it is now, fields.Date.today() + relativedelta(months=3)
is evaluated once when the class is loaded, not each time a record is created. Use a function returning the value so it’s evaluated on each record creation.
<field name="name">estate.property.tag.form</field> | ||
<field name="model">estate.property.tag</field> | ||
<field name="arch" type="xml"> | ||
<form string="Property"> |
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.
<form string="Property"> | |
<form string="Property Tag"> |
<field name="name">estate.property.offer.form</field> | ||
<field name="model">estate.property.offer</field> | ||
<field name="arch" type="xml"> | ||
<form string="Property"> |
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.
<form string="Property"> | |
<form string="Property Offer"> |
res = super().action_sold() | ||
self.env['account.move'].create({ | ||
"move_type": 'out_invoice', | ||
"partner_id": self.buyer.id, |
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.
What if the self.buyer
doesn't exist ?
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.
As buyer is a many2one field it gets a blank template by default. Therefore there is a field buyer.id
with the value False
which is interpreted as no buyer.
So when there is no buyer, this will create an invoice with no Customer
<!-- | ||
<div class="o_field_widget o_stat_info"> | ||
<span class="o_stat_value d-flex gap-1"> | ||
<field name="offer_count" widget="statinfo" nolabel="1" class="oe_inline"/> | ||
<field name="name" class="oe_inline"/> | ||
</span> | ||
</div> | ||
--> |
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.
<!-- | |
<div class="o_field_widget o_stat_info"> | |
<span class="o_stat_value d-flex gap-1"> | |
<field name="offer_count" widget="statinfo" nolabel="1" class="oe_inline"/> | |
<field name="name" class="oe_inline"/> | |
</span> | |
</div> | |
--> |
In general, we try to use comments to add context to the code. This doesn't seem to add much.
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 forgot to uncomment it after debugging
<field string="Bedrooms" name="bedrooms"/> | ||
<field string="Living Area (sqm)" name="living_area" filter_domain="[('living_area', '>', self)]"/> | ||
<field string="Facades" name="facades"/> | ||
<filter string="Available" name="state_availability_filter" domain="['|',('state','=', 'new'), ('state','=','offer received')]"/> |
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.
Domains have a in
operator
…the review Add a lambda fonction to the default field computing a date based on fields.Date.today method. Add a line at the end of file for files where it was missing. Adapted the create method of the EstatePropertyOffer to match the api.model_create_multi decorator. Add a call to the self.env._ method at each UserError callto export them for translation. Updated class name according to the guideline to match their model name in CamelCase format. Updated 'offer received' and 'offer accepted' to snake_case formatting. Updated misleading _sql_constraints name and error from estate_property_type. Switch to default return value instead of a workaround for max method in estate/models/estate_property.py . Updated action_confirm to: 1) right algorithm 2) better readability using write and filtered method Corrected some string field in xml. Uncommented the core of a stat_button that was only displaying 'test'.
6a68bec
to
7d4bb56
Compare
Creation of a module for real estate.
There should be more description however it's work in progress