Simplify workflow engine
review256001
This commit is contained in:
1 parent
bbd2ed5ebb
commit
69b67f1c0f
4 files changed
+19
-21
No files matched your search
@@ -12,7 +12,7 @@ minor_version = int(minor_version)
|
||||
|
||||
requires = []
|
||||
for dep in info.get('depends', []):
|
||||
if not re.match(r'(ir|res|workflow|webdav)(\W|$)', dep):
|
||||
if not re.match(r'(ir|res|webdav)(\W|$)', dep):
|
||||
requires.append('trytond_%s >= %s.%s, < %s.%s' %
|
||||
(dep, major_version, minor_version, major_version,
|
||||
minor_version + 1))
|
||||
@@ -21,7 +21,7 @@ requires.append('trytond >= %s.%s, < %s.%s' %
|
||||
|
||||
extras_require = {}
|
||||
for dep in info.get('extras_depend', []):
|
||||
if not re.match(r'(ir|res|workflow|webdav)(\W|$)', dep):
|
||||
if not re.match(r'(ir|res|webdav)(\W|$)', dep):
|
||||
extras_require[dep] = ('trytond_%s >= %s.%s, < %s.%s' %
|
||||
(dep, major_version, minor_version, major_version,
|
||||
minor_version + 1))
|
||||
|
||||
@@ -4,7 +4,7 @@ import copy
|
||||
from decimal import Decimal, ROUND_DOWN, ROUND_HALF_EVEN
|
||||
from operator import itemgetter
|
||||
|
||||
from trytond.model import Model, fields
|
||||
from trytond.model import Model, ModelView, Workflow, fields
|
||||
from trytond.pyson import Eval, Bool
|
||||
from trytond.pool import Pool
|
||||
from trytond.transaction import Transaction
|
||||
@@ -153,15 +153,17 @@ class ShipmentIn(Model):
|
||||
'unit_shipment_cost': cost['unit_shipment_cost'],
|
||||
})
|
||||
|
||||
def wkf_received(self, shipment):
|
||||
@ModelView.button
|
||||
@Workflow.transition('received')
|
||||
def receive(self, ids):
|
||||
carrier_obj = Pool().get('carrier')
|
||||
|
||||
if shipment.carrier:
|
||||
allocation_method = shipment.carrier.carrier_cost_allocation_method
|
||||
else:
|
||||
allocation_method = carrier_obj.default_carrier_cost_method()
|
||||
getattr(self, 'allocate_cost_by_%s' % allocation_method)(shipment)
|
||||
super(ShipmentIn, self).wkf_received(shipment)
|
||||
for shipment in self.browse(ids):
|
||||
if shipment.carrier:
|
||||
allocation_method = shipment.carrier.carrier_cost_allocation_method
|
||||
else:
|
||||
allocation_method = carrier_obj.default_carrier_cost_method()
|
||||
getattr(self, 'allocate_cost_by_%s' % allocation_method)(shipment)
|
||||
super(ShipmentIn, self).receive(ids)
|
||||
|
||||
ShipmentIn()
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ Install purchase_shipment_cost::
|
||||
>>> modules = Module.find([
|
||||
... ('name', '=', 'purchase_shipment_cost'),
|
||||
... ])
|
||||
>>> Module.button_install([x.id for x in modules], config.context)
|
||||
>>> Module.install([x.id for x in modules], config.context)
|
||||
>>> Wizard('ir.module.module.install_upgrade').execute('upgrade')
|
||||
|
||||
Create company::
|
||||
@@ -122,8 +122,7 @@ Receive a single product line::
|
||||
>>> shipment.cost_currency == currency
|
||||
True
|
||||
>>> shipment.save()
|
||||
>>> ShipmentIn.workflow_trigger_validate(shipment.id, 'received',
|
||||
... config.context)
|
||||
>>> ShipmentIn.receive([shipment.id], config.context)
|
||||
>>> shipment.reload()
|
||||
>>> shipment.state
|
||||
u'received'
|
||||
@@ -146,8 +145,7 @@ Receive many product lines::
|
||||
>>> shipment.cost == Decimal('3')
|
||||
True
|
||||
>>> shipment.save()
|
||||
>>> ShipmentIn.workflow_trigger_validate(shipment.id, 'received',
|
||||
... config.context)
|
||||
>>> ShipmentIn.receive([shipment.id], config.context)
|
||||
>>> shipment.reload()
|
||||
>>> shipment.state
|
||||
u'received'
|
||||
|
||||
@@ -26,7 +26,7 @@ Install purchase_shipment_cost::
|
||||
... ('name', 'in', ['purchase_shipment_cost',
|
||||
... 'account_stock_continental']),
|
||||
... ])
|
||||
>>> Module.button_install([x.id for x in modules], config.context)
|
||||
>>> Module.install([x.id for x in modules], config.context)
|
||||
>>> Wizard('ir.module.module.install_upgrade').execute('upgrade')
|
||||
|
||||
Create company::
|
||||
@@ -201,8 +201,7 @@ Receive a single product line::
|
||||
>>> shipment.cost_currency == currency
|
||||
True
|
||||
>>> shipment.save()
|
||||
>>> ShipmentIn.workflow_trigger_validate(shipment.id, 'received',
|
||||
... config.context)
|
||||
>>> ShipmentIn.receive([shipment.id], config.context)
|
||||
>>> shipment.reload()
|
||||
>>> shipment.state
|
||||
u'received'
|
||||
@@ -239,8 +238,7 @@ Receive many product lines::
|
||||
>>> shipment.cost == Decimal('3')
|
||||
True
|
||||
>>> shipment.save()
|
||||
>>> ShipmentIn.workflow_trigger_validate(shipment.id, 'received',
|
||||
... config.context)
|
||||
>>> ShipmentIn.receive([shipment.id], config.context)
|
||||
>>> shipment.reload()
|
||||
>>> shipment.state
|
||||
u'received'
|
||||
|
||||
Reference in new issue
Block a user