diff --git a/addons/point_of_sale/models/stock_picking.py b/addons/point_of_sale/models/stock_picking.py index e6cbc095e0c..52e74f5bbd2 100644 --- a/addons/point_of_sale/models/stock_picking.py +++ b/addons/point_of_sale/models/stock_picking.py @@ -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): diff --git a/addons/point_of_sale/tests/test_pos_stock_account.py b/addons/point_of_sale/tests/test_pos_stock_account.py index c614e07df7a..8a73cf1aaa6 100644 --- a/addons/point_of_sale/tests/test_pos_stock_account.py +++ b/addons/point_of_sale/tests/test_pos_stock_account.py @@ -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,