[FIX] sale, website_sale: quotation email.
4adb4b8d15
corrected the fact the quotation email
wasn't sent if you did not come back
from the payment provider
(when you closed your browser after
the payment but before coming back
to Odoo).
Before the above revision, the quotation
email was sent for payment methods
not redirecting to payment providers,
like transfers. It was no longer the case
with the above revision.
This revision re-introduces this behavior:
If there is a feedback from a transaction,
but the transaction isn't confirmed,
we send the quotation email without confirming
the sale order, like it was the case before
opw-644670
This commit is contained in:
parent
1bc2608490
commit
809e1a6081
|
@ -603,26 +603,7 @@ class sale_order(osv.osv):
|
|||
assert len(ids) == 1, 'This option should only be used for a single id at a time.'
|
||||
self.signal_workflow(cr, uid, ids, 'order_confirm')
|
||||
if context.get('send_email'):
|
||||
order_id = ids[0]
|
||||
email_act = self.action_quotation_send(cr, uid, [order_id], context=context)
|
||||
if email_act and email_act.get('context'):
|
||||
composer_obj = self.pool['mail.compose.message']
|
||||
composer_values = {}
|
||||
email_ctx = email_act['context']
|
||||
template_values = [
|
||||
email_ctx.get('default_template_id'),
|
||||
email_ctx.get('default_composition_mode'),
|
||||
email_ctx.get('default_model'),
|
||||
email_ctx.get('default_res_id'),
|
||||
]
|
||||
composer_values.update(composer_obj.onchange_template_id(cr, uid, None, *template_values, context=context).get('value', {}))
|
||||
if not composer_values.get('email_from'):
|
||||
composer_values['email_from'] = self.browse(cr, uid, order_id, context=context).company_id.email
|
||||
for key in ['attachment_ids', 'partner_ids']:
|
||||
if composer_values.get(key):
|
||||
composer_values[key] = [(6, 0, composer_values[key])]
|
||||
composer_id = composer_obj.create(cr, uid, composer_values, context=email_ctx)
|
||||
composer_obj.send_mail(cr, uid, [composer_id], context=email_ctx)
|
||||
self.force_quotation_send(cr, uid, ids, context=context)
|
||||
return True
|
||||
|
||||
def action_wait(self, cr, uid, ids, context=None):
|
||||
|
@ -672,6 +653,29 @@ class sale_order(osv.osv):
|
|||
'context': ctx,
|
||||
}
|
||||
|
||||
def force_quotation_send(self, cr, uid, ids, context=None):
|
||||
for order_id in ids:
|
||||
email_act = self.action_quotation_send(cr, uid, [order_id], context=context)
|
||||
if email_act and email_act.get('context'):
|
||||
composer_obj = self.pool['mail.compose.message']
|
||||
composer_values = {}
|
||||
email_ctx = email_act['context']
|
||||
template_values = [
|
||||
email_ctx.get('default_template_id'),
|
||||
email_ctx.get('default_composition_mode'),
|
||||
email_ctx.get('default_model'),
|
||||
email_ctx.get('default_res_id'),
|
||||
]
|
||||
composer_values.update(composer_obj.onchange_template_id(cr, uid, None, *template_values, context=context).get('value', {}))
|
||||
if not composer_values.get('email_from'):
|
||||
composer_values['email_from'] = self.browse(cr, uid, order_id, context=context).company_id.email
|
||||
for key in ['attachment_ids', 'partner_ids']:
|
||||
if composer_values.get(key):
|
||||
composer_values[key] = [(6, 0, composer_values[key])]
|
||||
composer_id = composer_obj.create(cr, uid, composer_values, context=email_ctx)
|
||||
composer_obj.send_mail(cr, uid, [composer_id], context=email_ctx)
|
||||
return True
|
||||
|
||||
def action_done(self, cr, uid, ids, context=None):
|
||||
for order in self.browse(cr, uid, ids, context=context):
|
||||
self.pool.get('sale.order.line').write(cr, uid, [line.id for line in order.order_line if line.state != 'cancel'], {'state': 'done'}, context=context)
|
||||
|
|
|
@ -24,5 +24,7 @@ class PaymentTransaction(orm.Model):
|
|||
tx = getattr(self, tx_find_method_name)(cr, uid, data, context=context)
|
||||
if tx and tx.state == 'done' and tx.sale_order_id and tx.sale_order_id.state in ['draft', 'sent']:
|
||||
self.pool['sale.order'].action_button_confirm(cr, SUPERUSER_ID, [tx.sale_order_id.id], context=dict(context, send_email=True))
|
||||
elif tx and tx.state not in ['cancel'] and tx.sale_order_id and tx.sale_order_id.state in ['draft']:
|
||||
self.pool['sale.order'].force_quotation_send(cr, SUPERUSER_ID, [tx.sale_order_id.id], context=context)
|
||||
|
||||
return res
|
||||
|
|
Loading…
Reference in New Issue