[REF] product_origin_char: simplify to template-based origin
- Move origin_text field from product.supplierinfo to product.template - Add related field in product.product for variant access - Remove dependency on product_main_seller - Update views to show field near category (editable) - Rewrite tests for new architecture - Update all documentation (README, readme/ fragments) - Bump version to 18.0.2.0.0
This commit is contained in:
parent
e2ced75ecd
commit
5efe57dc19
15 changed files with 180 additions and 402 deletions
|
|
@ -1,6 +1,5 @@
|
|||
# Copyright 2026 Criptomart
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from . import product_supplierinfo # noqa: F401
|
||||
from . import product_template # noqa: F401
|
||||
from . import product_product # noqa: F401
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
# Copyright 2026 Criptomart
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from odoo import api
|
||||
from odoo import fields
|
||||
from odoo import models
|
||||
|
||||
|
|
@ -10,21 +9,6 @@ class ProductProduct(models.Model):
|
|||
_inherit = "product.product"
|
||||
|
||||
origin_text = fields.Char(
|
||||
string="Origin",
|
||||
compute="_compute_origin_text",
|
||||
store=False,
|
||||
help="Origin text from main vendor's supplierinfo",
|
||||
related="product_tmpl_id.origin_text",
|
||||
readonly=False,
|
||||
)
|
||||
|
||||
@api.depends("product_tmpl_id.main_seller_id", "seller_ids.origin_text")
|
||||
def _compute_origin_text(self):
|
||||
for product in self:
|
||||
if product.product_tmpl_id.main_seller_id:
|
||||
# Find the supplierinfo record for the main seller
|
||||
main_seller = product.product_tmpl_id.main_seller_id
|
||||
seller = product.seller_ids.filtered(
|
||||
lambda s, ms=main_seller: s.partner_id == ms
|
||||
)[:1]
|
||||
product.origin_text = seller.origin_text if seller else False
|
||||
else:
|
||||
product.origin_text = False
|
||||
|
|
|
|||
|
|
@ -1,15 +0,0 @@
|
|||
# Copyright 2026 Criptomart
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from odoo import fields
|
||||
from odoo import models
|
||||
|
||||
|
||||
class ProductSupplierinfo(models.Model):
|
||||
_inherit = "product.supplierinfo"
|
||||
|
||||
origin_text = fields.Char(
|
||||
string="Origin",
|
||||
translate=True,
|
||||
help="Free text to describe product origin (country, region, producer, etc.)",
|
||||
)
|
||||
|
|
@ -1,7 +1,6 @@
|
|||
# Copyright 2026 Criptomart
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from odoo import api
|
||||
from odoo import fields
|
||||
from odoo import models
|
||||
|
||||
|
|
@ -11,20 +10,5 @@ class ProductTemplate(models.Model):
|
|||
|
||||
origin_text = fields.Char(
|
||||
string="Origin",
|
||||
compute="_compute_origin_text",
|
||||
store=False,
|
||||
help="Origin text from main vendor's supplierinfo",
|
||||
help="Origin of the product.",
|
||||
)
|
||||
|
||||
@api.depends("main_seller_id", "variant_seller_ids.origin_text")
|
||||
def _compute_origin_text(self):
|
||||
for template in self:
|
||||
if template.main_seller_id:
|
||||
# Find the supplierinfo record for the main seller
|
||||
main_seller = template.main_seller_id
|
||||
seller = template.variant_seller_ids.filtered(
|
||||
lambda s, ms=main_seller: s.partner_id == ms
|
||||
)[:1]
|
||||
template.origin_text = seller.origin_text if seller else False
|
||||
else:
|
||||
template.origin_text = False
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue