Merge lp:~unifield-team/unifield-server/us1358-trackchanges into lp:unifield-server

Proposed by jftempo
Status: Merged
Merged at revision: 3941
Proposed branch: lp:~unifield-team/unifield-server/us1358-trackchanges
Merge into: lp:unifield-server
Diff against target: 100 lines (+73/-0)
3 files modified
bin/addons/msf_audittrail/__openerp__.py (+1/-0)
bin/addons/msf_audittrail/audittrail.py (+15/-0)
bin/addons/msf_audittrail/data/audittrail_data_JI.yml (+57/-0)
To merge this branch: bzr merge lp:~unifield-team/unifield-server/us1358-trackchanges
Reviewer Review Type Date Requested Status
UniField Reviewer Team Pending
Review via email: mp+303654@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 2015-06-08 14:49:44 +0000
3+++ bin/addons/msf_audittrail/__openerp__.py 2016-08-23 07:24:56 +0000
4@@ -45,6 +45,7 @@
5 'data/audittrail_data_sale.yml',
6 'data/audittrail_data_purchase.yml',
7 'data/audittrail_data_products.yml',
8+ 'data/audittrail_data_JI.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 2016-05-25 15:17:02 +0000
15+++ bin/addons/msf_audittrail/audittrail.py 2016-08-23 07:24:56 +0000
16@@ -320,6 +320,21 @@
17
18 account_period()
19
20+#UF-1358: Track changes also for account move and account move line
21+class account_move(osv.osv):
22+ _name = 'account.move'
23+ _inherit = 'account.move'
24+ _trace = True
25+
26+account_move()
27+
28+class account_move_line(osv.osv):
29+ _name = 'account.move.line'
30+ _inherit = 'account.move.line'
31+ _trace = True
32+
33+account_move_line()
34+
35
36 class ir_module(osv.osv):
37 _inherit = 'ir.module.module'
38
39=== added file 'bin/addons/msf_audittrail/data/audittrail_data_JI.yml'
40--- bin/addons/msf_audittrail/data/audittrail_data_JI.yml 1970-01-01 00:00:00 +0000
41+++ bin/addons/msf_audittrail/data/audittrail_data_JI.yml 2016-08-23 07:24:56 +0000
42@@ -0,0 +1,57 @@
43+-
44+ For Journal Entries (account.move), track the creation and modif, delete
45+- !python {model: audittrail.rule}: |
46+ name = 'Journal Entries'
47+ object_ids = self.pool.get('ir.model').search(cr, uid, [('model', '=', 'account.move')], context=context)
48+ rule_id = self.search(cr, uid, [('object_id', 'in', object_ids)], context=context)
49+ if object_ids and not rule_id:
50+ # Create the rule
51+ fields = ['name','state','ref','journal_id','period_id','date','partner_id','status','sequence_id','manual_name','document_date','analytic_distribution_id','employee_id','instance_id','manual_currency_id']
52+ fields_ids = self.pool.get('ir.model.fields').search(cr, uid, [('model', '=' ,'account.move'), ('name', 'in', fields)], context=context)
53+
54+ rule_id = self.create(cr, uid, {'name': name,
55+ 'object_id': object_ids[0],
56+ 'log_write': True,
57+ 'log_unlink': True,
58+ 'log_create': True,
59+ 'field_ids': [(6, 0, fields_ids)],
60+ }, context=context)
61+
62+ # Subscribe to the rule
63+ self.subscribe(cr, uid, rule_id)
64+
65+-
66+ For Journal Items (account.move.line), track the creation and modif, delete
67+- !python {model: audittrail.rule}: |
68+ name = 'Journal Items'
69+ object_ids = self.pool.get('ir.model').search(cr, uid, [('model', '=', 'account.move.line')], context=context)
70+ rule_id = self.search(cr, uid, [('object_id', 'in', object_ids)], context=context)
71+ if object_ids and not rule_id:
72+ # Create the rule
73+ fields = ['state','reference','account_id','partner_txt','debit','credit','employee_id','analytic_distribution_id']
74+
75+ fields_ids = self.pool.get('ir.model.fields').search(cr, uid, [('model', '=' ,'account.move.line'), ('name', 'in', fields)], context=context)
76+ field_name = self.pool.get('ir.model.fields').search(cr, uid, [('model', '=', 'account.move.line'), ('name', '=', 'reference')], context=context)
77+ field_parent = self.pool.get('ir.model.fields').search(cr, uid, [('model', '=', 'account.move.line'), ('name', '=', 'move_id')], context=context)
78+
79+ name_id = False
80+ parent_id = False
81+
82+ if field_parent:
83+ parent_id = field_parent[0]
84+ if field_name:
85+ name_id = field_name[0]
86+
87+ rule_id = self.create(cr, uid, {'name': name,
88+ 'object_id': object_ids[0],
89+ 'log_write': True,
90+ 'log_unlink': True,
91+ 'log_create': True,
92+ 'field_ids': [(6, 0, fields_ids)],
93+ 'parent_field_id': parent_id,
94+ 'name_get_field_id': name_id,
95+ }, context=context)
96+
97+ # Subscribe to the rule
98+ self.subscribe(cr, uid, rule_id)
99+
100\ No newline at end of file

Subscribers

People subscribed via source and target branches

to all changes: