İçereği Atla
Menü
Bu soru işaretlendi
3722 Görünümler

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
Vazgeç
İlgili Gönderiler Cevaplar Görünümler Aktivite
2
Oca 18
5012
3
Mar 21
3799
0
Tem 20
2356
2
Mar 15
6375
0
Eki 20
1555