From 38262b8e5c09265354db72fd0c9a06236ea46f4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ram=C3=B3n=20V=C3=A1squez?= <ramon.vasquez@eynes.com.ar> Date: Fri, 7 Jun 2024 10:42:47 -0300 Subject: [PATCH] [FIX][T4541] Config in importer; bug --- models/customer_purchase_order_importer.py | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/models/customer_purchase_order_importer.py b/models/customer_purchase_order_importer.py index d605fd5..d738137 100644 --- a/models/customer_purchase_order_importer.py +++ b/models/customer_purchase_order_importer.py @@ -381,11 +381,18 @@ class CustomerPurchaseOrderImporter(models.Model): def get_config_units_as_boxes_vals(self, vals): for line in vals['pre_order_line_ids']: + box_kg = line[2]['box_kg'] product_uom = line[2]['product_uom'] - units_per_box = line[2]['units_per_box']['original'] + ordered_qty = line[2]['ordered_qty']['original'] - if product_uom and product_uom == self.env.ref('uom.product_uom_kgm').id and units_per_box: - line[2]['box_qty']['modified'] = units_per_box + if ( + product_uom + and product_uom == self.env.ref('uom.product_uom_kgm').id + and ordered_qty + and box_kg + ): + box_qty = int(ordered_qty / box_kg) + line[2]['box_qty']['modified'] = box_qty if box_qty >= 0 else 0 return vals @@ -452,7 +459,6 @@ class CustomerPurchaseOrderImporter(models.Model): def get_full_file_data(self, lines): msg_list = [] - address = None config_lines = None partner = None branch = None @@ -489,8 +495,6 @@ class CustomerPurchaseOrderImporter(models.Model): if product_type_errors: msg_list.extend(product_type_errors) - address = partner.address_get(['invoice']) - # Branch branch_ean_code = header_data['branch_ean_code'] if not branch_ean_code: @@ -751,7 +755,7 @@ class CustomerPurchaseOrderImporter(models.Model): def _get_product(self, data, description=''): errors = [] - code = list(data.keys())[0] + code = sorted(list(data.keys()))[0] product = data[code]['product'] if not product: -- GitLab