summaryrefslogtreecommitdiff
path: root/addons
diff options
context:
space:
mode:
authorAndrea Grazioso (agr-odoo) <agr@odoo.com>2021-05-28 11:22:30 +0000
committerAndrea Grazioso (agr-odoo) <agr@odoo.com>2021-05-28 12:04:22 +0000
commitd59fc6c96b5b148ac8d2576a7017de90fb4af224 (patch)
tree8bdaaf3ef455732d42251966b1ac36c630b9a522 /addons
parent05b6dfa0b1e4daf46d569c2e0a330b35e6437f8d (diff)
[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#71396 Signed-off-by: Nicolas Lempereur (nle) <nle@odoo.com>
Diffstat (limited to 'addons')
-rw-r--r--addons/point_of_sale/models/stock_picking.py17
-rw-r--r--addons/point_of_sale/tests/test_pos_stock_account.py2
2 files changed, 11 insertions, 8 deletions
diff --git a/addons/point_of_sale/models/stock_picking.py b/addons/point_of_sale/models/stock_picking.py
index b40f6cb08df..80fbb7e285e 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 e63739a3d0f..287b4430bd9 100644
--- a/addons/point_of_sale/tests/test_pos_stock_account.py
+++ b/addons/point_of_sale/tests/test_pos_stock_account.py
@@ -207,6 +207,8 @@ 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)
inventory = self.env['stock.inventory'].create({
'name': 'Inventory adjustment'