yoelf - technical training#1244
Conversation
d31232a to
77632cf
Compare
Mathilde411
left a comment
There was a problem hiding this comment.
Mostly okay so far :)
There are some things to fix still :)
Co-authored-by: Mathilde <mathilde.pascal411@gmail.com>
0f172ad to
2538c7d
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.
Mathilde411
left a comment
There was a problem hiding this comment.
Pretty nice, only changes in the python files mainly.
Good job :)
| estate_property_type_id = fields.Many2one( | ||
| "estate.property.type", string="Property Type" | ||
| ) |
There was a problem hiding this comment.
If you name the field 'property_type_id' you won't need to add the string attribute :)
| estate_property_type_id = fields.Many2one( | ||
| "estate.property.type", string="Property Type" | ||
| ) | ||
| buyer_id = fields.Many2one("res.partner", string="Buyer", copy=False, readonly=True) |
There was a problem hiding this comment.
Won't say it anymore ater that but there are more instances:
For many2one field the default string will be Xyz for xyz_id
And for one2many and many2many Xyz for xyz_ids
| @api.onchange("garden") | ||
| def _onchange_has_garden(self): | ||
| if self.garden: | ||
| self.garden_area = 10 | ||
| self.garden_orientation = "north" |
There was a problem hiding this comment.
Here you forgot to reset to the default value if garden is false
| property.best_price = ( | ||
| max(property.estate_property_offer_ids.mapped("price")) | ||
| if property.estate_property_offer_ids | ||
| else None | ||
| ) |
There was a problem hiding this comment.
| property.best_price = ( | |
| max(property.estate_property_offer_ids.mapped("price")) | |
| if property.estate_property_offer_ids | |
| else None | |
| ) | |
| property.best_price = max(property.estate_property_offer_ids.mapped("price"), default=0) |
| raise UserError("You can't sell a a cancelled property :)") | ||
|
|
||
| property.state = "sold" | ||
| return True |
There was a problem hiding this comment.
return True is indented too much here, will return at the first iteration of the loop
| raise UserError("you can't cancel a sold property :)") | ||
|
|
||
| property.state = "cancelled" | ||
| return True |
| precision_digits=2, | ||
| ) == -1: | ||
| raise ValidationError( | ||
| r"the selling price cannot be lower than 90% of the expected price" |
| if offer.create_date: | ||
| offer.date_deadline = fields.Date.add( | ||
| offer.create_date, | ||
| days=offer.validity, | ||
| ) | ||
| else: | ||
| offer.date_deadline = fields.Date.add( | ||
| fields.Date.today(), days=offer.validity | ||
| ) |
There was a problem hiding this comment.
| if offer.create_date: | |
| offer.date_deadline = fields.Date.add( | |
| offer.create_date, | |
| days=offer.validity, | |
| ) | |
| else: | |
| offer.date_deadline = fields.Date.add( | |
| fields.Date.today(), days=offer.validity | |
| ) | |
| offer.date_deadline = fields.Date.add( | |
| offer.create_date or fields.Date.today(), | |
| days=offer.validity, | |
| ) |
| for offer in self: | ||
| if offer.create_date: | ||
| offer.validity = (offer.date_deadline - offer.create_date.date()).days | ||
| else: | ||
| offer.validity = (offer.date_deadline - fields.Date.today()).days |
There was a problem hiding this comment.
| for offer in self: | |
| if offer.create_date: | |
| offer.validity = (offer.date_deadline - offer.create_date.date()).days | |
| else: | |
| offer.validity = (offer.date_deadline - fields.Date.today()).days | |
| date = offer.create_date.date() if offer.create_date else fields.Date.today() | |
| offer.validity = (offer.date_deadline - date).days |
| <menuitem id="estate_settings_menu" name="Settings"> | ||
| <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> |

PR with the first chapter exercises