-
-
Notifications
You must be signed in to change notification settings - Fork 109
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FIX]hs_code_link: properly declare OCA hs_code field on product.temp…
…late Before the change, the field was not being updated after the value of the H.S. Code was changed on a Product Template. The related stored field was not working fine with the company dependent field. As the `hs_code_id` field is company dependent, we can have the `hs_code` on the product.template as a computed non-stored to be computed based on the `force_company` value of the context, just as in the company_dependent fields.
- Loading branch information
1 parent
6b7d414
commit 83b051b
Showing
3 changed files
with
11 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,17 @@ | ||
# Copyright 2017 Camptocamp SA | ||
# Copyright 2023 ForgeFlow <http://www.forgeflow.com> | ||
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
* Denis Leemann <[email protected]> | ||
* Guillem Casassas <[email protected]> |