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

[FIX] account_invoice_merge - record set used instead of list of ids in do_merge #104

Closed
wants to merge 17 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 14 additions & 0 deletions account_invoice_rounding/account.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,14 @@ def _swedish_add_invoice_line(self, cr, uid, invoice,

company = invoice.company_id
if not invoice.global_round_line_id.id:
sequence = self._compute_sequence(invoice)
new_invoice_line = {
'name': _('Rounding'),
'price_unit': -delta,
'account_id': company.tax_calculation_rounding_account_id.id,
'invoice_id': invoice.id,
'is_rounding': True,
'sequence': sequence,
}
invoice_line_obj.create(cr, uid, new_invoice_line, context=context)
elif float_compare(invoice.global_round_line_id.price_unit, -delta,
Expand All @@ -57,6 +59,18 @@ def _swedish_add_invoice_line(self, cr, uid, invoice,
return {'amount_total': rounded_total,
'amount_untaxed': amount_untaxed}

def _compute_sequence(self, invoice):
"""
Returns the max sequence + 1
Will allow us to place the rounding difference invoice line always at the end
Copied from BT-Store/rounding_difference
"""
sequence = 0
for invoice_line in invoice.invoice_line:
if invoice_line.sequence > sequence:
sequence = invoice_line.sequence
return sequence + 1

@staticmethod
def _all_invoice_tax_line_computed(invoice):
""" Check if all taxes have been computed on invoice lines
Expand Down