Files
odoo_source/addons/website_sale/models/payment.py
T
fda-odoo 2ba6301d34 [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.
2018-01-24 15:29:58 +01:00

26 lines
1000 B
Python

# -*- 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