[FIX] portal, website_quote: change display of a button and default quotation template option
-> Move a button into its wizard and not in the void -> In the sale order, set the default value for require_payment related to sale_portal_confirmation_options.
This commit is contained in:
@@ -15,8 +15,8 @@
|
||||
</div>
|
||||
<div id="o_portal_signature" class="panel-body" style="padding: 0"/>
|
||||
</div>
|
||||
<div class="mt16 pull-right">
|
||||
<button type="submit" class="btn btn-primary o_portal_sign_submit"><t t-esc="widget.options.signLabel or 'Accept & Sign'"/></button>
|
||||
<div class="mt16 clearfix">
|
||||
<button type="submit" class="btn btn-primary o_portal_sign_submit pull-right"><t t-esc="widget.options.signLabel or 'Accept & Sign'"/></button>
|
||||
</div>
|
||||
</form>
|
||||
</t>
|
||||
|
||||
@@ -94,9 +94,9 @@ class PaymentPortal(http.Controller):
|
||||
|
||||
# proceed to the payment
|
||||
res = tx.confirm_sale_token()
|
||||
if res is not True and res != 'authorized_sale':
|
||||
params['error'] = res
|
||||
return request.redirect(_build_url_w_params(error_url, params))
|
||||
if res != 'authorized_sale':
|
||||
if tx.state != 'authorized' or not tx.acquirer_id.capture_manually:
|
||||
if res is not True:
|
||||
params['error'] = res
|
||||
return request.redirect(_build_url_w_params(error_url, params))
|
||||
params['success'] = 'pay_sale'
|
||||
return request.redirect(_build_url_w_params(success_url, params))
|
||||
|
||||
@@ -64,9 +64,7 @@ class PaymentTransaction(models.Model):
|
||||
_logger.info('<%s> transaction authorized, auto-confirming order %s (ID %s)', self.acquirer_id.provider, self.sale_order_id.name, self.sale_order_id.id)
|
||||
if self.sale_order_id.state in ('draft', 'sent'):
|
||||
self.sale_order_id.with_context(send_email=True).action_confirm()
|
||||
return 'authorized_sale'
|
||||
|
||||
if self.state == 'done':
|
||||
elif self.state == 'done':
|
||||
_logger.info('<%s> transaction completed, auto-confirming order %s (ID %s)', self.acquirer_id.provider, self.sale_order_id.name, self.sale_order_id.id)
|
||||
if self.sale_order_id.state in ('draft', 'sent'):
|
||||
self.sale_order_id.with_context(send_email=True).action_confirm()
|
||||
|
||||
@@ -51,6 +51,9 @@ class SaleOrder(models.Model):
|
||||
template = self.env.ref('website_quote.website_quote_template_default', raise_if_not_found=False)
|
||||
return template and template.active and template or False
|
||||
|
||||
def _get_default_online_payment(self):
|
||||
return 1 if self.env['ir.config_parameter'].sudo().get_param('sale.sale_portal_confirmation_options', default='none') == 'pay' else 0
|
||||
|
||||
template_id = fields.Many2one(
|
||||
'sale.quote.template', 'Quotation Template',
|
||||
readonly=True,
|
||||
@@ -66,7 +69,7 @@ class SaleOrder(models.Model):
|
||||
quote_viewed = fields.Boolean('Quotation Viewed')
|
||||
require_payment = fields.Selection([
|
||||
(0, 'Online Signature'),
|
||||
(1, 'Online Payment')], default=0, string='Confirmation Mode',
|
||||
(1, 'Online Payment')], default=_get_default_online_payment, string='Confirmation Mode',
|
||||
help="Choose how you want to confirm an order to launch the delivery process. You can either "
|
||||
"request a digital signature or an upfront payment. With a digital signature, you can "
|
||||
"request the payment when issuing the invoice.")
|
||||
|
||||
@@ -858,9 +858,11 @@ class WebsiteSale(http.Controller):
|
||||
# we proceed the s2s payment
|
||||
res = tx.confirm_sale_token()
|
||||
# we then redirect to the page that validates the payment by giving it error if there's one
|
||||
if res is not True and res != 'authorized_sale':
|
||||
return request.redirect('/shop/payment/validate?success=False&error=%s' % res)
|
||||
return request.redirect('/shop/payment/validate?success=True')
|
||||
if tx.state != 'authorized' or not tx.acquirer_id.capture_manually:
|
||||
if res is not True:
|
||||
return request.redirect('/shop/payment/validate?success=False&error=%s' % res)
|
||||
return request.redirect('/shop/payment/validate?success=True')
|
||||
return request.redirect('/shop/payment/validate')
|
||||
|
||||
@http.route('/shop/payment/get_status/<int:sale_order_id>', type='json', auth="public", website=True)
|
||||
def payment_get_status(self, sale_order_id, **post):
|
||||
|
||||
Reference in New Issue
Block a user