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

[17.0][MIG] repair_type: Migration to 17.0 #43

Merged
merged 28 commits into from
Jul 31, 2024

Conversation

miquelalzanillas
Copy link
Contributor

@miquelalzanillas miquelalzanillas commented May 29, 2024

Standard migration with one exception:

  • 'repair.line' model is missing in v17 and repair lines has been moved to 'stock.move'

cc https://github.com/APSL 155813 @peluko00 @mpascuall please review

BernatPForgeFlow and others added 27 commits May 29, 2024 09:27
The destination location was removed from the repair since 12.0.
Currently translated at 72.0% (18 of 25 strings)

Translation: manufacture-14.0/manufacture-14.0-repair_type
Translate-URL: https://translation.odoo-community.org/projects/manufacture-14-0/manufacture-14-0-repair_type/hr/
Updated by "Update PO files to match POT (msgmerge)" hook in Weblate.

Translation: manufacture-14.0/manufacture-14.0-repair_type
Translate-URL: https://translation.odoo-community.org/projects/manufacture-14-0/manufacture-14-0-repair_type/
Currently translated at 100.0% (23 of 23 strings)

Translation: manufacture-14.0/manufacture-14.0-repair_type
Translate-URL: https://translation.odoo-community.org/projects/manufacture-14-0/manufacture-14-0-repair_type/it/
Updated by "Update PO files to match POT (msgmerge)" hook in Weblate.

Translation: repair-16.0/repair-16.0-repair_type
Translate-URL: https://translation.odoo-community.org/projects/repair-16-0/repair-16-0-repair_type/
Currently translated at 100.0% (23 of 23 strings)

Translation: repair-16.0/repair-16.0-repair_type
Translate-URL: https://translation.odoo-community.org/projects/repair-16-0/repair-16-0-repair_type/it/
Currently translated at 100.0% (23 of 23 strings)

Translation: repair-16.0/repair-16.0-repair_type
Translate-URL: https://translation.odoo-community.org/projects/repair-16-0/repair-16-0-repair_type/it/
@miquelalzanillas miquelalzanillas mentioned this pull request May 29, 2024
4 tasks
@miquelalzanillas miquelalzanillas changed the title [17.0][MIG] repair_type [17.0][MIG] repair_type: Migration to 17.0 May 29, 2024
@peluko00 peluko00 force-pushed the 17.0-mig-repair_type branch from b48cb2b to e02b877 Compare July 5, 2024 09:04
@peluko00
Copy link
Contributor

peluko00 commented Jul 5, 2024

Hi @BernatPForgeFlow,

Do you know how to test migration script in v17 in that case?

Thanks in advance

@peluko00 peluko00 force-pushed the 17.0-mig-repair_type branch 3 times, most recently from 178d058 to ef54e99 Compare July 8, 2024 06:53
@peluko00
Copy link
Contributor

peluko00 commented Jul 8, 2024

Hello @BernatPForgeFlow @LoisRForgeFlow! In collaboration with @miquelalzanillas we carried out the migration including the data migration script.
Can you review when you can? Thank you very much in advance

@peluko00 peluko00 force-pushed the 17.0-mig-repair_type branch from ef54e99 to b854e0c Compare July 8, 2024 07:24
@BernatPForgeFlow
Copy link
Member

Hi @peluko00 @miquelalzanillas! Thanks for the improvements! I add some comments for things that I miss.

I am missing the 'Default Add Source Location' and 'Default Remove Destination Location' in the operation types. We use these locations to record which components have been used to repair products and are under warranty.
image

Also, can you create the new operation type fields with the same definition as the core ones? https://github.com/odoo/odoo/blob/17.0/addons/repair/models/stock_picking.py#L25 In that way, we pre-compute a value when creating it and we can edit it later. For the 'Default ... Source Location' fields I would maybe use this compute: https://github.com/odoo/odoo/blob/17.0/addons/stock/models/stock_picking.py#L252

Then, for the migration script, if you want to add fields like 'sequence_id' or 'sequence_prefix' that are not from this module, I would use a column_exists to make sure those columns exist: https://github.com/OCA/partner-contact/blob/14.0/partner_stage/migrations/14.0.2.0.0/pre-migrate.py#L8
If you want to migrate all repair_type_* modules in this single migration script, I would add a comment in the readme saying that the migration of that modules is added to this one.
As a final comment, in the migration script, since you will probably need to add many ifs to check if some columns exist and there won't probably be many records to migrate, I would perhaps create the new records via python.

@peluko00
Copy link
Contributor

peluko00 commented Jul 8, 2024

Hi @peluko00 @miquelalzanillas! Thanks for the improvements! I add some comments for things that I miss.

I am missing the 'Default Add Source Location' and 'Default Remove Destination Location' in the operation types. We use these locations to record which components have been used to repair products and are under warranty. image

Also, can you create the new operation type fields with the same definition as the core ones? https://github.com/odoo/odoo/blob/17.0/addons/repair/models/stock_picking.py#L25 In that way, we pre-compute a value when creating it and we can edit it later. For the 'Default ... Source Location' fields I would maybe use this compute: https://github.com/odoo/odoo/blob/17.0/addons/stock/models/stock_picking.py#L252

Then, for the migration script, if you want to add fields like 'sequence_id' or 'sequence_prefix' that are not from this module, I would use a column_exists to make sure those columns exist: https://github.com/OCA/partner-contact/blob/14.0/partner_stage/migrations/14.0.2.0.0/pre-migrate.py#L8 If you want to migrate all repair_type_* modules in this single migration script, I would add a comment in the readme saying that the migration of that modules is added to this one. As a final comment, in the migration script, since you will probably need to add many ifs to check if some columns exist and there won't probably be many records to migrate, I would perhaps create the new records via python.

Hi @BernatPForgeFlow, thanks for the annotations.

The 'Default Remove Destination Location' field is defined in the core.

@peluko00 peluko00 force-pushed the 17.0-mig-repair_type branch from b854e0c to 08f7f2b Compare July 15, 2024 17:54
Copy link
Member

@BernatPForgeFlow BernatPForgeFlow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I add the last comments. To set the default locations in the Operation Type I would use the following structure. To do that, we can inherit from core compute methods and add some logic afterwards. I add as individual comments how I would replace each of the methods.
image
Apart from that, in the '_get_repair_locations()' I would use the default_add_location_dest_id that we are defining in the operation type.

)

@api.depends("code")
def _compute_default_location_src_id(self):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@api.depends("code")
def _compute_default_location_src_id(self):
    res = super()._compute_default_location_src_id()
    for picking_type in self:
        stock_location = picking_type.warehouse_id.lot_stock_id
        if picking_type.code == "repair_operation":
            picking_type.default_add_location_src_id = stock_location.id
    return res

).id

@api.depends("code")
def _compute_default_location_dest_id(self):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@api.depends("code")
def _compute_default_location_dest_id(self):
    res = super()._compute_default_location_dest_id()
    for picking_type in self:
        if picking_type.code == "repair_operation":
            picking_type.default_add_location_dest_id = picking_type.default_location_dest_id.id
            picking_type.default_remove_location_src_id = picking_type.default_location_dest_id.id
            picking_type.default_recycle_location_src_id = picking_type.default_location_dest_id.id
    return res

):
res = (
self.repair_id.picking_type_id.default_add_location_src_id,
res[1],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

self.repair_id.picking_type_id.default_add_location_dest_id

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@peluko00 Here I was meaning to change the res[1] by self.repair_id.picking_type_id.default_add_location_dest_id.
First one should keep as self.repair_id.picking_type_id.default_add_location_src_id

@peluko00 peluko00 force-pushed the 17.0-mig-repair_type branch from 08f7f2b to 0885008 Compare July 19, 2024 12:01
@peluko00
Copy link
Contributor

I add the last comments. To set the default locations in the Operation Type I would use the following structure. To do that, we can inherit from core compute methods and add some logic afterwards. I add as individual comments how I would replace each of the methods. image Apart from that, in the '_get_repair_locations()' I would use the default_add_location_dest_id that we are defining in the operation type.

Thanks for your comments but i don't undestand exactly what is the logical purpose now for that changes.
I commit new changes for that, can you give me new feedback about it.
Thanks!

@BernatPForgeFlow
Copy link
Member

Thanks for your comments but i don't undestand exactly what is the logical purpose now for that changes. I commit new changes for that, can you give me new feedback about it. Thanks!

Thank you very much! The purpose of these changes is to default to a logical stock move if someone wants to set up a new "Repair" operation type. This way, even if they want to change locations, they will have a schema to base on their changes. And then also that when the repair orders are made, that we actually take the locations that we have configured in the operation type.
https://github.com/user-attachments/assets/d786a2e5-cfa8-42dc-ad1d-2e3a9364cfe6

Then, with the last change that I requested some minutes ago I will approve this PR 👍 .

@peluko00 peluko00 force-pushed the 17.0-mig-repair_type branch from 0885008 to 377edd2 Compare July 31, 2024 06:46
@peluko00
Copy link
Contributor

Thanks for your comments but i don't undestand exactly what is the logical purpose now for that changes. I commit new changes for that, can you give me new feedback about it. Thanks!

Thank you very much! The purpose of these changes is to default to a logical stock move if someone wants to set up a new "Repair" operation type. This way, even if they want to change locations, they will have a schema to base on their changes. And then also that when the repair orders are made, that we actually take the locations that we have configured in the operation type. https://github.com/user-attachments/assets/d786a2e5-cfa8-42dc-ad1d-2e3a9364cfe6

Then, with the last change that I requested some minutes ago I will approve this PR 👍 .

Just done! Can you make the final review? Thanks in advance

Copy link
Member

@BernatPForgeFlow BernatPForgeFlow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Functional and code review! 👍

Copy link

@LoisRForgeFlow LoisRForgeFlow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

@peluko00
Copy link
Contributor

Is ready for merge @LoisRForgeFlow @BernatPForgeFlow ?

@LoisRForgeFlow
Copy link

/ocabot merge nobump

@OCA-git-bot
Copy link
Contributor

What a great day to merge this nice PR. Let's do it!
Prepared branch 17.0-ocabot-merge-pr-43-by-LoisRForgeFlow-bump-nobump, awaiting test results.

@OCA-git-bot
Copy link
Contributor

This PR has the approved label and has been created more than 5 days ago. It should therefore be ready to merge by a maintainer (or a PSC member if the concerned addon has no declared maintainer). 🤖

@OCA-git-bot OCA-git-bot merged commit e924a48 into OCA:17.0 Jul 31, 2024
7 checks passed
@OCA-git-bot
Copy link
Contributor

Congratulations, your PR was merged at 1d0a56a. Thanks a lot for contributing to OCA. ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.