From 60f8451307ec4a4d227594826455421fcefeed4c Mon Sep 17 00:00:00 2001 From: Elvis Date: Sun, 3 Dec 2023 19:28:55 -0500 Subject: [PATCH] add new wizard --- __init__.py | 2 + locale/es.po | 106 ++++++++++++++----- stock.py | 137 ++++++++++++++++++++++++- stock.xml | 12 +++ view/create_order_point_start_form.xml | 27 +++++ 5 files changed, 255 insertions(+), 29 deletions(-) create mode 100644 view/create_order_point_start_form.xml diff --git a/__init__.py b/__init__.py index cd04974..bc21931 100755 --- a/__init__.py +++ b/__init__.py @@ -32,6 +32,7 @@ def register(): inventory.InventoryLine, inventory.CreateInventoriesStart, stock.WarehouseKardexStockStart, + stock.CreateOrderPointStart, product.ChangeUdmProductStart, location.ProductsByLocations, module='stock_co', type_='model') @@ -43,6 +44,7 @@ def register(): shipment.CreateInternalShipment, stock.WarehouseStock, stock.PrintProducts, + stock.CreateOrderPoint, shipment.ShipmentOutForceDraft, shipment.ShipmentInternalForceDraft, shipment.Assign, diff --git a/locale/es.po b/locale/es.po index 31eec46..016cfe6 100755 --- a/locale/es.po +++ b/locale/es.po @@ -36,10 +36,6 @@ msgctxt "field:product.product,amount_cost:" msgid "Amiunt Cost" msgstr "" -msgctxt "field:product.product,asset_location:" -msgid "Asset Location" -msgstr "" - msgctxt "field:product.product,avg_cost_price:" msgid "Average Cost Price" msgstr "Costo Promedio" @@ -48,30 +44,10 @@ msgctxt "field:product.product,exportable:" msgid "Exportable" msgstr "" -#, fuzzy -msgctxt "field:product.product,external_code:" -msgid "External Code" -msgstr "Cód. Externo" - -#, fuzzy -msgctxt "field:product.product,model_num:" -msgid "Model Number" -msgstr "Modelo" - -#, fuzzy -msgctxt "field:product.product,owner:" -msgid "Ower" -msgstr "Propietario" - msgctxt "field:product.product,positions:" msgid "Positions" msgstr "Locaciones" -#, fuzzy -msgctxt "field:product.product,serial:" -msgid "Serial" -msgstr "Serial" - msgctxt "field:product.product,stock_duration:" msgid "Stock Duration" msgstr "Duración de Inventario" @@ -192,6 +168,58 @@ msgctxt "field:stock_co.create_internal_shipment.start,to_location:" msgid "To Location" msgstr "A Ubicación" +msgctxt "field:stock_co.create_order_point.start,category:" +msgid "Category" +msgstr "Categoría" + +msgctxt "field:stock_co.create_order_point.start,company:" +msgid "Company" +msgstr "Empresa" + +msgctxt "field:stock_co.create_order_point.start,location:" +msgid "Location" +msgstr "Ubicación" + +msgctxt "field:stock_co.create_order_point.start,max_quantity:" +msgid "Maximal Quantity" +msgstr "Cantidad máxima" + +msgctxt "field:stock_co.create_order_point.start,min_quantity:" +msgid "Minimal Quantity" +msgstr "Cantidad mínima" + +msgctxt "field:stock_co.create_order_point.start,overflowing_location:" +msgid "Overflowing Location" +msgstr "Ubicación de excesos" + +msgctxt "field:stock_co.create_order_point.start,provisioning_location:" +msgid "Provisioning Location" +msgstr "Ubicación del abastecimiento" + +msgctxt "field:stock_co.create_order_point.start,storage_location:" +msgid "Storage Location" +msgstr "Ubicación interna" + +msgctxt "field:stock_co.create_order_point.start,target_quantity:" +msgid "Target Quantity" +msgstr "Cantidad destino" + +msgctxt "field:stock_co.create_order_point.start,type:" +msgid "Type" +msgstr "Tipo" + +msgctxt "field:stock_co.create_order_point.start,unit:" +msgid "Unit" +msgstr "Unidad" + +msgctxt "field:stock_co.create_order_point.start,unit_digits:" +msgid "Unit Digits" +msgstr "Dígitos de la unidad" + +msgctxt "field:stock_co.create_order_point.start,warehouse_location:" +msgid "Warehouse Location" +msgstr "Ubicación del Almacén" + msgctxt "field:stock_co.move_by_product.start,brand:" msgid "Brand" msgstr "Marca" @@ -425,6 +453,10 @@ msgctxt "model:ir.action,name:wizard_change_udm_product" msgid "Change UDM product" msgstr "" +msgctxt "model:ir.action,name:wizard_create_order_point" +msgid "Create Order Point" +msgstr "Crear Reglas de Abastecimiento" + msgctxt "model:ir.action,name:wizard_move_by_product" msgid "Move by Product" msgstr "Movimiento por Producto" @@ -477,6 +509,10 @@ msgctxt "model:ir.ui.menu,name:menu_reports" msgid "Reports" msgstr "Reportes" +msgctxt "model:ir.ui.menu,name:menu_wizard_create_order_point" +msgid "Create Order Point" +msgstr "Crear Reglas de Abastecimiento" + msgctxt "model:ir.ui.menu,name:print_products_report" msgid "Products Report" msgstr "Catalogo de Productos" @@ -517,6 +553,10 @@ msgctxt "model:stock_co.create_internal_shipment.start,name:" msgid "Create Internal Shipment Start" msgstr "Crear Envio Interno" +msgctxt "model:stock_co.create_order_point.start,name:" +msgid "Create Order Point Start" +msgstr "Crear Reglas de Abastecimiento" + msgctxt "model:stock_co.move_by_product.start,name:" msgid "Move By Product Start" msgstr "Movimiento por Producto" @@ -537,7 +577,6 @@ msgctxt "model:stock_co.warehouse_stock_detailed.start,name:" msgid "Warehouse Stock Detailed Start" msgstr "Informe de Existencias Detallado" -#, fuzzy msgctxt "report:stock.shipment.in.return.report:" msgid ":" msgstr ":" @@ -876,7 +915,6 @@ msgctxt "report:stock.shipment.shipment_detailed.report:" msgid "TRYTON" msgstr "" -#, fuzzy msgctxt "report:stock.shipment.shipment_detailed.report:" msgid "company" msgstr "empresa" @@ -2095,6 +2133,14 @@ msgctxt "selection:stock.shipment.shipment_detailed.start,type_shipment:" msgid "Supplier" msgstr "Proveedor" +msgctxt "selection:stock_co.create_order_point.start,type:" +msgid "Internal" +msgstr "Interno" + +msgctxt "selection:stock_co.create_order_point.start,type:" +msgid "Purchase" +msgstr "Orden de Compra" + msgctxt "view:product.template:" msgid "Positions" msgstr "Locaciones" @@ -2151,6 +2197,14 @@ msgctxt "wizard_button:stock_co.create_internal_shipment,start,end:" msgid "Cancel" msgstr "Cancelar" +msgctxt "wizard_button:stock_co.create_order_point,start,accept:" +msgid "Ok" +msgstr "Aceptar" + +msgctxt "wizard_button:stock_co.create_order_point,start,end:" +msgid "Cancel" +msgstr "Cancelar" + msgctxt "wizard_button:stock_co.print_move_by_product,start,end:" msgid "Cancel" msgstr "Cancelar" diff --git a/stock.py b/stock.py index e3a78a4..df1f911 100755 --- a/stock.py +++ b/stock.py @@ -6,10 +6,10 @@ from decimal import Decimal from trytond.model import fields, ModelView from trytond.pool import Pool, PoolMeta from trytond.pyson import Eval, Not, Bool -from trytond.wizard import Wizard, StateView, StateReport, Button +from trytond.wizard import Wizard, StateView, StateReport, Button, StateTransition from trytond.report import Report from trytond.transaction import Transaction - +from trytond.pyson import Eval, Equal, If, In STATES = {'invisible': (Eval('type') != 'goods')} @@ -1002,7 +1002,6 @@ class WarehouseKardexReport(Report): add_item = True elif row[6] == 'purchase.line': # qty_input = row[9] - print('paso por elif') party, number, cost_price, qty_input = purchase_lines_dict[int(row[7])] balance += qty_input add_item = True @@ -1031,3 +1030,135 @@ class WarehouseKardexReport(Report): } res.append(value) return res + + +class CreateOrderPointStart(ModelView): + 'Create Order Point Start' + __name__ = 'stock_co.create_order_point.start' + category = fields.Many2One('product.category', 'Category', required=True, + domain=[('accounting', '=', False)]) + warehouse_location = fields.Many2One('stock.location', + 'Warehouse Location', select=True, + domain=[('type', '=', 'warehouse')], + states={ + 'invisible': Not(Equal(Eval('type'), 'purchase')), + 'required': Equal(Eval('type'), 'purchase'), + }, + depends=['type']) + storage_location = fields.Many2One('stock.location', 'Storage Location', + select=True, + domain=[('type', '=', 'storage')], + states={ + 'invisible': Not(Equal(Eval('type'), 'internal')), + 'required': Equal(Eval('type'), 'internal'), + }, + depends=['type']) + location = fields.Function(fields.Many2One('stock.location', 'Location'), + 'get_location', searcher='search_location') + provisioning_location = fields.Many2One( + 'stock.location', 'Provisioning Location', + domain=[('type', 'in', ['storage', 'view'])], + states={ + 'invisible': Not(Equal(Eval('type'), 'internal')), + 'required': ((Eval('type') == 'internal') + & (Eval('min_quantity', None) != None)), # noqa: E711 + }, + depends=['type', 'min_quantity']) + overflowing_location = fields.Many2One( + 'stock.location', 'Overflowing Location', + domain=[('type', 'in', ['storage', 'view'])], + states={ + 'invisible': Eval('type') != 'internal', + 'required': ((Eval('type') == 'internal') + & (Eval('max_quantity', None) != None)), # noqa: E711 + }, + depends=['type', 'max_quantity']) + type = fields.Selection( + [('internal', 'Internal'), + ('purchase', 'Purchase')], + 'Type', select=True, required=True) + min_quantity = fields.Float('Minimal Quantity', + digits=(16, Eval('unit_digits', 2)), + states={ + # required for purchase and production types + 'required': Eval('type') != 'internal', + }, + domain=['OR', + ('min_quantity', '=', None), + ('min_quantity', '<=', Eval('target_quantity', 0)), + ], + depends=['unit_digits', 'target_quantity', 'type']) + target_quantity = fields.Float('Target Quantity', required=True, + digits=(16, Eval('unit_digits', 2)), + domain=[ + ['OR', + ('min_quantity', '=', None), + ('target_quantity', '>=', Eval('min_quantity', 0)), + ], + ['OR', + ('max_quantity', '=', None), + ('target_quantity', '<=', Eval('max_quantity', 0)), + ], + ], + depends=['unit_digits', 'min_quantity', 'max_quantity']) + max_quantity = fields.Float('Maximal Quantity', + digits=(16, Eval('unit_digits', 2)), + states={ + 'invisible': Eval('type') != 'internal', + }, + domain=['OR', + ('max_quantity', '=', None), + ('max_quantity', '>=', Eval('target_quantity', 0)), + ], + depends=['unit_digits', 'type', 'target_quantity']) + company = fields.Many2One('company.company', 'Company', required=True, + domain=[ + ('id', If(In('company', Eval('context', {})), '=', '!='), + Eval('context', {}).get('company', -1)), + ]) + unit = fields.Function(fields.Many2One('product.uom', 'Unit'), 'get_unit') + unit_digits = fields.Function(fields.Integer('Unit Digits'), + 'get_unit_digits') + + @staticmethod + def default_company(): + return Transaction().context.get('company') + + @staticmethod + def default_type(): + return "purchase" + + +class CreateOrderPoint(Wizard): + 'Create Order Point' + __name__ = 'stock_co.create_order_point' + start = StateView('stock_co.create_order_point.start', + 'stock_co.create_order_point_start_view_form', [ + Button('Cancel', 'end', 'tryton-cancel'), + Button('Ok', 'accept', 'tryton-ok', default=True), + ]) + accept = StateTransition() + + def transition_accept(self): + pool = Pool() + OrderPoint = pool.get('stock.order_point') + Product = pool.get('product.product') + order_points = [] + type = self.start.type + company = self.start.company + warehouse_location = self.start.warehouse_location + min_quantity = self.start.min_quantity + target_quantity = self.start.target_quantity + products = Product.search([('categories', 'in', [self.start.category])]) + print(products) + for product in products: + order_points.append({ + 'type': type, + 'company': company, + 'warehouse_location': warehouse_location.id, + 'product': product.id, + 'min_quantity': min_quantity, + 'target_quantity': target_quantity, + }) + OrderPoint.create(order_points) + return 'end' diff --git a/stock.xml b/stock.xml index a2f9a41..2f3e92b 100755 --- a/stock.xml +++ b/stock.xml @@ -164,6 +164,18 @@ this repository contains the full copyright notices and license terms. --> ods False --> + + stock_co.create_order_point.start + form + create_order_point_start_form + + + Create Order Point + stock_co.create_order_point + + diff --git a/view/create_order_point_start_form.xml b/view/create_order_point_start_form.xml new file mode 100644 index 0000000..569bbec --- /dev/null +++ b/view/create_order_point_start_form.xml @@ -0,0 +1,27 @@ + + +
+