Skip to content

Commit

Permalink
[ADD] mis_builder_analytic: New module
Browse files Browse the repository at this point in the history
  • Loading branch information
ernestotejeda authored and marcelsavegnago committed Jan 11, 2022
1 parent 51cd98e commit b3e750a
Show file tree
Hide file tree
Showing 11 changed files with 685 additions and 0 deletions.
92 changes: 92 additions & 0 deletions mis_builder_analytic/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
====================
MIS Builder Analytic
====================

.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! 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-AGPL--3-blue.png
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fmis--builder-lightgray.png?logo=github
:target: https://github.com/OCA/mis-builder/tree/11.0/mis_builder_analytic
:alt: OCA/mis-builder
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/mis-builder-11-0/mis-builder-11-0-mis_builder_analytic
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/248/11.0
:alt: Try me on Runbot

|badge1| |badge2| |badge3| |badge4| |badge5|

This module allows you to create a MIS report using Analytic entries as data
source

**Table of contents**

.. contents::
:local:

Usage
=====

To use this module, you need to:

#. Go to *Invoicing -> Reporting -> MIS Reporting -> MIS Reports*.
#. Create a new *MIS Report*
#. On *MIS Report* form view enable comparison mode and create a new Period
on *Columns* tab.
#. In this form view select *Actuals (alternative)* option on the field
*Source* and select *MIS Account Analytic Line* on the field
*Move lines source*,
#. Complete the rest of the report fields and click on Preview button.
#. Yow will se the report based on Account Analytic Lines.

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/mis-builder/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/mis-builder/issues/new?body=module:%20mis_builder_analytic%0Aversion:%2011.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
~~~~~~~

* Tecnativa

Contributors
~~~~~~~~~~~~

* `Tecnativa <https://www.tecnativa.com>`_:

* Ernesto Tejeda
* Pedro M. Baeza

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.

This module is part of the `OCA/mis-builder <https://github.com/OCA/mis-builder/tree/11.0/mis_builder_analytic>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
3 changes: 3 additions & 0 deletions mis_builder_analytic/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).

from . import models
20 changes: 20 additions & 0 deletions mis_builder_analytic/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Copyright 2018 Tecnativa - Ernesto Tejeda
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).

{
'name': 'MIS Builder Analytic',
'summary': "Provide account analytic lines for MIS builder reports",
'version': '11.0.1.0.0',
'license': 'AGPL-3',
'author': 'Tecnativa, '
'Odoo Community Association (OCA)',
'website': 'https://github.com/OCA/mis-builder',
'depends': [
'mis_builder',
],
'data': [
'views/mis_account_analytic_line_views.xml',
'security/ir.model.access.csv',
],
'installable': True,
}
3 changes: 3 additions & 0 deletions mis_builder_analytic/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).

from . import mis_account_analytic_line
62 changes: 62 additions & 0 deletions mis_builder_analytic/models/mis_account_analytic_line.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# Copyright 2018 Tecnativa - Ernesto Tejeda
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).

from odoo import api, fields, models, tools


class MisAccountAnalyticLine(models.Model):
_name = "mis.account.analytic.line"
_auto = False
_description = "MIS Account Analytic Line"

date = fields.Date()
analytic_line_id = fields.Many2one(
string="Analytic entry",
comodel_name='account.analytic.line',
)
account_id = fields.Many2one(
string='Account',
comodel_name='account.analytic.account',
)
company_id = fields.Many2one(
string='Company',
comodel_name='res.company',
)
balance = fields.Float(
string='Balance',
)
debit = fields.Float(
string='Debit',
)
credit = fields.Float(
string='Credit',
)
state = fields.Selection(
[('draft', 'Unposted'), ('posted', 'Posted')],
string='Status',
)

@api.model_cr
def init(self):
tools.drop_view_if_exists(self._cr, 'mis_account_analytic_line')
self._cr.execute("""
CREATE OR REPLACE VIEW mis_account_analytic_line AS (
SELECT
aal.id AS id,
aal.id AS analytic_line_id,
aal.date as date,
aal.account_id as account_id,
aal.company_id as company_id,
'posted'::VARCHAR as state,
CASE
WHEN aal.amount >= 0.0 THEN aal.amount
ELSE 0.0
END AS credit,
CASE
WHEN aal.amount < 0 THEN (aal.amount * -1)
ELSE 0.0
END AS debit,
aal.amount as balance
FROM
account_analytic_line aal
)""")
4 changes: 4 additions & 0 deletions mis_builder_analytic/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
* `Tecnativa <https://www.tecnativa.com>`_:

* Ernesto Tejeda
* Pedro M. Baeza
2 changes: 2 additions & 0 deletions mis_builder_analytic/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
This module allows you to create a MIS report using Analytic entries as data
source
11 changes: 11 additions & 0 deletions mis_builder_analytic/readme/USAGE.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
To use this module, you need to:

#. Go to *Invoicing -> Reporting -> MIS Reporting -> MIS Reports*.
#. Create a new *MIS Report*
#. On *MIS Report* form view enable comparison mode and create a new Period
on *Columns* tab.
#. In this form view select *Actuals (alternative)* option on the field
*Source* and select *MIS Account Analytic Line* on the field
*Move lines source*,
#. Complete the rest of the report fields and click on Preview button.
#. Yow will se the report based on Account Analytic Lines.
2 changes: 2 additions & 0 deletions mis_builder_analytic/security/ir.model.access.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_mis_account_analytic_line,access_mis_account_analytic_line,model_mis_account_analytic_line,analytic.group_analytic_accounting,1,0,0,0
Loading

0 comments on commit b3e750a

Please sign in to comment.