mirror of
https://bitbucket.org/presik/trytonpsk-stock_co.git
synced 2023-12-14 05:43:05 +01:00
add new wizard
This commit is contained in:
parent
82468fdcd8
commit
60f8451307
5 changed files with 255 additions and 29 deletions
|
@ -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,
|
||||
|
|
106
locale/es.po
106
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"
|
||||
|
|
137
stock.py
137
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'
|
||||
|
|
12
stock.xml
12
stock.xml
|
@ -164,6 +164,18 @@ this repository contains the full copyright notices and license terms. -->
|
|||
<field name="template_extension">ods</field>
|
||||
<field name="translatable">False</field>
|
||||
</record> -->
|
||||
<record model="ir.ui.view" id="create_order_point_start_view_form">
|
||||
<field name="model">stock_co.create_order_point.start</field>
|
||||
<field name="type">form</field>
|
||||
<field name="name">create_order_point_start_form</field>
|
||||
</record>
|
||||
<record model="ir.action.wizard" id="wizard_create_order_point">
|
||||
<field name="name">Create Order Point</field>
|
||||
<field name="wiz_name">stock_co.create_order_point</field>
|
||||
</record>
|
||||
|
||||
<menuitem name="Create Order Point" sequence="90" parent="stock.menu_stock"
|
||||
id="menu_wizard_create_order_point"
|
||||
action="wizard_create_order_point"/>
|
||||
</data>
|
||||
</tryton>
|
||||
|
|
27
view/create_order_point_start_form.xml
Normal file
27
view/create_order_point_start_form.xml
Normal file
|
@ -0,0 +1,27 @@
|
|||
<?xml version="1.0"?>
|
||||
<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||
this repository contains the full copyright notices and license terms. -->
|
||||
<form col="4">
|
||||
<label name="type"/>
|
||||
<field name="type"/>
|
||||
<label name="company"/>
|
||||
<field name="company"/>
|
||||
<label name="warehouse_location"/>
|
||||
<field name="warehouse_location"/>
|
||||
<label name="storage_location"/>
|
||||
<field name="storage_location"/>
|
||||
<label name="provisioning_location"/>
|
||||
<field name="provisioning_location"/>
|
||||
<label name="overflowing_location"/>
|
||||
<field name="overflowing_location"/>
|
||||
<newline/>
|
||||
<label name="category"/>
|
||||
<field name="category" colspan="3"/>
|
||||
|
||||
<label name="min_quantity"/>
|
||||
<field name="min_quantity" symbol="unit"/>
|
||||
<label name="target_quantity"/>
|
||||
<field name="target_quantity" symbol="unit"/>
|
||||
<label name="max_quantity"/>
|
||||
<field name="max_quantity" symbol="unit"/>
|
||||
</form>
|
Loading…
Reference in a new issue