Commit Graph
31 Commits
Author SHA1 Message Date
Denis Ledoux b4a7996e96 [IMP] base, *: change the API of init hooks to pass env
This is mostly a cleaning/refactoring change.

The current API for init hooks (pre, post, uninstall) is to pass
`cr, registry`.
But the first thing which was done by most
post init and uninstall hooks was to create an env using
the cr passed
e.g.
`env = api.Environment(cr, SUPERUSER_ID, {})`
and the `registry` argument was unused in all these hooks,
completely.

By changing the API of hooks to pass `env` instead
of `cr, registry`, we gain in average two lines in every
hooks:
- the line creating the env `env = api.Environment(cr, SUPERUSER_ID, {})`
- the line importing `api` and `SUPERUSER_ID`

Therefore removing ~250 lines of repeated code lines accross odoo/odoo and
odoo/enterprise.
In addition to these lines removed,
it also ease the API of init hooks for Odoo developers,
who are used to that `env` and not so much how to create an `env`
from a cursor.

Part-of: odoo/odoo#108254
2023-02-01 10:25:01 +01:00
Xavier-Do a99c73dce5 [FIX] hr: fix l10n_mx install
When installing l10n_mx, a error occurs

    Traceback (most recent call last):
    File "/data/build/odoo/odoo/service/server.py", line 1289, in preload_registries
        registry = Registry.new(dbname, update_module=update_module)
    File "<decorator-gen-15>", line 2, in new
    File "/data/build/odoo/odoo/tools/func.py", line 87, in locked
        return func(inst, *args, **kwargs)
    File "/data/build/odoo/odoo/modules/registry.py", line 91, in new
        odoo.modules.load_modules(registry, force_demo, status, update_module)
    File "/data/build/odoo/odoo/modules/loading.py", line 482, in load_modules
        processed_modules += load_marked_modules(cr, graph,
    File "/data/build/odoo/odoo/modules/loading.py", line 371, in load_marked_modules
        loaded, processed = load_module_graph(
    File "/data/build/odoo/odoo/modules/loading.py", line 206, in load_module_graph
        registry.setup_models(cr)
    File "/data/build/odoo/odoo/modules/registry.py", line 289, in setup_models
        model._setup_fields()
    File "/data/build/odoo/odoo/models.py", line 3294, in _setup_fields
        field.setup(self)
    File "/data/build/odoo/odoo/fields.py", line 512, in setup
        self.setup_nonrelated(model)
    File "/data/build/odoo/odoo/fields.py", line 4524, in setup_nonrelated
        m2m = model.pool._m2m
    AttributeError: 'Registry' object has no attribute '_m2m'

Since #99438 hr is sintalled automatically
This means that when doing a -i l10n_mx, hr is installed too

hr will conditionnaly call a button_immediate_install in this case.

What's going on after that: It's a mess

button_immediate_install will create another registry
This registry will be present on some models that will ne used later
by the initial registry creating the missing _m2m case

For the record, here are some of the strange and key element during
the install

    2022-09-21 16:31:27,691 2579263 INFO test_mx odoo.modules.loading: loading 1 modules...
    2022-09-21 16:31:27,691 2579263 INFO test_mx odoo.modules.loading: Loading module base (1/1)
    ...
    2022-09-21 16:31:36,222 2579263 INFO test_mx odoo.modules.loading: Module base loaded in 8.53s, 8902 queries (+8902 other)
    2022-09-21 16:31:36,222 2579263 INFO test_mx odoo.modules.loading: 1 modules loaded in 8.53s, 8902 queries (+8902 extra)
    2022-09-21 16:31:36,240 2579263 INFO test_mx odoo.modules.loading: updating modules list
    2022-09-21 16:31:36,241 2579263 INFO test_mx odoo.addons.base.models.ir_module: ALLOW access to module.update_list on [] to user __system__ #1 via n/a
    2022-09-21 16:31:36,943 2579263 INFO test_mx odoo.addons.base.models.ir_module: ALLOW access to module.button_install on ['Mexico - Accounting'] to user __system__ #1 via n/a
    ...
    2022-09-21 16:31:49,775 2579263 INFO test_mx odoo.modules.loading: Loading module base_install_request (26/78)
    ...
    2022-09-21 16:31:50,043 2579263 INFO test_mx odoo.addons.base.models.ir_module: ALLOW access to module.button_install on ['Project', 'Email Marketing', 'Employees', 'Knowledge', 'Sign', 'Planning', 'Appointments', 'Surveys'] to user __system__ #1 via n/a
    2022-09-21 16:31:50,167 2579263 INFO test_mx odoo.modules.loading: Module base_install_request loaded in 0.39s, 228 queries (+228 other)
    ...
    2022-09-21 16:32:10,816 2579263 INFO test_mx odoo.modules.loading: Loading module l10n_mx (55/78)
    ...
    2022-09-21 16:32:17,618 2579263 INFO test_mx odoo.modules.loading: Module l10n_mx loaded in 6.80s, 4302 queries (+4332 other)
    ...
    2022-09-21 16:32:50,371 2579263 INFO test_mx odoo.modules.loading: Loading module hr (35/112)
    2022-09-21 16:32:57,594 2579263 INFO test_mx odoo.addons.base.models.ir_module: ALLOW access to module.button_immediate_install on ['Employees - Mexico'] to user __system__ #1 via n/a
    2022-09-21 16:32:57,594 2579263 INFO test_mx odoo.addons.base.models.ir_module: User #1 triggered module installation
    2022-09-21 16:32:57,595 2579263 INFO test_mx odoo.addons.base.models.ir_module: ALLOW access to module.button_install on ['Employees - Mexico'] to user __system__ #1 via n/a
    ...
    2022-09-21 16:32:58,558 2579263 ERROR test_mx odoo.modules.registry: Creating Registry <odoo.modules.registry.Registry object at 0x7f02cc0e8130>
    Stack (most recent call last):
    File "/home/xdo/osrc/master/odoo/odoo-bin", line 8, in <module>
        odoo.cli.main()
    File "/home/xdo/osrc/master/odoo/odoo/cli/command.py", line 56, in main
        o.run(args)
    File "/home/xdo/osrc/master/odoo/odoo/cli/server.py", line 179, in run
        main(args)
    File "/home/xdo/osrc/master/odoo/odoo/cli/server.py", line 173, in main
        rc = odoo.service.server.start(preload=preload, stop=stop)
    File "/home/xdo/osrc/master/odoo/odoo/service/server.py", line 1391, in start
        rc = server.run(preload, stop)
    File "/home/xdo/osrc/master/odoo/odoo/service/server.py", line 570, in run
        rc = preload_registries(preload)
    File "/home/xdo/osrc/master/odoo/odoo/service/server.py", line 1289, in preload_registries
        registry = Registry.new(dbname, update_module=update_module)
    File "<decorator-gen-15>", line 2, in new
    File "/home/xdo/osrc/master/odoo/odoo/tools/func.py", line 87, in locked
        return func(inst, *args, **kwargs)
    File "/home/xdo/osrc/master/odoo/odoo/modules/registry.py", line 91, in new
        odoo.modules.load_modules(registry, force_demo, status, update_module)
    File "/home/xdo/osrc/master/odoo/odoo/modules/loading.py", line 482, in load_modules
        processed_modules += load_marked_modules(cr, graph,
    File "/home/xdo/osrc/master/odoo/odoo/modules/loading.py", line 371, in load_marked_modules
        loaded, processed = load_module_graph(
    File "/home/xdo/osrc/master/odoo/odoo/modules/loading.py", line 248, in load_module_graph
        getattr(py_module, post_init)(cr, registry)
    File "/home/xdo/osrc/master/odoo/addons/hr/__init__.py", line 19, in _install_hr_localization
        l10n_mx.button_immediate_install()
    File "<decorator-gen-74>", line 2, in button_immediate_install
    File "/home/xdo/osrc/master/odoo/odoo/addons/base/models/ir_module.py", line 75, in check_and_log
        return method(self, *args, **kwargs)
    File "/home/xdo/osrc/master/odoo/odoo/addons/base/models/ir_module.py", line 486, in button_immediate_install
        return self._button_immediate_function(type(self).button_install)
    File "/home/xdo/osrc/master/odoo/odoo/addons/base/models/ir_module.py", line 607, in _button_immediate_function
        registry = modules.registry.Registry.new(self._cr.dbname, update_module=True)
    File "<decorator-gen-15>", line 2, in new
    File "/home/xdo/osrc/master/odoo/odoo/tools/func.py", line 87, in locked
        return func(inst, *args, **kwargs)
    File "/home/xdo/osrc/master/odoo/odoo/modules/registry.py", line 79, in new
        registry.init(db_name)
    File "/home/xdo/osrc/master/odoo/odoo/modules/registry.py", line 115, in init
        _logger.error(self, stack_info=True)
    2022-09-21 16:32:58,580 2579263 INFO test_mx odoo.modules.loading: loading 1 modules...
    2022-09-21 16:32:58,581 2579263 INFO test_mx odoo.modules.loading: Loading module base (1/1)
    ...
    2022-09-21 16:33:35,294 2579263 INFO test_mx odoo.modules.loading: Loading module base_install_request (30/85)
    ...
    2022-09-21 16:33:35,745 2579263 INFO test_mx odoo.modules.loading: Module base_install_request loaded in 0.45s, 131 queries (+131 other)
    ...
    2022-09-21 16:34:05,789 2579263 INFO test_mx odoo.modules.loading: Loading module l10n_mx (62/85)
    ...
    2022-09-21 16:34:28,497 2579263 INFO test_mx odoo.modules.loading: Loading module hr (35/113)
    ...
    2022-09-21 16:34:32,067 2579263 INFO test_mx odoo.modules.loading: Module hr loaded in 3.57s, 4092 queries (+4092 other)
    2022-09-21 16:34:32,067 2579263 INFO test_mx odoo.modules.loading: Loading module link_tracker (37/113)
    ...
    2022-09-21 16:34:32,690 2579263 INFO test_mx odoo.modules.loading: Module link_tracker loaded in 0.62s, 267 queries (+267 other)
    ...
    2022-09-21 16:35:04,063 2579263 INFO test_mx odoo.modules.loading: Modules loaded.
    2022-09-21 16:35:04,068 2579263 INFO test_mx odoo.modules.registry: Registry loaded in 125.514s
    2022-09-21 16:35:04,068 2579263 INFO test_mx odoo.addons.base.models.ir_module: getting next ir.actions.todo()
    2022-09-21 16:35:04,071 2579263 INFO test_mx odoo.addons.base.models.ir_module: next action is "Open Menu"
    2022-09-21 16:35:04,094 2579263 INFO test_mx odoo.modules.loading: Module hr loaded in 133.72s, 4344 queries (+81420 other)
    ...
    2022-09-21 16:35:04,094 2579263 INFO test_mx odoo.modules.loading: Loading module link_tracker (37/112)
    2022-09-21 16:35:04,163 2579263 ERROR test_mx odoo.modules.registry:
    setuping model: ir.model.fields()
    registry on model: <odoo.modules.registry.Registry object at 0x7f02cc0e8130>
    registry calling setup_models: <odoo.modules.registry.Registry object at 0x7f02e92399d0>

    2022-09-21 16:35:04,164 2579263 WARNING test_mx odoo.modules.loading: Transient module states were reset
    2022-09-21 16:35:04,165 2579263 ERROR test_mx odoo.modules.registry: Failed to load registry
    2022-09-21 16:35:04,165 2579263 CRITICAL test_mx odoo.service.server: Failed to initialize database `test_mx`.
    Traceback (most recent call last):
    File "/home/xdo/osrc/master/odoo/odoo/service/server.py", line 1289, in preload_registries
        registry = Registry.new(dbname, update_module=update_module)
    File "<decorator-gen-15>", line 2, in new
    File "/home/xdo/osrc/master/odoo/odoo/tools/func.py", line 87, in locked
        return func(inst, *args, **kwargs)
    File "/home/xdo/osrc/master/odoo/odoo/modules/registry.py", line 91, in new
        odoo.modules.load_modules(registry, force_demo, status, update_module)
    File "/home/xdo/osrc/master/odoo/odoo/modules/loading.py", line 482, in load_modules
        processed_modules += load_marked_modules(cr, graph,
    File "/home/xdo/osrc/master/odoo/odoo/modules/loading.py", line 371, in load_marked_modules
        loaded, processed = load_module_graph(
    File "/home/xdo/osrc/master/odoo/odoo/modules/loading.py", line 206, in load_module_graph
        registry.setup_models(cr)
    File "/home/xdo/osrc/master/odoo/odoo/modules/registry.py", line 293, in setup_models
        model._setup_fields()
    File "/home/xdo/osrc/master/odoo/odoo/models.py", line 3294, in _setup_fields
        field.setup(self)
    File "/home/xdo/osrc/master/odoo/odoo/fields.py", line 512, in setup
        self.setup_nonrelated(model)
    File "/home/xdo/osrc/master/odoo/odoo/fields.py", line 4524, in setup_nonrelated
        m2m = model.pool._m2m
    AttributeError: 'Registry' object has no attribute '_m2m'

Naive fix here: use button_install instead of button_immediate_install
(not even sure this is 100% correct)

All calls to button_immediate_install should be fixed maybe to avoid
a registryloadingception

closes odoo/odoo#100909

X-original-commit: 919c1f362b1c26dbd04b0501c4d63e2929fb8df4
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
Signed-off-by: Xavier Dollé (xdo) <xdo@odoo.com>
2022-09-23 07:21:33 +02:00
Yannick Tivisse c3036694b3 [FIX] hr: Fix localized hr module installation
closes odoo/odoo#95547

Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
2022-07-07 17:31:10 +02:00
Kevin Baptiste 7bde79a367 [IMP] hr: add populate script
Add a populate script to automatically create lots of
employees/jobs/tags/work locations/departments.

closes odoo/odoo#82259

Taskid: 2728608
Signed-off-by: Kevin Baptiste <kba@odoo.com>
2022-01-05 16:21:55 +00:00
RomainLibert d5fd84b89a [IMP] hr: add onboarding/offboarding activity plannings
Purpose
=======

Give the possibility to elaborate plans through Odoo. For instance, in HR,
you could create an onboarding plan when a employee is created. Someone manages
laptop and other equipment, someone check hr stuff, ... This feature is generic
but in a first time we will apply it only on the hr module.

Ease HR process in a company by creating plans: a plan is an assembly of Next
Activities that will be launched together whenever you need it.

Example of plan for an employee onboarding:

Activity: Prepare materials
Responsible: Alain
Deadline: At the contract signature

Activity: Manage Cars
Responsible: Cécile
Deadline: at the contract signature (both signature)

Activity: Plan Training
Responsible: Caroline
Deadline: After signature

Activity: Training
Responsible: Employee
Deadline: 1 week after the employement date

Specifications
==============

On HR Configuration: Add a menu "Activity Plans"

Activity plan object:
 - Name
 - Model (debug mode) (hr by default)
 - Activity Template o2m
    - Activity Type (only the one related to hr)
    - Deadline (come from Activity Type)
    - Responsible \/
        0  Coach
        0  Manager
        0  Other
        [Responsible_name] \/  (coach, manager or manually set if other)

Add datas, 2 plans:

Onboarding
    - Name: Onboarding
    - Plan lines:
        Activity: Setup IT Materials
        Responsible: [a user] (manager)
        Deadline: At the contract signature

        Activity: Plan Training
        Responsible: [manager]
        Deadline: After signature

        Activity: Training
        Responsible: [Employee]
        Deadline: 1 week after the employement date

Offboarding
    - Name: Onboarding
    - Plan lines:
        Activity: Compute Out Delais
        Responsible: [a user] (manager)
        Deadline: today

        Activity: Take Back HR Materials
        Responsible: [manager]
        Deadline: today

        Activity: Manage Car
        Responsible: [manager]
        Deadline: today

When to trigger it ?

HR specific use case:

1/ On employee, from the employee chatter:
when you create an employee, Odoobot will log a note with the following message:
"Congratulations ! May i recommand you to setup an onboarding plan?", with a link
create a plan from it.

2/ Add a button 'launch plan' to open a wizard to select the plan

3/ When archive an employee
Open a wizard with:
    - Reason (selection)
    - Action plan (m2o not required)

Error if employee not linked to a user.

Task : 1912681

closes odoo/odoo#29151
2018-12-18 11:20:54 +00:00
xmo-odoo b4429c2a91 [FIX] Various P3-related import changes
* LDAP import: python-ldap is not python3-compatible, pyldap is

  Warning: only supported from debian Stretch (current testing)?
  https://packages.debian.org/search?searchon=names&keywords=pyldap

* implicitly relative imports
* imports of moved or removed stdlib modules

issue #8530
2017-04-28 09:06:53 +02:00
Ravi Gohil c30fd5cac7 [MOV] hr: reorganise module directory 2016-04-13 12:28:34 +02:00
Aaron Bohy db8203c27a [FIX] base,hr,mail: prefetch mention suggestions
The purpose of this commit is to improve the overall performance of the mention
mechanism of the client action and chatter composer, by pre-fetching some data.

First, the employees are fetched at chat initialization (basically, at web
client initialization), if hr is installed.

Second, when focusing on the composer of a channel, the members of this channel
are fetched. In the case of a chatter, the members are already known as they
are the followers of the document.

When the user types a mention, we first display suggestions from the pre-fetched
partners, and we only perform an RPC when there are no more result matching the
search string. This RPC searches among user, and then partners if there aren't
enough matches.

A few side changes occurred:
  - auto_join set to True on user_ids field of res.partner to boost the query
    that searches partners that are users
  - the '/mail/read_followers' route now returns follower's email as well, as
    we need it for the mention;
  - a partner can now be mentionned several times in the same message;
  - mentionned partner previsualization has been removed, mainly because of
    the previous point, but also because it simplifies the code;
2015-11-27 11:47:34 +01:00
Antony Lesuisse 37053a407c [REM] hr: unused and deprecated res.config 2015-08-26 17:49:07 +02:00
Olivier Dony 0bd4545348 [LEGAL] Use global LICENSE/COPYRIGHT files, remove boilerplate text
- Preserved explicit 3rd-party copyright notices
- Explicit boilerplate should not be necessary - copyright law applies
  automatically in all countries thanks to Berne Convention + WTO rules,
  and a reference to the applicable license is clear enough.
2015-06-02 03:16:04 +02:00
Leonardo Donelli 4a0b13ed92 [REF] remove vim modelines and resulting trailing blank lines
Let 2015 be a year without modelines!
cf #4174
2014-12-31 15:52:13 +01:00
Antony Lesuisse da020d326d [IMP] hr.department cleanup
- Consolidate multiple hr.departement definition into hr.py file
- Remove ulgy department_users_get() domain hack on act_window
- Add the jobs_ids inverse relationship from departement to jobs

bzr revid: al@openerp.com-20140129002913-5qgq10jy9u3xn74e
2014-01-29 01:29:13 +01:00
Thibault Delavallée 4f7a2419fe [CLEAN] hr: check_related_document now located in hr_employee instead of a mail_message override.
bzr revid: tde@openerp.com-20130612095507-1ksx759e8hkk323h
2013-06-12 11:55:07 +02:00
Martin Trigaux 52ddce88f3 [ADD] option to globally stop showing employeep suggestions
bzr revid: mat@openerp.com-20130403152443-3jqg0v182mcqsk0f
2013-04-03 17:24:43 +02:00
Martin Trigaux ccf6cf921e [ADD] overwrite check permission method to poston an employee profile
bzr revid: mat@openerp.com-20130327165126-dtoejma9h71m2zpx
2013-03-27 17:51:26 +01:00
Vo Minh Thu e7f4891d46 [IMP] use the openerp namespace.
bzr revid: vmt@openerp.com-20121206145632-0h1coh5aaem65wsy
2012-12-06 15:56:32 +01:00
Jagdish Panchal (Open ERP) 37465c6ea5 [IMP] HR: add the configuration wizard(new added file >> hr/res_config.py, hr/res_config_view.xml,hr_recruitment/res_config.py, hr_recruitment/res_config_view.xml, hr_timesheet_sheet/res_config.py, hr_timesheet_sheet/res_config_view.xml)
bzr revid: jap@tinyerp.com-20120402054418-596gzjhyne7o6148
2012-04-02 11:14:18 +05:30
Stephane Wirtel 57911141bc [IMP] Move all installers into base_setup
bzr revid: stw@openerp.com-20110926164323-ob28bw1zgfmaih9c
2011-09-26 18:43:23 +02:00
Mustufa Rangwala cf1debb7eb [IMP] hr: Unnecessary dependacy removed only highest level on __openerp__, Clean code
bzr revid: mra@mra-laptop-20100813052818-cbdg55q81bf2m91o
2010-08-13 10:58:18 +05:30
Vir (Open ERP) e6b2e4694e [ADD] hr : new object added as crm.job, changes and modification related to new object
bzr revid: vir@tinyerp.com-20100218101312-8a632c996z8ij7yu
2010-02-18 15:43:12 +05:30
Christophe Simonis 3dfcd6465b [MERGE]
bzr revid: chs@tinyerp.com-20100113140328-71w2yvlwbfn8oj34
2010-01-13 15:03:28 +01:00
Stephane Wirtel fb3ef7a2f4 [FIX] Change the year of the copyright
bzr revid: stephane@openerp.com-20100112091839-a6p7tenhb4e4zxyx
2010-01-12 10:18:39 +01:00
Xavier Morel 24b29730f2 [add] hr: modules installer
bzr revid: xmo@tinyerp.com-20100106142533-1gdvrblv32eqj06a
2010-01-06 15:25:33 +01:00
PSO(OpenERP) eb0b928cc0 Changed licencing terms
bzr revid: hda@tinyerp.com-20091014111534-1vtk21rz8byhszzf
2009-10-14 16:45:34 +05:30
ChristopheChauvet(syleam) 41e8ed59ef changed encoding to coding in all py files
lp bug: https://launchpad.net/bugs/357182 fixed

bzr revid: hda@tinyerp.com-20091013055837-3ntnbe8b938xmk97
2009-10-13 11:28:37 +05:30
Stephane Wirtel 21f104a506 [IMP] Update the copyright to 2009
bzr revid: stephane@tinyerp.com-20090104221250-55q32ayj2t8kzb2k
2009-01-04 23:12:50 +01:00
Christophe Simonis f5fad0ba30 passing modules in GPL-3
bzr revid: christophe@tinyerp.com-20081103191856-jhcivvwb16fvz2os
2008-11-03 20:18:56 +01:00
Christophe Simonis 3e3d897e88 add encoding comment and vim comment
bzr revid: christophe@tinyerp.com-20080723144147-77o5t9adx26a84lt
2008-07-23 16:41:47 +02:00
stw 0feb782c6a add Copyright and GPL license into the Header of Python files
bzr revid: stw-d9a6d631f7cfdab5a120a6b0104ce2dbf8644841
2008-06-16 11:00:21 +00:00
Fabien Pinckaers e3bf7892b5 Project
Get taks of projects and childs when clicking on a project
HR
	Add department structure
HR_Timesheet
	Timesheets of my department menu

bzr revid: fp@tinyerp.com-f75e046f17c24b31b7e141428c108630e907440d
2007-06-19 17:01:25 +00:00
pinky a83dce15e0 New trunk
bzr revid: pinky-dedd7f8a42bd4557112a0513082691b8590ad6cc
2006-12-07 13:41:40 +00:00