Skip to Content
Menu
This question has been flagged
3 Replies
1904 Views

I am working on an MES integration with Odoo for a control system. I am able to select a manufacturing order, start production, modify produced and consumed quantities, and end production. However, while inventory moves are registered, they are not updated in inventory (quantity available). 

I execute read/write methods on the following models for the integration: 

​mrp.production

​stock.move

​stock.move.line

​product.template

I also create a stock.valuation.layer record for all of the material. 

Everything executes as expected, except when the production is complete. none of the inventory quantities adjust.

Thoughts?

Avatar
Discard
Best Answer

I would think to process as it would have been done with manual entry.

In settings for manufacturing you must have flagged "Unlock manufacturing orders" to allow flexible consumption.

Be sure that you have set Flexible Consumption to Allowed in the BOM, and Manual consumption is flagged for the components.  (I assume you do not.

You must make sure you have filled the field qty_done in the stock move line for the components, which is the actual consumed qty.  Else you will only post what is planned.  

For produce fill the field qty_producing in mrp.production.

The result should be that the order get status = To close (field state in mrp.production).

Use the action "button_mark_done" and (of course) select only the actual manufacturing order.  You will use the standard Odoo processing. It will do several posting in the background: Material movements, Accounting entries, and product valuation.  So you should not need to send anything to stock valuation layer or stock.move.

But for Button Mark done action I have configured an automatic action, that run when field state is changed into "To Close". 

model.search([('state', '=', 'to_close')]).button_mark_done()

Why do you update in product.template? Product template is masterdata, and it is not logic to update when processing confirmation of manufacturing?

Hope this helps you.


Avatar
Discard
Author

Lars,

Thank you for your help. I did not have the "Unlock Manufacturing Orders" checked. It appears this was the missing piece. I have outline additional steps needed.

Flexible Consumption was Allowed.

There is not a field "qty_done" in stock.move.line model. In stock.move the field "quantity" is updated to reflect material in actuals. This will create/edit lines in stock.move.line model.

I need to set the field "picked" to True in stock.move model. Otherwise materials in will not be consumed.

In mrp.production model, "qty_producing" is updated with the material out actual quantity. As you note, this will update field "state" in the same model.

Executing the "button_mark_done" method on mrp.production model outside of Odoo will result in an error, but it appears this is due to the forms that are generated in the method, but cannot be.

The product.template model was only used to create the stock.valuation.layer for materials. Only read method was used, and is no longer required.

Thank you, again, for your help. It is truly appreciated.

Author Best Answer

Rajesh,

Thank you for your help. The "action_confirm" will set the state of a MO to Confirmed. I have tried using the "button_mark_done", but this only consumes material request (BOM) quantities, not material actual quantities. For example, if a MO requests 25 units of a product, but 26 are consumed, this method will only consume 25 in production inventory.

Please note I edited my original post as the stock.move and stock.move.line models were incorrect.

David

Avatar
Discard
Best Answer

Hello David,

Assuming that you are calling xml-rpc calls for your MES integration,
and in that if you are marking your M-order done via rpc call to 'action_confirm' (like odoo UI does the thing) then it should take care of all the stock effects


Avatar
Discard
Related Posts Replies Views Activity
3
Aug 25
3271
0
Jul 25
389
1
Jul 25
709
1
Jul 25
1145
0
Jun 25
521