Skip to Content
Menu
This question has been flagged
1 Reply
2130 Views
Odoo Server Error
Traceback (most recent call last):
  File "C: \ Program Files (x86) \ Odoo 13.0 \ server \ odoo \ http.py", line 624, in _handle_exception
    return super (JsonRequest, self) ._ handle_exception (exception)
  File "C: \ Program Files (x86) \ Odoo 13.0 \ server \ odoo \ http.py", line 310, in _handle_exception
    raise pycompat.reraise (type (exception), exception, sys.exc_info () [2])
  File "C: \ Program Files (x86) \ Odoo 13.0 \ server \ odoo \ tools \ pycompat.py", line 14, in reraise
    raise value
  File "C: \ Program Files (x86) \ Odoo 13.0 \ server \ odoo \ http.py", line 669, in dispatch
    result = self._call_function (** self.params)
  File "C: \ Program Files (x86) \ Odoo 13.0 \ server \ odoo \ http.py", line 350, in _call_function
    return checked_call (self.db, * args, ** kwargs)
  File "C: \ Program Files (x86) \ Odoo 13.0 \ server \ odoo \ service \ model.py", line 94, in wrapper
    return f (dbname, * args, ** kwargs)
  File "C: \ Program Files (x86) \ Odoo 13.0 \ server \ odoo \ http.py", line 339, in checked_call
    result = self.endpoint (* a, ** kw)
  File "C: \ Program Files (x86) \ Odoo 13.0 \ server \ odoo \ http.py", line 915, in __call__
    return self.method (* args, ** kw)
  File "C: \ Program Files (x86) \ Odoo 13.0 \ server \ odoo \ http.py", line 515, in response_wrap
    response = f (* args, ** kw)
  File "C: \ Program Files (x86) \ Odoo 13.0 \ server \ odoo \ addons \ web \ controllers \ main.py", line 1326, in call_button
    action = self._call_kw (model, method, args, kwargs)
  File "C: \ Program Files (x86) \ Odoo 13.0 \ server \ odoo \ addons \ web \ controllers \ main.py", line 1314, in _call_kw
    return call_kw (request.env [model], method, args, kwargs)
  File "C: \ Program Files (x86) \ Odoo 13.0 \ server \ odoo \ api.py", line 387, in call_kw
    result = _call_kw_multi (method, model, args, kwargs)
  File "C: \ Program Files (x86) \ Odoo 13.0 \ server \ odoo \ api.py", line 374, in _call_kw_multi
    result = method (recs, * args, ** kwargs)
  File "C: \ Program Files (x86) \ Odoo 13.0 \ server \ odoo \ addons \ mail \ wizard \ mail_compose_message.py", line 204, in action_send_mail
    self.send_mail ()
  File "C: \ Program Files (x86) \ Odoo 13.0 \ server \ odoo \ addons \ mail \ wizard \ mail_compose_message.py", line 284, in send_mail
    ActiveModel.browse (res_id) .message_post (** post_params)
  File "C: \ Program Files (x86) \ Odoo 13.0 \ server \ odoo \ addons \ mail \ models \ mail_thread.py", line 1897, in message_post
    self._notify_thread (new_message, values, ** notif_kwargs)
  File "C: \ Program Files (x86) \ Odoo 13.0 \ server \ odoo \ addons \ sms \ models \ mail_thread.py", line 205, in _notify_thread
    recipients_data = super (MailThread, self) ._ notify_thread (message, msg_vals = msg_vals, ** kwargs)
  File "C: \ Program Files (x86) \ Odoo 13.0 \ server \ odoo \ addons \ mail \ models \ mail_thread.py", line 2144, in _notify_thread
    self._notify_record_by_email (message, rdata, msg_vals = msg_vals, ** kwargs)
  File "C: \ Program Files (x86) \ Odoo 13.0 \ server \ odoo \ addons \ mail \ models \ mail_thread.py", line 2210, in _notify_record_by_email
    recipients_groups_data = self._notify_classify_recipients (partners_data, model_name)
  File "C: \ Program Files (x86) \ Odoo 13.0 \ server \ odoo \ addons \ mail \ models \ mail_thread.py", line 2572, in _notify_classify_recipients
    groups = self._notify_get_groups ()
  File "C: \ Program Files (x86) \ Odoo 13.0 \ server \ odoo \ addons \ portal \ models \ portal_mixin.py", line 65, in _notify_get_groups
    customer = self ['partner_id']
  File "C: \ Program Files (x86) \ Odoo 13.0 \ server \ odoo \ models.py", line 5620, in __getitem__
    return self._fields [key] .__ get __ (self, type (self))
KeyError: 'partner_id'


my template:

<record id = "email_prescription_template" model = "mail.template" > 
<field name = "name" > Email Prescription Template </field>
<field name = "model_id" ref = "basic_hms.model_medical_prescription_order" />
<field name = "email_from" > $ {(object.user_id.email_formatted or user.email_formatted) | safe} </field>
<field name = "partner_to" > $ {(object.patient_id.patient_id.id) | (object.patient_id.mail)} <
> Patient Prescription Ref $ {object.name or 'n / a'} </field>
<field name = "auto_delete" eval = "True" />
<field name = "lang" > $ {object.user_id.lang} </field>
<field name = "body_html" type = "html" >
<div style = "margin: 0px; padding: 0px;" >
<p style = "margin: 0px; padding: 0px; font-size: 13px;" >
% set doc_name = 'Prescription Details'
Hello,



<strong> $ {object.name} </strong>
<br/>
Do not hesitate to contact us if you have any questions.
<br/>
</p>
</div>
</field>
</record>

button:

this is button:
<button
name = "action_prescription_send" string = "Send by Email" type = "object"
class = "oe_highlight" />


python method:

def action_prescription_send ( self ): 
'' 'Opens a wizard to compose an email, with relevant mail template loaded by default' ''
self .ensure_one ()
template_id =self .env.ref ( " basic_hms.email_prescription_template " ) .id template = self .env [ 'mail.template' ] .browse (template_id)

if template.lang:
lang = template._render_template (template.lang , 'medical.prescription.order' , self .ids [ 0 ])
ctx = {
'default_model' : 'medical.prescription.order' ,
'default_res_id' : self .ids [ 0 ] , 'default_use_template' : bool (template_id) , 'default_template_id' : template_id , 'default_composition_mode' : 'comment' , 'mark_so_as_sent' : True , 'force_email' : True ,}
return

{ 'name' : _ ( 'Compose Email' ) ,
'type' : 'ir.actions.act_window' ,
'view_mode' : 'form' , 'res_model' : 'mail.compose.message' ,
'views' : [ ( False , 'form' )] ,
'view_id' : False ,
'target' : 'new' ,
'context' : ctx ,
}
Avatar
Discard
Best Answer

Hello, it seems like you accidentally put 2 partner_id in partner_to.:

$ {(object.patient_id.patient_id.id) | (object.patient_id.mail)}

Try this:

<record id = "email_prescription_template" model = "mail.template" > 
<field name = "name" > Email Prescription Template </field>
<field name = "model_id" ref = "basic_hms.model_medical_prescription_order" />
    <field name = "email_from" > $ {(object.user_id.email_formatted or user.email_formatted) | safe}</field>
   <field name = "partner_to">${object.partner_id.id}</field>
<field name = "auto_delete" eval = "True" />
<field name = "lang" > $ {object.user_id.lang} </field>
<field name = "body_html" type = "html" >
<div style = "margin: 0px; padding: 0px;" >
<p style = "margin: 0px; padding: 0px; font-size: 13px;" >
% set doc_name = 'Prescription Details'
Hello,



<strong> $ {object.name} </strong>
<br/>
Do not hesitate to contact us if you have any questions.
<br/>
</p>
</div>
</field>
</record>

Please vote if it helps.
Avatar
Discard
Related Posts Replies Views Activity
4
May 24
10077
1
Apr 24
1566
0
Nov 23
525
1
Sep 23
572
2
Aug 23
2427