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_vat_period_end_statement: check move_id exists to get statement_draft properly working #435

Merged
merged 1 commit into from
Jan 11, 2018
Merged
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
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