forked from OCA/hr
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[add] hr_employee_address_improved (OCA#357)
- Loading branch information
1 parent
59f0e2e
commit 5d84fe4
Showing
6 changed files
with
151 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,84 @@ | ||
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg | ||
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html | ||
:alt: License: AGPL-3 | ||
|
||
============================ | ||
HR Employee Address Improved | ||
============================ | ||
|
||
When the HR modules are enabled and we have 1 employee for each users, | ||
some parts of the UI become confusing because | ||
we have several partners for the same person: | ||
|
||
1. res.user inherits from res.partner, | ||
and fields such as the email are stored in there | ||
|
||
2. hr.employee has address_id and address_home_id. | ||
The first one refers to the work address | ||
(presumably the partner related to the company of the address | ||
of an office of the company, so not a problem) | ||
but the other one is the home address | ||
and if used it will probably be linked to a partner | ||
with the same name as the employee. | ||
|
||
Assumption: we would like to exclude home addresses | ||
from the list of available partners in m2o and m2m fields. | ||
|
||
.. note:: | ||
|
||
when this module is installed a post init hook | ||
**will set all partners related via `address_home_id` as inactive**. | ||
|
||
Installation | ||
============ | ||
|
||
To install this module, you need to: | ||
|
||
* clone the branch 10.0 of the repository https://github.com/OCA/hr | ||
* add the path to this repository in your configuration (addons-path) | ||
* update the module list | ||
* search for "HR Employee Address Improved" in your addons | ||
* install the module | ||
|
||
Configuration | ||
============= | ||
|
||
No extra configuration needed. | ||
|
||
|
||
Bug Tracker | ||
=========== | ||
|
||
Bugs are tracked on `GitHub Issues | ||
<https://github.com/OCA/hr/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. | ||
|
||
Credits | ||
======= | ||
|
||
Images | ||
------ | ||
|
||
* Odoo Community Association: `Icon <https://github.com/OCA/maintainer-tools/blob/master/template/module/static/description/icon.svg>`_. | ||
|
||
Contributors | ||
------------ | ||
|
||
* Simone Orsi <simone.orsi@camptocamp.com> | ||
* Alexandre Fayolle <alexandre.fayolle@camptocamp.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 @@ | ||
from .hooks import post_init_hook |
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 @@ | ||
# -*- coding: utf-8 -*- | ||
# Author: Simone Orsi | ||
# Copyright 2017 Camptocamp SA | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
{ | ||
'name': 'HR Employee Address Improved', | ||
'version': '10.0.1.0.0', | ||
'category': 'Human Resources', | ||
'author': 'Camptocamp,Odoo Community Association (OCA)', | ||
'license': 'AGPL-3', | ||
'depends': ['hr'], | ||
'website': 'http://www.camptocamp.com', | ||
'data': [ | ||
'views/hr.xml', | ||
], | ||
'installable': True, | ||
'post_init_hook': 'post_init_hook', | ||
} |
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,23 @@ | ||
# -*- coding: utf-8 -*- | ||
# Author: Simone Orsi | ||
# Copyright 2017 Camptocamp SA | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
|
||
from odoo import SUPERUSER_ID, api | ||
import logging | ||
|
||
logger = logging.getLogger('[hr_employee_address_improved.post_init_hook]') | ||
|
||
|
||
def post_init_hook(cr, pool): | ||
env = api.Environment(cr, SUPERUSER_ID, {}) | ||
partners_count = env['res.partner'].search_count([]) | ||
empls = env['hr.employee'].with_context( | ||
active_test=False).search([('address_home_id', '!=', False)]) | ||
empls.mapped('address_home_id').with_context( | ||
tracking_disable=True).write({'active': False}) | ||
logger.info( | ||
'Set all partners assigned to `employee.address_home_id` ' | ||
'as not active. Partners matching: %d out of %d', | ||
len(empls), partners_count | ||
) |
Loading
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,25 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<odoo> | ||
<record id="view_employee_form" model="ir.ui.view"> | ||
<field name="name">hr_employee_address_improved hr.employee.form </field> | ||
<field name="model">hr.employee</field> | ||
<field name="inherit_id" ref="hr.view_employee_form"/> | ||
<field name="arch" type="xml"> | ||
<field name="bank_account_id" position="attributes"> | ||
<attribute name="domain">['|', ('active', '=', True), ('active', '=', False)]</attribute> | ||
<attribute name="context">{ | ||
'default_supplier': True, | ||
'default_customer': False, | ||
'default_active': False, | ||
'default_partner_id': address_home_id}</attribute> | ||
</field> | ||
<field name="address_home_id" position="attributes"> | ||
<attribute name="context">{ | ||
'show_address': True, | ||
'default_supplier': True, | ||
'default_customer': False, | ||
'default_active': False}</attribute> | ||
</field> | ||
</field> | ||
</record> | ||
</odoo> |