diff options
| author | Goffin Simon <sig@odoo.com> | 2019-08-13 12:54:58 +0000 |
|---|---|---|
| committer | Nicolas Lempereur <nle@odoo.com> | 2019-08-14 11:49:15 +0000 |
| commit | 9e6f342e06e73c723d0dc194875d5ac8f014076e (patch) | |
| tree | efd925baea531b979086403fae4f159f9d777c0e /addons | |
| parent | f8978fc235009c12d808c59d521cca76bb9db317 (diff) | |
[FIX] {purchase,sale}_stock: Not possible to see a SN on an other company
Steps to reproduce the bug:
- Let's consider two company C1 and C2 and a user U allowed for this two companies
- Create a storable product P tracked by serial number
- Create a PO in C1 with P and deliver it with a serial number SN
- Go to Inventory>Master data>Lots/Serial Numbers
- Change your current company to C2
- Click on SN
Bug:
An access rights error was raised because the system tried to compute SO and PO linked to SN
with the moves of all the companies. So the record rule "stock_move multi-company" was
raised.
opw-2049093
closes #35694
Signed-off-by: Nicolas Lempereur (nle) <nle@odoo.com>
Diffstat (limited to 'addons')
| -rw-r--r-- | addons/purchase_stock/models/stock.py | 3 | ||||
| -rw-r--r-- | addons/sale_stock/models/stock.py | 3 |
2 files changed, 4 insertions, 2 deletions
diff --git a/addons/purchase_stock/models/stock.py b/addons/purchase_stock/models/stock.py index 15f2ecee538..73e551344e3 100644 --- a/addons/purchase_stock/models/stock.py +++ b/addons/purchase_stock/models/stock.py @@ -210,7 +210,8 @@ class ProductionLot(models.Model): stock_moves = self.env['stock.move.line'].search([ ('lot_id', '=', lot.id), ('state', '=', 'done') - ]).mapped('move_id').filtered( + ]).mapped('move_id') + stock_moves = stock_moves.search([('id', 'in', stock_moves.ids)]).filtered( lambda move: move.picking_id.location_id.usage == 'supplier' and move.state == 'done') lot.purchase_order_ids = stock_moves.mapped('purchase_line_id.order_id') lot.purchase_order_count = len(lot.purchase_order_ids) diff --git a/addons/sale_stock/models/stock.py b/addons/sale_stock/models/stock.py index f622c61820e..a346b815d20 100644 --- a/addons/sale_stock/models/stock.py +++ b/addons/sale_stock/models/stock.py @@ -120,7 +120,8 @@ class ProductionLot(models.Model): stock_moves = self.env['stock.move.line'].search([ ('lot_id', '=', lot.id), ('state', '=', 'done') - ]).mapped('move_id').filtered( + ]).mapped('move_id') + stock_moves = stock_moves.search([('id', 'in', stock_moves.ids)]).filtered( lambda move: move.picking_id.location_dest_id.usage == 'customer' and move.state == 'done') lot.sale_order_ids = stock_moves.mapped('sale_line_id.order_id') lot.sale_order_count = len(lot.sale_order_ids) |
