تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
5 الردود
13569 أدوات العرض

Hello,

 

I have created a custom field in "stock.picking" model. I need to auto increment this field. 

How can I do this? Can you show me a document about this section?

I am really sorry about this kind of bad question, but I'm really a newbie on OpenERP

Thanks all.

الصورة الرمزية
إهمال
je te remercie beaucoup.

El jue., 13 de ago. de 2020 a la(s) 05:25, Kiran Mohan (kirankmohan96@gmail.com) escribió:

Une nouvelle réponse sur Auto Increment Custom Field a été publiée. Cliquez ici pour accéder au message :

Voir la publication

Envoyé par Odoo S.A. utilisant Odoo.

Thank you very much for the information.

El jue., 13 de ago. de 2020 a la(s) 01:35, Sehrish (sehrishnaz47@gmail.com) escribió:
أفضل إجابة
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






الصورة الرمزية
إهمال
أفضل إجابة

Hi Thelmes,

If you are looking for auto sequence same as you can see it in sales orders like SO001, SO002 and so on.

Then here is your answer: Generate sequence from code.

الصورة الرمزية
إهمال
المنشورات ذات الصلة الردود أدوات العرض النشاط
1
أغسطس 25
167
4
يوليو 25
1514
1
يوليو 25
828
2
يوليو 25
858
1
يوليو 25
1969