-
Notifications
You must be signed in to change notification settings - Fork 2.7k
[ADD] estate: init #1029
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 #1029
Conversation
yoba-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.
Nice work 👏
Just some small comments, Also if you can squash the LINT and FIX comments with their parent IMP commit it would be better to keep a clean commit history.
yoba-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.
Some more changes 😇
84e43df to
2afca8f
Compare
yoba-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.
Almost perfect 👌
Just pay attention to the EOL at the end of every file 😄
d6392eb to
3819b02
Compare
| @api.model | ||
| def create(self, offers_list): | ||
| for offer in offers_list: | ||
| linked_property = self.env['estate.property'].browse(offer['property_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.
| linked_property = self.env['estate.property'].browse(offer['property_id']) | |
| linked_property = self.env['estate.property'].browse(offer.get('property_id')) |
When fetching something from a dictionary we tend to use get to avoid KeyError if the key doesn't exist. I know mostly the property_id will always be there but it is better safe than sorry 😅
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.
Just learn a new python thing ty 😂
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.
By doing that I got this error:

I would do that to fix it :
property_id = offer.get('property_id')
if not property_id:
continue
linked_property = self.env['estate.property'].browse(property_id)I just think I should raise an error instead of continuing but idk which type of error, I didn't saw any InternalError or something similar in the exceptions definitions. What would you do ?
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.
Yup, my bad. When using get() and the key doesn't exist it will return None which might cause an Error as browse() is waiting for int
what you can do is fallback on a default value in get() like this:
offer.get('property_id', 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.
But then if their is a property with an id of 0 it will not raise an error but change the wrong property no ?
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.
Normally we don't have a record with id 0, our id sequences are 1-indexed. But to stick with the better-safe-than-sorry ideology we can do something like
if offer.get('property_id'):
linked_property = self.env['estate.property'].browse(offer['property_id'])… property sold/canceled state management
… property offers, tags, and types
…nd field adjustments
…del with property relationship
…perty integration and invoice creation
86d8f5c to
e7282d7
Compare
…c pricing information
e7282d7 to
6dc7bc1
Compare

No description provided.