Skip to content

Instantly share code, notes, and snippets.

@3mrdev
Created October 8, 2022 16:25
Show Gist options
  • Save 3mrdev/1a5499a67d3bfe98ca139f0a9846efe2 to your computer and use it in GitHub Desktop.
Save 3mrdev/1a5499a67d3bfe98ca139f0a9846efe2 to your computer and use it in GitHub Desktop.
How to make odoo sequence ?
class your_model_class_name (models.Model):
_name = "your_model_name"
@api.model
def create(self, vals):
if vals.get('seq', 'New') == 'New':
vals['seq'] = self.env['ir.sequence'].next_by_code('example.seq') or '/'
newId = super(your_model_class_name, self).create(vals)
return newId
<odoo>
<data noupdate="1">
<record id="seq_id" model="ir.sequence">
<field name="name">Sequence</field>
<field name="code">example.seq</field>
<field name="prefix">EX</field>
<field name="padding">7</field>
</record>
</data>
</odoo>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment