Skip to content

Commit

Permalink
[FIX] connector_oxigesti: set the default code on the first created v…
Browse files Browse the repository at this point in the history
…ariant
  • Loading branch information
FrankC013 committed Nov 14, 2024
1 parent 68a3629 commit b7deeb4
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions connector_oxigesti/models/product_template/binding.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,20 @@
from odoo.exceptions import ValidationError


class ProductProduct(models.Model):
_inherit = "product.product"

# TODO: Review move the default_code logic (required) in a separate module.
@api.model_create_multi
def create(self, vals_list):
records = super().create(vals_list)
for product_tmpl in records.product_tmpl_id:
if not any(product_tmpl.product_variant_ids.mapped("default_code")):
first_variant = product_tmpl.product_variant_ids.sorted("id")[0]
first_variant.default_code = product_tmpl.default_code
return records


class ProductTemplate(models.Model):
_inherit = "product.template"

Expand Down

0 comments on commit b7deeb4

Please sign in to comment.