First module created#1234
Conversation
…reated by/on and Last updated by/on as they are automatically generated.
6c4f13f to
fce6075
Compare
c98f6fa to
64d81ad
Compare
delcourtfl
left a comment
There was a problem hiding this comment.
Hello there ! Good work already, just a few comments.
Also it seems your first commits have the wrong author set (most probably because your config was not properly set before pushing, might want to check into this as a general git exercise)
| @@ -0,0 +1,32 @@ | |||
| # -*- coding: utf-8 -*- | |||
| string='Type', | ||
| selection=[('north', 'North'), ('south', 'South'), ('east', 'East'), ('west', 'West')], | ||
| help="this is used to indicated the garden orientation" | ||
| ) No newline at end of file |
There was a problem hiding this comment.
It's recommended to have one empty line at the end of each file
| 'author': "covey", | ||
| 'website': "", | ||
| 'category': 'Tutorials', | ||
| 'version': '0.1', |
There was a problem hiding this comment.
| 'version': '0.1', | |
| 'version': '19.0.0.1.0', |
First 2 numbers of the version are the odoo version, and the 3 next are your module's version. This will prevent your module to be installed in another version than 19.0 in this instance. (Standard modules don't do it because they are 19.0)
| 'version': '0.1', | ||
| 'application': True, | ||
| 'installable': True, | ||
| 'depends': ['base'], |
There was a problem hiding this comment.
| 'depends': ['base'], | |
| 'depends': [ | |
| 'base', | |
| ], |
Most of the time it's better to keep arrays formatted in a way that will limit further diff, and doesn't break the git blame when we need to add some additional dependencies
| 'author': "covey", | ||
| 'website': "", |
There was a problem hiding this comment.
| 'author': "covey", | |
| 'website': "", | |
| 'author': 'covey', | |
| 'website': '', |
Try to avoid mixing single and double quote when it's not needed
145cd42 to
aa12051
Compare
aa12051 to
cfe6336
Compare
delcourtfl
left a comment
There was a problem hiding this comment.
Hello ! Everything is quite good already, just added a few minor remarks.
| if float_is_zero(record.selling_price, precision_digits=2) or float_is_zero( | ||
| record.expected_price, precision_digits=2 | ||
| ): | ||
| raise ValidationError( | ||
| "Selling price and expected price must be greater than zero." | ||
| ) | ||
| if ( | ||
| float_compare( | ||
| record.selling_price, | ||
| record.expected_price * 0.9, | ||
| precision_digits=2, | ||
| ) | ||
| < 0 | ||
| ): | ||
| raise ValidationError( | ||
| "Selling price cannot be lower than 90%of expected price!" | ||
| ) |
There was a problem hiding this comment.
This function is not that readable, I suppose it's what a linter would suggest to avoid too long lines (+80 char), but I think it can be improved in a few ways (avoid inconsistent line breaks, use temp variables, ...), for example:
| if float_is_zero(record.selling_price, precision_digits=2) or float_is_zero( | |
| record.expected_price, precision_digits=2 | |
| ): | |
| raise ValidationError( | |
| "Selling price and expected price must be greater than zero." | |
| ) | |
| if ( | |
| float_compare( | |
| record.selling_price, | |
| record.expected_price * 0.9, | |
| precision_digits=2, | |
| ) | |
| < 0 | |
| ): | |
| raise ValidationError( | |
| "Selling price cannot be lower than 90%of expected price!" | |
| ) | |
| if any( | |
| float_is_zero(value, precision_digits=2) | |
| for value in [record.selling_price, record.expected_price] | |
| ): | |
| raise ValidationError( | |
| "Selling price and expected price must be greater than zero." | |
| ) | |
| if float_compare( | |
| record.selling_price, | |
| record.expected_price * 0.9, | |
| precision_digits=2, | |
| ) < 0: | |
| raise ValidationError( | |
| "Selling price cannot be lower than 90% of expected price!" | |
| ) |
| _check_offer_price_positive = models.Constraint( | ||
| "CHECK(price > 0)", "The offer price must be positive." | ||
| ) |
There was a problem hiding this comment.
Always try to keep the constraints after the fields (see https://www.odoo.com/documentation/19.0/contributing/development/coding_guidelines.html#symbols-and-conventions for the model attribute order)
| "version": "19.0.0.1.0", | ||
| "application": True, | ||
| "installable": True, | ||
| "depends": ["base"], |
There was a problem hiding this comment.
| "depends": ["base"], | |
| "depends": [ | |
| "base", | |
| ], |
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.
| record.garden_area = 0 | ||
| record.garden_orientation = None | ||
|
|
||
| def cancel_sale(self): |
There was a problem hiding this comment.
Better to explicitly keep action in the name in this case (so that we know it's coming from the ui): action_cancel_sale
| for record in self: | ||
| record.state = "cancelled" | ||
|
|
||
| def mark_as_sold(self): |
| @@ -0,0 +1 @@ | |||
| from . import test_estate_property No newline at end of file | |||

Creation of Estate Module: