merge
This commit is contained in:
commit
4ddab245a8
3 files changed
+29
-53
No files matched your search
@@ -146,7 +146,7 @@ class Move(OSV):
|
||||
def unlink(self, cursor, user, ids, context=None):
|
||||
move_ids = self.search(
|
||||
cursor, user, [('id', 'in', ids), ('state', 'in',
|
||||
['done', 'waiting', 'cancel'])], context)
|
||||
['done', 'waiting'])], context)
|
||||
if move_ids:
|
||||
raise ExceptORM('UserError', 'You can only delete draft moves !')
|
||||
return super(Move, self).unlink(cursor, user, ids, context=context)
|
||||
|
||||
+13
-17
@@ -2,6 +2,7 @@
|
||||
from trytond.osv import fields, OSV
|
||||
from trytond.wizard import Wizard, WizardOSV
|
||||
import time
|
||||
from trytond.netsvc import LocalService
|
||||
|
||||
STATES = {
|
||||
'readonly': "state in ('cancel', 'done')",
|
||||
@@ -29,7 +30,7 @@ class PackingIn(OSV):
|
||||
relation='stock.move', string='Inventory Moves',
|
||||
fnct_inv='set_inventory_moves',
|
||||
states={
|
||||
'readonly': "state in ('draft', 'waiting')",
|
||||
'readonly': "state == 'draft'",
|
||||
}, context="{'warehouse': warehouse, "\
|
||||
"'packing_state': state, 'type':'inventory_in'}")
|
||||
moves = fields.One2Many('stock.move', 'packing_in', 'Moves',
|
||||
@@ -39,19 +40,14 @@ class PackingIn(OSV):
|
||||
('draft', 'Draft'),
|
||||
('done', 'Done'),
|
||||
('cancel', 'Cancel'),
|
||||
('waiting', 'Waiting'),
|
||||
('received', 'Received'),
|
||||
], 'State', readonly=True)
|
||||
|
||||
def __init__(self):
|
||||
super(PackingIn, self).__init__()
|
||||
self._rpc_allowed += [
|
||||
'set_state_done',
|
||||
'set_state_waiting',
|
||||
'set_state_draft',
|
||||
'set_state_cancel',
|
||||
'set_state_received',
|
||||
]
|
||||
'button_draft',
|
||||
]
|
||||
self._order[0] = ('id', 'DESC')
|
||||
|
||||
def default_state(self, cursor, user, context=None):
|
||||
@@ -163,14 +159,6 @@ class PackingIn(OSV):
|
||||
self.write(cursor, user, packing_id, {'state':'cancel'},
|
||||
context=context)
|
||||
|
||||
def set_state_waiting(self, cursor, user, packing_id, context=None):
|
||||
move_obj = self.pool.get('stock.move')
|
||||
packing = self.browse(cursor, user, packing_id, context=context)
|
||||
move_obj.set_state_waiting(
|
||||
cursor, user, [m.id for m in packing.incoming_moves], context)
|
||||
self.write(cursor, user, packing_id, {'state':'waiting'},
|
||||
context=context)
|
||||
|
||||
def set_state_received(self, cursor, user, packing_id, context=None):
|
||||
move_obj = self.pool.get('stock.move')
|
||||
packing = self.browse(cursor, user, packing_id, context=context)
|
||||
@@ -184,7 +172,9 @@ class PackingIn(OSV):
|
||||
packing = self.browse(cursor, user, packing_id, context=context)
|
||||
move_obj.set_state_draft(
|
||||
cursor, user, [m.id for m in packing.incoming_moves], context)
|
||||
move_obj.set_state_cancel(
|
||||
move_obj.set_state_waiting(
|
||||
cursor, user, [m.id for m in packing.incoming_moves], context)
|
||||
move_obj.unlink(
|
||||
cursor, user, [m.id for m in packing.inventory_moves], context)
|
||||
self.write(
|
||||
cursor, user, packing_id, {'state':'draft'}, context=context)
|
||||
@@ -219,6 +209,12 @@ class PackingIn(OSV):
|
||||
'inventory_moves': [('create', vals)]
|
||||
}, context=context)
|
||||
|
||||
def button_draft(self, cursor, user, ids, context=None):
|
||||
workflow_service = LocalService('workflow')
|
||||
for packing in self.browse(cursor, user, ids, context=context):
|
||||
workflow_service.trg_create(user, self._name, packing.id, cursor)
|
||||
return True
|
||||
|
||||
PackingIn()
|
||||
|
||||
|
||||
|
||||
+15
-35
@@ -49,18 +49,15 @@
|
||||
<label name="state"/>
|
||||
<field name="state"/>
|
||||
<group col="4" colspan="2">
|
||||
<button string="Cancel" name="signal_cancel"
|
||||
states="{'invisible': '''state in
|
||||
('cancel','done',) '''}"/>
|
||||
<button string="Set Done" name="signal_done"
|
||||
states="{'invisible': '''state !=
|
||||
'received' '''}"/>
|
||||
<button string="Set Waiting" name="signal_waiting"
|
||||
states="{'invisible': '''state !=
|
||||
'draft' '''}"/>
|
||||
<button string="Received" name="signal_received"
|
||||
states="{'invisible': '''state !=
|
||||
'waiting' '''}"/>
|
||||
<button string="Cancel" name="cancel"
|
||||
states="{'invisible': '''state in ('cancel', 'done') '''}"/>
|
||||
<button string="Set Done" name="done"
|
||||
states="{'invisible': '''state != 'received' '''}"/>
|
||||
<button string="Received" name="received"
|
||||
states="{'invisible': '''state != 'draft' '''}"/>
|
||||
<button string="Reset to Draft" name="button_draft"
|
||||
type="object"
|
||||
states="{'invisible': '''state != 'cancel' '''}"/>
|
||||
</group>
|
||||
</group>
|
||||
</form>
|
||||
@@ -344,12 +341,6 @@
|
||||
<field name="kind">function</field>
|
||||
<field name="action">set_state_done()</field>
|
||||
</record>
|
||||
<record model="workflow.activity" id="packingin_act_waiting">
|
||||
<field name="name">Waiting</field>
|
||||
<field name="kind">function</field>
|
||||
<field name="workflow" ref="wkf_packingin"/>
|
||||
<field name="action">set_state_waiting()</field>
|
||||
</record>
|
||||
<record model="workflow.activity" id="packingin_act_received">
|
||||
<field name="name">Received</field>
|
||||
<field name="kind">function</field>
|
||||
@@ -358,37 +349,26 @@
|
||||
</record>
|
||||
|
||||
<record model="workflow.transition"
|
||||
id="packingin_trans_waiting_received">
|
||||
<field name="act_from" ref="packingin_act_waiting"/>
|
||||
id="packingin_trans_draft_received">
|
||||
<field name="act_from" ref="packingin_act_draft"/>
|
||||
<field name="act_to" ref="packingin_act_received"/>
|
||||
<field name="signal">signal_received</field>
|
||||
<field name="signal">received</field>
|
||||
</record>
|
||||
<record model="workflow.transition" id="packingin_trans_received_done">
|
||||
<field name="act_from" ref="packingin_act_received"/>
|
||||
<field name="act_to" ref="packingin_act_done"/>
|
||||
<field name="signal">signal_done</field>
|
||||
</record>
|
||||
<record model="workflow.transition" id="packingin_trans_draft_waiting">
|
||||
<field name="act_from" ref="packingin_act_draft"/>
|
||||
<field name="act_to" ref="packingin_act_waiting"/>
|
||||
<field name="signal">signal_waiting</field>
|
||||
</record>
|
||||
<record model="workflow.transition"
|
||||
id="packingin_trans_waiting_cancel">
|
||||
<field name="act_from" ref="packingin_act_waiting"/>
|
||||
<field name="act_to" ref="packingin_act_cancel"/>
|
||||
<field name="signal">signal_cancel</field>
|
||||
<field name="signal">done</field>
|
||||
</record>
|
||||
<record model="workflow.transition" id="packingin_trans_draft_cancel">
|
||||
<field name="act_from" ref="packingin_act_draft"/>
|
||||
<field name="act_to" ref="packingin_act_cancel"/>
|
||||
<field name="signal">signal_cancel</field>
|
||||
<field name="signal">cancel</field>
|
||||
</record>
|
||||
<record model="workflow.transition"
|
||||
id="packingin_trans_received_cancel">
|
||||
<field name="act_from" ref="packingin_act_received"/>
|
||||
<field name="act_to" ref="packingin_act_cancel"/>
|
||||
<field name="signal">signal_cancel</field>
|
||||
<field name="signal">cancel</field>
|
||||
</record>
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user