Python 选择所有记录id';来自Odoo联系人列表视图的

Python 选择所有记录id';来自Odoo联系人列表视图的,python,xml,listview,odoo-9,Python,Xml,Listview,Odoo 9,我在.py文件中编写了一些python代码来显示向导 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,

我在.py文件中编写了一些python代码来显示向导

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, self._context.get('active_ids',[]))]
    })

感谢

ValueError:“'res.partner'对象在计算u时没有属性'env'”,如果上下文.get('active_model')=='res.partner'和context.get('active_id'):\n action=self.pool['res.partner'].distance_-to_搜索(cr,uid,context.get('active_id')”)”
从xml获取此错误。有什么想法吗?是的,您使用了旧语法。在xml的代码字段中使用此代码:if context.get('active_model')='res.partner'和context.get('active_id'):action=self.pool.get('res.partner')。result_to_search(cr、uid、context.get('active_id'))
wizard = self.pool['sale.example_wizard'].create(cr, uid, vals={
        'partner_ids': [(6, 0, self._context.get('active_ids',[]))]
    })