[FIX] point_of_sale: Fix the pos.session's workflow
bzr revid: stw@openerp.com-20120530143543-1dkfudbub83ga71c
This commit is contained in:
parent
26a722c910
commit
fa7d30035c
|
@ -155,6 +155,30 @@ class pos_session(osv.osv):
|
|||
break
|
||||
return result
|
||||
|
||||
def _compute_controls(self, cr, uid, ids, fieldnames, args, context=None):
|
||||
result = {}
|
||||
|
||||
for record in self.browse(cr, uid, ids, context=context):
|
||||
has_opening_control = False
|
||||
has_closing_control = False
|
||||
|
||||
for journal in record.config_id.journal_ids:
|
||||
if journal.opening_control == True:
|
||||
has_opening_control = True
|
||||
if journal.closing_control == True:
|
||||
has_closing_control = True
|
||||
|
||||
if has_opening_control and has_closing_control:
|
||||
break
|
||||
|
||||
values = {
|
||||
'has_opening_control': has_opening_control,
|
||||
'has_closing_control': has_closing_control,
|
||||
}
|
||||
result[record.id] = values
|
||||
|
||||
return result
|
||||
|
||||
_columns = {
|
||||
'config_id' : fields.many2one('pos.config', 'Point of Sale',
|
||||
help="The physical point of sale you will use.",
|
||||
|
@ -229,6 +253,8 @@ class pos_session(osv.osv):
|
|||
'order_ids' : fields.one2many('pos.order', 'session_id', 'Orders'),
|
||||
|
||||
'statement_ids' : fields.one2many('account.bank.statement', 'pos_session_id', 'Bank Statement', readonly=True),
|
||||
'has_opening_control' : fields.function(_compute_controls, string='Has Opening Control', multi='control', type='boolean'),
|
||||
'has_closing_control' : fields.function(_compute_controls, string='Has Closing Control', multi='control', type='boolean'),
|
||||
}
|
||||
|
||||
_defaults = {
|
||||
|
@ -310,6 +336,9 @@ class pos_session(osv.osv):
|
|||
st.button_open(context=context)
|
||||
return True
|
||||
|
||||
def wkf_action_opening_control(self, cr, uid, ids, context=None):
|
||||
return self.write(cr, uid, ids, {'state' : 'opening_control'}, context=context)
|
||||
|
||||
def wkf_action_closing_control(self, cr, uid, ids, context=None):
|
||||
for session in self.browse(cr, uid, ids, context=context):
|
||||
for statement in session.statement_ids:
|
||||
|
@ -351,17 +380,6 @@ class pos_session(osv.osv):
|
|||
self._confirm_orders(cr, uid, ids, context=context)
|
||||
return self.write(cr, uid, ids, {'state' : 'closed'}, context=context)
|
||||
|
||||
def has_opening_control(self, cr, uid, ids, context=None):
|
||||
return any(journal.opening_control == True
|
||||
for session in self.browse(cr, uid, ids, context=context)
|
||||
for journal in session.config_id.journal_ids)
|
||||
|
||||
def has_closing_control(self, cr, uid, ids, context=None):
|
||||
result = any(journal.closing_control == True
|
||||
for session in self.browse(cr, uid, ids, context=context)
|
||||
for journal in session.config_id.journal_ids)
|
||||
return result
|
||||
|
||||
def _confirm_orders(self, cr, uid, ids, context=None):
|
||||
wf_service = netsvc.LocalService("workflow")
|
||||
|
||||
|
|
|
@ -861,8 +861,7 @@
|
|||
<div class="oe_form_topbar">
|
||||
<button name="open" type="workflow" string="Validate & Open Session" states="opening_control" />
|
||||
<button name="cashbox_control" type="workflow" string="End of Session" states="opened" />
|
||||
<button name="close" type="workflow" string="Validate & Close" states="closing_control" />
|
||||
|
||||
<button name="close" type="workflow" string="Validate & Close" states="closing_control,opened" />
|
||||
|
||||
<div class="oe_right">
|
||||
<field name="state" widget="statusbar" statusbar_visible="opening_control,opened,closing_control,closed" nolabel="1"/>
|
||||
|
@ -872,6 +871,8 @@
|
|||
|
||||
<group colspan="4" col="4">
|
||||
<field name="config_id"/>
|
||||
<field name="has_opening_control" invisible="1" />
|
||||
<field name="has_closing_control" invisible="1" />
|
||||
<group colspan="2" col="2">
|
||||
<button name="%(action_pos_box_in)d" string="Put Money In" type="action" states="opened"/>
|
||||
<button name="%(action_pos_box_out)d" string="Take Money Out" type="action" states="opened"/>
|
||||
|
|
|
@ -86,10 +86,17 @@
|
|||
|
||||
<!-- Activities -->
|
||||
|
||||
<record model="workflow.activity" id="act_start">
|
||||
<field name="wkf_id" ref="wkf_pos_session" />
|
||||
<field name="flow_start">True</field>
|
||||
<field name="name">start</field>
|
||||
</record>
|
||||
|
||||
<record model="workflow.activity" id="act_opening_control">
|
||||
<field name="wkf_id" ref="wkf_pos_session"/>
|
||||
<field name="flow_start">True</field>
|
||||
<field name="name">opening_control</field>
|
||||
<field name="action">wkf_action_opening_control()</field>
|
||||
<field name="kind">function</field>
|
||||
</record>
|
||||
|
||||
<record model="workflow.activity" id="act_open">
|
||||
|
@ -115,6 +122,19 @@
|
|||
</record>
|
||||
|
||||
<!-- Transitions -->
|
||||
<record model="workflow.transition" id="trans_start_to_opening_control">
|
||||
<field name="act_from" ref="act_start" />
|
||||
<field name="act_to" ref="act_opening_control" />
|
||||
<field name="signal" eval="False" /> <!-- >start_to_opening_control</field> -->
|
||||
<field name="condition">has_opening_control == True</field>
|
||||
</record>
|
||||
|
||||
<record model="workflow.transition" id="trans_start_to_open">
|
||||
<field name="act_from" ref="act_start" />
|
||||
<field name="act_to" ref="act_open" />
|
||||
<field name="signal" eval="False" />
|
||||
<field name="condition">has_opening_control == False</field>
|
||||
</record>
|
||||
<!-- state:opening_control -> signal:open -> state:opened -> signal:cashbox_control -> state:closing_control -> signal:close -> state:close -->
|
||||
|
||||
<record model="workflow.transition" id="trans_opening_control_to_open">
|
||||
|
@ -122,29 +142,20 @@
|
|||
<field name="act_to" ref="act_open" />
|
||||
<field name="signal">open</field>
|
||||
</record>
|
||||
<!--
|
||||
<record model="workflow.transition" id="trans_opening_control_to_open_automatic">
|
||||
<field name="act_from" ref="act_opening_control" />
|
||||
<field name="act_to" ref="act_open" />
|
||||
<field name="signal" eval="False" />
|
||||
<field name="condition">not has_opening_control()</field>
|
||||
</record>
|
||||
-->
|
||||
|
||||
<record model="workflow.transition" id="trans_open_to_closing_control">
|
||||
<field name="act_from" ref="act_open" />
|
||||
<field name="act_to" ref="act_closing_control" />
|
||||
<field name="signal">cashbox_control</field>
|
||||
<field name="condition">has_closing_control == True</field>
|
||||
</record>
|
||||
|
||||
<!--
|
||||
<record model="workflow.transition" id="trans_closing_control_to_close_automatic">
|
||||
<field name="act_from" ref="act_closing_control" />
|
||||
<record model="workflow.transition" id="trans_open_to_close">
|
||||
<field name="act_from" ref="act_open" />
|
||||
<field name="act_to" ref="act_close" />
|
||||
<field name="signal" eval="False" />
|
||||
<field name="condition">not has_closing_control()</field>
|
||||
<field name="signal">close</field>
|
||||
<field name="condition">has_closing_control == False</field>
|
||||
</record>
|
||||
-->
|
||||
|
||||
<record model="workflow.transition" id="trans_closing_control_to_close">
|
||||
<field name="act_from" ref="act_closing_control" />
|
||||
|
|
|
@ -22,11 +22,11 @@ class pos_session_opening(osv.osv_memory):
|
|||
'config_id' : wizard.pos_config_id.id,
|
||||
}
|
||||
session_id = proxy.create(cr, uid, values, context=context)
|
||||
if all(journal.opening_control == False
|
||||
for journal in wizard.pos_config_id.journal_ids):
|
||||
# if all(journal.opening_control == False
|
||||
# for journal in wizard.pos_config_id.journal_ids):
|
||||
|
||||
wkf_service = netsvc.LocalService('workflow')
|
||||
wkf_service.trg_validate(uid, 'pos.session', session_id, 'open', cr)
|
||||
# wkf_service = netsvc.LocalService('workflow')
|
||||
# wkf_service.trg_validate(uid, 'pos.session', session_id, 'open', cr)
|
||||
return self._open_session(session_id)
|
||||
return self._open_session(wizard.pos_session_id.id)
|
||||
|
||||
|
|
Loading…
Reference in New Issue