Skip to content

Commit 5ba08cc

Browse files
committed
[IMP] res_partner_operating_unit: pre-commit auto fixes
1 parent d0f5ff6 commit 5ba08cc

File tree

16 files changed

+148
-120
lines changed

16 files changed

+148
-120
lines changed

res_partner_operating_unit/README.rst

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -17,22 +17,24 @@ Partner with Operating Unit
1717
:target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html
1818
:alt: License: LGPL-3
1919
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Foperating--unit-lightgray.png?logo=github
20-
:target: https://github.com/OCA/operating-unit/tree/12.0/res_partner_operating_unit
20+
:target: https://github.com/OCA/operating-unit/tree/18.0/res_partner_operating_unit
2121
:alt: OCA/operating-unit
2222
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
23-
:target: https://translation.odoo-community.org/projects/operating-unit-12-0/operating-unit-12-0-res_partner_operating_unit
23+
:target: https://translation.odoo-community.org/projects/operating-unit-18-0/operating-unit-18-0-res_partner_operating_unit
2424
:alt: Translate me on Weblate
2525
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
26-
:target: https://runboat.odoo-community.org/builds?repo=OCA/operating-unit&target_branch=12.0
26+
:target: https://runboat.odoo-community.org/builds?repo=OCA/operating-unit&target_branch=18.0
2727
:alt: Try me on Runboat
2828

2929
|badge1| |badge2| |badge3| |badge4| |badge5|
3030

3131
This module introduces the following features:
3232

33-
* Adds the Operating Unit (OU) to res partner.
34-
* The user’s default Operating Unit (OU) is proposed at the time of creating Partner.
35-
* Security rules are defined to ensure that users can only see Partner of that Operating Units in which they are allowed access to.
33+
- Adds the Operating Unit (OU) to res partner.
34+
- The user’s default Operating Unit (OU) is proposed at the time of
35+
creating Partner.
36+
- Security rules are defined to ensure that users can only see Partner
37+
of that Operating Units in which they are allowed access to.
3638

3739
**Table of contents**
3840

@@ -42,45 +44,45 @@ This module introduces the following features:
4244
Usage
4345
=====
4446

45-
* Go to customer
46-
* You only see the customer of your operating units
47-
* Create an customer. It is assigned to your default operating unit.
47+
- Go to customer
48+
- You only see the customer of your operating units
49+
- Create an customer. It is assigned to your default operating unit.
4850

4951
Bug Tracker
5052
===========
5153

5254
Bugs are tracked on `GitHub Issues <https://github.com/OCA/operating-unit/issues>`_.
5355
In case of trouble, please check there if your issue has already been reported.
5456
If you spotted it first, help us to smash it by providing a detailed and welcomed
55-
`feedback <https://github.com/OCA/operating-unit/issues/new?body=module:%20res_partner_operating_unit%0Aversion:%2012.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
57+
`feedback <https://github.com/OCA/operating-unit/issues/new?body=module:%20res_partner_operating_unit%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
5658

5759
Do not contact contributors directly about support or help with technical issues.
5860

5961
Credits
6062
=======
6163

6264
Authors
63-
~~~~~~~
65+
-------
6466

6567
* Edi Santoso
6668
* Niaga Solution
6769

6870
Contributors
69-
~~~~~~~~~~~~
71+
------------
7072

71-
* Edi Santoso <repodevs@gmail.com>
72-
* Maxime Chambreuil <mchambreuil@opensourceintegrators.com>
73-
* Hiren Dangar <hiren.dangar.serpentcs@gmail.com>
73+
- Edi Santoso <repodevs@gmail.com>
74+
- Maxime Chambreuil <mchambreuil@opensourceintegrators.com>
75+
- Hiren Dangar <hiren.dangar.serpentcs@gmail.com>
7476

7577
Other credits
76-
~~~~~~~~~~~~~
78+
-------------
7779

78-
* Niaga Solution
79-
* Open Source Integrators
80-
* Serpent Consulting Services Pvt. Ltd. <support@serpentcs.com>
80+
- Niaga Solution
81+
- Open Source Integrators
82+
- Serpent Consulting Services Pvt. Ltd. <support@serpentcs.com>
8183

8284
Maintainers
83-
~~~~~~~~~~~
85+
-----------
8486

8587
This module is maintained by the OCA.
8688

@@ -92,6 +94,6 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose
9294
mission is to support the collaborative development of Odoo features and
9395
promote its widespread use.
9496

95-
This module is part of the `OCA/operating-unit <https://github.com/OCA/operating-unit/tree/12.0/res_partner_operating_unit>`_ project on GitHub.
97+
This module is part of the `OCA/operating-unit <https://github.com/OCA/operating-unit/tree/18.0/res_partner_operating_unit>`_ project on GitHub.
9698

9799
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

res_partner_operating_unit/__manifest__.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,13 @@
44
"name": "Partner with Operating Unit",
55
"summary": "Introduces Operating Unit fields in Partner",
66
"version": "12.0.1.1.1",
7-
"author": "Edi Santoso, "
8-
"Niaga Solution, "
9-
"Odoo Community Association (OCA)",
7+
"author": "Edi Santoso, " "Niaga Solution, " "Odoo Community Association (OCA)",
108
"website": "https://github.com/OCA/operating-unit",
119
"category": "Generic",
1210
"depends": ["operating_unit"],
1311
"license": "LGPL-3",
1412
"data": [
1513
"views/res_partner_view.xml",
1614
],
17-
'installable': True,
15+
"installable": True,
1816
}

res_partner_operating_unit/models/res_partner.py

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@
55

66

77
class ResPartner(models.Model):
8-
_inherit = 'res.partner'
8+
_inherit = "res.partner"
99

1010
@api.model
1111
def operating_unit_default_get(self, uid2=False):
1212
if not uid2:
1313
uid2 = self._uid
14-
user = self.env['res.users'].browse(uid2)
14+
user = self.env["res.users"].browse(uid2)
1515
return user.default_operating_unit_id
1616

1717
@api.model
@@ -23,28 +23,36 @@ def _default_operating_units(self):
2323
return self._default_operating_unit()
2424

2525
operating_unit_ids = fields.Many2many(
26-
'operating.unit', 'operating_unit_partner_rel',
27-
'partner_id', 'operating_unit_id',
28-
'Operating Units',
29-
default=lambda self: self._default_operating_units())
26+
"operating.unit",
27+
"operating_unit_partner_rel",
28+
"partner_id",
29+
"operating_unit_id",
30+
"Operating Units",
31+
default=lambda self: self._default_operating_units(),
32+
)
3033

3134
# Extending methods to replace a record rule.
3235
# Ref: https://github.com/OCA/operating-unit/issues/258
3336
@api.model
3437
def search(self, args, offset=0, limit=None, order=None, count=False):
3538
# Get the OUs of the user
3639
ou_ids = self.env.user.operating_unit_ids.ids
37-
domain = ['|',
38-
('operating_unit_ids', 'in', ou_ids),
39-
('operating_unit_ids', '=', False)]
40-
return super().search(domain + args, offset=offset, limit=limit,
41-
order=order, count=count)
40+
domain = [
41+
"|",
42+
("operating_unit_ids", "in", ou_ids),
43+
("operating_unit_ids", "=", False),
44+
]
45+
return super().search(
46+
domain + args, offset=offset, limit=limit, order=order, count=count
47+
)
4248

4349
@api.model
4450
def search_count(self, args):
4551
# Get the OUs of the user
4652
ou_ids = self.env.user.operating_unit_ids.ids
47-
domain = ['|',
48-
('operating_unit_ids', 'in', ou_ids),
49-
('operating_unit_ids', '=', False)]
53+
domain = [
54+
"|",
55+
("operating_unit_ids", "in", ou_ids),
56+
("operating_unit_ids", "=", False),
57+
]
5058
return super().search_count(domain + args)

res_partner_operating_unit/models/res_users.py

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,35 +2,39 @@
22
# Copyright (C) 2019 Serpent Consulting Services
33
# Copyright (C) 2019 Open Source Integrators
44
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
5-
from odoo import api, models, _
5+
from odoo import _, api, models
66
from odoo.exceptions import UserError
77

88

99
class ResUsers(models.Model):
10-
_inherit = 'res.users'
10+
_inherit = "res.users"
1111

1212
@api.model
1313
def create(self, vals):
1414
res = super().create(vals)
15-
res.partner_id.operating_unit_ids = \
16-
[(4, res.default_operating_unit_id.id)]
15+
res.partner_id.operating_unit_ids = [(4, res.default_operating_unit_id.id)]
1716
return res
1817

1918
@api.multi
2019
def write(self, vals):
2120
res = super().write(vals)
22-
if vals.get('default_operating_unit_id'):
21+
if vals.get("default_operating_unit_id"):
2322
# Add the new OU
24-
self.partner_id.operating_unit_ids = \
25-
[(4, vals['default_operating_unit_id'])]
23+
self.partner_id.operating_unit_ids = [
24+
(4, vals["default_operating_unit_id"])
25+
]
2626
return res
2727

28-
@api.constrains('partner_id.operating_unit_ids',
29-
'default_operating_unit_id')
28+
@api.constrains("partner_id.operating_unit_ids", "default_operating_unit_id")
3029
def check_partner_operating_unit(self):
31-
if self.partner_id.operating_unit_ids and \
32-
self.default_operating_unit_id.id not in \
33-
self.partner_id.operating_unit_ids.ids:
34-
raise UserError(_(
35-
"The operating units of the partner must include the default "
36-
"one of the user."))
30+
if (
31+
self.partner_id.operating_unit_ids
32+
and self.default_operating_unit_id.id
33+
not in self.partner_id.operating_unit_ids.ids
34+
):
35+
raise UserError(
36+
_(
37+
"The operating units of the partner must include the default "
38+
"one of the user."
39+
)
40+
)
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[build-system]
2+
requires = ["whool"]
3+
build-backend = "whool.buildapi"
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
- Edi Santoso \<repodevs@gmail.com\>
2+
- Maxime Chambreuil \<mchambreuil@opensourceintegrators.com\>
3+
- Hiren Dangar \<hiren.dangar.serpentcs@gmail.com\>

res_partner_operating_unit/readme/CONTRIBUTORS.rst

Lines changed: 0 additions & 3 deletions
This file was deleted.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
- Niaga Solution
2+
- Open Source Integrators
3+
- Serpent Consulting Services Pvt. Ltd. \<support@serpentcs.com\>

res_partner_operating_unit/readme/CREDITS.rst

Lines changed: 0 additions & 3 deletions
This file was deleted.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
This module introduces the following features:
2+
3+
- Adds the Operating Unit (OU) to res partner.
4+
- The user’s default Operating Unit (OU) is proposed at the time of
5+
creating Partner.
6+
- Security rules are defined to ensure that users can only see Partner
7+
of that Operating Units in which they are allowed access to.

0 commit comments

Comments
 (0)