I would like to change the invoice sequence from INV/%(range_year)% to something else (say ABC/INV/%(range_year)%.
This is my code:
.py file
class AccountMove(models.Model):
_inherit = 'account.move'
@api.model
def create(self, vals):
if vals.get('name', ('New')) == ('New'):
vals['name'] = self.env['ir.sequence'].next_by_code('account.invoice.sequence') or ('New')
record = super(AccountMove, self).create(vals)
return record
.xml file
Invoice Sequence
account.invoice.sequence
ABC/INV/%(y)s/
4
This changed the invoice sequence format but the problem is it keeps generating invoice number even in draft state. How to solve this?
I got the solution. Thank you all for the response