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

first im a novice in python

here is the code im using 

@api.multi

    def _prepare_invoice(self):

        invoice_vals = super(SaleOrder, self)._prepare_invoice()

        invoice_vals = {

'field1' : self.field1 ,

'field2' : self.field2

}

but it got me an account error

when i use only 

invoice_vals['field1'] =self.field1

it works perfectly but i dont know how to add other field since i have 5 in total

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

Hi Blaise, 
function _prepare_invoice from sale order returns a dict. If you want to add other values ( field1 and field2 in your case), you need to do this : 

invoice_vals.update(field1=self.field1, field2=self.field2)

If u have only one item to add, it is preferable, for me, to do this : invoice_vals['field1'] =self.field1

Upvote if this helps.

Thank you.

อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
2
ก.ค. 24
13307
1
ก.ค. 21
7360
0
เม.ย. 20
4149
0
เม.ย. 18
2971
Can not over ride _compute_default_code แก้ไขแล้ว
4
มี.ค. 25
3296