Welcome!

Share and discuss the best content and new marketing ideas, build your professional profile and become a better marketer together.

Sign up

You need to be registered to interact with the community.
This question has been flagged
1 Reply
10 Views

Hey Cyllo users! How do I set up Cyllo to automatically generate unique reference numbers for my records?

Avatar
Discard

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) Load Sequence File in __manifest__.py Use the Sequence in Python XML code - Define the Sequence Example Sequence example.model EXM/%(year)s/ 5 1 1 Python code - Use the Sequence in Python 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) Remember to add 'data/ir_sequence_data.xml' to your '__manifest__.py' file under the 'data' key.

Avatar
Discard

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!