Skip to Content
Menu
This question has been flagged
1 Reply
6039 Views

I'm trying to populate two tables via xml, restaurant.floor and restaurant.table from a custom module.

All goes just fine when I create the floor entry with

<record id="floor_main" model="restaurant.floor">
<field name="name">floor_main</field>
<field name="background_color">rgb(136,137,242)</field>
<field name="pos_config_id" eval="ref('point_of_sale.pos_config_main')" />
</record>

but as soon as my xml reach the first of my tables definitions with

<record id="table_01" model="restaurant.table">
<field name="name">Mesa 01</field>
 <field name="floor_id" eval="ref('pos_restaurant.floor_main')" />
<field name="seats">2</field>
 <field name="color">rgb(172,109,173)</field>
 <field name="shape">square</field>
 <field name="width">120</field>
<field name="height">120</field>
  <field name="position_h">900</field>
<field name="position_v">5</field>
</record>

I get a parse error

ParseError: "<type 'exceptions.ValueError'>: "External ID not found in the system: pos_restaurant.floor_main" while evaluating"ref('pos_restaurant.floor_main')"" 

And that's strange, because the db table I'm trying to update is on the same module (pos_restaurant) of restaurant.floor. 

Pos_restaurant module is on the dependencies inside my manifest and the structure of my data.xml was copied from the demo.xml on pos_restaurant, then the syntax should be fine.

Solved changing the record id on the floor definition to grab the correct external ID on tables creation:

<record id="pos_restaurant.floor_main" model="restaurant.floor">
Avatar
Discard
Best Answer

Hi,

Try like this:

<record id="pos_restaurant.floor_main" model="restaurant.floor">    
    <field name="name">floor_main</field>
    <field name="background_color">rgb(136,137,242)</field>
    <field name="pos_config_id" eval="ref('point_of_sale.pos_config_main')" />
</record>

I think, the reason could be, there is no record defined with id floor_main in the module pos_restaurant. That record id comes from your custom module. So External ID not found. You should either try like above or try by replacing <field name="floor_id" eval="ref('floor_main')" /> in the table record.

Avatar
Discard
Author

Adding 'pos_restaurant' to the id on 'floor_main' did the magic. However, the eval on tables xml must be

eval="ref('pos_restaurant.floor_main')

or you will get the same parse error.

I am not sure abt the other way, since both records are on same file, it should work without 'pos_restaurant' I thought. Did you try like that?

Author

Tried. Without the prefix the script rise the very same error:

ParseError: "<type 'exceptions.ValueError'>: "External ID not found in the system: divina_v10.floor_main" while evaluating

"ref('floor_main')"" while parsing /odoo_test2/odoo_test2-server/addons/divina_v10/data/divina_pos_data.xml:22, near

<record id="table_01" model="restaurant.table">

<field name="name">Mesa 01</field>

<field name="floor_id" eval="ref('floor_main')"/>

<field name="seats">2</field>

<field name="color">rgb(172,109,173)</field>

<field name="shape">square</field>

<field name="width">120</field>

<field name="height">120</field>

<field name="position_h">900</field>

<field name="position_v">5</field>

</record>

ok fine, good to know :)

Related Posts Replies Views Activity
1
Sep 18
106
1
May 17
7398
2
Dec 24
61
0
Jul 24
276
2
Nov 23
5926