Hello,
I am trying to add a notification to hr resignation module. So that when one is creating a new resignation they are prompted to attach a letter of resignation. I am using a module 'popup message' from odoo apps to help with the creation of the pop-up.
I have added some extra lines of code shown below. to the def create function under hr_resignation.
from odoo import models, api
class ResignationPopUp(models.Model):
_inherit = 'hr.resignation'
@api.multi
def create(self, vals):
# assigning the sequence for the record
if vals.get('name', _('New')) == _('New'):
vals['name'] = self.env['ir.sequence'].next_by_code('hr.resignation') or _('New')
record = super(HrResignation, self).create(vals)
view = self.env.ref('sh_message.sh_message_wizard')
view_id = view and view.id or False context = dict(self.context or {})
context['message'] = "Please attach resignation letter \ for approval purposes"
return record, {'name': 'resignation letter required', 'type': 'ir.action.act_window', 'view_type': 'form', 'view_mode': 'form', 'res_model': 'sh.message.wizard', 'views': '[(view.id, form )]', 'view_id': 'view.id', 'target': 'new', 'context': 'context', }
However, I am getting this error while testing if it works.
Error:
Odoo Server Error
Traceback (most recent call last):
File "/home/viscar/odoo12/odoo/http.py", line 656, in _handle_exception
return super(JsonRequest, self)._handle_exception(exception)
File "/home/viscar/odoo12/odoo/http.py", line 314, in _handle_exception
raise pycompat.reraise(type(exception), exception, sys.exc_info()[2])
File "/home/viscar/odoo12/odoo/tools/pycompat.py", line 87, in reraise
raise value
File "/home/viscar/odoo12/odoo/http.py", line 698, in dispatch
result = self._call_function(**self.params)
File "/home/viscar/odoo12/odoo/http.py", line 346, in _call_function
return checked_call(self.db, *args, **kwargs)
File "/home/viscar/odoo12/odoo/service/model.py", line 97, in wrapper
return f(dbname, *args, **kwargs)
File "/home/viscar/odoo12/odoo/http.py", line 339, in checked_call
result = self.endpoint(*a, **kw)
File "/home/viscar/odoo12/odoo/http.py", line 941, in __call__
return self.method(*args, **kw)
File "/home/viscar/odoo12/odoo/http.py", line 519, in response_wrap
response = f(*args, **kw)
File "/home/viscar/odoo12/addons/web/controllers/main.py", line 962, in call_kw
return self._call_kw(model, method, args, kwargs)
File "/home/viscar/odoo12/addons/web/controllers/main.py", line 954, in _call_kw
return call_kw(request.env[model], method, args, kwargs)
File "/home/viscar/odoo12/odoo/api.py", line 749, in call_kw
return _call_kw_multi(method, model, args, kwargs)
File "/home/viscar/odoo12/odoo/api.py", line 736, in _call_kw_multi
result = method(recs, *args, **kwargs)
TypeError: create() missing 1 required positional argument: 'vals'