New addon to replace structured country/state fields with flexible free-text origin descriptions. Features: - Translatable origin_text field in product.supplierinfo - Computed origin field in products based on main_seller_id - Support for creative supplier origin descriptions - Full OCA documentation structure - ES/EU translations included - 8 unit tests (all passing) Replaces product_origin for use cases where suppliers use non-standardized origin descriptions (e.g., 'Valencia, Spain', 'Huerta de...', etc.) Depends on: product, product_main_seller Author: Criptomart Funding: Elika Bilbo
30 lines
1,008 B
Python
30 lines
1,008 B
Python
# 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
|
|
|
|
|
|
class ProductTemplate(models.Model):
|
|
_inherit = "product.template"
|
|
|
|
origin_text = fields.Char(
|
|
string="Origin",
|
|
compute="_compute_origin_text",
|
|
store=False,
|
|
help="Origin text from main vendor's supplierinfo",
|
|
)
|
|
|
|
@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
|