diff --git a/connector_prestashop/README.rst b/connector_prestashop/README.rst index 62b001d9f..d1c6c811b 100644 --- a/connector_prestashop/README.rst +++ b/connector_prestashop/README.rst @@ -175,6 +175,7 @@ Contributors * Marc Poch * JesusVMayor * Hai Lang +* David Palanca * `Greenice `_: diff --git a/connector_prestashop/models/product_product/importer.py b/connector_prestashop/models/product_product/importer.py index 90ef20fef..c7d108490 100644 --- a/connector_prestashop/models/product_product/importer.py +++ b/connector_prestashop/models/product_product/importer.py @@ -298,14 +298,20 @@ def default_code(self, record): @mapping def barcode(self, record): barcode = record.get("barcode") or record.get("ean13") - check_ean = self.env["barcode.nomenclature"].check_ean + barcode_nomenclature_model = self.env["barcode.nomenclature"] + + def is_valid_ean(barcode): + """Validates if a barcode is a valid EAN.""" + return barcode_nomenclature_model.check_encoding(barcode, "ean13") + if barcode in ["", "0"]: backend_adapter = self.component( usage="backend.adapter", model_name="prestashop.product.template" ) template = backend_adapter.read(record["id_product"]) barcode = template.get("barcode") or template.get("ean13") - if barcode and barcode != "0" and check_ean(barcode): + + if barcode and barcode != "0" and is_valid_ean(barcode): return {"barcode": barcode} return {} diff --git a/connector_prestashop/models/product_template/common.py b/connector_prestashop/models/product_template/common.py index f7f72f4a2..f3cc7699e 100644 --- a/connector_prestashop/models/product_template/common.py +++ b/connector_prestashop/models/product_template/common.py @@ -49,6 +49,17 @@ def update_prestashop_quantities(self): ).recompute_prestashop_qty() return True + @api.model + def create(self, vals): + if "type" in vals: + if vals["type"] == "product": + vals["detailed_type"] = "product" + elif vals["type"] == "consu": + vals["detailed_type"] = "consu" + elif vals["type"] == "service": + vals["detailed_type"] = "service" + return super(ProductTemplate, self).create(vals) + class ProductQtyMixin(models.AbstractModel): _name = "prestashop.product.qty.mixin" diff --git a/connector_prestashop/models/product_template/importer.py b/connector_prestashop/models/product_template/importer.py index a7b30a7b3..de5af15e5 100644 --- a/connector_prestashop/models/product_template/importer.py +++ b/connector_prestashop/models/product_template/importer.py @@ -338,11 +338,17 @@ def company_id(self, record): def barcode(self, record): if self.has_combinations(record): return {} + barcode = record.get("barcode") or record.get("ean13") if barcode in ["", "0"]: return {} - if self.env["barcode.nomenclature"].check_ean(barcode): + + barcode_nomenclature = self.env["barcode.nomenclature"] + if barcode_nomenclature.check_encoding( + barcode, "ean13" + ) or barcode_nomenclature.check_encoding(barcode, "ean8"): return {"barcode": barcode} + return {} def _get_tax_ids(self, record): diff --git a/connector_prestashop/static/description/index.html b/connector_prestashop/static/description/index.html index 7c99ae15d..7f7a5aed8 100644 --- a/connector_prestashop/static/description/index.html +++ b/connector_prestashop/static/description/index.html @@ -1,4 +1,3 @@ - @@ -9,10 +8,11 @@ /* :Author: David Goodger (goodger@python.org) -:Id: $Id: html4css1.css 8954 2022-01-20 10:10:25Z milde $ +:Id: $Id: html4css1.css 9511 2024-01-13 09:50:07Z milde $ :Copyright: This stylesheet has been placed in the public domain. Default cascading style sheet for the HTML output of Docutils. +Despite the name, some widely supported CSS2 features are used. See https://docutils.sourceforge.io/docs/howto/html-stylesheets.html for how to customize this style sheet. @@ -275,7 +275,7 @@ margin-left: 2em ; margin-right: 2em } -pre.code .ln { color: grey; } /* line numbers */ +pre.code .ln { color: gray; } /* line numbers */ pre.code, code { background-color: #eeeeee } pre.code .comment, code .comment { color: #5C6576 } pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold } @@ -301,7 +301,7 @@ span.pre { white-space: pre } -span.problematic { +span.problematic, pre.problematic { color: red } span.section-subtitle { @@ -527,6 +527,7 @@

Contributors

  • Marc Poch <mpoch@planetatic.com>
  • JesusVMayor <jesus@comunitea.com>
  • Hai Lang <hailn@trobz.com>
  • +
  • David Palanca <davidpalanca@grupoisonor.es>
  • Greenice: @@ -544,7 +545,9 @@

    Other credits

    Maintainers

    This module is maintained by the OCA.

    -Odoo Community Association + +Odoo Community Association +

    OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use.