跳至內容
選單
此問題已被標幟
2 回覆
7847 瀏覽次數
content = fields.Text('Content')
@api.multi
def write(self, values):

    library_write = super(Library, self).write(values)
 
    text = self.read_from_doc()
    values['content'] = text
 
    print 'Passed this function. passed_override_write_function value: ' + str(
    library_write)

    return library_write
頭像
捨棄

In this article you will learn how to override Odoo methods. I will show you how to override Odoo Create, Write and Unlink method.

Reference Link: https://goo.gl/4BkizH

最佳答案

Hi,

Rewrite the function like this,

@api.multi
def write(self, values):
text = self.read_from_doc()
values['content'] = text
library_write = super(Library, self).write(values)
return library_write


Thanks

頭像
捨棄
作者

But when I update the content field before, the previous value is updated,not the current value. I need to update it with the current value. When i save all other fields get current values, but content field alone gets the previous value. What may be the issue?

最佳答案

After Calling super() you are trying to update values with 'content' it's wrong.

Before Calling the super()  you have to update values with 'content' field

@api.multi
def write(self, values):
values['content'] = self.read_from_doc()
return super(Library, self).write(values)
頭像
捨棄
相關帖文 回覆 瀏覽次數 活動
2
7月 25
4790
2
12月 24
7894
2
11月 24
28695
2
5月 24
7593
3
3月 24
7040