Skip to content

Commit

Permalink
[FIX] stock_inventory: fix allowed fields to be written in stock-quan…
Browse files Browse the repository at this point in the history
…ts and the case of shared location between several companies
  • Loading branch information
AlexPForgeFlow committed Sep 21, 2023
1 parent f77cdc0 commit 81ba4db
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions stock_inventory/models/stock_quant.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from odoo import fields, models
from odoo import _, fields, models


class StockQuant(models.Model):
Expand All @@ -22,15 +22,23 @@ def _apply_inventory(self):
[
("product_id", "=", rec.product_id.id),
("lot_id", "=", rec.lot_id.id),
("company_id", "=", rec.company_id.id),
"|",
("location_id", "=", rec.location_id.id),
("location_dest_id", "=", rec.location_id.id),
],
order="create_date asc",
).filtered(
lambda x: not x.company_id.id
or not rec.company_id.id
or rec.company_id.id == x.company_id.id
)
if len(moves) == 0:
raise ValueError(_("No move lines have been created"))
move = moves[len(moves) - 1]
adjustment.stock_move_ids |= move
move.inventory_adjustment_id = adjustment
rec.to_do = False
return res

def _get_inventory_fields_write(self):
return super()._get_inventory_fields_write() + ["to_do"]

0 comments on commit 81ba4db

Please sign in to comment.