Skip to Content
Menu
This question has been flagged

Hello, 

I am struggling to implement creation of manufacturing orders via XML RPC API.

The particular challenge here: both (some of) the components _and_ the finished product are tracked by serial number. My goal is to create a manufacturing order for a whole batch of the product (let's say 500 pieces), then break it down in to 500 backorders (1 piece each, carrying the S/N of the finished products and having the components serial numbers tracked).

It looks like I found a way to achieve it, but to me it looks like plain DB manipulation and I am afraid it is preventing normal checks being applied and thus potentially leading to an inconsistent data base?

My approach works like this:

1. Create manufacuring order for X pieces and call "action_confirm" & "action_assign" on it

2. This fills the "move_raw_ids" and "move_raw_line_ids" in the MO

3. I'm setting the "lot_producing_id" to the desired S/N of the finished product

4. In the "move_raw_ids" stock moves I am setting "next_serial" to the S/N and "should_consume_quantity" to 1

5. In the stock move I am setting in every move line: lot_id,  qty_done, is_completed, manual_consumption.

6. Then I'm creating a record in stock.assign.serial with all the serial numbers for all the products to be produced, and finally

7. I am calling "apply" on it which is creating all the backorders.


Is this the right way of doing it? How would it be done when doing this through the UI manually?

I'm a bit afraid as I realized during my testing that you can even execute the manufacturing orders created when some of the components are not available - leading to negative inventory and similar things...

Any general suggestions about how to create "mass" manufactoring orders with serial numbers?

Thanks in advance for any furthe hints..

Portretas
Atmesti
Related Posts Replies Rodiniai Veikla
0
spal. 22
4558
1
liep. 22
3819
0
geg. 20
3782
1
kov. 23
2918
2
lapkr. 22
3535