diff --git a/hs_code_link/__manifest__.py b/hs_code_link/__manifest__.py index 6824b08..c4b53a5 100644 --- a/hs_code_link/__manifest__.py +++ b/hs_code_link/__manifest__.py @@ -1,4 +1,5 @@ # Copyright 2017 Camptocamp SA +# Copyright 2023 ForgeFlow # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). { "name": "HS Code Link", diff --git a/hs_code_link/models/product.py b/hs_code_link/models/product.py index d000495..52128f8 100644 --- a/hs_code_link/models/product.py +++ b/hs_code_link/models/product.py @@ -1,10 +1,17 @@ # Copyright 2017 Camptocamp SA +# Copyright 2023 ForgeFlow # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -from odoo import fields, models +from odoo import api, fields, models class ProductTemplate(models.Model): _inherit = "product.template" - hs_code = fields.Char(related="hs_code_id.hs_code", readonly=True, store=True) + # Make it compute non-stored as we will get the value from the bypassed company + hs_code = fields.Char(compute="_compute_hs_code") + + @api.depends_context("force_company") + def _compute_hs_code(self): + for template in self: + template.hs_code = template.hs_code_id.hs_code diff --git a/hs_code_link/readme/CONTRIBUTORS.rst b/hs_code_link/readme/CONTRIBUTORS.rst index fcb7aaa..316ea70 100644 --- a/hs_code_link/readme/CONTRIBUTORS.rst +++ b/hs_code_link/readme/CONTRIBUTORS.rst @@ -1 +1,2 @@ * Denis Leemann +* Guillem Casassas