Odoo is the world's easiest all-in-one management software. It includes hundreds of business apps:
CRM | e-Commerce | Accounting | Inventory | PoS | Project management | MRP | etc.
[SOLVED] How to add values to a column which belongs to an existing table from a XML file (config) [v7]?
Hello! I created a new table called res.country.region and added a column in res.country.state called region_id, to know to which region a state belongs to.
I also created a module which add some data to the new table res.country.region. I do this through an XML file, and it works well.
But now, I am trying to add the respective region_id to several states of res.country.state. which I am pretty sure that exist. How can I do this through a XML file?
This is an example of a XML record I used to fill in the res.country.region table:
<record model='res.country.region' id='myregionid01'>
<field name='name'>My region</field>
<field name="country_id" ref="base.es"/> <!-- I copied this line from other file, and it points to the country, but I do not know how it does -->
This is an example of what I have now:
<record model='res.country.state' id='mystateid01'> <!-- How can I point here to an existing state in res.country.state to fill only its empty column region_id? -->
<field name="region_id" ref="¿?"/>
The default syntax for this is "module_name.xml_record_id".
So for example if your module is called region_extend and you have multiple records in your XML for regions, you will need to check for those ids. If you have region catalonia named like <record id="cata"/>, then you reference should be like so:
<field name="region_id" ref="region_extend.cata"/>
Hope this helps.
If I understand you correctly, you already have records for countries as well as regions. These were all added by hand, and now you want to link them? In that case using the importer might help.
Take the following steps:
- Export the list of regions (go to regions list view, select all records and press "Export" to export as CSV). Make sure to export their ID at least.
- Export a list of countries in the same way, make sure to export the columns id and region_id at least, next to the purple coloured fields that are mandatory!
- Open in Excel or equivalent software and copy-paste the Id's from the region export to the country-export under the region_id column of the appropriate country.
- Import the country list.
Once imported, all the existing id's (aka countries) will be updated and only completely new countries will be added.
Hope this helps you out a little.
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
|Asked: 10/10/14, 7:14 AM|
|Seen: 1460 times|
|Last updated: 3/16/15, 8:10 AM|