onboarding server framework - #1383
Conversation
| @@ -0,0 +1 @@ | |||
| from . import models No newline at end of file | |||
There was a problem hiding this comment.
Keep in mind to always add a newline in the end of each file
| 'views': [ | ||
|
|
||
| ], |
There was a problem hiding this comment.
We can remove this I don't think we need it since we are already defining the views in the data key
| <field name="model">estate.property</field> | ||
| <field name="arch" type="xml"> | ||
| <search string="Search"> | ||
| <field name="name" string="Title"/> |
There was a problem hiding this comment.
This will work fine but to avoid setting a string for each field in each view you can add this string to the field definition in python and it will be used everywhere you call this field in XML
| from odoo import fields, models | ||
| from dateutil.relativedelta import relativedelta | ||
|
|
||
| class TestModel(models.Model): |
There was a problem hiding this comment.
I know this is a tutorial 😅 but avoid to name anything test unless it is a real test as this is the convention we use for unit test files
yoba-odoo
left a comment
There was a problem hiding this comment.
Nice work 👌
While applying the changes try to make the ci/* checks pass
| string='type', | ||
| selection=[('north', 'North'), ('south', 'South'), ('East', 'east'), ('West', 'west')], | ||
| ) | ||
| total_area = fields.Integer(string="Total Area", compute="_compute_total_surface") |
There was a problem hiding this comment.
| total_area = fields.Integer(string="Total Area", compute="_compute_total_surface") | |
| total_area = fields.Integer(string="Total Area", compute="_compute_total_area") |
We normally tend to name the compute method after the exact name of field
| return True | ||
|
|
||
| @api.ondelete(at_uninstall=False) | ||
| def ondelete(self): |
There was a problem hiding this comment.
It is kinda a nitpick but we usually name those method as _unlink_**** for example:
| def ondelete(self): | |
| def _unlink_except_new_cancelled(self): |
| for record in self: | ||
| if record.create_date: | ||
| record.date_deadline = record.create_date + relativedelta(days=record.validity) | ||
| else: | ||
| record.date_deadline = fields.Datetime.today() + relativedelta(days=record.validity) |
There was a problem hiding this comment.
| for record in self: | |
| if record.create_date: | |
| record.date_deadline = record.create_date + relativedelta(days=record.validity) | |
| else: | |
| record.date_deadline = fields.Datetime.today() + relativedelta(days=record.validity) | |
| for record in self: | |
| check_date = record.create_date if record.create_date else fields.Datetime.today() | |
| record.date_deadline = check_date + relativedelta(days=record.validity) |
To avoid duplicating some of the code we can do this, wdyt?
|
|
||
| # ===========button actions=========== | ||
| def action_accept(self): | ||
|
|
| property = self.env["estate.property"].browse(to_create["property_id"]) | ||
| new_bid = to_create["price"] | ||
| for offer in property.offer_ids: | ||
| if offer.price > new_bid: |
There was a problem hiding this comment.
since you introduced an order for the offers here https://github.com/odoo/tutorials/pull/1383/changes#diff-8000c23a2907f34f0cc387be9dc4178411fda81b674724854bd4d048f9e11b16R9 the recordset will be ordered upon price by default so normally offer_ids[0] will have the offer that has the highest price
| @@ -0,0 +1,10 @@ | |||
| from odoo import fields, models | |||
|
|
|||
| class InheritedModel(models.Model): | |||
There was a problem hiding this comment.
When inherit a model we name the class the same as the parent class
| @@ -0,0 +1,62 @@ | |||
| <?xml version="1.0"?> | |||
There was a problem hiding this comment.
it is a better practice to have a XML view file for each model.
So here separate the estate_property and the estate_property_type and estate_property_tag and estate_property_offer views each in a separate file
| @@ -0,0 +1,180 @@ | |||
| <?xml version="1.0"?> | |||
prevent other people from breaking the reset of the estate's garden area and orientation when a garden is present
In order to improve readability estate views which were all in one file have been refactored such that every view has their own file named according to their id.
…n be set. Since the requirements don't allow the property type to be edited directly in the list view a field has been created in the form view to allow setting the property type.
added a component containing a button and a counter such that the button increments the counter. also added a component which creates its own children buttons such that it's possible to have a global counter of all the children buttons.

No description provided.