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

I want to create a customer_number in the format of cust<id> (For example, cust001, cust004,.. ) using the id. When I use the create() function it returns the id of the record. So I decided to update the record with my customer_number using the id of the record. The following code is in the create() function

@api.model

def create(self, vals):

    res = super(lot_number, self).create(vals)

     customer_id='cust'+str(res.id)

    vals.update({'customer_id':customer_id}) 

    res = super(lot_number, self).write(vals)

    return res




This code didn't show any error. and also the data not get updated.

i also ask this question in stack overflow.

https://stackoverflow.com/questions/53590435/how-to-override-update-function-of-a-custom-model-in-odoo-11

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

Hello Subash,

Try the following code

@api.model

def create(self, vals):

    res = super(lot_number, self).create(vals)

    res.customer_id = 'cust'+str(res.id)

    return res

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

Mr.Subbarao .... Thanks for your replay.. now it working fine. i struck with this for more than 4 hours. your reply helps me to save my time.

  Thanks alot. 

Subash Hariharan AR

الصورة الرمزية
إهمال
المنشورات ذات الصلة الردود أدوات العرض النشاط
2
يوليو 24
2682
1
يونيو 24
5143
1
أكتوبر 23
10852
1
أكتوبر 23
98
1
أغسطس 23
2193