Skip to content
Open
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
20 changes: 15 additions & 5 deletions addons/account/models/account_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -1591,6 +1591,20 @@ def _prepare_tax_line_for_taxes_computation(self, tax_line):
sign=self.direction_sign,
)

def _get_base_amls(self):
""" Get the base lines to be used for the taxes computation.

:return: A recordset of account.move.line.
"""
self.ensure_one()
is_invoice = self.is_invoice(include_receipts=True)

if self.id or not is_invoice:
base_amls = self.line_ids.filtered(lambda line: line.display_type == 'product')
else:
base_amls = self.invoice_line_ids.filtered(lambda line: line.display_type == 'product')
return base_amls

def _get_rounded_base_and_tax_lines(self, round_from_tax_lines=True):
""" Small helper to extract the base and tax lines for the taxes computation from the current move.
The move could be stored or not and could have some features generating extra journal items acting as
Expand All @@ -1602,12 +1616,8 @@ def _get_rounded_base_and_tax_lines(self, round_from_tax_lines=True):
"""
self.ensure_one()
AccountTax = self.env['account.tax']
is_invoice = self.is_invoice(include_receipts=True)

if self.id or not is_invoice:
base_amls = self.line_ids.filtered(lambda line: line.display_type == 'product')
else:
base_amls = self.invoice_line_ids.filtered(lambda line: line.display_type == 'product')
base_amls = self._get_base_amls()
base_lines = [self._prepare_product_base_line_for_taxes_computation(line) for line in base_amls]

tax_lines = []
Expand Down