Skip to content

Commit

Permalink
[IMP] lighting_export_bmecat: last imp
Browse files Browse the repository at this point in the history
  • Loading branch information
FrankC013 committed Mar 3, 2025
1 parent a97b8d8 commit 528a152
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
18 changes: 9 additions & 9 deletions lighting_export_bmecat/models/lighting_export_bmecat.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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",
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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()
Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion lighting_export_bmecat/views/report_bmecat.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
<PRODUCT mode="new">
<SUPPLIER_PID t-out="product.reference" />
<PRODUCT_DETAILS>
<DESCRIPTION_SHORT t-out="product.description_manual" />
<DESCRIPTION_SHORT t-out="product.description" />
<INTERNATIONAL_PID type="gtin" t-out="product.ean" />
<PRODUCT_TYPE>physical</PRODUCT_TYPE>
</PRODUCT_DETAILS>
Expand Down

0 comments on commit 528a152

Please sign in to comment.