预期的单例:stock.move-Odoo v9社区 [英] Expected singleton: stock.move - Odoo v9 community

查看:108
本文介绍了预期的单例:stock.move-Odoo v9社区的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用以下方法从fleet_vehicle_log_services创建一个stock.picking:

I'm creating a stock.picking from fleet_vehicle_log_services with this method:

@api.multi
def create_picking(self):
    self.ensure_one()
    vals = {
        'move_lines': self.move_lines.id,
        'origin': self.name
    }
    picking = self.env['stock.picking'].create(vals)
    return picking

它在fields上这样声明:

move_lines = fields.One2many('stock.move', 'picking_id', string="Stock Moves", copy=True)

我的观点:

    <group string="Datos del picking">
       <button name="create_picking" string="Crear Picking" type="object" class="oe_highlight"/>
                        <tree>
                            <field name="move_lines" string="Lineas"/>
                            <field name="state" invisible="1"/>
                        </tree>
                </group>

当我单击创建选择"时,它会向我抛出:

When I click on create the picking it throws me this:

Traceback (most recent call last):
File "/home/kristian/odoov9/odoo-9.0c-20161106/openerp/http.py", line 648, in _handle_exception
return super(JsonRequest, self)._handle_exception(exception)
File "/home/kristian/odoov9/odoo-9.0c-20161106/openerp/http.py", line 685, in dispatch
result = self._call_function(**self.params)
File "/home/kristian/odoov9/odoo-9.0c-20161106/openerp/http.py", line 321, in _call_function
return checked_call(self.db, *args, **kwargs)
File "/home/kristian/odoov9/odoo-9.0c-20161106/openerp/service/model.py", line 118, in wrapper
return f(dbname, *args, **kwargs)
File "/home/kristian/odoov9/odoo-9.0c-20161106/openerp/http.py", line 314, in checked_call
result = self.endpoint(*a, **kw)
File "/home/kristian/odoov9/odoo-9.0c-20161106/openerp/http.py", line 964, in __call__
return self.method(*args, **kw)
File "/home/kristian/odoov9/odoo-9.0c-20161106/openerp/http.py", line 514, in response_wrap
response = f(*args, **kw)
File "/home/kristian/odoov9/odoo-9.0c-20161106/openerp/addons/web/controllers/main.py", line 892, in call_button
action = self._call_kw(model, method, args, {})
File "/home/kristian/odoov9/odoo-9.0c-20161106/openerp/addons/web/controllers/main.py", line 880, in _call_kw
return getattr(request.registry.get(model), method)(request.cr, request.uid, *args, **kwargs)
File "/home/kristian/odoov9/odoo-9.0c-20161106/openerp/api.py", line 250, in wrapper
return old_api(self, *args, **kwargs)
File "/home/kristian/odoov9/odoo-9.0c-20161106/openerp/api.py", line 381, in old_api
result = method(recs, *args, **kwargs)
File "/home/kristian/odoov9/danisan/fleet_stock/models/fleet_vehicle_services.py", line 215, in create_picking
'move_lines': self.move_lines.id,
File "/home/kristian/odoov9/odoo-9.0c-20161106/openerp/fields.py", line 2030, in __get__
return record.ensure_one()._ids[0]
File "/home/kristian/odoov9/odoo-9.0c-20161106/openerp/models.py", line 5420, in ensure_one
raise ValueError("Expected singleton: %s" % self)
ValueError: Expected singleton: stock.move(45, 68)

有什么想法吗?

推荐答案

一个字段很多需要特殊的命令才能插入.就您而言:

One2many fields need special commands for inserting. In your case:

 vals = {
        'move_lines': [(6, 0, self.move_lines.ids)],
        'origin': self.name
    }

请阅读 查看全文

登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆