Skip to content

Commit 56eab1f

Browse files
committed
[IMP] mis_builder_cash_flow: Multi company
1 parent 03f6063 commit 56eab1f

File tree

5 files changed

+51
-0
lines changed

5 files changed

+51
-0
lines changed

mis_builder_cash_flow/README.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,9 @@ Contributors
8585
* `Tecnativa <https://www.tecnativa.com>`_:
8686

8787
* Pedro M. Baeza
88+
* `PyTech <https://www.pytech.it>`_:
89+
90+
* Simone Rubino <simone.rubino@pytech.it>
8891

8992
Maintainers
9093
~~~~~~~~~~~

mis_builder_cash_flow/readme/CONTRIBUTORS.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,6 @@
44
* `Tecnativa <https://www.tecnativa.com>`_:
55

66
* Pedro M. Baeza
7+
* `PyTech <https://www.pytech.it>`_:
8+
9+
* Simone Rubino <simone.rubino@pytech.it>

mis_builder_cash_flow/security/mis_cash_flow_security.xml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,17 @@
2020
<field name="perm_write" eval="1" />
2121
<field name="perm_unlink" eval="1" />
2222
</record>
23+
<data noupdate="1">
24+
<record id="mis_cash_flow_forecast_line_company_rule" model="ir.rule">
25+
<field name="name">MIS Cash Flow Forecast Line multi company rule</field>
26+
<field name="model_id" ref="model_mis_cash_flow_forecast_line" />
27+
<field name="domain_force">
28+
[
29+
'|',
30+
('company_id', '=', False),
31+
('company_id', 'in', company_ids),
32+
]
33+
</field>
34+
</record>
35+
</data>
2336
</odoo>

mis_builder_cash_flow/static/description/index.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -434,6 +434,10 @@ <h2><a class="toc-backref" href="#toc-entry-6">Contributors</a></h2>
434434
<li>Pedro M. Baeza</li>
435435
</ul>
436436
</li>
437+
<li><a class="reference external" href="https://www.pytech.it">PyTech</a>:<ul>
438+
<li>Simone Rubino &lt;<a class="reference external" href="mailto:simone.rubino&#64;pytech.it">simone.rubino&#64;pytech.it</a>&gt;</li>
439+
</ul>
440+
</li>
437441
</ul>
438442
</div>
439443
<div class="section" id="maintainers">

mis_builder_cash_flow/tests/test_cash_flow.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
from odoo.tests.common import TransactionCase, tagged
99
from odoo.tools import mute_logger
1010

11+
from odoo.addons.mail.tests.common import mail_new_test_user
12+
1113

1214
@tagged("post_install", "-at_install")
1315
class TestCashFlow(TransactionCase):
@@ -155,3 +157,29 @@ def check_matrix(self, args=None, ignore_rows=None):
155157
break
156158
if not found:
157159
self.assertEqual(cell.val, 0)
160+
161+
def test_multi_company(self):
162+
"""Forecast lines can only be accessed within their company."""
163+
# Arrange
164+
company = self.company
165+
company_line = self.env["mis.cash_flow.forecast_line"].create(
166+
{
167+
"account_id": self.account.id,
168+
"date": Date.to_date("2020-01-01"),
169+
"balance": 1000,
170+
"company_id": company.id,
171+
}
172+
)
173+
other_company_user = mail_new_test_user(
174+
self.env,
175+
login="test user from another company",
176+
)
177+
# pre-condition
178+
self.assertNotEqual(company, other_company_user.company_id)
179+
180+
# Assert
181+
self.assertFalse(
182+
self.env["mis.cash_flow.forecast_line"]
183+
.with_user(other_company_user)
184+
.search([("id", "=", company_line.id)])
185+
)

0 commit comments

Comments
 (0)