[IMP] website_payment: when invoicing always ignore invoice policy
Sale orders created through the website that have to be automatically invoiced should ignore the delivery invoicing policy. Otherwise you can end up with either an invoice not being generated at all. This means the user has to manually generate and add the payment to it. Even worse is if only some purchased products have invoice policy delivery. In this case a partial invoice would be generated to which the payment would be added, leading to a mismatch between invoice total and payment amount.
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import res_config
|
||||
import payment
|
||||
import website
|
||||
import sale
|
||||
|
||||
@@ -18,6 +18,8 @@ class PaymentTransaction(models.Model):
|
||||
sale_order_id = fields.Many2one('sale.order', string='Sale Order')
|
||||
|
||||
def _generate_and_pay_invoice(self, tx, acquirer_name):
|
||||
tx.sale_order_id._force_lines_to_invoice_policy_order()
|
||||
|
||||
created_invoice = tx.sale_order_id.action_invoice_create()
|
||||
created_invoice = self.env['account.invoice'].browse(created_invoice)
|
||||
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
# coding: utf-8
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
import logging
|
||||
from odoo import api, fields, models
|
||||
|
||||
class SaleOrder(models.Model):
|
||||
_inherit = 'sale.order'
|
||||
|
||||
def _force_lines_to_invoice_policy_order(self):
|
||||
for line in self.order_line:
|
||||
if self.state in ['sale', 'done']:
|
||||
line.qty_to_invoice = line.product_uom_qty - line.qty_invoiced
|
||||
else:
|
||||
line.qty_to_invoice = 0
|
||||
Reference in New Issue
Block a user