Перейти к содержимому
Меню
Чтобы взаимодействовать с сообществом, необходимо зарегистрироваться.
Этот вопрос был отмечен
1 Ответить
702 Представления

Hello,

I added a field to 'res.country' table

from odoo import models, fields, _

class ResCountry(models.Model):
_inherit = 'res.country'

from_eu = fields.Boolean(string=_('From EU'))


I would like to fill this new field with True for countries of European Union using a xml file, but it's not working.
I suppose that it's due to the fact that, in metadata, I have a noupdate = True for all countries (and noupdate = False for my own tables).

How can I set this value (from_eu = True) for the European Comission countries via an xml file ?

Thanks in advance,

Boris


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

Actually, there is a model "res.country.group" by default already which allows you not only to define EU countries but also other regions, i.e. SEPA countries, or other groupings.

Автор

Thanks Christoph Farnleitner.

Before reading your answer, I discover this group and use it to compute if a country is in EU or not.

However, if I want to set a new field in a base model, how it is possible using a xml file?

Boris

Лучший ответ

You'll find answers here: https://www.odoo.com/forum/1/how-can-i-update-a-record-stored-with-the-attribute-noupdate-1-78133

i.e.

<!-- Allow changes on noupdate -->
<function name="write" model="ir.model.data"> <function name="search" model="ir.model.data"> <value eval="[('module', '=', 'base'), ('name', '=', 'at')]" /> </function> <value eval="{'noupdate': False}" /> </function> <record id="base.at" model="res.country"> <field name="from_eu">1</field> </record> <!-- Revoke noupdate change --> <function name="write" model="ir.model.data"> <function name="search" model="ir.model.data"> <value eval="[('module', '=', 'base'), ('name', '=', 'at')]" /> </function> <value eval="{'noupdate': True}" /> </function>

is one option that should work

Аватар
Отменить
Related Posts Ответы Просмотры Активность
Loading demo data Решено
3
мар. 24
8972
2
сент. 22
3024
4
янв. 21
20866
0
янв. 20
2606
1
авг. 24
2284