Skip to content

Conversation

@MiquelRForgeFlow
Copy link
Contributor

Make use of merge_records tool to merge records.

--
I confirm I have signed the CLA and read the PR guidelines at www.odoo.com/submit-pr

@MiquelRForgeFlow
Copy link
Contributor Author

I can retarget to v11 branch if you prefer.

@kos94ok-3D
Copy link

We have not the constrain for combination_indices in pre-migration so maybe better to calculate combination_indices and then group product by product template and combination_indices?

@MiquelRForgeFlow MiquelRForgeFlow force-pushed the 13.0-fix-merge-products-with-same-attributes branch from e297acb to 29d8bb4 Compare May 17, 2021 13:17
@MiquelRForgeFlow MiquelRForgeFlow force-pushed the 13.0-fix-merge-products-with-same-attributes branch from 29d8bb4 to a1f3395 Compare June 4, 2021 10:56
@kos94ok-3D
Copy link

Hi, @MiquelRForgeFlow Could you rebase it?

@MiquelRForgeFlow MiquelRForgeFlow force-pushed the 13.0-fix-merge-products-with-same-attributes branch from a1f3395 to c272fd6 Compare November 19, 2021 09:45
@kos94ok-3D
Copy link

Maybe need to be added in a commit? odoo/odoo#32086
And said that it was added in Odoo v12 6 months after the release of Odoo v13.

Copy link

@kos94ok-3D kos94ok-3D left a comment

Choose a reason for hiding this comment

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

Tested on a real DB

Copy link
Member

@pedrobaeza pedrobaeza left a comment

Choose a reason for hiding this comment

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

Shouldn't you update combination_indices after the merge?

@MiquelRForgeFlow
Copy link
Contributor Author

Shouldn't you update combination_indices after the merge?

No, why? The combination_indices are the same, they don't change.

for template_id in templates:
openupgrade_merge_records.merge_records(
env, 'product.product', templates[template_id][1:],
templates[template_id][0], field_spec=None, method='sql',
Copy link
Contributor Author

@MiquelRForgeFlow MiquelRForgeFlow Dec 16, 2021

Choose a reason for hiding this comment

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

The question now is: should I put a field_spec?

Copy link
Member

Choose a reason for hiding this comment

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

It depends if the standard fields require it or default merge values are enough

Copy link
Contributor Author

@MiquelRForgeFlow MiquelRForgeFlow Dec 17, 2021

Choose a reason for hiding this comment

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

Yeah, my best option is {'default_code': 'first_not_null', 'active': 'or', 'barcode': 'first_not_null', 'volume': 'max', 'weight': 'max'}. My concern is for custom modules that add float/char/boolean fields, which would need to add more things in this dict. Maybe we could add in openupgradelib a functionality like if the dict contains 'other_fields': 'preserve', then every other field is excluded and preserved.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@pedrobaeza
Copy link
Member

My take on this is that merging complete products is something that shouldn't be corrected at OpenUpgrade level. If they have done such ugly thing, then it must be fixed before doing the migration.

@MiquelRForgeFlow
Copy link
Contributor Author

MiquelRForgeFlow commented Dec 17, 2021

Ok (don't delete branch)

@cvinh
Copy link

cvinh commented Mar 16, 2022

FYI this PR fixed our issue where we have a product with same attributes
@MiquelRForgeFlow thanks for not having deleted it

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.

4 participants