我已經創建了一個條件警報的嚮導,並且對我做的很好。具有類似人的概率我按我的想法如下
我的新嚮導類
class sale_order_confirm(osv.osv):
_name = "sale.order.confirm"
_description = "Sales Order Confirm"
def action_confirm(self, cr, uid, ids, context=None):
assert len(ids) == 1, 'This option should only be used for a single id at a time.'
wf_service = netsvc.LocalService('workflow')
wf_service.trg_validate(uid, 'sale.order', ids[0], 'order_confirm', cr)
# redisplay the record as a sales order
view_ref = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'sale', 'view_order_form')
view_id = view_ref and view_ref[1] or False,
return {
'type': 'ir.actions.act_window',
'name': _('Sales Order'),
'res_model': 'sale.order',
'res_id': ids[0],
'view_type': 'form',
'view_mode': 'form',
'view_id': view_id,
'target': 'current',
'nodestroy': True,
}
sale_order_confirm()
我的觀點記錄
<record id="view_cancel_order" model="ir.ui.view">
<field name="name">Cancel Repair</field>
<field name="model">sale.order.confirm</field>
<field name="arch" type="xml">
<form string="Confirm Sale Order" version="7.0">
<group>
<label string="This Sale Order will be confirmed with service Product. Agree?"/>
</group>
<footer>
<button name="action_confirm" string="Yes" type="object" class="oe_highlight"/>
or
<button string="Cancel" class="oe_link" special="cancel" />
</footer>
</form>
</field>
</record>
我已經改變了我action_button_confirm功能在sale_order .py有點
def action_button_confirm(self, cr, uid, ids, context=None):
assert len(ids) == 1, 'This option should only be used for a single id at a time.'
is_optional_item_exists = False # here i can check for wt ever condition and this variable will have the resul
so_obj = self.browse(cr, uid, ids, context)
if so_obj:
for line in so_obj[0].order_line:
print line.name
if line.is_optional_item:
is_optional_item_exists = True
if(is_optional_item_exists):
return {
'name': 'Order Confirmation',
'view_type': 'form',
'view_mode': 'form',
'res_model': 'sale.order.confirm',
'type': 'ir.actions.act_window',
'nodestroy': True,
'target': 'new',
}
else:
wf_service = netsvc.LocalService('workflow')
wf_service.trg_validate(uid, 'sale.order', ids[0], 'order_confirm', cr)
# redisplay the record as a sales order
view_ref = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'sale', 'view_order_form')
view_id = view_ref and view_ref[1] or False,
return {
'type': 'ir.actions.act_window',
'name': _('Sales Order'),
'res_model': 'sale.order',
'res_id': ids[0],
'view_type': 'form',
'view_mode': 'form',
'view_id': view_id,
'target': 'current',
'nodestroy': True,
}
謝謝大家,歡呼!
這有點棘手,你可以通過從OE方法返回行動來實現這一點,我已經在過去做過這種確認信息, –