summaryrefslogtreecommitdiff
path: root/addons
diff options
context:
space:
mode:
authorfda-odoo <fda@odoo.com>2017-12-21 11:32:42 +0100
committerfda-odoo <fda@odoo.com>2018-01-24 15:33:53 +0100
commitb7a064af9f2e1f9e9a4d7c28b7bcbb8af7842f4e (patch)
treeaf8afc9c3d6519ae6652d602ebf9bdca2a5af061 /addons
parent196f491e12e6789784c350b0b159061b67d18834 (diff)
[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.
Diffstat (limited to 'addons')
-rw-r--r--addons/portal/static/src/xml/portal_signature.xml4
-rw-r--r--addons/sale_payment/controllers/payment.py8
-rw-r--r--addons/sale_payment/models/payment.py4
-rw-r--r--addons/website_quote/models/sale_order.py5
-rw-r--r--addons/website_sale/controllers/main.py8
5 files changed, 16 insertions, 13 deletions
diff --git a/addons/portal/static/src/xml/portal_signature.xml b/addons/portal/static/src/xml/portal_signature.xml
index 4b0ca5344d1..3ef5c8f1ea0 100644
--- a/addons/portal/static/src/xml/portal_signature.xml
+++ b/addons/portal/static/src/xml/portal_signature.xml
@@ -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 &amp; 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 &amp; Sign'"/></button>
</div>
</form>
</t>
diff --git a/addons/sale_payment/controllers/payment.py b/addons/sale_payment/controllers/payment.py
index f06d0aa3aa7..1d00409a204 100644
--- a/addons/sale_payment/controllers/payment.py
+++ b/addons/sale_payment/controllers/payment.py
@@ -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))
diff --git a/addons/sale_payment/models/payment.py b/addons/sale_payment/models/payment.py
index 905641d34da..857ff857dfb 100644
--- a/addons/sale_payment/models/payment.py
+++ b/addons/sale_payment/models/payment.py
@@ -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()
diff --git a/addons/website_quote/models/sale_order.py b/addons/website_quote/models/sale_order.py
index 3e96864c45c..6824284b84e 100644
--- a/addons/website_quote/models/sale_order.py
+++ b/addons/website_quote/models/sale_order.py
@@ -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.")
diff --git a/addons/website_sale/controllers/main.py b/addons/website_sale/controllers/main.py
index 961934eecad..190ca516d9d 100644
--- a/addons/website_sale/controllers/main.py
+++ b/addons/website_sale/controllers/main.py
@@ -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):