dalio - Technical Training#1233
Conversation
6d29bbd to
d9454fb
Compare
Mathilde411
left a comment
There was a problem hiding this comment.
Very solid PR.
Also be careful of usage of ' vs ". You should use a convention and stick to it.
Most R&D teams use ' :)
| { | ||
| "python.analysis.extraPaths": [ | ||
| "/home/odoo/src/venv", | ||
| "/home/odoo/src/odoo", | ||
| "/home/odoo/src/enterprise" | ||
| ], | ||
| "python.defaultInterpreterPath": "/home/odoo/src/venv/bin/python3.12" | ||
| } No newline at end of file |
There was a problem hiding this comment.
This file is your local vscode confing, you shouldn't commit and push it to the repo
| @@ -0,0 +1,2 @@ | |||
| id,name,model_id/id,group_id/id,perm_read,perm_write,perm_create,perm_unlink | |||
There was a problem hiding this comment.
Using slashes work, but most commonly used is:
| id,name,model_id/id,group_id/id,perm_read,perm_write,perm_create,perm_unlink | |
| id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink |
| @@ -0,0 +1,2 @@ | |||
| id,name,model_id/id,group_id/id,perm_read,perm_write,perm_create,perm_unlink | |||
| access_estate_property,access_estate_property,model_estate_property,base.group_user,1,1,1,1 | |||
There was a problem hiding this comment.
The access right should say what group it applies on.
Name is meant to be displayed, usually names use dots in Odoo
| access_estate_property,access_estate_property,model_estate_property,base.group_user,1,1,1,1 | |
| estate_property_access_user,estate.property.user,model_estate_property,base.group_user,1,1,1,1 |
| <menuitem id="estate_menu_root" name="Real Estate"/> | ||
| <menuitem id="estate_first_level_menu" name="Advertisements" parent="estate_menu_root"/> | ||
| <menuitem id="estate_property_menu_action" parent="estate_first_level_menu" action="estate_property_action"/> |
There was a problem hiding this comment.
Menu items can be nested, avoids having to set the parent
| <menuitem id="estate_menu_root" name="Real Estate"/> | |
| <menuitem id="estate_first_level_menu" name="Advertisements" parent="estate_menu_root"/> | |
| <menuitem id="estate_property_menu_action" parent="estate_first_level_menu" action="estate_property_action"/> | |
| <menuitem id="estate_menu_root" name="Real Estate"> | |
| <menuitem id="estate_first_level_menu" name="Advertisements"> | |
| <menuitem id="estate_property_menu_action" action="estate_property_action"/> | |
| </menuitem> | |
| </menuitem> |
| <menuitem id="estate_menu_root" name="Real Estate"/> | ||
| <menuitem id="estate_first_level_menu" name="Advertisements" parent="estate_menu_root"/> | ||
| <menuitem id="estate_property_menu_action" parent="estate_first_level_menu" action="estate_property_action"/> |
There was a problem hiding this comment.
| <menuitem id="estate_menu_root" name="Real Estate"/> | |
| <menuitem id="estate_first_level_menu" name="Advertisements" parent="estate_menu_root"/> | |
| <menuitem id="estate_property_menu_action" parent="estate_first_level_menu" action="estate_property_action"/> | |
| <menuitem id="estate_menu_root" name="Real Estate"/> | |
| <menuitem id="estate_menu_advertisement" name="Advertisements" parent="estate_menu_root"/> | |
| <menuitem id="estate_property_menu" parent="estate_menu_advertisement" action="estate_property_action"/> |
| @@ -0,0 +1,15 @@ | |||
| { | |||
| 'name': 'Real Estate', | |||
| 'version': '1.0', | |||
There was a problem hiding this comment.
When using modules outside odoo standard, best practice is to specify th Odoo version.
| 'version': '1.0', | |
| 'version': '19.0.1.0.0', |
| 'name': 'Real Estate', | ||
| 'version': '1.0', | ||
| 'depends': [ | ||
| 'base_setup' |
There was a problem hiding this comment.
For the diff if you add a new dependency
| 'base_setup' | |
| 'base', |
Also you should depend on base not base_setup
| 'data': [ | ||
| 'security/ir.model.access.csv', | ||
| 'views/estate_property_views.xml', | ||
| 'views/estate_menus.xml' |
Mathilde411
left a comment
There was a problem hiding this comment.
Very good, I don't have a lot to say :D
| @@ -0,0 +1 @@ | |||
| from . import estate_property, estate_property_type, estate_property_tag, estate_property_offer | |||
There was a problem hiding this comment.
Make it one line per import, this way you can see what commit adds whant, and resolving conflicts is easier :)
| _check_expected_price = models.Constraint( | ||
| "CHECK(expected_price > 0)", | ||
| "the expected price must be strictly positive.", | ||
| ) | ||
|
|
||
| _check_selling_price = models.Constraint( | ||
| "CHECK(selling_price >= 0)", | ||
| "the selling price must be positive.", | ||
| ) | ||
|
|
||
| @api.constrains("selling_price", "expected_price") | ||
| def _check_selling_price(self): | ||
| for record in self: | ||
|
|
||
| if float_is_zero(record.selling_price, precision_digits=2): | ||
| continue | ||
|
|
||
| lower_bound = 0.9 * record.expected_price | ||
|
|
||
| if float_compare(record.selling_price, lower_bound, precision_digits=2) == -1: | ||
| raise ValidationError( | ||
| "The selling price must be at least 90% of the expected price! " | ||
| "You must reduce the expected price if you want to accept this offer." | ||
| ) |
There was a problem hiding this comment.
Be careful about attribute ordering
| ) | ||
| property_type_id = fields.Many2one("estate.property.type", string="Property Type") | ||
| salesman_id = fields.Many2one("res.users", string="Salesman", default=lambda self: self.env.user) | ||
| buyer_id = fields.Many2one("res.partner", string="Buyer", copy=False) |
There was a problem hiding this comment.
When using a many2one the string is inferred by removing _id at the end. So buyer_id default string is "Buyer", so no need to add the string there :D
(same for many2many and one2many but w/ _ids instead)
| prices = record.offer_ids.mapped("price") | ||
|
|
||
| if prices: | ||
| record.best_price = max(prices) | ||
| else: | ||
| record.best_price = 0.0 |
There was a problem hiding this comment.
| prices = record.offer_ids.mapped("price") | |
| if prices: | |
| record.best_price = max(prices) | |
| else: | |
| record.best_price = 0.0 | |
| prices = max(record.offer_ids.mapped("price"), default=0.0) |
There is a default argument on max (and min) that avoids the condition
| def _compute_date_deadline(self): | ||
| for record in self: | ||
| base_date = record.create_date or fields.Date.today() | ||
| days_to_add = record.validity or 0 |
There was a problem hiding this comment.
You don't need the days_to_add here, for numeric fields, the default value is always 0, so you can use record.validity directly :)
|
|
||
| def _inverse_date_deadline(self): | ||
| for record in self: | ||
| base_date = fields.Date.to_date(record.create_date) or fields.Date.today() |
| for record in self: | ||
| record.status = "refused" |
There was a problem hiding this comment.
| for record in self: | |
| record.status = "refused" | |
| self.status = "refused" |
You can assign values of recordsets attributes, no need to iterate :D
| <button name="action_sold" | ||
| string="Sold" | ||
| type="object" | ||
| class="oe_highlight"/> <button name="action_cancel" | ||
| string="Cancel" | ||
| type="object"/> <field name="state" widget="statusbar" statusbar_visible="new,offer_received,offer_accepted,sold"/> |
| </div> | ||
| <group> | ||
| <group> | ||
| <field name="state"/> |
There was a problem hiding this comment.
State here is not necessary since you have the statusbar :)
2409a9d to
1338c5c
Compare
This commit is here to introduce the testing framework of Odoo. Try running the tests using `--test-tags :TestEstateProperty`. Doc: https://www.odoo.com/documentation/18.0/developer/reference/backend/testing.html?highlight=tests#invocation The tests were made such that the first one should work but the second one should fail. Your job is to ensure both tests pass in the end. You should update the behaviour of the appropriate models. If you want, you can also add a small test of your own to get a feel for it.

No description provided.