This question has been flagged
4 Replies
9880 Views

Hello there,

We are on Odoo 8.

It is really not the first time that I try to update a record in the database.

I have declared the file in my __openerp__.py file, like I always do.

In my custom module, I have put this code :

<?xml version="1.0" encoding="utf-8"?>
    <openerp>
        <data noupdate="0">
            <record id="account.account_financial_report_profitloss_toreport0" model="account.financial.report">
                 <field name="name">Effacer</field>
                 <field name="parent_id" eval="4" />
             </record>
         </data>
    </openerp>


I have unchecked the "non updatable" checkbox of the record "account_financial_report_profitloss_toreport0" in external identifiers before tu update my module.

I see in the log that my custom .xml file is well read. 

But nothing happens!!! 

Is this something special with this record? Why it is impossible to update? 

I did it 1000 times before...


EDIT #1

I tried with the field "sign" also declared. No success... No update...

        <record id="account.account_financial_report_profitloss_toreport0" model="account.financial.report">

<field name="name">Effacer</field>
<field name="sign" eval="1" />
<field name="parent_id" eval="4" />
</record>




Avatar
Discard

I suppose your problem is a field named "sign" in this model, it is required.

Author

Hello my old friend Zbik! Are you saying that I should also declare the field "sign" in my custom XML record even if I don't really want to change the value of this field? When a field is "required", we always have to include it to update a record?

No. I understood that you are creating a new record. If you do an update and it does not work, then this record is probably already marked in ir.model.data as noupdate = 1. Verify it directly in database.

Author

noupdate was already to False for this record. It is the first thing I have verified. It is not the problem.

id=4 exist and is active? a better solution is:

<field name="parent_id" ref="account.HERE_NAME_ID_4"/>, probably this should be

<field name="parent_id" ref="account.account_financial_report_liabilitysum0"/>

PS 1. noupdate = False is unexpected, original record account_financial_report_profitloss_toreport0 has noupdate=1

PS 2. module depends is set ok?

Is it by chance another module does not overwrite this record as well?

Author

I have cut and pasted once again in my custom XML file and it worked. I have absolutely no idea of what was the problem. Big thanks for your help!

Best Answer

Hi Pascal,

You are not able to see the change is because the record is already set as noupdate=1 in the XML file of account module.

To make it work you have to set noupdate to 0 by update query and then upgrade your module.

Query:

UPDATE ir_model_data SET noupdate=False WHERE name='account_financial_report_profitloss_toreport0' and module='account';


Sudhir Arya
ERP Harbor Consulting Services
skype: sudhir@erpharbor.com  website: http://www.erpharbor.com
Avatar
Discard
Author

noupdate was already to False. It is the first thing I have verified. It is not the problem.

Author

I have cut and pasted once again in my custom XML file and it worked. I have absolutely no idea of what was the problem. Big thanks for your help!

You cannot override noupdate. If it is set to true in account module, you must unlock it with SQL before you can update it.