Merge lp:~jfb-tempo-consulting/unifield-server/US-7941 into lp:unifield-server
- US-7941
- Merge into trunk
Proposed by
jftempo
Status: | Merged |
---|---|
Merged at revision: | 5975 |
Proposed branch: | lp:~jfb-tempo-consulting/unifield-server/US-7941 |
Merge into: | lp:unifield-server |
Diff against target: |
545 lines (+193/-29) 12 files modified
bin/addons/msf_doc_import/purchase_order.py (+24/-8) bin/addons/msf_profile/data/patches.xml (+5/-0) bin/addons/msf_profile/msf_profile.py (+23/-0) bin/addons/msf_tools/automated_export.py (+22/-6) bin/addons/msf_tools/automated_export_data.xml (+1/-0) bin/addons/msf_tools/automated_export_function.py (+2/-0) bin/addons/msf_tools/automated_import.py (+75/-8) bin/addons/msf_tools/automated_import_data.xml (+5/-1) bin/addons/msf_tools/automated_import_function.py (+2/-0) bin/addons/msf_tools/views/automated_export_view.xml (+16/-2) bin/addons/msf_tools/views/automated_import_view.xml (+15/-3) bin/osv/orm.py (+3/-1) |
To merge this branch: | bzr merge lp:~jfb-tempo-consulting/unifield-server/US-7941 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
UniField Reviewer Team | Pending | ||
Review via email: mp+401180@code.launchpad.net |
Commit message
Description of the change
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_doc_import/purchase_order.py' |
2 | --- bin/addons/msf_doc_import/purchase_order.py 2020-12-14 16:49:10 +0000 |
3 | +++ bin/addons/msf_doc_import/purchase_order.py 2021-04-15 08:08:32 +0000 |
4 | @@ -65,12 +65,12 @@ |
5 | return result |
6 | |
7 | def export_po(self, cr, uid, ids, context=None): |
8 | - auto_job_ids = self.pool.get('automated.export').search(cr, uid, [('function_id.method_to_call', '=', 'auto_export_validated_purchase_order'), ('active', '=', True)], context=context) |
9 | + wiz = self.browse(cr, uid, ids[0], context) |
10 | + auto_job_ids = self.pool.get('automated.export').search(cr, uid, [('function_id.method_to_call', '=', 'auto_export_validated_purchase_order'), ('active', '=', True), ('partner_id', '=', wiz.purchase_id.partner_id.id)], context=context) |
11 | if not auto_job_ids: |
12 | raise osv.except_osv(_('Warning'), _('The job to export PO is not active.')) |
13 | |
14 | auto_job = self.pool.get('automated.export').browse(cr, uid, auto_job_ids[0], context=context) |
15 | - wiz = self.browse(cr, uid, ids[0], context) |
16 | |
17 | |
18 | processed, rejected, trash = self.pool.get('purchase.order').auto_export_validated_purchase_order(cr, uid, auto_job, [wiz.purchase_id.id], context=context) |
19 | @@ -126,11 +126,26 @@ |
20 | for id in ids: |
21 | ret[id] = False |
22 | |
23 | - if not self.pool.get('automated.export').search_exist(cr, uid, [('function_id.method_to_call', '=', 'auto_export_validated_purchase_order'), ('active', '=', True)], context=context): |
24 | - return ret |
25 | - |
26 | - for x in self.search(cr, uid, [('id', 'in', ids), ('partner_type', '=', 'esc'), ('state', 'in', ['validated', 'validated_p'])], context=context): |
27 | - ret[x] = True |
28 | + if not ids: |
29 | + return {} |
30 | + |
31 | + cr.execute(''' |
32 | + select o.id |
33 | + from |
34 | + purchase_order o, automated_export exp, automated_export_function fnct |
35 | + where |
36 | + o.id in %s and |
37 | + o.partner_type = 'esc' and |
38 | + o.state in ('validated', 'validated_p') and |
39 | + o.partner_id = exp.partner_id and |
40 | + exp.active = 't' and |
41 | + exp.function_id = fnct.id and |
42 | + fnct.method_to_call = 'auto_export_validated_purchase_order' |
43 | + ''', (tuple(ids), )) |
44 | + |
45 | + for x in cr.fetchall(): |
46 | + ret[x[0]] = True |
47 | + |
48 | return ret |
49 | |
50 | _columns = { |
51 | @@ -390,7 +405,8 @@ |
52 | ('partner_type', '=', 'esc'), |
53 | ('state', 'in', ['validated', 'validated_p']), |
54 | ('auto_exported_ok', '=', False), |
55 | - ], context= context) |
56 | + ('partner_id', '=', export_wiz.partner_id.id), |
57 | + ], context=context) |
58 | |
59 | if not po_ids: |
60 | msg = _('No PO to export !') |
61 | |
62 | === modified file 'bin/addons/msf_profile/data/patches.xml' |
63 | --- bin/addons/msf_profile/data/patches.xml 2021-02-04 16:31:58 +0000 |
64 | +++ bin/addons/msf_profile/data/patches.xml 2021-04-15 08:08:32 +0000 |
65 | @@ -647,5 +647,10 @@ |
66 | <field name="method">us_6796_hide_prod_status_inconsistencies</field> |
67 | </record> |
68 | |
69 | + <!-- UF21.0 --> |
70 | + <record id="us_7941_auto_vi_set_partner" model="patch.scripts"> |
71 | + <field name="method">us_7941_auto_vi_set_partner</field> |
72 | + </record> |
73 | + |
74 | </data> |
75 | </openerp> |
76 | |
77 | === modified file 'bin/addons/msf_profile/msf_profile.py' |
78 | --- bin/addons/msf_profile/msf_profile.py 2021-02-04 16:31:58 +0000 |
79 | +++ bin/addons/msf_profile/msf_profile.py 2021-04-15 08:08:32 +0000 |
80 | @@ -51,6 +51,29 @@ |
81 | _defaults = { |
82 | 'model': lambda *a: 'patch.scripts', |
83 | } |
84 | + # UF21.0 |
85 | + def us_7941_auto_vi_set_partner(self, cr, uid, *a, **b): |
86 | + cr.execute(''' |
87 | + update automated_import imp set partner_id = (select id from res_partner where ref='APU' and partner_type='esc' LIMIT 1) |
88 | + from automated_import_function function |
89 | + where |
90 | + function.id = imp.function_id and |
91 | + imp.partner_id is null and |
92 | + function.multiple='t' |
93 | + ''') |
94 | + self._logger.warn('APU set on %s VI import.' % (cr.rowcount,)) |
95 | + |
96 | + cr.execute(''' |
97 | + update automated_export exp set partner_id = (select id from res_partner where ref='APU' and partner_type='esc' LIMIT 1) |
98 | + from automated_export_function function |
99 | + where |
100 | + function.id = exp.function_id and |
101 | + exp.partner_id is null and |
102 | + function.multiple='t' |
103 | + ''') |
104 | + self._logger.warn('APU set on %s VI export.' % (cr.rowcount,)) |
105 | + |
106 | + return True |
107 | |
108 | # UF20.0 |
109 | def us_7866_fill_in_target_cc_code(self, cr, uid, *a, **b): |
110 | |
111 | === modified file 'bin/addons/msf_tools/automated_export.py' |
112 | --- bin/addons/msf_tools/automated_export.py 2020-09-18 13:38:52 +0000 |
113 | +++ bin/addons/msf_tools/automated_export.py 2021-04-15 08:08:32 +0000 |
114 | @@ -33,6 +33,16 @@ |
115 | |
116 | class automated_export(osv.osv): |
117 | _name = 'automated.export' |
118 | + _order = 'name, id' |
119 | + |
120 | + def _auto_init(self, cr, context=None): |
121 | + res = super(automated_export, self)._auto_init(cr, context) |
122 | + # migration delete old constraint |
123 | + cr.drop_constraint_if_exists('automated_export', 'automated_export_export_function_id_uniq') |
124 | + cr.execute("SELECT indexname FROM pg_indexes WHERE indexname = 'automated_export_function_id_partner_id_uniq'") |
125 | + if not cr.fetchone(): |
126 | + cr.execute("CREATE UNIQUE INDEX automated_export_function_id_partner_id_uniq ON automated_export (function_id, coalesce(partner_id, 0))") |
127 | + return res |
128 | |
129 | _columns = { |
130 | 'name': fields.char( |
131 | @@ -77,6 +87,7 @@ |
132 | required=True, |
133 | ), |
134 | 'disable_cron': fields.related('function_id', 'disable_cron', string='Cron disabled', type='boolean', write_relate=False), |
135 | + 'multiple': fields.related('function_id', 'multiple', string='Multiple', type='boolean', write_relate=False), |
136 | 'export_format': fields.selection( |
137 | selection=[ |
138 | ('excel', 'Excel'), |
139 | @@ -109,6 +120,7 @@ |
140 | 'ftp_dest_ok': fields.boolean(string='on FTP server', help='Is given path is located on FTP server ?'), |
141 | 'ftp_dest_fail_ok': fields.boolean(string='on FTP server', help='Is given path is located on FTP server ?'), |
142 | 'ftp_report_ok': fields.boolean(string='on FTP server', help='Is given path is located on FTP server ?'), |
143 | + 'partner_id': fields.many2one('res.partner', 'Partner', domain=[('supplier', '=', True), ('partner_type', '=', 'esc')]), |
144 | |
145 | } |
146 | |
147 | @@ -127,10 +139,11 @@ |
148 | _('Another Automated export with same name already exists (maybe inactive). Automated export name must be unique. Please select an other name.'), |
149 | ), |
150 | ( |
151 | - 'export_function_id_uniq', |
152 | - 'unique(function_id)', |
153 | - _('Another Automated export with same functionality already exists (maybe inactive). Only one automated export must be created for a '\ |
154 | - 'same functionality. Please select an other functionality.'), |
155 | + # declared in _auto_init |
156 | + 'function_id_partner_id_uniq', |
157 | + '', |
158 | + _('Another Automated export with same functionality and same partner already exists (maybe inactive). Only one automated export must be created for a '\ |
159 | + 'same functionality and partner.'), |
160 | ), |
161 | ( |
162 | 'export_positive_interval', |
163 | @@ -141,9 +154,12 @@ |
164 | |
165 | def change_function_id(self, cr, uid, ids, function_id, context=None): |
166 | disable_cron = False |
167 | + multiple = False |
168 | if function_id: |
169 | - disable_cron = self.pool.get('automated.export.function').browse(cr, uid, function_id, context=context).disable_cron |
170 | - return {'value': {'disable_cron': disable_cron}} |
171 | + fct_data = self.pool.get('automated.export.function').browse(cr, uid, function_id, context=context) |
172 | + disable_cron = fct_data.disable_cron |
173 | + multiple = fct_data.multiple |
174 | + return {'value': {'disable_cron': disable_cron, 'multiple': multiple}} |
175 | |
176 | def onchange_ftp_ok(self, cr, uid, ids, ftp_ok, context=None): |
177 | if context is None: |
178 | |
179 | === modified file 'bin/addons/msf_tools/automated_export_data.xml' |
180 | --- bin/addons/msf_tools/automated_export_data.xml 2020-09-18 10:39:31 +0000 |
181 | +++ bin/addons/msf_tools/automated_export_data.xml 2021-04-15 08:08:32 +0000 |
182 | @@ -5,6 +5,7 @@ |
183 | <field name="name">Export validated Purchase Order</field> |
184 | <field name="model_id" model="ir.model" search="[('model', '=', 'purchase.order')]" /> |
185 | <field name="method_to_call">auto_export_validated_purchase_order</field> |
186 | + <field name="multiple" eval="True" /> |
187 | </record> |
188 | <record id="auto_export_fnct_oca_finance_vi" model="automated.export.function"> |
189 | <field name="name">Export to HQ system (OCA) - Not yet exported</field> |
190 | |
191 | === modified file 'bin/addons/msf_tools/automated_export_function.py' |
192 | --- bin/addons/msf_tools/automated_export_function.py 2020-09-18 10:39:31 +0000 |
193 | +++ bin/addons/msf_tools/automated_export_function.py 2021-04-15 08:08:32 +0000 |
194 | @@ -45,11 +45,13 @@ |
195 | required=True, |
196 | ), |
197 | 'disable_cron': fields.boolean('No cron'), |
198 | + 'multiple': fields.boolean('Allow multiple jobs'), |
199 | } |
200 | |
201 | _defaults = { |
202 | 'method_to_call': lambda *a: 'export_data_from_csv', |
203 | 'disable_cron': False, |
204 | + 'multiple': False, |
205 | } |
206 | |
207 | _order = 'name' |
208 | |
209 | === modified file 'bin/addons/msf_tools/automated_import.py' |
210 | --- bin/addons/msf_tools/automated_import.py 2020-10-20 12:50:50 +0000 |
211 | +++ bin/addons/msf_tools/automated_import.py 2021-04-15 08:08:32 +0000 |
212 | @@ -33,6 +33,16 @@ |
213 | |
214 | class automated_import(osv.osv): |
215 | _name = 'automated.import' |
216 | + _order = 'name, id' |
217 | + |
218 | + def _auto_init(self, cr, context=None): |
219 | + res = super(automated_import, self)._auto_init(cr, context) |
220 | + # migration delete old constraint |
221 | + cr.drop_constraint_if_exists('automated_import', 'automated_import_import_function_id_uniq') |
222 | + cr.execute("SELECT indexname FROM pg_indexes WHERE indexname = 'automated_import_function_id_partner_id_uniq'") |
223 | + if not cr.fetchone(): |
224 | + cr.execute("CREATE UNIQUE INDEX automated_import_function_id_partner_id_uniq ON automated_import (function_id, coalesce(partner_id, 0))") |
225 | + return res |
226 | |
227 | def _check_paths(self, cr, uid, ids, context=None): |
228 | """ |
229 | @@ -73,6 +83,44 @@ |
230 | |
231 | return True |
232 | |
233 | + def _check_unicity(self, cr, uid, ids, context=None): |
234 | + ''' |
235 | + if the function_id allows multiple then the server / src_path must be unique |
236 | + if not multiple: then function_id must be unique |
237 | + ''' |
238 | + |
239 | + error = [] |
240 | + cr.execute(''' |
241 | + select function.name |
242 | + from automated_import import, automated_import_function function |
243 | + where |
244 | + function.id = import.function_id and |
245 | + coalesce(function.multiple, 'f') = 'f' |
246 | + group by function.name |
247 | + having(count(*) > 1) |
248 | + ''') |
249 | + for x in cr.fetchall(): |
250 | + error.append(_('Another Automated import with same functionality "%s" already exists (maybe inactive). Only one automated import must be created for a '\ |
251 | + 'same functionality. Please select an other functionality.') % x[0]) |
252 | + |
253 | + cr.execute(''' |
254 | + select function.name |
255 | + from automated_import import, automated_import_function function |
256 | + where |
257 | + function.id = import.function_id and |
258 | + coalesce(function.multiple, 'f') = 't' and |
259 | + coalesce(src_path, '') != '' |
260 | + group by function.name, src_path, ftp_url |
261 | + having(count(*) > 1) |
262 | + ''') |
263 | + for x in cr.fetchall(): |
264 | + error.append(_('Another Automated import with same functionality "%s", same server and same source already exists (maybe inactive).') % x[0]) |
265 | + |
266 | + if error: |
267 | + raise osv.except_osv(_('Warning'), "\n".join(error)) |
268 | + |
269 | + return True |
270 | + |
271 | def _get_isadmin(self, cr, uid, ids, *a, **b): |
272 | ret = {} |
273 | for _id in ids: |
274 | @@ -123,6 +171,7 @@ |
275 | string='Functionality', |
276 | required=True, |
277 | ), |
278 | + 'multiple': fields.related('function_id', 'multiple', string='Multiple', type='boolean', write_relate=False), |
279 | 'active': fields.boolean( |
280 | string='Active', |
281 | readonly=True, |
282 | @@ -149,6 +198,7 @@ |
283 | 'ftp_dest_fail_ok': fields.boolean(string='on FTP server', help='Is given path is located on FTP server ?'), |
284 | 'ftp_report_ok': fields.boolean(string='on FTP server', help='Is given path is located on FTP server ?'), |
285 | 'is_admin': fields.function(_get_isadmin, method=True, type='boolean', string='Is Admin'), |
286 | + 'partner_id': fields.many2one('res.partner', 'Partner', domain=[('partner_type', '=', 'esc')]), |
287 | } |
288 | |
289 | _defaults = { |
290 | @@ -167,10 +217,9 @@ |
291 | _('Another Automated import with same name already exists (maybe inactive). Automated import name must be unique. Please select an other name.'), |
292 | ), |
293 | ( |
294 | - 'import_function_id_uniq', |
295 | - 'unique(function_id)', |
296 | - _('Another Automated import with same functionality already exists (maybe inactive). Only one automated import must be created for a '\ |
297 | - 'same functionality. Please select an other functionality.'), |
298 | + 'function_id_partner_id_uniq', |
299 | + '', |
300 | + _('Another Automated import with same function / same partner already exists (maybe inactive).'), |
301 | ), |
302 | ( |
303 | 'import_positive_interval', |
304 | @@ -181,8 +230,20 @@ |
305 | |
306 | _constraints = [ |
307 | (_check_paths, _('There is a problem with paths'), ['active', 'src_path', 'dest_path', 'report_path', 'dest_path_failure']), |
308 | + (_check_unicity, _('There is a problem with paths'), []), |
309 | ] |
310 | |
311 | + def change_function_id(self, cr, uid, ids, function_id, context=None): |
312 | + multiple = False |
313 | + value = {} |
314 | + if function_id: |
315 | + fct_data = self.pool.get('automated.import.function').browse(cr, uid, function_id, context=context) |
316 | + multiple = fct_data.multiple |
317 | + if not multiple: |
318 | + value['partner_id'] = False |
319 | + value['multiple'] = multiple |
320 | + return {'value': value} |
321 | + |
322 | def onchange_ftp_ok(self, cr, uid, ids, ftp_ok, context=None): |
323 | if context is None: |
324 | context = {} |
325 | @@ -290,14 +351,20 @@ |
326 | |
327 | main_path = os.path.join(config.get('root_path'), 'vi_auto_import') |
328 | write_me = {'ftp_source_ok': False, 'ftp_dest_ok': False, 'ftp_dest_fail_ok': False, 'ftp_report_ok': False, 'ftp_ok': False, 'active': True, 'interval_unit': 'months', 'interval': 12} |
329 | + |
330 | + prefix = '' |
331 | + for job in self.browse(cr, uid, ids, fields_to_fetch=['name', 'function_id'], context=context): |
332 | + if job.function_id.multiple: |
333 | + num = self.search(cr, uid, [('function_id', '=', job.function_id.id), ('active', 'in', ['t', 'f'])], count=True, context=context) |
334 | + if num > 1: |
335 | + prefix = num |
336 | + self.log(cr, uid, job.id, 'Auto configuration done on job %s' % job.name) |
337 | + |
338 | for directory in ['src_path', 'dest_path', 'dest_path_failure', 'report_path']: |
339 | - target = os.path.join(main_path, directory) |
340 | + target = os.path.join(main_path, '%s%s' % (directory, prefix)) |
341 | write_me[directory] = target |
342 | if not os.path.exists(target): |
343 | os.makedirs(target) |
344 | - |
345 | - for job in self.read(cr, uid, ids, ['name'], context=context): |
346 | - self.log(cr, uid, job['id'], 'Auto configuration done on job %s' % job['name']) |
347 | self.write(cr, uid, ids, write_me, context=context) |
348 | return True |
349 | |
350 | |
351 | === modified file 'bin/addons/msf_tools/automated_import_data.xml' |
352 | --- bin/addons/msf_tools/automated_import_data.xml 2018-03-29 07:34:43 +0000 |
353 | +++ bin/addons/msf_tools/automated_import_data.xml 2021-04-15 08:08:32 +0000 |
354 | @@ -61,6 +61,7 @@ |
355 | <field name="model_id" model="ir.model" search="[('model', '=', 'supplier.catalogue')]" /> |
356 | <field name="method_to_call">auto_import</field> |
357 | <field name="startswith">SCL_</field> |
358 | + <field name="multiple" eval="True" /> |
359 | </record> |
360 | |
361 | <record id="auto_import_fnct_product_list" model="automated.import.function"> |
362 | @@ -75,6 +76,7 @@ |
363 | <field name="model_id" model="ir.model" search="[('model', '=', 'stock.picking')]" /> |
364 | <field name="method_to_call">auto_import_incoming_shipment</field> |
365 | <field name="startswith">SHPM_</field> |
366 | + <field name="multiple" eval="True" /> |
367 | </record> |
368 | |
369 | <record id="auto_import_fnct_purchase_order" model="automated.import.function"> |
370 | @@ -82,13 +84,15 @@ |
371 | <field name="model_id" model="ir.model" search="[('model', '=', 'purchase.order')]" /> |
372 | <field name="method_to_call">auto_import_purchase_order</field> |
373 | <field name="startswith">POV_</field> |
374 | + <field name="multiple" eval="True" /> |
375 | </record> |
376 | - |
377 | + |
378 | <record id="auto_import_fnct_confirmed_purchase_order" model="automated.import.function"> |
379 | <field name="name">Import Purchase Order and confirm</field> |
380 | <field name="model_id" model="ir.model" search="[('model', '=', 'purchase.order')]" /> |
381 | <field name="method_to_call">auto_import_confirmed_purchase_order</field> |
382 | <field name="startswith">POV_</field> |
383 | + <field name="multiple" eval="True" /> |
384 | </record> |
385 | |
386 | <record id="auto_import_fnct_product_categories" model="automated.import.function"> |
387 | |
388 | === modified file 'bin/addons/msf_tools/automated_import_function.py' |
389 | --- bin/addons/msf_tools/automated_import_function.py 2018-03-29 07:34:43 +0000 |
390 | +++ bin/addons/msf_tools/automated_import_function.py 2021-04-15 08:08:32 +0000 |
391 | @@ -45,10 +45,12 @@ |
392 | required=True, |
393 | ), |
394 | 'startswith': fields.char('Starts with', size=56), |
395 | + 'multiple': fields.boolean('Allow multiple jobs'), |
396 | } |
397 | |
398 | _defaults = { |
399 | 'method_to_call': lambda *a: 'import_data_from_csv', |
400 | + 'multiple': False, |
401 | } |
402 | |
403 | _order = 'name' |
404 | |
405 | === modified file 'bin/addons/msf_tools/views/automated_export_view.xml' |
406 | --- bin/addons/msf_tools/views/automated_export_view.xml 2020-09-18 10:39:31 +0000 |
407 | +++ bin/addons/msf_tools/views/automated_export_view.xml 2021-04-15 08:08:32 +0000 |
408 | @@ -8,9 +8,16 @@ |
409 | <field name="type">search</field> |
410 | <field name="arch" type="xml"> |
411 | <search string="Automated exports"> |
412 | - <filter name="inactive" domain="[('active', '=', False)]" string="Inactive" icon="gtk-undo" /> |
413 | + <filter icon="terp-check" name="filteractive" string="Active" domain="[('active', '=', True)]" /> |
414 | + <filter icon="gtk-dialog-error" name="filterinactive" string="Inactive" domain="[('active', '=', False)]" /> |
415 | <field name="name" /> |
416 | <field name="function_id" /> |
417 | + <field name="partner_id" /> |
418 | + <newline /> |
419 | + <group expand="1" string="Group By..." colspan="4" col="4"> |
420 | + <filter string="Partner" name="groupby_partner_id" icon="terp-partner" domain="[]" context="{'group_by':'partner_id'}"/> |
421 | + <filter string="Function" name="groupby_function_id" icon="terp-accessories-archiver" domain="[]" context="{'group_by':'function_id'}"/> |
422 | + </group> |
423 | </search> |
424 | </field> |
425 | </record> |
426 | @@ -20,12 +27,14 @@ |
427 | <field name="model">automated.export</field> |
428 | <field name="type">tree</field> |
429 | <field name="arch" type="xml"> |
430 | - <tree string="Automated exports"> |
431 | + <tree string="Automated exports" colors="red: not active"> |
432 | <field name="name" /> |
433 | <field name="function_id" /> |
434 | + <field name="partner_id" /> |
435 | <field name="start_time" /> |
436 | <field name="interval" /> |
437 | <field name="interval_unit" /> |
438 | + <field name="active" /> |
439 | </tree> |
440 | </field> |
441 | </record> |
442 | @@ -41,10 +50,14 @@ |
443 | <field name="function_id" widget="selection" on_change="change_function_id(function_id)"/> |
444 | <field name="active" /> |
445 | <field name="export_format" attrs="{'invisible': [('disable_cron', '=', True)]}"/> |
446 | + <label colspan="2" /> |
447 | + <field name="partner_id" attrs="{'invisible': [('multiple', '=', False)], 'required': [('multiple', '=', True)]}"/> |
448 | + <newline /> |
449 | <button name="run_job_manually" string="Run job manually" colspan="2" type="object" icon="gtk-execute" /> |
450 | <button name="sent_to_remote" string="Manually send to FTP" colspan="2" type="object" icon="cloud.png" attrs="{'invisible': ['|', ('disable_cron', '=', False), ('ftp_ok', '=', False)]}" /> |
451 | |
452 | <field name="disable_cron" invisible="1" /> |
453 | + <field name="multiple" invisible="1" /> |
454 | |
455 | <separator colspan="4" string="FTP server" /> |
456 | <group col="4" colspan="4"> |
457 | @@ -87,6 +100,7 @@ |
458 | <field name="res_model">automated.export</field> |
459 | <field name="view_type">form</field> |
460 | <field name="view_mode">tree,form</field> |
461 | + <field name="context">{'search_default_filteractive' : 1}</field> |
462 | </record> |
463 | <menuitem |
464 | id="automated_export_menu" |
465 | |
466 | === modified file 'bin/addons/msf_tools/views/automated_import_view.xml' |
467 | --- bin/addons/msf_tools/views/automated_import_view.xml 2020-10-20 15:14:32 +0000 |
468 | +++ bin/addons/msf_tools/views/automated_import_view.xml 2021-04-15 08:08:32 +0000 |
469 | @@ -8,9 +8,16 @@ |
470 | <field name="type">search</field> |
471 | <field name="arch" type="xml"> |
472 | <search string="Automated imports"> |
473 | - <filter name="inactive" domain="[('active', '=', False)]" string="Inactive" icon="gtk-undo" /> |
474 | + <filter icon="terp-check" name="filteractive" string="Active" domain="[('active', '=', True)]" /> |
475 | + <filter icon="gtk-dialog-error" name="filterinactive" string="Inactive" domain="[('active', '=', False)]" /> |
476 | <field name="name" /> |
477 | <field name="function_id" /> |
478 | + <field name="partner_id" /> |
479 | + <newline /> |
480 | + <group expand="1" string="Group By..." colspan="4" col="4"> |
481 | + <filter string="Partner" name="groupby_partner_id" icon="terp-partner" domain="[]" context="{'group_by':'partner_id'}"/> |
482 | + <filter string="Function" name="groupby_function_id" icon="terp-accessories-archiver" domain="[]" context="{'group_by':'function_id'}"/> |
483 | + </group> |
484 | </search> |
485 | </field> |
486 | </record> |
487 | @@ -20,12 +27,14 @@ |
488 | <field name="model">automated.import</field> |
489 | <field name="type">tree</field> |
490 | <field name="arch" type="xml"> |
491 | - <tree string="Automated imports"> |
492 | + <tree string="Automated imports" colors="red: not active"> |
493 | <field name="name" /> |
494 | <field name="function_id" /> |
495 | + <field name="partner_id" /> |
496 | <field name="start_time" /> |
497 | <field name="interval" /> |
498 | <field name="interval_unit" /> |
499 | + <field name="active" /> |
500 | </tree> |
501 | </field> |
502 | </record> |
503 | @@ -58,9 +67,11 @@ |
504 | }); |
505 | </script> |
506 | </html> |
507 | + <field name="multiple" invisible="1" /> |
508 | <field name="name" /> |
509 | - <field name="function_id" widget="selection" /> |
510 | + <field name="function_id" widget="selection" on_change="change_function_id(function_id)" /> |
511 | <field name="active" /> |
512 | + <field name="partner_id" attrs="{'invisible': [('multiple', '=', False)], 'required': [('multiple', '=', True)]}"/> |
513 | <field name="is_admin" invisible="1"/> |
514 | <button name="run_job_manually" string="Run job manually" colspan="2" type="object" icon="gtk-execute" /> |
515 | <button name="local_autoconfig" string="Local Auto Configuration" colspan="2" type="object" icon="terp-dialog-close" confirm="This action should only be executed on a Sandbox, it will override the current configuration. Do you confirm ?" attrs="{'invisible': [('is_admin', '=', False)]}"/> |
516 | @@ -108,6 +119,7 @@ |
517 | <field name="res_model">automated.import</field> |
518 | <field name="view_type">form</field> |
519 | <field name="view_mode">tree,form</field> |
520 | + <field name="context">{'search_default_filteractive' : 1}</field> |
521 | </record> |
522 | <menuitem |
523 | id="automated_import_menu" |
524 | |
525 | === modified file 'bin/osv/orm.py' |
526 | --- bin/osv/orm.py 2021-02-02 10:20:51 +0000 |
527 | +++ bin/osv/orm.py 2021-04-15 08:08:32 +0000 |
528 | @@ -3425,6 +3425,8 @@ |
529 | cr.commit() # start a new transaction |
530 | |
531 | for (key, con, null) in self._sql_constraints: |
532 | + if not con: |
533 | + continue |
534 | conname = '%s_%s' % (self._table, key) |
535 | |
536 | cr.execute("SELECT conname, pg_catalog.pg_get_constraintdef(oid, true) as condef FROM pg_constraint where conname=%s", (conname,)) |
537 | @@ -4007,7 +4009,7 @@ |
538 | [('res_id','in',list(sub_ids)),('model','=',self._name)], |
539 | order='NO_ORDER', context=context) |
540 | |
541 | - if self._name in xmlid_no_delete.prevent_deletion: |
542 | + if referenced_ids and self._name in xmlid_no_delete.prevent_deletion: |
543 | cr.execute('''select module, name from ir_model_data |
544 | where |
545 | (module, name) in %s and |