1
votes

(version 9) i need to update odoo/openerp/addons/base/res/res_currency_data.xml file

i created module added field to res.currency and added data file in my modules data folder. but my field is not updating. any suggestions?

from openerp import models, fields


class ResCurrency(models.Model):
    _inherit = 'res.currency'

currency_word = fields.Char(translate=True, help='HELP')

and this is my data xml file.

<?xml version="1.0" encoding="utf-8"?>
<openerp>
    <data noupdate="0">
        <!-- Currencies -->
        <record id="base.USD" model="res.currency">
            <field name="currency_word">Dollars</field>
        </record>

    </data>
</openerp>

and xml for field to show up in form view.

<openerp>
    <data>

        <record id="view_currency_form" model="ir.ui.view">
            <field name="name">res.currency.form</field>
            <field name="model">res.currency</field>
            <field name="inherit_id" ref="base.view_currency_form"/>
            <field name="arch" type="xml">
                <field name="name" position="after">
                    <field name="currency_word"/>
                </field>
            </field>
        </record>

    </data>
</openerp>
1
make sure your files are register properly under your manifest/openerp file. And give string/label to that field so you can understand whether it's visible or not. - Bhavesh Odedra
yeh i allready figured out. the problem that noupdate=1 is still is =1 so if i load in new database it gives me once to change the field and then it's stay permament. is there is workaround for this noupdate=1. - user7897726
for just testing you can delete noupdate if it bothers you. and use lowercase for id name. also on creating record you must make sure you are giving all the required fields. and also you can just edit record from python function instead of xml record. gl - Dachi Darchiashvili
Just remove the field from manifest "noupdate" or else make this field value "0". - Keval Mehta

1 Answers

2
votes

this is a workaround for noupdate=1

        <function name="write" model="ir.model.data">
            <function name="search" model="ir.model.data">
                <value eval="[('module', '=', 'base'), ('name', '=', 'USD')]" />
            </function>
            <value eval="{'noupdate': False}" />
        </function>
        <record id="base.USD" model="res.currency">
            <field name="currency_word">Dollars</field>
        </record>
        <function name="write" model="ir.model.data">
            <function name="search" model="ir.model.data">
                <value eval="[('module', '=', 'base'), ('name', '=', 'USD')]" />
            </function>
            <value eval="{'noupdate': True}" />
        </function>