Skip to content

Commit

Permalink
connector_importer_product: Do not override product_tmpl_id
Browse files Browse the repository at this point in the history
When updating product.product records, product_tmpl_id is set to False in values if not specified in the import type.
But we don't want to set it to False as the value already exists in the odoo_record
  • Loading branch information
Ricardoalso committed Sep 11, 2024
1 parent f89cd27 commit ec15d21
Showing 1 changed file with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,16 @@ def odoo_post_create(self, odoo_record, values, orig_values):
def odoo_post_write(self, odoo_record, values, orig_values):
self._update_template_attributes(odoo_record, values, orig_values)

def odoo_pre_write(self, odoo_record, values, orig_values):
if (
"product_tmpl_id" not in orig_values
and "product_tmpl_id" in odoo_record._fields.keys()
and odoo_record.product_tmpl_id
):
values["product_tmpl_id"] = odoo_record.product_tmpl_id.id

return super().odoo_pre_write(odoo_record, values, orig_values)

def odoo_create(self, values, orig_values):
odoo_record = super().odoo_create(values, orig_values)
# Set the external ID for the template if necessary
Expand Down

0 comments on commit ec15d21

Please sign in to comment.