-
Notifications
You must be signed in to change notification settings - Fork 244
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
[13.0] [MIG] fieldservice_maintenance #670
Conversation
…nce_equipment_id is not set
…code suggested by zbik2607
Currently translated at 100.0% (8 of 8 strings) Translation: field-service-12.0/field-service-12.0-fieldservice_maintenance Translate-URL: https://translation.odoo-community.org/projects/field-service-12-0/field-service-12-0-fieldservice_maintenance/pt_BR/
Co-authored-by: Daniel Reis <dgreis@sapo.pt>
Updated by "Update PO files to match POT (msgmerge)" hook in Weblate. Translation: field-service-12.0/field-service-12.0-fieldservice_maintenance Translate-URL: https://translation.odoo-community.org/projects/field-service-12-0/field-service-12-0-fieldservice_maintenance/
Updated by "Update PO files to match POT (msgmerge)" hook in Weblate. Translation: field-service-12.0/field-service-12.0-fieldservice_maintenance Translate-URL: https://translation.odoo-community.org/projects/field-service-12-0/field-service-12-0-fieldservice_maintenance/
Hi @smangukiya, @bodedra, @max3903, |
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.
Hello, thank you for your work.
I added some comments with questions and suggestions, thanks in advance for taking a look.
Regards,
ondelete="restrict", | ||
delegate=True, | ||
auto_join=True, | ||
index=True, |
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.
You need required=True for delegate fields.
If the reason is that the field becomes required on the Form view, you can adapt the attrs required with False in the view.
[("maintenance_equipment_id", "=", equipment.id)] | ||
) | ||
if not other: | ||
equipment.is_fsm_equipment = False |
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.
is_fsm_equipment should be a computed field. If you are using a One2many fsm_equipment_ids on maintenance.equipment then your computed field just have to look if fsm_equipment_ids contains records.
Therefore you don't have to overwrite the unlink anymore.
maintenance_equipment_id = self.env["maintenance.equipment"].create( | ||
self._prepare_maintenance_vals(vals) | ||
) | ||
if maintenance_equipment_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.
The "if" here is not necessary because if the create doesn't work, you'll have an exception
if maintenance_equipment_id: | ||
vals.update({"maintenance_equipment_id": maintenance_equipment_id.id}) | ||
res = super().create(vals) | ||
maintenance_equipment_id.fsm_equipment_id = res.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.
You should use a one2many (fsm_equipment_ids) on maintenance.equipment model. Therefore no need to write on the maintenance_equipment after the create.
_inherit = "maintenance.equipment" | ||
|
||
is_fsm_equipment = fields.Boolean(string="Is a FSM Equipment") | ||
fsm_equipment_id = fields.Many2one("fsm.equipment", "FSM Equipment", readonly=True) |
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.
This should be a one2many. Is there any reason why you use a many2one instead?
class MaintenanceEquipment(models.Model): | ||
_inherit = "maintenance.equipment" | ||
|
||
is_fsm_equipment = fields.Boolean(string="Is a FSM Equipment") |
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.
This should be computed field.
class MaintenanceRequest(models.Model): | ||
_inherit = "maintenance.request" | ||
|
||
fsm_order_id = fields.Many2one("fsm.order", "Field Service Order") |
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.
Why don't use a one2many fields with inverse_name = request_id ?
With your current implementation when you create the maintenance.request from the fsm.order your fsm_order_id is empty.
You should have a same result from both side therefore it is better to use a one2many.
If you need a "one2one" relation I think it is better to apply a constrains()
self._context.get("active_ids", []) | ||
) | ||
for maintenance_id in maintenance_equpment_ids: | ||
if not (maintenance_id.product_id or maintenance_id.lot_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.
Hi there! Thanks for this pr.
I have a problem with this line.
It leads to a bug since there is no product_id on a maintenance.equipment.
There hasn't been any activity on this pull request in the past 4 months, so it has been marked as stale and it will be closed automatically if no further activity occurs in the next 30 days. |
Migration of fieldservice_maintenance to 13.0
#354
Moved from #657