Skip to Content
Menu
This question has been flagged
4 Replies
1731 Views

Hello, i want to block creation of 2 invoices for the same user at the same date in odoo 12
User is allow to create a single invoice for a customer for the same date.
An alert must be done if the user tries to create a second invoice for the same customer at the same date.
Can anyone help me?
Thank you

Avatar
Discard
Author

I actually want to send an alert when the same customer is billed twice on the same date.

I create a custom module to inherit account.invoice and i add a sql contraint field but it doesn't work.

Here is the code add in inherit class account.invoice

_sql_constraints = [('paie_uniq', 'unique(partner_id,date_invoice)',

'Erreur !')]

Best Answer

It is only possible if you do customization.

Avatar
Discard
Best Answer

You need to do customization for it, you can use api.connstrains to write your logic-

@api.constrains('partner_id','user_id', 'date_invoice')

def check_same_invoice(self):

// write your logic for particular users to raise warning

Avatar
Discard
Author Best Answer

Thank you for your answer, But  I think I didn't express myself.
I actually want to send an alert when the same customer is billed twice on the same date

Avatar
Discard

Maybe you read the answer carefully?