mirror of
https://github.com/NaN-tic/trytond-systemlogics_modula.git
synced 2023-12-14 04:32:53 +01:00
Generate IMP ORDINI: control rollback + context
This commit is contained in:
parent
1aecb8807d
commit
3946127562
1 changed files with 34 additions and 11 deletions
45
stock.py
45
stock.py
|
@ -3,6 +3,7 @@
|
|||
#the full copyright notices and license terms.
|
||||
from trytond.pool import Pool, PoolMeta
|
||||
from trytond.model import fields
|
||||
from trytond.transaction import Transaction
|
||||
|
||||
__all__ = ['ShipmentOut', 'ShipmentInternal']
|
||||
__metaclass__ = PoolMeta
|
||||
|
@ -31,16 +32,25 @@ class ShipmentOut:
|
|||
if systemLogics:
|
||||
systemlogics_shipments.append(s)
|
||||
|
||||
# mark shipment is in systemlogics process
|
||||
if systemlogics_shipments:
|
||||
cls.write(systemlogics_shipments, {'systemlogics_modula': True})
|
||||
SystemLogicsModula.imp_ordini(
|
||||
systemlogics_shipments, template='IMP_ORDINI_OUT', type_='P')
|
||||
|
||||
# Force not get a rollback to generate XML file
|
||||
shipment_ids = [shipment.id for shipment in shipments]
|
||||
Transaction().cursor.commit()
|
||||
# Search shipment ID to sure not have a rollback
|
||||
shipments = cls.search([
|
||||
('id', 'in', shipment_ids),
|
||||
])
|
||||
SystemLogicsModula.imp_ordini(
|
||||
shipments, template='IMP_ORDINI_OUT', type_='P')
|
||||
|
||||
@classmethod
|
||||
def assign(cls, shipments):
|
||||
super(ShipmentOut, cls).assign(shipments)
|
||||
cls.generate_systemlogics_modula(shipments)
|
||||
# control generate systemlogics module with context
|
||||
if Transaction().context.get('generate_systemlogics_modula', True):
|
||||
cls.generate_systemlogics_modula(shipments)
|
||||
|
||||
|
||||
class ShipmentInternal:
|
||||
|
@ -64,15 +74,28 @@ class ShipmentInternal:
|
|||
if s.to_location.systemlogics_modula:
|
||||
deposit_shipments.append(s)
|
||||
|
||||
# mark shipment is in systemlogics process
|
||||
if extract_shipments or deposit_shipments:
|
||||
cls.write(extract_shipments + deposit_shipments, {'systemlogics_modula': True})
|
||||
if extract_shipments:
|
||||
SystemLogicsModula.imp_ordini(
|
||||
extract_shipments, template='IMP_ORDINI_IN', type_='P')
|
||||
if deposit_shipments:
|
||||
SystemLogicsModula.imp_ordini(
|
||||
deposit_shipments, template='IMP_ORDINI_IN', type_='V')
|
||||
|
||||
# Force not get a rollback to generate XML file
|
||||
extract_shipments_ids = [shipment.id for shipment in extract_shipments]
|
||||
deposit_shipments_ids = [shipment.id for shipment in deposit_shipments]
|
||||
Transaction().cursor.commit()
|
||||
|
||||
if extract_shipments_ids:
|
||||
# Search shipment ID to sure not have a rollback
|
||||
ext_shipments = cls.search([
|
||||
('id', 'in', extract_shipments_ids),
|
||||
])
|
||||
SystemLogicsModula.imp_ordini(
|
||||
ext_shipments, template='IMP_ORDINI_IN', type_='P')
|
||||
if deposit_shipments_ids:
|
||||
# Search shipment ID to sure not have a rollback
|
||||
dep_shipments = cls.search([
|
||||
('id', 'in', deposit_shipments_ids),
|
||||
])
|
||||
SystemLogicsModula.imp_ordini(
|
||||
dep_shipments, template='IMP_ORDINI_IN', type_='V')
|
||||
|
||||
@classmethod
|
||||
def assign(cls, shipments):
|
||||
|
|
Loading…
Reference in a new issue