Skip to Content
Odoo เมนู
  • ลงชื่อเข้าใช้
  • ทดลองใช้ฟรี
  • แอป
    การเงิน
    • ระบบบัญชี
    • ระบบการออกใบแจ้งหนี้
    • ระบบบัญชีรายจ่าย
    • ระบบการจัดการข้อมูลผ่านสเปรดชีต (BI)
    • เอกสาร
    • ระบบลงลายเซ็น
    การขาย
    • ลูกค้าสัมพันธ์
    • การขาย
    • POS ร้านค้า
    • POS ร้านอาหาร
    • ระบบสมัครสมาชิก
    • การเช่า
    การจัดการเว็บไซต์
    • เครื่องมือสร้างเว็บไซต์
    • ระบบการขายออนไลน์
    • บล็อก
    • ฟอรั่ม
    • ไลฟ์แชท
    • ระบบการอบรมออนไลน์
    ซัพพลายเชน
    • คลังสินค้า
    • ระบบการผลิต
    • PLM
    • ระบบการจัดซื้อ
    • การซ่อมบำรุง
    • ระบบจัดการคุณภาพ
    ทรัพยากรบุคคล
    • ข้อมูลพนักงาน
    • ระบบสรรหาบุคลากร
    • ระบบการลา
    • การประเมิน
    • ระบบการแนะนำพนักงาน
    • ระบบจัดการยานพาหนะ
    การตลาด
    • โซเชียลมาร์เก็ตติ้ง
    • การตลาดผ่านอีเมล
    • ระบบการตลาดผ่าน SMS
    • ระบบการจัดงานอีเวนต์
    • การตลาดแบบอัตโนมัติ
    • ระบบแบบสำรวจ
    การบริการ
    • โปรเจกต์
    • ระบบบันทึกเวลา
    • ระบบการจัดการบริการภาคสนาม
    • ระบบดูแลช่วยเหลือ
    • การวางแผน
    • การนัดหมาย
    ประสิทธิผล
    • ระบบแสดงความคิดเห็น
    • ระบบการอนุมัติ
    • ไอโอที
    • VoIP
    • คลังข้อมูล
    • WhatsApp
    แอปพลิเคชันของบุคคลที่สาม Odoo สตูดิโอ แพลตฟอร์มคลาวด์ของ Odoo
  • อุตสาหกรรม
    การค้าปลีก
    • ร้านขายหนังสือ
    • ร้านขายเสื้อผ้า
    • ร้านขายเฟอร์นิเจอร์
    • ร้านขายของชำ
    • ร้านขายฮาร์ดแวร์
    • ร้านขายของเล่น
    Food & Hospitality
    • บาร์และผับ
    • ร้านอาหาร
    • อาหารฟาสต์ฟู้ด
    • Guest House
    • ตัวแทนจำหน่ายเครื่องดื่ม
    • Hotel
    อสังหาริมทรัพย์
    • Real Estate Agency
    • บริษัทสถาปัตยกรรม
    • บริษัทรับเหมา
    • การจัดการอสังหาริมทรัพย์
    • การจัดสวน
    • สมาคมเจ้าของอสังหาริมทรัพย์
    ปรึกษา
    • สำนักงานบัญชี
    • Odoo พาร์ทเนอร์
    • เอเจนซี่การตลาด
    • สำนักงานกฎหมาย
    • บริการสรรหาบุคลากร
    • การตรวจสอบและการรับรอง
    ระบบการผลิต
    • Textile
    • เหล็ก
    • เฟอร์นิเจอร์
    • อาหาร
    • Brewery
    • ของขวัญขององค์กร
    สุขภาพ & ฟิตเนส
    • ชมรมกีฬา
    • ร้านขายแว่นตา
    • ฟิตเนส
    • ผู้ประกอบวิชาชีพด้านสุขภาพ
    • ร้านขายยา
    • ร้านทำผม
    Trades
    • ช่างซ่อม
    • ฮาร์ดแวร์และการสนับสนุนด้านไอที
    • ระบบพลังงานแสงอาทิตย์
    • ช่างทำรองเท้า
    • บริการทำความสะอาด
    • HVAC Services
    อื่น ๆ
    • Nonprofit Organization
    • สำนักงานสิ่งแวดล้อม
    • ร้านเช่าป้ายโฆษณา
    • การถ่ายภาพ
    • ร้านเช่าจักรยาน
    • ตัวแทนจำหน่ายซอฟต์แวร์
    Browse all Industries
  • คอมมูนิตี้
    ศึกษา
    • บทเรียน
    • เอกสารกำกับโปรแกรม
    • การรับรอง
    • การฝึกอบรม
    • บล็อก
    • พอดแคสต์
    เพิ่มศักยภาพให้กับการศึกษา
    • โปรแกรมการศึกษา
    • Scale Up! Business Game
    • เยี่ยมชม Odoo
    รับซอฟต์แวร์
    • ดาวน์โหลด
    • เปรียบเทียบรุ่น
    • เผยแพร่
    ทำงานร่วมกัน
    • Github
    • ฟอรั่ม
    • ระบบการจัดงานอีเวนต์
    • การแปล
    • ร่วมเป็นพาร์ทเนอร์
    • Services for Partners
    • ลงทะเบียนเพื่อสร้างบัญชีบริษัทของคุณ
    รับบริการ
    • ค้นหาพาร์ทเนอร์
    • ค้นหานักบัญชี
    • พบกับที่ปรึกษา
    • บริการติดตั้งระบบเพื่อใช้งาน
    • ข้อมูลอ้างอิงลูกค้า
    • การสนับสนุน
    • อัปเกรด
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    รับการสาธิต
  • ราคา
  • ช่วยเหลือ

Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:

  • ลูกค้าสัมพันธ์
  • e-Commerce
  • ระบบบัญชี
  • สินค้าคงคลัง
  • PoS
  • โปรเจกต์
  • MRP
All apps
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
All Posts คน เหรียญรางวัล
แท็ก (View all)
odoo accounting v14 pos v15
เกี่ยวกับฟอรั่มนี้
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
All Posts คน เหรียญรางวัล
แท็ก (View all)
odoo accounting v14 pos v15
เกี่ยวกับฟอรั่มนี้
ช่วยเหลือ

How to create manufacturing order using API?

ติดตาม

รับการแจ้งเตือนเมื่อมีกิจกรรมในโพสต์นี้

คำถามนี้ถูกตั้งค่าสถานะ
apibomManufacturing Order
2 ตอบกลับ
11078 มุมมอง
อวตาร
Ruben Agadzanjans

I'm trying to create a manufacturing order using API. I can create a new order, but it doesn't have any components. The bom I'm using has components defined, by they are not populated when this manufacturing order is created.

Here is how I'm creating it: 

models.execute_kw(db, uid, password, 
'mrp.production', 'create', [{
  product_id: 69,
  bom_id: 9,
  product_uom_id: 1,
}]
)
Thanks!
0
อวตาร
ละทิ้ง
Cody Kinzett

Hey there, did you work this out? I am facing the same issue. I can create the MO but cannot proceed as it has no components, I believe the stock.move has something to do with it. as this line is in mrp_production.py

move_raw_ids = fields.One2many(

'stock.move', 'raw_material_production_id', 'Components',

copy=True, states={'done': [('readonly', True)], 'cancel': [('readonly', True)]},

domain=[('scrapped', '=', False)])

Ruben Agadzanjans
ผู้เขียน

I ended up using python to create manufacturing order.

Here is what I do:

```

bom_description = self.get_bom_description(product_id)

manufacturing_order = self.env['mrp.production'].create([{

'product_id': product_id,

'product_qty': 1,

'product_uom_qty': 1,

'qty_produced': 1,

'product_uom_id': bom_description['product_uom_id'][0],

'bom_id': bom_description['bom_id'][0],

'origin': origin,

'move_finished_ids': [

[0, '', {

'product_id': move_finished_id[2]['product_id'][0],

'product_uom': move_finished_id[2]['product_uom'][0],

'product_uom_qty': move_finished_id[2]['product_uom_qty'],

'location_id': move_finished_id[2]['location_id'][0],

'location_dest_id': destination_location.id,

'name': move_finished_id[2]['name'],

'byproduct_id': False,

}]

for move_finished_id in bom_description['move_finished_ids'][1:]

],

'move_raw_ids': [

[0, '', {

'product_id': move_raw_id[2]['product_id'][0],

'bom_line_id': move_raw_id[2]['bom_line_id'][0],

'product_uom': move_raw_id[2]['product_uom'][0],

'product_uom_qty': move_raw_id[2]['product_uom_qty'],

'location_id': part_source_location.id,

'location_dest_id': move_raw_id[2]['location_dest_id'][0],

'name': move_raw_id[2]['name'],

}]

for move_raw_id in bom_description['move_raw_ids'][1:]

]

}])

manufacturing_order.action_confirm()

manufacturing_order.update({'lot_producing_id': lot.id})

immediate_production = self.env['mrp.immediate.production'].create({

'immediate_production_line_ids': [[0, '', {

'production_id': manufacturing_order.id,

'to_immediate': True

}]]

})

immediate_production.process()

manufacturing_order.button_mark_done()

def get_bom_description(self, product_id):

onchange_res = self.env['mrp.production'].onchange(

{

'product_id': product_id,

},

'product_id',

{

'company_id': '1',

'product_id': '1',

'product_qty': '1',

'product_uom_id': '1',

'bom_id': '1',

'move_finished_ids': '1',

'move_finished_ids.product_id': '1',

'move_finished_ids.product_uom': '1',

'move_finished_ids.product_uom_qty': '1',

'move_finished_ids.location_id': '1',

'move_finished_ids.location_dest_id': '1',

'move_finished_ids.name': '',

'move_raw_ids': '1',

'move_raw_ids.product_id': '1',

'move_raw_ids.name': '',

'move_raw_ids.bom_line_id': '',

'move_raw_ids.location_id': '1',

'move_raw_ids.location_dest_id': '1',

'move_raw_ids.product_uom_qty': '1',

'move_raw_ids.product_uom': '1',

}

)

return onchange_res['value']

```

Same thing can be done using API. The important part for me was that I needed to call [mrp.production].onchange to get information about all components from the bom and then pass them in as move_finished_ids and move_raw_ids.

อวตาร
Ruben Agadzanjans
ผู้เขียน คำตอบที่ดีที่สุด

I ended up using python to create manufacturing order.

Here is what I do:

    def assemble_product(self, product_id, part_source_location, destination_location, origin=None):
bom_description = self.get_bom_description(product_id)
manufacturing_order = self.env['mrp.production'].create([{
'product_id': product_id,
'product_qty': 1,
'product_uom_qty': 1,
'qty_produced': 1,
'product_uom_id': bom_description['product_uom_id'][0],
'bom_id': bom_description['bom_id'][0],
'origin': origin,
'move_finished_ids': [
[0, '', {
'product_id': move_finished_id[2]['product_id'][0],
'product_uom': move_finished_id[2]['product_uom'][0],
'product_uom_qty': move_finished_id[2]['product_uom_qty'],
'location_id': move_finished_id[2]['location_id'][0],
'location_dest_id': destination_location.id,
'name': move_finished_id[2]['name'],
'byproduct_id': False,
}]
for move_finished_id in bom_description['move_finished_ids'][1:]
],
'move_raw_ids': [
[0, '', {
'product_id': move_raw_id[2]['product_id'][0],
'bom_line_id': move_raw_id[2]['bom_line_id'][0],
'product_uom': move_raw_id[2]['product_uom'][0],
'product_uom_qty': move_raw_id[2]['product_uom_qty'],
'location_id': part_source_location.id,
'location_dest_id': move_raw_id[2]['location_dest_id'][0],
'name': move_raw_id[2]['name'],
}]
for move_raw_id in bom_description['move_raw_ids'][1:]
]
}])
manufacturing_order.action_confirm()
immediate_production = self.env['mrp.immediate.production'].create({
'immediate_production_line_ids': [[0, '', {
'production_id': manufacturing_order.id,
'to_immediate': True
}]]
})
immediate_production.process()
manufacturing_order.button_mark_done()

def get_bom_description(self, product_id):
onchange_res = self.env['mrp.production'].onchange(
{
'product_id': product_id,
},
'product_id',
{
'company_id': '1',
'product_id': '1',
'product_qty': '1',
'product_uom_id': '1',
'bom_id': '1',
'move_finished_ids': '1',
'move_finished_ids.product_id': '1',
'move_finished_ids.product_uom': '1',
'move_finished_ids.product_uom_qty': '1',
'move_finished_ids.location_id': '1',
'move_finished_ids.location_dest_id': '1',
'move_finished_ids.name': '',
'move_raw_ids': '1',
'move_raw_ids.product_id': '1',
'move_raw_ids.name': '',
'move_raw_ids.bom_line_id': '',
'move_raw_ids.location_id': '1',
'move_raw_ids.location_dest_id': '1',
'move_raw_ids.product_uom_qty': '1',
'move_raw_ids.product_uom': '1',
}
)
return onchange_res['value']

def assemble_product_with_serial_number(self, product_id, serial_number, part_source_location, destination_location, origin=None):
if not serial_number:
raise UserError('non-empty serial_number must be provided')

_logger.info(f'Assembling: {serial_number}')

lot_name = serial_number
existing_lot = self.env['stock.production.lot'].search([('name', '=', lot_name)], limit=1)
if existing_lot and existing_lot.product_qty > 0:
raise UserError(f'Device with serial number {lot_name} already exists')

lot = existing_lot or self.env['stock.production.lot'].create({
'product_id': product_id,
'name': lot_name,
'company_id': self.env.company.id
})

bom_description = self.get_bom_description(product_id)
manufacturing_order = self.env['mrp.production'].create([{
'product_id': product_id,
'product_qty': 1,
'product_uom_qty': 1,
'qty_produced': 1,
'product_uom_id': bom_description['product_uom_id'][0],
'bom_id': bom_description['bom_id'][0],
'origin': origin,
'move_finished_ids': [
[0, '', {
'product_id': move_finished_id[2]['product_id'][0],
'product_uom': move_finished_id[2]['product_uom'][0],
'product_uom_qty': move_finished_id[2]['product_uom_qty'],
'location_id': move_finished_id[2]['location_id'][0],
'location_dest_id': destination_location.id,
'name': move_finished_id[2]['name'],
'byproduct_id': False,
}]
for move_finished_id in bom_description['move_finished_ids'][1:]
],
'move_raw_ids': [
[0, '', {
'product_id': move_raw_id[2]['product_id'][0],
'bom_line_id': move_raw_id[2]['bom_line_id'][0],
'product_uom': move_raw_id[2]['product_uom'][0],
'product_uom_qty': move_raw_id[2]['product_uom_qty'],
'location_id': part_source_location.id,
'location_dest_id': move_raw_id[2]['location_dest_id'][0],
'name': move_raw_id[2]['name'],
}]
for move_raw_id in bom_description['move_raw_ids'][1:]
]
}])
manufacturing_order.action_confirm()
manufacturing_order.update({'lot_producing_id': lot.id})
immediate_production = self.env['mrp.immediate.production'].create({
'immediate_production_line_ids': [[0, '', {
'production_id': manufacturing_order.id,
'to_immediate': True
}]]
})
immediate_production.process()
manufacturing_order.button_mark_done()
_logger.info(f'Completed Manufacturing Order {manufacturing_order.name}')

return self.env['stock.production.lot'].browse(lot.id)



Same thing can be done using API. The important part for me was that I needed to call [mrp.production].onchange to get information about all components from the bom and then pass them in as move_finished_ids and move_raw_ids.

(edit: added example for assembling a product with serial number)
1
อวตาร
ละทิ้ง
Cody Kinzett

Awesome thank you for the script! this works as needed, i don't think i would have ever worked this out! I would mark your answer as the correct answer as i'm sure people will look for this in the future!

Ray Carnes (ray)

A way to get access to the "secret" API calls you need is explained https://www.odoo.com/forum/help-1/how-can-i-see-which-api-calls-are-made-to-learn-what-odoo-is-doing-at-specific-times-183911

Cody Kinzett

Another quick question if you have any suggestions, it works great for products that dont need a Serial/Lot ID but gives me an error for products that do need a lot.

i can generate a randomised serial using the commented code, manufacturing_order.action_generate_serial()

but id really like to use the Lot_id provided by the user to create the lot.

ive tried passing 'lot_producing_id' and it actually appears in the produced MO's but i must be missing a variable or prior function because the MO's cannot be advanced to 'Done' even if you change to a different/create a new Serial on the Manufacturing order direclty. it always says user Error a lot/serial number must be supplied.

ive also tried passing 'Lot_Ids' ,'order_finished_lot_ids' on the 'move_finished_ids' variable but this doesnt help or progress it in any way...

wondering if i pass a var in the XML. as i have seen some Xpath solutions.

Code is :::

Lot_id = self.env['stock.production.lot'].create({

'name': self.Serial_Number,

'product_id': WIP_check,

'company_id': company,

})

## https://www.odoo.com/forum/help-1/how-to-create-manufacturing-order-using-api-182874

bom_description = self.get_bom_description(WIP_check)

print('str(self.package_qty)',str(self.package_qty))

manufacturing_order = self.env['mrp.production'].create([{

'product_id': WIP_check,

'product_qty': str(self.package_qty),

'product_uom_id': bom_description['product_uom_id'][0],

'qty_producing': self.package_qty,

'product_uom_qty': str(self.package_qty),

'bom_id': bom_description['bom_id'][0],

'origin': self.reference,

'location_src_id': Source_Location,

'lot_producing_id': Lot_id.id,

'move_finished_ids': [

[0, '', {

'product_id': move_finished_id[2]['product_id'][0],

'product_uom': move_finished_id[2]['product_uom'][0],

'product_uom_qty': str(int(move_finished_id[2]['product_uom_qty'])*int(self.package_qty)),

'location_id': move_finished_id[2]['location_id'][0],

'location_dest_id': move_finished_id[2]['location_dest_id'][0],

'name': move_finished_id[2]['name'],

'byproduct_id': False,

'quantity_done': str(int(move_finished_id[2]['product_uom_qty']) * int(self.package_qty)),

}]

for move_finished_id in bom_description['move_finished_ids'][1:]

],

'move_raw_ids': [ [0, '', {

'product_id': move_raw_id[2]['product_id'][0],

'bom_line_id': move_raw_id[2]['bom_line_id'][0],

'product_uom': move_raw_id[2]['product_uom'][0],

'product_uom_qty': str(int(move_raw_id[2]['product_uom_qty'])*int(self.package_qty)),

'location_id': Source_Location,

'location_dest_id':Source_Location,

'name': move_raw_id[2]['name'],

'quantity_done': str(int(move_raw_id[2]['product_uom_qty']) * int(self.package_qty)),

}]

for move_raw_id in bom_description['move_raw_ids'][1:]

]

}])

manufacturing_order.action_confirm()

# manufacturing_order.action_generate_serial()

manufacturing_order.action_assign()

manufacturing_order.button_mark_done()

def get_bom_description(self, product_id):

onchange_res = self.env['mrp.production'].onchange(

{

'product_id': product_id

},

'product_id',

{

'company_id': '1',

'product_id': '1',

'product_qty': '1',

'product_uom_id': '1',

'bom_id': '1',

'move_finished_ids': '1',

'move_finished_ids.product_id': '1',

'move_finished_ids.product_uom': '1',

'move_finished_ids.product_uom_qty': '1',

'move_finished_ids.location_id': '1',

'move_finished_ids.location_dest_id': '1',

'move_finished_ids.name': '',

'move_raw_ids': '1',

'move_raw_ids.product_id': '1',

'move_raw_ids.name': '',

'move_raw_ids.bom_line_id': '',

'move_raw_ids.location_id': '1',

'move_raw_ids.location_dest_id': '1',

'move_raw_ids.product_uom_qty': '1',

'move_raw_ids.product_uom': '1',

}

)

return onchange_res['value']

Cody Kinzett

also @ray i setup this and it is helpful, but when i compare my code running to odoo code manufacturing i see the same thing.

working MO : 'lot_producing_id': (185, '0000011'),

my test : 'lot_producing_id': (195, '207'),

when I look at PGadmin i can see the lot_producing_id in the correct table.

select * from mrp_production mp

inner join

stock_production_lot spl

on

mp.lot_producing_id = spl.id;

my lack of odoo understanding and where to find solutions is the issue hahahah.

im not sure which triggers run when Odoo runs its own MO because from what i can tell im doing the right things.

Ive found a ton of your answers for automating stuff using auto assigned Lots but unfortunately not much for user assigned lots.

Hoping your expertise will come in handy here

Ruben Agadzanjans
ผู้เขียน

I've edited the answer to add another example for manufacturing a product with a serial number

Cody Kinzett

Thank you Ruben very professional! I hope to be as skilled as you someday! any advice on how to learn to reverse engineer Odoo so I can learn how to do this myself?

Ruben Agadzanjans
ผู้เขียน

It took me around three months to figure this out and to implement odoo in our organization. Basically I had to read a lot of the source code to understand how it works (e.g. https://github.com/odoo/odoo/tree/14.0/addons/mrp/models). I also inspect what calls are made by the odoo UI and that gives me an idea of where to look at.

Cody Kinzett

A little extra. this code will consume products where lot assignment is turned on for consumed goods. thanks to Ray and Ruben for the advice that got me there.

def assemble_product_with_serial_number(self):

lot_name = self.Serial_Number

existing_lot = self.env['stock.production.lot'].search([('name', '=', lot_name)], limit=1)

if existing_lot and existing_lot.product_qty > 0:

raise exceptions.UserError(f'Device with serial number {lot_name} already exists')

lot = existing_lot or self.env['stock.production.lot'].create({

'product_id': WIP_check,

'name': lot_name,

'company_id': self.env.company.id

})

bom_description = self.get_bom_description(WIP_check)

for move_finished_id in bom_description['move_finished_ids']:

print(move_finished_id)

manufacturing_order = self.env['mrp.production'].create([{

'product_id': WIP_check,

'product_qty': str(self.package_qty),

'product_uom_qty': 1,

'product_uom_id': bom_description['product_uom_id'][0],

'bom_id': bom_description['bom_id'][0],

'origin': self.reference,

'location_src_id': Source_Location,

'move_finished_ids': [

[0, '', {

'product_id': move_finished_id[2]['product_id'][0],

'product_uom': move_finished_id[2]['product_uom'][0],

'product_uom_qty': str(int(move_finished_id[2]['product_uom_qty'])*int(self.package_qty)),

'location_id': move_finished_id[2]['location_id'][0],

'location_dest_id': Source_Location,

'name': move_finished_id[2]['name'],

'byproduct_id': False,

}]

for move_finished_id in bom_description['move_finished_ids'][1:]

],

'move_raw_ids': [

[0, '', {

'product_id': move_raw_id[2]['product_id'][0],

'bom_line_id': move_raw_id[2]['bom_line_id'][0],

'product_uom': move_raw_id[2]['product_uom'][0],

'product_uom_qty': str(int(move_raw_id[2]['product_uom_qty'])*int(self.package_qty)),

'location_id': Source_Location,

'location_dest_id': move_raw_id[2]['location_dest_id'][0],

'name': move_raw_id[2]['name'],

}]

for move_raw_id in bom_description['move_raw_ids'][1:]

]

}])

manufacturing_order.action_confirm()

# get actual lot ID's in WIP, - how to handle half lots?

# get actual consumption value - DONE

tracking=[]

for raw_ids in bom_description['move_raw_ids'][1:]:

if raw_ids[2]['has_tracking'] != 'none':

sm = self.env['stock.move'].search([('reference', '=', manufacturing_order.name),('product_id','=',raw_ids[2]['product_id'][0])])

self._cr.execute("""

select

lot_id,

sq.quantity,

reserved_quantity,

sl.complete_name

from

stock_quant sq

inner join

stock_location sl

on

sq.location_id = sl.id

inner join

stock_move sm

on

sl.id = sm.location_id

and

sq.product_id = sm.product_id

where

sl.complete_name like %s

and

sm.id = %s

and

lot_id is not null

""",

('%WIP%',sm.id))

Lots_Avail_in_WIP = self._cr.fetchall()

product_to_consume = int(self.package_qty)

for lot_id, sq_quantity, reserved_quantity, sl_complete_name in Lots_Avail_in_WIP:

print('--', lot_id, sq_quantity, reserved_quantity, sl_complete_name)

print('--int(raw_ids[2][product_uom_qty]) * product_to_consume',int(raw_ids[2]['product_uom_qty']) * product_to_consume)

if sq_quantity < 1:

continue

elif sq_quantity > int(raw_ids[2]['product_uom_qty']) * product_to_consume:

print('---Enough goods for single lot consumption')

self.env['stock.move'].search([('id', '=', sm.id)]).update({'lot_ids': [lot_id],

'product_uom_qty': str(int(raw_ids[2]['product_uom_qty'])*product_to_consume),

'quantity_done': str(int(raw_ids[2]['product_uom_qty'])*product_to_consume),

'should_consume_qty': str(int(raw_ids[2]['product_uom_qty'])*product_to_consume),

})

break

else:

#to be completed

print('---not enough goods for single lot consumption')

self.env['stock.move'].search([('id', '=', sm.id)]).update({'lot_ids': [lot_id],

'product_uom_qty': str(int(

raw_ids[2][

'product_uom_qty']) * product_to_consume),

'quantity_done': str(int(raw_ids[2][

'product_uom_qty']) * product_to_consume),

'should_consume_qty': str(int(

raw_ids[2][

'product_uom_qty']) * product_to_consume),

})

product_to_consume -= sq_quantity

manufacturing_order.update({'lot_producing_id': lot.id})

immediate_production = self.env['mrp.immediate.production'].create({

'immediate_production_line_ids': [[0, '', {

'production_id': manufacturing_order.id,

'to_immediate': True

}]]

})

immediate_production.process()

manufacturing_order.button_mark_done()

_logger.info(f'Completed Manufacturing Order {manufacturing_order.name}')

อวตาร
Andrei Dobrescu
คำตอบที่ดีที่สุด

Hello,

The easisest way I could find is to trigger these methods:

  record._onchange_move_raw()

  record._onchange_move_finished_product()

  record._onchange_workorder_ids()

It should deliver everything needed for the BoM.


Cheers,

Andrei

0
อวตาร
ละทิ้ง
สนุกกับการพูดคุยนี้ใช่ไหม? เข้าร่วมเลย!

สร้างบัญชีวันนี้เพื่อเพลิดเพลินไปกับฟีเจอร์พิเศษและมีส่วนร่วมกับคอมมูนิตี้ที่ยอดเยี่ยมของเรา!

ลงชื่อ
Related Posts ตอบกลับ มุมมอง กิจกรรม
Single MO Creates 3 Products 13.0 แก้ไขแล้ว
bom Manufacturing Order
อวตาร
2
ม.ค. 20
3428
How to know when to order inventory to fulfil Manufacturing Orders? แก้ไขแล้ว
bom Manufacturing Order
อวตาร
อวตาร
อวตาร
อวตาร
6
ต.ค. 18
6705
Show SO availability from BoM components for Make-To-Order repairs (need MO)
bom Manufacturing Order sales order
อวตาร
อวตาร
1
ต.ค. 25
504
Start manufacturing with available components
bom subprocess Manufacturing Order
อวตาร
0
มี.ค. 23
2545
Produce multiple items from one manufacturing order
manufacturing bom Manufacturing Order
อวตาร
อวตาร
1
พ.ค. 22
6279
คอมมูนิตี้
  • บทเรียน
  • เอกสารกำกับโปรแกรม
  • ฟอรั่ม
โอเพนซอร์ส
  • ดาวน์โหลด
  • Github
  • Runbot
  • การแปล
บริการ
  • โฮสติ้ง odoo.sh เซิร์ฟเวอร์
  • การสนับสนุน
  • อัปเกรด
  • การพัฒนาที่กำหนดเอง
  • การศึกษา
  • ค้นหานักบัญชี
  • ค้นหาพาร์ทเนอร์
  • ร่วมเป็นพาร์ทเนอร์
เกี่ยวกับเรา
  • บริษัทของเรา
  • ทรัพย์สินในรูปของเครื่องหมายการค้า
  • ติดต่อเรา
  • งาน
  • ระบบการจัดงานอีเวนต์
  • พอดแคสต์
  • บล็อก
  • ลูกค้า
  • กฎหมาย • ความเป็นส่วนตัว
  • ความปลอดภัย
الْعَرَبيّة Català 简体中文 繁體中文 (台灣) Čeština Dansk Nederlands English Suomi Français Deutsch हिंदी Bahasa Indonesia Italiano 日本語 한국어 (KR) Lietuvių kalba Język polski Português (BR) română русский язык Slovenský jazyk slovenščina Español (América Latina) Español ภาษาไทย Türkçe українська Tiếng Việt

Odoo เป็นชุดแอปธุรกิจแบบเปิดที่ครอบคลุมทุกความต้องการของบริษัทของคุณ อาธิ CRM eCommerce ระบบบัญชี ระบบสินค้าคงคลัง ระบบการขายหน้าร้าน โปรเจกต์ และ อีกมากมาย

ความเหนือกว่าอันเป็นเอกลักษณ์ของ Odoo คือการใช้งานที่ง่ายดายและผสานการทำงานอย่างสมบูรณ์แบบในเวลาเดียวกัน

Website made with

Odoo Experience on YouTube

1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.

Live support on Youtube
Watch now