Hello, I'm using Odoo 10 in english. I'm a novice.
In purchase order page I add a dropdown with a reference to Sale Order.
In PurchaseOrder inherited model, I wrote following code:
@api.onchange('sale_order_id')
def onchange_sale_order_lines(self):
model_purchase_order_line = self.env['purchase.order.line']
for so_line in self.sale_order_id.order_line:
vals = {}
vals['order_id'] = self._origin.id
vals['product_id'] = so_line.product_id.id
vals['product_qty'] = so_line.product_uom_qty
vals['product_uom'] = so_line.product_uom.id
vals['price_unit'] = so_line.price_unit
vals['price_total'] = so_line.price_total
vals['price_tax'] = so_line.price_tax
vals['name'] = so_line.name
vals['date_planned'] = date.today()
model_purchase_order_line.create(vals)but when sale order dropdown changes, I have the following error (Odoo administrator user set to english language):
Traceback (most recent call last):
File "/home/odooadmin/OCB/odoo/http.py", line 642, in _handle_exception
return super(JsonRequest, self)._handle_exception(exception)
File "/home/odooadmin/OCB/odoo/http.py", line 684, in dispatch
result = self._call_function(**self.params)
File "/home/odooadmin/OCB/odoo/http.py", line 334, in _call_function
return checked_call(self.db, *args, **kwargs)
File "/home/odooadmin/OCB/odoo/service/model.py", line 101, in wrapper
return f(dbname, *args, **kwargs)
File "/home/odooadmin/OCB/odoo/http.py", line 327, in checked_call
result = self.endpoint(*a, **kw)
File "/home/odooadmin/OCB/odoo/http.py", line 942, in __call__
return self.method(*args, **kw)
File "/home/odooadmin/OCB/odoo/http.py", line 507, in response_wrap
response = f(*args, **kw)
File "/home/odooadmin/OCB/addons/web/controllers/main.py", line 895, in call_kw
return self._call_kw(model, method, args, kwargs)
File "/home/odooadmin/OCB/addons/web/controllers/main.py", line 887, in _call_kw
return call_kw(request.env[model], method, args, kwargs)
File "/home/odooadmin/OCB/odoo/api.py", line 689, in call_kw
return call_kw_multi(method, model, args, kwargs)
File "/home/odooadmin/OCB/odoo/api.py", line 678, in call_kw_multi
recs = self.with_context(context or {}).browse(ids)
File "/home/odooadmin/OCB/odoo/models.py", line 4835, in browse
return self._browse(ids, self.env, prefetch)
File "/home/odooadmin/OCB/odoo/models.py", line 4822, in _browse
prefetch[cls._name].update(ids)
TypeError: unhashable type: 'list'unexpectedly, when I switch to italian language, I have a different error:
(translated from italian)
The operation cannot probably be concluded for the following reasons:
- elimination: other recordings refer to the registration that we want to delete
- creation / modification: a mandatory field is not filled in correctly
[object with reference: order_id - order.id]
I don't understand which is the problem, can you help me?
thanks in advance
Tony
Do you want to create sale order from purchase order?