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

I plan to create vendor bills and automatically validate them using the following code. The problem with my code is that it creates customer invoice instead of supplier/vendor invoice and the invoice is not validated automatically. How to correct?

@api.multi
def pay_commission(self):
journal = self.env['account.invoice']._default_journal().id
supplier_line = {
'product_id': self.use_product.id,
'name': self.use_product.name,
'quantity': 1,
'account_id': journal,
'price_unit': self.commission,
}
record_line = {
'partner_id': self.user_id.id,
'invoice_line_ids': [(0, 0, supplier_line)],
}
record = self.env['account.invoice'].create(record_line)
self.env['account.invoice'].action_invoice_open()
return record




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

Hi,

Specify the type while  creating the invoice,  in the supplier_line dict add type also.

'type' : 'in_invoice',


Uptd :

To make the invoice validated , change this line in your code,

self.env['account.invoice'].action_invoice_open()

to

record.action_invoice_open()


Thanks


อวตาร
ละทิ้ง
ผู้เขียน

still not working

"not working" - are you getting an Error?

ผู้เขียน

It creates vendor bills now, but isn't automatically validated.

@Sandy Digil : change this line,

self.env['account.invoice'].action_invoice_open()

to

record.action_invoice_open()

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


@api.multi
def pay_commission(self):
journal = self.env['account.invoice']._default_journal().id
supplier_line = {
'product_id': self.use_product.id,
'name': self.use_product.name,
'quantity': 1,
'account_id': journal,
'price_unit': self.commission,
}
record_line = {
'partner_id': self.user_id.id,
'invoice_line_ids': [(0, 0, supplier_line)],
}
record = self.env['account.invoice'].create(record_line)
self.env['account.invoice'].action_invoice_open()
return record


อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด
'move_type' : 'in_invoice',

'move_type':'in_invoice', 


อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
1
ก.ค. 22
3272
4
เม.ย. 22
9613
0
ม.ค. 25
4302
3
ก.พ. 20
3488
3
ต.ค. 19
4985