Monday, July 22, 2019

how to create sequence in odoo

ODOO

fields

 

Sequence is that field which generated automatically by the system and it's unique for each record in the table in the database and we can create it by following these steps 


  • define the sequence field as bellow 
        reference = fields.Char('Reference', readonly=True)
  • define the function which will create the sequence when we create the record as bellow 
      @api.model
       def create(self,vals):
           vals['reference'] = self.env['ir.sequence'].get('academic.year')
           return super(academic_year, self).create(vals)     
  • define the sequence related model and the name of the sequence and other attributes as bellow 
      <record id="student_reference" model="ir.sequence">
          <field name="name">Student Reference</field>
          <field name="prefix">Stu_</field>
          <field name="padding">6</field>
          <field name="code">student.student</field>
       </record>
  • at last we have to add our field to the tree view or other view we want

No comments:

Post a Comment

Odoo Invoice Qr code issues

There are two main issues must of us facing with the QR code in Odoo invoice & these issues are 1/ QR code displayed as broken image w...