From 2709b5c99d4a62d4288877f13c34027cc21794ad Mon Sep 17 00:00:00 2001 From: sergio-teruel Date: Mon, 4 Nov 2024 10:24:11 +0100 Subject: [PATCH] [FIX] stock_weighing_auto_package: Store stock_weighing_auto_package with sudo TT51569 --- .../wizards/weighing_wizard.py | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/stock_weighing_auto_package/wizards/weighing_wizard.py b/stock_weighing_auto_package/wizards/weighing_wizard.py index 531f6aad..17166da2 100644 --- a/stock_weighing_auto_package/wizards/weighing_wizard.py +++ b/stock_weighing_auto_package/wizards/weighing_wizard.py @@ -1,17 +1,28 @@ # Copyright 2024 Tecnativa - Sergio Teruel # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl) -from odoo import fields, models +from odoo import api, fields, models class WeighingWizard(models.TransientModel): _inherit = "weighing.wizard" stock_weighing_auto_package = fields.Boolean( - related="product_id.stock_weighing_auto_package", - readonly=False, + compute="_compute_stock_weighing_auto_package", + inverse="_inverse_stock_weighing_auto_package", string="Auto package", ) + @api.depends("product_id") + def _compute_stock_weighing_auto_package(self): + for wiz in self: + wiz.stock_weighing_auto_package = wiz.product_id.stock_weighing_auto_package + + def _inverse_stock_weighing_auto_package(self): + for wiz in self: + wiz.product_id.sudo().stock_weighing_auto_package = ( + wiz.stock_weighing_auto_package + ) + def _post_add_detailed_operation(self): res = super(WeighingWizard, self)._post_add_detailed_operation() if self.result_package_id: