[FIX] point_of_sale: perform stock operation only when necessary

Fine tuning of
https://github.com/odoo/odoo/commit/bdd36f7ce68999576dfc30298f4ddf2572b4c7ec
to perform the assignment and related operation only when 'consignment' is
enabled

opw-2508371

closes odoo/odoo#71800

X-original-commit: 441ff95adf218534fb7f32aa16eac18023352d0f
Signed-off-by: Nicolas Lempereur (nle) <nle@odoo.com>
Signed-off-by: agr-odoo <agr-odoo@users.noreply.github.com>
This commit is contained in:
Andrea Grazioso (agr-odoo)
2021-06-07 10:16:58 +00:00
parent a11d043245
commit dc62f07783
2 changed files with 12 additions and 8 deletions
+9 -8
View File
@@ -149,14 +149,15 @@ class StockPicking(models.Model):
self.env['stock.move.line'].create(ml_vals)
else:
move._action_assign()
for move_line in move.move_line_ids:
move_line.qty_done = move_line.product_uom_qty
if float_compare(move.product_uom_qty, move.quantity_done, precision_rounding=move.product_uom.rounding) > 0:
remaining_qty = move.product_uom_qty - move.quantity_done
ml_vals = move._prepare_move_line_vals()
ml_vals.update({'qty_done':remaining_qty})
self.env['stock.move.line'].create(ml_vals)
if self.user_has_groups('stock.group_tracking_owner'):
move._action_assign()
for move_line in move.move_line_ids:
move_line.qty_done = move_line.product_uom_qty
if float_compare(move.product_uom_qty, move.quantity_done, precision_rounding=move.product_uom.rounding) > 0:
remaining_qty = move.product_uom_qty - move.quantity_done
ml_vals = move._prepare_move_line_vals()
ml_vals.update({'qty_done':remaining_qty})
self.env['stock.move.line'].create(ml_vals)
move.quantity_done = move.product_uom_qty
def _send_confirmation_email(self):
@@ -206,6 +206,9 @@ class TestPoSStock(TestPoSCommon):
"""
Test order via POS a product having stock owner.
"""
group_owner = self.env.ref('stock.group_tracking_owner')
self.env.user.write({'groups_id': [(4, group_owner.id)]})
self.product4 = self.create_product('Product 3', self.categ_basic, 30.0, 15.0)
self.env['stock.quant'].with_context(inventory_mode=True).create({
'product_id': self.product4.id,