跳至內容
選單
此問題已被標幟
2 回覆
5848 瀏覽次數

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)



頭像
捨棄
相關帖文 回覆 瀏覽次數 活動
7
5月 20
6302
0
4月 16
2977
11
9月 21
31983
2
1月 24
14895
2
12月 17
4095