Odoo Help

0

How to define the parent_id of a new account.account entry if actual accounts don't have external ID?

By
Pascal Tremblay
on 2/1/16, 12:44 PM 767 views

Hello all,

In a custom module, I want to create a new account with this code :

<record id="rounding_account" model="account.account">
            <field name="name">Rounding account</field>
            <field name="code">5300</field>
            <field name="type">regular</field>
            <field name="user_type" ref="account.data_account_type_expense"/>
            <field name="reconcile" eval="False"/>
            <field name="parent_id" ref="????????"/>
 </record>


But none of my actual accounts have an external ID. Even if I define manually an external ID for the parent account that I want, the next to install the module will never have the same external ID...

If I want that this module be easy to install on any Odoo server, how to choose the right parent_id, for example account of code 111 in the accounting chart?


UPDATE #1

For the moment, with the answer of Cyrus Waithaka, I get this error : 

ParseError: "invalid syntax
('<string>', 1, 7, "[(code='111')]")" while parsing /home/odoo-test/addons_pt/canada_rounding/journal_account_lapagept.xml:11, near
<record id="rounding_account" model="account.account">
<field name="name">Rounding account</field>
<field name="code">53300</field>
<field name="type">Regular</field>
<field name="user_type" ref="account.data_account_type_expense"/>
<field name="reconcile" eval="False"/>
<field name="parent_id" search="[(code='111')]"/>
</record>
0
Cyrus Waithaka
On 2/1/16, 3:28 PM

Every record in odoo will have an external id attached to it. You can view this ID by exporting the records. A record that is added by a module using xml will have an external id equivalent to "module_name.value_of_record_tag_id". You will notice that manually created records will also have an external ID.

You can also use 'search' in the event that you want to reference another record by another field name rather than by external id. For example:

<field name="parent_id" search="[(code='111')]"/>

I hope this will help

very interesting trick. Will try it very soon... thanks a lot. I come back

Pascal Tremblay
on 2/1/16, 4:35 PM

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

1 follower(s)

Stats

Asked: 2/1/16, 12:44 PM
Seen: 767 times
Last updated: 2/1/16, 6:30 PM