4

I'm working on a custom module and i need to add field to res.partner model. I've add some field to this model but since 1 week, when i try to add a new one i got this error :

ERROR: column res_partner.my_field does not exist

Other field works good but not this one :

my_field = fields.Boolean(default=False)

I really don't unterstand why i have this issue. I've try to add 'contacts' dependencies to my module, it have work on my local version but not on my online verison

If somone has any idea it could be really nice

Thanks for your help

Edit res.partner classe

from odoo import api, fields, models
    
class ResPartner(models.Model):
    _inherit = 'res.partner'
    
    badge_ids = fields.One2many('mymodule.badge','client_i
    sub_ids = fields.One2many('mymodule.subs','client_id')
    #field that doesn't work
    my_field = fields.Boolean(default=False)

Manifest dependencies

'depends': ['base', 'sale', 'website', 'calendar','contacts', 'point_of_sale', 'base_automation'],
dcg
  • 4,187
  • 1
  • 18
  • 32

4 Answers4

6

Looks like a bug. Here's possible workaround:

Add 'res' to dependencies as well as 'base', then restart odoo instance.

after confirming fields updated; remove 'res' from dependencies then upgrade module.

This behavior exist on Odoo versions above 8.0

kholioeg
  • 326
  • 3
  • 5
  • thanks @kholioeg this was useful to install, but i think it may have interfered with the uninstall, now when i uninstall it the columns may not have been deleted, is this possible? – bermick Jan 28 '21 at 20:51
5
class Partner(models.Model):
    _inherit = "res.partner"

   my_field = fields.Boolean()

Note: Give 'base' as dependencies in manifest of your custom module.

Bhoomi Vaishnani
  • 718
  • 4
  • 19
0

I did this to solve it

  1. Comment your custom fields in xml file
  2. Add depands "base", "res" in your manifest
  3. Restart odoo
  4. Remove "res", "base"
  5. Upgrade your custom module
  6. Make sure new field added in the model that you want to inherit
  7. Uncomment your field in xml file
  8. Upgrade your custom module

Odoo 10

Remn
  • 251
  • 1
  • 3
  • 13
0

UPDATE:

A good solution for that is to inherit the model as a new model and I assume this is the official solution as well:

Class ResPartner(models.model):
    _name = 'res.partner'
    _inherit = 'res.partner'

    my_field = fields.Char()
kholioeg
  • 326
  • 3
  • 5