-
Notifications
You must be signed in to change notification settings - Fork 21
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
12.0 Fix "stock_inventory_merge" #112
base: 12.0
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -74,11 +74,11 @@ def complete_with_zero(self): | |
item | ||
) == self._get_inventory_line_keys(product_line): | ||
found = True | ||
continue | ||
break | ||
if not found: | ||
# Add the line, if inventory line was not found | ||
product_line["product_qty"] = 0 | ||
product_line["inventory_id"] = self.id | ||
product_line["inventory_id"] = inventory.id | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. indeed ! |
||
line_obj.create(product_line) | ||
|
||
@api.multi | ||
|
@@ -109,14 +109,18 @@ def action_merge_duplicated_line(self): | |
uom_obj.browse(default_uom_id), | ||
) | ||
|
||
# Update the first line with the sumed quantity | ||
keeped_line = line_obj.browse(keeped_line_id) | ||
keeped_line.write({"product_qty": sum_quantity}) | ||
|
||
# Delete all the other lines | ||
line_ids.remove(keeped_line_id) | ||
line_obj.browse(line_ids).unlink() | ||
|
||
# Update the first line with the sumed quantity | ||
# Note: This has to be done *after* deleting the other lines, | ||
# because the `write()` calls the `_check_no_duplicate_line()` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it should not fails, due to that https://github.com/grap/grap-odoo-incubator/blob/12.0/stock_inventory_merge/models/stock_inventory_line.py#L25 could you explain in which case it is failing. i don't face any problem (and I have a lot of duplicates !) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The issue here is that if the update There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hi, the inventory with duplicates can only be in a non confirm state, as the function So I see the commit 93ebd39 as unnecessary. Or maybe I missed something. If yes, could you write a test that is failing without this change ? kind regards. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hi, First of all, state Now, the analysis below is no longer valid, as that issue has already been fixed with commit eb02a51, where the flag However, the way the issue had been solved, by changing of the search domain to def _check_no_duplicate_line(self):
if self.env.context.get("do_not_check_duplicates", False):
return
return super(StockInventoryLine, self)._check_no_duplicate_line() rather than accomplish the effect indirectly in this obscure way by overwriting If this is fine, I would the revert commit 93ebd39 and then add the suggested code change for overwriting [Here follows the obsolete analysis:] Module "stock_inventory_merge" provides a flag However, the method So, if the accumulated quantity is written to the line to be kept ( For a test,
Summarized, I think this commit 93ebd39 is actually necessary. keeped_line.with_context(do_not_check_duplicates=True).write({"product_qty": sum_quantity}) [And this is what makes the analysis obsolete, as that context flag gets already added in |
||
# which may trigger the "You cannot have two inventory | ||
# adjustments..." exception. | ||
keeped_line = line_obj.browse(keeped_line_id) | ||
keeped_line.write({"product_qty": sum_quantity}) | ||
|
||
# Custom Section | ||
@api.multi | ||
def _get_duplicated_line_ids(self): | ||
|
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.
makes sense.