Skip to Content
Меню
Чтобы взаимодействовать с сообществом, необходимо зарегистрироваться.
Этот вопрос был отмечен
4 Ответы
37909 Представления

When trying to use the context to avoid an onchange flieds recursion situation (see my other question about it: https://www.odoo.com/es_ES/forum/help-1/question/how-to-deal-with-api-depends-recursion-in-v8-71901 ), I tried doing:

self.with_context(skip_onchange_zip_ids=True).update()

That was in order to get that 'skip_onchange_zip_ids' from context in another onchange method to abort it to avoid infinite change recursion.

But I get this error:

TypeError: update() takes exactly 2 arguments (1 given)

So, how to actually use and modify context? What I am missing?

 

 

Аватар
Отменить
Лучший ответ

Change Context (more info at https://github.com/odoo/odoo/blob/8.0/openerp/models.py#L5214)

rec_set2 = rec_set.with_context(context2)
rec_set2 = rec_set.with_context(lang='IN')

self.with_context(skip_onchange_zip_ids=True)

Аватар
Отменить
Автор

Perfect. This solved the problem. The ".update()" part was not necessary.

Лучший ответ

Hello, 

I you want to add a new param to existing context you can:

self.with_context(skip_onchange_zip_ids=True)

Doc:

# current context is {'key1': True}
r2 = records.with_context({}, key2=True)
# -> r2._context is {'key2': True}
r2 = records.with_context(key2=True)
# -> r2._context is {'key1': True, 'key2': True}

Note: please valid correct answer to have your question closed

 

Аватар
Отменить
Related Posts Ответы Просмотры Активность
2
дек. 15
4200
1
мар. 15
7330
2
мар. 15
7323
3
февр. 23
21644
1
мая 25
184