0
我已经写了一些Python代码在我的.py文件中显示的向导选择所有记录ID从Odoo联系人列表视图的
class DisplayWindow(models.Model):
_inherit = 'res.partner'
wizard_id = fields.Many2one('sale.example_wizard')
def result_to_search(self, cr, uid, active_ids):
wizard = self.pool['sale.example_wizard'].create(cr, uid, vals={
'partner_ids': [(6, 0, active_ids)]
})
return {
'name': _('Account Search'),
'type': 'ir.actions.act_window',
'res_model': 'sale.example_wizard',
'res_id': wizard,
'view_type': 'form',
'view_mode': 'form',
'target': 'new',
}
,这里是我的.xml文件
<openerp>
<data>
<!--This xml file is responsible for the server action of displaying the wizard-->
<record model="ir.actions.server" id="action_search_for_result">
<field name="name">Account Search</field>
<field name="model_id" ref="sale.model_res_partner"/>
<field name="code">
if context.get('active_model') == 'res.partner' and context.get('active_ids'):
action = self.pool['res.partner'].result_to_search(cr, uid, context.get('active_ids'))
</field>
</record>
<record model="ir.values" id="search_result">
<field name="model_id" ref="sale.model_res_partner"/>
<field name="name">Account Search</field>
<field name="key2">client_action_multi</field>
<!--automatically attach action to the dropdown button-->
<field name="value" eval="'ir.actions.server,' +str(ref('action_search_for_result'))"/>
<field name="key">action</field>
<field name="model">res.partner</field>
</record>
</data>
</openerp>
我的问题是当我从顾客的列表视图中选择所有客户时,只选择第一页联系人以及我为向导的按钮编写的任何代码,但它仅适用于第一页的客户。但是,我期望的结果假定适用于我拥有的所有客户数据库。 也许我做错了什么用这段代码
wizard = self.pool['sale.example_wizard'].create(cr, uid, vals={
'partner_ids': [(6, 0, active_ids)]
})
请帮助我。如果需要,我可以解释更多。谢谢
'ValueError异常: “ 'res.partner' 对象没有属性 'ENV'” 而评估 U“如果context.get( 'active_model')== 'res.partner' 和distance.to_search(cr,uid,context.get('active_ids'))“'从xml.Any中获取这个错误。理念? – Paramita
是的,您已经使用过旧的语法。 –
在xml的代码字段中使用此代码:if context.get('active_model')=='res.partner'和context.get('active_ids'): action = self.pool.get('res.partner' ).result_to_search(cr,uid,context.get('active_ids')) –