Skip to Content
Menu
This question has been flagged

Hello all,

Can I produce a Manufacturing Order (assign + force production + produce) from Python? I want to do the same, via python code, as I do clicking on the buttons above the Manufacturing Order.

My attempt so far is this, but it is not working:

class mrp_production(osv.osv):

    """ Production Orders / Manufacturing Orders """ _inherit = 'mrp.production'

    def create(self, cr, uid, values, context=None):

        res = super(mrp_production, self).create(cr, uid, values, context=context)

        prod_obj = self.pool.get('mrp.production')

        production = prod_obj.browse(cr, uid, res, context=context)

        prod_obj.action_assign(cr, uid, production.id, context=context) production = prod_obj.browse(cr, uid, res, context=context) if production.state == 'draft':

            prod_obj.force_production(cr, uid, production.id) prod_obj.action_produce(cr, uid, production.id, production.product_qty, 'consume_produce', context=context)

        prod_obj.signal_workflow(cr, uid, [production.id,], 'button_produce', context=context)

        return res


Going step-by-step the problem seems to be because no stock moves are generated using this script.


What could I be missing?


Thanks in advance

Avatar
Discard
Related Posts Replies Views Activity
2
Jan 18
4115
3
Mar 21
2592
0
Jul 20
1516
2
Mar 15
5411
0
Oct 20
884