Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
391 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
language: python | ||
sudo: false | ||
cache: pip | ||
|
||
python: | ||
- "2.7" | ||
|
||
addons: | ||
apt: | ||
packages: | ||
- expect-dev # provides unbuffer utility | ||
- python-lxml # because pip installation is slow | ||
|
||
env: | ||
global: | ||
- VERSION="8.0" LINT_CHECK="0" TESTS="0" TRANSIFEX="0" | ||
|
||
matrix: | ||
- LINT_CHECK="1" | ||
- TRANSIFEX="0" | ||
- TESTS="1" ODOO_REPO="odoo/odoo" | ||
- TESTS="1" ODOO_REPO="OCA/OCB" | ||
|
||
virtualenv: | ||
system_site_packages: true | ||
|
||
install: | ||
- git clone --depth=1 https://github.com/OCA/maintainer-quality-tools.git ${HOME}/maintainer-quality-tools | ||
- export PATH=${HOME}/maintainer-quality-tools/travis:${PATH} | ||
- travis_install_nightly | ||
|
||
script: | ||
- travis_run_tests | ||
|
||
after_success: | ||
- travis_after_tests_success |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
.. image:: https://img.shields.io/badge/license-AGPLv3-blue.svg | ||
:target: https://www.gnu.org/licenses/agpl.html | ||
:alt: License: AGPL-3 | ||
|
||
============== | ||
Operating Unit | ||
============== | ||
|
||
An operating unit (OU) is an organizational entity part of a company, with | ||
separate management ownership. Management by OU is aimed to introduce the | ||
following features: | ||
|
||
* Data partitioning from other OU. | ||
* Own sequencing schemes. | ||
* User access administration for data processing and reporting. | ||
* Product and customer independence of OU. | ||
* OU specific P&L and Balance sheet. | ||
|
||
Installation | ||
============ | ||
|
||
No external library is used. | ||
|
||
Configuration | ||
============= | ||
|
||
To configure this module, you need to: | ||
|
||
* Assign *Multi Operating Unit* group to user. | ||
* Go to *Settings / Companies / Operating Units* and create Operating Units. | ||
|
||
Usage | ||
===== | ||
|
||
This module defines the operating unit entity and the user's security rules. | ||
Other modules extend the standard Odoo apps with the OU. | ||
|
||
.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas | ||
:alt: Try me on Runbot | ||
:target: https://runbot.odoo-community.org/runbot/213/8.0 | ||
|
||
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/ | ||
213/issues/new?body=module:%20 | ||
operating_unit%0Aversion:%20 | ||
8.0%0A%0A**Steps%20to%20reproduce**%0A-%20.. | ||
.%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_. | ||
|
||
Credits | ||
======= | ||
|
||
Images | ||
------ | ||
|
||
* Odoo Community Association: `Icon <https://github.com/OCA/maintainer-tools/blob/master/template/module/static/description/icon.svg>`_. | ||
|
||
Contributors | ||
------------ | ||
|
||
* Eficent Business and IT Consulting Services S.L. <contact@eficent.com> | ||
* Xpansa Group <hello@xpansa.com> | ||
* Serpent Consulting Services Pvt. Ltd. <support@serpentcs.com> | ||
|
||
|
||
|
||
Maintainer | ||
---------- | ||
|
||
.. image:: https://odoo-community.org/logo.png | ||
:alt: Odoo Community Association | ||
:target: https://odoo-community.org | ||
|
||
This module is maintained by the OCA. | ||
|
||
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. | ||
|
||
To contribute to this module, please visit https://odoo-community.org. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# -*- coding: utf-8 -*- | ||
# © 2015 Eficent Business and IT Consulting Services S.L. | ||
# - Jordi Ballester Alomar | ||
# © 2015 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). | ||
from . import models |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# -*- coding: utf-8 -*- | ||
# © 2015 Eficent Business and IT Consulting Services S.L. | ||
# - Jordi Ballester Alomar | ||
# © 2015 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). | ||
|
||
{ | ||
"name": "Operating Unit", | ||
"summary": "An operating unit (OU) is an organizational entity part of a " | ||
"company", | ||
"version": "8.0.1.0.0", | ||
"author": "Eficent Business and IT Consulting Services S.L., " | ||
"Serpent Consulting Services Pvt. Ltd.," | ||
"Odoo Community Association (OCA)", | ||
"website": "http://www.eficent.com", | ||
"category": "Accounting and finance", | ||
"depends": ["base"], | ||
"license": "AGPL-3", | ||
"data": [ | ||
"security/operating_unit_security.xml", | ||
"security/ir.model.access.csv", | ||
"view/operating_unit_view.xml", | ||
"view/res_users_view.xml", | ||
"data/operating_unit_data.xml", | ||
], | ||
'demo': [ | ||
"demo/operating_unit_demo.xml" | ||
], | ||
'installable': True, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<openerp> | ||
<data noupdate="1"> | ||
|
||
<!-- Basic Operating Unit --> | ||
<record id="main_operating_unit" model="operating.unit"> | ||
<field name="name">Main Operating Unit</field> | ||
<field name="code">OU1</field> | ||
<field name="partner_id" ref="base.main_partner"/> | ||
</record> | ||
|
||
<record model="res.users" id="base.user_root"> | ||
<field name="default_operating_unit_id" ref="main_operating_unit"/> | ||
<field name="operating_unit_ids" | ||
eval="[(4, ref('main_operating_unit'))]"/> | ||
<field name="groups_id" | ||
eval="[(4,ref('operating_unit.group_multi_operating_unit'))]"/> | ||
</record> | ||
|
||
</data> | ||
</openerp> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<openerp> | ||
<data noupdate="0"> | ||
|
||
<record id="b2b_operating_unit" model="operating.unit"> | ||
<field name="name">B2B</field> | ||
<field name="code">B2B</field> | ||
<field name="partner_id" ref="base.main_partner"/> | ||
</record> | ||
|
||
<record id="b2c_operating_unit" model="operating.unit"> | ||
<field name="name">B2C</field> | ||
<field name="code">B2C</field> | ||
<field name="partner_id" ref="base.main_partner"/> | ||
</record> | ||
|
||
<record model="res.users" id="base.user_demo"> | ||
<field name="default_operating_unit_id" | ||
ref="main_operating_unit"/> | ||
<field name="operating_unit_ids" | ||
eval="[(4, ref('main_operating_unit')),(4, ref('b2b_operating_unit')),(4, ref('b2b_operating_unit')),(4, ref('b2c_operating_unit'))]"/> | ||
<field name="groups_id" | ||
eval="[(4,ref('operating_unit.group_multi_operating_unit'))]"/> | ||
</record> | ||
|
||
</data> | ||
</openerp> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# -*- coding: utf-8 -*- | ||
# © 2015 Eficent Business and IT Consulting Services S.L. | ||
# - Jordi Ballester Alomar | ||
# © 2015 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). | ||
from . import operating_unit | ||
from . import res_users |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# -*- coding: utf-8 -*- | ||
# © 2015 Eficent Business and IT Consulting Services S.L. | ||
# - Jordi Ballester Alomar | ||
# © 2015 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). | ||
from openerp import api, fields, models | ||
|
||
|
||
class OperatingUnit(models.Model): | ||
|
||
_name = 'operating.unit' | ||
_description = 'Operating Unit' | ||
|
||
name = fields.Char(required=True) | ||
code = fields.Char(required=True) | ||
active = fields.Boolean(default=True) | ||
company_id = fields.Many2one( | ||
'res.company', 'Company', required=True, default=lambda self: | ||
self.env['res.company']._company_default_get('account.account')) | ||
partner_id = fields.Many2one('res.partner', 'Partner', required=True) | ||
|
||
_sql_constraints = [ | ||
('code_company_uniq', 'unique (code,company_id)', | ||
'The code of the operating unit must ' | ||
'be unique per company!'), | ||
('name_company_uniq', 'unique (name,company_id)', | ||
'The name of the operating unit must ' | ||
'be unique per company!') | ||
] | ||
|
||
@api.model | ||
def name_search(self, name, args=None, operator='ilike', limit=100): | ||
# Make a search with default criteria | ||
names1 = super(models.Model, self).name_search( | ||
name=name, args=args, operator=operator, limit=limit) | ||
# Make the other search | ||
names2 = [] | ||
if name: | ||
domain = [('code', '=ilike', name + '%')] | ||
names2 = self.search(domain, limit=limit).name_get() | ||
# Merge both results | ||
return list(set(names1) | set(names2))[:limit] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# -*- coding: utf-8 -*- | ||
# © 2015 Eficent Business and IT Consulting Services S.L. | ||
# - Jordi Ballester Alomar | ||
# © 2015 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). | ||
from openerp import api, fields, models | ||
|
||
|
||
class ResUsers(models.Model): | ||
|
||
_inherit = 'res.users' | ||
|
||
@api.model | ||
def operating_unit_default_get(self, uid2): | ||
if not uid2: | ||
uid2 = self._uid | ||
user = self.env['res.users'].browse(uid2) | ||
return user.default_operating_unit_id | ||
|
||
@api.model | ||
def _get_operating_unit(self): | ||
return self.operating_unit_default_get(self._uid) | ||
|
||
@api.model | ||
def _get_operating_units(self): | ||
return self._get_operating_unit() | ||
|
||
operating_unit_ids = fields.Many2many('operating.unit', | ||
'operating_unit_users_rel', | ||
'user_id', 'poid', 'Operating Units', | ||
default=_get_operating_units) | ||
default_operating_unit_id = fields.Many2one('operating.unit', | ||
'Default Operating Unit', | ||
default=_get_operating_unit) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink | ||
access_account_operating_unit_erp_manager,operating.unit erp.manager,model_operating_unit,base.group_erp_manager,1,1,1,1 | ||
access_account_operating_unit_user,operating_unit user,model_operating_unit,,1,0,0,0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<openerp> | ||
<data noupdate="1"> | ||
|
||
<record id="group_multi_operating_unit" model="res.groups"> | ||
<field name="name">Multi Operating Unit</field> | ||
<field name="category_id" ref="base.module_category_usability"/> | ||
</record> | ||
|
||
<record id="operating_unit_comp_rule" model="ir.rule"> | ||
<field name="name">Operating Unit Entry</field> | ||
<field name="model_id" ref="model_operating_unit"/> | ||
<field name="global" eval="True"/> | ||
<field name="domain_force">['|',('company_id','=',False),('company_id','child_of',[user.company_id.id])]</field> | ||
</record> | ||
|
||
</data> | ||
</openerp> |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<openerp> | ||
<data> | ||
|
||
<record id="view_operating_unit_form" model="ir.ui.view"> | ||
<field name="name">operating.unit.form</field> | ||
<field name="model">operating.unit</field> | ||
<field name="arch" type="xml"> | ||
<form string="Operating Unit" version="7.0"> | ||
<group> | ||
<field name="name"/> | ||
<field name="code"/> | ||
<field name="active"/> | ||
<field name="partner_id"/> | ||
<field name="company_id" groups="base.group_multi_company"/> | ||
</group> | ||
</form> | ||
</field> | ||
</record> | ||
|
||
<record id="view_operating_unit_tree" model="ir.ui.view"> | ||
<field name="name">operating.unit.tree</field> | ||
<field name="model">operating.unit</field> | ||
<field name="arch" type="xml"> | ||
<tree string="Operating Unit"> | ||
<field name="code"/> | ||
<field name="name"/> | ||
<field name="company_id" groups="base.group_multi_company"/> | ||
</tree> | ||
</field> | ||
</record> | ||
<record id="view_operating_unit_search" model="ir.ui.view"> | ||
<field name="name">operating.unit.search</field> | ||
<field name="model">operating.unit</field> | ||
<field name="arch" type="xml"> | ||
<search string="Search Operating Unit"> | ||
<field name="name" string="Operating Unit"/> | ||
<field name="code" string="Code"/> | ||
</search> | ||
</field> | ||
</record> | ||
|
||
<record id="action_operating_unit_tree" model="ir.actions.act_window"> | ||
<field name="name">Operating Units</field> | ||
<field name="res_model">operating.unit</field> | ||
<field name="view_type">form</field> | ||
<field name="view_mode">tree,form</field> | ||
<field name="help" type="html"> | ||
<p class="oe_view_nocontent_create"> | ||
Click to start a new Operating Unit. | ||
</p> | ||
</field> | ||
</record> | ||
|
||
<menuitem action="action_operating_unit_tree" | ||
id="menu_action_operating_unit_tree" | ||
parent="base.menu_res_company_global" | ||
groups="operating_unit.group_multi_operating_unit"/> | ||
</data> | ||
</openerp> |
Oops, something went wrong.