Odoo Help

Welcome!

This community 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.

0

XML insert instead of update. Is it a bug???

By
Dariusz Kubiak
on 7/5/13, 1:20 PM 1,940 views

I want to update company name with a new module installation. I have company_data.xml

<?xml version="1.0" encoding="utf-8"?>
<openerp>
    <data noupdate="0">
      <record model="res.company" id="1">
        <field name="name">New name</field>
      </record>
    </data>
</openerp>

But instead of update the name it adds a new company with id=2. If I change the name value again AND id value 1 or 2 in XML then reinstall the module, it changes only the name of company id 2.

Why it doesn't change the name of company with id 1??? IS IT A BUG???

1

Sudhir Arya (SA)

--Sudhir Arya (SA)--
10150
| 6 8 8
Ahmedabad, India
--Sudhir Arya (SA)--

Working as an OpenERP/Odoo developer and a Team Leader 

Top 5 Odoo contributor On Stackoverflow

LinkedIn

Blog

Stackoverflow

Sudhir Arya (SA)
On 7/6/13, 2:38 AM

Try this:

<record id="base.main_company" model="res.company">
    <field name="name">Your Company Name</field>
    <field name="partner_id" ref="base.main_partner"/>
    <field name="rml_header1">Your Company Tagline</field>
    <field name="currency_id" ref="base.EUR"/>
</record>

Woks well! Than you :)

I create a new company named "Second Company”. It has id=3. How do I refere this company? It's not base.main_company. Using id=3 doesn't work - it adds a new record again. <record id="3" model="res.company"> <field name="name">Second Company 3</field> </record>

Macopedia Sp. z o.o, Dariusz Kubiak
on 7/8/13, 6:13 AM

Every record in xml is overwritten by it's ID (In our case it is base.main_company).

Sudhir Arya (SA)
on 7/8/13, 7:09 AM

My goal is to make configuration file in a separate module to update all settings at once (eg. in res.company, res.lang for Polish and more). Can I make it putting all settings to one XML? Polish language has id=2 1. When I update the settings like this: <record model="res.lang" id="2"> IntegrityError: null value in column "name" violates not-null constraint because it tryies to add new record, 2. or this: <record model="res.lang" id="base.main_company"> AssertionError: External ID conflict, main_company already refers to a res.company record, you can't define a res.lang record with this

Macopedia Sp. z o.o, Dariusz Kubiak
on 7/8/13, 9:53 AM

The ID is not '1', or '2', or '3'. That is the DATABASE ID. You don't get XML ID's for records you create via the UI. The ID is "base.main_company" for the main company because it was created via CSV or XML import from a module. If you want your companies to have XML ID's you either need to create them from a module or export them once you have entered them via the user interface.

Bista Solutions US, Ray Carnes
on 10/23/15, 4:02 PM
0

Grover Menacho

--Grover Menacho--
2523
| 5 7 8
La Paz, Bolivia
--Grover Menacho--

Systems Engineer + MBA

Grover Menacho
On 7/5/13, 1:53 PM

That id="1" doesn't mean that you are going to update that name to the id="1", it's saying that your xml view's name is "1". I'm not sure about this but you can try writing.

<record model="res.company" id="custom_module_company_name">
    <field name="id">1</field>
    <field name="name">New name</field>
  </record>

Maybe that could work.

Thx for answer! Still add a new company...

Macopedia Sp. z o.o, Dariusz Kubiak
on 7/8/13, 5:34 AM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

0 follower(s)

Stats

Asked: 7/5/13, 1:20 PM
Seen: 1940 times
Last updated: 3/16/15, 8:10 AM