Browse Source

[FIX] account_financial_report: filter cancelled journal items

pull/735/head
Joan Sisquella 4 years ago
parent
commit
46174ae637
  1. 4
      account_financial_report/report/aged_partner_balance.py
  2. 4
      account_financial_report/report/general_ledger.py
  3. 2
      account_financial_report/report/journal_ledger.py
  4. 31
      account_financial_report/report/open_items.py
  5. 8
      account_financial_report/report/trial_balance.py
  6. 4
      account_financial_report/report/vat_report.py
  7. 4
      account_financial_report/wizard/journal_ledger_wizard.py

4
account_financial_report/report/aged_partner_balance.py

@ -75,6 +75,8 @@ class AgedPartnerBalanceReport(models.AbstractModel):
domain += [("partner_id", "in", partner_ids)]
if only_posted_moves:
domain += [("move_id.state", "=", "posted")]
else:
domain += [("move_id.state", "in", ["posted", "draft"])]
if date_from:
domain += [("date", ">", date_from)]
return domain
@ -141,6 +143,8 @@ class AgedPartnerBalanceReport(models.AbstractModel):
domain += [("partner_id", "in", partner_ids)]
if only_posted_moves:
domain += [("move_id.state", "=", "posted")]
else:
domain += [("move_id.state", "in", ["posted", "draft"])]
return domain
def _recalculate_move_lines(

4
account_financial_report/report/general_ledger.py

@ -191,6 +191,8 @@ class GeneralLedgerReport(models.AbstractModel):
base_domain += [("partner_id", "in", partner_ids)]
if only_posted_moves:
base_domain += [("move_id.state", "=", "posted")]
else:
base_domain += [("move_id.state", "in", ["posted", "draft"])]
if analytic_tag_ids:
base_domain += [("analytic_tag_ids", "in", analytic_tag_ids)]
if cost_center_ids:
@ -371,6 +373,8 @@ class GeneralLedgerReport(models.AbstractModel):
domain += [("partner_id", "in", partner_ids)]
if only_posted_moves:
domain += [("move_id.state", "=", "posted")]
else:
domain += [("move_id.state", "in", ["posted", "draft"])]
if analytic_tag_ids:
domain += [("analytic_tag_ids", "in", analytic_tag_ids)]
if cost_center_ids:

2
account_financial_report/report/journal_ledger.py

@ -49,6 +49,8 @@ class JournalLedgerReport(models.AbstractModel):
]
if wizard.move_target != "all":
domain += [("state", "=", wizard.move_target)]
else:
domain += [("state", "in", ["posted", "draft"])]
return domain
def _get_moves_order(self, wizard, journal_ids):

31
account_financial_report/report/open_items.py

@ -54,7 +54,7 @@ class OpenItemsReport(models.AbstractModel):
@api.model
def _get_new_move_lines_domain(
self, new_ml_ids, account_ids, company_id, partner_ids, target_moves
self, new_ml_ids, account_ids, company_id, partner_ids, only_posted_moves
):
domain = [
("account_id", "in", account_ids),
@ -63,8 +63,10 @@ class OpenItemsReport(models.AbstractModel):
]
if partner_ids:
domain += [("partner_id", "in", partner_ids)]
if target_moves == "posted":
if only_posted_moves:
domain += [("move_id.state", "=", "posted")]
else:
domain += [("move_id.state", "in", ["posted", "draft"])]
return domain
def _recalculate_move_lines(
@ -78,7 +80,7 @@ class OpenItemsReport(models.AbstractModel):
account_ids,
company_id,
partner_ids,
target_moves,
only_posted_moves,
):
debit_ids = set(debit_ids)
credit_ids = set(credit_ids)
@ -89,7 +91,7 @@ class OpenItemsReport(models.AbstractModel):
new_ml_ids = reconciled_ids - ml_ids
new_ml_ids = list(new_ml_ids)
new_domain = self._get_new_move_lines_domain(
new_ml_ids, account_ids, company_id, partner_ids, target_moves
new_ml_ids, account_ids, company_id, partner_ids, only_posted_moves
)
ml_fields = [
"id",
@ -123,7 +125,7 @@ class OpenItemsReport(models.AbstractModel):
@api.model
def _get_move_lines_domain(
self, company_id, account_ids, partner_ids, target_move, date_from
self, company_id, account_ids, partner_ids, only_posted_moves, date_from
):
domain = [
("account_id", "in", account_ids),
@ -132,8 +134,10 @@ class OpenItemsReport(models.AbstractModel):
]
if partner_ids:
domain += [("partner_id", "in", partner_ids)]
if target_move == "posted":
if only_posted_moves:
domain += [("move_id.state", "=", "posted")]
else:
domain += [("move_id.state", "in", ["posted", "draft"])]
if date_from:
domain += [("date", ">", date_from)]
return domain
@ -168,12 +172,12 @@ class OpenItemsReport(models.AbstractModel):
account_ids,
partner_ids,
date_at_object,
target_move,
only_posted_moves,
company_id,
date_from,
):
domain = self._get_move_lines_domain(
company_id, account_ids, partner_ids, target_move, date_from
company_id, account_ids, partner_ids, only_posted_moves, date_from
)
ml_fields = [
"id",
@ -223,7 +227,7 @@ class OpenItemsReport(models.AbstractModel):
account_ids,
company_id,
partner_ids,
target_move,
only_posted_moves,
)
move_lines = [
move_line
@ -356,7 +360,7 @@ class OpenItemsReport(models.AbstractModel):
date_at = data["date_at"]
date_at_object = datetime.strptime(date_at, "%Y-%m-%d").date()
date_from = data["date_from"]
target_move = data["target_move"]
only_posted_moves = data["only_posted_moves"]
show_partner_details = data["show_partner_details"]
(
@ -366,7 +370,12 @@ class OpenItemsReport(models.AbstractModel):
accounts_data,
open_items_move_lines_data,
) = self._get_data(
account_ids, partner_ids, date_at_object, target_move, company_id, date_from
account_ids,
partner_ids,
date_at_object,
only_posted_moves,
company_id,
date_from,
)
total_amount = self._calculate_amounts(open_items_move_lines_data)

8
account_financial_report/report/trial_balance.py

@ -74,6 +74,8 @@ class TrialBalanceReport(models.AbstractModel):
domain += [("partner_id", "in", partner_ids)]
if only_posted_moves:
domain += [("move_id.state", "=", "posted")]
else:
domain += [("move_id.state", "in", ["posted", "draft"])]
if show_partner_details:
domain += [("account_id.internal_type", "in", ["receivable", "payable"])]
return domain
@ -106,6 +108,8 @@ class TrialBalanceReport(models.AbstractModel):
domain += [("partner_id", "in", partner_ids)]
if only_posted_moves:
domain += [("move_id.state", "=", "posted")]
else:
domain += [("move_id.state", "in", ["posted", "draft"])]
if show_partner_details:
domain += [("account_id.internal_type", "in", ["receivable", "payable"])]
return domain
@ -137,6 +141,8 @@ class TrialBalanceReport(models.AbstractModel):
domain += [("partner_id", "in", partner_ids)]
if only_posted_moves:
domain += [("move_id.state", "=", "posted")]
else:
domain += [("move_id.state", "in", ["posted", "draft"])]
if show_partner_details:
domain += [("account_id.internal_type", "in", ["receivable", "payable"])]
return domain
@ -168,6 +174,8 @@ class TrialBalanceReport(models.AbstractModel):
domain += [("partner_id", "in", partner_ids)]
if only_posted_moves:
domain += [("move_id.state", "=", "posted")]
else:
domain += [("move_id.state", "in", ["posted", "draft"])]
if show_partner_details:
domain += [("account_id.internal_type", "in", ["receivable", "payable"])]
return domain

4
account_financial_report/report/vat_report.py

@ -40,6 +40,8 @@ class VATReport(models.AbstractModel):
]
if only_posted_moves:
domain += [("move_id.state", "=", "posted")]
else:
domain += [("move_id.state", "in", ["posted", "draft"])]
return domain
@api.model
@ -52,6 +54,8 @@ class VATReport(models.AbstractModel):
]
if only_posted_moves:
domain += [("move_id.state", "=", "posted")]
else:
domain += [("move_id.state", "in", ["posted", "draft"])]
return domain
def _get_vat_report_data(self, company_id, date_from, date_to, only_posted_moves):

4
account_financial_report/wizard/journal_ledger_wizard.py

@ -152,8 +152,8 @@ class JournalLedgerReportWizard(models.TransientModel):
@api.model
def _get_partner_name(self, partner_id, partner_data):
if str(partner_id) in partner_data.keys():
return partner_data[str(partner_id)]["name"]
if partner_id in partner_data.keys():
return partner_data[partner_id]["name"]
else:
return ""

Loading…
Cancel
Save