[FIX] purchase_stock: merge allocated moves

Steps to reproduce:
- In User settings add 'allocation reports' group to the admin User
- In Inventory settings enable allocation reports
- Create a stored product with 0/0 reordering rules and set a vendor
- Create an SO for that product
- Confirm the generated PO and click assign all on its receipt's allocation report
- Reduce the quantity on the SO and save

Bug:
a return is created instead of adjusting the quantity to deliver
the stock moves were not merged because their procurement method do not
match ('make_to_stock' / 'make_to_order')

Fix:
ignore procurement method when merging the moves
(introducing new config parameter)

opw-3621316

closes odoo/odoo#154942

X-original-commit: 337d4c79bf51f0d1705a80341fa83a88c5297128
Signed-off-by: William Henrotin (whe) <whe@odoo.com>
Signed-off-by: Walid Hanniche (waha) <waha@odoo.com>
This commit is contained in:
Walid
2024-02-24 19:33:46 +00:00
parent ab7a2098f0
commit b40bd15c9c
+4 -1
View File
@@ -25,7 +25,10 @@ class StockMove(models.Model):
@api.model
def _prepare_merge_negative_moves_excluded_distinct_fields(self):
return super()._prepare_merge_negative_moves_excluded_distinct_fields() + ['created_purchase_line_ids']
excluded_fields = super()._prepare_merge_negative_moves_excluded_distinct_fields() + ['created_purchase_line_id']
if self.env['ir.config_parameter'].sudo().get_param('purchase_stock.merge_different_procurement'):
excluded_fields += ['procure_method']
return excluded_fields
def _compute_partner_id(self):
# dropshipped moves should have their partner_ids directly set