[REM] website_sale: remove dead code
The commit https://github.com/odoo/odoo/commit/01216345e28374b554bfe95df82d607c591271cf#diff-6bc8c8d6d3cf3075da7e6f417cf28434L33 removes the methods `_confirm_so`, `_generate_and_pay_invoice`, but the commit doesn't apply these changes everywhere. Hence we had dead code still remaining in website_sale
This commit is contained in:
committed by
RomainLibert
parent
d68d8d9039
commit
f6aba7fb5b
@@ -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
|
||||
|
||||
@@ -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
|
||||
@@ -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'])
|
||||
|
||||
@@ -228,15 +228,4 @@
|
||||
action="product.variants_action"
|
||||
parent="menu_product_settings" groups="product.group_product_variant" sequence="3"/>
|
||||
|
||||
<record id="sale_order_view_form" model="ir.ui.view">
|
||||
<field name="name">sale.order.form</field>
|
||||
<field name="model">sale.order</field>
|
||||
<field name="inherit_id" ref="sale.view_order_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<field name="partner_id" position="after">
|
||||
<field name="can_directly_mark_as_paid" invisible="1"/>
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
</odoo>
|
||||
|
||||
Reference in New Issue
Block a user