تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
3739 أدوات العرض

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

الصورة الرمزية
إهمال
المنشورات ذات الصلة الردود أدوات العرض النشاط
2
يناير 18
5046
3
مارس 21
3836
0
يوليو 20
2371
2
مارس 15
6402
0
أكتوبر 20
1605