Skip to content

Commit

Permalink
[FIX] account_vat_period_end_statement: check move_id exists to get s…
Browse files Browse the repository at this point in the history
…tatement_draft properly working (OCA#435)

move_id needs to be checked if exists in the computed fields, otherwise the method unlink, during the fields recomputation, raises a MissingError for them
  • Loading branch information
tafaRU authored and jackjack82 committed Jul 18, 2018
1 parent 0f8bbd3 commit 8408618
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 15 deletions.
2 changes: 1 addition & 1 deletion account_vat_period_end_statement/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

{
"name": "Period End VAT Statement",
"version": "10.0.1.3.0",
"version": "10.0.1.3.1",
'category': 'Generic Modules/Accounting',
'license': 'AGPL-3',
"depends": [
Expand Down
32 changes: 18 additions & 14 deletions account_vat_period_end_statement/models/account.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,16 @@ def _compute_residual(self):
precision = self.env.user.company_id.currency_id.decimal_places
for statement in self:
residual = 0.0
if not statement.move_id:
statement.residual = 0.0
statement.reconciled = False
return
for line in statement.move_id.line_ids:
if line.account_id.id == statement.authority_vat_account_id.id:
residual += line.amount_residual
if statement.move_id.exists():
if not statement.move_id:
statement.residual = 0.0
statement.reconciled = False
return
for line in statement.move_id.line_ids:
authority_vat_account_id = (
statement.authority_vat_account_id.id)
if line.account_id.id == authority_vat_account_id:
residual += line.amount_residual
statement.residual = abs(residual)
if float_is_zero(statement.residual, precision_digits=precision):
statement.reconciled = True
Expand All @@ -88,13 +91,14 @@ def _compute_residual(self):
def _compute_lines(self):
for statement in self:
payment_lines = []
for line in statement.move_id.line_ids:
payment_lines.extend(filter(None, [
rp.credit_move_id.id for rp in line.matched_credit_ids
]))
payment_lines.extend(filter(None, [
rp.debit_move_id.id for rp in line.matched_debit_ids
]))
if statement.move_id.exists():
for line in statement.move_id.line_ids:
payment_lines.extend(filter(None, [
rp.credit_move_id.id for rp in line.matched_credit_ids
]))
payment_lines.extend(filter(None, [
rp.debit_move_id.id for rp in line.matched_debit_ids
]))
statement.payment_ids = self.env['account.move.line'].browse(
list(set(payment_lines)))

Expand Down

0 comments on commit 8408618

Please sign in to comment.