diff --git a/addons/website_sale/models/__init__.py b/addons/website_sale/models/__init__.py index ad98431fbaf..d6c4695f4e4 100644 --- a/addons/website_sale/models/__init__.py +++ b/addons/website_sale/models/__init__.py @@ -7,7 +7,6 @@ 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 website from . import res_config_settings diff --git a/addons/website_sale/models/payment.py b/addons/website_sale/models/payment.py deleted file mode 100644 index 9981baa94e3..00000000000 --- a/addons/website_sale/models/payment.py +++ /dev/null @@ -1,25 +0,0 @@ -# -*- 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('sale_payment.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 diff --git a/addons/website_sale/models/sale_order.py b/addons/website_sale/models/sale_order.py index b0de22315b7..5a9141485e9 100644 --- a/addons/website_sale/models/sale_order.py +++ b/addons/website_sale/models/sale_order.py @@ -23,19 +23,9 @@ class SaleOrder(models.Model): ) cart_quantity = fields.Integer(compute='_compute_cart_info', string='Cart Quantity') only_services = fields.Boolean(compute='_compute_cart_info', string='Only Services') - can_directly_mark_as_paid = fields.Boolean(compute='_compute_can_directly_mark_as_paid', - string="Can be directly marked as paid", store=True, - help="""Checked if the sales order can directly be marked as paid, i.e. if the quotation - is sent or confirmed and if the payment acquire is of the type transfer or manual""") is_abandoned_cart = fields.Boolean('Abandoned Cart', compute='_compute_abandoned_cart', search='_search_abandoned_cart') cart_recovery_email_sent = fields.Boolean('Cart recovery email already sent') - @api.depends('state', 'transaction_ids') - def _compute_can_directly_mark_as_paid(self): - for order in self: - transaction = order.get_portal_last_transaction() - order.can_directly_mark_as_paid = order.state in ['sent', 'sale'] and transaction and transaction.acquirer_id.provider in ['transfer', 'manual'] - @api.multi @api.depends('website_order_line.product_uom_qty', 'website_order_line.product_id') def _compute_cart_info(self): @@ -241,22 +231,6 @@ class SaleOrder(models.Model): }, } - def action_mark_as_paid(self): - """ Mark directly a sales order as paid if: - - State: Quotation Sent, or sales order - - Provider: wire transfer or manual config - The transaction is marked as done - The invoice may be generated and marked as paid if configured in the website settings - """ - self.ensure_one() - if self.can_directly_mark_as_paid: - self.action_confirm() - if self.env['ir.config_parameter'].sudo().get_param('sale_payment.automatic_invoice', default=False): - self.payment_tx_id._generate_and_pay_invoice() - self.payment_tx_id.state = 'done' - else: - raise ValidationError(_("The quote should be sent and the payment acquirer type should be manual or wire transfer")) - def _set_demo_create_date(self, create_date): self.env.cr.execute("""UPDATE sale_order SET create_date=%s WHERE id IN %s """, (create_date, tuple(self.ids))) self.modified(['create_date']) diff --git a/addons/website_sale/views/sale_order_views.xml b/addons/website_sale/views/sale_order_views.xml index b02ac550549..e80895b0678 100644 --- a/addons/website_sale/views/sale_order_views.xml +++ b/addons/website_sale/views/sale_order_views.xml @@ -228,15 +228,4 @@ action="product.variants_action" parent="menu_product_settings" groups="product.group_product_variant" sequence="3"/> - - sale.order.form - sale.order - - - - - - - -