Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exclude rounding lines when checking for missing taxes #1768

Open
xabispacebiker opened this issue Jul 19, 2024 · 0 comments
Open

Exclude rounding lines when checking for missing taxes #1768

xabispacebiker opened this issue Jul 19, 2024 · 0 comments
Labels

Comments

@xabispacebiker
Copy link

Module

account_tax_invoice_required

Describe the bug

The _test_invoice_line_tax method does not exclude rounding lines when checking for missing taxes on invoice lines. This results in unnecessary errors related to rounding lines.

To Reproduce

Odoo 14

Steps to reproduce the behavior:
Create an invoice with a rounding line.
Ensure the rounding line has no taxes defined.
Validate the invoice.

Expected behavior
The method _test_invoice_line_tax should exclude rounding lines (is_rounding_line is True) when checking for missing taxes on invoice lines. Only relevant invoice lines should be checked, preventing unnecessary errors related to rounding lines.

This is the suggested fix:

from odoo import api, models, _
from odoo.exceptions import UserError

class AccountMove(models.Model):
    _inherit = "account.move"

    def _test_invoice_line_tax(self):
        errors = []
        error_template = _("Invoice has a line with product %s with no taxes")
        
        for invoice_line in self.mapped("invoice_line_ids").filtered(
            lambda x: x.display_type is False and not x.is_rounding_line
        ):
            if not invoice_line.tax_ids:
                error_string = error_template % (invoice_line.name)
                errors.append(error_string)
        
        if errors:
            raise UserError(
                _("%s\n%s") % (_("No Taxes Defined!"), "\n".join(errors))
            )
            .... 
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant