[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.
This commit is contained in:
@@ -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()
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
Reference in New Issue
Block a user