Initial commit: Odoo 18.0-20251222 extra-addons
Some checks failed
pre-commit / pre-commit (push) Has been cancelled
tests / Detect unreleased dependencies (push) Has been cancelled
tests / test with OCB (push) Has been cancelled
tests / test with Odoo (push) Has been cancelled

This commit is contained in:
tocmo0nlord
2026-03-13 20:43:25 +00:00
parent 36e847a7df
commit adbe430761
9472 changed files with 1265727 additions and 0 deletions

View File

@@ -0,0 +1,45 @@
# Copyright 2019 Tecnativa - Sergio Teruel
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from odoo import api, fields, models
class ProductTemplate(models.Model):
_inherit = "product.template"
is_elaboration = fields.Boolean()
elaboration_profile_id = fields.Many2one(
comodel_name="product.elaboration.profile",
compute="_compute_elaboration_profile_id",
inverse="_inverse_elaboration_profile_id",
store=True,
help="Keep this field empty to use the default value from the product "
"category.",
)
@api.depends("product_variant_ids", "product_variant_ids.elaboration_profile_id")
def _compute_elaboration_profile_id(self):
unique_variants = self.filtered(lambda tmpl: tmpl.product_variant_count == 1)
for template in unique_variants:
template.elaboration_profile_id = (
template.product_variant_ids.elaboration_profile_id
)
for template in self - unique_variants:
template.elaboration_profile_id = False
def _inverse_elaboration_profile_id(self):
for template in self:
if len(template.product_variant_ids) == 1:
template.product_variant_ids.elaboration_profile_id = (
template.elaboration_profile_id
)
@api.model_create_multi
def create(self, vals_list):
templates = super().create(vals_list)
# This is needed to set given values to first variant after creation
for template, vals in zip(templates, vals_list, strict=False):
if vals.get("elaboration_profile_id"):
template.write(
{"elaboration_profile_id": vals["elaboration_profile_id"]}
)
return templates