Merge lp:~julie-w/unifield-server/US-5443 into lp:unifield-server

Proposed by jftempo on 2019-06-12
Status: Merged
Merged at revision: 5404
Proposed branch: lp:~julie-w/unifield-server/US-5443
Merge into: lp:unifield-server
Diff against target: 210 lines (+87/-18)
7 files modified
bin/addons/account_journal/project/project.py (+4/-0)
bin/addons/msf_audittrail/__openerp__.py (+2/-0)
bin/addons/msf_audittrail/data/audittrail_account_analytic_journal.yml (+27/-0)
bin/addons/msf_audittrail/data/audittrail_account_journal.yml (+28/-0)
bin/addons/msf_instance/add_instance.py (+7/-8)
bin/addons/msf_sync_data_server/data/sync_server.sync_rule.csv (+1/-1)
bin/addons/msf_tools/msf_tools.py (+18/-9)
To merge this branch: bzr merge lp:~julie-w/unifield-server/US-5443
Reviewer Review Type Date Requested Status
UniField Reviewer Team 2019-06-12 Pending
Review via email: mp+368719@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/account_journal/project/project.py'
2--- bin/addons/account_journal/project/project.py 2017-09-18 12:35:40 +0000
3+++ bin/addons/account_journal/project/project.py 2019-06-12 15:18:02 +0000
4@@ -120,7 +120,11 @@
5 def create(self, cr, uid, vals, context=None):
6 if context is None:
7 context = {}
8+ user_obj = self.pool.get('res.users')
9 self._check_code_duplication(cr, uid, vals, context=context)
10+ if 'instance_id' not in vals:
11+ # Prop. instance by default at creation time is the current one: add it in vals to make it appear in the Track Changes
12+ vals['instance_id'] = user_obj.browse(cr, uid, uid, fields_to_fetch=['company_id'], context=context).company_id.instance_id.id
13 return super(account_analytic_journal, self).create(cr, uid, vals, context=context)
14
15 def write(self, cr, uid, ids, vals, context=None):
16
17=== modified file 'bin/addons/msf_audittrail/__openerp__.py'
18--- bin/addons/msf_audittrail/__openerp__.py 2019-05-14 07:28:06 +0000
19+++ bin/addons/msf_audittrail/__openerp__.py 2019-06-12 15:18:02 +0000
20@@ -51,6 +51,8 @@
21 'data/audittrail_res_users.yml',
22 'data/audittrail_hr_employee.yml',
23 'data/audittrail_res_partner.yml',
24+ 'data/audittrail_account_analytic_journal.yml',
25+ 'data/audittrail_account_journal.yml',
26 'data/audittrail_account_account.yml',
27 'audittrail_report.xml',
28 'audittrail_invoice_data.yml',
29
30=== added file 'bin/addons/msf_audittrail/data/audittrail_account_analytic_journal.yml'
31--- bin/addons/msf_audittrail/data/audittrail_account_analytic_journal.yml 1970-01-01 00:00:00 +0000
32+++ bin/addons/msf_audittrail/data/audittrail_account_analytic_journal.yml 2019-06-12 15:18:02 +0000
33@@ -0,0 +1,27 @@
34+-
35+ For Analytic Journals (account.analytic.journal), track the creation, modification, and deletion
36+-
37+ !python {model: audittrail.rule}: |
38+ name = 'Analytic Journals'
39+ object_ids = self.pool.get('ir.model').search(cr, uid, [('model', '=', 'account.analytic.journal')], context=context)
40+ rule_id = self.search(cr, uid, [('object_id', 'in', object_ids)], context=context)
41+ if object_ids:
42+ fields = ['name', 'code', 'instance_id', 'type', 'active']
43+
44+ fields_ids = self.pool.get('ir.model.fields').search(cr, uid, [('model', '=', 'account.analytic.journal'), ('name', 'in', fields)], context=context)
45+
46+ vals = {
47+ 'name': name,
48+ 'object_id': object_ids[0],
49+ 'log_write': True,
50+ 'log_unlink': True,
51+ 'log_create': True,
52+ 'field_ids': [(6, 0, fields_ids)],
53+ }
54+
55+ if not rule_id:
56+ rule_id = self.create(cr, uid, vals, context=context)
57+ elif rule_id:
58+ self.write(cr, uid, rule_id, vals, context=context)
59+ # Subscribe to the rule
60+ self.subscribe(cr, uid, rule_id)
61
62=== added file 'bin/addons/msf_audittrail/data/audittrail_account_journal.yml'
63--- bin/addons/msf_audittrail/data/audittrail_account_journal.yml 1970-01-01 00:00:00 +0000
64+++ bin/addons/msf_audittrail/data/audittrail_account_journal.yml 2019-06-12 15:18:02 +0000
65@@ -0,0 +1,28 @@
66+-
67+ For Journals (account.journal), track the creation, modification, and deletion
68+-
69+ !python {model: audittrail.rule}: |
70+ name = 'Journals'
71+ object_ids = self.pool.get('ir.model').search(cr, uid, [('model', '=', 'account.journal')], context=context)
72+ rule_id = self.search(cr, uid, [('object_id', 'in', object_ids)], context=context)
73+ if object_ids:
74+ fields = ['name', 'code', 'type', 'default_debit_account_id', 'default_credit_account_id', 'instance_id', 'currency',
75+ 'analytic_journal_id', 'bank_account_name', 'bank_account_number', 'bank_swift_code', 'bank_address', 'bank_journal_id']
76+
77+ fields_ids = self.pool.get('ir.model.fields').search(cr, uid, [('model', '=', 'account.journal'), ('name', 'in', fields)], context=context)
78+
79+ vals = {
80+ 'name': name,
81+ 'object_id': object_ids[0],
82+ 'log_write': True,
83+ 'log_unlink': True,
84+ 'log_create': True,
85+ 'field_ids': [(6, 0, fields_ids)],
86+ }
87+
88+ if not rule_id:
89+ rule_id = self.create(cr, uid, vals, context=context)
90+ elif rule_id:
91+ self.write(cr, uid, rule_id, vals, context=context)
92+ # Subscribe to the rule
93+ self.subscribe(cr, uid, rule_id)
94
95=== modified file 'bin/addons/msf_instance/add_instance.py'
96--- bin/addons/msf_instance/add_instance.py 2019-05-02 09:38:25 +0000
97+++ bin/addons/msf_instance/add_instance.py 2019-06-12 15:18:02 +0000
98@@ -25,6 +25,7 @@
99 class account_analytic_journal(osv.osv):
100 _name = 'account.analytic.journal'
101 _inherit = 'account.analytic.journal'
102+ _trace = True
103
104 def _get_current_instance(self, cr, uid, ids, name, args, context=None):
105 """
106@@ -70,6 +71,7 @@
107 class account_journal(osv.osv):
108 _name = 'account.journal'
109 _inherit = 'account.journal'
110+ _trace = True
111
112 def name_get(self, cr, uid, ids, context=None):
113 if context is None:
114@@ -114,22 +116,19 @@
115 # the create and write check and replace with the "good" journal if necessary.
116 def create(self, cr, uid, vals, context=None):
117 analytic_obj = self.pool.get('account.analytic.journal')
118+ user_obj = self.pool.get('res.users')
119+ if 'instance_id' not in vals: # ensure that the instance_id always exists, in particular for the Track Changes
120+ vals['instance_id'] = user_obj.browse(cr, uid, uid, fields_to_fetch=['company_id'], context=context).company_id.instance_id.id
121 if vals.get('type') and vals.get('type') not in ['situation', 'stock'] and vals.get('analytic_journal_id'):
122 analytic_journal = analytic_obj.browse(cr, uid, vals['analytic_journal_id'], context=context)
123
124- instance_id = False
125- if 'instance_id' in vals:
126- instance_id = vals['instance_id']
127- else:
128- instance_id = self.pool.get('res.users').browse(cr, uid, uid, context).company_id.instance_id.id
129-
130 if analytic_journal and \
131 analytic_journal.name and \
132 analytic_journal.instance_id and \
133- analytic_journal.instance_id.id != instance_id:
134+ analytic_journal.instance_id.id != vals['instance_id']:
135 # replace the journal with the one with the same name, and the wanted instance
136 new_journal_ids = analytic_obj.search(cr, uid, [('name','=', analytic_journal.name),
137- ('instance_id','=',instance_id)], context=context)
138+ ('instance_id', '=', vals['instance_id'])], context=context)
139 if len(new_journal_ids) > 0:
140 vals['analytic_journal_id'] = new_journal_ids[0]
141 return super(account_journal, self).create(cr, uid, vals, context=context)
142
143=== modified file 'bin/addons/msf_sync_data_server/data/sync_server.sync_rule.csv'
144--- bin/addons/msf_sync_data_server/data/sync_server.sync_rule.csv 2019-05-14 15:12:35 +0000
145+++ bin/addons/msf_sync_data_server/data/sync_server.sync_rule.csv 2019-06-12 15:18:02 +0000
146@@ -150,7 +150,7 @@
147 msf_sync_data_server.trigger_something,TRUE,TRUE,TRUE,TRUE,cp_to_rw,Down,"[]","['name']",OC,sync.trigger.something,,Trigger Something,Valid,,11
148 msf_sync_data.msf_instance_cloud,TRUE,TRUE,FALSE,FALSE,bidirectional,Bidirectional-Private,[],"['cloud_url', 'cloud_login', 'cloud_password', 'cloud_schedule_time', 'instance', 'cloud_retry_from', 'cloud_retry_to']",OC,msf.instance.cloud,instance,Cloud backup config,Valid,,728
149 msf_sync_data_server.ir_translation,TRUE,TRUE,TRUE,TRUE,cp_to_rw,Down,"[('res_id', '!=', 0), ('src', '!=', False), ('xml_id', '!=', False), ('lang', '!=', 'en_US'), ('type', '=', 'model'), ('name', 'in', ['res.partner.category,name','product.uom,name','product.template,description_purchase','product.template,description','product.template,description_sale','product.uom.categ,name','product.pricelist,name','product.category,name','product.nomenclature,name','product.product,form_value','product.product,function_value','product.product,fit_value','res.currency,currency_name','res.country,name','product.ul,name','product.price.type,name','product.pricelist.type,name','product.pricelist.version,name','account.analytic.account,name','account.fiscal.position,note','hr.employee.marital.status,name','account.period,name','account.tax.code,name','account.journal,name','account.tax,name','account.analytic.journal,name','account.account,name','stock.reason.type,name','product.template,name','product.justification.code,code'])]","['lang', 'src', 'name', 'value', 'type', 'xml_id']",OC,ir.translation,,Translations,Valid,,730
150-msf_sync_data_server.ir_translation_journal_up,TRUE,TRUE,FALSE,TRUE,bidirectional,Bidirectional,"[('res_id', '!=', 0), ('src', '!=', False), ('xml_id', '!=', False), ('lang', '!=', 'en_US'), ('type', '=', 'model'), ('name', 'in', ['account.journal,name'])]","['lang', 'src', 'name', 'value', 'type', 'xml_id']",HQ + MISSION,ir.translation,,Translations,Valid,,731
151+msf_sync_data_server.ir_translation_journal_up,TRUE,TRUE,FALSE,TRUE,bidirectional,Bidirectional,"[('res_id', '!=', 0), ('src', '!=', False), ('xml_id', '!=', False), ('lang', '!=', 'en_US'), ('type', '=', 'model'), ('name', 'in', ['account.journal,name', 'account.analytic.journal,name'])]","['lang', 'src', 'name', 'value', 'type', 'xml_id']",HQ + MISSION,ir.translation,,Translations,Valid,,731
152 msf_sync_data_server.cash_request,TRUE,TRUE,TRUE,FALSE,bidirectional,Bidirectional,"[('state', '!=', 'draft')]","['name', 'prop_instance_id/id', 'month_period_id/id', 'request_date', 'consolidation_currency_id/id', 'transfer_account_id/id', 'bank_journal_id/id', 'state', 'instance_ids/id', 'transfer_to_come', 'security_envelope', 'buffer', 'total_to_transfer', 'past_transfer_ids/id']",HQ + MISSION,cash.request,,Cash Request,Valid,,740
153 msf_sync_data_server.cash_request_transfer_currency,TRUE,TRUE,TRUE,FALSE,bidirectional,Bidirectional,"[('cash_request_id.state', '!=', 'draft')]","['currency_id/id', 'percentage', 'cash_request_id/id']",HQ + MISSION,cash.request.transfer.currency,,Cash Request Transfer Currency,Valid,,741
154 msf_sync_data_server.cash_request_commitment,TRUE,TRUE,TRUE,FALSE,bidirectional,Bidirectional,"[('cash_request_id.state', '!=', 'draft')]","['instance_id/id', 'instance_level', 'period_id/id', 'cash_request_id/id', 'total_commitment']",HQ + MISSION,cash.request.commitment,,Cash Request Commitment,Valid,,742
155
156=== modified file 'bin/addons/msf_tools/msf_tools.py'
157--- bin/addons/msf_tools/msf_tools.py 2019-05-06 09:49:19 +0000
158+++ bin/addons/msf_tools/msf_tools.py 2019-06-12 15:18:02 +0000
159@@ -667,10 +667,19 @@
160 return prod[0]['product_tmpl_id'][0]
161 return res_id
162
163- def _audit_product_name(self, cr, uid, ids, vals, context=None):
164- if context.get('sync_update_execution') and vals.get('name') == 'product.template,name' and vals.get('lang'):
165- templ_obj = self.pool.get('product.template')
166- audit_rule_ids = templ_obj.check_audit(cr, uid, 'write')
167+ def _audit_translatable_fields(self, cr, uid, ids, vals, context=None):
168+ """
169+ Fills in the Track Changes for translatable fields at synchro time,
170+ e.g. track the updates received on journal name in the Track Changes of the Journal object
171+ """
172+ fields = ['product.template,name', 'account.account,name', 'account.analytic.account,name',
173+ 'account.journal,name', 'account.analytic.journal,name']
174+ if context is None:
175+ context = {}
176+ if context.get('sync_update_execution') and vals.get('name') in fields and vals.get('lang'):
177+ obj_name = vals['name'].split(',')[0]
178+ obj = self.pool.get(obj_name)
179+ audit_rule_ids = obj.check_audit(cr, uid, 'write')
180 if audit_rule_ids:
181 new_ctx = context.copy()
182 new_ctx['lang'] = vals['lang']
183@@ -678,14 +687,14 @@
184 if not template_id and ids:
185 template_id = self.browse(cr, uid, ids[0], fields_to_fetch=['res_id'], context=new_ctx).res_id
186 if template_id:
187- previous = templ_obj.read(cr, uid, [template_id], ['name'], context=new_ctx)[0]
188+ previous = obj.read(cr, uid, [template_id], ['name'], context=new_ctx)[0]
189 audit_obj = self.pool.get('audittrail.rule')
190- audit_obj.audit_log(cr, uid, audit_rule_ids, templ_obj, template_id, 'write', previous, {template_id: {'name': vals['value']}} , context=context)
191+ audit_obj.audit_log(cr, uid, audit_rule_ids, obj, template_id, 'write', previous, {template_id: {'name': vals['value']}} , context=context)
192
193
194
195 def write(self, cr, uid, ids, vals, clear=False, context=None):
196- self._audit_product_name(cr, uid, ids, vals, context=context)
197+ self._audit_translatable_fields(cr, uid, ids, vals, context=context)
198 return super(ir_translation, self).write(cr, uid, ids, vals, clear=clear, context=context)
199
200
201@@ -731,8 +740,8 @@
202 self.write(cr, uid, ids, vals, context=context)
203 return ids[0]
204
205- if context.get('sync_update_execution') and vals.get('res_id') and vals.get('name') == 'product.template,name' and vals.get('lang'):
206- self._audit_product_name(cr, uid, False, vals, context=context)
207+ if context.get('sync_update_execution') and vals.get('res_id') and vals.get('lang'):
208+ self._audit_translatable_fields(cr, uid, False, vals, context=context)
209
210 return super(ir_translation, self).create(cr, uid, vals, clear=clear, context=context)
211

Subscribers

People subscribed via source and target branches