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