Skip to Content
Menu
This question has been flagged
4 Replies
1480 Views

I am a starter in odoo. Can anyone help me to find a solution for the problem mentioned below?

in CRM Module, I  want to get a mail when a record is created with code

i have created a email template too, i want his to be done by code. can anyone help me to achieve this goal. Thanks in advance .


Avatar
Discard
Author

anyone ?

Best Answer

Already solution given to send mail

https://www.odoo.com/forum/help-1/question/how-to-trigger-mail-for-certain-field-when-it-changes-in-odoo12-171523

Override create method and send mail, based on your requirements.

Avatar
Discard
Author

i tried but iam getting error bro :

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'

function :

@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)

Updated answer, heck. Remove self.ids in create method and return change write into create.