This question has been flagged
3 Replies
8274 Views

Hi, this is a simple issue on a simple example (with all data provided here). I'm using OpenERP 7.0-20130212-002145

I've created a very simple module as shown below (it adds one field named dtc_dc_ident to account.invoice object and view), and when I install it all goes fine, but when I update it (with no change at all) I get the following error (in the server log file):

2013-02-13 18:17:22,721 1448 ERROR test7 openerp.osv.orm: Can't find field 'dtc_dc_ident' in the following view parts composing the view of object model 'account.invoice':

  • a_test_inherit.account.invoice.form

If I comment the line <field name="dtc_dc_ident" required="1"/> it works fine (and the field dtc_dc_ident is visible in the account.invoice object model)

This problem only arises on account.invoice, for example on hr.holidays all is OK.

Here is the module structure (4 files):

a_test

__init__.py __openerp__.py a_test_account_invoice.py a_test_account_invoice.xml

Here is the content of each file :

__init__.py

import a_test_account_invoice

__openerp__.py

{
"name" : "short description : a_test",
"version" : "1.0",
"author" : "Test DTC",
"website" : "none",
"category" : "Generic Modules/Others",
"depends" : ["base", "account" ],
"description" : "Description : A Test  module",
"init_xml" : ["a_test_account_invoice.xml", ],
"demo_xml" : [],
"update_xml" : [],
"active": False,
"installable": True,
"application": True,
}

a_test_account_invoice.py

from osv import fields, osv
import os
import time
import pooler
import codecs
import datetime
import string

from tools.translate import _
class account_invoice(osv.osv):
  _name = 'account.invoice'
  _inherit = 'account.invoice'
  _description = 'Invoice'
  _columns = {
    'dtc_dc_ident': fields.char('Identifiant DC', required=False, size=32),
  }
account_invoice()

a_test_account_invoice.xml

<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="a_test_inherit_invoice_form" model="ir.ui.view">
<field name="name">a_test_inherit.account.invoice.form</field>
<field  name="inherit_id"  ref="account.invoice_form"/>
<field name="model">account.invoice</field>
<field name="type">form</field>
<field name="arch" type="xml">
<field name="name" position="after">
<field name="dtc_dc_ident" required="1"/>
</field>
</field>
</record>

</data>
</openerp>
Avatar
Discard
Author

Not sure I'm allowed to push my post back up in this way... but I would like it if someone could test this and confirm what I get...

Thanks

No, this is not a good practice. Although I converted your "answer" into a comment.

Best Answer

Maybe you can change:

"init_xml" : ["a_test_account_invoice.xml", ],

by:

"update_xml" : ["a_test_account_invoice.xml", ],

Avatar
Discard
Author Best Answer

Try to :

uninstall your module
restart your server OpenERP
install your module

I had the same problem and it's the only one solution i found. Tell me if it work.

Yes, this will work, but this doesn't solve my issue, because normally you can update a module without uninstalling it (and restarting the server is only in case you change the python code). Besides, the above example works perfectly if you simply replace account.invoice with hr.holidays (and adapt a little)... so I'm sure it's related to something specific with account.invoice.

ybe you can change:

"init_xml" : ["a_test_account_invoice.xml", ],

by:

"update_xml" : ["a_test_account_invoice.xml", ],

I'd tested this already... but I'll test again just to see.

Thanks for your input in all cases, I'll be back after a few more tests.

Avatar
Discard
Author

Well, I've done the above tests and it performs as I expected.... indeed, uninstall and reinstall works fine, but this isn't right, upgrade should work too.

Changing using update instead of init didn't change anything....

Author

Again... if I use hr.holidays instead of account.invoice no problem arises..

Best Answer

Try to :

  1. uninstall your module
  2. restart your server OpenERP
  3. install your module

I had the same problem and it's the only one solution i found. Tell me if it work.

Avatar
Discard