Hey Cyllo users! How do I set up Cyllo to automatically generate unique reference numbers for my records?
Welcome!
Share and discuss the best content and new marketing ideas, build your professional profile and become a better marketer together.
This question has been flagged
Here's how you can define and use a sequence in Odoo to generate unique identifiers for your records. This approach ensures that each record has a distinct and traceable ID. Sequence numbers are used to generate unique identifiers for records such as orders, invoices, or custom models. They ensure traceability and help maintain order integrity.
Define the Sequence in XML (in data/ir_sequence_data.xml) and load Sequence File in __manifest__.py.
Example Sequence
example.model
EXM/%(year)s/
5
1
1
class ExampleModel(models.Model):
_name = 'example.model'
name = fields.Char(string="Reference", required=True, copy=False, readonly=True, default='New')
@api.model
def create(self, vals):
if vals.get('name', 'New') == 'New':
vals['name'] = self.env['ir.sequence'].next_by_code('example.model') or 'New'
return super(ExampleModel, self).create(vals)