Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
2 ตอบกลับ
5948 มุมมอง

Hello, I have Odoo 8. I am developing a module and I want to override "write" method to check that a special field (for instance: "field_a") not changes after edition. How can I check this?

In the creation the field can assume any value.

Thanks!

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

José,

Here you go!

    def write(cr, uid, ids, vals, context=None):

        if not vals.has_key(''field_a):

            print "Your Field A is not updated..."

        res =  super(class_name, self).write(cr, uid, ids, vals, context=context)

        return res

This might helps you!


Regards,

Anil.


อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด


try this ;

def write(self,cr,uid,ids,vals,context=None):

     if vals.get('field_a',False):

               ##### if pass the condition means that 'field_a' has been updated

      return super(your_class_name, self).write(cr, uid, ids, vals, context=context)



อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
7
พ.ค. 20
6401
0
เม.ย. 16
3063
Hide field in a tree view แก้ไขแล้ว
11
ก.ย. 21
32134
Group by on field of a related model. แก้ไขแล้ว
2
ม.ค. 24
15022
2
ธ.ค. 17
4182