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

My custom model try to send data to account.invoice  and account invoice lines.But I got  Error

ValueError: dictionary update sequence element #0 has length 3; 2 is required

Here is my code,

result = super(create_invoice_wizard,self).default_get(fields)

res = []

invoice_line_ids = []

flag = True

for obj_ppo_id in obj_ppo_ids:

    invoice_data = self.env['sale.commission'].search([('id','=',obj_ppo_id.id)])

    if flag:

        res.append({

                    'partner_id':invoice_data.consignor.id,

                    'date_invoice':datetime.today(),

                    'invoice_line_ids': [{

                                            'product_id':invoice_data.product_id.id,

                                            'quantity':invoice_data.qty,

                                            'price_unit':invoice_data.total_sales}]

                    })

        flag = False


    else:

        res[0]['invoice_line_ids'].append({'product_id':invoice_data.product_id.id,

                                           'quantity':invoice_data.qty,

                                           'price_unit':invoice_data.total_sales})


result.update(res)

return result

 

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

you need to use special functions to pass data to related fields. it should be

'invoice_line_ids': [(0, 0, {your dict with data})]

this looks like only just one argument, but the reference (self) is the first argument. 

 

อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
9
มิ.ย. 23
13009
2
ม.ค. 22
3809
2
ธ.ค. 21
7826
0
มิ.ย. 21
1903
0
ก.พ. 21
2505