Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
2 ตอบกลับ
3141 มุมมอง

Hello everyone, I have created a custom module, in this module, I have a button. The button should create a delivery order in the inventory module ( just like the confirm button in the Sales module). But when I click it, It gives this error ( The operation cannot be completed: - Create/update: a mandatory field is not set. - Delete: another model requires the record being deleted. If possible, archive it instead. Model: Stock Move (stock.move), Field: Description (name) ), and this is my code.

def delivery_order(self):
    delivery = self.env['stock.picking'].create({
        # 'type': 'out_invoice',
        'state': 'assigned',
        'picking_type_id': 1,
        'partner_id': self.partner_id.id,
        'location_id': 1,
        'location_dest_id': 1,
        'origin': self.name,
        'move_ids_without_package': [(0, 0, {
            'product_id': self.product_id.id,
            'product_uom_qty': self.selected_weight,
            'picking_type_id': 1,

        })]})
    return delivery

 

อวตาร
ละทิ้ง
ผู้เขียน คำตอบที่ดีที่สุด

@Niyas Raphy thank you for your response, but there is no field called name inside the o2m  move_ids_without_package model. I

อวตาร
ละทิ้ง

move_ids_without_package is referring to stock.move table, and you can see the field there.
https://github.com/odoo/odoo/blob/13.0/addons/stock/models/stock_move.py

ผู้เขียน

thank you it works

คำตอบที่ดีที่สุด

Hi,

Seems you have not passed the value for the required field name inside the o2m:  move_ids_without_package.

Please make sure that values for all the required field is passed during the create.

Thanks

อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
1
มิ.ย. 23
3151
1
ม.ค. 23
2952
0
ก.ย. 22
2669
1
ส.ค. 22
3665
0
ส.ค. 22
2785