[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>
This commit is contained in:
committed by
Nicolas Lempereur
parent
f8978fc235
commit
9e6f342e06
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user