scanning/model/scanning.py
Add a field in your model
name = fields.Char(string='Test ID', help="Lab Result ID", readonly="1",copy=False, index=True)
Add the following code in create function , if you want to increment sequence at the time of creating a record
@api.model
def create(self, vals):
vals['name'] =self.env['ir.sequence'].next_by_code('patient.scanning.test')
return super(PatientLabTest, self).create(vals)
scanning/data/scanning_data.xml
Create a XML Code to Declare Sequence
<record id="seq_scanning_test" model="ir.sequence">
<field name="name">Patient Scanning Test</field>
<field name="code">patient.scanning.test</field>
<field name="prefix">ST</field>
<field name="padding">3</field>
</record>
name : Name of the Record
code : Sequence Code
prefix : Prefix of the sequence Eg: ST001
padding: Size of Sequence
You can configure Sequence from Settings also
Activate Developer Mode
Settings > Technical > Sequence & Identifiers > Sequences
Create custom auto incremented field: https://learnopenerp.blogspot.com/2020/08/generate-create-sequence-number-odoo.html