Trợ giúp

0

Field `is_blacklisted` does not exist

Avatar
Talmid

I am building a custom module where I add an extra field to partner (Organic Certifier Code). It was working fine until I accidentally I added an user to a group and then I removed it, now the server crashes if I use my module. I use Odoo v12.

Here is my class: models/partner.py

# -*- coding: utf-8 -*-
from odoo import fields, models
class Partner(models.Model):
     _inherit = 'res.partner'

     organic_certifier_code = fields.Char("Organic Certifier Code") 

 
Here is my view views/partner.xml

<?xml version="1.0" encoding="UTF-8"?>
<odoo>
	<record model="ir.ui.view" id="partner_organic_certifier_form_view">
    <field name="model">res.partner</field>
    <field name="inherit_id" ref="base.view_partner_form"/>
    <field name="arch" type="xml">
      <field name="vat" position="after">
			  <field name="organic_certifier_code" placeholder="e.g. BIO-0001"/>
      </field>
    </field>
	</record>
</odoo>

And here is the error I get:

2018-11-22 14:31:23,952 2784 ERROR mymodule werkzeug: Error on request:
Traceback (most recent call last):
  File "/opt/odoo/odoo12-venv/lib/python3.6/site-packages/werkzeug/serving.py", line 205, in run_wsgi
    execute(self.server.app)
  File "/opt/odoo/odoo12-venv/lib/python3.6/site-packages/werkzeug/serving.py", line 193, in execute
    application_iter = app(environ, start_response)
  File "/opt/odoo/odoo12/odoo/service/wsgi_server.py", line 126, in application
    return werkzeug.contrib.fixers.ProxyFix(application_unproxied)(environ, start_response)
  File "/opt/odoo/odoo12-venv/lib/python3.6/site-packages/werkzeug/contrib/fixers.py", line 152, in __call__
    return self.app(environ, start_response)
  File "/opt/odoo/odoo12/odoo/service/wsgi_server.py", line 117, in application_unproxied
    result = odoo.http.root(environ, start_response)
  File "/opt/odoo/odoo12/odoo/http.py", line 1317, in __call__
    return self.dispatch(environ, start_response)
  File "/opt/odoo/odoo12/odoo/http.py", line 1290, in __call__
    return self.app(environ, start_wrapped)
  File "/opt/odoo/odoo12-venv/lib/python3.6/site-packages/werkzeug/wsgi.py", line 599, in __call__
    return self.app(environ, start_response)
  File "/opt/odoo/odoo12/odoo/http.py", line 1489, in dispatch
    response = self.get_response(httprequest, result, explicit_session)
  File "/opt/odoo/odoo12/odoo/http.py", line 287, in __exit__
    elif self.registry:
  File "/opt/odoo/odoo12/odoo/http.py", line 378, in registry
    return odoo.registry(self.db)
  File "/opt/odoo/odoo12/odoo/__init__.py", line 78, in registry
    return modules.registry.Registry(database_name)
  File "/opt/odoo/odoo12/odoo/modules/registry.py", line 62, in __new__
    return cls.new(db_name)
  File "/opt/odoo/odoo12/odoo/modules/registry.py", line 86, in new
    odoo.modules.load_modules(registry._db, force_demo, status, update_module)
  File "/opt/odoo/odoo12/odoo/modules/loading.py", line 422, in load_modules
    force, status, report, loaded_modules, update_module, models_to_check)
  File "/opt/odoo/odoo12/odoo/modules/loading.py", line 318, in load_marked_modules
    perform_checks=perform_checks, models_to_check=models_to_check
  File "/opt/odoo/odoo12/odoo/modules/loading.py", line 224, in load_module_graph
    load_data(cr, idref, mode, kind='data', package=package, report=report)
  File "/opt/odoo/odoo12/odoo/modules/loading.py", line 68, in load_data
    tools.convert_file(cr, package.name, filename, idref, mode, noupdate, kind, report)
  File "/opt/odoo/odoo12/odoo/tools/convert.py", line 792, in convert_file
    convert_xml_import(cr, module, fp, idref, mode, noupdate, report)
  File "/opt/odoo/odoo12/odoo/tools/convert.py", line 853, in convert_xml_import
    obj.parse(doc.getroot(), mode=mode)
  File "/opt/odoo/odoo12/odoo/tools/convert.py", line 754, in parse
    exc_info[2]
  File "/opt/odoo/odoo12/odoo/tools/pycompat.py", line 86, in reraise
    raise value.with_traceback(tb)
  File "/opt/odoo/odoo12/odoo/tools/convert.py", line 748, in parse
    self._tags[rec.tag](rec, de, mode=mode)
  File "/opt/odoo/odoo12/odoo/tools/convert.py", line 653, in _tag_record
    record = model.with_context(rec_context)._load_records([data], self.mode == 'update')
  File "/opt/odoo/odoo12/odoo/models.py", line 3795, in _load_records
    records = self.create([data['values'] for data in to_create])
  File "<decorator-gen-32>", line 2, in create
    
  File "/opt/odoo/odoo12/odoo/api.py", line 452, in _model_create_multi
    return create(self, arg)
  File "/opt/odoo/odoo12/odoo/addons/base/models/ir_ui_view.py", line 418, in create
    return super(View, self).create(vals_list)
  File "<decorator-gen-3>", line 2, in create
    
  File "/opt/odoo/odoo12/odoo/api.py", line 452, in _model_create_multi
    return create(self, arg)
  File "/opt/odoo/odoo12/odoo/models.py", line 3540, in create
    fields[0].determine_inverse(batch_recs)
  File "/opt/odoo/odoo12/odoo/fields.py", line 1104, in determine_inverse
    getattr(records, self.inverse)()
  File "/opt/odoo/odoo12/odoo/addons/base/models/ir_ui_view.py", line 268, in _inverse_arch
    view.write(data)
  File "/opt/odoo/odoo12/addons/website/models/ir_ui_view.py", line 70, in write
    super(View, self).write(vals)
  File "/opt/odoo/odoo12/odoo/addons/base/models/ir_ui_view.py", line 434, in write
    return super(View, self).write(self._compute_defaults(vals))
  File "/opt/odoo/odoo12/odoo/models.py", line 3257, in write
    self._write(store_vals)
  File "/opt/odoo/odoo12/odoo/models.py", line 3401, in _write
    self._validate_fields(vals)
  File "/opt/odoo/odoo12/odoo/models.py", line 1104, in _validate_fields
    raise ValidationError("%s\n\n%s" % (_("Error while validating constraint"), tools.ustr(e)))
odoo.tools.convert.ParseError: "Error while validating constraint

Field 'is_blacklisted' used in attributes must be present in view but is missing:
 - 'is_blacklisted' in attrs="{'invisible': [('is_blacklisted', '=', False)]}"

Error context:
View `res.partner form`
[view_id: 1639, xml_id: n/a, model: res.partner, parent_id: 113]
None" while parsing /opt/odoo/odoo12-custom-addons/mymodule/views/partner.xml:3, near
<record model="ir.ui.view" id="partner_organic_certifier_form_view">
    <field name="model">res.partner</field>
    <field name="inherit_id" ref="base.view_partner_form"/>
    <field name="arch" type="xml">
      <field name="vat" position="after">
			  <field name="organic_certifier_code" placeholder="e.g. BIO-0001"/>
      </field>
    </field>
	</record> 830 0.804 2.941
How could I find out what the actual problem is? To fix this would it be better to create a new database and import the entries again?
Ảnh đại diện
Huỷ bỏ
1 Trả lời
4
Avatar
Axel Priem
Best Answer

I had the exact same problem yesterday with v12. After a long search, I found the cause. The field is_blacklisted is restricted to group "base.group_user". And apparently, the user "__system__" (which is used by Odoo when building the module and views), had suddenly lost its access to this group. Therefore the field was "invisible" and an error appears that says the field is missing from the view. 

To fix it: go to settings >  users and show the inactive users by changing the filter (__system__ is always an inactive user). Then for this user, set the user type to "internal user" (this is the group "base.group_user"). This fixed it for me!

2 Bình luận
Ảnh đại diện
Huỷ bỏ
Avatar
Talmid
-

I'm sorry I couldn't test it, meanwhile I tried to rename the database and than naming it back, but the css was not working anymore. So I will just recreate everything. The whole issue happened when I installed a module "app_odoo_customize", it changed my whole configuration to their company also when I tried to unpublish items from the website they disappeared... Thank you for your help though!

Avatar
DWARKANATH BARI
-

It's work for me. Thanks