-
Notifications
You must be signed in to change notification settings - Fork 2.7k
[ADD] Estate: init #1028
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?
[ADD] Estate: init #1028
Conversation
…line (L7) deletation
clbr-odoo
left a comment
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.
Very good job, continue like this !
The module name in the commit title should be lower case, it's the technical name of the module, which is equivalent to the folder name.
d717a89 to
ac39bed
Compare
clbr-odoo
left a comment
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 job !
| _name = "estate.property" | ||
| _description = "Estate Property" | ||
| _order = "id desc" | ||
| _check_expected_price = models.Constraint( |
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.
Constraints should be just below field definition. Check the coding guidelines for the order of the methods and fields because it's not the only one misplaced :)
| @api.depends("offer_ids") | ||
| def _compute_best_offer(self): | ||
| for record in self: | ||
| record.best_price = max(record.offer_ids.mapped("price")) if len(record.offer_ids) > 0 else 0.0 |
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.
| record.best_price = max(record.offer_ids.mapped("price")) if len(record.offer_ids) > 0 else 0.0 | |
| record.best_price = max(record.offer_ids.mapped("price"), default=0.0) |
- You never need to check the length if you want to check if a recordset is filled, just do
if record.offer_ids: - You can simplify a bit like this ☝️
| record.garden_orientation = 'north' | ||
|
|
||
| def estate_property_action_sold(self): | ||
| self.__estate_property_action_sold_cancel('sold', "A cancelled property cannot be sold!", "This property is already sold!") |
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.
| self.__estate_property_action_sold_cancel('sold', "A cancelled property cannot be sold!", "This property is already sold!") | |
| self._estate_property_action_sold_cancel('sold', "A cancelled property cannot be sold!", "This property is already sold!") |
| @api.onchange("offer_ids") | ||
| def _onchange_offer_ids(self): | ||
| for record in self: | ||
| if len(record.offer_ids) > 0: |
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.
| if len(record.offer_ids) > 0: | |
| if record.offer_ids: |
| if record.status == 'accepted': | ||
| return False |
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.
It's weird to have a method that returns False in the middle of the loop.
This will lead to inconsistencies.
| for record in self: | ||
| record.property_id.selling_price = 0.0 |
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 can actually "batch write" it self.property_id.selling_price = 0.0
| <field name="arch" type="xml"> | ||
| <form string="My new house"> | ||
| <header> | ||
| <button name="estate_property_action_sold" type="object" string="Sold" invisible="state == 'sold' or state == 'cancelled'"/> |
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.
| <button name="estate_property_action_sold" type="object" string="Sold" invisible="state == 'sold' or state == 'cancelled'"/> | |
| <button name="estate_property_action_sold" type="object" string="Sold" invisible="state in ('sold', 'cancelled')"/> |

No description provided.