hi all, iam trying to get mail when a new record created and modified for a field in CRM Module so i have defined this functions
in py:
@ api.multi
def write (self, vals):
if 'lead_status' in vals and self.ids:
for rec in self:
template = self.env.ref ('crm_extended.crm_lead_mail_template')
template.send_mail (rec.id, force_send = True)
return super (crm_extended, self) .write (vals)
@ api.multi
def create (self, vals):
if 'lead_status' in vals and self.ids:
for rec in self:
template = self.env.ref ('crm_extended.create_crm_lead_mail_template')
template.send_mail (rec.id, force_send = True)
return super (crm_extended, self) .write (vals)
when the change the state or give save, odoo popping me an error as below
Error:
Odoo Server Error
Traceback (most recent call last):
File "/opt/odoo/odoo-12.0/odoo/http.py", line 656, in _handle_exception
return super (JsonRequest, self) ._ handle_exception (exception)
File "/opt/odoo/odoo-12.0/odoo/http.py", line 314, in _handle_exception
raise pycompat.reraise(type(exception), exception, sys.exc_info()[2])
File "/opt/odoo/odoo-12.0/odoo/tools/pycompat.py", line 87, in reraise
raise value
File "/opt/odoo/odoo-12.0/odoo/http.py", line 698, in dispatch
result = self._call_function(**self.params)
File "/opt/odoo/odoo-12.0/odoo/http.py", line 346, in _call_function
return checked_call(self.db, *args, **kwargs)
File "/opt/odoo/odoo-12.0/odoo/service/model.py", line 98, in wrapper
return f(dbname, *args, **kwargs)
File "/opt/odoo/odoo-12.0/odoo/http.py", line 339, in checked_call
result = self.endpoint(*a, **kw)
File "/opt/odoo/odoo-12.0/odoo/http.py", line 941, in __call__
return self.method(*args, **kw)
File "/opt/odoo/odoo-12.0/odoo/http.py", line 519, in response_wrap
response = f(*args, **kw)
File "/opt/odoo/odoo-12.0/addons/web/controllers/main.py", line 962, in call_kw
return self._call_kw(model, method, args, kwargs)
File "/opt/odoo/odoo-12.0/addons/web/controllers/main.py", line 954, in _call_kw
return call_kw(request.env[model], method, args, kwargs)
File "/opt/odoo/odoo-12.0/odoo/api.py", line 757, in call_kw
return _call_kw_model_create(method, model, args, kwargs)
File "/opt/odoo/odoo-12.0/odoo/api.py", line 737, in _call_kw_model_create
result = method (recs, * args, ** kwargs)
File "<decorator-gen-260>", line 2, in create
File "/opt/odoo/odoo-12.0/odoo/api.py", line 461, in _model_create_multi
return create (self, [arg])
File "/opt/odoo/odoo-12.0/addons/base_automation/models/base_automation.py", line 231, in create
action._process (action._filter_post (records))
File "/opt/odoo/odoo-12.0/addons/base_automation/models/base_automation.py", line 164, in _filter_post
return self._filter_post_export_domain (records) [0]
File "/opt/odoo/odoo-12.0/addons/base_automation/models/base_automation.py", line 169, in _filter_post_export_domain
domain = [('id', 'in', records.ids)] + safe_eval (self.filter_domain, self._get_eval_context ())
AttributeError: 'bool' object has no attribute 'ids'
updated answer, check with latest code