1

I am writing a code to add new field in "res.partner". I searched everywhere but couldn't find the solution to this problem.

I am naming the Class "ResPartner" and inheriting "res.partner". adding personal_id field and running and installing the module it worked fine. Now,

If: I add a new field in that existing DB it will give me the error that res_partner. does not exist.

BUT: If I create a new db after I have written the new fields in python under "res.partner" and install the module in that db it will run without any error.

class ResPartner(models.Model):
    _inherit = 'res.partner'

    personal_id = fields.Char(string="Personal ID Number")
    child_name_new = fields.Integer(string="Name of the Child:")
    birth_date_child = fields.Date(string="Date of birth of child")
    admission_date_child = fields.Date(string="Date of admission")

EXPECTED: NO ERROR

ERROR:

File /home/braincrew/Documents/projects/odoo/odoo12/odoo/odoo/models.py", line 2765, in read
    self._read_from_database(stored, inherited)
  File "/home/braincrew/Documents/projects/odoo/odoo12/odoo/odoo/models.py", line 2892, in _read_from_database
    cr.execute(query_str, params)
  File "/home/braincrew/Documents/projects/odoo/odoo12/odoo/odoo/sql_db.py", line 148, in wrapper
    return f(self, *args, **kwargs)
  File "/home/braincrew/Documents/projects/odoo/odoo12/odoo/odoo/sql_db.py", line 225, in execute
    res = self._obj.execute(query, params)
psycopg2.ProgrammingError: column res_partner.child_name_new does not exist
LINE 1: ...nce","res_partner"."personal_id" as "personal_id","res_partn..."
rahul rachh
  • 99
  • 1
  • 12

2 Answers2

1

Are you using any custom modules ? Because the error shows ,

psycopg2.ProgrammingError: column res_partner.loan_value does not exist

i think the field loan_value is from a custom module , and it may the reason of the error.

Ajmal JK
  • 813
  • 4
  • 14
  • sorry my bad actually that is the original field of the project that i am working on. i have actually recreated the above class which is similar to the project that i am working on right now. i fogot to rename the field in the error. i have done that please have a look – rahul rachh May 28 '19 at 06:37
  • So the error occur when you try to upgrade your module ? – Ajmal JK May 28 '19 at 06:58
  • yeah it gave me the error when i try to upgrade the module – rahul rachh May 29 '19 at 06:23
  • @rahulrachh did you try uninstall and install the module. – Ajmal JK May 29 '19 at 06:51
  • Yeah i did that. so when i get this error i go to __init__.py and remove the python file that has res.partner. after the i restart the server uninstall the module, add the python file that has res.partner object. only that it will accept the newly added fields. – rahul rachh May 31 '19 at 10:24
0

I think your problem is somehow similar with this one Error column doesn't exist on custom module Odoo

I also read here https://ngasturi.id/2021/01/12/mengatasi-error-column-does-not-exist-pada-odoo/ that that error only occurs when you add new fields in res.partner or res.users on already installed module. One solution is to run this query on your database

update ir_module_module set state = 'uninstalled' where name = 'your_module';

then restart your service and install that module again. And don't worry about your data, it is save.

The other way is to upgrade your module via command line.