Vauxoo / odoo

Fork of Odoo (formerly OpenERP). [This project is not publically mantained just born for internal usage with some little patches] go to official repository on github.com/odoo/odoo
https://www.odoo.com
Other
9 stars 9 forks source link

[FIX] account: removes limiting `if tax_ids` condition #597

Closed maneandrea closed 2 months ago

maneandrea commented 2 months ago

In odoo the function map_tax in account.fiscal.position returns an empty recordset of account.tax if it receives an empty recordset as input.

Some extensions of odoo might change this behavior and return a non- empty recordset even with an empty input. For example map_tax might return tax_ids.tax_dest_id which have is_fee = True.

This commit removes the validation if tax_ids so that map_tax is always called. In vanilla Odoo this just adds a noop because it would call a method which loops over zero elements and returns.


I confirm I have signed the CLA and read the PR guidelines at www.odoo.com/submit-pr

maneandrea commented 2 months ago

For internal reference, here is the motivation of the PR:

In IRCodoo we have a map_tax that looks like this:

    def map_tax(self, taxes):
        fees = self.mapped("tax_ids.tax_dest_id").filtered("is_fee")
        if fees:
            taxes |= fees
        return super().map_tax(taxes)

so if this function gets an empty recordset, it could still output something useful.

However, the condition if tax_ids here just skips that line (with the logic that in normal Odoo that like is useless on an empty recordset.)

See related MR in ircodoo https://gitlab.com/ircanada/ircodoo/-/merge_requests/2939

@moylop260 @luisg123v

moylop260 commented 2 months ago

IRC doesn't use this feature since that they are using sale.order instead of account.move

sale.order is doing the things good however it looks they have different code

Also, @randall-vx sent us a commit where all these kind of methods were merged in one model:

So, maybe we shouldn't dedicate resources to this now