Help

0

Automated Action: Create delivery order from production order.

Avatar
Jan Krähling

Hello,

I use the community version of Odoo 13.

By the way sorry for my bad english.


I created the automated action so far, everything works exept the recording of the product ids for the field "move_ids_without_package".

I dont use the sale module, that is because i need this automated action.


I tried to get the product ids in the module mrp.production from the field "finished_move_line_ids" with the python code "record.move_finished_ids.id" or "record.move_finished_ids.ids" but i get Errors like:


TypeError: object of type 'int' has no len()
TypeError: can only concatenate list (not "int") to list

What would be the right python code or do i have to create a new field based on the product ids in the production order?


Avatar
Discard
1 Answer
0
Avatar
ti-sq
Best Answer

Hi Jan,

what about using only finished_move_line_ids? Without the endings '.id'/'.ids'. Because this field is a list and has a length, so I suppose that this should work.


I see that was the wrong approach. Could you possibly post your code?

1 Comment
Avatar
Discard
Avatar
Jan Krähling
-

I tried it, but i get this error:

Odoo Server Error

Traceback (most recent call last):

File "C:\Program Files (x86)\Odoo 13.0\server\odoo\http.py", line 619, in _handle_exception

return super(JsonRequest, self)._handle_exception(exception)

File "C:\Program Files (x86)\Odoo 13.0\server\odoo\http.py", line 309, in _handle_exception

raise pycompat.reraise(type(exception), exception, sys.exc_info()[2])

File "C:\Program Files (x86)\Odoo 13.0\server\odoo\tools\pycompat.py", line 14, in reraise

raise value

File "C:\Program Files (x86)\Odoo 13.0\server\odoo\http.py", line 664, in dispatch

result = self._call_function(**self.params)

File "C:\Program Files (x86)\Odoo 13.0\server\odoo\http.py", line 345, in _call_function

return checked_call(self.db, *args, **kwargs)

File "C:\Program Files (x86)\Odoo 13.0\server\odoo\service\model.py", line 93, in wrapper

return f(dbname, *args, **kwargs)

File "C:\Program Files (x86)\Odoo 13.0\server\odoo\http.py", line 338, in checked_call

result = self.endpoint(*a, **kw)

File "C:\Program Files (x86)\Odoo 13.0\server\odoo\http.py", line 909, in __call__

return self.method(*args, **kw)

File "C:\Program Files (x86)\Odoo 13.0\server\odoo\http.py", line 510, in response_wrap

response = f(*args, **kw)

File "C:\Program Files (x86)\Odoo 13.0\server\odoo\addons\web\controllers\main.py", line 1324, in call_button

action = self._call_kw(model, method, args, kwargs)

File "C:\Program Files (x86)\Odoo 13.0\server\odoo\addons\web\controllers\main.py", line 1312, in _call_kw

return call_kw(request.env[model], method, args, kwargs)

File "C:\Program Files (x86)\Odoo 13.0\server\odoo\api.py", line 395, in call_kw

result = _call_kw_multi(method, model, args, kwargs)

File "C:\Program Files (x86)\Odoo 13.0\server\odoo\api.py", line 382, in _call_kw_multi

result = method(recs, *args, **kwargs)

File "C:\Program Files (x86)\Odoo 13.0\server\odoo\addons\mrp\models\mrp_production.py", line 932, in button_mark_done

self.post_inventory()

File "C:\Program Files (x86)\Odoo 13.0\server\odoo\addons\mrp\models\mrp_production.py", line 907, in post_inventory

moves_to_finish = moves_to_finish._action_done()

File "C:\Program Files (x86)\Odoo 13.0\server\odoo\addons\stock\models\stock_move.py", line 1404, in _action_done

moves_todo.mapped('move_line_ids').sorted()._action_done()

File "C:\Program Files (x86)\Odoo 13.0\server\odoo\addons\stock\models\stock_move_line.py", line 472, in _action_done

available_qty, in_date = Quant._update_available_quantity(ml.product_id, ml.location_id, -quantity, lot_id=ml.lot_id, package_id=ml.package_id, owner_id=ml.owner_id)

File "C:\Program Files (x86)\Odoo 13.0\server\odoo\addons\stock\models\stock_quant.py", line 401, in _update_available_quantity

with self._cr.savepoint():

File "C:\Program Files (x86)\Odoo 13.0\python\lib\contextlib.py", line 112, in __enter__

return next(self.gen)

File "C:\Program Files (x86)\Odoo 13.0\server\odoo\sql_db.py", line 427, in savepoint

flush_env(self)

File "C:\Program Files (x86)\Odoo 13.0\server\odoo\sql_db.py", line 67, in flush_env

env['base'].flush()

File "C:\Program Files (x86)\Odoo 13.0\server\odoo\models.py", line 5368, in flush

self.recompute()

File "C:\Program Files (x86)\Odoo 13.0\server\odoo\models.py", line 5770, in recompute

process(next(iter(fields_to_compute)))

File "C:\Program Files (x86)\Odoo 13.0\server\odoo\models.py", line 5753, in process

recs.mapped(field.name)

File "C:\Program Files (x86)\Odoo 13.0\server\odoo\models.py", line 5185, in mapped

recs = recs._mapped_func(operator.itemgetter(name))

File "C:\Program Files (x86)\Odoo 13.0\server\odoo\models.py", line 5144, in _mapped_func

vals = [func(rec) for rec in self]

File "C:\Program Files (x86)\Odoo 13.0\server\odoo\models.py", line 5144, in <listcomp>

vals = [func(rec) for rec in self]

File "C:\Program Files (x86)\Odoo 13.0\server\odoo\models.py", line 5589, in __getitem__

return self._fields[key].__get__(self, type(self))

File "C:\Program Files (x86)\Odoo 13.0\server\odoo\fields.py", line 973, in __get__

self.compute_value(recs)

File "C:\Program Files (x86)\Odoo 13.0\server\odoo\fields.py", line 1087, in compute_value

records._compute_field_value(self)

File "C:\Program Files (x86)\Odoo 13.0\server\odoo\addons\base_automation\models\base_automation.py", line 307, in _compute_field_value

action._process(records, domain_post=domain_post)

File "C:\Program Files (x86)\Odoo 13.0\server\odoo\addons\base_automation\models\base_automation.py", line 207, in _process

self.action_server_id.with_context(**ctx).run()

File "C:\Program Files (x86)\Odoo 13.0\server\odoo\addons\base\models\ir_actions.py", line 561, in run

res = func(action, eval_context=eval_context)

File "C:\Program Files (x86)\Odoo 13.0\server\odoo\addons\base\models\ir_actions.py", line 467, in run_action_object_create

res = self.env[action.crud_model_id.model].create(res)

File "<decorator-gen-139>", line 2, in create

File "C:\Program Files (x86)\Odoo 13.0\server\odoo\api.py", line 322, in _model_create_single

return create(self, arg)

File "C:\Program Files (x86)\Odoo 13.0\server\odoo\addons\stock\models\stock_picking.py", line 557, in create

moves = vals.get('move_lines', []) + vals.get('move_ids_without_package', [])

TypeError: can only concatenate list (not "stock.move.line") to list