AttributeError:'dict'对象没有属性'id' - 新API [Odoo / Openerp]

时间:2016-03-24 08:42:51

标签: python opencv odoo-8

我正在尝试在Odoo中使用新的API。 (仍然不太熟悉)

我创建了一个继承'sale.order'对象的模块。我在'action_button_confirm'方法中添加了代码,如果我的条件为真,则返回向导,我想在create方法中传输代码但是每当它返回向导时我都会收到错误:

AttributeError: 'dict' object has no attribute 'id'

.py文件

class sale_order(models.Model):
_inherit = "sale.order"

    @api.model
    def create(self, vals):
        res = super(sale_order, self).create(vals)
        return self.action_try(res)

    def action_try(self, res):
        for order_id in res:
            #codes

            if my_condition:
                return {
                'name': 'My wizard',
                'view_mode': 'form',
                'view_type': 'form',
                'res_model': 'my.wizard',
                'type': 'ir.actions.act_window',
                'nodestroy': True,
                'target': 'new',
                'context': {
                            #fields
                            }
                        }

其他信息

Traceback (most recent call last):
  File "/home/workspace/odoo8/openerp/http.py", line 537, in _handle_exception
    return super(JsonRequest, self)._handle_exception(exception)
  File "/home/workspace/odoo8/openerp/http.py", line 574, in dispatch
    result = self._call_function(**self.params)
  File "/home/workspace/odoo8/openerp/http.py", line 310, in _call_function
    return checked_call(self.db, *args, **kwargs)
  File "/home/workspace/odoo8/openerp/service/model.py", line 118, in wrapper
    return f(dbname, *args, **kwargs)
  File "/home/workspace/odoo8/openerp/http.py", line 307, in checked_call
    return self.endpoint(*a, **kw)
  File "/home/workspace/odoo8/openerp/http.py", line 803, in __call__
    return self.method(*args, **kw)
  File "/home/workspace/odoo8/openerp/http.py", line 403, in response_wrap
    response = f(*args, **kw)
  File "/home/workspace/odoo8/addons/web/controllers/main.py", line 944, in call_kw
    return self._call_kw(model, method, args, kwargs)
  File "/home/workspace/odoo8/addons/web/controllers/main.py", line 936, in _call_kw
    return getattr(request.registry.get(model), method)(request.cr, request.uid, *args, **kwargs)
  File "/home/workspace/odoo8/openerp/api.py", line 268, in wrapper
    return old_api(self, *args, **kwargs)
  File "/home/workspace/odoo8/openerp/api.py", line 373, in old_api
    return downgrade(recs, result, *args, **kwargs)
  File "/home/workspace/odoo8/openerp/api.py", line 291, in <lambda>
    return lambda self, *args, **kwargs: downgrade(args[0])
  File "/home/workspace/odoo8/openerp/models.py", line 4049, in <lambda>
    @api.returns('self', lambda value: value.id)
AttributeError: 'dict' object has no attribute 'id'

我没有包含我的代码,因为它没有任何问题(我手动检查),只有当它返回向导时才会出现错误。

0 个答案:

没有答案