Skip to content

Commit

Permalink
[FIX] stock_account_product_run_fifo_hook: don't use taken_data as fi…
Browse files Browse the repository at this point in the history
…eld name

Fixes #1761
  • Loading branch information
MiquelRForgeFlow committed Nov 15, 2024
1 parent 6806c6e commit e4f5baa
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
1 change: 1 addition & 0 deletions stock_account_product_run_fifo_hook/model/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
from . import product
from . import stock_valuation_layer
19 changes: 19 additions & 0 deletions stock_account_product_run_fifo_hook/model/stock_valuation_layer.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Copyright 2024 ForgeFlow, S.L.
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
from odoo import api, models


class StockValuationLayer(models.Model):
_inherit = "stock.valuation.layer"

@api.model_create_multi
def create(self, values):
recs = self.browse()
for val in values:
taken_data = "taken_data" in val.keys() and val.pop("taken_data") or {}
if taken_data:
rec = super(StockValuationLayer, self.with_context(taken_data=taken_data)).create(val)
else:
rec = super(StockValuationLayer, self).create(val)
recs |= rec
return recs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def _process_taken_data(self, taken_data, rec):
def create(self, values):
recs = self.browse()
for val in values:
taken_data = "taken_data" in val.keys() and val.pop("taken_data") or {}
taken_data = self.env.context.get("taken_data", {})
rec = super(StockValuationLayer, self).create(val)
# There are cases in which the transformation
# comes from a return process,
Expand Down

0 comments on commit e4f5baa

Please sign in to comment.