Skip to content

Commit

Permalink
[FIX] l10n_es_aeat_mod349: take all lines related to refunded invoice
Browse files Browse the repository at this point in the history
  • Loading branch information
oihane authored and OCA-git-bot committed Jul 22, 2019
1 parent 00303ce commit 19d91b7
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions l10n_es_aeat_mod349/models/mod349.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,17 +192,21 @@ def _create_349_refund_records(self):
# TODO: Instead continuing, generate an empty record and a msg
continue
# Fetch the latest presentation made for this move
original_detail = detail_obj.search([
original_details = detail_obj.search([
('move_line_id.invoice_id', '=', origin_invoice.id),
('partner_record_id.operation_key', '=', op_key),
('id', 'not in', visited_details.ids)
], limit=1, order='report_id desc')
if original_detail:
# There's a previous 349 declaration report
origin_amount = original_detail.amount_untaxed
period_type = original_detail.report_id.period_type
year = original_detail.report_id.year
visited_details |= original_detail
], order='report_id desc')
# we add all of them to visited, as we don't want to repeat
visited_details |= original_details
if original_details:
# There's at least one previous 349 declaration report
report = original_details.mapped('report_id')[:1]
original_details = original_details.filtered(
lambda d: d.report_id == report)
origin_amount = sum(original_details.mapped('amount_untaxed'))
period_type = report.period_type
year = report.year
else:
# There's no previous 349 declaration report in Odoo
original_amls = move_line_obj.search([
Expand Down

0 comments on commit 19d91b7

Please sign in to comment.