Skip to content

[18.0][FIX] account_invoice_import: apply the fiscal position Odoo would determine for the partner - #1302

Open
mt-software-de wants to merge 1 commit into
OCA:18.0from
mt-software-de:18-fix-account_invoice_import-fiscal_position
Open

mt-software-de wants to merge 1 commit into
OCA:18.0from
mt-software-de:18-fix-account_invoice_import-fiscal_position

Conversation

@mt-software-de

@mt-software-de mt-software-de commented Feb 27, 2026 •

Copy link
Copy Markdown

When building invoice lines, the import wizard mapped accounts and taxes using only
partner.property_account_position_id. That differs from what Odoo does when an
invoice is created manually:

  • Auto-applied fiscal positions were ignored. If the partner has no fiscal position
    set but one applies automatically (by country, country group, VAT requirement, …),
    the lines kept the unmapped account and taxes, while the move header still got the
    fiscal position through its own compute. The header and the lines no longer agreed.
  • Wrong company context. property_account_position_id is company-dependent and was
    read in the environment's current company, not the company the invoice is imported
    into. With multiple companies, the fiscal position of the wrong company could be
    applied, or none at all.

Changes

  • New helper _get_fiscal_position() calls the standard
    account.fiscal.position._get_fiscal_position(partner, delivery) in the import
    company (import_config["company"]). It respects the fiscal position set on the
    partner and the auto-apply rules, just like account.move.
  • New helper _map_account_and_taxes() holds the mapping that used to be duplicated
    in _prepare_line_vals_1line() and _prepare_line_vals_nline(). Both methods now
    call it, and other modules can override it.

@OCA-git-bot

Copy link
Copy Markdown
Contributor

Hi @alexis-via,
some modules you are maintaining are being modified, check this out!

@mt-software-de mt-software-de changed the title [FIX] account_invoice_import: Use correct fiscal position [18.0][FIX] account_invoice_import: Use correct fiscal position Feb 27, 2026
@mt-software-de
mt-software-de force-pushed the 18-fix-account_invoice_import-fiscal_position branch from 2103d7d to e83c606 Compare February 27, 2026 12:44

@arnaudlayec arnaudlayec left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello,
Thank you for this change. I agree it is really needed because in previous code, if partner.property_account_position_id is empty, the fiscal position of the invoice can be set wrongly.
A call to the native method res_partner._get_fiscal_position should indeed replace the partner.property_account_position_id

I have a few suggestions to let the code simple to read

Comment thread account_invoice_import/wizard/account_invoice_import.py
Comment thread account_invoice_import/readme/CONTRIBUTORS.md
Comment thread account_invoice_import/wizard/account_invoice_import.py Outdated
Comment thread account_invoice_import/wizard/account_invoice_import.py
Comment thread account_invoice_import/wizard/account_invoice_import.py Outdated
@mt-software-de
mt-software-de force-pushed the 18-fix-account_invoice_import-fiscal_position branch from e83c606 to 58f7e36 Compare May 12, 2026 09:54
@OCA-git-bot OCA-git-bot added series:18.0 mod:account_invoice_import Module account_invoice_import labels May 12, 2026
@mt-software-de
mt-software-de force-pushed the 18-fix-account_invoice_import-fiscal_position branch from 58f7e36 to b2ab15f Compare May 12, 2026 13:29

@arnaudlayec arnaudlayec left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All good for me, I think it is very helpful

@mt-software-de

Copy link
Copy Markdown
Author

@alexis-via could you maybe give this PR a second review?

@mt-software-de

Copy link
Copy Markdown
Author

@OCA/edi-maintainers can someon merge this one?

@mt-software-de
mt-software-de force-pushed the 18-fix-account_invoice_import-fiscal_position branch from b2ab15f to 12e3696 Compare October 6, 2026 22:19
@mt-software-de

Copy link
Copy Markdown
Author

I did a rebase and added some tests. @OCA/edi-maintainers @alexis-via could this please merged?

@mt-software-de mt-software-de changed the title [18.0][FIX] account_invoice_import: Use correct fiscal position [18.0][FIX] account_invoice_import: apply the fiscal position Odoo would determine for the partner Oct 6, 2026
@mt-software-de
mt-software-de force-pushed the 18-fix-account_invoice_import-fiscal_position branch from 12e3696 to 34de857 Compare October 6, 2026 22:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

mod:account_invoice_import Module account_invoice_import series:18.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants