在openerp中确认具有动态文本的条件对话框
我发现下面弹出了一个关于openerp中按钮按下操作的确认对话框在openerp中确认具有动态文本的条件对话框,openerp,Openerp,我发现下面弹出了一个关于openerp中按钮按下操作的确认对话框 <button name="action_button_confirm" states="draft" string="Confirm Sale" type="object" groups="base.group_user" confirm="Do you confirm this sale?"/> 其中Ac Services是服务产品名称(即基于订单行的动态文本)。请给我一个建议。谢谢如果您想自定义此功能,那么您
<button name="action_button_confirm" states="draft" string="Confirm Sale"
type="object" groups="base.group_user" confirm="Do you confirm this sale?"/>
其中Ac Services是服务产品名称(即基于订单行的动态文本)。请给我一个建议。谢谢如果您想自定义此功能,那么您需要使用向导 扩展表单并将按钮名称更改为确定是否需要显示向导的方法(返回包含窗口操作的词典),或直接调用现有操作按钮确认方法。然后,如果用户单击“确定”,向导可以调用“操作”按钮确认
这当然是可以做到的,但对于大多数用户无论如何都忽略的警告来说,这有点麻烦。我已经创建了一个向导,用于在某个条件下发出警报,这对我来说做得很好。对于有类似问题的人,我将我的想法放在下面 我的新向导类
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>
谢谢大家,干杯 这有点棘手,你可以通过返回OE方法的操作来实现这一点,我过去也做过这种确认消息,谢谢Adrian的回答。不幸的是,在你的答案到达之前,我已经完成了这项工作。然而,这是我先前选择的道路。我也会投票给其他人。非常感谢您的支持,请检查我的答案。
<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>
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,
}