From 528a1528d06261b1bcd23840326eaa77a6370787 Mon Sep 17 00:00:00 2001 From: FrankC013 Date: Mon, 3 Mar 2025 09:43:04 +0100 Subject: [PATCH] [IMP] lighting_export_bmecat: last imp --- .../models/lighting_export_bmecat.py | 18 +++++++++--------- lighting_export_bmecat/views/report_bmecat.xml | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/lighting_export_bmecat/models/lighting_export_bmecat.py b/lighting_export_bmecat/models/lighting_export_bmecat.py index 480ece21..b697b5a0 100644 --- a/lighting_export_bmecat/models/lighting_export_bmecat.py +++ b/lighting_export_bmecat/models/lighting_export_bmecat.py @@ -25,7 +25,7 @@ class LightingExportBMEcat(models.Model): name = fields.Char(required=True) date = fields.Date(default=fields.Date.today) bmecat_config_id = fields.Many2one( - comodel_name="lighting.bmecat.config", required=True + comodel_name="lighting.bmecat.config", required=True, tracking=True ) catalog_id = fields.Many2one(comodel_name="lighting.catalog", required=True) create_job = fields.Boolean() @@ -50,7 +50,9 @@ class LightingExportBMEcat(models.Model): default=lambda self: self.env.company, readonly=True, ) - valid_start_date = fields.Date(string="Publication Date", required=True) + valid_start_date = fields.Date( + string="Publication Date", required=True, tracking=True + ) language_id = fields.Many2one(comodel_name="res.lang", required=True) bmecat_jobs_ids = fields.Many2many( comodel_name="queue.job", @@ -191,13 +193,11 @@ def _check_bmecat_file_values(self, products): _("The following products do not have a reference: %s") % ", ".join(products_without_ref.mapped("name")) ) - products_without_desc_short = products.filtered( - lambda x: not x.description_manual - ) + products_without_desc_short = products.filtered(lambda x: not x.description) if products_without_desc_short: raise ValidationError( - _("The following products do not have a manual description: %s") - % ", ".join(products_without_desc_short.mapped("name")) + _("The following products do not have a description: %s") + % ", ".join(products_without_desc_short.mapped("reference")) ) products_without_packing_unit = products.filtered( lambda product: not self.bmecat_config_id.packing_unit_ids.filtered( @@ -304,8 +304,6 @@ def _write_bmecat_xml(self, file, products): 0 ] ) - if counter % 500 == 0: - _logger.info("Procesados %d productos...", counter) if counter % self.bmecat_config_id.cache_clear_limit == 0: self.env.cache.clear() self.env.cache.clear() @@ -322,6 +320,7 @@ def _generate_bmecat_file(self): "in", self.bmecat_config_id.state_marketing_filter.mapped("value"), ), + ("state", "=", "published"), # TODO REVIEW: Reconsider logic ] ) self._check_bmecat_file_values(products) @@ -352,6 +351,7 @@ def _generate_bmecat_file(self): if not self.create_job: return self.action_download_bmecat_file() + # TODO: GENERAR NOTA EN EL CHATTER AMB EL FITXER def generate_bmecat_file(self): self.ensure_one() self = self.with_context(lang=self.language_id.code) diff --git a/lighting_export_bmecat/views/report_bmecat.xml b/lighting_export_bmecat/views/report_bmecat.xml index db0d9a07..a3ca3121 100644 --- a/lighting_export_bmecat/views/report_bmecat.xml +++ b/lighting_export_bmecat/views/report_bmecat.xml @@ -40,7 +40,7 @@ - + physical