【问题标题】:TypeError: 'int' object is not iterable in wizardTypeError:“int”对象在向导中不可迭代
【发布时间】:2018-11-19 18:44:27
【问题描述】:

我的代码有问题。

 if not context.get('account_id', False):
     wizard_id = self.env.get('ir.model.data').get_object_reference('l10n_mn_consume_order', 'action_consumable_material_in_use_wizard')[1]
     result = **self.env.get('ir.actions.act_window').read(wizard_id)**
     result['context'] = dict(self.context.items(), active_id=asset.id, active_ids=[asset.id])
     return result
     print 'some action'

错误是:

文件“/home/delgertsetseg/workspace/odoo/addons/web/controllers/main.py”,第 877 行,在 _call_kw
return call_kw(request.env[model], method, args, kwargs)
文件“/home/delgertsetseg/workspace/odoo/odoo/api.py”,第 689 行,在 call_kw
返回 call_kw_multi(方法、模型、参数、kwargs)
文件“/home/delgertsetseg/workspace/odoo/odoo/api.py”,第 680 行,在 call_kw_multi
结果 = 方法(recs,*args,**kwargs)
文件“/home/delgertsetseg/workspace/oderp10/addons/l10n_mn_consume_order /models/consume_material_in_use.py”,第 113 行,在 button_done
结果 = self.env.get('ir.actions.act_window').read(wizard_id)
文件“/home/delgertsetseg/workspace/odoo/odoo/addons/base/ir/ir_actions.py”,第 317 行,已读
结果 = super(IrActionsActWindow, self).read(fields, load=load)
文件“/home/delgertsetseg/workspace/odoo/odoo/models.py”,第 2993 行,在字段中的 readfor 名称中: TypeError: 'int' 对象不可迭代

正如你看到我的问题。 我需要使用向导中传递的值进行操作。然后我有一些行动 我正在尝试这个解决方案:

return {
                'name': _('Account?'),
                'type': 'ir.actions.act_window',
                'view_type': 'form',
                'view_mode': 'form',
                'res_model': 'consumable.material.in.use.wizard',
                'views': [(view.id, 'form')],
                'view_id': view.id,
                'target': 'new',
#                 'res_id': wiz.id,
                'context': self.env.context,
            }

解决方案无法运行return after code。

我没有在向导中传递值。

请帮帮我。

【问题讨论】:

    标签: odoo wizard iterable


    【解决方案1】:

    错误似乎是由于 l10n_mn_consume_orderbutton_done 方法造成的,您试图在该方法中返回一个操作。

    这是克服错误的可能解决方案。

    @api.multi
    def button_done(self):
        self.ensure_one()
        # your code here
        action = self.env.ref('l10n_mn_consume_order.wizard_action_id').read()[0] 
        # replace the wizard_action_id with your wizard's action
        action['context'] = dict(self.context.items(), active_id=asset.id, active_ids=[asset.id])
        return action
    

    确保在向导视图文件中ir.actions.act_window记录存在。

    希望这会有所帮助。

    【讨论】:

    • 谢谢,改一下错误:AttributeError: 'consumable.material.in.use' object has no attribute 'context' 而我的功能是:
    • 不需要参数上下文。 def button_done(self): 很好。
    • 您可以从self.env.context 访问上下文,这将是frozendict。
    猜你喜欢
    • 2017-09-11
    • 1970-01-01
    • 2023-01-22
    • 2015-12-03
    • 1970-01-01
    • 2018-09-29
    • 2020-02-26
    • 2015-04-06
    相关资源
    最近更新 更多