Skip to Content
Menu
This question has been flagged

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

 

Avatar
Discard

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

Author

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

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

Author

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

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

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"

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

Best Answer

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

Avatar
Discard
Best Answer

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.

Avatar
Discard
Related Posts Replies Views Activity
5
Dec 22
5557
0
May 21
1273
1
Aug 24
420
2
Nov 24
748
3
Oct 23
13195