Passa al contenuto
Menu
È necessario essere registrati per interagire con la community.
La domanda è stata contrassegnata
3772 Visualizzazioni

I wish to add email notification when a 'quotation' changes state.

Key actions I want to record and email out are:
Quote Accepted,
Quote Rejected,
Feedback Submitted.

What would be the best practice to add this capability to the existing workflows (sale.order.basic)?

My current attempt has this code in another module which works to a point...

def action_wait(self, cr, uid, ids, context=None):
context = context or {}
context = context or {}
for o in self.browse(cr, uid, ids):
if not any(line.state != 'cancel' for line in o.order_line):
raise osv.except_osv(_('Error!'),_('You cannot confirm a sales order which has no line.'))
noprod = self.test_no_product(cr, uid, o, context)
if (o.order_policy == 'manual') or noprod:
self.write(cr, uid, [o.id], {'state': 'manual', 'date_confirm': fields.date.context_today(self, cr, uid, context=context)})
else:
self.write(cr, uid, [o.id], {'state': 'progress', 'date_confirm': fields.date.context_today(self, cr, uid, context=context)})
self.pool.get('sale.order.line').button_confirm(cr, uid, [x.id for x in o.order_line if x.state != 'cancel'])
_logger.error("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
email_ids = self.pool.get('mail.mail')
raise_exception=False
message="Sales Order Signed and Confirmed"
vals = {'state': 'outgoing',
'subject': 'Order Confirmation',
'body_html': message,
'body_html': '<pre>%s</pre>' % message,
'email_to': 'example_to@example.com',
'email_from': 'example_from@example.com',
}
msg_id = email_ids.create(cr, uid, vals, context=context)
_logger.error(msg_id)
email_ids.send(cr, uid, [msg_id], raise_exception=raise_exception, context=context)
return True

The problem with this is I can't call variable values like:
Quote number,
Client Email,
Etc.

Is it possible to call such information in a python file or does it have to be accessed via XML templates?

Avatar
Abbandona
Post correlati Risposte Visualizzazioni Attività
0
gen 20
4902
1
set 16
4502
0
set 15
3645
0
lug 15
4134
2
mag 15
3565