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

Hi! I need to validate invoice automatically to send to my clients in Odoo 9. I used Automated Actions to validate Contract invoices using this code, but it's not working:

if context and context.get('default_type') and context['default_type']=='contract':    
object.signal_workflow('invoice_open')

Are there any option to validate invoices on creation?

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

Hi Jose Antonio, 

You can Automatically validate an invoice by the following code. 

For Version 10

class YourClass(models.Model):
_inherit = "account.invoice"

@api.model
def create(self, values):
invoice = super(YourClass, self).create(values)
invoice.action_invoice_open() return invoice

For Version 8 and 9

@api.model
def create(self, values):
invoice = super(YourClass, self).create(values)
invoice.signal_workflow('invoice_open')
return invoice

Thank You.

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

Hi Avinash Nk,

I tried your code and I'm getting this error:

AttributeError: 'account.invoice' object has no attribute 'action_invoice_open'

What means this error? Thanks.


อวตาร
ละทิ้ง

Hi Jose Antonio,

I think you are using Odoo 8 or 9. That is why you getting that error. Anyway i just update the Answer. You can choose which code is needed for your Version of Odoo. And please Don't Put This Type of Comments as Answers. You can put it as Comments.

Thank you.

Related Posts ตอบกลับ มุมมอง กิจกรรม
2
มี.ค. 21
5075
2
ก.พ. 17
4969
0
พ.ค. 15
4331
change between 2 Invoice formats แก้ไขแล้ว
1
ก.ค. 25
444
2
ก.ค. 25
621