Im trying to add a sequence field to the crm.lead model. I have implemented this code for another custom module I built previously with no issues.
Ive added the new field
class vox_crm_register(models.Model):
_inherit = 'crm.lead'
name_seq = fields.Char(
string='Registration Reference',
required=True,
copy=False,
readonly=True,
index=True,
default=lambda self: _('New'))
Ive overwritten the create function
@api.model
def create(self, vals):
print(vals.get('name_seq'))
if vals.get('name_seq', _('New')) == _('New'):
print('IF is true')
vals['name_seq'] = self.env['ir.sequence'].next_by_code('vox_crm_register.sequence') or _('New')
res = super(vox_crm_register, self).create(vals)
return res
and this is my sequence
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data noupdate="1">
<record id="registration_sequence" model="ir.sequence">
<field name="name">Registration Sequence</field>
<field name="code">vox_crm_register.sequence</field>
<field name="prefix">reg</field>
<field name="padding">3</field>
<field name="company_id" eval="False"/>
</record>
</data>
</odoo>
the result from the print statements in the create function are
None
IF is true
because its inherited do I have to force it in someway or add a context???
Any help appreciated