openerp - Odoo 10 how to check if Purchase Order "Sent PO by email" action was executed or not -


in odoo 10, possible define report list purchase orders marked confirmed not sent email supplier?
i.e., how can detect if in purchase order action "sent po email" completed or not.

thanks,

you can using following simple way.

step 1 : add 1 boolean field in purchase order model , update context in following method.

from odoo import fields,models,api  class purchase_order(models.model):     _inherit="purchase.order"      sent_po_via_email=fields.boolean("sent po via email",default=false,copy=false)       @api.multi     def action_rfq_send(self):         '''         function opens window compose email, edi purchase template message loaded default         '''         self.ensure_one()         ctx = dict(self.env.context or {})         ir_model_data = self.env['ir.model.data']         try:             if self.env.context.get('send_rfq', false):                 template_id = ir_model_data.get_object_reference('purchase', 'email_template_edi_purchase')[1]             else:                 ctx.update({'sent_po_via_email':true})                 template_id = ir_model_data.get_object_reference('purchase', 'email_template_edi_purchase_done')[1]         except valueerror:             template_id = false         try:             compose_form_id = ir_model_data.get_object_reference('mail', 'email_compose_message_wizard_form')[1]         except valueerror:             compose_form_id = false         ctx.update({             'default_model': 'purchase.order',             'default_res_id': self.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,         } 

we have override action_rfq_send method & check if user not sending ref update context ctx.update({'sent_po_via_email':true}).

step 2: inherit send_mail method of mail.compose.message.

class mailcomposemessage(models.transientmodel):     _inherit = 'mail.compose.message'      @api.multi     def send_mail(self, auto_commit=false):         context = self._context         if context.get('default_model') == 'purchase.order' , \                 context.get('default_res_id') , context.get('sent_po_via_email'):             po_order = self.env['purchase.order'].browse(context['default_res_id'])             po_order.sent_po_via_email = true         return super(mailcomposemessage, self).send_mail(auto_commit=auto_commit) 

in above method have checked if user sending purchase order via email set check mark true.

we have used simple context identify process & based on context, write value in purchase order.

this may you.


Comments

Popular posts from this blog

python - How to insert QWidgets in the middle of a Layout? -

python - serve multiple gunicorn django instances under nginx ubuntu -

module - Prestashop displayPaymentReturn hook url -