-
-
Notifications
You must be signed in to change notification settings - Fork 265
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
[15.0][ADD] product_variant_template_reassign: New module #373
base: 15.0
Are you sure you want to change the base?
[15.0][ADD] product_variant_template_reassign: New module #373
Conversation
b333364
to
5ceb0cb
Compare
product_variant_template_reassign/wizards/reassign_variant_views.xml
Outdated
Show resolved
Hide resolved
"product.template", | ||
self.origin_product_template_id.ids, | ||
self.target_product_template_id.id, | ||
method="sql", |
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.
With method="sql", the possible default_code
in the unique variant is lost, as well as other data. One possibility is to specify the merge options.
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.
Ok, done. Although with products with operations like done stock moves normally isn't possible
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.
Well, I was not talking about changing the merge method, but adding the extra parameters to indicate the field merge options.
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.
Understood. I added a hook method to configure it and added a test case. Do know of other possible issues of that kind?
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 image and list price.
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.
I should try for image. As for pricelist_id, its related to the template... what should we do there?
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.
Don't do anything on the list price then.
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.
I understood pricelist_id which is related indeed. list_price should be kept and it's done so now. A special post-process hook has been added to deal with field specs that don't work with merge_records
91398a1
to
85e35e5
Compare
"product.template", | ||
self.origin_product_template_id.ids, | ||
self.target_product_template_id.id, | ||
method="sql", |
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 image and list price.
6b88490
to
0ae17f7
Compare
"author": "Tecnativa, Odoo Community Association (OCA)", | ||
"maintainers": ["chienandalu"], | ||
"license": "AGPL-3", | ||
"depends": ["purchase_stock", "website_sale_stock"], |
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 have forgotten this again.
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.
sorry... 😵💫️
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 again...
0ae17f7
to
5d42634
Compare
@carlosdauden can you review |
5d42634
to
c49b2c9
Compare
).unlink() | ||
# Take a snapshot of the original variant data before the merge | ||
original_values = ( | ||
self.origin_product_template_id.product_variant_id.copy_data() |
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 not using read
instead?
c49b2c9
to
8d7a869
Compare
I was thinking of doing the same kind of addon in V16 and I found your PR. There is, however, one element in the approach that questions me. Why does attaching the variant to another template involve creating a new variant and then merging the existing variant into this new variant? Naively I thought I'd do this first step by simply changing the parent_id in DB and managing the attributes between the variant and the template in the same process. As for template management, my idea was also to update all the FKs to the original template with the value of the target template and thereafter remove-it. I haven't yet really analyzed all the impacts and functional elements linked to the template and there are undoubtedly many challenges to be met. For example, supplier information should be linked to the variants when the reference is updated from the old template to the new . |
Hi, @lmignon
The main goal of the approach is using the power
Yes, in cases like that one we could be missing some of the bussiness logic and we should deal with it. |
Thank you for your explanation @chienandalu My main concern with this approach is the impact on the database. With the creation and merge of the old variant to a new one, the process will imply the update of a too large number of records into too many tables. This will lead for sure to concurrent update errors and deadlock on systems daily managing thousands of stock pickings, sale orders etc, making this functionality unusable (you should also take into account all the stock.move.line, sale.order.line, stock.move and sock.move.line existing into your db where the variant is referenced). In my case, it's the biggest challenge. That's why I'm thinking to an approach with the less impact on the database. If we don't create a new variant, we drastically reduce the impact and will speed up the process.... The merge of the template is also possible but do we really need-it. All we need is to be able to use the logic of swapping the original template id with the new one into all the column where a FK exists. |
There are a lot of submodels and some tricky fields like |
Thank you @pedrobaeza. My use case is to move from an installation where the variant were not used at all to a full support of the variants. This process will involve a lot of reassignment of variants to others template. This process must be possible on a running instance as part of the day to day work. That's why I will go for the less intrusive approach. An sql update on the table stock_move, stock_move_line, account_move_line, .. is not possible without locking the system. For example, we've 9 986 501 records into the account_move_line table. I'm conscious that the change on the |
8d7a869
to
a098c28
Compare
a098c28
to
ae2a419
Compare
ae2a419
to
30216d5
Compare
cc @Tecnativa TT51495
ready for review @carlosdauden @pedrobaeza