Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

Change value of "partner_to" Email template

By
OUM
on 8/21/16, 10:53 AM 233 views

Hi, 

I want to send purchase order to another partner ,I create a wizard to select the partner that contains a many2one field :

 'customer_id': fields.many2one('res.partner', 'Customer',domain=[('customer','=',True)],required=True),

but I don't know how can I change the value of the partner in the template and the report of purchase,

This is my function : 

 

 def wkf_send_rfq2(self, cr, uid, ids, context=None):

  if not context:

context= {}

ir_model_data = self.pool.get('ir.model.data')

try:

template_id = ir_model_data.get_object_reference(cr, uid, 'mymodul', 'email_template_edi_purchase_done_drop33')[1]

except ValueError:

template_id = False

try:

compose_form_id = ir_model_data.get_object_reference(cr, uid, 'mail', 'email_compose_message_wizard_form')[1]

except ValueError:

compose_form_id = False

ctx = dict(context)

ctx.update({

'default_model': 'purchase.drop',

# 'default_res_id':ids[0]

'default_use_template': bool(template_id),

'default_template_id': template_id,

'default_composition_mode': 'comment',

})

return {

'name': _('Compose Email'),

'type': 'ir.actions.act_window',

'view_type': 'form',

'view_mode': 'form',

'res_model': 'mail.compose.message',

'views': [(compose_form_id, 'form')],

'view_id': compose_form_id,

'target': 'new',

'context': ctx,

}


Thanks, 

1

Pawan

--Pawan--
1267
| 4 3 5
Hyderabad, India
--Pawan--


Pawan
On 8/22/16, 2:05 AM

Oumaima,

You can simply get the template reference and update the email_to field of the template....

template_id = ir_model_data.get_object_reference(cr, uid, '<MODULE>', '<TEMPLATE_xmlid>')[1]

curr_obj = self.browse(cr, uid, ids)

self.pool.get('mail.template').write(cr, uid, template_id, {'email_to':curr_obj.customer_id.email})

at last... you can send the mail as:

res = self.pool.get('mail.template').send_mail(cr, uid, template_id, ids[0], force_send=True, context=context)


hope it help!!

0
OUM
On 8/22/16, 3:02 PM

Your response just add another address in  Recipient field, but what I want is to modify all informations of the partner in email wizard, and the address of the partner in purchase order report(PDF file)

Thanks Pawan, 

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 8/21/16, 10:53 AM
Seen: 233 times
Last updated: 8/22/16, 3:02 PM