Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions account_invoice_import/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
- Yannick Vaucher \<<yannick.vaucher@camptocamp.com>\>
- Ronald Portier \<<ronald@therp.nl>\>
- Simone Orsi \<<simone.orsi@camptocamp.com>\>
- Michael Tietz (MT Software) \<<mtietz@mt-software.de>\>
Comment thread
mt-software-de marked this conversation as resolved.
34 changes: 25 additions & 9 deletions account_invoice_import/wizard/account_invoice_import.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Copyright 2015-2021 Akretion France (http://www.akretion.com/)
# Copyright 2020-2021 Therp BV (https://therp.nl)
# Copyright 2026 Michael Tietz (MT Software) <mtietz@mt-software.de>
Comment thread
mt-software-de marked this conversation as resolved.
# @author: Alexis de Lattre <alexis.delattre@akretion.com>
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

Expand Down Expand Up @@ -364,6 +365,24 @@ def _prepare_create_invoice_vals(self, parsed_inv, import_config):
vals["check_total"] = parsed_inv["amount_total"]
return vals

def _get_fiscal_position(self, import_config, partner, partner_shipping=None):
return (
self.env["account.fiscal.position"]
.with_company(import_config["company"])
._get_fiscal_position(partner, partner_shipping)
)

def _map_account_and_taxes(self, import_config, partner, account, taxes):
res = account, taxes
if not partner:
return res
fiscal_position = self._get_fiscal_position(import_config, partner)
Comment thread
mt-software-de marked this conversation as resolved.
if not fiscal_position:
return res
new_account = fiscal_position.map_account(account)
new_taxes = fiscal_position.map_tax(taxes)
return new_account, new_taxes

@api.model
def _prepare_line_vals_1line(self, parsed_inv, import_config, vals, partner):
il_vals = {
Expand Down Expand Up @@ -394,10 +413,9 @@ def _prepare_line_vals_1line(self, parsed_inv, import_config, vals, partner):
account = import_config["account"]
if import_config.get("taxes"):
taxes = import_config["taxes"]
fp = partner and partner.property_account_position_id or False
if fp:
account = fp.map_account(account)
taxes = fp.map_tax(taxes)
account, taxes = self._map_account_and_taxes(
import_config, partner, account, taxes
)
il_vals.update(
{
"account_id": account.id,
Expand Down Expand Up @@ -459,11 +477,9 @@ def _prepare_line_vals_nline(self, parsed_inv, import_config, vals, partner):
type_tax_use=type_tax_use,
raise_exception=False,
)

fp = partner and partner.property_account_position_id or False
if fp:
account = fp.map_account(account)
taxes = fp.map_tax(taxes)
account, taxes = self._map_account_and_taxes(
import_config, partner, account, taxes
)
uom = bdio._match_uom(
line.get("uom"),
parsed_inv["chatter_msg"],
Expand Down
Loading