跳至内容
菜单
此问题已终结
3 回复
9205 查看

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', 


形象
丢弃
相关帖文 回复 查看 活动
1
7月 22
3206
4
4月 22
9580
0
1月 25
4289
3
2月 20
3464
3
10月 19
4970