Browse Source

[MIG] mis_builder_cash_flow: Migration to 13.0

pull/676/head
mreficent 5 years ago
parent
commit
cd93363ef8
  1. 4
      mis_builder_cash_flow/__manifest__.py
  2. 8
      mis_builder_cash_flow/data/mis_report.xml
  3. 2
      mis_builder_cash_flow/i18n/mis_builder_cash_flow.pot
  4. 5
      mis_builder_cash_flow/models/mis_cash_flow_forecast_line.py
  5. 26
      mis_builder_cash_flow/report/mis_cash_flow.py
  6. 14
      mis_builder_cash_flow/tests/test_cash_flow.py
  7. 1
      oca_dependencies.txt

4
mis_builder_cash_flow/__manifest__.py

@ -3,11 +3,11 @@
{
"name": "MIS Builder Cash Flow",
"version": "12.0.1.3.0",
"version": "13.0.1.0.0",
"license": "LGPL-3",
"author": "ADHOC SA, " "Odoo Community Association (OCA)",
"website": "https://github.com/OCA/mis-builder",
"depends": ["mis_builder",],
"depends": ["mis_builder"],
"data": [
"security/mis_cash_flow_security.xml",
"report/mis_cash_flow_views.xml",

8
mis_builder_cash_flow/data/mis_report.xml

@ -16,7 +16,7 @@
<field name="sequence">20</field>
<field
name="expression"
>bal[][('account_id.internal_type', '=', 'liquidity'), ('line_type', '=', 'move_line'), ('account_id.hide_in_cash_flow', '=', False)]</field>
>bal[][('account_internal_type', '=', 'liquidity'), ('line_type', '=', 'move_line'), ('account_id.hide_in_cash_flow', '=', False)]</field>
</record>
<record id="mis_kpi_in_total" model="mis.report.kpi">
<field name="report_id" ref="mis_report_cash_flow" />
@ -36,7 +36,7 @@
<field name="sequence">50</field>
<field
name="expression"
>bal[][('account_id.internal_type', '=', 'receivable'), ('full_reconcile_id', '=', False), ('line_type', '=', 'move_line'), ('account_id.hide_in_cash_flow', '=', False)]</field>
>bal[][('account_internal_type', '=', 'receivable'), ('full_reconcile_id', '=', False), ('line_type', '=', 'move_line'), ('account_id.hide_in_cash_flow', '=', False)]</field>
</record>
<record id="mis_kpi_in_forecast" model="mis.report.kpi">
<field name="report_id" ref="mis_report_cash_flow" />
@ -68,7 +68,7 @@
<field name="sequence">100</field>
<field
name="expression"
>bal[][('account_id.internal_type', '=', 'payable'), ('full_reconcile_id', '=', False), ('line_type', '=', 'move_line'), ('account_id.hide_in_cash_flow', '=', False)]</field>
>bal[][('account_internal_type', '=', 'payable'), ('full_reconcile_id', '=', False), ('line_type', '=', 'move_line'), ('account_id.hide_in_cash_flow', '=', False)]</field>
</record>
<record id="mis_kpi_out_forecast" model="mis.report.kpi">
<field name="report_id" ref="mis_report_cash_flow" />
@ -101,7 +101,7 @@
<field name="sequence">150</field>
<field
name="expression"
>bale[][('account_id.hide_in_cash_flow', '=', False), '|', ('line_type', '=', 'forecast_line'), ('line_type', '=', 'move_line'), '|', ('account_id.internal_type', '=', 'liquidity'), ('account_id.internal_type', 'in', ('receivable', 'payable')), ('full_reconcile_id', '=', False)]</field>
>bale[][('account_id.hide_in_cash_flow', '=', False), '|', ('line_type', '=', 'forecast_line'), ('line_type', '=', 'move_line'), '|', ('account_internal_type', '=', 'liquidity'), ('account_internal_type', 'in', ('receivable', 'payable')), ('full_reconcile_id', '=', False)]</field>
<field
name="style_expression"
>'Cash Flow - Good' if balance >= 0.0 else 'Cash Flow - Bad'</field>

2
mis_builder_cash_flow/i18n/mis_builder_cash_flow.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"

5
mis_builder_cash_flow/models/mis_cash_flow_forecast_line.py

@ -14,7 +14,7 @@ class MisCashFlowForecastLine(models.Model):
comodel_name="account.account",
string="Account",
required=True,
help="The account of the forecast line is only for informative " "purpose",
help="The account of the forecast line is only for informative purpose",
)
partner_id = fields.Many2one(comodel_name="res.partner", string="Partner",)
name = fields.Char(required=True, default="/",)
@ -27,10 +27,9 @@ class MisCashFlowForecastLine(models.Model):
index=True,
)
@api.multi
@api.constrains("company_id", "account_id")
def _check_company_id_account_id(self):
if self.filtered(lambda x: x.company_id != x.account_id.company_id):
raise ValidationError(
_("The Company and the Company of the Account must be the " "same.")
_("The Company and the Company of the Account must be the same.")
)

26
mis_builder_cash_flow/report/mis_cash_flow.py

@ -2,7 +2,7 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from psycopg2.extensions import AsIs
from odoo import api, fields, models, tools
from odoo import fields, models, tools
class MisCashFlow(models.Model):
@ -47,15 +47,12 @@ class MisCashFlow(models.Model):
full_reconcile_id = fields.Many2one(
"account.full.reconcile", string="Matching Number", readonly=True, index=True,
)
user_type_id = fields.Many2one(
"account.account.type", auto_join=True, readonly=True, index=True,
account_internal_type = fields.Selection(
related="account_id.user_type_id.type", readonly=True
)
@api.model_cr
def init(self):
account_type_receivable = self.env.ref("account.data_account_type_receivable")
query = (
"""
query = """
SELECT
-- we use negative id to avoid duplicates and we don't use
-- ROW_NUMBER() because the performance was very poor
@ -77,15 +74,14 @@ class MisCashFlow(models.Model):
aml.full_reconcile_id as full_reconcile_id,
aml.partner_id as partner_id,
aml.company_id as company_id,
aml.user_type_id as user_type_id,
aml.name as name,
aml.date_maturity as date
COALESCE(aml.date_maturity, aml.date) as date
FROM account_move_line as aml
UNION ALL
SELECT
fl.id as id,
CAST('forecast_line' AS varchar) as line_type,
Null as move_line_id,
NULL as move_line_id,
fl.account_id as account_id,
CASE
WHEN fl.balance > 0
@ -97,23 +93,19 @@ class MisCashFlow(models.Model):
THEN -fl.balance
ELSE 0.0
END AS credit,
Null as reconciled,
Null as full_reconcile_id,
NULL as reconciled,
NULL as full_reconcile_id,
fl.partner_id as partner_id,
fl.company_id as company_id,
%i as user_type_id,
fl.name as name,
fl.date as date
FROM mis_cash_flow_forecast_line as fl
"""
% account_type_receivable.id
)
tools.drop_view_if_exists(self.env.cr, self._table)
self._cr.execute(
"CREATE OR REPLACE VIEW %s AS %s", (AsIs(self._table), AsIs(query))
"CREATE OR REPLACE VIEW %s AS (%s)", (AsIs(self._table), AsIs(query))
)
@api.multi
def action_open_related_line(self):
self.ensure_one()
if self.line_type == "move_line":

14
mis_builder_cash_flow/tests/test_cash_flow.py

@ -5,12 +5,11 @@ from datetime import timedelta
from odoo.exceptions import ValidationError
from odoo.fields import Date
from odoo.tests.common import TransactionCase, at_install, post_install
from odoo.tests.common import TransactionCase, tagged
from odoo.tools import mute_logger
@at_install(False)
@post_install(True)
@tagged("post_install", "-at_install")
class TestCashFlow(TransactionCase):
def setUp(self):
super().setUp()
@ -61,7 +60,7 @@ class TestCashFlow(TransactionCase):
def test_company_constrain(self):
with self.assertRaises(ValidationError):
self.env["mis.cash_flow.forecast_line"].create(
{"account_id": self.account.id, "date": Date.today(), "balance": 1000,}
{"account_id": self.account.id, "date": Date.today(), "balance": 1000}
)
def test_report_instance(self):
@ -71,6 +70,7 @@ class TestCashFlow(TransactionCase):
"name": "Move",
"journal_id": self.journal.id,
"company_id": self.company.id,
"type": "entry",
"line_ids": [
(
0,
@ -114,11 +114,11 @@ class TestCashFlow(TransactionCase):
],
ignore_rows=["balance", "period_balance", "in_total"],
)
date = Date.from_string(Date.today()) + timedelta(weeks=8)
date = Date.today() + timedelta(weeks=8)
self.env["mis.cash_flow.forecast_line"].create(
{
"account_id": self.account.id,
"date": Date.to_string(date),
"date": date,
"balance": 1000,
"company_id": self.company.id,
}
@ -133,7 +133,7 @@ class TestCashFlow(TransactionCase):
ignore_rows=["balance", "period_balance", "in_total"],
)
def check_matrix(self, args=False, ignore_rows=False):
def check_matrix(self, args=None, ignore_rows=None):
if not args:
args = []
if not ignore_rows:

1
oca_dependencies.txt

@ -1,2 +1,3 @@
mis-builder
server-ux
reporting-engine
Loading…
Cancel
Save