Created
October 8, 2022 16:25
-
-
Save 3mrdev/1a5499a67d3bfe98ca139f0a9846efe2 to your computer and use it in GitHub Desktop.
How to make odoo sequence ?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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