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 0098442 commit 5409d70
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
4 changes: 2 additions & 2 deletions connector_importer/components/mapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ def required_keys(self, create=False):
The recordset will use this to show required fields to users.
"""
req = dict(self.required)
req.update(self.work.options.mapper.get("required_keys", {}))
return req

return self.work.options.mapper.get("required_keys", {}) or req

translatable = []

Expand Down
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 5409d70

Please sign in to comment.