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

I want to create manufacturing order from stock picking .I want to create if two stock.move line in stock picking , I will create two manufacturing order. When I create ,the problem is can't be mark as done in manufacturing order and get user error.Here is my code 

for move in picking.move_ids_without_package:
if move.cleaning_quantity>0:
tmpl_id = move.product_id.product_tmpl_id
bom_id = self.env['mrp.bom'].search([('product_tmpl_id','=',tmpl_id.id)])
if bom_id:
logging.info("Creatre++++++++++++++++")
mrp = self.env['mrp.production'].create({
'product_id':move\.product_id\.id,
'product_qty':move\.cleaning_quantity,
'qty_producing':move\.cleaning_quantity,
'bom_id':bom_id\.id,
'product_uom_id':bom_id\.product_uom_id\.id
\}\)\ \ \ \ \ \ \ \ \ \ \ \ \ \
else:
mrp\ =\ self\.env\['mrp\.production'\]\.create\(\{
'product_id':move\.product_id\.id,
'product_qty':move\.cleaning_quantity,
'product_uom_id':move.product_id.uom_id.id,
})

الصورة الرمزية
إهمال

Hello 

What issue you facing here ?

أفضل إجابة

Hello, GGWP , 

Here is the solution of your error:
If bom exists: This code will solve user error and confirm MO as per your need
If bom not exists: Need to create a bom with its child components as per your need(see sample code in comment) 

Thanks & Regards,
Email: odoo@aktivsoftware.com
Skype: kalpeshmaheshwari

الصورة الرمزية
إهمال

Try this code:

for move in self.move_ids_without_package:
if move.product_uom_qty > 0:
tmpl_id = move.product_id.product_tmpl_id
bom_id = self.env['mrp.bom'].search([('product_tmpl_id', '=', tmpl_id.id)])
if not bom_id:
"""Create Bom with child components
bom_id = self.env['mrp.bom'].create({})"""
else:
mrp = self.env['mrp.production'].create({
'product_id': move.product_id.id,
'product_qty': move.product_uom_qty,
'qty_producing': move.product_uom_qty,
'bom_id': bom_id.id,
'product_uom_id': bom_id.product_uom_id.id
})
# Call onchange method to populate components of MO
mrp._onchange_move_raw()

المنشورات ذات الصلة الردود أدوات العرض النشاط
0
نوفمبر 24
1289
2
سبتمبر 22
2556
0
ديسمبر 21
1702
1
أكتوبر 22
7539
0
يونيو 21
2259