Merge lp:~fabien-morin/unifield-server/fm-us-2940 into lp:unifield-server

Proposed by jftempo
Status: Merged
Merged at revision: 4436
Proposed branch: lp:~fabien-morin/unifield-server/fm-us-2940
Merge into: lp:unifield-server
Diff against target: 81 lines (+55/-0)
3 files modified
bin/addons/msf_audittrail/__openerp__.py (+1/-0)
bin/addons/msf_audittrail/audittrail.py (+8/-0)
bin/addons/msf_audittrail/data/audittrail_hr_employee.yml (+46/-0)
To merge this branch: bzr merge lp:~fabien-morin/unifield-server/fm-us-2940
Reviewer Review Type Date Requested Status
UniField Reviewer Team Pending
Review via email: mp+327704@code.launchpad.net
To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'bin/addons/msf_audittrail/__openerp__.py'
2--- bin/addons/msf_audittrail/__openerp__.py 2017-01-19 08:43:05 +0000
3+++ bin/addons/msf_audittrail/__openerp__.py 2017-07-19 11:47:49 +0000
4@@ -47,6 +47,7 @@
5 'data/audittrail_data_products.yml',
6 'data/audittrail_data_JI.yml',
7 'data/audittrail_res_users.yml',
8+ 'data/audittrail_hr_employee.yml',
9 'audittrail_report.xml',
10 'audittrail_invoice_data.yml',
11 ],
12
13=== modified file 'bin/addons/msf_audittrail/audittrail.py'
14--- bin/addons/msf_audittrail/audittrail.py 2017-03-02 09:07:25 +0000
15+++ bin/addons/msf_audittrail/audittrail.py 2017-07-19 11:47:49 +0000
16@@ -331,6 +331,14 @@
17 account_move_line()
18
19
20+class hr_employee(osv.osv):
21+ _name = 'hr.employee'
22+ _inherit = 'hr.employee'
23+ _trace = True
24+
25+hr_employee()
26+
27+
28 class ir_module(osv.osv):
29 _inherit = 'ir.module.module'
30
31
32=== added file 'bin/addons/msf_audittrail/data/audittrail_hr_employee.yml'
33--- bin/addons/msf_audittrail/data/audittrail_hr_employee.yml 1970-01-01 00:00:00 +0000
34+++ bin/addons/msf_audittrail/data/audittrail_hr_employee.yml 2017-07-19 11:47:49 +0000
35@@ -0,0 +1,46 @@
36+-
37+ For EMPLOYEE, rule for the CREATE of objects with the list of fields to track
38+-
39+ !python {model: audittrail.rule}: |
40+ name = 'EMPLOYEE CREATE WRITE'
41+ object_ids = self.pool.get('ir.model').search(cr, uid, [('model', '=', 'hr.employee')], context=context)
42+ rule_id = self.search(cr, uid, [('name', '=', name)], context=context)
43+ if object_ids:
44+ fields = ['active', 'birthday', 'code', 'cost_center_id', 'country_id', 'destination_id', 'employee_type', 'free1_id', 'free2_id', 'funding_pool_id', 'gender', 'homere_codeterrain', 'homere_id_staff', 'homere_id_unique', 'identification_id', 'job_id', 'marital', 'mobile_phone', 'name', 'name_resource', 'notes', 'passport_id', 'private_phone', 'resource_type', 'sinid', 'ssnid', 'work_email', 'work_location', 'work_phone']
45+ fields_ids = self.pool.get('ir.model.fields').search(cr, uid, [('model', 'in' , ('hr.employee', 'resource.resource')), ('name', 'in', fields)], context=context)
46+ vals = {'name': name,
47+ 'object_id': object_ids[0],
48+ 'log_create': True,
49+ 'log_write': True,
50+ 'log_unlink': False,
51+ 'field_ids': [(6, 0, fields_ids)],
52+ }
53+ if not rule_id:
54+ rule_id = self.create(cr, uid, vals, context=context)
55+ elif rule_id:
56+ self.write(cr, uid, rule_id, vals, context=context)
57+ # Subscribe to the rule
58+ self.subscribe(cr, uid, rule_id)
59+-
60+ For EMPLOYEE, rule for the DELETE of objects with the list of fields to track
61+-
62+ !python {model: audittrail.rule}: |
63+ name = 'EMPLOYEE DELETE'
64+ object_ids = self.pool.get('ir.model').search(cr, uid, [('model', '=', 'hr.employee')], context=context)
65+ rule_id = self.search(cr, uid, [('name', '=', name)], context=context)
66+ if object_ids:
67+ fields = ['name']
68+ fields_ids = self.pool.get('ir.model.fields').search(cr, uid, [('model', '=' ,'hr.employee'), ('name', 'in', fields)], context=context)
69+ vals = {'name': name,
70+ 'object_id': object_ids[0],
71+ 'log_create': False,
72+ 'log_write': False,
73+ 'log_unlink': True,
74+ 'field_ids': [(6, 0, fields_ids)],
75+ }
76+ if not rule_id:
77+ rule_id = self.create(cr, uid, vals, context=context)
78+ elif rule_id:
79+ self.write(cr, uid, rule_id, vals, context=context)
80+ # Subscribe to the rule
81+ self.subscribe(cr, uid, rule_id)

Subscribers

People subscribed via source and target branches