Skip to content
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

Closed
wants to merge 59 commits into from

Conversation

RLeeOSI
Copy link
Contributor

@RLeeOSI RLeeOSI commented Nov 18, 2020

Migration of fieldservice_maintenance to 13.0

#354

Moved from #657

OCA-git-bot and others added 13 commits November 17, 2020 13:20
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/
@OCA-git-bot
Copy link
Contributor

Hi @smangukiya, @bodedra, @max3903,
some modules you are maintaining are being modified, check this out!

@max3903 max3903 added this to the 13.0 milestone Dec 14, 2020
@brian10048 brian10048 linked an issue Jan 16, 2021 that may be closed by this pull request
43 tasks
Copy link

@apineux apineux left a 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,
Copy link

@apineux apineux Apr 20, 2021

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
Copy link

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:
Copy link

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
Copy link

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)
Copy link

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")
Copy link

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")
Copy link

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):
Copy link

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.

@github-actions
Copy link

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.
If you want this PR to never become stale, please ask a PSC member to apply the "no stale" label.

@github-actions github-actions bot added the stale PR/Issue without recent activity, it'll be soon closed automatically. label Jun 26, 2022
@github-actions github-actions bot closed this Jul 31, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
migration stale PR/Issue without recent activity, it'll be soon closed automatically.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Migration to version 13.0