Skip to Content
Меню
Вам необхідно зареєструватися, щоб взаємодіяти зі спільнотою.
Це запитання позначене
3805 Переглядів

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?

Аватар
Відмінити
Related Posts Відповіді Переглядів Дія
0
січ. 20
4935
1
вер. 16
4507
0
вер. 15
3657
0
лип. 15
4145
2
трав. 15
3597