diff --git a/mrp_bom_import/__manifest__.py b/mrp_bom_import/__manifest__.py index 414e6b2d7..7fed52a52 100644 --- a/mrp_bom_import/__manifest__.py +++ b/mrp_bom_import/__manifest__.py @@ -14,9 +14,11 @@ 'summary': '''MRP BoM Import''', 'website': 'http://www.avanzosc.es', 'data': [ - 'views/mrp_bom_view.xml', + 'views/mrp_bom_line_view.xml', 'views/product_view.xml', 'security/ir.model.access.csv', + 'views/mrp_bom_import_line_view.xml', + 'views/mrp_bom_import_view.xml', ], 'installable': True, 'auto_install': False, diff --git a/mrp_bom_import/i18n/es.po b/mrp_bom_import/i18n/es.po index 7564c6141..2ee9650e1 100644 --- a/mrp_bom_import/i18n/es.po +++ b/mrp_bom_import/i18n/es.po @@ -6,8 +6,8 @@ msgid "" msgstr "" "Project-Id-Version: Odoo Server 12.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-09-25 10:38+0000\n" -"PO-Revision-Date: 2019-09-25 10:38+0000\n" +"POT-Creation-Date: 2024-03-25 09:56+0000\n" +"PO-Revision-Date: 2024-03-25 09:56+0000\n" "Last-Translator: <>\n" "Language-Team: \n" "MIME-Version: 1.0\n" @@ -16,183 +16,112 @@ msgstr "" "Plural-Forms: \n" #. module: mrp_bom_import -#: model_terms:ir.ui.view,arch_db:mrp_bom_import.view_mrp_bom_import_form -msgid "BoMs" -msgstr "LdMs" - -#. module: mrp_bom_import -#: model_terms:ir.ui.view,arch_db:mrp_bom_import.view_mrp_bom_import_form -msgid "Products" -msgstr "Productos" - -#. module: mrp_bom_import -#: model:ir.model.fields,field_description:mrp_bom_import.field_mrp_bom_line_import__bom_id -msgid "BoM" -msgstr "LdM" - -#. module: mrp_bom_import -#: model:ir.model.fields,field_description:mrp_bom_import.field_mrp_bom_line_import__bom_import_id -#: model:ir.ui.menu,name:mrp_bom_import.menu_bom_import -#: model_terms:ir.ui.view,arch_db:mrp_bom_import.view_mrp_bom_import_form -#: model_terms:ir.ui.view,arch_db:mrp_bom_import.view_mrp_bom_import_tree -#: model_terms:ir.ui.view,arch_db:mrp_bom_import.view_mrp_bom_line_tree -msgid "BoM Import" -msgstr "Importar LdM" - -#. module: mrp_bom_import -#: model:ir.model.fields,field_description:mrp_bom_import.field_mrp_bom_import__bom_import_lines -msgid "BoM Import Lines" -msgstr "Importar lineas LdM" - -#. module: mrp_bom_import -#: model:ir.model.fields,field_description:mrp_bom_import.field_mrp_bom_line_import__bom_code -msgid "BoM code" -msgstr "Codigo LdM" - -#. module: mrp_bom_import -#: code:addons/mrp_bom_import/models/mrp_bom_import.py:138 -#, python-format -msgid "Buy" +#: model:ir.model,name:mrp_bom_import.model_import_file +msgid "Base for import file" msgstr "" #. module: mrp_bom_import -#: model:ir.model.fields,field_description:mrp_bom_import.field_mrp_bom_line_import__category_id -msgid "Category" -msgstr "Categoría" - -#. module: mrp_bom_import -#: model:ir.model.fields,field_description:mrp_bom_import.field_mrp_bom_line_import__categ_name -msgid "Category name" -msgstr "Nombre categoría" - -#. module: mrp_bom_import -#: model:ir.model.fields,field_description:mrp_bom_import.field_mrp_bom_import__create_uid -#: model:ir.model.fields,field_description:mrp_bom_import.field_mrp_bom_line_import__create_uid -msgid "Created by" -msgstr "Creado por" - -#. module: mrp_bom_import -#: model:ir.model.fields,field_description:mrp_bom_import.field_mrp_bom_import__create_date -#: model:ir.model.fields,field_description:mrp_bom_import.field_mrp_bom_line_import__create_date -msgid "Created on" -msgstr "Creado el" - -#. module: mrp_bom_import -#: model:ir.model.fields,field_description:mrp_bom_import.field_mrp_bom_import__display_name -#: model:ir.model.fields,field_description:mrp_bom_import.field_mrp_bom_line_import__display_name -msgid "Display Name" -msgstr "Nombre mostrado" +#: code:addons/mrp_bom_import/models/import_file.py:91 +#, python-format +msgid "Bill of Material line" +msgstr "Linea de lista de materiales" #. module: mrp_bom_import -#: model:ir.model.fields,field_description:mrp_bom_import.field_mrp_bom_line_import__map -msgid "Erection Drawing" -msgstr "Plano Montaje" +#: code:addons/mrp_bom_import/models/import_file.py:48 +#, python-format +msgid "Bill of material" +msgstr "Lista de material" #. module: mrp_bom_import -#: selection:mrp.bom.line.import,state:0 -msgid "Error" +#: selection:import.file,software:0 +msgid "Clients" msgstr "" #. module: mrp_bom_import -#: model:ir.model.fields,field_description:mrp_bom_import.field_mrp_bom_import__data -msgid "File" -msgstr "Archivo" - -#. module: mrp_bom_import -#: model:ir.ui.menu,name:mrp_bom_import.mrp_bom_import -msgid "File BoM Import" -msgstr "Importar archivo LdM" - -#. module: mrp_bom_import -#: model:ir.model.fields,field_description:mrp_bom_import.field_mrp_bom_import__file_date -msgid "File Import Date" -msgstr "Fecha importación archivo" +#: code:addons/mrp_bom_import/models/import_file.py:74 +#, python-format +msgid "Component" +msgstr "Componente" #. module: mrp_bom_import -#: model:ir.model.fields,field_description:mrp_bom_import.field_mrp_bom_import__filename -msgid "Filename" -msgstr "Nombre de archivo" +#: code:addons/mrp_bom_import/models/mrp_bom_import.py:237 +#, python-format +msgid "Component Import Lines" +msgstr "Importación de componentes" #. module: mrp_bom_import -#: model:ir.model.fields,field_description:mrp_bom_import.field_mrp_bom_import__id -#: model:ir.model.fields,field_description:mrp_bom_import.field_mrp_bom_line_import__id -msgid "ID" +#: selection:import.file,software:0 +msgid "Datos extra" msgstr "" #. module: mrp_bom_import -#: model_terms:ir.ui.view,arch_db:mrp_bom_import.view_mrp_bom_import_form -msgid "Import" -msgstr "Importar" - -#. module: mrp_bom_import -#: model:ir.model.fields,field_description:mrp_bom_import.field_mrp_bom_import__name -msgid "Import name" -msgstr "Nombre importación" - -#. module: mrp_bom_import -#: model:ir.model.fields,field_description:mrp_bom_import.field_mrp_bom_line_import__state -msgid "Import state" -msgstr "Estado" +#: code:addons/mrp_bom_import/models/mrp_bom_import.py:331 +#, python-format +msgid "Error: BoM product not found." +msgstr "Error: Producto padre no encontrada." #. module: mrp_bom_import -#: model:ir.model.fields,field_description:mrp_bom_import.field_mrp_bom_import____last_update -#: model:ir.model.fields,field_description:mrp_bom_import.field_mrp_bom_line_import____last_update -msgid "Last Modified on" -msgstr "Última modificación en" +#: code:addons/mrp_bom_import/models/mrp_bom_import.py:334 +#, python-format +msgid "Error: More than one BoM product found." +msgstr "Error: Más de un producto padre encontrado." #. module: mrp_bom_import -#: model:ir.model.fields,field_description:mrp_bom_import.field_mrp_bom_import__write_uid -#: model:ir.model.fields,field_description:mrp_bom_import.field_mrp_bom_line_import__write_uid -msgid "Last Updated by" -msgstr "Última actualización por" +#: code:addons/mrp_bom_import/models/mrp_bom_import.py:312 +#, python-format +msgid "Error: More than one product found." +msgstr "Error: Más de un componente encontrado." #. module: mrp_bom_import -#: model:ir.model.fields,field_description:mrp_bom_import.field_mrp_bom_import__write_date -#: model:ir.model.fields,field_description:mrp_bom_import.field_mrp_bom_line_import__write_date -msgid "Last Updated on" -msgstr "Última actualización el" +#: code:addons/mrp_bom_import/models/mrp_bom_import.py:309 +#, python-format +msgid "Error: Product not found." +msgstr "Error: Componente no encontrado." #. module: mrp_bom_import -#: model:ir.model.fields,field_description:mrp_bom_import.field_mrp_bom_line_import__log_info -msgid "Log Info" -msgstr "Info log." +#: code:addons/mrp_bom_import/models/mrp_bom_import.py:349 +#, python-format +msgid "Error: Quantity cannot be 0." +msgstr "Error: La cantidad no puede ser 0." #. module: mrp_bom_import -#: model:ir.actions.act_window,name:mrp_bom_import.mrp_bom_import_act -msgid "MRP BoM Import" -msgstr "MRP Importación LdM" +#: code:addons/mrp_bom_import/models/mrp_bom_import.py:389 +#, python-format +msgid "Error: There is another line with the same parent product errors." +msgstr "Error: Hay otra línea para la misma LdM con errores." #. module: mrp_bom_import -#: code:addons/mrp_bom_import/models/mrp_bom_import.py:135 -#, python-format -msgid "Manufacture" -msgstr "" +#: model:ir.model.fields,field_description:mrp_bom_import.field_import_file__software +msgid "External software" +msgstr "Software" #. module: mrp_bom_import -#: model:ir.model.fields,field_description:mrp_bom_import.field_product_product__map_number -msgid "Map Number" -msgstr "Plano montaje" +#: model:ir.model,name:mrp_bom_import.model_mrp_bom_import +msgid "Import BoM from excel file" +msgstr "Importar LdM de fichero excel" #. module: mrp_bom_import -#: model:ir.model.fields,field_description:mrp_bom_import.field_mrp_bom_line_import__origin -msgid "Origin" -msgstr "Origen" +#: model:ir.model,name:mrp_bom_import.model_mrp_bom_line_import +msgid "Import BoM lines" +msgstr "Lineas de importador de LdM" #. module: mrp_bom_import -#: model_terms:ir.ui.view,arch_db:mrp_bom_import.view_mrp_bom_import_form -msgid "Process" -msgstr "Procesar" +#: selection:import.file,software:0 +msgid "None" +msgstr "Ninguno" #. module: mrp_bom_import -#: selection:mrp.bom.line.import,state:0 -msgid "Processed" -msgstr "Procesado" +#: code:addons/mrp_bom_import/models/import_file.py:66 +#, python-format +msgid "Operation" +msgstr "Operación" #. module: mrp_bom_import +#: code:addons/mrp_bom_import/models/import_file.py:42 #: model:ir.model,name:mrp_bom_import.model_product_product -#: model:ir.model.fields,field_description:mrp_bom_import.field_mrp_bom_line_import__product_id +#, python-format msgid "Product" -msgstr "Producto" +msgstr "Componente" #. module: mrp_bom_import #: model:ir.model,name:mrp_bom_import.model_product_category @@ -200,69 +129,40 @@ msgid "Product Category" msgstr "Categoría de producto" #. module: mrp_bom_import -#: model:ir.model.fields,field_description:mrp_bom_import.field_mrp_bom_line_import__product_ref -msgid "Product code" -msgstr "Código producto" - -#. module: mrp_bom_import -#: model:ir.model.fields,field_description:mrp_bom_import.field_mrp_bom_line_import__product_name -msgid "Product name" -msgstr "Nombre producto" - -#. module: mrp_bom_import -#: code:addons/mrp_bom_import/models/mrp_bom_import.py:57 -#: code:addons/mrp_bom_import/models/mrp_bom_import.py:74 -#, python-format +#: selection:import.file,software:0 msgid "Products" -msgstr "" +msgstr "Productos" #. module: mrp_bom_import -#: model:ir.model.fields,field_description:mrp_bom_import.field_mrp_bom_line_import__quantity -msgid "Quantity" -msgstr "Cantidad" - -#. module: mrp_bom_import -#: model:ir.model.fields,field_description:mrp_bom_import.field_product_category__supplier_id -msgid "Supplier" -msgstr "Proveedor" - -#. module: mrp_bom_import -#: selection:mrp.bom.line.import,state:0 -msgid "To validate" -msgstr "Para validar" - -#. module: mrp_bom_import -#: model:ir.model.fields,field_description:mrp_bom_import.field_mrp_bom_import__bom_count -msgid "Total BoMs" -msgstr "Total LdMs" - -#. module: mrp_bom_import -#: model:ir.model.fields,field_description:mrp_bom_import.field_mrp_bom_import__products_count -msgid "Total Products" -msgstr "Total productos" +#: selection:import.file,software:0 +msgid "Regas de abastecimiento" +msgstr "" #. module: mrp_bom_import -#: model_terms:ir.ui.view,arch_db:mrp_bom_import.view_mrp_bom_import_form -msgid "Validate" -msgstr "Validar" +#: code:addons/mrp_bom_import/models/import_file.py:54 +#, python-format +msgid "Route" +msgstr "Ruta" #. module: mrp_bom_import -#: selection:mrp.bom.line.import,state:0 -msgid "Validated" -msgstr "Validado" +#: selection:import.file,software:0 +msgid "Suppliers" +msgstr "" #. module: mrp_bom_import -#: model:ir.model.fields,field_description:mrp_bom_import.field_mrp_bom_line_import__weight -msgid "Weight" -msgstr "Peso" +#: code:addons/mrp_bom_import/models/mrp_bom_import.py:198 +#, python-format +msgid "This is not a valid file." +msgstr "No es un archivo válido." #. module: mrp_bom_import -#: model:ir.model,name:mrp_bom_import.model_mrp_bom_import -msgid "mrp.bom.import" +#: selection:import.file,software:0 +msgid "Variantes" msgstr "" #. module: mrp_bom_import -#: model:ir.model,name:mrp_bom_import.model_mrp_bom_line_import -msgid "mrp.bom.line.import" -msgstr "" +#: code:addons/mrp_bom_import/models/import_file.py:60 +#, python-format +msgid "Workcenter" +msgstr "Centro de trabajo" diff --git a/mrp_bom_import/i18n/fr.po b/mrp_bom_import/i18n/fr.po new file mode 100644 index 000000000..8b57ff2e4 --- /dev/null +++ b/mrp_bom_import/i18n/fr.po @@ -0,0 +1,168 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * mrp_bom_import +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 12.0+e\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2024-03-25 09:56+0000\n" +"PO-Revision-Date: 2024-03-25 09:56+0000\n" +"Last-Translator: <>\n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: mrp_bom_import +#: model:ir.model,name:mrp_bom_import.model_import_file +msgid "Base for import file" +msgstr "" + +#. module: mrp_bom_import +#: code:addons/mrp_bom_import/models/import_file.py:91 +#, python-format +msgid "Bill of Material line" +msgstr "" + +#. module: mrp_bom_import +#: code:addons/mrp_bom_import/models/import_file.py:48 +#, python-format +msgid "Bill of material" +msgstr "" + +#. module: mrp_bom_import +#: selection:import.file,software:0 +msgid "Clients" +msgstr "" + +#. module: mrp_bom_import +#: code:addons/mrp_bom_import/models/import_file.py:74 +#, python-format +msgid "Component" +msgstr "" + +#. module: mrp_bom_import +#: code:addons/mrp_bom_import/models/mrp_bom_import.py:237 +#, python-format +msgid "Component Import Lines" +msgstr "" + +#. module: mrp_bom_import +#: selection:import.file,software:0 +msgid "Datos extra" +msgstr "" + +#. module: mrp_bom_import +#: code:addons/mrp_bom_import/models/mrp_bom_import.py:331 +#, python-format +msgid "Error: BoM product not found." +msgstr "" + +#. module: mrp_bom_import +#: code:addons/mrp_bom_import/models/mrp_bom_import.py:334 +#, python-format +msgid "Error: More than one BoM product found." +msgstr "" + +#. module: mrp_bom_import +#: code:addons/mrp_bom_import/models/mrp_bom_import.py:312 +#, python-format +msgid "Error: More than one product found." +msgstr "" + +#. module: mrp_bom_import +#: code:addons/mrp_bom_import/models/mrp_bom_import.py:309 +#, python-format +msgid "Error: Product not found." +msgstr "" + +#. module: mrp_bom_import +#: code:addons/mrp_bom_import/models/mrp_bom_import.py:349 +#, python-format +msgid "Error: Quantity cannot be 0." +msgstr "" + +#. module: mrp_bom_import +#: code:addons/mrp_bom_import/models/mrp_bom_import.py:389 +#, python-format +msgid "Error: There is another line with the same parent product errors." +msgstr "" + +#. module: mrp_bom_import +#: model:ir.model.fields,field_description:mrp_bom_import.field_import_file__software +msgid "External software" +msgstr "" + +#. module: mrp_bom_import +#: model:ir.model,name:mrp_bom_import.model_mrp_bom_import +msgid "Import BoM from excel file" +msgstr "" + +#. module: mrp_bom_import +#: model:ir.model,name:mrp_bom_import.model_mrp_bom_line_import +msgid "Import BoM lines" +msgstr "" + +#. module: mrp_bom_import +#: selection:import.file,software:0 +msgid "None" +msgstr "" + +#. module: mrp_bom_import +#: code:addons/mrp_bom_import/models/import_file.py:66 +#, python-format +msgid "Operation" +msgstr "" + +#. module: mrp_bom_import +#: code:addons/mrp_bom_import/models/import_file.py:42 +#: model:ir.model,name:mrp_bom_import.model_product_product +#, python-format +msgid "Product" +msgstr "Article" + +#. module: mrp_bom_import +#: model:ir.model,name:mrp_bom_import.model_product_category +msgid "Product Category" +msgstr "Catégorie d'article" + +#. module: mrp_bom_import +#: selection:import.file,software:0 +msgid "Products" +msgstr "" + +#. module: mrp_bom_import +#: selection:import.file,software:0 +msgid "Regas de abastecimiento" +msgstr "" + +#. module: mrp_bom_import +#: code:addons/mrp_bom_import/models/import_file.py:54 +#, python-format +msgid "Route" +msgstr "" + +#. module: mrp_bom_import +#: selection:import.file,software:0 +msgid "Suppliers" +msgstr "" + +#. module: mrp_bom_import +#: code:addons/mrp_bom_import/models/mrp_bom_import.py:198 +#, python-format +msgid "This is not a valid file." +msgstr "" + +#. module: mrp_bom_import +#: selection:import.file,software:0 +msgid "Variantes" +msgstr "" + +#. module: mrp_bom_import +#: code:addons/mrp_bom_import/models/import_file.py:60 +#, python-format +msgid "Workcenter" +msgstr "" + diff --git a/mrp_bom_import/i18n/mrp_bom_import.pot b/mrp_bom_import/i18n/mrp_bom_import.pot index 4c54735df..c747bce9d 100644 --- a/mrp_bom_import/i18n/mrp_bom_import.pot +++ b/mrp_bom_import/i18n/mrp_bom_import.pot @@ -6,8 +6,8 @@ msgid "" msgstr "" "Project-Id-Version: Odoo Server 12.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-09-25 10:38+0000\n" -"PO-Revision-Date: 2019-09-25 10:38+0000\n" +"POT-Creation-Date: 2024-03-25 09:56+0000\n" +"PO-Revision-Date: 2024-03-25 09:56+0000\n" "Last-Translator: <>\n" "Language-Team: \n" "MIME-Version: 1.0\n" @@ -16,181 +16,110 @@ msgstr "" "Plural-Forms: \n" #. module: mrp_bom_import -#: model_terms:ir.ui.view,arch_db:mrp_bom_import.view_mrp_bom_import_form -msgid "BoMs" +#: model:ir.model,name:mrp_bom_import.model_import_file +msgid "Base for import file" msgstr "" #. module: mrp_bom_import -#: model_terms:ir.ui.view,arch_db:mrp_bom_import.view_mrp_bom_import_form -msgid "Products" -msgstr "" - -#. module: mrp_bom_import -#: model:ir.model.fields,field_description:mrp_bom_import.field_mrp_bom_line_import__bom_id -msgid "BoM" -msgstr "" - -#. module: mrp_bom_import -#: model:ir.model.fields,field_description:mrp_bom_import.field_mrp_bom_line_import__bom_import_id -#: model:ir.ui.menu,name:mrp_bom_import.menu_bom_import -#: model_terms:ir.ui.view,arch_db:mrp_bom_import.view_mrp_bom_import_form -#: model_terms:ir.ui.view,arch_db:mrp_bom_import.view_mrp_bom_import_tree -#: model_terms:ir.ui.view,arch_db:mrp_bom_import.view_mrp_bom_line_tree -msgid "BoM Import" -msgstr "" - -#. module: mrp_bom_import -#: model:ir.model.fields,field_description:mrp_bom_import.field_mrp_bom_import__bom_import_lines -msgid "BoM Import Lines" -msgstr "" - -#. module: mrp_bom_import -#: model:ir.model.fields,field_description:mrp_bom_import.field_mrp_bom_line_import__bom_code -msgid "BoM code" -msgstr "" - -#. module: mrp_bom_import -#: code:addons/mrp_bom_import/models/mrp_bom_import.py:138 +#: code:addons/mrp_bom_import/models/import_file.py:91 #, python-format -msgid "Buy" +msgid "Bill of Material line" msgstr "" #. module: mrp_bom_import -#: model:ir.model.fields,field_description:mrp_bom_import.field_mrp_bom_line_import__category_id -msgid "Category" -msgstr "" - -#. module: mrp_bom_import -#: model:ir.model.fields,field_description:mrp_bom_import.field_mrp_bom_line_import__categ_name -msgid "Category name" -msgstr "" - -#. module: mrp_bom_import -#: model:ir.model.fields,field_description:mrp_bom_import.field_mrp_bom_import__create_uid -#: model:ir.model.fields,field_description:mrp_bom_import.field_mrp_bom_line_import__create_uid -msgid "Created by" -msgstr "" - -#. module: mrp_bom_import -#: model:ir.model.fields,field_description:mrp_bom_import.field_mrp_bom_import__create_date -#: model:ir.model.fields,field_description:mrp_bom_import.field_mrp_bom_line_import__create_date -msgid "Created on" -msgstr "" - -#. module: mrp_bom_import -#: model:ir.model.fields,field_description:mrp_bom_import.field_mrp_bom_import__display_name -#: model:ir.model.fields,field_description:mrp_bom_import.field_mrp_bom_line_import__display_name -msgid "Display Name" -msgstr "" - -#. module: mrp_bom_import -#: model:ir.model.fields,field_description:mrp_bom_import.field_mrp_bom_line_import__map -msgid "Erection Drawing" +#: code:addons/mrp_bom_import/models/import_file.py:48 +#, python-format +msgid "Bill of material" msgstr "" #. module: mrp_bom_import -#: selection:mrp.bom.line.import,state:0 -msgid "Error" +#: selection:import.file,software:0 +msgid "Clients" msgstr "" #. module: mrp_bom_import -#: model:ir.model.fields,field_description:mrp_bom_import.field_mrp_bom_import__data -msgid "File" +#: code:addons/mrp_bom_import/models/import_file.py:74 +#, python-format +msgid "Component" msgstr "" #. module: mrp_bom_import -#: model:ir.ui.menu,name:mrp_bom_import.mrp_bom_import -msgid "File BoM Import" +#: code:addons/mrp_bom_import/models/mrp_bom_import.py:237 +#, python-format +msgid "Component Import Lines" msgstr "" #. module: mrp_bom_import -#: model:ir.model.fields,field_description:mrp_bom_import.field_mrp_bom_import__file_date -msgid "File Import Date" +#: selection:import.file,software:0 +msgid "Datos extra" msgstr "" #. module: mrp_bom_import -#: model:ir.model.fields,field_description:mrp_bom_import.field_mrp_bom_import__filename -msgid "Filename" +#: code:addons/mrp_bom_import/models/mrp_bom_import.py:331 +#, python-format +msgid "Error: BoM product not found." msgstr "" #. module: mrp_bom_import -#: model:ir.model.fields,field_description:mrp_bom_import.field_mrp_bom_import__id -#: model:ir.model.fields,field_description:mrp_bom_import.field_mrp_bom_line_import__id -msgid "ID" +#: code:addons/mrp_bom_import/models/mrp_bom_import.py:334 +#, python-format +msgid "Error: More than one BoM product found." msgstr "" #. module: mrp_bom_import -#: model_terms:ir.ui.view,arch_db:mrp_bom_import.view_mrp_bom_import_form -msgid "Import" +#: code:addons/mrp_bom_import/models/mrp_bom_import.py:312 +#, python-format +msgid "Error: More than one product found." msgstr "" #. module: mrp_bom_import -#: model:ir.model.fields,field_description:mrp_bom_import.field_mrp_bom_import__name -msgid "Import name" +#: code:addons/mrp_bom_import/models/mrp_bom_import.py:309 +#, python-format +msgid "Error: Product not found." msgstr "" #. module: mrp_bom_import -#: model:ir.model.fields,field_description:mrp_bom_import.field_mrp_bom_line_import__state -msgid "Import state" +#: code:addons/mrp_bom_import/models/mrp_bom_import.py:349 +#, python-format +msgid "Error: Quantity cannot be 0." msgstr "" #. module: mrp_bom_import -#: model:ir.model.fields,field_description:mrp_bom_import.field_mrp_bom_import____last_update -#: model:ir.model.fields,field_description:mrp_bom_import.field_mrp_bom_line_import____last_update -msgid "Last Modified on" +#: code:addons/mrp_bom_import/models/mrp_bom_import.py:389 +#, python-format +msgid "Error: There is another line with the same parent product errors." msgstr "" #. module: mrp_bom_import -#: model:ir.model.fields,field_description:mrp_bom_import.field_mrp_bom_import__write_uid -#: model:ir.model.fields,field_description:mrp_bom_import.field_mrp_bom_line_import__write_uid -msgid "Last Updated by" +#: model:ir.model.fields,field_description:mrp_bom_import.field_import_file__software +msgid "External software" msgstr "" #. module: mrp_bom_import -#: model:ir.model.fields,field_description:mrp_bom_import.field_mrp_bom_import__write_date -#: model:ir.model.fields,field_description:mrp_bom_import.field_mrp_bom_line_import__write_date -msgid "Last Updated on" +#: model:ir.model,name:mrp_bom_import.model_mrp_bom_import +msgid "Import BoM from excel file" msgstr "" #. module: mrp_bom_import -#: model:ir.model.fields,field_description:mrp_bom_import.field_mrp_bom_line_import__log_info -msgid "Log Info" +#: model:ir.model,name:mrp_bom_import.model_mrp_bom_line_import +msgid "Import BoM lines" msgstr "" #. module: mrp_bom_import -#: model:ir.actions.act_window,name:mrp_bom_import.mrp_bom_import_act -msgid "MRP BoM Import" +#: selection:import.file,software:0 +msgid "None" msgstr "" #. module: mrp_bom_import -#: code:addons/mrp_bom_import/models/mrp_bom_import.py:135 +#: code:addons/mrp_bom_import/models/import_file.py:66 #, python-format -msgid "Manufacture" -msgstr "" - -#. module: mrp_bom_import -#: model:ir.model.fields,field_description:mrp_bom_import.field_product_product__map_number -msgid "Map Number" -msgstr "" - -#. module: mrp_bom_import -#: model:ir.model.fields,field_description:mrp_bom_import.field_mrp_bom_line_import__origin -msgid "Origin" -msgstr "" - -#. module: mrp_bom_import -#: model_terms:ir.ui.view,arch_db:mrp_bom_import.view_mrp_bom_import_form -msgid "Process" -msgstr "" - -#. module: mrp_bom_import -#: selection:mrp.bom.line.import,state:0 -msgid "Processed" +msgid "Operation" msgstr "" #. module: mrp_bom_import +#: code:addons/mrp_bom_import/models/import_file.py:42 #: model:ir.model,name:mrp_bom_import.model_product_product -#: model:ir.model.fields,field_description:mrp_bom_import.field_mrp_bom_line_import__product_id +#, python-format msgid "Product" msgstr "" @@ -200,69 +129,40 @@ msgid "Product Category" msgstr "" #. module: mrp_bom_import -#: model:ir.model.fields,field_description:mrp_bom_import.field_mrp_bom_line_import__product_ref -msgid "Product code" -msgstr "" - -#. module: mrp_bom_import -#: model:ir.model.fields,field_description:mrp_bom_import.field_mrp_bom_line_import__product_name -msgid "Product name" -msgstr "" - -#. module: mrp_bom_import -#: code:addons/mrp_bom_import/models/mrp_bom_import.py:57 -#: code:addons/mrp_bom_import/models/mrp_bom_import.py:74 -#, python-format +#: selection:import.file,software:0 msgid "Products" msgstr "" #. module: mrp_bom_import -#: model:ir.model.fields,field_description:mrp_bom_import.field_mrp_bom_line_import__quantity -msgid "Quantity" -msgstr "" - -#. module: mrp_bom_import -#: model:ir.model.fields,field_description:mrp_bom_import.field_product_category__supplier_id -msgid "Supplier" +#: selection:import.file,software:0 +msgid "Regas de abastecimiento" msgstr "" #. module: mrp_bom_import -#: selection:mrp.bom.line.import,state:0 -msgid "To validate" -msgstr "" - -#. module: mrp_bom_import -#: model:ir.model.fields,field_description:mrp_bom_import.field_mrp_bom_import__bom_count -msgid "Total BoMs" -msgstr "" - -#. module: mrp_bom_import -#: model:ir.model.fields,field_description:mrp_bom_import.field_mrp_bom_import__products_count -msgid "Total Products" -msgstr "" - -#. module: mrp_bom_import -#: model_terms:ir.ui.view,arch_db:mrp_bom_import.view_mrp_bom_import_form -msgid "Validate" +#: code:addons/mrp_bom_import/models/import_file.py:54 +#, python-format +msgid "Route" msgstr "" #. module: mrp_bom_import -#: selection:mrp.bom.line.import,state:0 -msgid "Validated" +#: selection:import.file,software:0 +msgid "Suppliers" msgstr "" #. module: mrp_bom_import -#: model:ir.model.fields,field_description:mrp_bom_import.field_mrp_bom_line_import__weight -msgid "Weight" +#: code:addons/mrp_bom_import/models/mrp_bom_import.py:198 +#, python-format +msgid "This is not a valid file." msgstr "" #. module: mrp_bom_import -#: model:ir.model,name:mrp_bom_import.model_mrp_bom_import -msgid "mrp.bom.import" +#: selection:import.file,software:0 +msgid "Variantes" msgstr "" #. module: mrp_bom_import -#: model:ir.model,name:mrp_bom_import.model_mrp_bom_line_import -msgid "mrp.bom.line.import" +#: code:addons/mrp_bom_import/models/import_file.py:60 +#, python-format +msgid "Workcenter" msgstr "" diff --git a/mrp_bom_import/models/mrp_bom_import.py b/mrp_bom_import/models/mrp_bom_import.py index b3f8aaf67..5653b8147 100644 --- a/mrp_bom_import/models/mrp_bom_import.py +++ b/mrp_bom_import/models/mrp_bom_import.py @@ -1,13 +1,17 @@ -# Copyright (c) 2019 Daniel Campos - Avanzosc S.L. +# Copyright 2019 Daniel Campos - Avanzosc S.L. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -from odoo import fields, models, exceptions, api, _ import base64 -import tempfile -import math + +from odoo import _, api, fields, models +from odoo.exceptions import ValidationError +from odoo.models import expression +from odoo.tools.safe_eval import safe_eval try: import xlrd + + try: from xlrd import xlsx except ImportError: @@ -16,289 +20,390 @@ xlrd = xlsx = None +def check_number(number): + try: + if isinstance(number, float) or isinstance(number, int): + return number + if "." in number: + val = float(number) + else: + val = int(number) + return val + except ValueError: + return False + +def convert2str(value): + if isinstance(value, float) or isinstance(value, int): + new_value = str(value).strip() + if "." in new_value: + new_value = new_value[: new_value.index(".")] + return new_value.strip(" \n\t") + elif isinstance(value, tuple): + return value[0].strip(" \n\t") + else: + return value.strip(" \n\t") + + +IMPORT_STATUS = [ + ("2validate", "To validate"), + ("pass", "Validated"), + ("error", "Error"), + ("done", "Processed"), +] + + class MrpBomImport(models.Model): - _name = 'mrp.bom.import' + _name = "mrp.bom.import" + _description = "Import BoM from excel file" + _order = "file_date desc" + _inherit = ["mail.thread", "mail.activity.mixin"] - @api.multi - @api.depends('filename', 'file_date') - def _get_import_name(self): + name = fields.Char( + string="Import name", + compute="_compute_import_name", + copy=False, + ) + bom_count = fields.Integer( + compute="_compute_bom_count", + string="Total BoMs", + ) + data = fields.Binary( + string="File", + required=True, + copy=False, + ) + filename = fields.Char( + string="Filename", + copy=False, + ) + file_date = fields.Date( + string="File Import Date", + required=True, + default=fields.Date.context_today, + copy=False, + ) + bom_line_import_ids = fields.One2many( + comodel_name="mrp.bom.line.import", + inverse_name="bom_import_id", + string="BoM Component Lines", + copy=False, + ) + state = fields.Selection( + selection=IMPORT_STATUS, + compute="_compute_state", + string="Status", + ) + log_info = fields.Text( + string="Log Info", + compute="_compute_log_info", + ) + product_found_by_code = fields.Boolean( + string="Product Found By Code", + default=False) + + def _get_import_lines(self): + return self.mapped("bom_line_import_ids") + + @api.depends("filename", "file_date") + def _compute_import_name(self): for file_import in self: - file_import.name = u'{} - {}'.format(file_import.filename, - file_import.file_date) - products_count = fields.Float(compute='_compute_products_count', - string='Total Products') - bom_count = fields.Float(compute='_compute_products_count', - string='Total BoMs') - name = fields.Char(string='Import name', compute='_get_import_name') - data = fields.Binary('File', required=True) - filename = fields.Char('Filename') - file_date = fields.Date(string="File Import Date", required=True, - default=fields.Date.context_today) - bom_import_lines = fields.One2many( - comodel_name='mrp.bom.line.import', inverse_name='bom_import_id', - string='BoM Import Lines' + file_import.name = "{} - {}".format( + file_import.filename, file_import.file_date + ) + + @api.depends( + "bom_line_import_ids", + "bom_line_import_ids.product_id", + "bom_line_import_ids.bom_id", ) + def _compute_bom_count(self): + for bom_import in self: + lines = bom_import._get_import_lines() + bom_import.bom_count = len(lines.mapped("bom_id")) - @api.multi - def _compute_products_count(self): - if self.bom_import_lines: - self.products_count = len( - set(self.mapped("bom_import_lines.product_id").ids)) - self.bom_count = len( - set(self.mapped("bom_import_lines.bom_id").ids)) - return {} - - @api.multi - def action_bom_import_products(self): - views = [ - (self.env.ref('product.product_product_tree_view').id, 'tree'), - (self.env.ref('product.product_normal_form_view').id, 'form')] - return { - 'name': _('Products'), - 'view_type': 'form', - 'view_mode': 'tree,form', - 'res_model': 'product.product', - 'view_id': False, - 'views': views, - 'type': 'ir.actions.act_window', - 'domain': [('id', 'in', - self.bom_import_lines.mapped("product_id").ids)], - } + @api.depends( + "bom_line_import_ids", + "bom_line_import_ids.state", + ) + def _compute_state(self): + for bom_import in self: + lines = bom_import._get_import_lines() + line_states = lines.mapped("state") + if line_states and any([state == "error" for state in line_states]): + bom_import.state = "error" + elif line_states and all([state == "done" for state in line_states]): + bom_import.state = "done" + elif line_states and all([state == "pass" for state in line_states]): + bom_import.state = "pass" + else: + bom_import.state = "2validate" + + @api.depends( + "bom_line_import_ids", + "bom_line_import_ids.log_info", + ) + def _compute_log_info(self): + for bom_import in self: + lines = bom_import._get_import_lines() + logged_lines = lines.filtered("log_info") + if logged_lines: + bom_import.log_info = "\n".join(logged_lines.mapped("log_info")) + else: + bom_import.log_info = "" - @api.multi def action_bom_import_boms(self): - views = [ - (self.env.ref('mrp.mrp_bom_tree_view').id, 'tree'), - (self.env.ref('mrp.mrp_bom_form_view').id, 'form')] - return { - 'name': _('Products'), - 'view_type': 'form', - 'view_mode': 'tree,form', - 'res_model': 'mrp.bom', - 'view_id': False, - 'views': views, - 'type': 'ir.actions.act_window', - 'domain': [('id', 'in', - self.bom_import_lines.mapped("bom_id").ids)], - } + action = self.env.ref("mrp.mrp_bom_form_action") + action_dict = action and action.read()[0] + lines = self._get_import_lines() + domain = expression.AND( + [ + [("id", "in", lines.mapped("bom_id").ids)], + safe_eval(action.domain or "[]"), + ] + ) + action_dict.update({"domain": domain}) + return action_dict - def check_number(self, number): - try: - if isinstance(number, float) or isinstance(number, int): - return number - if "." in number: - val = float(number) - else: - val = int(number) - return val - except ValueError: - return False - - def float2string(self, number): - if isinstance(number, float): - if math.fmod(number, 1) == 0.0: - return str(number).replace('.0', '') - return str(number) - - def check_product(self, name, default_code, weight=False, map_number=False, - category_id=False, origin=False): - product_obj = self.env['product.product'] - product_category = self.env['product.category'] - supplierinfo_obj = self.env['product.supplierinfo'] - route_obj = self.env['stock.location.route'] - wh_obj = self.env['stock.warehouse'] - if not name and not default_code: - return False - sub_name = product = False - if default_code: - sub_name = product_obj.search([('name', 'ilike', default_code)], - limit=1) - product = product_obj.search([('default_code', '=', default_code)], - limit=1) - if sub_name: - return False - if not product and name: - product = product_obj.search(([('name', '=', name)]), limit=1) - if not product: - vals = {'name': name, - 'default_code': default_code, - 'type': 'product', - 'weight': weight, - 'map_number': map_number, - } - if category_id: - vals['categ_id'] = category_id - if origin and (origin == 'F' or origin == 'C'): - if origin == 'F': - route_id = wh_obj._find_global_route( - 'mrp.route_warehouse0_manufacture', - _('Manufacture')).id - if origin == 'C': - route_id = wh_obj._find_global_route( - 'purchase_stock.route_warehouse0_buy', _('Buy')).id - vals['route_ids'] = [(6, 0, [route_id])] - product = product_obj.create(vals) - if category_id: - category = product_category.browse(category_id) - if category.supplier_id: - sup_info = supplierinfo_obj.search( - [('product_id', '=', product.id), - ('product_tmpl_id', '=', product.product_tmpl_id.id), - ('name', '=', category.supplier_id.id)]) - if not sup_info: - supplierinfo_obj.create( - {'product_id': product.id, - 'product_tmpl_id': product.product_tmpl_id.id, - 'name': category.supplier_id.id}) - return product.id - - def check_categ(self, name): - product_categ_obj = self.env['product.category'] - if not name: - return False - categ_lst = product_categ_obj.search([('name', '=', name)], limit=1) - if not categ_lst: - return False - else: - return categ_lst.id + def action_bom_import_bom_lines(self): + action = self.env.ref("mrp_bom_import.mrp_bom_line_action") + action_dict = action and action.read()[0] + lines = self._get_import_lines() + domain = expression.AND( + [ + [("id", "in", lines.mapped("bom_line_id").ids)], + safe_eval(action.domain or "[]"), + ] + ) + action_dict.update({"domain": domain}) + return action_dict def action_import_bom(self): - for line in self.bom_import_lines: - line.unlink() - """Load BoM lines data from the xls file.""" - file_1 = base64.decodestring(self.data) - (fileno, fp_name) = tempfile.mkstemp('.xls', 'odoo_') - outFile = open(fp_name, 'wb') - outFile.write(file_1) - outFile.close() - reader = xlrd.open_workbook(fp_name) - sheet = reader.sheet_by_index(0) - ctx = self.env.context - bom_import_line_obj = self.env['mrp.bom.line.import'] - keys = ['null', 'item', 'qty', 'code', 'map', 'name', 'weight', - 'qty_total', 'denomination', 'weight2', 'parent_code', - 'origin', 'category' - ] - reader.nrow = 10 - for counter in range(9, sheet.nrows-1): - # grab the current row - rowValues = sheet.row_values(counter+1, 0, end_colx=sheet.ncols) - values = dict(zip(keys, rowValues)) - line_data = { - 'bom_import_id': self.id, - 'product_name': values['name'], - 'quantity': self.check_number(values['qty']) or 0, - 'product_ref': self.float2string(values['code']), - 'map': self.float2string(values['map']), - 'weight': self.check_number(values['weight']) or 0, - 'origin': values['origin'], - 'bom_code': values['parent_code'], - 'categ_name': values['category'], - } - try: - bom_import_line_obj.create(line_data) - except Exception as error: - raise exceptions.Warning(u"Line Error: \n") + self.ensure_one() + (self._get_import_lines()).unlink() + book = base64.decodebytes(self.data) + reader = xlrd.open_workbook(file_contents=book) + try: + sheet_list = reader.sheet_names() + for sheet_name in sheet_list: + sheet = reader.sheet_by_name(sheet_name) + bom_import_line_obj = self.env["mrp.bom.line.import"] + keys = [c.value for c in sheet.row(0)] + for counter in range(1, sheet.nrows): + row_values = sheet.row_values(counter, 0, end_colx=sheet.ncols) + values = dict(zip(keys, row_values)) + line_data = self._get_line_values(values) + if line_data: + bom_import_line_obj.create(line_data) + except Exception: + raise ValidationError(_("This is not a valid file.")) + + def _get_line_values(self, row_values): + self.ensure_one() + if ( + not row_values.get("Product Name") + and not row_values.get("Product Code") + and not row_values.get("Quantity", 1) + ): + return {} + values = { + "bom_ref": convert2str(row_values.get("BoM Ref", "")), + "product_name": convert2str(row_values.get("Product Name", "")), + "product_ref": convert2str(row_values.get("Product Code", "")), + "quantity": check_number(row_values.get("Quantity", 1)), + "bom_code": convert2str(row_values.get("Parent Code", "")), + "bom_name": convert2str(row_values.get("Parent Name", "")), + "parent_qty": check_number(row_values.get("Parent Qty", 1)), + } + values.update( + { + "bom_import_id": self.id, + } + ) + return values def action_validate_lines(self): - product_obj = self.env['product.product'] - bom_obj = self.env['mrp.bom'] - for line in self.bom_import_lines.filtered( - lambda x: x.state not in ('done', 'pass')): - category_id = False - if line.categ_name: - category_id = self.check_categ(line.categ_name) - if category_id: - line.category_id = category_id - if not category_id: - line.state = 'error' - line.log_info = 'Error: Category not found' - continue - if not line.product_id and (line.product_ref or line.product_name): - product_id = self.check_product(line.product_name, - line.product_ref, - line.weight, - line.map, - line.category_id.id, - line.origin - ) - line.product_id = product_id - line.state = 'pass' - elif line.product_id: - line.state = 'pass' - else: - line.state = 'error' - line.log_info = 'Error: Cannot assign product' - continue - if line.bom_code: - bom = bom_obj.search([('code', '=', line.bom_code)]) - if bom: - line.state = 'error' - line.log_info = 'Error: BoM already exist' - continue - bom_product = product_obj.search([('default_code', '=', - line.bom_code)]) - if not bom_product: - line.state = 'error' - line.log_info = 'Error: BoM product does not exist' - continue - if not line.quantity: - line.state = 'error' - line.log_info = 'Error: Quantity cannot be 0' + lines = (self._get_import_lines()).filtered( + lambda x: x.state not in ("done")) + lines.action_validate_lines() def action_process_lines(self): - bom_obj = self.env['mrp.bom'] - bom_line_obj = self.env['mrp.bom.line'] - product_obj = self.env['product.product'] - for line in self.bom_import_lines.filtered( - lambda x: x.state == 'pass'): - bom_product = product_obj.search( - [('default_code', '=', line.bom_code)], limit=1) - if not bom_product: - line.state = 'error' - line.log_info = 'Error: BoM product does not exist' - break - bom = bom_obj.search( - [('code', '=', line.bom_code)], limit=1) - if not bom: - bom = bom_obj.create( - {'code': line.bom_code, - 'product_tmpl_id': bom_product.product_tmpl_id.id, - 'product_id': bom_product.id}) - bom_line = bom_line_obj.search( - [('product_id', '=', line.product_id.id), - ('bom_id', '=', bom.id)], limit=1) - if not bom_line: - bom_line = bom_line_obj.create( - {'product_id': line.product_id.id, - 'product_qty': line.quantity, 'bom_id': bom.id}) - line.bom_id = bom.id - line.state = 'done' - line.log_info = '' + lines = (self._get_import_lines()).filtered( + lambda x: x.state == "pass") + lines.action_process_lines() + + def button_open_bom_component_import_line(self): + self.ensure_one() + return { + "name": _("Component Import Lines"), + "type": "ir.actions.act_window", + "res_model": self.bom_line_import_ids._name, + "view_mode": "tree", + "view_id": self.env.ref( + "mrp_bom_import.mrp_bom_line_component_import_view_tree" + ).id, + "target": "current", + "domain": [("id", "in", self.bom_line_import_ids.ids)], + "context": { + "default_bom_import_id": self.id, + }, + } class MrpBomLineImport(models.Model): - _name = 'mrp.bom.line.import' + _name = "mrp.bom.line.import" + _description = "Import BoM lines" bom_import_id = fields.Many2one( - comodel_name='mrp.bom.import', string='BoM Import', ondelete='cascade', - required=True) - quantity = fields.Float(string='Quantity') - product_name = fields.Char(string='Product name') - product_ref = fields.Char(string='Product code') - product_id = fields.Many2one('product.product', string='Product') - weight = fields.Float(string='Weight') - origin = fields.Char(string='Origin') - map = fields.Char(string='Erection Drawing') - bom_code = fields.Char(string='BoM code') - bom_id = fields.Many2one('mrp.bom', string='BoM') - categ_name = fields.Char(string='Category name') - category_id = fields.Many2one('product.category', string='Category') - log_info = fields.Text(string='Log Info') - state = fields.Selection([ - ('2validate', 'To validate'), - ('pass', 'Validated'), - ('error', 'Error'), - ('done', 'Processed')], - string='Import state', default='2validate' + comodel_name="mrp.bom.import", + string="BoM Import", + ondelete="cascade", ) + product_name = fields.Char(string="Product name") + product_ref = fields.Char(string="Product code") + product_id = fields.Many2one( + comodel_name="product.product", + string="Product", + ) + quantity = fields.Float(string="Quantity") + bom_ref = fields.Char(string="BoM Ref") + bom_code = fields.Char(string="BoM code") + bom_name = fields.Char(string="BoM Name") + bom_product_id = fields.Many2one( + string="Parent Product", + comodel_name="product.product") + bom_id = fields.Many2one( + comodel_name="mrp.bom", + string="BoM", + ) + bom_line_id = fields.Many2one( + string="BoM Line", + comodel_name="mrp.bom.line") + log_info = fields.Text(string="Log Info") + state = fields.Selection( + selection=IMPORT_STATUS, + string="Status", + default="2validate", + ) + parent_product_bom_count = fields.Integer( + string="Parent Bom Qty", + related="bom_product_id.bom_count", + store=True) + parent_qty = fields.Float(string="Parent Quantity") + + def _check_product(self): + self.ensure_one() + log_info = "" + if self.product_id: + return self.product_id, log_info + product_obj = self.env["product.product"] + search_domain = [("name", "=", self.product_name)] + if self.product_ref: + search_domain = expression.AND( + [[("default_code", "=", self.product_ref)], search_domain] + ) + if self.bom_import_id.product_found_by_code: + search_domain = [("default_code", "=", self.product_ref)] + products = product_obj.search(search_domain) + if not products: + products = False + log_info = _("Error: Product not found.") + elif len(products) != 1: + products = False + log_info = _("Error: More than one product found.") + return products, log_info + + def _check_bom_product(self): + self.ensure_one() + log_info = "" + if self.bom_product_id: + return self.bom_product_id, log_info + product_obj = self.env["product.product"] + search_domain = [("name", "=", self.bom_name)] + if self.bom_code: + search_domain = expression.AND( + [[("default_code", "=", self.bom_code)], search_domain] + ) + if self.bom_import_id.product_found_by_code: + search_domain = [("default_code", "=", self.bom_code)] + products = product_obj.search(search_domain) + if not products: + products = False + log_info = _("Error: BoM product not found.") + elif len(products) != 1: + products = False + log_info = _("Error: More than one BoM product found.") + return products, log_info + + def action_validate_lines(self): + for line in self.filtered(lambda x: x.state not in ("done")): + line_vals = {} + log_info = "" + product = bom_product = bom = False + product, product_log_info = line._check_product() + if product_log_info: + log_info += product_log_info + bom_product, bom_product_log_info = line._check_bom_product() + if bom_product_log_info: + log_info += bom_product_log_info + if not line.quantity: + log_info += _("Error: Quantity cannot be 0.") + state = "error" if log_info else "pass" + line_vals.update( + { + "product_id": product and product.id, + "bom_product_id": bom_product and bom_product.id, + "bom_id": bom and bom.id, + "state": state, + "log_info": log_info, + } + ) + line.write(line_vals) + + def _create_bom(self): + self.ensure_one() + bom = self.env["mrp.bom"].create({ + "product_tmpl_id": self.bom_product_id.product_tmpl_id.id, + "code": self.bom_ref, + "product_qty": self.parent_qty, + "product_uom_id": self.bom_product_id.uom_id.id}) + return bom + + def generate_bom_line_values(self): + self.ensure_one() + bom_line = { + "product_id": self.product_id.id, + "product_qty": self.quantity, + "product_uom_id": self.product_id.uom_id.id} + return bom_line + + def action_process_lines(self): + bom_product = [] + for line in self.filtered(lambda x: x.state == "pass"): + log_info = "" + bom = False + if not line.bom_id and line.bom_product_id and line.bom_product_id not in bom_product: + state = "2validate" + same_parent = line.bom_import_id.bom_line_import_ids.filtered( + lambda c: c.bom_product_id == line.bom_product_id) + if any([state.state == "error" for state in same_parent]): + log_info = _("Error: There is another line with the " + + "same parent product errors.") + state = "error" + else: + bom = line._create_bom() + for l in same_parent: + bom_line_values = l.generate_bom_line_values() + bom_line_values.update({"bom_id": bom.id}) + bom_line = self.env["mrp.bom.line"].create( + bom_line_values) + l.write({ + "bom_id": bom.id, + "bom_line_id": bom_line.id, + "state": "done"}) + state = "done" + line.write( + { + "state": state, + "log_info": log_info, + } + ) diff --git a/mrp_bom_import/views/mrp_bom_import_line_view.xml b/mrp_bom_import/views/mrp_bom_import_line_view.xml new file mode 100644 index 000000000..0edbab6d2 --- /dev/null +++ b/mrp_bom_import/views/mrp_bom_import_line_view.xml @@ -0,0 +1,48 @@ + + + + mrp.bom.line.import + + + + + + + + + + + + + + + + + diff --git a/mrp_bom_import/views/mrp_bom_import_view.xml b/mrp_bom_import/views/mrp_bom_import_view.xml new file mode 100644 index 000000000..f7195bde7 --- /dev/null +++ b/mrp_bom_import/views/mrp_bom_import_view.xml @@ -0,0 +1,185 @@ + + + + mrp.bom.import + + + + + + + + + + + + mrp.bom.import + +
+
+
+ +
+ + +
+ + + + + + + + + + + + + + + + + + + +
+

Help with Excel column names

+

You must use this column names in order to fill the table:

+
    +
  • Product Code: this will fill Component Product Code
  • +
  • Product Name: this will fill Component Product Name
  • +
  • Quantity: this will fill Component Quantity
  • +
  • Parent Code: this will fill Parent Product Code
  • +
  • Parent Name: this will fill Parent Product Name
  • +
  • Parent Qty: this will fill Parent Product Quantity
  • +
  • BoM Ref: this will fill BoM Reference
  • +
+
+
+
+
+ +
+
+
+
+ + + mrp.bom.line.import + + + + + + + + + + + + + + + + + + + + + + MRP BoM Import + ir.actions.act_window + mrp.bom.import + tree,form + + + + + + +
diff --git a/mrp_bom_import/views/mrp_bom_line_view.xml b/mrp_bom_import/views/mrp_bom_line_view.xml new file mode 100644 index 000000000..6748197a9 --- /dev/null +++ b/mrp_bom_import/views/mrp_bom_line_view.xml @@ -0,0 +1,25 @@ + + + + + mrp.bom.line.tree + mrp.bom.line + + + + + + + + + + + + MRP BoM Lines + ir.actions.act_window + mrp.bom.line + tree,form + + + +