Skip to Content
Menu
This question has been flagged
2 Replies
2941 Views

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



Avatar
Discard
Best Answer

Hi,

You have to set the cite_sequence as the rec_name for the model.

Sample:

class Groups(models.Model):
_name = "res.groups"
_description = "Access Groups"
_rec_name = 'full_name'
_order = 'name'

See  :- What is rec name for Models in Odoo Development


Thanks

Avatar
Discard
Best Answer

I think you need to define _rec_name on letter.form model or define the name field in letter.form

Avatar
Discard
Related Posts Replies Views Activity
1
Aug 24
4616
2
Dec 18
6750
1
Aug 24
294
1
Jul 23
1323
0
May 23
1487