From d61672dac481cf36118ceab1f712e30346edd0e8 Mon Sep 17 00:00:00 2001 From: Mauricio Baeza Date: Mon, 5 Jul 2021 15:21:03 -0500 Subject: [PATCH] Add UI windows for add inventory manually --- source/app/models/main.py | 5 +++ source/static/js/controller/products.js | 24 ++++++++++++++ source/static/js/ui/products.js | 42 ++++++++++++++++++++++++- 3 files changed, 70 insertions(+), 1 deletion(-) diff --git a/source/app/models/main.py b/source/app/models/main.py index 32054f2..7c83a0b 100644 --- a/source/app/models/main.py +++ b/source/app/models/main.py @@ -3563,6 +3563,7 @@ class Productos(BaseModel): tags = ManyToManyField(Tags, related_name='productos_tags') cantidad_empaque = DecimalField(default=0.0, max_digits=14, decimal_places=4, auto_round=True) + is_discontinued = BooleanField(default=False) class Meta: order_by = ('descripcion',) @@ -9943,6 +9944,10 @@ def _migrate_tables(rfc=''): decimal_places=4, auto_round=True) migrations.append(migrator.add_column( table, 'cantidad_empaque', cantidad_empaque)) + if not 'is_discontinued' in columns: + is_discontinued = BooleanField(default=False) + migrations.append(migrator.add_column( + table, 'is_discontinued', is_discontinued)) table = 'facturasdetalle' columns = [c.name for c in database_proxy.get_columns(table)] diff --git a/source/static/js/controller/products.js b/source/static/js/controller/products.js index d6f4eef..a992b7a 100644 --- a/source/static/js/controller/products.js +++ b/source/static/js/controller/products.js @@ -32,6 +32,7 @@ var products_controllers = { $$("cmd_save_product").attachEvent("onItemClick", cmd_save_product_click) $$("cmd_cancel_product").attachEvent("onItemClick", cmd_cancel_product_click) $$("cmd_import_products").attachEvent("onItemClick", cmd_import_products_click) + $$("cmd_add_inventory").attachEvent("onItemClick", cmd_add_inventory_click) $$("cmd_products_add").attachEvent("onItemClick", cmd_products_add_click) $$('cmd_add_products_from_xml').attachEvent('onItemClick', cmd_add_products_from_xml_click) $$('cmd_save_products_add').attachEvent('onItemClick', cmd_save_products_add_click) @@ -433,6 +434,19 @@ function up_products_upload_complete(response){ } +//~ Add inventory +function cmd_add_inventory_click(id, e, node){ + var row = $$('grid_products').getSelectedItem() + if (row == undefined){ + msg_error('Selecciona un Producto') + return + } + + win_add_inventory.init() + $$('win_add_inventory').show() + +} + //~ Add products function cmd_products_add_click(id, e, node){ $$("multi_products").setValue("product_add") @@ -681,3 +695,13 @@ function grid_partner_products_select(row_id, state){ grid.refresh(row_id) } } + + +function cmd_add_inventory_save_click(id, e, node){ + +} + + +function cmd_add_inventory_cancel_click(id, e, node){ + $$('win_add_inventory').close() +} diff --git a/source/static/js/ui/products.js b/source/static/js/ui/products.js index cdcfc7a..a2e6d3e 100644 --- a/source/static/js/ui/products.js +++ b/source/static/js/ui/products.js @@ -10,7 +10,9 @@ var toolbar_products = [ {}, {view: 'button', id: 'cmd_import_products', label: 'Importar', type: 'iconButton', autowidth: true, icon: 'upload'}, - {view: "button", id: "cmd_products_add", label: "Altas", + {view: "button", id: "cmd_add_inventory", label: "Altas", + type: "iconButton", autowidth: true, icon: "plus"}, + {view: "button", id: "cmd_products_add", label: "Altas CFDI", type: "iconButton", autowidth: true, icon: "plus"}, ] @@ -413,3 +415,41 @@ var win_add_products_from_xml = { $$('up_products_from_xml').attachEvent('onUploadComplete', up_products_from_xml_upload_complete) } } + + +var body_add_inventory = {rows: [{minHeight: 10}, + {view: 'text', id: 'txt_add_id', readonly: true, hidden: true}, + {cols: [ + {view: 'text', id: 'txt_add_key', label: 'Clave', + labelPosition: 'top', readonly: true}, + {view: 'text', id: 'txt_add_unit', label: 'Unidad', + labelPosition: 'top', readonly: true}, + ]}, + {view: 'textarea', id: 'txt_add_description', height: 100, + label: 'DescripciĆ³n', readonly: true, labelPosition: 'top'}, + {view: 'counter', id: 'txt_new_cant', label: 'Cantidad a agregar', + labelWidth: 'auto', step: 5, value: 0, min: 0.01}, + {minHeight: 20}, + {cols: [{}, + {view: 'button', id: 'cmd_add_inventory_save', label: 'Guardar'}, {}, + {view: 'button', id: 'cmd_add_inventory_cancel', label: 'Cancelar', type: 'danger'}, {} + ]}, + {minHeight: 20}, +]} + + +var win_add_inventory = { + init: function(){ + webix.ui({ + view: 'window', + id: 'win_add_inventory', + width: 600, + modal: true, + position: 'center', + head: 'Agregar manualmente', + body: body_add_inventory, + }) + $$('cmd_add_inventory_save').attachEvent('onItemClick', cmd_add_inventory_save_click) + $$('cmd_add_inventory_cancel').attachEvent('onItemClick', cmd_add_inventory_cancel_click) + } +}