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

Column x does not exist error (custom module)

By
Glenn
on 12/20/14, 7:02 AM 2,735 views

Hello everyone

 

I've added a column to my custom module as show in the example below:

class res_partner(osv.osv): 
_inherit = 'res.partner'
_columns = { 'x_invoice_partner': fields.boolean('Invoice partner', help="Select this if you want to send invoices to this person")

Then I added that field to my custom XML file as shown below:

<record id="view_partner_form" model="ir.ui.view">
<field name="name">res.partner.form</field>
<field name="model">res.partner</field>
<field eval="1" name="priority"/>
<field name="inherit_id" ref="base.view_partner_form"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='use_parent_address']" position="after">
<field name="x_invoice_partner"/> </xpath>
</field> </record>

When I save this and restart the server I get this message: "column res_partner.x_invoice_partner does not exist" when I want to login. What exactly am I doing wrong here? Thanks in advance

EDIT: Sorry @zbik apparently I don't have enough karma to react to someone's response, I can't update the module since I get the error message when login. So I can't get past the login screen and thus can't get to the settings. Thanks in advance

 

You have a spaces or tabs before _inherit and before _columns?

zbik
on 12/20/14, 7:09 AM

@zbik Yes I have a tab before both of them, sorry I couldn't properly edit it in the post

Glenn
on 12/20/14, 7:11 AM

You have a column 'x_invoice_partner' in database? (you upgrade your module or only restart the server?)

zbik
on 12/20/14, 7:33 AM

@zbik I've only restarted the server, I've read something about updating the database with a command in the terminal, is this needed?

Glenn
on 12/20/14, 7:46 AM

Maybe add a column in the database manually, should help.

zbik
on 12/20/14, 8:16 AM

You update all modules by (if ubuntu or debian): $su - odoo -s /bin/bash $/usr/bin/openerp-server -d YOURDATABASE -u all --stop-after-init --config="/etc/openerp/openerp-server.conf"

zbik
on 12/20/14, 8:21 AM

If you are logged in, then remove from the database, and you perform Upgrade.

zbik
on 12/20/14, 8:50 AM
0

Med Said BARA

--Med Said BARA--
2664
| 5 5 7
Algeria
--Med Said BARA--
Med Said BARA
On 12/20/14, 9:01 AM

To avoid any confusion and If you just want to add a new field "x_invoice_partner'" to the class res_partner and display it in the base.view_partner_form;

Give to your class a distinguished name: my_respartner and use a "Class Inheritance" by adding  _name = 'res.partner' in your class definition.

class my_respartner(osv.osv): 

_name = 'res.partner'

_inherit = 'res.partner' 


_columns = 

     { 'x_invoice_partner': fields.boolean('Invoice partner', help="Select this if you want to send invoices to this person")

 

Do the same for the view in .xml (to avoid any confusion and form name conflict): 

<record id="view_partner_form_sendinvoice" model="ir.ui.view"> or 

<field name="name">res.partner.form.sendinvoice</field>

<field name="model">res.partner</field>

<field name="inherit_id" ref="base.view_partner_form"/>

<field name="arch" type="xml">
<xpath expr="//field[@name='use_parent_address']" position="after">
<field name="x_invoice_partner"/> 

</xpath>
</field>

</record>

Last, respect the indentation.

0

zbik

--zbik--
5941
| 6 4 7
Lodz, Poland
--zbik--


zbik
On 12/20/14, 7:52 AM

Update your module on admin site Settings/Local Modules. You remove filter "Apps", search your module name, open view, and click on "Upgrade".

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

2 follower(s)

Stats

Asked: 12/20/14, 7:02 AM
Seen: 2735 times
Last updated: 3/16/15, 8:10 AM