From e4f5baa9aa505355484d74261f342b164343c76c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miquel=20Ra=C3=AFch?= Date: Fri, 15 Nov 2024 12:24:44 +0100 Subject: [PATCH] [FIX] stock_account_product_run_fifo_hook: don't use taken_data as field name Fixes https://github.com/OCA/stock-logistics-workflow/issues/1761 --- .../model/__init__.py | 1 + .../model/stock_valuation_layer.py | 19 +++++++++++++++++++ .../models/stock_valuation_layer.py | 2 +- 3 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 stock_account_product_run_fifo_hook/model/stock_valuation_layer.py diff --git a/stock_account_product_run_fifo_hook/model/__init__.py b/stock_account_product_run_fifo_hook/model/__init__.py index 9649db77a159..3e46e947420a 100644 --- a/stock_account_product_run_fifo_hook/model/__init__.py +++ b/stock_account_product_run_fifo_hook/model/__init__.py @@ -1 +1,2 @@ from . import product +from . import stock_valuation_layer diff --git a/stock_account_product_run_fifo_hook/model/stock_valuation_layer.py b/stock_account_product_run_fifo_hook/model/stock_valuation_layer.py new file mode 100644 index 000000000000..ccd86076aadb --- /dev/null +++ b/stock_account_product_run_fifo_hook/model/stock_valuation_layer.py @@ -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 diff --git a/stock_valuation_layer_usage/models/stock_valuation_layer.py b/stock_valuation_layer_usage/models/stock_valuation_layer.py index bded38c22b14..818a0f5bd279 100644 --- a/stock_valuation_layer_usage/models/stock_valuation_layer.py +++ b/stock_valuation_layer_usage/models/stock_valuation_layer.py @@ -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,