summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfda-odoo <fda@odoo.com>2017-12-13 16:17:41 +0100
committerfda-odoo <fda@odoo.com>2018-01-24 15:29:58 +0100
commit2ba6301d341400003298370b643f724eec822f06 (patch)
tree29cddae86ec0c0b0de268405bf723254570675e0
parentdaf6ab1c872ed9a04517dccd2b32db8dd4855163 (diff)
[FIX] website_sale: stop the generation of invoices if the option is unchecked in the e-commerce settings
An invoice was always generated even if the option was unchecked when we the order is confirmed.
-rw-r--r--addons/sale_payment/models/payment.py3
-rw-r--r--addons/sale_payment/views/sale_portal_templates.xml2
-rw-r--r--addons/website_sale/models/__init__.py1
-rw-r--r--addons/website_sale/models/payment.py25
4 files changed, 28 insertions, 3 deletions
diff --git a/addons/sale_payment/models/payment.py b/addons/sale_payment/models/payment.py
index 410d287b247..758bb94c112 100644
--- a/addons/sale_payment/models/payment.py
+++ b/addons/sale_payment/models/payment.py
@@ -66,10 +66,9 @@ class PaymentTransaction(models.Model):
self.sale_order_id.with_context(send_email=True).action_confirm()
if self.state == 'done':
- _logger.info('<%s> transaction completed, auto-confirming order %s (ID %s) and generating invoice', self.acquirer_id.provider, self.sale_order_id.name, self.sale_order_id.id)
+ _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()
- self._generate_and_pay_invoice()
elif self.state not in ['cancel', 'error'] and self.sale_order_id.state == 'draft':
_logger.info('<%s> transaction pending/to confirm manually, sending quote email for order %s (ID %s)', self.acquirer_id.provider, self.sale_order_id.name, self.sale_order_id.id)
self.sale_order_id.force_quotation_send()
diff --git a/addons/sale_payment/views/sale_portal_templates.xml b/addons/sale_payment/views/sale_portal_templates.xml
index df86ce75998..5ca7511fbec 100644
--- a/addons/sale_payment/views/sale_portal_templates.xml
+++ b/addons/sale_payment/views/sale_portal_templates.xml
@@ -13,7 +13,7 @@
</t>
</xpath>
<xpath expr="//div[@id='portal_sign']" position="after">
- <div class="row" t-if="not invoices and order.state in ('sent', 'sale') and portal_confirmation == 'pay'" id="portal_pay">
+ <div class="row" t-if="not invoices and order.state in ('sent') and portal_confirmation == 'pay'" id="portal_pay">
<div class="col-md-offset-3 col-md-6">
<div t-if="pms or s2s_acquirers or form_acquirers" id="payment_method" class="text-left col-md-13">
<h4 class="mb24">Pay with</h4>
diff --git a/addons/website_sale/models/__init__.py b/addons/website_sale/models/__init__.py
index 8cc73414b40..3a394e73151 100644
--- a/addons/website_sale/models/__init__.py
+++ b/addons/website_sale/models/__init__.py
@@ -7,6 +7,7 @@ from . import mail_compose_message
from . import product
from . import res_country
from . import res_partner
+from . import payment
from . import sale_order
from . import ir_model_fields
from . import website
diff --git a/addons/website_sale/models/payment.py b/addons/website_sale/models/payment.py
new file mode 100644
index 00000000000..3bebb9dfff8
--- /dev/null
+++ b/addons/website_sale/models/payment.py
@@ -0,0 +1,25 @@
+# -*- coding: utf-8 -*-
+# Part of Odoo. See LICENSE file for full copyright and licensing details.
+
+import logging
+
+from odoo import models
+
+_logger = logging.getLogger(__name__)
+
+
+class PaymentTransaction(models.Model):
+ _inherit = 'payment.transaction'
+
+ # --------------------------------------------------
+ # Sale management
+ # --------------------------------------------------
+
+ def _confirm_so(self):
+ """Generate the invoice automatically when option is enabled from ecommerce setting"""
+ result = super(PaymentTransaction, self)._confirm_so()
+ IrConfigParameter = self.env['ir.config_parameter'].sudo()
+ if self.state == 'done' and IrConfigParameter.get_param('website_sale.automatic_invoice', default=False):
+ _logger.info('<%s> transaction completed, generating invoice for order %s (ID %s)', self.acquirer_id.provider, self.sale_order_id.name, self.sale_order_id.id)
+ self._generate_and_pay_invoice()
+ return result