From eef99cab3fe61ea0f2a8e01a374c733514912694 Mon Sep 17 00:00:00 2001 From: Miquel Alzanillas Date: Mon, 28 Oct 2024 07:58:11 +0100 Subject: [PATCH] [IMP] partner_aging: pre-commit auto fixes --- partner_aging/README.rst | 57 ++++----- partner_aging/pyproject.toml | 3 + partner_aging/readme/CONTRIBUTORS.md | 9 ++ partner_aging/readme/CONTRIBUTORS.rst | 9 -- partner_aging/readme/CREDITS.md | 4 + partner_aging/readme/CREDITS.rst | 4 - .../{DESCRIPTION.rst => DESCRIPTION.md} | 9 +- partner_aging/readme/USAGE.md | 5 + partner_aging/readme/USAGE.rst | 5 - partner_aging/static/description/index.html | 15 +-- .../wizard/res_partner_aging_customer.py | 112 ++++++------------ .../wizard/res_partner_aging_supplier.py | 112 ++++++------------ 12 files changed, 139 insertions(+), 205 deletions(-) create mode 100644 partner_aging/pyproject.toml create mode 100644 partner_aging/readme/CONTRIBUTORS.md delete mode 100644 partner_aging/readme/CONTRIBUTORS.rst create mode 100644 partner_aging/readme/CREDITS.md delete mode 100644 partner_aging/readme/CREDITS.rst rename partner_aging/readme/{DESCRIPTION.rst => DESCRIPTION.md} (61%) create mode 100644 partner_aging/readme/USAGE.md delete mode 100644 partner_aging/readme/USAGE.rst diff --git a/partner_aging/README.rst b/partner_aging/README.rst index 6a8190c7ca9f..fd653a37bcf6 100644 --- a/partner_aging/README.rst +++ b/partner_aging/README.rst @@ -17,22 +17,23 @@ Interactive Partner Aging at any date :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html :alt: License: AGPL-3 .. |badge3| image:: https://img.shields.io/badge/github-OCA%2Faccount--payment-lightgray.png?logo=github - :target: https://github.com/OCA/account-payment/tree/16.0/partner_aging + :target: https://github.com/OCA/account-payment/tree/17.0/partner_aging :alt: OCA/account-payment .. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png - :target: https://translation.odoo-community.org/projects/account-payment-16-0/account-payment-16-0-partner_aging + :target: https://translation.odoo-community.org/projects/account-payment-17-0/account-payment-17-0-partner_aging :alt: Translate me on Weblate .. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png - :target: https://runboat.odoo-community.org/builds?repo=OCA/account-payment&target_branch=16.0 + :target: https://runboat.odoo-community.org/builds?repo=OCA/account-payment&target_branch=17.0 :alt: Try me on Runboat |badge1| |badge2| |badge3| |badge4| |badge5| -This module creates a new customer / supplier aging report as of a given date. +This module creates a new customer / supplier aging report as of a given +date. -The default Aged Partner balance report is related to a specific date and a -static PDF that is based on the difference between credits and debits, not -based on documents such as Invoices/Bills and Payments. +The default Aged Partner balance report is related to a specific date +and a static PDF that is based on the difference between credits and +debits, not based on documents such as Invoices/Bills and Payments. This module provides an interactive view with details of the invoice. @@ -48,9 +49,9 @@ Usage To use this module, you need to: -#. Go to Accounting -#. Click on Sales > Customer Aging or Purchases > Supplier Aging -#. Change the date if necessary +1. Go to Accounting +2. Click on Sales > Customer Aging or Purchases > Supplier Aging +3. Change the date if necessary Bug Tracker =========== @@ -58,7 +59,7 @@ Bug Tracker Bugs are tracked on `GitHub Issues `_. In case of trouble, please check there if your issue has already been reported. If you spotted it first, help us to smash it by providing a detailed and welcomed -`feedback `_. +`feedback `_. Do not contact contributors directly about support or help with technical issues. @@ -66,33 +67,33 @@ Credits ======= Authors -~~~~~~~ +------- * Open Source Integrators Contributors -~~~~~~~~~~~~ - -* Bhavesh Odedra -* Balaji Kannan -* Sandeep Mangukiya -* Sudarshan Kadalazhi -* Murtuza Saleh -* Maxime Chambreuil -* Nikul Chaudhary -* Ammar Offcewala -* Urvisha Desai +------------ + +- Bhavesh Odedra +- Balaji Kannan +- Sandeep Mangukiya +- Sudarshan Kadalazhi +- Murtuza Saleh +- Maxime Chambreuil +- Nikul Chaudhary +- Ammar Offcewala +- Urvisha Desai Other credits -~~~~~~~~~~~~~ +------------- The development of this module has been financially supported by: -* Open Source Integrators -* Serpent Consulting Services Pvt. Ltd. +- Open Source Integrators +- Serpent Consulting Services Pvt. Ltd. Maintainers -~~~~~~~~~~~ +----------- This module is maintained by the OCA. @@ -112,6 +113,6 @@ Current `maintainer `__: |maintainer-Urvisha-OSI| -This module is part of the `OCA/account-payment `_ project on GitHub. +This module is part of the `OCA/account-payment `_ project on GitHub. You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/partner_aging/pyproject.toml b/partner_aging/pyproject.toml new file mode 100644 index 000000000000..4231d0cccb3d --- /dev/null +++ b/partner_aging/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/partner_aging/readme/CONTRIBUTORS.md b/partner_aging/readme/CONTRIBUTORS.md new file mode 100644 index 000000000000..2b76145f2ff8 --- /dev/null +++ b/partner_aging/readme/CONTRIBUTORS.md @@ -0,0 +1,9 @@ +- Bhavesh Odedra \<\> +- Balaji Kannan \<\> +- Sandeep Mangukiya \<\> +- Sudarshan Kadalazhi \<\> +- Murtuza Saleh \<\> +- Maxime Chambreuil \<\> +- Nikul Chaudhary \<\> +- Ammar Offcewala \<\> +- Urvisha Desai \<\> diff --git a/partner_aging/readme/CONTRIBUTORS.rst b/partner_aging/readme/CONTRIBUTORS.rst deleted file mode 100644 index fc984e6b8650..000000000000 --- a/partner_aging/readme/CONTRIBUTORS.rst +++ /dev/null @@ -1,9 +0,0 @@ -* Bhavesh Odedra -* Balaji Kannan -* Sandeep Mangukiya -* Sudarshan Kadalazhi -* Murtuza Saleh -* Maxime Chambreuil -* Nikul Chaudhary -* Ammar Offcewala -* Urvisha Desai diff --git a/partner_aging/readme/CREDITS.md b/partner_aging/readme/CREDITS.md new file mode 100644 index 000000000000..081bc339d3bf --- /dev/null +++ b/partner_aging/readme/CREDITS.md @@ -0,0 +1,4 @@ +The development of this module has been financially supported by: + +- Open Source Integrators \<\> +- Serpent Consulting Services Pvt. Ltd. \<\> diff --git a/partner_aging/readme/CREDITS.rst b/partner_aging/readme/CREDITS.rst deleted file mode 100644 index 652cd7148e02..000000000000 --- a/partner_aging/readme/CREDITS.rst +++ /dev/null @@ -1,4 +0,0 @@ -The development of this module has been financially supported by: - -* Open Source Integrators -* Serpent Consulting Services Pvt. Ltd. diff --git a/partner_aging/readme/DESCRIPTION.rst b/partner_aging/readme/DESCRIPTION.md similarity index 61% rename from partner_aging/readme/DESCRIPTION.rst rename to partner_aging/readme/DESCRIPTION.md index 59ff97bfed4a..834d192139a2 100644 --- a/partner_aging/readme/DESCRIPTION.rst +++ b/partner_aging/readme/DESCRIPTION.md @@ -1,8 +1,9 @@ -This module creates a new customer / supplier aging report as of a given date. +This module creates a new customer / supplier aging report as of a given +date. -The default Aged Partner balance report is related to a specific date and a -static PDF that is based on the difference between credits and debits, not -based on documents such as Invoices/Bills and Payments. +The default Aged Partner balance report is related to a specific date +and a static PDF that is based on the difference between credits and +debits, not based on documents such as Invoices/Bills and Payments. This module provides an interactive view with details of the invoice. diff --git a/partner_aging/readme/USAGE.md b/partner_aging/readme/USAGE.md new file mode 100644 index 000000000000..a6ebe517e3ca --- /dev/null +++ b/partner_aging/readme/USAGE.md @@ -0,0 +1,5 @@ +To use this module, you need to: + +1. Go to Accounting +2. Click on Sales \> Customer Aging or Purchases \> Supplier Aging +3. Change the date if necessary diff --git a/partner_aging/readme/USAGE.rst b/partner_aging/readme/USAGE.rst deleted file mode 100644 index 5aa58565af50..000000000000 --- a/partner_aging/readme/USAGE.rst +++ /dev/null @@ -1,5 +0,0 @@ -To use this module, you need to: - -#. Go to Accounting -#. Click on Sales > Customer Aging or Purchases > Supplier Aging -#. Change the date if necessary diff --git a/partner_aging/static/description/index.html b/partner_aging/static/description/index.html index 2d41e179a59d..92f4d09216d0 100644 --- a/partner_aging/static/description/index.html +++ b/partner_aging/static/description/index.html @@ -369,11 +369,12 @@

Interactive Partner Aging at any date

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !! source digest: sha256:9d6c86b781d675e63abf8dd470d67e3151e1f402ed879ddacbf0e2eee51fa030 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! --> -

Production/Stable License: AGPL-3 OCA/account-payment Translate me on Weblate Try me on Runboat

-

This module creates a new customer / supplier aging report as of a given date.

-

The default Aged Partner balance report is related to a specific date and a -static PDF that is based on the difference between credits and debits, not -based on documents such as Invoices/Bills and Payments.

+

Production/Stable License: AGPL-3 OCA/account-payment Translate me on Weblate Try me on Runboat

+

This module creates a new customer / supplier aging report as of a given +date.

+

The default Aged Partner balance report is related to a specific date +and a static PDF that is based on the difference between credits and +debits, not based on documents such as Invoices/Bills and Payments.

This module provides an interactive view with details of the invoice.

This module does not consider unapplied credits.

Table of contents

@@ -404,7 +405,7 @@

Bug Tracker

Bugs are tracked on GitHub Issues. In case of trouble, please check there if your issue has already been reported. If you spotted it first, help us to smash it by providing a detailed and welcomed -feedback.

+feedback.

Do not contact contributors directly about support or help with technical issues.

@@ -448,7 +449,7 @@

Maintainers

promote its widespread use.

Current maintainer:

Urvisha-OSI

-

This module is part of the OCA/account-payment project on GitHub.

+

This module is part of the OCA/account-payment project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

diff --git a/partner_aging/wizard/res_partner_aging_customer.py b/partner_aging/wizard/res_partner_aging_customer.py index 83dc2a6256c2..c8ac0aac6f9a 100644 --- a/partner_aging/wizard/res_partner_aging_customer.py +++ b/partner_aging/wizard/res_partner_aging_customer.py @@ -31,7 +31,7 @@ def execute_aging_query(self, age_date=False): if not age_date: age_date = fields.Date.context_today(self) - query = """ + query = f""" SELECT aml.id, aml.partner_id as partner_id, ai.invoice_user_id as salesman, aml.date as date, aml.date as date_due, ai.name as invoice_ref, @@ -41,13 +41,13 @@ def execute_aging_query(self, age_date=False): aml.amount_residual<0) THEN -(aml.credit-(select coalesce(sum(apr.amount),0) from account_partial_reconcile apr where (apr.credit_move_id =aml.id or - apr.debit_move_id=aml.id) and apr.create_date <= '{}')) + apr.debit_move_id=aml.id) and apr.create_date <= '{age_date}')) WHEN (aml.full_reconcile_id is NULL and aml.amount_residual>0) THEN aml.debit-(select coalesce(sum(apr.amount),0) from account_partial_reconcile apr where (apr.credit_move_id =aml.id or - apr.debit_move_id=aml.id) and apr.create_date <= '{}') + apr.debit_move_id=aml.id) and apr.create_date <= '{age_date}') WHEN (aml.full_reconcile_id is NOT NULL) THEN aml.amount_residual END ELSE 0 END AS days_due_01to30, @@ -56,13 +56,13 @@ def execute_aging_query(self, age_date=False): aml.amount_residual<0) THEN -(aml.credit-(select coalesce(sum(apr.amount),0) from account_partial_reconcile apr where (apr.credit_move_id =aml.id or - apr.debit_move_id=aml.id) and apr.create_date <= '{}')) + apr.debit_move_id=aml.id) and apr.create_date <= '{age_date}')) WHEN (aml.full_reconcile_id is NULL and aml.amount_residual>0) THEN aml.debit-(select coalesce(sum(apr.amount),0) from account_partial_reconcile apr where (apr.credit_move_id =aml.id or - apr.debit_move_id=aml.id) and apr.create_date <= '{}') + apr.debit_move_id=aml.id) and apr.create_date <= '{age_date}') WHEN (aml.full_reconcile_id is NOT NULL) THEN aml.amount_residual END ELSE 0 END AS days_due_31to60, @@ -71,13 +71,13 @@ def execute_aging_query(self, age_date=False): aml.amount_residual<0) THEN -(aml.credit-(select coalesce(sum(apr.amount),0) from account_partial_reconcile apr where (apr.credit_move_id =aml.id or - apr.debit_move_id=aml.id) and apr.create_date <= '{}')) + apr.debit_move_id=aml.id) and apr.create_date <= '{age_date}')) WHEN (aml.full_reconcile_id is NULL and aml.amount_residual>0) THEN aml.debit-(select coalesce(sum(apr.amount),0) from account_partial_reconcile apr where (apr.credit_move_id =aml.id or - apr.debit_move_id=aml.id) and apr.create_date <= '{}') + apr.debit_move_id=aml.id) and apr.create_date <= '{age_date}') WHEN (aml.full_reconcile_id is NOT NULL) THEN aml.amount_residual END ELSE 0 END AS days_due_61to90, @@ -86,14 +86,14 @@ def execute_aging_query(self, age_date=False): aml.amount_residual<0) THEN -(aml.credit-(select coalesce(sum(apr.amount),0) from account_partial_reconcile apr where (apr.credit_move_id =aml.id or - apr.debit_move_id=aml.id) and apr.create_date <= '{}')) + apr.debit_move_id=aml.id) and apr.create_date <= '{age_date}')) WHEN (aml.full_reconcile_id is NULL and aml.amount_residual>0) THEN aml.debit-(select coalesce(sum(apr.amount),0) from account_partial_reconcile apr where (apr.credit_move_id =aml.id or apr.debit_move_id=aml.id) and - apr.create_date <= '{}') + apr.create_date <= '{age_date}') WHEN (aml.full_reconcile_id is NOT NULL) THEN aml.amount_residual END ELSE 0 END AS days_due_91to120, @@ -102,12 +102,12 @@ def execute_aging_query(self, age_date=False): aml.amount_residual<0) THEN -(aml.credit-(select coalesce(sum(apr.amount),0) from account_partial_reconcile apr where (apr.credit_move_id =aml.id or - apr.debit_move_id=aml.id) and apr.create_date <= '{}')) + apr.debit_move_id=aml.id) and apr.create_date <= '{age_date}')) WHEN (aml.full_reconcile_id is NULL and aml.amount_residual>0) THEN aml.debit-(select coalesce(sum(apr.amount),0) from account_partial_reconcile apr where (apr.credit_move_id =aml.id or - apr.debit_move_id=aml.id) and apr.create_date <= '{}') + apr.debit_move_id=aml.id) and apr.create_date <= '{age_date}') WHEN (aml.full_reconcile_id is NOT NULL) THEN aml.amount_residual END ELSE 0 END AS days_due_121togr, @@ -118,12 +118,12 @@ def execute_aging_query(self, age_date=False): aml.amount_residual<0) THEN -(aml.credit-(select coalesce(sum(apr.amount),0) from account_partial_reconcile apr where (apr.credit_move_id =aml.id or - apr.debit_move_id=aml.id) and apr.create_date <= '{}')) + apr.debit_move_id=aml.id) and apr.create_date <= '{age_date}')) WHEN (aml.full_reconcile_id is NULL and aml.amount_residual>0) THEN aml.debit-(select coalesce(sum(apr.amount),0) from account_partial_reconcile apr where (apr.credit_move_id =aml.id or - apr.debit_move_id=aml.id) and apr.create_date <= '{}') + apr.debit_move_id=aml.id) and apr.create_date <= '{age_date}') WHEN (aml.full_reconcile_id is NOT NULL) THEN aml.amount_residual END ELSE 0 END AS not_due, @@ -131,12 +131,12 @@ def execute_aging_query(self, age_date=False): aml.amount_residual<0) THEN -(aml.credit-(select coalesce(sum(apr.amount),0) from account_partial_reconcile apr where (apr.credit_move_id =aml.id or - apr.debit_move_id=aml.id) and apr.create_date <= '{}')) + apr.debit_move_id=aml.id) and apr.create_date <= '{age_date}')) WHEN (aml.full_reconcile_id is NULL and aml.amount_residual>0) THEN aml.debit-(select coalesce(sum(apr.amount),0) from account_partial_reconcile apr where (apr.credit_move_id =aml.id or - apr.debit_move_id=aml.id) and apr.create_date <= '{}') + apr.debit_move_id=aml.id) and apr.create_date <= '{age_date}') WHEN (aml.full_reconcile_id is NOT NULL) THEN aml.amount_residual END AS total, ai.id as invoice_id, @@ -146,7 +146,7 @@ def execute_aging_query(self, age_date=False): INNER JOIN (SELECT lt.id, CASE WHEN inv.invoice_date_due is null then 0 - WHEN inv.id is not null THEN '{}' - inv.invoice_date_due + WHEN inv.id is not null THEN '{age_date}' - inv.invoice_date_due ELSE current_date - lt.date END AS days_due FROM account_move_line lt LEFT JOIN account_move inv on lt.move_id = inv.id) DaysDue @@ -154,7 +154,7 @@ def execute_aging_query(self, age_date=False): LEFT JOIN account_move as ai ON ai.id = aml.move_id WHERE ac.account_type = 'asset_receivable' and aml.date - <= '{}' AND ai.state = 'posted' AND + <= '{age_date}' AND ai.state = 'posted' AND (ai.payment_state != 'paid' OR aml.full_reconcile_id IS NULL) AND ai.move_type IN ('out_invoice', 'out_refund') @@ -172,12 +172,12 @@ def execute_aging_query(self, age_date=False): aml.amount_residual<0) THEN -(aml.credit-(select coalesce(sum(apr.amount),0) from account_partial_reconcile apr where (apr.credit_move_id =aml.id or - apr.debit_move_id=aml.id) and apr.create_date <= '{}')) + apr.debit_move_id=aml.id) and apr.create_date <= '{age_date}')) WHEN (aml.full_reconcile_id is NULL and aml.amount_residual>0) THEN aml.debit-(select coalesce(sum(apr.amount),0) from account_partial_reconcile apr where (apr.credit_move_id =aml.id or - apr.debit_move_id=aml.id) and apr.create_date <= '{}') + apr.debit_move_id=aml.id) and apr.create_date <= '{age_date}') WHEN (aml.full_reconcile_id is NOT NULL) THEN aml.amount_residual END ELSE 0 END AS days_due_01to30, @@ -186,14 +186,14 @@ def execute_aging_query(self, age_date=False): aml.amount_residual<0) THEN -(aml.credit-(select coalesce(sum(apr.amount),0) from account_partial_reconcile apr where (apr.credit_move_id =aml.id or - apr.debit_move_id=aml.id) and apr.create_date <= '{}')) + apr.debit_move_id=aml.id) and apr.create_date <= '{age_date}')) WHEN (aml.full_reconcile_id is NULL and aml.amount_residual>0) THEN aml.debit-(select coalesce(sum(apr.amount),0) from account_partial_reconcile apr where (apr.credit_move_id =aml.id or apr.debit_move_id=aml.id) - and apr.create_date <= '{}') + and apr.create_date <= '{age_date}') WHEN (aml.full_reconcile_id is NOT NULL) THEN aml.amount_residual END ELSE 0 END AS days_due_31to60, @@ -202,13 +202,13 @@ def execute_aging_query(self, age_date=False): aml.amount_residual<0) THEN -(aml.credit-(select coalesce(sum(apr.amount),0) from account_partial_reconcile apr where (apr.credit_move_id =aml.id or - apr.debit_move_id=aml.id) and apr.create_date <= '{}')) + apr.debit_move_id=aml.id) and apr.create_date <= '{age_date}')) WHEN (aml.full_reconcile_id is NULL and aml.amount_residual>0) THEN aml.debit-(select coalesce(sum(apr.amount),0) from account_partial_reconcile apr where (apr.credit_move_id =aml.id or - apr.debit_move_id=aml.id) and apr.create_date <= '{}') + apr.debit_move_id=aml.id) and apr.create_date <= '{age_date}') WHEN (aml.full_reconcile_id is NOT NULL) THEN aml.amount_residual END ELSE 0 END AS days_due_61to90, @@ -218,12 +218,12 @@ def execute_aging_query(self, age_date=False): coalesce(sum(apr.amount),0) from account_partial_reconcile apr where (apr.credit_move_id =aml.id or apr.debit_move_id=aml.id) - and apr.create_date <= '{}')) WHEN (aml.full_reconcile_id + and apr.create_date <= '{age_date}')) WHEN (aml.full_reconcile_id is NULL and aml.amount_residual>0) THEN aml.debit-(select coalesce(sum(apr.amount),0) from account_partial_reconcile apr where (apr.credit_move_id =aml.id or apr.debit_move_id=aml.id) - and apr.create_date <= '{}') + and apr.create_date <= '{age_date}') WHEN (aml.full_reconcile_id is NOT NULL) THEN aml.amount_residual END ELSE 0 END AS days_due_91to120, @@ -233,11 +233,11 @@ def execute_aging_query(self, age_date=False): coalesce(sum(apr.amount),0) from account_partial_reconcile apr where (apr.credit_move_id =aml.id or apr.debit_move_id=aml.id) - and apr.create_date <= '{}')) WHEN (aml.full_reconcile_id + and apr.create_date <= '{age_date}')) WHEN (aml.full_reconcile_id is NULL and aml.amount_residual>0) THEN aml.debit-(select coalesce(sum(apr.amount),0) from account_partial_reconcile apr where (apr.credit_move_id =aml.id or - apr.debit_move_id=aml.id) and apr.create_date <= '{}') + apr.debit_move_id=aml.id) and apr.create_date <= '{age_date}') WHEN (aml.full_reconcile_id is NOT NULL) THEN aml.amount_residual END ELSE 0 END AS days_due_121togr, @@ -249,12 +249,12 @@ def execute_aging_query(self, age_date=False): aml.amount_residual<0) THEN -(aml.credit-(select coalesce(sum(apr.amount),0) from account_partial_reconcile apr where (apr.credit_move_id =aml.id or - apr.debit_move_id=aml.id) and apr.create_date <= '{}')) + apr.debit_move_id=aml.id) and apr.create_date <= '{age_date}')) WHEN (aml.full_reconcile_id is NULL and aml.amount_residual>0) THEN aml.debit-(select coalesce(sum(apr.amount),0) from account_partial_reconcile apr where (apr.credit_move_id =aml.id or - apr.debit_move_id=aml.id) and apr.create_date <= '{}') + apr.debit_move_id=aml.id) and apr.create_date <= '{age_date}') WHEN (aml.full_reconcile_id is NOT NULL) THEN aml.amount_residual END ELSE 0 END AS not_due, @@ -262,12 +262,12 @@ def execute_aging_query(self, age_date=False): aml.amount_residual<0) THEN -(aml.credit-(select coalesce(sum(apr.amount),0) from account_partial_reconcile apr where (apr.credit_move_id =aml.id or - apr.debit_move_id=aml.id) and apr.create_date <= '{}')) + apr.debit_move_id=aml.id) and apr.create_date <= '{age_date}')) WHEN (aml.full_reconcile_id is NULL and aml.amount_residual>0) THEN aml.debit-(select coalesce(sum(apr.amount),0) from account_partial_reconcile apr where (apr.credit_move_id =aml.id or - apr.debit_move_id=aml.id) and apr.create_date <= '{}') + apr.debit_move_id=aml.id) and apr.create_date <= '{age_date}') WHEN (aml.full_reconcile_id is NOT NULL) THEN aml.amount_residual END AS total, ai.id as invoice_id, @@ -278,7 +278,7 @@ def execute_aging_query(self, age_date=False): ( SELECT lt.id, CASE WHEN inv.invoice_date_due is null then 0 - WHEN inv.id is not null THEN '{}' - inv.invoice_date_due + WHEN inv.id is not null THEN '{age_date}' - inv.invoice_date_due ELSE current_date - lt.date END AS days_due FROM account_move_line lt LEFT JOIN account_move inv on lt.move_id = inv.id @@ -286,7 +286,7 @@ def execute_aging_query(self, age_date=False): ON DaysDue.id = aml.id LEFT JOIN account_move as ai ON ai.id = aml.move_id WHERE ac.account_type = 'asset_receivable' - AND aml.date <= '{}' + AND aml.date <= '{age_date}' AND aml.partner_id IS NULL AND ai.partner_id IS not NULL AND aml.full_reconcile_id is NULL @@ -309,59 +309,23 @@ def execute_aging_query(self, age_date=False): CASE WHEN (aml.credit - (select sum(debit) from account_move_line l where l.full_reconcile_id = aml.full_reconcile_id and - l.date<='{}')) > 0 then -(aml.credit - (select + l.date<='{age_date}')) > 0 then -(aml.credit - (select sum(debit) from account_move_line l where l.full_reconcile_id = aml.full_reconcile_id and - l.date<='{}')) ELSE 0 END AS total, + l.date<='{age_date}')) ELSE 0 END AS total, null as invoice_id, aml.date as inv_date_due from account_move_line aml LEFT JOIN account_account ac on ac.id = aml.account_id - where aml.date <= '{}' + where aml.date <= '{age_date}' and aml.partner_id IS NOT NULL and aml.full_reconcile_id IS NOT NULL and ac.account_type = 'asset_receivable' and aml.credit > 0 - """.format( - age_date, - age_date, - age_date, - age_date, - age_date, - age_date, - age_date, - age_date, - age_date, - age_date, - age_date, - age_date, - age_date, - age_date, - age_date, - age_date, - age_date, - age_date, - age_date, - age_date, - age_date, - age_date, - age_date, - age_date, - age_date, - age_date, - age_date, - age_date, - age_date, - age_date, - age_date, - age_date, - age_date, - age_date, - age_date, - ) + """ tools.drop_view_if_exists(self.env.cr, self._table) # pylint: disable=sql-injection - q = """CREATE OR REPLACE VIEW {} AS ({})""".format(self._table, (query)) + q = f"""CREATE OR REPLACE VIEW {self._table} AS ({query})""" self.env.cr.execute(q) def open_document(self): diff --git a/partner_aging/wizard/res_partner_aging_supplier.py b/partner_aging/wizard/res_partner_aging_supplier.py index ff96dd63c925..93d58ed49e4b 100644 --- a/partner_aging/wizard/res_partner_aging_supplier.py +++ b/partner_aging/wizard/res_partner_aging_supplier.py @@ -31,7 +31,7 @@ def execute_aging_query(self, age_date=False): if not age_date: age_date = fields.Date.context_today(self) - query = """ + query = f""" SELECT aml.id, aml.partner_id as partner_id, ai.invoice_user_id as salesman, aml.date as date, aml.date as date_due, ai.name as invoice_ref, days_due AS avg_days_overdue, @@ -41,13 +41,13 @@ def execute_aging_query(self, age_date=False): select coalesce(sum(apr.amount),0) from account_partial_reconcile apr where (apr.credit_move_id =aml.id or apr.debit_move_id=aml.id) - and apr.create_date <= '{}') + and apr.create_date <= '{age_date}') WHEN (aml.full_reconcile_id is NULL and aml.amount_residual>0) THEN -( aml.debit-(select coalesce(sum(apr.amount),0) from account_partial_reconcile apr where (apr.credit_move_id =aml.id or - apr.debit_move_id=aml.id) and apr.create_date <= '{}')) + apr.debit_move_id=aml.id) and apr.create_date <= '{age_date}')) WHEN (aml.full_reconcile_id is NOT NULL) THEN aml.amount_residual END ELSE 0 END AS days_due_01to30, @@ -57,13 +57,13 @@ def execute_aging_query(self, age_date=False): select coalesce(sum(apr.amount),0) from account_partial_reconcile apr where (apr.credit_move_id =aml.id or apr.debit_move_id=aml.id) - and apr.create_date <= '{}') + and apr.create_date <= '{age_date}') WHEN (aml.full_reconcile_id is NULL and aml.amount_residual>0) THEN -( aml.debit-(select coalesce(sum(apr.amount),0) from account_partial_reconcile apr where (apr.credit_move_id =aml.id or - apr.debit_move_id=aml.id) and apr.create_date <= '{}')) + apr.debit_move_id=aml.id) and apr.create_date <= '{age_date}')) WHEN (aml.full_reconcile_id is NOT NULL) THEN aml.amount_residual END ELSE 0 END AS days_due_31to60, @@ -73,13 +73,13 @@ def execute_aging_query(self, age_date=False): select coalesce(sum(apr.amount),0) from account_partial_reconcile apr where ( apr.credit_move_id =aml.id or apr.debit_move_id=aml.id) - and apr.create_date <= '{}') + and apr.create_date <= '{age_date}') WHEN (aml.full_reconcile_id is NULL and aml.amount_residual>0) THEN -( aml.debit-(select coalesce(sum(apr.amount),0) from account_partial_reconcile apr where (apr.credit_move_id =aml.id or - apr.debit_move_id=aml.id) and apr.create_date <= '{}')) + apr.debit_move_id=aml.id) and apr.create_date <= '{age_date}')) WHEN (aml.full_reconcile_id is NOT NULL) THEN aml.amount_residual END ELSE 0 END AS days_due_61to90, @@ -89,13 +89,13 @@ def execute_aging_query(self, age_date=False): select coalesce(sum(apr.amount),0) from account_partial_reconcile apr where ( apr.credit_move_id =aml.id or - apr.debit_move_id=aml.id) and apr.create_date <= '{}') + apr.debit_move_id=aml.id) and apr.create_date <= '{age_date}') WHEN (aml.full_reconcile_id is NULL and aml.amount_residual>0) THEN -( aml.debit-(select coalesce(sum(apr.amount),0) from account_partial_reconcile apr where ( apr.credit_move_id =aml.id or - apr.debit_move_id=aml.id) and apr.create_date <= '{}')) + apr.debit_move_id=aml.id) and apr.create_date <= '{age_date}')) WHEN (aml.full_reconcile_id is NOT NULL) THEN aml.amount_residual END ELSE 0 END AS days_due_91to120, @@ -105,13 +105,13 @@ def execute_aging_query(self, age_date=False): select coalesce(sum(apr.amount),0) from account_partial_reconcile apr where ( apr.credit_move_id =aml.id or - apr.debit_move_id=aml.id) and apr.create_date <= '{}') + apr.debit_move_id=aml.id) and apr.create_date <= '{age_date}') WHEN (aml.full_reconcile_id is NULL and aml.amount_residual>0) THEN -( aml.debit-(select coalesce(sum(apr.amount),0) from account_partial_reconcile apr where ( apr.credit_move_id =aml.id or - apr.debit_move_id=aml.id) and apr.create_date <= '{}')) + apr.debit_move_id=aml.id) and apr.create_date <= '{age_date}')) WHEN (aml.full_reconcile_id is NOT NULL) THEN aml.amount_residual END ELSE 0 END AS days_due_121togr, @@ -124,13 +124,13 @@ def execute_aging_query(self, age_date=False): select coalesce(sum(apr.amount),0) from account_partial_reconcile apr where ( apr.credit_move_id =aml.id or - apr.debit_move_id=aml.id) and apr.create_date <= '{}') + apr.debit_move_id=aml.id) and apr.create_date <= '{age_date}') WHEN (aml.full_reconcile_id is NULL and aml.amount_residual>0) THEN -(aml.debit-( select coalesce(sum(apr.amount),0) from account_partial_reconcile apr where ( apr.credit_move_id =aml.id or - apr.debit_move_id=aml.id) and apr.create_date <= '{}')) + apr.debit_move_id=aml.id) and apr.create_date <= '{age_date}')) WHEN (aml.full_reconcile_id is NOT NULL) THEN aml.amount_residual END ELSE 0 END AS not_due, @@ -139,13 +139,13 @@ def execute_aging_query(self, age_date=False): select coalesce(sum(apr.amount),0) from account_partial_reconcile apr where ( apr.credit_move_id =aml.id or apr.debit_move_id=aml.id) and - apr.create_date <= '{}') + apr.create_date <= '{age_date}') WHEN (aml.full_reconcile_id is NULL and aml.amount_residual>0) THEN -(aml.debit-( select coalesce(sum(apr.amount),0) from account_partial_reconcile apr where ( apr.credit_move_id =aml.id or - apr.debit_move_id=aml.id) and apr.create_date <= '{}')) + apr.debit_move_id=aml.id) and apr.create_date <= '{age_date}')) WHEN (aml.full_reconcile_id is NOT NULL) THEN aml.amount_residual END AS total, ai.id as invoice_id, @@ -156,7 +156,7 @@ def execute_aging_query(self, age_date=False): ( SELECT lt.id, CASE WHEN inv.invoice_date_due is null then 0 - WHEN inv.id is not null THEN '{}' - inv.invoice_date_due + WHEN inv.id is not null THEN '{age_date}' - inv.invoice_date_due ELSE current_date - lt.date END AS days_due FROM account_move_line lt LEFT JOIN account_move inv on lt.move_id = inv.id @@ -165,7 +165,7 @@ def execute_aging_query(self, age_date=False): LEFT JOIN account_move as ai ON ai.id = aml.move_id WHERE ac.account_type = 'liability_payable' - AND aml.date <= '{}' + AND aml.date <= '{age_date}' AND ai.state = 'posted' AND (ai.payment_state != 'paid' OR aml.full_reconcile_id IS NULL) @@ -183,13 +183,13 @@ def execute_aging_query(self, age_date=False): select coalesce(sum(apr.amount),0) from account_partial_reconcile apr where ( apr.credit_move_id =aml.id or apr.debit_move_id=aml.id - ) and apr.create_date <= '{}') + ) and apr.create_date <= '{age_date}') WHEN (aml.full_reconcile_id is NULL and aml.amount_residual>0) THEN -(aml.debit-( select coalesce(sum(apr.amount),0) from account_partial_reconcile apr where ( apr.credit_move_id =aml.id or - apr.debit_move_id=aml.id) and apr.create_date <= '{}')) + apr.debit_move_id=aml.id) and apr.create_date <= '{age_date}')) WHEN (aml.full_reconcile_id is NOT NULL) THEN aml.amount_residual END ELSE 0 END AS days_due_01to30, @@ -199,13 +199,13 @@ def execute_aging_query(self, age_date=False): select coalesce(sum(apr.amount),0) from account_partial_reconcile apr where ( apr.credit_move_id =aml.id or apr.debit_move_id=aml.id) - and apr.create_date <= '{}') + and apr.create_date <= '{age_date}') WHEN (aml.full_reconcile_id is NULL and aml.amount_residual>0) THEN -(aml.debit-( select coalesce(sum(apr.amount),0) from account_partial_reconcile apr where ( apr.credit_move_id =aml.id or - apr.debit_move_id=aml.id) and apr.create_date <= '{}')) + apr.debit_move_id=aml.id) and apr.create_date <= '{age_date}')) WHEN (aml.full_reconcile_id is NOT NULL) THEN aml.amount_residual END ELSE 0 END AS days_due_31to60, @@ -215,13 +215,13 @@ def execute_aging_query(self, age_date=False): select coalesce(sum(apr.amount),0) from account_partial_reconcile apr where ( apr.credit_move_id =aml.id or apr.debit_move_id=aml.id - ) and apr.create_date <= '{}') + ) and apr.create_date <= '{age_date}') WHEN (aml.full_reconcile_id is NULL and aml.amount_residual>0) THEN -(aml.debit-( select coalesce(sum(apr.amount),0) from account_partial_reconcile apr where ( apr.credit_move_id =aml.id or - apr.debit_move_id=aml.id) and apr.create_date <= '{}')) + apr.debit_move_id=aml.id) and apr.create_date <= '{age_date}')) WHEN (aml.full_reconcile_id is NOT NULL) THEN aml.amount_residual END ELSE 0 END AS days_due_61to90, @@ -231,13 +231,13 @@ def execute_aging_query(self, age_date=False): select coalesce(sum(apr.amount),0) from account_partial_reconcile apr where ( apr.credit_move_id =aml.id or - apr.debit_move_id=aml.id) and apr.create_date <= '{}') + apr.debit_move_id=aml.id) and apr.create_date <= '{age_date}') WHEN (aml.full_reconcile_id is NULL and aml.amount_residual>0) THEN -(aml.debit-( select coalesce(sum(apr.amount),0) from account_partial_reconcile apr where ( apr.credit_move_id =aml.id or - apr.debit_move_id=aml.id) and apr.create_date <= '{}')) + apr.debit_move_id=aml.id) and apr.create_date <= '{age_date}')) WHEN (aml.full_reconcile_id is NOT NULL) THEN aml.amount_residual END ELSE 0 END AS days_due_91to120, @@ -247,13 +247,13 @@ def execute_aging_query(self, age_date=False): select coalesce(sum(apr.amount),0) from account_partial_reconcile apr where (apr.credit_move_id =aml.id or - apr.debit_move_id=aml.id) and apr.create_date <= '{}') + apr.debit_move_id=aml.id) and apr.create_date <= '{age_date}') WHEN (aml.full_reconcile_id is NULL and aml.amount_residual>0) THEN -(aml.debit-( select coalesce(sum(apr.amount),0) from account_partial_reconcile apr where ( apr.credit_move_id =aml.id or - apr.debit_move_id=aml.id) and apr.create_date <= '{}')) + apr.debit_move_id=aml.id) and apr.create_date <= '{age_date}')) WHEN (aml.full_reconcile_id is NOT NULL) THEN aml.amount_residual END ELSE 0 END AS days_due_121togr, @@ -266,13 +266,13 @@ def execute_aging_query(self, age_date=False): select coalesce(sum(apr.amount),0) from account_partial_reconcile apr where ( apr.credit_move_id =aml.id or - apr.debit_move_id=aml.id) and apr.create_date <= '{}') + apr.debit_move_id=aml.id) and apr.create_date <= '{age_date}') WHEN (aml.full_reconcile_id is NULL and aml.amount_residual>0) THEN -(aml.debit-( select coalesce(sum(apr.amount),0) from account_partial_reconcile apr where ( apr.credit_move_id =aml.id or - apr.debit_move_id=aml.id) and apr.create_date <= '{}')) + apr.debit_move_id=aml.id) and apr.create_date <= '{age_date}')) WHEN (aml.full_reconcile_id is NOT NULL) THEN aml.amount_residual END ELSE 0 END AS not_due, @@ -281,13 +281,13 @@ def execute_aging_query(self, age_date=False): select coalesce(sum(apr.amount),0) from account_partial_reconcile apr where ( apr.credit_move_id =aml.id or apr.debit_move_id=aml.id) - and apr.create_date <= '{}') + and apr.create_date <= '{age_date}') WHEN (aml.full_reconcile_id is NULL and aml.amount_residual>0) THEN -(aml.debit-( select coalesce(sum(apr.amount),0) from account_partial_reconcile apr where ( apr.credit_move_id =aml.id or apr.debit_move_id=aml.id - ) and apr.create_date <= '{}')) + ) and apr.create_date <= '{age_date}')) WHEN (aml.full_reconcile_id is NOT NULL) THEN aml.amount_residual END AS total, ai.id as invoice_id, @@ -298,7 +298,7 @@ def execute_aging_query(self, age_date=False): ( SELECT lt.id, CASE WHEN inv.invoice_date_due is null then 0 - WHEN inv.id is not null THEN '{}' - inv.invoice_date_due + WHEN inv.id is not null THEN '{age_date}' - inv.invoice_date_due ELSE current_date - lt.date END AS days_due FROM account_move_line lt LEFT JOIN account_move inv on lt.move_id = inv.id @@ -307,7 +307,7 @@ def execute_aging_query(self, age_date=False): LEFT JOIN account_move as ai ON ai.id = aml.move_id WHERE ac.account_type = 'liability_payable' - AND aml.date <= '{}' + AND aml.date <= '{age_date}' AND aml.partner_id IS NULL and ai.partner_id IS NOT NULL AND aml.full_reconcile_id is NULL @@ -331,61 +331,25 @@ def execute_aging_query(self, age_date=False): CASE WHEN (aml.debit - (select sum(credit) from account_move_line l where l.full_reconcile_id = aml.full_reconcile_id - and l.date<='{}')) > 0 then + and l.date<='{age_date}')) > 0 then -(aml.debit - (select sum(credit) from account_move_line l where l.full_reconcile_id = aml.full_reconcile_id - and l.date<='{}')) + and l.date<='{age_date}')) ELSE 0 END AS total, null as invoice_id, aml.date as inv_date_due from account_move_line aml LEFT JOIN account_account ac on ac.id = aml.account_id - where aml.date <= '{}' + where aml.date <= '{age_date}' and aml.full_reconcile_id IS NOT NULL and ac.account_type = 'liability_payable' and aml.debit > 0 - """.format( - age_date, - age_date, - age_date, - age_date, - age_date, - age_date, - age_date, - age_date, - age_date, - age_date, - age_date, - age_date, - age_date, - age_date, - age_date, - age_date, - age_date, - age_date, - age_date, - age_date, - age_date, - age_date, - age_date, - age_date, - age_date, - age_date, - age_date, - age_date, - age_date, - age_date, - age_date, - age_date, - age_date, - age_date, - age_date, - ) + """ tools.drop_view_if_exists(self.env.cr, self._table) # pylint: disable=sql-injection - q = """CREATE OR REPLACE VIEW {} AS ({})""".format(self._table, (query)) + q = f"""CREATE OR REPLACE VIEW {self._table} AS ({query})""" self.env.cr.execute(q) def open_document(self):