Skip to content

Commit

Permalink
Merge fa8ab9f into 7c2db88
Browse files Browse the repository at this point in the history
  • Loading branch information
MiquelRForgeFlow committed Jan 16, 2020
2 parents 7c2db88 + fa8ab9f commit e81888a
Show file tree
Hide file tree
Showing 13 changed files with 651 additions and 0 deletions.
80 changes: 80 additions & 0 deletions mis_builder_operating_unit/README.rst
@@ -0,0 +1,80 @@
===============================
MIS Builder with Operating Unit
===============================

.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! 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%2Foperating--unit-lightgray.png?logo=github
:target: https://github.com/OCA/operating-unit/tree/12.0/mis_builder_operating_unit
:alt: OCA/operating-unit
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/operating-unit-12-0/operating-unit-12-0-mis_builder_operating_unit
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/213/12.0
:alt: Try me on Runbot

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

Introduces the operating unit to MIS Builder report instances.

**Table of contents**

.. contents::
:local:

Usage
=====

Set the operating unit in a MIS Builder instance.

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

Bugs are tracked on `GitHub Issues <https://github.com/OCA/operating-unit/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/operating-unit/issues/new?body=module:%20mis_builder_operating_unit%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
~~~~~~~

* Eficent Business and IT Consulting Services S.L.
* Serpent Consulting Services Pvt. Ltd.
* ACSONE SA/NV

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

* Stéphane Bidoul <stephane.bidoul@acsone.eu>

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/operating-unit <https://github.com/OCA/operating-unit/tree/12.0/mis_builder_operating_unit>`_ 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_operating_unit/__init__.py
@@ -0,0 +1,3 @@
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).

from . import model
22 changes: 22 additions & 0 deletions mis_builder_operating_unit/__manifest__.py
@@ -0,0 +1,22 @@
# © 2015-19 Eficent Business and IT Consulting Services S.L. -
# Jordi Ballester Alomar
# © 2015-19 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).

{
'name': 'MIS Builder with Operating Unit',
'version': '12.0.1.0.0',
'category': 'Reporting',
"author": "Eficent Business and IT Consulting Services S.L., "
"Serpent Consulting Services Pvt. Ltd.,"
"ACSONE SA/NV,"
"Odoo Community Association (OCA)",
"license": "LGPL-3",
'website': 'https://github.com/operating-unit',
'depends': ['mis_builder', 'account_operating_unit'],
'data': [
'security/mis_builder_security.xml',
'view/mis_builder.xml'
],
'installable': True,
}
3 changes: 3 additions & 0 deletions mis_builder_operating_unit/model/__init__.py
@@ -0,0 +1,3 @@
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).

from . import mis_builder
49 changes: 49 additions & 0 deletions mis_builder_operating_unit/model/mis_builder.py
@@ -0,0 +1,49 @@
# Copyright 2015-19 Eficent Business and IT Consulting Services S.L. -
# Jordi Ballester Alomar
# Copyright 2015-19 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya
# Copyright 2018-19 ACSONE SA/NV
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).

from odoo import api, fields, models


class MisReportInstance(models.Model):

_inherit = 'mis.report.instance'

operating_unit_ids = fields.Many2many(
'operating.unit',
string='Operating Unit',
)


class MisReportInstancePeriod(models.Model):

_inherit = 'mis.report.instance.period'

operating_unit_ids = fields.Many2many(
'operating.unit',
string='Operating Unit',
)

@api.multi
def _get_additional_move_line_filter(self):
aml_domain = super(MisReportInstancePeriod, self).\
_get_additional_move_line_filter()
# we need sudo because, imagine a user having access
# to operating unit A, viewing a report with 3 columns
# for OU A, B, C: in columns B and C, self.operating_unit_ids
# would be empty for him, and the query on a.m.l would be only
# restricted by the record rules (ie showing move lines
# for OU A only). So the report would display values
# for OU A in all 3 columns.
sudoself = self.sudo()
if sudoself.report_instance_id.operating_unit_ids:
aml_domain.append(
('operating_unit_id', 'in',
sudoself.report_instance_id.operating_unit_ids.ids))
if sudoself.operating_unit_ids:
aml_domain.append(
('operating_unit_id', 'in',
sudoself.operating_unit_ids.ids))
return aml_domain
1 change: 1 addition & 0 deletions mis_builder_operating_unit/readme/CONTRIBUTORS.rst
@@ -0,0 +1 @@
* Stéphane Bidoul <stephane.bidoul@acsone.eu>
1 change: 1 addition & 0 deletions mis_builder_operating_unit/readme/DESCRIPTION.rst
@@ -0,0 +1 @@
Introduces the operating unit to MIS Builder report instances.
1 change: 1 addition & 0 deletions mis_builder_operating_unit/readme/USAGE.rst
@@ -0,0 +1 @@
Set the operating unit in a MIS Builder instance.
19 changes: 19 additions & 0 deletions mis_builder_operating_unit/security/mis_builder_security.xml
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<!--Copyright 2015-19 Eficent Business and IT Consulting Services S.L. - -->
<!--Jordi Ballester Alomar-->
<!--Copyright 2015-19 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya-->
<!--Copyright 2018-19 ACSONE SA/NV-->
<record id="ir_rule_mis_builder_allowed_operating_units"
model="ir.rule">
<field name="model_id" ref="mis_builder.model_mis_report_instance"/>
<field name="domain_force">['|',('operating_unit_ids','=',False),('operating_unit_ids','in',[g.id for g in user.operating_unit_ids])]</field>
<field name="name">MIS Reports from allowed operating units</field>
<field name="global" eval="True"/>
<field eval="1" name="perm_unlink"/>
<field eval="1" name="perm_write"/>
<field eval="1" name="perm_read"/>
<field eval="1" name="perm_create"/>
</record>

</odoo>
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit e81888a

Please sign in to comment.