mirror of
https://github.com/OCA/account-financial-tools.git
synced 2025-02-02 12:47:26 +02:00
25 lines
1.1 KiB
Python
25 lines
1.1 KiB
Python
# Copyright 2019 Ecosoft Co., Ltd (http://ecosoft.co.th/)
|
|
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html)
|
|
from odoo import api, models
|
|
|
|
|
|
class PurchaseOrderLine(models.Model):
|
|
_inherit = "purchase.order.line"
|
|
|
|
@api.depends("invoice_lines.move_id.state", "invoice_lines.quantity")
|
|
def _compute_qty_invoiced(self):
|
|
""" Cancel Reversal Entry is of type "entry", correction is needed """
|
|
res = super()._compute_qty_invoiced()
|
|
for line in self:
|
|
for inv_line in line.invoice_lines:
|
|
if inv_line.move_id.cancel_reversal:
|
|
if inv_line.move_id.type == "in_invoice":
|
|
line.qty_invoiced -= inv_line.product_uom_id._compute_quantity(
|
|
inv_line.quantity, line.product_uom
|
|
)
|
|
elif inv_line.move_id.type == "in_refund":
|
|
line.qty_invoiced += inv_line.product_uom_id._compute_quantity(
|
|
inv_line.quantity, line.product_uom
|
|
)
|
|
return res
|