From 69b868cbc61d709fb9a894d90baf60b19cac2ecc Mon Sep 17 00:00:00 2001
From: mreficent
Date: Tue, 4 Feb 2020 12:26:38 +0100
Subject: [PATCH] [MIG] partner_statement: Migration to 13.0
---
partner_statement/README.rst | 18 +++++++++---------
partner_statement/__manifest__.py | 8 ++++----
partner_statement/i18n/partner_statement.pot | 2 +-
partner_statement/readme/CONTRIBUTORS.rst | 2 +-
partner_statement/report/activity_statement.py | 15 +++++++--------
.../report/outstanding_statement.py | 12 ++++++------
.../report/report_statement_common.py | 11 +++++------
.../static/description/index.html | 12 ++++++------
.../tests/test_activity_statement.py | 12 ++++++------
.../tests/test_outstanding_statement.py | 10 +++++-----
.../tests/test_res_config_settings.py | 2 +-
partner_statement/views/activity_statement.xml | 2 +-
partner_statement/views/aging_buckets.xml | 2 +-
partner_statement/views/assets.xml | 2 +-
.../views/outstanding_statement.xml | 2 +-
.../views/res_config_settings.xml | 5 ++++-
.../wizard/activity_statement_wizard.py | 7 +++----
.../wizard/outstanding_statement_wizard.py | 7 +++----
partner_statement/wizard/statement_common.py | 1 -
partner_statement/wizard/statement_wizard.xml | 10 +++-------
20 files changed, 68 insertions(+), 74 deletions(-)
diff --git a/partner_statement/README.rst b/partner_statement/README.rst
index 0520050a..a8f0b656 100644
--- a/partner_statement/README.rst
+++ b/partner_statement/README.rst
@@ -14,18 +14,18 @@ Partner Statement
: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--financial--reporting-lightgray.png?logo=github
- :target: https://github.com/OCA/account-financial-reporting/tree/12.0/partner_statement
+ :target: https://github.com/OCA/account-financial-reporting/tree/13.0/partner_statement
:alt: OCA/account-financial-reporting
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
- :target: https://translation.odoo-community.org/projects/account-financial-reporting-12-0/account-financial-reporting-12-0-partner_statement
+ :target: https://translation.odoo-community.org/projects/account-financial-reporting-13-0/account-financial-reporting-13-0-partner_statement
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
- :target: https://runbot.odoo-community.org/runbot/91/12.0
+ :target: https://runbot.odoo-community.org/runbot/91/13.0
:alt: Try me on Runbot
-|badge1| |badge2| |badge3| |badge4| |badge5|
+|badge1| |badge2| |badge3| |badge4| |badge5|
-This module extends the functionality of Invoicing to support the printing of customer and vendor statements.
+This module extends the functionality of Invoicing to support the printing of customer and vendor statements.
There are two types of statements, Activity and Outstanding. Aging details can be shown in the reports, expressed in aging buckets,
so the customer or vendor can review how much is open, due or overdue.
@@ -96,7 +96,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 smashing it by providing a detailed and welcomed
-`feedback `_.
+`feedback `_.
Do not contact contributors directly about support or help with technical issues.
@@ -106,12 +106,12 @@ Credits
Authors
~~~~~~~
-* Eficent
+* ForgeFlow
Contributors
~~~~~~~~~~~~
-* Miquel Raïch
+* Miquel Raïch
* Graeme Gellatly
Maintainers
@@ -127,6 +127,6 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.
-This module is part of the `OCA/account-financial-reporting `_ project on GitHub.
+This module is part of the `OCA/account-financial-reporting `_ project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
diff --git a/partner_statement/__manifest__.py b/partner_statement/__manifest__.py
index 9678a23a..f37b56fd 100644
--- a/partner_statement/__manifest__.py
+++ b/partner_statement/__manifest__.py
@@ -1,16 +1,16 @@
-# Copyright 2018 Eficent Business and IT Consulting Services S.L.
-# (http://www.eficent.com)
+# Copyright 2018 ForgeFlow, S.L. (http://www.forgeflow.com)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
{
"name": "Partner Statement",
- "version": "12.0.1.0.5",
+ "version": "13.0.1.0.0",
"category": "Accounting & Finance",
"summary": "OCA Financial Reports",
- "author": "Eficent, Odoo Community Association (OCA)",
+ "author": "ForgeFlow, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/account-financial-reporting",
"license": "AGPL-3",
"depends": ["account"],
+ "external_dependencies": {"python": ["dateutil"]},
"data": [
"security/statement_security.xml",
"views/activity_statement.xml",
diff --git a/partner_statement/i18n/partner_statement.pot b/partner_statement/i18n/partner_statement.pot
index 0728e300..d3252096 100644
--- a/partner_statement/i18n/partner_statement.pot
+++ b/partner_statement/i18n/partner_statement.pot
@@ -4,7 +4,7 @@
#
msgid ""
msgstr ""
-"Project-Id-Version: Odoo Server 12.0\n"
+"Project-Id-Version: Odoo Server 13.0\n"
"Report-Msgid-Bugs-To: \n"
"Last-Translator: <>\n"
"Language-Team: \n"
diff --git a/partner_statement/readme/CONTRIBUTORS.rst b/partner_statement/readme/CONTRIBUTORS.rst
index 1e2a70df..286b2c12 100644
--- a/partner_statement/readme/CONTRIBUTORS.rst
+++ b/partner_statement/readme/CONTRIBUTORS.rst
@@ -1,2 +1,2 @@
-* Miquel Raïch
+* Miquel Raïch
* Graeme Gellatly
diff --git a/partner_statement/report/activity_statement.py b/partner_statement/report/activity_statement.py
index b45d6873..f1de2b6c 100644
--- a/partner_statement/report/activity_statement.py
+++ b/partner_statement/report/activity_statement.py
@@ -1,5 +1,4 @@
-# Copyright 2018 Eficent Business and IT Consulting Services S.L.
-# (http://www.eficent.com)
+# Copyright 2018 ForgeFlow, S.L. (https://www.forgeflow.com)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
from collections import defaultdict
@@ -12,6 +11,7 @@ class ActivityStatement(models.AbstractModel):
_inherit = "statement.common"
_name = "report.partner_statement.activity_statement"
+ _description = "Partner Activity Statement"
def _initial_balance_sql_q1(self, partners, date_start, account_type):
return str(
@@ -27,9 +27,9 @@ class ActivityStatement(models.AbstractModel):
ELSE sum(l.credit)
END as credit
FROM account_move_line l
- JOIN account_account_type at ON (at.id = l.user_type_id)
JOIN account_move m ON (l.move_id = m.id)
- WHERE l.partner_id IN %(partners)s AND at.type = %(account_type)s
+ WHERE l.partner_id IN %(partners)s
+ AND l.account_internal_type = %(account_type)s
AND l.date < %(date_start)s AND not l.blocked
AND m.state IN ('posted')
GROUP BY l.partner_id, l.currency_id, l.amount_currency,
@@ -103,11 +103,10 @@ class ActivityStatement(models.AbstractModel):
ELSE l.date_maturity
END as date_maturity
FROM account_move_line l
- JOIN account_account_type at ON (at.id = l.user_type_id)
JOIN account_move m ON (l.move_id = m.id)
JOIN account_journal aj ON (l.journal_id = aj.id)
WHERE l.partner_id IN %(partners)s
- AND at.type = %(account_type)s
+ AND l.account_internal_type = %(account_type)s
AND %(date_start)s <= l.date
AND l.date <= %(date_end)s
AND m.state IN ('posted')
@@ -172,8 +171,8 @@ class ActivityStatement(models.AbstractModel):
res[row.pop("partner_id")].append(row)
return res
- @api.multi
- def _get_report_values(self, docids, data):
+ @api.model
+ def _get_report_values(self, docids, data=None):
if not data:
data = {}
if "company_id" not in data:
diff --git a/partner_statement/report/outstanding_statement.py b/partner_statement/report/outstanding_statement.py
index 63b42cbe..ce1af302 100644
--- a/partner_statement/report/outstanding_statement.py
+++ b/partner_statement/report/outstanding_statement.py
@@ -1,5 +1,4 @@
-# Copyright 2018 Eficent Business and IT Consulting Services S.L.
-# (http://www.eficent.com)
+# Copyright 2018 ForgeFlow, S.L. (https://www.forgeflow.com)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
from odoo import api, models
@@ -10,6 +9,7 @@ class OutstandingStatement(models.AbstractModel):
_inherit = "statement.common"
_name = "report.partner_statement.outstanding_statement"
+ _description = "Partner Outstanding Statement"
def _display_lines_sql_q1(self, partners, date_end, account_type):
partners = tuple(partners)
@@ -39,7 +39,6 @@ class OutstandingStatement(models.AbstractModel):
ELSE l.date_maturity
END as date_maturity
FROM account_move_line l
- JOIN account_account_type at ON (at.id = l.user_type_id)
JOIN account_move m ON (l.move_id = m.id)
LEFT JOIN (SELECT pr.*
FROM account_partial_reconcile pr
@@ -53,7 +52,8 @@ class OutstandingStatement(models.AbstractModel):
ON pr.debit_move_id = l2.id
WHERE l2.date <= %(date_end)s
) as pc ON pc.credit_move_id = l.id
- WHERE l.partner_id IN %(partners)s AND at.type = %(account_type)s
+ WHERE l.partner_id IN %(partners)s
+ AND l.account_internal_type = %(account_type)s
AND (
(pd.id IS NOT NULL AND
pd.max_date <= %(date_end)s) OR
@@ -131,8 +131,8 @@ class OutstandingStatement(models.AbstractModel):
res[row.pop("partner_id")].append(row)
return res
- @api.multi
- def _get_report_values(self, docids, data):
+ @api.model
+ def _get_report_values(self, docids, data=None):
if not data:
data = {}
if "company_id" not in data:
diff --git a/partner_statement/report/report_statement_common.py b/partner_statement/report/report_statement_common.py
index 09ebb586..e4ac4819 100644
--- a/partner_statement/report/report_statement_common.py
+++ b/partner_statement/report/report_statement_common.py
@@ -1,5 +1,4 @@
-# Copyright 2018 Eficent Business and IT Consulting Services S.L.
-# (http://www.eficent.com)
+# Copyright 2018 ForgeFlow, S.L. (https://www.forgeflow.com)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
from datetime import datetime, timedelta
@@ -53,7 +52,6 @@ class ReportStatementCommon(models.AbstractModel):
ELSE l.date_maturity
END as date_maturity
FROM account_move_line l
- JOIN account_account_type at ON (at.id = l.user_type_id)
JOIN account_move m ON (l.move_id = m.id)
LEFT JOIN (SELECT pr.*
FROM account_partial_reconcile pr
@@ -67,7 +65,8 @@ class ReportStatementCommon(models.AbstractModel):
ON pr.debit_move_id = l2.id
WHERE l2.date <= %(date_end)s
) as pc ON pc.credit_move_id = l.id
- WHERE l.partner_id IN %(partners)s AND at.type = %(account_type)s
+ WHERE l.partner_id IN %(partners)s
+ AND l.account_internal_type = %(account_type)s
AND (
(pd.id IS NOT NULL AND
pd.max_date <= %(date_end)s) OR
@@ -289,8 +288,8 @@ class ReportStatementCommon(models.AbstractModel):
currencies,
)
- @api.multi
- def _get_report_values(self, docids, data):
+ @api.model # noqa: C901
+ def _get_report_values(self, docids, data=None):
"""
@return: returns a dict of parameters to pass to qweb report.
the most important pair is {'data': res} which contains all
diff --git a/partner_statement/static/description/index.html b/partner_statement/static/description/index.html
index 42d1ce46..352a3e7a 100644
--- a/partner_statement/static/description/index.html
+++ b/partner_statement/static/description/index.html
@@ -367,7 +367,7 @@ ul.auto-toc {
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
-

+

This module extends the functionality of Invoicing to support the printing of customer and vendor statements.
There are two types of statements, Activity and Outstanding. Aging details can be shown in the reports, expressed in aging buckets,
so the customer or vendor can review how much is open, due or overdue.
@@ -386,7 +386,7 @@ outstanding payments. The list is displayed in chronological order and is split
Usage
Known issues / Roadmap
Changelog
Bug Tracker
@@ -449,7 +449,7 @@ outstanding payments. The list is displayed in chronological order and is split
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 smashing it by providing a detailed and welcomed
-feedback.
+feedback.
Do not contact contributors directly about support or help with technical issues.
@@ -457,13 +457,13 @@ If you spotted it first, help us smashing it by providing a detailed and welcome
@@ -474,7 +474,7 @@ If you spotted it first, help us smashing it by providing a detailed and welcome
OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.
-
This module is part of the OCA/account-financial-reporting project on GitHub.
+
This module is part of the OCA/account-financial-reporting project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
diff --git a/partner_statement/tests/test_activity_statement.py b/partner_statement/tests/test_activity_statement.py
index 4247cbc1..8482835a 100644
--- a/partner_statement/tests/test_activity_statement.py
+++ b/partner_statement/tests/test_activity_statement.py
@@ -1,5 +1,4 @@
-# Copyright 2018 Eficent Business and IT Consulting Services S.L.
-# (http://www.eficent.com)
+# Copyright 2018 ForgeFlow, S.L. (https://www.forgeflow.com)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
from datetime import date
@@ -9,15 +8,16 @@ from odoo.tests.common import TransactionCase
class TestActivityStatement(TransactionCase):
- """
- Tests for Activity Statement.
- """
+ """ Tests for Activity Statement."""
def setUp(self):
super().setUp()
self.res_users_model = self.env["res.users"]
self.company = self.env.ref("base.main_company")
+ self.company.external_report_layout_id = self.env.ref(
+ "web.external_layout_standard"
+ )
self.partner1 = self.env.ref("base.res_partner_1")
self.partner2 = self.env.ref("base.res_partner_2")
self.g_account_user = self.env.ref("account.group_account_user")
@@ -98,7 +98,7 @@ class TestActivityStatement(TransactionCase):
self.assertEqual(res, "30/09/2018")
def test_onchange_aging_type(self):
- """Test that partner data is filled accodingly"""
+ """Test that partner data is filled accordingly"""
wiz_id = self.wiz.with_context(
active_ids=[self.partner1.id, self.partner2.id]
).new()
diff --git a/partner_statement/tests/test_outstanding_statement.py b/partner_statement/tests/test_outstanding_statement.py
index 984595da..d747b228 100644
--- a/partner_statement/tests/test_outstanding_statement.py
+++ b/partner_statement/tests/test_outstanding_statement.py
@@ -1,20 +1,20 @@
-# Copyright 2018 Eficent Business and IT Consulting Services S.L.
-# (http://www.eficent.com)
+# Copyright 2018 ForgeFlow, S.L. (https://www.forgeflow.com)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
from odoo.tests.common import TransactionCase
class TestOutstandingStatement(TransactionCase):
- """
- Tests for Outstanding Statement.
- """
+ """ Tests for Outstanding Statement."""
def setUp(self):
super().setUp()
self.res_users_model = self.env["res.users"]
self.company = self.env.ref("base.main_company")
+ self.company.external_report_layout_id = self.env.ref(
+ "web.external_layout_standard"
+ )
self.partner1 = self.env.ref("base.res_partner_2")
self.partner2 = self.env.ref("base.res_partner_3")
self.g_account_user = self.env.ref("account.group_account_user")
diff --git a/partner_statement/tests/test_res_config_settings.py b/partner_statement/tests/test_res_config_settings.py
index 0724a378..919cccf7 100644
--- a/partner_statement/tests/test_res_config_settings.py
+++ b/partner_statement/tests/test_res_config_settings.py
@@ -14,7 +14,7 @@ class TestResConfigSettings(TransactionCase):
"ORDER BY uid DESC LIMIT 1"
)
self.account_user = self.cr.fetchone()[0]
- self.user_obj = self.env["res.users"].sudo(self.account_user)
+ self.user_obj = self.env["res.users"].with_user(self.account_user)
def test_groups(self):
conf = self.config.create(
diff --git a/partner_statement/views/activity_statement.xml b/partner_statement/views/activity_statement.xml
index 0e293bd3..5118afe6 100644
--- a/partner_statement/views/activity_statement.xml
+++ b/partner_statement/views/activity_statement.xml
@@ -1,5 +1,5 @@
-
diff --git a/partner_statement/views/aging_buckets.xml b/partner_statement/views/aging_buckets.xml
index 732e5c0f..197ed9c3 100644
--- a/partner_statement/views/aging_buckets.xml
+++ b/partner_statement/views/aging_buckets.xml
@@ -1,5 +1,5 @@
-
diff --git a/partner_statement/views/assets.xml b/partner_statement/views/assets.xml
index 17f69456..69a7557b 100644
--- a/partner_statement/views/assets.xml
+++ b/partner_statement/views/assets.xml
@@ -1,5 +1,5 @@
-
-
diff --git a/partner_statement/views/res_config_settings.xml b/partner_statement/views/res_config_settings.xml
index 6c4982d0..5dda8318 100644
--- a/partner_statement/views/res_config_settings.xml
+++ b/partner_statement/views/res_config_settings.xml
@@ -6,7 +6,10 @@
-
+
diff --git a/partner_statement/wizard/activity_statement_wizard.py b/partner_statement/wizard/activity_statement_wizard.py
index 5c7c8fe0..b764472c 100644
--- a/partner_statement/wizard/activity_statement_wizard.py
+++ b/partner_statement/wizard/activity_statement_wizard.py
@@ -1,5 +1,4 @@
-# Copyright 2018 Eficent Business and IT Consulting Services S.L.
-# (http://www.eficent.com)
+# Copyright 2018 ForgeFlow, S.L. (http://www.forgeflow.com)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
from dateutil.relativedelta import relativedelta
@@ -34,8 +33,8 @@ class ActivityStatementWizard(models.TransientModel):
"""Export to PDF."""
data = self._prepare_statement()
return self.env.ref(
- "partner_statement" ".action_print_activity_statement"
- ).report_action(self, data=data)
+ "partner_statement.action_print_activity_statement"
+ ).report_action(self.ids, data=data)
def _prepare_statement(self):
res = super()._prepare_statement()
diff --git a/partner_statement/wizard/outstanding_statement_wizard.py b/partner_statement/wizard/outstanding_statement_wizard.py
index 07498d68..b9b8baef 100644
--- a/partner_statement/wizard/outstanding_statement_wizard.py
+++ b/partner_statement/wizard/outstanding_statement_wizard.py
@@ -1,5 +1,4 @@
-# Copyright 2018 Eficent Business and IT Consulting Services S.L.
-# (http://www.eficent.com)
+# Copyright 2018 ForgeFlow, S.L. (http://www.forgeflow.com)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
from odoo import models
@@ -16,5 +15,5 @@ class OutstandingStatementWizard(models.TransientModel):
"""Export to PDF."""
data = self._prepare_statement()
return self.env.ref(
- "partner_statement" ".action_print_outstanding_statement"
- ).report_action(self, data=data)
+ "partner_statement.action_print_outstanding_statement"
+ ).report_action(self.ids, data=data)
diff --git a/partner_statement/wizard/statement_common.py b/partner_statement/wizard/statement_common.py
index cda4b2cf..2a89f505 100644
--- a/partner_statement/wizard/statement_common.py
+++ b/partner_statement/wizard/statement_common.py
@@ -56,7 +56,6 @@ class StatementCommon(models.AbstractModel):
else:
self.date_end = fields.Date.context_today(self)
- @api.multi
def button_export_pdf(self):
self.ensure_one()
return self._export()
diff --git a/partner_statement/wizard/statement_wizard.xml b/partner_statement/wizard/statement_wizard.xml
index 5af15375..9c3d41c7 100644
--- a/partner_statement/wizard/statement_wizard.xml
+++ b/partner_statement/wizard/statement_wizard.xml
@@ -1,27 +1,23 @@
-