Odoo Help

0

Xml translation and search in another module

By
Antanas
on 7/4/13, 4:37 AM 4,201 views

If I have a module 'foo' with, for example, an xml definition like this:

<?xml version="1.0" encoding="UTF-8"?>
<openerp>
    <data noupdate="0">
        <!-- account.tax.template -->
        <record id="attn_VAT-OUT-21-S" model="account.tax.template">
            <field name="sequence">10</field>
            <field name="description">VAT-OUT-21-S</field>
            <field name="name">VAT 21% - Services</field>
            <field name="account_collected_id" ref="a451054"/>
            <field name="account_paid_id" ref="a451054"/>
            <field name="price_include" eval="0"/>
            <field name="amount">0.21</field>
            <field name="type">percent</field>
            <field name="type_tax_use">sale</field>
            <field name="base_code_id" ref="atctn_03"/>
            <field name="base_sign">1</field>
            <field name="tax_code_id" ref="atctn_54"/>
            <field name="tax_sign">1</field>
            <field name="ref_base_code_id" ref="atctn_49"/>
            <field name="ref_base_sign">1</field>
            <field name="ref_tax_code_id" ref="atctn_64"/>
            <field name="ref_tax_sign">1</field>
            <field name="child_depend" eval="0"/>
            <field name="chart_template_id" ref="l10nlt_chart_template"/>
        </record>
    </data>
</openerp>

And a module 'bar' with an xml like this, where I wish to provide translation for above xml's "name" field:

<?xml version="1.0" encoding="utf-8"?>
<openerp>
    <data noupdate="1">

        <!-- ir.translation -->
        <record id="vat_name_LT" model="ir.translation">
            <field name="name">account.tax.template,name</field>
            <field name="type">model</field>
            <field name="res_id" ref="attn_VAT-OUT-21-S" search="[('model','=','acount.tax.template'),('id','=','attn_VAT-OUT-21-S')]"/>
            <field name="lang">lt_LT</field>
            <field name="src">VAT 21% - Services</field>
            <field name="value">PVM 21% - Paslaugos</field>
        </record>
    </data>
</openerp>

What is the correct way to do that? With code like above I am getting an error:

AssertionError: Define an attribute model="..." in your .XML file !

Edit (problem solved):

Working code (line 9):

<?xml version="1.0" encoding="utf-8"?>
<openerp>
     <data noupdate="1">

        <!-- ir.translation -->
        <record id="vat_name_LT" model="ir.translation">
            <field name="name">account.tax.template,name</field>
            <field name="type">model</field>
            <field name="res_id" ref="foo.attn_VAT-OUT-21-S"/>
            <field name="lang">lt_LT</field>
            <field name="src">VAT 21% - Services</field>
            <field name="value">PVM 21% - Paslaugos</field>
        </record>
    </data>
</openerp>
2
Ghanshyam Prajapati
On 7/4/13, 5:32 AM

Hi Antanas,

Try Following,

Replace

<field name="res_id" ref="attn_VAT-OUT-21-S" search="[('model','=','acount.tax.template'),('id','=','attn_VAT-OUT-21-S')]"/>

with

<field name="res_id" ref="foo.attn_VAT-OUT-21-S"/>

Hope it work for you.

Made it work with <field name="res_id" ref="foo.attn_VAT-OUT-21-S"/> , when id is in another module, id must be prepended with module name and a dot.

Antanas
on 7/4/13, 8:22 AM

Is it work for you? or it gives you error???

Ghanshyam Prajapati
on 7/4/13, 8:25 AM

Yes, it works now. I did just like you suggested, only prepended module name and a dot to the id in ref="". I will try to edit my question and add a snippet of working code there.

Antanas
on 7/4/13, 8:32 AM

Hey Antanas, please mark my answer as solved if your problem is solved, :)

Ghanshyam Prajapati
on 7/4/13, 8:35 AM

Will be glad to do that, just please edit your answer, so we don't confuse readers of this question. (I mean maybe make it look exactly like my question edit) P.S. Thank you.

Antanas
on 7/4/13, 8:37 AM

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

Register

Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

0 follower(s)

Stats

Asked: 7/4/13, 4:37 AM
Seen: 4201 times
Last updated: 3/16/15, 8:10 AM