Skip to Content
Menu
This question has been flagged
2 Replies
12946 Views

i'm using odoo 11 and i develop a custom module to fix the stages in the "hr.applicant" model but it shows error ValueError: The _name attribute Applicant is not valid. Any idea for help please ?

Traceback

Traceback (most recent call last):
File "/opt/openhrms/odoo/http.py", line 651, in _handle_exception
return super(JsonRequest, self)._handle_exception(exception)
File "/opt/openhrms/odoo/http.py", line 310, in _handle_exception
raise pycompat.reraise(type(exception), exception, sys.exc_info()[2])
File "/opt/openhrms/odoo/tools/pycompat.py", line 87, in reraise
raise value
File "/opt/openhrms/odoo/http.py", line 693, in dispatch
result = self._call_function(**self.params)
File "/opt/openhrms/odoo/http.py", line 342, in _call_function
return checked_call(self.db, *args, **kwargs)
File "/opt/openhrms/odoo/service/model.py", line 97, in wrapper
return f(dbname, *args, **kwargs)
File "/opt/openhrms/odoo/http.py", line 335, in checked_call
result = self.endpoint(*a, **kw)
File "/opt/openhrms/odoo/http.py", line 937, in __call__
return self.method(*args, **kw)
File "/opt/openhrms/odoo/http.py", line 515, in response_wrap
response = f(*args, **kw)
File "/opt/openhrms/addons/web/controllers/main.py", line 938, in call_button
action = self._call_kw(model, method, args, {})
File "/opt/openhrms/addons/web/controllers/main.py", line 926, in _call_kw
return call_kw(request.env[model], method, args, kwargs)
File "/opt/openhrms/odoo/api.py", line 689, in call_kw
return call_kw_multi(method, model, args, kwargs)
File "/opt/openhrms/odoo/api.py", line 680, in call_kw_multi
result = method(recs, *args, **kwargs)
File "<decorator-gen-57>", line 2, in button_immediate_install
File "/opt/openhrms/odoo/addons/base/module/module.py", line 72, in check_and_log
return method(self, *args, **kwargs)
File "/opt/openhrms/odoo/addons/base/module/module.py", line 450, in button_immediate_install
return self._button_immediate_function(type(self).button_install)
File "/opt/openhrms/odoo/addons/base/module/module.py", line 552, in _button_immediate_function
modules.registry.Registry.new(self._cr.dbname, update_module=True)
File "/opt/openhrms/odoo/modules/registry.py", line 85, in new
odoo.modules.load_modules(registry._db, force_demo, status, update_module)
File "/opt/openhrms/odoo/modules/loading.py", line 380, in load_modules
loaded_modules, update_module, models_to_check)
File "/opt/openhrms/odoo/modules/loading.py", line 274, in load_marked_modules
perform_checks=perform_checks, models_to_check=models_to_check
File "/opt/openhrms/odoo/modules/loading.py", line 153, in load_module_graph
registry.init_models(cr, model_names, {'module': package.name})
File "/opt/openhrms/odoo/modules/registry.py", line 306, in init_models
model._auto_init()
File "/opt/openhrms/odoo/models.py", line 2180, in _auto_init
raise_on_invalid_object_name(self._name)
File "/opt/openhrms/odoo/models.py", line 97, in raise_on_invalid_object_name
raise ValueError(msg)
ValueError: The _name attribute Applicant is not valid.

hr_recruitment_view.py

<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data noupdate="1">
    <record model="hr.recruitment.stage" id="default_stage_job">
        <field name="name">CV in progress</field>
        <field name="sequence">0</field>
    </record>

 </data>
</odoo>

hr_recruitment.py

 class Applicant(models.Model):
_inherit = "hr.applicant"

def _default_stage_id(self):
    # Search your stage
    stage_id = self.env['hr.recruitment.stage'].search([('name', '=', 'CV in progress')], limit=1).id
    if stage_id:
        return stage_id
    return super(Applicant, self)._default_stage_id()
Avatar
Discard
Best Answer

votre fonction n'est pas optimiser:

def _default_stage_id(self):
    # Search your stage
    return self.ref('module.default_stage_job') or super(Applicant, self)._default_stage_id()

le message d'erreur apparaît lors de l'installation/mise à jour du module ou lors de l'accès au menu des candidatures?

Avatar
Discard
Best Answer

Hello,

somewhere model name is given as "Applicant" and upper Case is not allow as model name in Odoo.

Please check model name in your custom modules.

Avatar
Discard
Related Posts Replies Views Activity
2
Feb 24
13200
1
Dec 22
3863
2
Dec 22
12725
2
Jun 22
4688
2
Jun 22
3505