I am creating an addon and I inserted a sequence to it when creating each record. The problem is that when creating each record, the title of the sequence within the form gives the following:
External Letters / letter.form, 3
But for any other sequence instead of "letter.form, 3" the generated sequence appears, and I need its corresponding sequence to appear for each form. For example for sales it is:
Quotes / S00002
This is the code in:
XML:
<data noupdate="1">
<record id="sequence_letter" model="ir.sequence">
<field name="name">Cite</field>
<field name="code">letter.sequence</field>
<field name="prefix">CITE.:</field>
<field name="suffix">/%(y)s</field>
<field name="padding">4</field>
<field name="number_next">1</field>
<field name="number_increment">1</field>
</record>
</data>
PY:
@api.model
def create(self, vals):
seq_date = None
if 'date' in vals:
seq_date = fields.Datetime.context_timestamp(self, fields.Datetime.to_datetime(vals['date']))
if vals.get('cite_sequence', 'New') == 'New':
vals['cite_sequence'] = self.env['ir.sequence'].next_by_code('letter.sequence', sequence_date=seq_date) or 'New'
result = super(letter, self).create(vals)
return result