mirror of
https://github.com/NaN-tic/trytond-systemlogics_modula.git
synced 2023-12-14 04:32:53 +01:00
Upgrade from last changes in 3.8 branch
This commit is contained in:
parent
e849db551b
commit
38ba6d60f9
|
@ -6,21 +6,27 @@ from . import systemlogics
|
||||||
from . import location
|
from . import location
|
||||||
from . import product
|
from . import product
|
||||||
from . import stock
|
from . import stock
|
||||||
|
from . import configuration
|
||||||
|
|
||||||
def register():
|
def register():
|
||||||
Pool.register(
|
Pool.register(
|
||||||
systemlogics.SystemLogicsModula,
|
systemlogics.SystemLogicsModula,
|
||||||
systemlogics.SystemLogicsModulaEXPOrdiniFile,
|
systemlogics.SystemLogicsModulaEXPOrdiniFile,
|
||||||
|
systemlogics.SystemLogicsModulaImportEXPOrdiniFileStart,
|
||||||
location.Location,
|
location.Location,
|
||||||
product.Product,
|
product.Product,
|
||||||
stock.ShipmentIn,
|
stock.ShipmentIn,
|
||||||
stock.ShipmentOut,
|
stock.ShipmentOut,
|
||||||
stock.ShipmentOutReturn,
|
stock.ShipmentOutReturn,
|
||||||
stock.ShipmentOutSystemlogicsModulaExportStart,
|
stock.ShipmentOutSystemlogicsModulaExportStart,
|
||||||
|
stock.ShipmentOutSystemlogicsModulaCheckStart,
|
||||||
stock.ShipmentInternal,
|
stock.ShipmentInternal,
|
||||||
product.SystemlogicsModulaArticoliResult,
|
product.SystemlogicsModulaArticoliResult,
|
||||||
|
configuration.Configuration,
|
||||||
module='systemlogics_modula', type_='model')
|
module='systemlogics_modula', type_='model')
|
||||||
Pool.register(
|
Pool.register(
|
||||||
|
systemlogics.SystemLogicsModulaImportEXPOrdiniFile,
|
||||||
stock.ShipmentOutSystemlogicsModulaExport,
|
stock.ShipmentOutSystemlogicsModulaExport,
|
||||||
|
stock.ShipmentOutSystemlogicsModulaCheck,
|
||||||
product.SystemlogicsModulaArticoli,
|
product.SystemlogicsModulaArticoli,
|
||||||
module='systemlogics_modula', type_='wizard')
|
module='systemlogics_modula', type_='wizard')
|
||||||
|
|
26
configuration.py
Normal file
26
configuration.py
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
# The COPYRIGHT file at the top level of this repository contains the full
|
||||||
|
# copyright notices and license terms.
|
||||||
|
from trytond.model import fields
|
||||||
|
from trytond.pool import PoolMeta
|
||||||
|
|
||||||
|
__all__ = ['Configuration']
|
||||||
|
|
||||||
|
|
||||||
|
class Configuration(metaclass=PoolMeta):
|
||||||
|
__name__ = 'stock.configuration'
|
||||||
|
|
||||||
|
try_generate_systemlogics_modula = fields.Boolean(
|
||||||
|
'Try Generate SystemLogic Modula',
|
||||||
|
help="Try generate SystemLogic Modula files")
|
||||||
|
slice_systemlogics_modula = fields.Integer(
|
||||||
|
'Cron Slice SystemLogics Modula',
|
||||||
|
help=("Number of blocs of shipments to generate the systemlogics "
|
||||||
|
"modula file. If 0 or null it will be all."))
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def default_try_generate_systemlogics_modula():
|
||||||
|
return True
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def default_slice_systemlogics_modula():
|
||||||
|
return 100
|
13
configuration.xml
Normal file
13
configuration.xml
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
<?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. -->
|
||||||
|
<tryton>
|
||||||
|
<data>
|
||||||
|
<record model="ir.ui.view" id="stock_configuration_view_form">
|
||||||
|
<field name="model">stock.configuration</field>
|
||||||
|
<field name="inherit"
|
||||||
|
ref="stock.stock_configuration_view_form"/>
|
||||||
|
<field name="name">configuration_form</field>
|
||||||
|
</record>
|
||||||
|
</data>
|
||||||
|
</tryton>
|
|
@ -162,6 +162,10 @@ msgctxt "model:ir.action,name:wizard_shipment_out_export"
|
||||||
msgid "Export Systemlogics Modula"
|
msgid "Export Systemlogics Modula"
|
||||||
msgstr "Exporta Systemlogics Modula"
|
msgstr "Exporta Systemlogics Modula"
|
||||||
|
|
||||||
|
msgctxt "model:ir.action,name:wizard_shipment_out_check"
|
||||||
|
msgid "Check Systemlogics Modula"
|
||||||
|
msgstr "Comprovar Systemlogics Modula"
|
||||||
|
|
||||||
msgctxt "model:ir.action,name:wizard_systemlogics_modula_articoli"
|
msgctxt "model:ir.action,name:wizard_systemlogics_modula_articoli"
|
||||||
msgid "Export Products Modula"
|
msgid "Export Products Modula"
|
||||||
msgstr "Exporta productes Modula"
|
msgstr "Exporta productes Modula"
|
||||||
|
@ -262,6 +266,10 @@ msgctxt "view:stock.shipment.out.systemlogics.modula.export.start:"
|
||||||
msgid "Export Shipments Out to Modula"
|
msgid "Export Shipments Out to Modula"
|
||||||
msgstr "Exporta albarans client a Modula"
|
msgstr "Exporta albarans client a Modula"
|
||||||
|
|
||||||
|
msgctxt "view:stock.shipment.out.systemlogics.modula.check.start:"
|
||||||
|
msgid "Check Shipments Out to Modula"
|
||||||
|
msgstr "Comprovar albarans client a Modula"
|
||||||
|
|
||||||
msgctxt "view:systemlogics.modula.articoli.result:"
|
msgctxt "view:systemlogics.modula.articoli.result:"
|
||||||
msgid "Export Product XML Modula"
|
msgid "Export Product XML Modula"
|
||||||
msgstr "Exportar XML productes Modula"
|
msgstr "Exportar XML productes Modula"
|
||||||
|
@ -288,6 +296,11 @@ msgctxt ""
|
||||||
msgid "Export"
|
msgid "Export"
|
||||||
msgstr "Exporta"
|
msgstr "Exporta"
|
||||||
|
|
||||||
|
msgctxt ""
|
||||||
|
"wizard_button:stock.shipment.out.systemlogics.modula.check,start,check:"
|
||||||
|
msgid "Check"
|
||||||
|
msgstr "Comprova"
|
||||||
|
|
||||||
msgctxt "wizard_button:systemlogics.modula.articoli,result,end:"
|
msgctxt "wizard_button:systemlogics.modula.articoli,result,end:"
|
||||||
msgid "Close"
|
msgid "Close"
|
||||||
msgstr "Tanca"
|
msgstr "Tanca"
|
|
@ -162,6 +162,10 @@ msgctxt "model:ir.action,name:wizard_shipment_out_export"
|
||||||
msgid "Export Systemlogics Modula"
|
msgid "Export Systemlogics Modula"
|
||||||
msgstr "Exportar Systemlogics Modula"
|
msgstr "Exportar Systemlogics Modula"
|
||||||
|
|
||||||
|
msgctxt "model:ir.action,name:wizard_shipment_out_check"
|
||||||
|
msgid "Check Systemlogics Modula"
|
||||||
|
msgstr "Comprobar Systemlogics Modula"
|
||||||
|
|
||||||
msgctxt "model:ir.action,name:wizard_systemlogics_modula_articoli"
|
msgctxt "model:ir.action,name:wizard_systemlogics_modula_articoli"
|
||||||
msgid "Export Products Modula"
|
msgid "Export Products Modula"
|
||||||
msgstr "Exportar productos Modula"
|
msgstr "Exportar productos Modula"
|
||||||
|
@ -262,6 +266,10 @@ msgctxt "view:stock.shipment.out.systemlogics.modula.export.start:"
|
||||||
msgid "Export Shipments Out to Modula"
|
msgid "Export Shipments Out to Modula"
|
||||||
msgstr "Exportar albaranes cliente a Modula"
|
msgstr "Exportar albaranes cliente a Modula"
|
||||||
|
|
||||||
|
msgctxt "view:stock.shipment.out.systemlogics.modula.check.start:"
|
||||||
|
msgid "Check Shipments Out to Modula"
|
||||||
|
msgstr "Comprobar albaranes cliente a Modula"
|
||||||
|
|
||||||
msgctxt "view:systemlogics.modula.articoli.result:"
|
msgctxt "view:systemlogics.modula.articoli.result:"
|
||||||
msgid "Export Product XML Modula"
|
msgid "Export Product XML Modula"
|
||||||
msgstr "Exportar productos XML Modula"
|
msgstr "Exportar productos XML Modula"
|
||||||
|
@ -288,6 +296,11 @@ msgctxt ""
|
||||||
msgid "Export"
|
msgid "Export"
|
||||||
msgstr "Exportar"
|
msgstr "Exportar"
|
||||||
|
|
||||||
|
msgctxt ""
|
||||||
|
"wizard_button:stock.shipment.out.systemlogics.modula.check,start,check:"
|
||||||
|
msgid "Check"
|
||||||
|
msgstr "Comprobar"
|
||||||
|
|
||||||
msgctxt "wizard_button:systemlogics.modula.articoli,result,end:"
|
msgctxt "wizard_button:systemlogics.modula.articoli,result,end:"
|
||||||
msgid "Close"
|
msgid "Close"
|
||||||
msgstr "Cerrar"
|
msgstr "Cerrar"
|
85
shipment.xml
85
shipment.xml
|
@ -39,5 +39,90 @@ The COPYRIGHT file at the top level of this repository contains the full copyrig
|
||||||
<field name="action" ref="wizard_shipment_out_export"/>
|
<field name="action" ref="wizard_shipment_out_export"/>
|
||||||
<field name="group" ref="group_systemlogics_modula"/>
|
<field name="group" ref="group_systemlogics_modula"/>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
|
<!-- stock.shipment.out check wizard -->
|
||||||
|
<record model="ir.ui.view" id="shipment_out_check_form">
|
||||||
|
<field name="model">stock.shipment.out.systemlogics.modula.check.start</field>
|
||||||
|
<field name="type">form</field>
|
||||||
|
<field name="name">shipment_out_check_form</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<record model="ir.action.wizard" id="wizard_shipment_out_check">
|
||||||
|
<field name="name">Check Systemlogics Modula</field>
|
||||||
|
<field name="wiz_name">stock.shipment.out.systemlogics.modula.check</field>
|
||||||
|
<field name="model">stock.shipment.out</field>
|
||||||
|
</record>
|
||||||
|
<record model="ir.action.keyword" id="shipment_out_check_keyword">
|
||||||
|
<field name="keyword">form_action</field>
|
||||||
|
<field name="model">stock.shipment.out,-1</field>
|
||||||
|
<field name="action" ref="wizard_shipment_out_check"/>
|
||||||
|
</record>
|
||||||
|
<record model="ir.action-res.group"
|
||||||
|
id="action_group_wizard_shipment_out_check">
|
||||||
|
<field name="action" ref="wizard_shipment_out_check"/>
|
||||||
|
<field name="group" ref="group_systemlogics_modula"/>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<!-- user cron shipment out check systemlogics modula -->
|
||||||
|
<record model="res.user" id="user_stock_check_systemlogics_modula">
|
||||||
|
<field name="login">user_stock_check_systemlogics_modula</field>
|
||||||
|
<field name="name">Cron Check SystemLogics Modula</field>
|
||||||
|
<field name="active" eval="False"/>
|
||||||
|
</record>
|
||||||
|
<record model="res.user-res.group" id="user_stock_check_systemlogics_modula_stock_force_assignment_group">
|
||||||
|
<field name="user" ref="user_stock_check_systemlogics_modula"/>
|
||||||
|
<field name="group" ref="stock.group_stock_force_assignment"/>
|
||||||
|
</record>
|
||||||
|
<record model="res.user-res.group" id="user_stock_check_systemlogics_modula_stock_group">
|
||||||
|
<field name="user" ref="user_stock_check_systemlogics_modula"/>
|
||||||
|
<field name="group" ref="stock.group_stock"/>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<record model="ir.cron" id="cron_shipment_out_check_systemlogics_modula">
|
||||||
|
<field name="name">Check SystemLogic Modula for Out Shipments</field>
|
||||||
|
<field name="request_user" ref="res.user_admin"/>
|
||||||
|
<field name="user" ref="user_stock_check_systemlogics_modula"/>
|
||||||
|
<field name="active" eval="True"/>
|
||||||
|
<field name="interval_number" eval="5"/>
|
||||||
|
<field name="interval_type">minutes</field>
|
||||||
|
<field name="number_calls" eval="-1"/>
|
||||||
|
<field name="repeat_missed" eval="False"/>
|
||||||
|
<field name="model">stock.shipment.out</field>
|
||||||
|
<field name="function">check_systemlogics_modula_scheduler</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<!-- user cron shipment out generate systemlogics modula -->
|
||||||
|
<record model="res.user" id="user_stock_generate_systemlogics_modula">
|
||||||
|
<field name="login">user_stock_generate_systemlogics_modula</field>
|
||||||
|
<field name="name">Cron Generate SystemLogics Modula</field>
|
||||||
|
<field name="active" eval="False"/>
|
||||||
|
</record>
|
||||||
|
<record model="res.user-res.group" id="user_stock_generate_systemlogics_modula_stock_force_assignment_group">
|
||||||
|
<field name="user" ref="user_stock_generate_systemlogics_modula"/>
|
||||||
|
<field name="group" ref="stock.group_stock_force_assignment"/>
|
||||||
|
</record>
|
||||||
|
<record model="res.user-res.group" id="user_stock_generate_systemlogics_modula_stock_group">
|
||||||
|
<field name="user" ref="user_stock_generate_systemlogics_modula"/>
|
||||||
|
<field name="group" ref="stock.group_stock"/>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<record model="ir.cron" id="cron_shipment_out_generate_systemlogics_modula">
|
||||||
|
<field name="name">Generate SystemLogic Modula for Out Shipments</field>
|
||||||
|
<field name="request_user" ref="res.user_admin"/>
|
||||||
|
<field name="user" ref="user_stock_generate_systemlogics_modula"/>
|
||||||
|
<field name="active" eval="True"/>
|
||||||
|
<field name="interval_number" eval="1"/>
|
||||||
|
<field name="interval_type">hours</field>
|
||||||
|
<field name="number_calls" eval="-1"/>
|
||||||
|
<field name="repeat_missed" eval="False"/>
|
||||||
|
<field name="model">stock.shipment.out</field>
|
||||||
|
<field name="function">generate_systemlogics_modula_scheduler</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<record model="ir.ui.view" id="shipment_out_view_tree">
|
||||||
|
<field name="model">stock.shipment.out</field>
|
||||||
|
<field name="inherit" ref="stock.shipment_out_view_tree"/>
|
||||||
|
<field name="name">shipment_out_tree</field>
|
||||||
|
</record>
|
||||||
</data>
|
</data>
|
||||||
</tryton>
|
</tryton>
|
||||||
|
|
281
stock.py
281
stock.py
|
@ -6,9 +6,14 @@ from trytond.model import ModelView, fields
|
||||||
from trytond.transaction import Transaction
|
from trytond.transaction import Transaction
|
||||||
from trytond.pyson import Eval
|
from trytond.pyson import Eval
|
||||||
from trytond.wizard import Wizard, StateView, Button, StateTransition
|
from trytond.wizard import Wizard, StateView, Button, StateTransition
|
||||||
|
from trytond.tools import grouped_slice
|
||||||
|
import logging
|
||||||
|
|
||||||
__all__ = ['ShipmentIn', 'ShipmentOut', 'ShipmentOutReturn', 'ShipmentInternal',
|
__all__ = ['ShipmentIn', 'ShipmentOut', 'ShipmentOutReturn', 'ShipmentInternal',
|
||||||
'ShipmentOutSystemlogicsModulaExportStart', 'ShipmentOutSystemlogicsModulaExport']
|
'ShipmentOutSystemlogicsModulaExportStart', 'ShipmentOutSystemlogicsModulaExport',
|
||||||
|
'ShipmentOutSystemlogicsModulaCheckStart', 'ShipmentOutSystemlogicsModulaCheck']
|
||||||
|
|
||||||
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class ShipmentIn(metaclass=PoolMeta):
|
class ShipmentIn(metaclass=PoolMeta):
|
||||||
|
@ -75,59 +80,43 @@ class ShipmentOut(metaclass=PoolMeta):
|
||||||
systemlogics_modula = fields.Boolean('SystemLogics Modula')
|
systemlogics_modula = fields.Boolean('SystemLogics Modula')
|
||||||
systemlogics_modula_completed = fields.Boolean(
|
systemlogics_modula_completed = fields.Boolean(
|
||||||
'SystemLogics Modula Completed')
|
'SystemLogics Modula Completed')
|
||||||
|
systemlogics_modula_sended = fields.Boolean('SystemLogics Modula Sended')
|
||||||
|
ship_create_date = fields.Function(fields.DateTime('Create Date'),
|
||||||
|
'get_ship_create_date')
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def default_systemlogics_modula():
|
def default_systemlogics_modula():
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def default_systemlogics_modula_completed():
|
||||||
|
return False
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def default_systemlogics_modula_sended():
|
||||||
|
return False
|
||||||
|
|
||||||
|
def get_ship_create_date(self, name):
|
||||||
|
return self.create_date
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def copy(cls, shipments, default=None):
|
def copy(cls, shipments, default=None):
|
||||||
if default is None:
|
if default is None:
|
||||||
default = {}
|
default = {}
|
||||||
default = default.copy()
|
default = default.copy()
|
||||||
default['systemlogics_modula'] = None
|
default['systemlogics_modula'] = False
|
||||||
default['systemlogics_modula_completed'] = None
|
default['systemlogics_modula_completed'] = False
|
||||||
|
default['systemlogics_modula_sended'] = False
|
||||||
return super(ShipmentOut, cls).copy(shipments, default=default)
|
return super(ShipmentOut, cls).copy(shipments, default=default)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def generate_systemlogics_modula(cls, shipments):
|
def generate_systemlogics_modula_file(cls, shipments):
|
||||||
'''Active System Logics process when a move from location is systemlogics marked'''
|
|
||||||
SystemLogicsModula = Pool().get('systemlogics.modula')
|
SystemLogicsModula = Pool().get('systemlogics.modula')
|
||||||
|
|
||||||
s_completed = [] # shipments completed
|
|
||||||
s_incompleted = [] # shipments incompleted
|
|
||||||
for s in shipments:
|
|
||||||
if hasattr(s, 'review'):
|
|
||||||
if s.review:
|
|
||||||
continue
|
|
||||||
systemLogics = False
|
|
||||||
completed = True
|
|
||||||
for move in s.inventory_moves:
|
|
||||||
if move.from_location.systemlogics_modula:
|
|
||||||
systemLogics = True
|
|
||||||
else:
|
|
||||||
completed = False
|
|
||||||
if systemLogics:
|
|
||||||
if completed:
|
|
||||||
s_completed.append(s)
|
|
||||||
else:
|
|
||||||
s_incompleted.append(s)
|
|
||||||
|
|
||||||
if s_completed or s_incompleted:
|
|
||||||
if s_completed:
|
|
||||||
cls.write(s_completed, {
|
|
||||||
'systemlogics_modula': True,
|
|
||||||
'systemlogics_modula_completed': True,
|
|
||||||
})
|
|
||||||
if s_incompleted:
|
|
||||||
cls.write(s_incompleted, {
|
|
||||||
'systemlogics_modula': True,
|
|
||||||
'systemlogics_modula_completed': False,
|
|
||||||
})
|
|
||||||
|
|
||||||
# Force not get a rollback to generate XML file
|
# Force not get a rollback to generate XML file
|
||||||
shipment_ids = [s.id for s in (s_completed + s_incompleted)]
|
shipment_ids = [s.id for s in shipments]
|
||||||
Transaction().commit()
|
Transaction().commit()
|
||||||
|
|
||||||
# Search shipment ID to sure not have a rollback
|
# Search shipment ID to sure not have a rollback
|
||||||
shipments = cls.search([
|
shipments = cls.search([
|
||||||
('id', 'in', shipment_ids),
|
('id', 'in', shipment_ids),
|
||||||
|
@ -135,12 +124,149 @@ class ShipmentOut(metaclass=PoolMeta):
|
||||||
SystemLogicsModula.imp_ordini(
|
SystemLogicsModula.imp_ordini(
|
||||||
shipments, template='IMP_ORDINI_OUT', type_='P')
|
shipments, template='IMP_ORDINI_OUT', type_='P')
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def check_systemlogics_modula(cls, shipments):
|
||||||
|
pool = Pool()
|
||||||
|
Configuration = pool.get('stock.configuration')
|
||||||
|
|
||||||
|
config = Configuration(1)
|
||||||
|
if not (Transaction().context.get('generate_systemlogics_modula',
|
||||||
|
config.try_generate_systemlogics_modula)):
|
||||||
|
return
|
||||||
|
|
||||||
|
to_write = []
|
||||||
|
values = {
|
||||||
|
'systemlogics_modula': True
|
||||||
|
}
|
||||||
|
for shipment in shipments:
|
||||||
|
if hasattr(shipment, 'review'):
|
||||||
|
if shipment.review:
|
||||||
|
continue
|
||||||
|
systemLogics = False
|
||||||
|
completed = True
|
||||||
|
for move in shipment.inventory_moves:
|
||||||
|
if move.from_location.systemlogics_modula:
|
||||||
|
systemLogics = True
|
||||||
|
else:
|
||||||
|
completed = False
|
||||||
|
if systemLogics:
|
||||||
|
values = values.copy()
|
||||||
|
if completed:
|
||||||
|
values['systemlogics_modula_completed'] = True
|
||||||
|
else:
|
||||||
|
values['systemlogics_modula_completed'] = False
|
||||||
|
to_write.extend(([shipment], values))
|
||||||
|
if to_write:
|
||||||
|
cls.write(*to_write)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def generate_systemlogics_modula(cls, shipments):
|
||||||
|
'''Generate SystemLogics Modula'''
|
||||||
|
Configuration = Pool().get('stock.configuration')
|
||||||
|
|
||||||
|
config = Configuration(1)
|
||||||
|
if not (Transaction().context.get('generate_systemlogics_modula',
|
||||||
|
config.try_generate_systemlogics_modula)):
|
||||||
|
return
|
||||||
|
|
||||||
|
to_write = []
|
||||||
|
shipments_modula = []
|
||||||
|
value = {
|
||||||
|
'systemlogics_modula_sended': True
|
||||||
|
}
|
||||||
|
for shipment in shipments:
|
||||||
|
if hasattr(shipment, 'review'):
|
||||||
|
if shipment.review:
|
||||||
|
continue
|
||||||
|
shipments_modula.append(shipment)
|
||||||
|
to_write.extend(([shipment], value))
|
||||||
|
|
||||||
|
if shipments_modula:
|
||||||
|
cls.write(*to_write)
|
||||||
|
cls.generate_systemlogics_modula_file(shipments_modula)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def assign(cls, shipments):
|
def assign(cls, shipments):
|
||||||
super(ShipmentOut, cls).assign(shipments)
|
super(ShipmentOut, cls).assign(shipments)
|
||||||
# control generate systemlogics module with context
|
assigned = [s for s in shipments if s.state == 'assigned']
|
||||||
if Transaction().context.get('generate_systemlogics_modula', True):
|
cls.check_systemlogics_modula(assigned)
|
||||||
cls.generate_systemlogics_modula(shipments)
|
cls.generate_systemlogics_modula(assigned)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def check_systemlogics_modula_scheduler(cls, args=None):
|
||||||
|
'''
|
||||||
|
This method is intended to be called from ir.cron
|
||||||
|
args: warehouse ids [ids]
|
||||||
|
'''
|
||||||
|
pool = Pool()
|
||||||
|
Configuration = pool.get('stock.configuration')
|
||||||
|
config = Configuration(1)
|
||||||
|
|
||||||
|
domain = [
|
||||||
|
('state', '=', 'assigned'),
|
||||||
|
]
|
||||||
|
if args:
|
||||||
|
domain.append(
|
||||||
|
('warehouse', 'in', args),
|
||||||
|
)
|
||||||
|
shipments = cls.search(domain)
|
||||||
|
|
||||||
|
len_ships = len(shipments)
|
||||||
|
logger.info(
|
||||||
|
'Scheduler Try Check Systemlogics Modula. Total: %s' % (
|
||||||
|
len_ships))
|
||||||
|
if len_ships:
|
||||||
|
blocs = 1
|
||||||
|
slice_systemlogics_modula = (config.slice_systemlogics_modula or
|
||||||
|
len_ships)
|
||||||
|
with Transaction().set_context(generate_systemlogics_modula=True):
|
||||||
|
for sub_shipments in grouped_slice(shipments,
|
||||||
|
slice_systemlogics_modula):
|
||||||
|
logger.info('Start bloc %s of %s.' % (
|
||||||
|
blocs, len_ships/slice_systemlogics_modula))
|
||||||
|
cls.check_systemlogics_modula(list(sub_shipments))
|
||||||
|
logger.info('End bloc %s.' % blocs)
|
||||||
|
blocs += 1
|
||||||
|
logger.info('End Scheduler Try Check Systemlogics Modula.')
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def generate_systemlogics_modula_scheduler(cls, args=None):
|
||||||
|
'''
|
||||||
|
This method is intended to be called from ir.cron
|
||||||
|
args: warehouse ids [ids]
|
||||||
|
'''
|
||||||
|
pool = Pool()
|
||||||
|
Configuration = pool.get('stock.configuration')
|
||||||
|
config = Configuration(1)
|
||||||
|
|
||||||
|
domain = [
|
||||||
|
('state', '=', 'assigned'),
|
||||||
|
('systemlogics_modula', '=', True),
|
||||||
|
('systemlogics_modula_sended', '=', False),
|
||||||
|
]
|
||||||
|
if args:
|
||||||
|
domain.append(
|
||||||
|
('warehouse', 'in', args),
|
||||||
|
)
|
||||||
|
shipments = cls.search(domain)
|
||||||
|
|
||||||
|
len_ships = len(shipments)
|
||||||
|
logger.info(
|
||||||
|
'Scheduler Try generate Systemlogics Modula. Total: %s' % (
|
||||||
|
len_ships))
|
||||||
|
if len_ships:
|
||||||
|
blocs = 1
|
||||||
|
slice_systemlogics_modula = (config.slice_systemlogics_modula or
|
||||||
|
len_ships)
|
||||||
|
with Transaction().set_context(generate_systemlogics_modula=True):
|
||||||
|
for sub_shipments in grouped_slice(shipments,
|
||||||
|
slice_systemlogics_modula):
|
||||||
|
logger.info('Start bloc %s of %s.' % (
|
||||||
|
blocs, len_ships/slice_systemlogics_modula))
|
||||||
|
cls.generate_systemlogics_modula(list(sub_shipments))
|
||||||
|
logger.info('End bloc %s.' % blocs)
|
||||||
|
blocs += 1
|
||||||
|
logger.info('End Scheduler Try generate Systemlogics Modula.')
|
||||||
|
|
||||||
|
|
||||||
class ShipmentOutReturn(metaclass=PoolMeta):
|
class ShipmentOutReturn(metaclass=PoolMeta):
|
||||||
|
@ -245,7 +371,7 @@ class ShipmentInternal(metaclass=PoolMeta):
|
||||||
('id', 'in', extract_shipments_ids),
|
('id', 'in', extract_shipments_ids),
|
||||||
])
|
])
|
||||||
SystemLogicsModula.imp_ordini(
|
SystemLogicsModula.imp_ordini(
|
||||||
ext_shipments, template='IMP_ORDINI_IN', type_='P')
|
ext_shipments, template='IMP_ORDINI_INTERNAL', type_='P')
|
||||||
if deposit_shipments_ids:
|
if deposit_shipments_ids:
|
||||||
# Search shipment ID to sure not have a rollback
|
# Search shipment ID to sure not have a rollback
|
||||||
dep_shipments = cls.search([
|
dep_shipments = cls.search([
|
||||||
|
@ -264,23 +390,25 @@ class ShipmentOutSystemlogicsModulaExportStart(ModelView):
|
||||||
'Customer shipments export Systemlogics Modula Start'
|
'Customer shipments export Systemlogics Modula Start'
|
||||||
__name__ = 'stock.shipment.out.systemlogics.modula.export.start'
|
__name__ = 'stock.shipment.out.systemlogics.modula.export.start'
|
||||||
shipments = fields.Many2Many('stock.shipment.out', None, None, 'Shipments',
|
shipments = fields.Many2Many('stock.shipment.out', None, None, 'Shipments',
|
||||||
domain=[
|
required=True, domain=[
|
||||||
('state', 'in', ['assigned']),
|
('state', '=', 'assigned'),
|
||||||
|
('systemlogics_modula', '=', True),
|
||||||
|
('systemlogics_modula_sended', '=', False),
|
||||||
],
|
],
|
||||||
states={
|
|
||||||
'required': True,
|
|
||||||
},
|
|
||||||
help='Assigned customer shipments to export Systemlogics Modula.')
|
help='Assigned customer shipments to export Systemlogics Modula.')
|
||||||
|
|
||||||
@staticmethod
|
@classmethod
|
||||||
def default_shipments():
|
def default_shipments(cls):
|
||||||
ShipmentOut = Pool().get('stock.shipment.out')
|
ShipmentOut = Pool().get('stock.shipment.out')
|
||||||
|
|
||||||
active_ids = Transaction().context.get('active_ids', [])
|
active_ids = Transaction().context.get('active_ids', [])
|
||||||
shipments = ShipmentOut.search([
|
domain = []
|
||||||
('id', 'in', active_ids),
|
domain.extend(cls.shipments.domain)
|
||||||
('state', 'in', ['assigned']),
|
if active_ids:
|
||||||
])
|
domain.append(
|
||||||
|
('id', 'in', active_ids)
|
||||||
|
)
|
||||||
|
shipments = ShipmentOut.search(domain)
|
||||||
return [s.id for s in shipments]
|
return [s.id for s in shipments]
|
||||||
|
|
||||||
|
|
||||||
|
@ -298,7 +426,54 @@ class ShipmentOutSystemlogicsModulaExport(Wizard):
|
||||||
def transition_export(self):
|
def transition_export(self):
|
||||||
ShipmentOut = Pool().get('stock.shipment.out')
|
ShipmentOut = Pool().get('stock.shipment.out')
|
||||||
|
|
||||||
shipments = self.start.shipments
|
shipments = list(self.start.shipments)
|
||||||
if shipments:
|
if shipments:
|
||||||
|
with Transaction().set_context(generate_systemlogics_modula=True):
|
||||||
ShipmentOut.generate_systemlogics_modula(shipments)
|
ShipmentOut.generate_systemlogics_modula(shipments)
|
||||||
return 'end'
|
return 'end'
|
||||||
|
|
||||||
|
|
||||||
|
class ShipmentOutSystemlogicsModulaCheckStart(ModelView):
|
||||||
|
'Customer shipments check Systemlogics Modula Start'
|
||||||
|
__name__ = 'stock.shipment.out.systemlogics.modula.check.start'
|
||||||
|
shipments = fields.Many2Many('stock.shipment.out', None, None, 'Shipments',
|
||||||
|
required=True, domain=[
|
||||||
|
('state', '=', 'assigned'),
|
||||||
|
],
|
||||||
|
help='Assigned customer shipments to check Systemlogics Modula.')
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def default_shipments():
|
||||||
|
ShipmentOut = Pool().get('stock.shipment.out')
|
||||||
|
|
||||||
|
active_ids = Transaction().context.get('active_ids', [])
|
||||||
|
domain = [
|
||||||
|
('state', '=', 'assigned'),
|
||||||
|
]
|
||||||
|
if active_ids:
|
||||||
|
domain.append(
|
||||||
|
('id', 'in', active_ids)
|
||||||
|
)
|
||||||
|
shipments = ShipmentOut.search(domain)
|
||||||
|
return [s.id for s in shipments]
|
||||||
|
|
||||||
|
|
||||||
|
class ShipmentOutSystemlogicsModulaCheck(Wizard):
|
||||||
|
'Customer shipments check Systemlogics Modula'
|
||||||
|
__name__ = 'stock.shipment.out.systemlogics.modula.check'
|
||||||
|
|
||||||
|
start = StateView('stock.shipment.out.systemlogics.modula.check.start',
|
||||||
|
'systemlogics_modula.shipment_out_check_form', [
|
||||||
|
Button('Cancel', 'end', 'tryton-cancel'),
|
||||||
|
Button('Check', 'check', 'tryton-ok', True),
|
||||||
|
])
|
||||||
|
check = StateTransition()
|
||||||
|
|
||||||
|
def transition_check(self):
|
||||||
|
ShipmentOut = Pool().get('stock.shipment.out')
|
||||||
|
|
||||||
|
shipments = list(self.start.shipments)
|
||||||
|
if shipments:
|
||||||
|
with Transaction().set_context(generate_systemlogics_modula=True):
|
||||||
|
ShipmentOut.check_systemlogics_modula(shipments)
|
||||||
|
return 'end'
|
||||||
|
|
|
@ -2,7 +2,8 @@
|
||||||
#The COPYRIGHT file at the top level of this repository contains
|
#The COPYRIGHT file at the top level of this repository contains
|
||||||
#the full copyright notices and license terms.
|
#the full copyright notices and license terms.
|
||||||
from trytond.pool import Pool
|
from trytond.pool import Pool
|
||||||
from trytond.model import ModelView, ModelSQL, fields
|
from trytond.model import ModelView, ModelSQL, fields, Unique
|
||||||
|
from trytond.wizard import Wizard, StateTransition, StateView, Button
|
||||||
from trytond.pyson import Eval
|
from trytond.pyson import Eval
|
||||||
from trytond.transaction import Transaction
|
from trytond.transaction import Transaction
|
||||||
from trytond.rpc import RPC
|
from trytond.rpc import RPC
|
||||||
|
@ -16,7 +17,9 @@ import logging
|
||||||
import datetime
|
import datetime
|
||||||
import tempfile
|
import tempfile
|
||||||
|
|
||||||
__all__ = ['SystemLogicsModula', 'SystemLogicsModulaEXPOrdiniFile']
|
__all__ = ['SystemLogicsModula', 'SystemLogicsModulaEXPOrdiniFile',
|
||||||
|
'SystemLogicsModulaImportEXPOrdiniFile',
|
||||||
|
'SystemLogicsModulaImportEXPOrdiniFileStart']
|
||||||
|
|
||||||
loader = genshi.template.TemplateLoader(
|
loader = genshi.template.TemplateLoader(
|
||||||
os.path.join(os.path.dirname(__file__), 'template'),
|
os.path.join(os.path.dirname(__file__), 'template'),
|
||||||
|
@ -224,31 +227,25 @@ class SystemLogicsModula(ModelSQL, ModelView):
|
||||||
EXPOrdiniFile = Pool().get('systemlogics.modula.exp.ordini.file')
|
EXPOrdiniFile = Pool().get('systemlogics.modula.exp.ordini.file')
|
||||||
|
|
||||||
logger.info('Start read SystemLogics Module files')
|
logger.info('Start read SystemLogics Module files')
|
||||||
|
|
||||||
modulas = cls.search([
|
|
||||||
('name', '=', 'EXP_ORDINI'),
|
|
||||||
])
|
|
||||||
|
|
||||||
vlist = []
|
vlist = []
|
||||||
to_delete = []
|
to_process = []
|
||||||
for modula in modulas:
|
for modula in cls.search([('name', '=', 'EXP_ORDINI')]):
|
||||||
try:
|
try:
|
||||||
filenames = os.listdir(modula.path)
|
filenames = os.listdir(modula.path)
|
||||||
except OSError:
|
except OSError as e:
|
||||||
logger.warning('Error reading path: %s' % e)
|
logger.warning('Error reading path: %s' % e)
|
||||||
continue
|
continue
|
||||||
|
exp_ordini_files = [f.name for f in EXPOrdiniFile.search([
|
||||||
|
('name', 'in', filenames)])]
|
||||||
for filename in filenames:
|
for filename in filenames:
|
||||||
fullname = '%s/%s' % (modula.path, filename)
|
fullname = '%s/%s' % (modula.path, filename)
|
||||||
values = {}
|
values = {}
|
||||||
exp_ordini_file = EXPOrdiniFile.search([
|
if filename in exp_ordini_files:
|
||||||
('name', '=', filename)
|
to_process.append(fullname)
|
||||||
])
|
|
||||||
if exp_ordini_file:
|
|
||||||
to_delete.append(fullname)
|
|
||||||
continue
|
continue
|
||||||
try:
|
try:
|
||||||
content = open(fullname, 'r').read()
|
content = open(fullname, 'r').read()
|
||||||
except IOError:
|
except IOError as e:
|
||||||
logger.warning('Error reading file %s: %s' % (fullname, e))
|
logger.warning('Error reading file %s: %s' % (fullname, e))
|
||||||
continue
|
continue
|
||||||
values['name'] = filename
|
values['name'] = filename
|
||||||
|
@ -256,15 +253,18 @@ class SystemLogicsModula(ModelSQL, ModelView):
|
||||||
values['content'] = content
|
values['content'] = content
|
||||||
values['state'] = 'pending'
|
values['state'] = 'pending'
|
||||||
vlist.append(values)
|
vlist.append(values)
|
||||||
to_delete.append(fullname)
|
to_process.append(fullname)
|
||||||
|
|
||||||
ordini_files = EXPOrdiniFile.create(vlist)
|
ordini_files = EXPOrdiniFile.create(vlist)
|
||||||
EXPOrdiniFile.process_export_ordini(ordini_files)
|
EXPOrdiniFile.process_export_ordini(ordini_files)
|
||||||
for filename in to_delete:
|
Transaction().commit()
|
||||||
|
|
||||||
|
for filename in to_process:
|
||||||
try:
|
try:
|
||||||
os.remove(filename)
|
os.remove(filename)
|
||||||
except OSError:
|
except OSError:
|
||||||
pass
|
pass
|
||||||
logger.info('Loaded SystemLogics Module %s files' % (len(to_delete)))
|
logger.info('Loaded SystemLogics Module %s files' % (len(to_process)))
|
||||||
|
|
||||||
|
|
||||||
class SystemLogicsModulaEXPOrdiniFile(ModelSQL, ModelView):
|
class SystemLogicsModulaEXPOrdiniFile(ModelSQL, ModelView):
|
||||||
|
@ -284,8 +284,9 @@ class SystemLogicsModulaEXPOrdiniFile(ModelSQL, ModelView):
|
||||||
@classmethod
|
@classmethod
|
||||||
def __setup__(cls):
|
def __setup__(cls):
|
||||||
super(SystemLogicsModulaEXPOrdiniFile, cls).__setup__()
|
super(SystemLogicsModulaEXPOrdiniFile, cls).__setup__()
|
||||||
cls._sql_constraints += [
|
t = cls.__table__()
|
||||||
('name_uniq', 'UNIQUE(name)', 'Name must be unique.'),
|
cls._sql_constraints = [
|
||||||
|
('name_uniq', Unique(t, t.name), 'Name must be unique.'),
|
||||||
]
|
]
|
||||||
cls._buttons.update({
|
cls._buttons.update({
|
||||||
'process_export_ordini': {
|
'process_export_ordini': {
|
||||||
|
@ -325,20 +326,20 @@ class SystemLogicsModulaEXPOrdiniFile(ModelSQL, ModelView):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
quantities = {}
|
quantities = {}
|
||||||
moves = []
|
move_ids = []
|
||||||
for o in dom.getElementsByTagName('EXP_ORDINI_RIGHE'):
|
for o in dom.getElementsByTagName('EXP_ORDINI_RIGHE'):
|
||||||
move = {}
|
id_ = int(o.getElementsByTagName(
|
||||||
id_ = (o.getElementsByTagName('RIG_HOSTINF')[0]
|
'RIG_HOSTINF')[0].firstChild.data)
|
||||||
.firstChild.data)
|
move_ids.append(id_)
|
||||||
moves.append(id_)
|
|
||||||
quantities[int(id_)] = float(
|
quantities[int(id_)] = float(
|
||||||
o.getElementsByTagName('RIG_QTAE')
|
o.getElementsByTagName('RIG_QTAE')
|
||||||
[0].firstChild.data.replace(',', '.'))
|
[0].firstChild.data.replace(',', '.'))
|
||||||
|
|
||||||
moves = Move.search([
|
for move in Move.search([('id', 'in', move_ids)]):
|
||||||
('id', 'in', moves)
|
# TODO process shipment out and internal
|
||||||
])
|
if (not move.shipment
|
||||||
for move in moves:
|
or move.shipment.__name__ != 'stock.shipment.out'):
|
||||||
|
continue
|
||||||
if (quantities[move.id] == move.quantity
|
if (quantities[move.id] == move.quantity
|
||||||
and move.shipment.state == 'assigned'):
|
and move.shipment.state == 'assigned'):
|
||||||
to_do.append(move)
|
to_do.append(move)
|
||||||
|
@ -368,3 +369,24 @@ class SystemLogicsModulaEXPOrdiniFile(ModelSQL, ModelView):
|
||||||
cls.write(done_ordini_files, {'state': 'done'})
|
cls.write(done_ordini_files, {'state': 'done'})
|
||||||
if fail_ordini_files:
|
if fail_ordini_files:
|
||||||
cls.write(fail_ordini_files, {'state': 'failed'})
|
cls.write(fail_ordini_files, {'state': 'failed'})
|
||||||
|
|
||||||
|
|
||||||
|
class SystemLogicsModulaImportEXPOrdiniFileStart(ModelView):
|
||||||
|
'SystemLogcics Modula Import EXP Ordini File Start'
|
||||||
|
__name__ = 'systemlogics.modula.import.exp.ordini.file.start'
|
||||||
|
|
||||||
|
|
||||||
|
class SystemLogicsModulaImportEXPOrdiniFile(Wizard):
|
||||||
|
'SystemLogics Modula Import EXP Ordini File'
|
||||||
|
__name__ = "systemlogics.modula.import.exp.ordini.file"
|
||||||
|
start = StateView('systemlogics.modula.import.exp.ordini.file.start',
|
||||||
|
'systemlogics_modula.systemlogics_modula_import_exp_ordini_file_start', [
|
||||||
|
Button('Cancel', 'end', 'tryton-cancel'),
|
||||||
|
Button('Import', 'import_', 'tryton-ok', default=True),
|
||||||
|
])
|
||||||
|
import_ = StateTransition()
|
||||||
|
|
||||||
|
def transition_import_(self):
|
||||||
|
SystemLogicsModula = Pool().get('systemlogics.modula')
|
||||||
|
SystemLogicsModula.export_ordini_file()
|
||||||
|
return 'end'
|
||||||
|
|
|
@ -19,6 +19,22 @@ The COPYRIGHT file at the top level of this repository contains the full copyrig
|
||||||
<field name="group" ref="group_systemlogics_modula"/>
|
<field name="group" ref="group_systemlogics_modula"/>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
|
<!-- systemlogics.user -->
|
||||||
|
<record model="res.user" id="user_systemlogics_modula">
|
||||||
|
<field name="login">user_cron_internal_systemlogics_modula</field>
|
||||||
|
<field name="name">Cron SystemLogics Modula</field>
|
||||||
|
<field name="signature"></field>
|
||||||
|
<field name="active" eval="False"/>
|
||||||
|
</record>
|
||||||
|
<record model="res.user-res.group" id="user_systemlogics_modula_admin_group">
|
||||||
|
<field name="user" ref="user_systemlogics_modula"/>
|
||||||
|
<field name="group" ref="group_systemlogics_modula"/>
|
||||||
|
</record>
|
||||||
|
<record model="res.user-res.group" id="user_systemlogics_modula_stock_admin_group">
|
||||||
|
<field name="user" ref="user_systemlogics_modula"/>
|
||||||
|
<field name="group" ref="stock.group_stock_admin"/>
|
||||||
|
</record>
|
||||||
|
|
||||||
<!-- Menus -->
|
<!-- Menus -->
|
||||||
<menuitem parent="stock.menu_configuration"
|
<menuitem parent="stock.menu_configuration"
|
||||||
name="SystemLogics Modula" id="menu_systemlogics_modula_configuration"/>
|
name="SystemLogics Modula" id="menu_systemlogics_modula_configuration"/>
|
||||||
|
@ -110,17 +126,37 @@ The COPYRIGHT file at the top level of this repository contains the full copyrig
|
||||||
<field name="act_window" ref="act_systemlogics_modula_exp_ordini_file"/>
|
<field name="act_window" ref="act_systemlogics_modula_exp_ordini_file"/>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
<menuitem
|
<menuitem id="menu_systemlogics_modula_exp_ordini_file" parent="menu_systemlogics_modula"
|
||||||
id="menu_systemlogics_modula_exp_ordini_file"
|
action="act_systemlogics_modula_exp_ordini_file" name="EXP Ordini Files"/>
|
||||||
parent="menu_systemlogics_modula"
|
<record model="ir.ui.menu-res.group" id="menu_systemlogics_exp_ordini_file_group_modula">
|
||||||
action="act_systemlogics_modula_exp_ordini_file"
|
<field name="menu" ref="menu_systemlogics_modula_exp_ordini_file"/>
|
||||||
name="EXP Ordini Files"/>
|
<field name="group" ref="group_systemlogics_modula"/>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<!-- Import EXP Ordini File -->
|
||||||
|
<record model="ir.ui.view" id="systemlogics_modula_import_exp_ordini_file_start">
|
||||||
|
<field name="model">systemlogics.modula.import.exp.ordini.file.start</field>
|
||||||
|
<field name="type">form</field>
|
||||||
|
<field name="name">systemlogics_modula_import_exp_ordini_file_start</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<record model="ir.action.wizard" id="wizard_systemlogics_modula_import_exp_ordini_file_start">
|
||||||
|
<field name="name">Import EXP Ordini File</field>
|
||||||
|
<field name="wiz_name">systemlogics.modula.import.exp.ordini.file</field>
|
||||||
|
</record>
|
||||||
|
<menuitem id="menu_systemlogics_modula_import_exp_ordini_file" parent="menu_systemlogics_modula_exp_ordini_file"
|
||||||
|
action="wizard_systemlogics_modula_import_exp_ordini_file_start" name="Import Export Ordini Files"
|
||||||
|
sequence="20"/>
|
||||||
|
<record model="ir.ui.menu-res.group" id="menu_systemlogics_modula_exp_ordini_file_group_modula">
|
||||||
|
<field name="menu" ref="menu_systemlogics_modula_import_exp_ordini_file"/>
|
||||||
|
<field name="group" ref="group_systemlogics_modula"/>
|
||||||
|
</record>
|
||||||
|
|
||||||
<!-- CRON for systemlogics.modula -->
|
<!-- CRON for systemlogics.modula -->
|
||||||
<record model="ir.cron" id="cron_export_ordini_file">
|
<record model="ir.cron" id="cron_export_ordini_file">
|
||||||
<field name="name">Export Ordini Files</field>
|
<field name="name">Export Ordini Files</field>
|
||||||
<field name="request_user" ref="res.user_admin"/>
|
<field name="request_user" ref="res.user_admin"/>
|
||||||
<field name="user" ref="res.user_trigger"/>
|
<field name="user" ref="user_systemlogics_modula"/>
|
||||||
<field name="active" eval="True"/>
|
<field name="active" eval="True"/>
|
||||||
<field name="interval_number">1</field>
|
<field name="interval_number">1</field>
|
||||||
<field name="interval_type">days</field>
|
<field name="interval_type">days</field>
|
||||||
|
@ -201,14 +237,6 @@ The COPYRIGHT file at the top level of this repository contains the full copyrig
|
||||||
<field name="perm_create" eval="False"/>
|
<field name="perm_create" eval="False"/>
|
||||||
<field name="perm_delete" eval="False"/>
|
<field name="perm_delete" eval="False"/>
|
||||||
</record>
|
</record>
|
||||||
<record model="ir.model.access" id="access_systemlogics_modula_exp_ordini_file_modula_admin">
|
|
||||||
<field name="model" search="[('model', '=', 'systemlogics.modula.exp.ordini.file')]"/>
|
|
||||||
<field name="group" ref="group_systemlogics_modula_admin"/>
|
|
||||||
<field name="perm_read" eval="True"/>
|
|
||||||
<field name="perm_write" eval="True"/>
|
|
||||||
<field name="perm_create" eval="True"/>
|
|
||||||
<field name="perm_delete" eval="True"/>
|
|
||||||
</record>
|
|
||||||
<record model="ir.model.access" id="access_systemlogics_modula_exp_ordini_file_modula">
|
<record model="ir.model.access" id="access_systemlogics_modula_exp_ordini_file_modula">
|
||||||
<field name="model" search="[('model', '=', 'systemlogics.modula.exp.ordini.file')]"/>
|
<field name="model" search="[('model', '=', 'systemlogics.modula.exp.ordini.file')]"/>
|
||||||
<field name="group" ref="group_systemlogics_modula"/>
|
<field name="group" ref="group_systemlogics_modula"/>
|
||||||
|
|
|
@ -8,7 +8,8 @@
|
||||||
<ORD_CLIENTE></ORD_CLIENTE>
|
<ORD_CLIENTE></ORD_CLIENTE>
|
||||||
<ORD_SPEDIZIONE></ORD_SPEDIZIONE>
|
<ORD_SPEDIZIONE></ORD_SPEDIZIONE>
|
||||||
<ORD_GEST_PKL></ORD_GEST_PKL>
|
<ORD_GEST_PKL></ORD_GEST_PKL>
|
||||||
<IMP_ORDINI_RIGHE py:for="move in shipment.moves">
|
<py:for each="move in shipment.moves">
|
||||||
|
<IMP_ORDINI_RIGHE py:if="(move.from_location.systemlogics_modula and type_ == 'P') or (move.to_location.systemlogics_modula and type_ == 'V')">
|
||||||
<RIG_ORDINE>${shipment.number}</RIG_ORDINE>
|
<RIG_ORDINE>${shipment.number}</RIG_ORDINE>
|
||||||
<RIG_ARTICOLO>${move.product.code or move.product.rec_name}</RIG_ARTICOLO>
|
<RIG_ARTICOLO>${move.product.code or move.product.rec_name}</RIG_ARTICOLO>
|
||||||
<RIG_SUB1/>
|
<RIG_SUB1/>
|
||||||
|
@ -20,5 +21,6 @@
|
||||||
<RIG_PRIO>0</RIG_PRIO>
|
<RIG_PRIO>0</RIG_PRIO>
|
||||||
<RIG_REQ_NOTE/>
|
<RIG_REQ_NOTE/>
|
||||||
</IMP_ORDINI_RIGHE>
|
</IMP_ORDINI_RIGHE>
|
||||||
|
</py:for>
|
||||||
</IMP_ORDINI>
|
</IMP_ORDINI>
|
||||||
</SYSTORE_ORDINI>
|
</SYSTORE_ORDINI>
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<?xml version="1.0" encoding="Windows-1252"?>
|
<?xml version="1.0" encoding="Windows-1252"?>
|
||||||
<SYSTORE_ORDINI xmlns:py="http://genshi.edgewall.org/">
|
<SYSTORE_ORDINI xmlns:py="http://genshi.edgewall.org/">
|
||||||
<IMP_ORDINI py:for="shipment in shipments">
|
<IMP_ORDINI py:for="shipment in shipments">
|
||||||
<ORD_ORDINE>${shipment.number}</ORD_ORDINE>
|
<ORD_ORDINE>${shipment.code}</ORD_ORDINE>
|
||||||
<ORD_DES>${shipment.reference and shipment.reference[:50]}</ORD_DES>
|
<ORD_DES>${shipment.reference and shipment.reference[:50]}</ORD_DES>
|
||||||
<ORD_TIPOOP>${type_}</ORD_TIPOOP> <!-- P: Extracion / V: Deposito -->
|
<ORD_TIPOOP>${type_}</ORD_TIPOOP> <!-- P: Extracion / V: Deposito -->
|
||||||
<ORD_PRIOHOST>${datetime.datetime.now().strftime("%Y%m%d%H%M%s")[:16]}</ORD_PRIOHOST> <!-- fechaHora AAAAMMGGHHPPPPPP -->
|
<ORD_PRIOHOST>${datetime.datetime.now().strftime("%Y%m%d%H%M%s")[:16]}</ORD_PRIOHOST> <!-- fechaHora AAAAMMGGHHPPPPPP -->
|
||||||
|
@ -10,7 +10,7 @@
|
||||||
<ORD_GEST_PKL></ORD_GEST_PKL>
|
<ORD_GEST_PKL></ORD_GEST_PKL>
|
||||||
<py:for each="move in shipment.inventory_moves">
|
<py:for each="move in shipment.inventory_moves">
|
||||||
<IMP_ORDINI_RIGHE py:if="move.from_location.systemlogics_modula">
|
<IMP_ORDINI_RIGHE py:if="move.from_location.systemlogics_modula">
|
||||||
<RIG_ORDINE>${shipment.number}</RIG_ORDINE>
|
<RIG_ORDINE>${shipment.code}</RIG_ORDINE>
|
||||||
<RIG_ARTICOLO>${move.product.code or move.product.rec_name}</RIG_ARTICOLO>
|
<RIG_ARTICOLO>${move.product.code or move.product.rec_name}</RIG_ARTICOLO>
|
||||||
<RIG_SUB1/>
|
<RIG_SUB1/>
|
||||||
<RIG_SUB2/>
|
<RIG_SUB2/>
|
||||||
|
@ -23,7 +23,7 @@
|
||||||
</IMP_ORDINI_RIGHE>
|
</IMP_ORDINI_RIGHE>
|
||||||
</py:for>
|
</py:for>
|
||||||
<IMP_ORDINI_RIGHE py:if="not shipment.systemlogics_modula_completed">
|
<IMP_ORDINI_RIGHE py:if="not shipment.systemlogics_modula_completed">
|
||||||
<RIG_ORDINE>${shipment.number}</RIG_ORDINE>
|
<RIG_ORDINE>${shipment.code}</RIG_ORDINE>
|
||||||
<RIG_ARTICOLO>${systemlogic.not_completed or'Not completed'}</RIG_ARTICOLO>
|
<RIG_ARTICOLO>${systemlogic.not_completed or'Not completed'}</RIG_ARTICOLO>
|
||||||
<RIG_SUB1/>
|
<RIG_SUB1/>
|
||||||
<RIG_SUB2/>
|
<RIG_SUB2/>
|
||||||
|
|
23
tests/exp_ordini.xml
Normal file
23
tests/exp_ordini.xml
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
<?xml version="1.0" standalone="yes"?>
|
||||||
|
<SYSTORE>
|
||||||
|
<EXP_ORDINI>
|
||||||
|
<ORD_ORDINE>2</ORD_ORDINE>
|
||||||
|
<ORD_DES />
|
||||||
|
<ORD_TIPOOP>P</ORD_TIPOOP>
|
||||||
|
<EXP_ORDINI_RIGHE>
|
||||||
|
<RIG_ORDINE>2</RIG_ORDINE>
|
||||||
|
<RIG_ARTICOLO>P2</RIG_ARTICOLO>
|
||||||
|
<RIG_SUB1 />
|
||||||
|
<RIG_SUB2 />
|
||||||
|
<RIG_STAMATE />
|
||||||
|
<RIG_TIPOCONF />
|
||||||
|
<RIG_HOSTINF>6</RIG_HOSTINF>
|
||||||
|
<RIG_QTAR>1,000</RIG_QTAR>
|
||||||
|
<RIG_QTAE>1,000</RIG_QTAE>
|
||||||
|
<RIG_REQ_NOTE />
|
||||||
|
<RIG_NOTE_STAMPA />
|
||||||
|
<RIG_HOSTCAUS />
|
||||||
|
<RIG_HOSTRIF />
|
||||||
|
</EXP_ORDINI_RIGHE>
|
||||||
|
</EXP_ORDINI>
|
||||||
|
</SYSTORE>
|
|
@ -5,16 +5,19 @@ Systemlogics Modula Scenario
|
||||||
Imports::
|
Imports::
|
||||||
|
|
||||||
>>> import datetime
|
>>> import datetime
|
||||||
|
>>> import os
|
||||||
>>> from dateutil.relativedelta import relativedelta
|
>>> from dateutil.relativedelta import relativedelta
|
||||||
>>> from decimal import Decimal
|
>>> from decimal import Decimal
|
||||||
>>> from proteus import config, Model, Wizard
|
>>> from proteus import config, Model, Wizard
|
||||||
>>> from trytond.tests.tools import activate_modules
|
>>> from trytond.tests.tools import activate_modules
|
||||||
>>> from trytond.modules.company.tests.tools import create_company, \
|
>>> from trytond.modules.company.tests.tools import create_company, \
|
||||||
... get_company
|
... get_company
|
||||||
|
>>> from trytond.modules.systemlogics_modula.tests.tools \
|
||||||
|
... import read_file
|
||||||
>>> today = datetime.date.today()
|
>>> today = datetime.date.today()
|
||||||
>>> yesterday = today - relativedelta(days=1)
|
>>> yesterday = today - relativedelta(days=1)
|
||||||
|
|
||||||
Install SystemLogics Modula Module::
|
Install stock Module::
|
||||||
|
|
||||||
>>> config = activate_modules('systemlogics_modula')
|
>>> config = activate_modules('systemlogics_modula')
|
||||||
|
|
||||||
|
@ -52,6 +55,10 @@ Create product::
|
||||||
>>> template.list_price = Decimal('20')
|
>>> template.list_price = Decimal('20')
|
||||||
>>> template.save()
|
>>> template.save()
|
||||||
>>> product, = template.products
|
>>> product, = template.products
|
||||||
|
>>> product.code = 'P1'
|
||||||
|
>>> product.cost_price = Decimal('8')
|
||||||
|
>>> product.code = 'P1'
|
||||||
|
>>> product.save()
|
||||||
|
|
||||||
>>> product2 = Product()
|
>>> product2 = Product()
|
||||||
>>> template = ProductTemplate()
|
>>> template = ProductTemplate()
|
||||||
|
@ -62,6 +69,9 @@ Create product::
|
||||||
>>> template.list_price = Decimal('20')
|
>>> template.list_price = Decimal('20')
|
||||||
>>> template.save()
|
>>> template.save()
|
||||||
>>> product2, = template.products
|
>>> product2, = template.products
|
||||||
|
>>> product2.cost_price = Decimal('8')
|
||||||
|
>>> product2.code = 'P2'
|
||||||
|
>>> product2.save()
|
||||||
|
|
||||||
Get stock locations::
|
Get stock locations::
|
||||||
|
|
||||||
|
@ -169,13 +179,13 @@ Create Shipment Out::
|
||||||
>>> shipment_out.systemlogics_modula == False
|
>>> shipment_out.systemlogics_modula == False
|
||||||
True
|
True
|
||||||
|
|
||||||
>>> shipment_out = ShipmentOut()
|
>>> shipment_out2 = ShipmentOut()
|
||||||
>>> shipment_out.planned_date = today
|
>>> shipment_out2.planned_date = today
|
||||||
>>> shipment_out.customer = customer
|
>>> shipment_out2.customer = customer
|
||||||
>>> shipment_out.warehouse = warehouse_loc
|
>>> shipment_out2.warehouse = warehouse_loc
|
||||||
>>> shipment_out.company = company
|
>>> shipment_out2.company = company
|
||||||
>>> shipment_out.outgoing_moves.extend([StockMove()])
|
>>> shipment_out2.outgoing_moves.extend([StockMove()])
|
||||||
>>> for move in shipment_out.outgoing_moves:
|
>>> for move in shipment_out2.outgoing_moves:
|
||||||
... move.product = product2
|
... move.product = product2
|
||||||
... move.uom = unit
|
... move.uom = unit
|
||||||
... move.quantity = 1
|
... move.quantity = 1
|
||||||
|
@ -184,15 +194,15 @@ Create Shipment Out::
|
||||||
... move.company = company
|
... move.company = company
|
||||||
... move.unit_price = Decimal('1')
|
... move.unit_price = Decimal('1')
|
||||||
... move.currency = company.currency
|
... move.currency = company.currency
|
||||||
>>> shipment_out.save()
|
>>> shipment_out2.save()
|
||||||
>>> shipment_out.click('wait')
|
>>> shipment_out2.click('wait')
|
||||||
>>> inventory_move, = shipment_out.inventory_moves
|
>>> inventory_move, = shipment_out2.inventory_moves
|
||||||
>>> inventory_move.from_location = modula_loc
|
>>> inventory_move.from_location = modula_loc
|
||||||
>>> inventory_move.save()
|
>>> inventory_move.save()
|
||||||
>>> shipment_out.reload()
|
>>> shipment_out2.reload()
|
||||||
>>> shipment_out.click('assign_try')
|
>>> shipment_out2.click('assign_try')
|
||||||
True
|
True
|
||||||
>>> shipment_out.systemlogics_modula == True
|
>>> shipment_out2.systemlogics_modula == True
|
||||||
True
|
True
|
||||||
|
|
||||||
Create Shipment Out Return::
|
Create Shipment Out Return::
|
||||||
|
@ -270,3 +280,19 @@ Create Shipment Internal::
|
||||||
>>> shipment_internal.reload()
|
>>> shipment_internal.reload()
|
||||||
>>> shipment_internal.systemlogics_modula == True
|
>>> shipment_internal.systemlogics_modula == True
|
||||||
True
|
True
|
||||||
|
|
||||||
|
Import EXP Ordini::
|
||||||
|
|
||||||
|
>>> EXPOrdiniFile = Model.get('systemlogics.modula.exp.ordini.file')
|
||||||
|
>>> ordine_file = os.path.join(os.path.dirname(__file__), 'exp_ordini.xml')
|
||||||
|
>>> exp_ordini_file = EXPOrdiniFile()
|
||||||
|
>>> exp_ordini_file.name = 'EXP_ORDINI1.XML'
|
||||||
|
>>> exp_ordini_file.modula = sm_exp_ordini
|
||||||
|
>>> exp_ordini_file.content = read_file(ordine_file).decode('utf-8')
|
||||||
|
>>> exp_ordini_file.save()
|
||||||
|
>>> exp_ordini_file.click('process_export_ordini')
|
||||||
|
>>> exp_ordini_file.state == 'done'
|
||||||
|
True
|
||||||
|
>>> shipment_out2.reload()
|
||||||
|
>>> shipment_out2.state == 'packed'
|
||||||
|
True
|
||||||
|
|
13
tests/tools.py
Normal file
13
tests/tools.py
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
# The COPYRIGHT file at the top level of this repository contains the full
|
||||||
|
# copyright notices and license terms.
|
||||||
|
|
||||||
|
__all__ = ['read_file']
|
||||||
|
|
||||||
|
|
||||||
|
def read_file(filename):
|
||||||
|
with open(filename) as f:
|
||||||
|
data = f.read()
|
||||||
|
# On python3 we must cast to bytes with valid encoding
|
||||||
|
if bytes != str:
|
||||||
|
data = bytes(data, encoding=f.encoding)
|
||||||
|
return data
|
|
@ -13,3 +13,4 @@ xml:
|
||||||
location.xml
|
location.xml
|
||||||
product.xml
|
product.xml
|
||||||
shipment.xml
|
shipment.xml
|
||||||
|
configuration.xml
|
||||||
|
|
12
view/configuration_form.xml
Normal file
12
view/configuration_form.xml
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
<?xml version="1.0"?>
|
||||||
|
<!-- The COPYRIGHT file at the top level of this repository contains the full
|
||||||
|
copyright notices and license terms. -->
|
||||||
|
<data>
|
||||||
|
<xpath expr="/form/field[@name='shipment_internal_sequence']"
|
||||||
|
position="after">
|
||||||
|
<label name="try_generate_systemlogics_modula"/>
|
||||||
|
<field name="try_generate_systemlogics_modula"/>
|
||||||
|
<label name="slice_systemlogics_modula"/>
|
||||||
|
<field name="slice_systemlogics_modula"/>
|
||||||
|
</xpath>
|
||||||
|
</data>
|
6
view/shipment_out_check_form.xml
Normal file
6
view/shipment_out_check_form.xml
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
<?xml version="1.0"?>
|
||||||
|
<!-- This file is part systemlogics_modula module for Tryton.
|
||||||
|
The COPYRIGHT file at the top level of this repository contains the full copyright notices and license terms. -->
|
||||||
|
<form>
|
||||||
|
<field name="shipments" colspan="4"/>
|
||||||
|
</form>
|
14
view/shipment_out_tree.xml
Normal file
14
view/shipment_out_tree.xml
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
<?xml version="1.0"?>
|
||||||
|
<!-- This file is part stock_shipment_out_autoassign module for Tryton.
|
||||||
|
The COPYRIGHT file at the top level of this repository contains the full copyright notices and license terms. -->
|
||||||
|
<data>
|
||||||
|
<xpath expr="/tree/field[@name='planned_date']" position="before">
|
||||||
|
<field name="ship_create_date" widget="date"/>
|
||||||
|
</xpath>
|
||||||
|
|
||||||
|
<xpath expr="/tree/field[@name='state']" position="after">
|
||||||
|
<field name="systemlogics_modula" tree_invisible="1"/>
|
||||||
|
<field name="systemlogics_modula_completed" tree_invisible="1"/>
|
||||||
|
<field name="systemlogics_modula_sended" tree_invisible="1"/>
|
||||||
|
</xpath>
|
||||||
|
</data>
|
|
@ -12,6 +12,6 @@ The COPYRIGHT file at the top level of this repository contains the full copyrig
|
||||||
<label name="state"/>
|
<label name="state"/>
|
||||||
<field name="state"/>
|
<field name="state"/>
|
||||||
<group col="4" colspan="2" id="buttons">
|
<group col="4" colspan="2" id="buttons">
|
||||||
<button name="process_export_ordini" string="Process" icon="tryton-go-next"/>
|
<button name="process_export_ordini" icon="tryton-go-next"/>
|
||||||
</group>
|
</group>
|
||||||
</form>
|
</form>
|
||||||
|
|
17
view/systemlogics_modula_import_exp_ordini_file_start.xml
Normal file
17
view/systemlogics_modula_import_exp_ordini_file_start.xml
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
<?xml version="1.0"?>
|
||||||
|
<!-- This file is part of the carrier_send_shipments_seur module for Tryton.
|
||||||
|
The COPYRIGHT file at the top level of this repository contains the full
|
||||||
|
copyright notices and license terms. -->
|
||||||
|
<form>
|
||||||
|
<image name="tryton-dialog-information" xexpand="0"
|
||||||
|
xfill="0"/>
|
||||||
|
<group col="1" id="import">
|
||||||
|
<label
|
||||||
|
string="Import EXP Ordini Files."
|
||||||
|
id="send"
|
||||||
|
yalign="0.0" xalign="0.0" xexpand="1"/>
|
||||||
|
<label string="Note that this operation may take a few minutes."
|
||||||
|
id="operation"
|
||||||
|
yalign="0.0" xalign="0.0" xexpand="1"/>
|
||||||
|
</group>
|
||||||
|
</form>
|
Loading…
Reference in a new issue