Browse Source

[NEW] add mis_builder_analytic_cash_flow

12.0-mis_builder_analytic_cash_flow
Nicolas JEUDY 3 years ago
parent
commit
1bd4f2e549
  1. 102
      mis_builder_analytic_cash_flow/README.rst
  2. 2
      mis_builder_analytic_cash_flow/__init__.py
  3. 21
      mis_builder_analytic_cash_flow/__manifest__.py
  4. 1
      mis_builder_analytic_cash_flow/models/__init__.py
  5. 15
      mis_builder_analytic_cash_flow/models/mis_cash_flow_forecast_line.py
  6. 1
      mis_builder_analytic_cash_flow/readme/CONTRIBUTORS.rst
  7. 5
      mis_builder_analytic_cash_flow/readme/DESCRIPTION.rst
  8. 3
      mis_builder_analytic_cash_flow/readme/ROADMAP.rst
  9. 4
      mis_builder_analytic_cash_flow/readme/USAGE.rst
  10. 1
      mis_builder_analytic_cash_flow/report/__init__.py
  11. 81
      mis_builder_analytic_cash_flow/report/mis_cash_flow.py
  12. 37
      mis_builder_analytic_cash_flow/report/mis_cash_flow_views.xml
  13. 38
      mis_builder_analytic_cash_flow/views/mis_cash_flow_forecast_line_views.xml

102
mis_builder_analytic_cash_flow/README.rst

@ -0,0 +1,102 @@
=====================
MIS Builder Cash Flow
=====================
.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
:alt: Beta
.. |badge2| image:: https://img.shields.io/badge/licence-LGPL--3-blue.png
:target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html
:alt: License: LGPL-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/mis_builder_cash_flow
: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-mis_builder_cash_flow
: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
:alt: Try me on Runbot
|badge1| |badge2| |badge3| |badge4| |badge5|
This module allows you to have a cash flow forecast.
The forecast is based on two types of date:
* Accounting entries: Due date field instead of Date
* Forecast lines: manual lines created that forecast in/out cashflow moves.
**Table of contents**
.. contents::
:local:
Usage
=====
To use this module, you need to:
#. Go to Accounting > Reports > MIS Reporting > MIS Reports and choose "Cash Flow" report
#. You can add forecast lines on Accounting > Reports > MIS Reporting > Cash Flow Forecast Line
Known issues / Roadmap
======================
The mis_builder `roadmap <https://github.com/OCA/mis-builder/issues?q=is%3Aopen+is%3Aissue+label%3Aenhancement>`_
and `known issues <https://github.com/OCA/mis-builder/issues?q=is%3Aopen+is%3Aissue+label%3Abug>`_ can
be found on GitHub.
Bug Tracker
===========
Bugs are tracked on `GitHub Issues <https://github.com/OCA/account-financial-reporting/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 <https://github.com/OCA/account-financial-reporting/issues/new?body=module:%20mis_builder_cash_flow%0Aversion:%2012.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
Do not contact contributors directly about support or help with technical issues.
Credits
=======
Authors
~~~~~~~
* ADHOC SA
Contributors
~~~~~~~~~~~~
* Juan José Scarafía <jjs@adhoc.com.ar>
* Gonzalo Ruzafa <gr@adhoc.com.ar>
* Alberto Martín <alberto.martin@guadaltech.es>
Maintainers
~~~~~~~~~~~
This module is maintained by the OCA.
.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org
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.
.. |maintainer-jjscarafia| image:: https://github.com/jjscarafia.png?size=40px
:target: https://github.com/jjscarafia
:alt: jjscarafia
Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:
|maintainer-jjscarafia|
This module is part of the `OCA/account-financial-reporting <https://github.com/OCA/account-financial-reporting/tree/12.0/mis_builder_cash_flow>`_ project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

2
mis_builder_analytic_cash_flow/__init__.py

@ -0,0 +1,2 @@
from . import models
from . import report

21
mis_builder_analytic_cash_flow/__manifest__.py

@ -0,0 +1,21 @@
# Copyright 2021 Nicolas JEUDY
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
{
'name': 'MIS Builder Analytic Cash Flow',
'version': '12.0.1.0.0',
'license': 'LGPL-3',
'author': 'Nicolas JEUDY, '
'Odoo Community Association (OCA)',
'website': 'https://github.com/OCA/mis-builder',
'depends': [
'mis_builder_cash_flow',
],
'data': [
'report/mis_cash_flow_views.xml',
'views/mis_cash_flow_forecast_line_views.xml',
],
'installable': True,
'maintainers': ['njeudy'],
'development_status': 'Beta',
}

1
mis_builder_analytic_cash_flow/models/__init__.py

@ -0,0 +1 @@
from . import mis_cash_flow_forecast_line

15
mis_builder_analytic_cash_flow/models/mis_cash_flow_forecast_line.py

@ -0,0 +1,15 @@
from odoo import fields, models, api, _
from odoo.exceptions import ValidationError
class MisCashFlowForecastLine(models.Model):
_inherit = 'mis.cash_flow.forecast_line'
analytic_account_id = fields.Many2one(
comodel_name='account.analytic.account',
string='Analytic Account',
required=True,
help='The account of the forecast line is only for informative '
'purpose',
)

1
mis_builder_analytic_cash_flow/readme/CONTRIBUTORS.rst

@ -0,0 +1 @@
* Nicolas JEUDY <https://github.com/njeudy>

5
mis_builder_analytic_cash_flow/readme/DESCRIPTION.rst

@ -0,0 +1,5 @@
This module allows you to have a cash flow forecast with account analytic filter.
The forecast is based on two types of date:
* Accounting entries: Due date field instead of Date
* Forecast lines: manual lines created that forecast in/out cashflow moves.

3
mis_builder_analytic_cash_flow/readme/ROADMAP.rst

@ -0,0 +1,3 @@
The mis_builder `roadmap <https://github.com/OCA/mis-builder/issues?q=is%3Aopen+is%3Aissue+label%3Aenhancement>`_
and `known issues <https://github.com/OCA/mis-builder/issues?q=is%3Aopen+is%3Aissue+label%3Abug>`_ can
be found on GitHub.

4
mis_builder_analytic_cash_flow/readme/USAGE.rst

@ -0,0 +1,4 @@
To use this module, you need to:
#. Go to Accounting > Reports > MIS Reporting > MIS Reports and choose "Cash Flow" report
#. You can add forecast lines on Accounting > Reports > MIS Reporting > Cash Flow Forecast Line

1
mis_builder_analytic_cash_flow/report/__init__.py

@ -0,0 +1 @@
from . import mis_cash_flow

81
mis_builder_analytic_cash_flow/report/mis_cash_flow.py

@ -0,0 +1,81 @@
from odoo import api, fields, models, tools
from psycopg2.extensions import AsIs
class MisCashFlow(models.Model):
_inherit = 'mis.cash_flow'
analytic_account_id = fields.Many2one(
comodel_name='account.analytic.account',
string='Analytic Account',
auto_join=True,
index=True,
readonly=True,
)
@api.model_cr
def init(self):
account_type_receivable = self.env.ref(
'account.data_account_type_receivable')
query = """
SELECT
-- we use negative id to avoid duplicates and we don't use
-- ROW_NUMBER() because the performance was very poor
-aml.id as id,
CAST('move_line' AS varchar) as line_type,
aml.id as move_line_id,
aml.account_id as account_id,
aml.analytic_account_id as analytic_account_id,
aml.debit as debit,
aml.credit as credit,
aml.reconciled as reconciled,
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
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,
fl.account_id as account_id,
fl.analytic_account_id as analytic_account_id,
CASE
WHEN fl.balance > 0
THEN fl.balance
ELSE 0.0
END AS debit,
CASE
WHEN fl.balance < 0
THEN -fl.balance
ELSE 0.0
END AS credit,
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))
)
@api.multi
def action_open_related_line(self):
self.ensure_one()
if self.line_type == 'move_line':
return self.move_line_id.get_formview_action()
else:
return self.env['mis.cash_flow.forecast_line'].browse(
self.id).get_formview_action()

37
mis_builder_analytic_cash_flow/report/mis_cash_flow_views.xml

@ -0,0 +1,37 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record model="ir.ui.view" id="mis_analytic_cash_flow_tree_view">
<field name="name">mis_analytic_cash_flow_tree_view</field>
<field name="model">mis.cash_flow</field>
<field name="inherit_id" ref="mis_builder_cash_flow.mis_cash_flow_tree_view"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='account_id']" position="after">
<field name="analytic_account_id"/>
</xpath>
</field>
</record>
<record model="ir.ui.view" id="mis_analytic_cash_flow_form_view">
<field name="name">mis_analytic_cash_flow_form_view</field>
<field name="model">mis.cash_flow</field>
<field name="inherit_id" ref="mis_builder_cash_flow.mis_cash_flow_form_view"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='account_id']" position="after">
<field name="analytic_account_id"/>
</xpath>
</field>
</record>
<record model="ir.ui.view" id="mis_analytic_cash_flow_search_view">
<field name="name">mis_cash_flow_search_view</field>
<field name="model">mis.cash_flow</field>
<field name="inherit_id" ref="mis_builder_cash_flow.mis_cash_flow_search_view"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='account_id']" position="after">
<field name="analytic_account_id"/>
</xpath>
</field>
</record>
</odoo>

38
mis_builder_analytic_cash_flow/views/mis_cash_flow_forecast_line_views.xml

@ -0,0 +1,38 @@
<?xml version="1.0" encoding="UTF-8"?>
<odoo>
<record model="ir.ui.view" id="mis_analytic_cash_flow_forecast_line_view_form">
<field name="name">mis_analytic_cash_flow_forecast_line_view_form</field>
<field name="model">mis.cash_flow.forecast_line</field>
<field name="inherit_id" ref="mis_builder_cash_flow.mis_cash_flow_forecast_line_view_form"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='account_id']" position="after">
<field name="analytic_account_id" domain="[('company_id', '=', company_id)]"/>
</xpath>
</field>
</record>
<record model="ir.ui.view" id="mis_analytic_cash_flow_forecast_line_view_search">
<field name="name">mis_analytic_cash_flow_forecast_line_view_search</field>
<field name="model">mis.cash_flow.forecast_line</field>
<field name="inherit_id" ref="mis_builder_cash_flow.mis_cash_flow_forecast_line_view_search"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='account_id']" position="after">
<field name="analytic_account_id"/>
</xpath>
</field>
</record>
<record model="ir.ui.view" id="mis_analytic_cash_flow_forecast_line_view_tree">
<field name="name">mis_analitic_cash_flow_forecast_line_view_tree</field>
<field name="model">mis.cash_flow.forecast_line</field>
<field name="inherit_id" ref="mis_builder_cash_flow.mis_cash_flow_forecast_line_view_tree"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='account_id']" position="after">
<field name="analytic_account_id"/>
</xpath>
</field>
</record>
</odoo>
Loading…
Cancel
Save