I'm trying to change the prefix of quotation's sequence in Odoo. I want that the prefix change by a boolean but i don't have any result.
Here is my code :
class prefix_change(models.Model):
_inherit = 'sale.order'
prefix_choice = fields.Boolean(string="Set to OL", default=False)
def _get_sequence(self, xml_id='quotation.seq'):
user = self.env.user
sequence = self.env['ir.sequence'].with_company(user.company_id).next_by_code(xml_id)
if not sequence:
return _('New')
try:
prefix, suffix = sequence.split('-')
except Exception as e:
logging.error(repr(e))
return _('New')
if not self.prefix_choice :
prefix = "BE"
else:
prefix = "OL"
return "%s-%s-%s" % (prefix, suffix)
Thanks by advance....
Answer W.R.T create and write call:
Please check and let me know if it works for you.