TypeError:类型'bool'的参数在openerp中不可迭代

时间:2013-10-09 06:21:05

标签: python field openerp

事情就是这样:我想在view_employee_tree模块中继承moudle - hr:的树视图(id为“hr_contract”)。     这是我的代码:

 <record id="hr_contract_hr_employee_tree" model="ir.ui.view">
                <field name="name">hr.contract.hr.employee.tree</field>
                <field name="model">hr.employee</field>
                <field name="inherit_id" ref="hr.view_employee_tree"/>
                <field name="arch" type="xml">
                    <field name="work_phone" position="after">
                        <field name="contract_ids"/>
                    </field>
                </field>
            </record>

更新模块后(hr,hr_contract),我得到如下错误:)

OpenERP Server Error Client Traceback (most recent call last): 

File "d:\Program Files\OpenERP7.0-20130726-231403\Server\server\openerp\addons\web\http.py", line 204, in dispatch   
File "d:\Program Files\OpenERP7.0-20130726-231403\Server\server\openerp\addons\web\controllers\main.py", line 1128, in call_kw   
File "d:\Program Files\OpenERP7.0-20130726-231403\Server\server\openerp\addons\web\controllers\main.py", line 1120, in _call_kw   
File "d:\Program Files\OpenERP
        7.0-20130726-231403\Server\server\openerp\addons\web\session.py", line 42, in proxy   
File "d:\Program Files\OpenERP
        7.0-20130726-231403\Server\server\openerp\addons\web\session.py", line 30, in proxy_method   File "d:\Program Files\OpenERP
        7.0-20130726-231403\Server\server\openerp\addons\web\session.py", line 103, in send


Server Traceback (most recent call last): 

File "d:\Program Files\OpenERP
        7.0-20130726-231403\Server\server\openerp\addons\web\session.py", line 89, in send   
File "D:\Program Files\OpenERP
        7.0-20130726-231403\Server\server\.\openerp\netsvc.py", line 292, in dispatch_rpc   
File "D:\Program Files\OpenERP
        7.0-20130726-231403\Server\server\.\openerp\service\web_services.py", line 626, in dispatch
File "D:\Program Files\OpenERP
        7.0-20130726-231403\Server\server\.\openerp\osv\osv.py", line 188, in execute_kw   
File "D:\Program Files\OpenERP
        7.0-20130726-231403\Server\server\.\openerp\osv\osv.py", line 131, in wrapper   
File "D:\Program Files\OpenERP
        7.0-20130726-231403\Server\server\.\openerp\osv\osv.py", line 197, in execute   
File "D:\Program Files\OpenERP
        7.0-20130726-231403\Server\server\.\openerp\osv\osv.py", line 185, in execute_cr   
File "D:\Program Files\OpenERP
        7.0-20130726-231403\Server\server\.\openerp\osv\orm.py", line 2290, in fields_view_get   
File "D:\Program Files\OpenERP
        7.0-20130726-231403\Server\server\.\openerp\osv\orm.py", line 2270, in clean TypeError: 
    argument of type 'bool' is not iterable

我一直跟踪这个bug一整天。我转到文件:\openerp\osv\orm.py,并获取2270行附近的代码:

            ir_values_obj = self.pool.get('ir.values')
            resprint = ir_values_obj.get(cr, user, 'action',
                    'client_print_multi', [(self._name, False)], False,
                    context)
            resaction = ir_values_obj.get(cr, user, 'action',
                    'client_action_multi', [(self._name, False)], False,
                    context)

            resrelate = ir_values_obj.get(cr, user, 'action',
                    'client_action_relate', [(self._name, False)], False,
                    context)

            #I added this for output
            for action in resaction:
                print 'orm debug : '
                print 'action[1]:',action[1]
                print 'action[2]',action[2]

            resaction = [clean(action) for action in resaction
                         if view_type == 'tree' or not action[2].get('multi')]
            resprint = [clean(print_) for print_ in resprint
                        if view_type == 'tree' or not print_[2].get('multi')]
            #When multi="True" set it will display only in More of the list view 
            resrelate = [clean(action) for action in resrelate
                         if (action[2].get('multi') and view_type == 'tree') or (not action[2].get('multi') and view_type == 'form')]

            for x in itertools.chain(resprint, resaction, resrelate):
                x['string'] = x['name']

我添加了print代码来输出var:resaction,这是输出:

输出:

orm_debug:
Subordinate Hierarchy
False

出色!似乎错误:TypeError: argument of type 'bool' is not iterable是有道理的。 Subordinate Hierarchy是文件hr_view.xml中act_window的名称:

<record id="action2" model="ir.actions.act_window">
        <field name="name">Subordinate Hierarchy</field>
        <field name="type">ir.actions.act_window</field>
        <field name="res_model">hr.employee</field>
        <field name="domain">[('id','in',active_ids)]</field>
        <field name="view_type">tree</field>
        <field name="view_id" ref="view_partner_tree2"/>
        <field name="view_id" ref="view_employee_tree"/>
</record>

但真正的问题是什么? 我做错了什么 ?

任何帮助都非常感谢!!在此先感谢!!

1 个答案:

答案 0 :(得分:0)

将这两个视图链接起来:

<record id="action2" model="ir.actions.act_window">
        <field name="name">Subordinate Hierarchy</field>
        <field name="type">ir.actions.act_window</field>
        <field name="res_model">hr.employee</field>
        <field name="domain">[('id','in',active_ids)]</field>
        <field name="view_type">tree</field>
</record>

    <record model="ir.actions.act_window.view" id="action_action2_tree2">
        <field name="sequence" eval="1"/>
        <field name="view_mode">tree</field>
        <field name="view_id" ref="view_partner_tree2"/>
        <field name="act_window_id" ref="action2"/>
    </record>
    <record model="ir.actions.act_window.view" id="action_action2_tree1">
        <field name="sequence" eval="2"/>
        <field name="view_mode">tree</field>
        <field name="view_id" ref="view_employee_tree"/>
        <field name="act_window_id" ref="action2"/>
    </record>

这应解决问题。

谢谢