DISHON KADO
DISHON KADO

Reputation: 1

Sequencing in odoo 10

I am trying to create a sequence in odoo here is my xml file

<record model="ir.sequence" id="connection_sequence_id">
        <field name="name">New Connections Sequence</field>
        <field name="code">ftth.connection</field>
        <field name="prefix">FTTH</field>
        <field name="padding">6</field>
        <field name="company_id" eval="False" />
 </record>

I have created a field for it in my .py file

my_seq = fields.Char(string="sequence", default=lambda self: _('New'))

and overiddeen the create function by using the following code

 @api.model
def create(self, vals):
    if vals:
        vals['my_seq'] = self.env['ir.sequence'].next_by_code('ftth.connection') or _('New')
        result = super(NewConnections, self).create(vals)
        return result

but my code is not generating a sequence instead it gives ftth.connection.(sequence number).what might be wrong with my code.please assist

Upvotes: 0

Views: 281

Answers (1)

Rinaldi
Rinaldi

Reputation: 260

use super to customize your create function, this an example:

    @api.model
    def create(self, vals):
        if vals:
           seq = self.env['ir.sequence']
           vals['my_seq'] = seq.next_by_code('ftth.connection') or _('New')
        return super(ObjectName, self).create(values)

Upvotes: 1

Related Questions