Merge lp:~dorian-kemps/unifield-server/US-7216 into lp:unifield-server
- US-7216
- Merge into trunk
Proposed by
jftempo
Status: | Needs review |
---|---|
Proposed branch: | lp:~dorian-kemps/unifield-server/US-7216 |
Merge into: | lp:unifield-server |
Diff against target: |
352 lines (+162/-22) 5 files modified
bin/addons/msf_profile/i18n/fr_MF.po (+41/-3) bin/addons/product/wizard/product_mass_update.py (+50/-17) bin/addons/product/wizard/product_mass_update_view.xml (+11/-2) bin/addons/product_attributes/product_attributes.py (+39/-0) bin/addons/product_attributes/product_attributes_view.xml (+21/-0) |
To merge this branch: | bzr merge lp:~dorian-kemps/unifield-server/US-7216 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
UniField Reviewer Team | Pending | ||
Review via email: mp+381110@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_profile/i18n/fr_MF.po' |
2 | --- bin/addons/msf_profile/i18n/fr_MF.po 2020-03-20 14:08:02 +0000 |
3 | +++ bin/addons/msf_profile/i18n/fr_MF.po 2020-03-27 09:04:35 +0000 |
4 | @@ -58275,6 +58275,7 @@ |
5 | #: report:addons/procurement_cycle/report/replenishment_order_calc.mako:429 |
6 | #: field:replenishment.inventory.review.line,warning:0 |
7 | #: field:replenishment.order_calc.line,warning:0 |
8 | +#: view:product.ask.activate.wizard:0 |
9 | #, python-format |
10 | msgid "Warning" |
11 | msgstr "Avertissement" |
12 | @@ -96483,6 +96484,7 @@ |
13 | #: selection:export.report.stock.move,state:0 |
14 | #: view:replenishment.order_calc:0 |
15 | #: view:replenishment.segment:0 |
16 | +#: view:product.ask.activate.wizard:0 |
17 | #, python-format |
18 | msgid "Cancel" |
19 | msgstr "Annuler" |
20 | @@ -105338,6 +105340,11 @@ |
21 | msgid "Non-Deactivable Products" |
22 | msgstr "Produits Non-Désactivables" |
23 | |
24 | +#. module: product |
25 | +#: view:product.mass.update:0 |
26 | +msgid "Non-Activable Products" |
27 | +msgstr "Produits Non-Activables" |
28 | + |
29 | #. module: product, procurement_cycle |
30 | #: view:product.mass.update:0 |
31 | #: model:ir.actions.act_window,name:procurement_cycle.action_replenishment_product_list |
32 | @@ -105361,9 +105368,26 @@ |
33 | msgstr "Vous ne pouvez pas appliquer de mise à jour à aucun produits." |
34 | |
35 | #. module: product |
36 | -#: code:addons/product/wizard/product_mass_update.py:287 |
37 | -msgid "Some products could not be deactivated. No product will be changed until all of them can be deactivated. Please check the corresponding tab." |
38 | -msgstr "Certains produits n'ont pas pu être désactivés. Aucun produit ne sera modifié tant qu'ils ne pourront pas tous être désactivés. Veuillez vérifier l'onglet approprié." |
39 | +#: code:addons/product/wizard/product_mass_update.py:369 |
40 | +#, python-format |
41 | +msgid "Some products could not be deactivated. No product will be changed until all of them can be deactivated.\n" |
42 | +"" |
43 | +msgstr "Certains produits n'ont pas pu être désactivés. Aucun produit ne sera modifié tant qu'ils ne pourront pas tous être désactivés.\n" |
44 | +"" |
45 | + |
46 | +#. module: product |
47 | +#: code:addons/product/wizard/product_mass_update.py:380 |
48 | +#, python-format |
49 | +msgid "Some NSL (Non-standard Local) products could not be activated to ensure that there is no duplicate “Local” product. No product will be changed and those NSL products should be activated manually.\n" |
50 | +"" |
51 | +msgstr "Certains produits NSL (Non-standard Local) n'ont pas pu être activés afin d'assurer qu'il n'y a pas de produit “Local” en doublon. Aucun produit ne sera modifié et ces produits NSL devraient être activés manuellement.\n" |
52 | +"" |
53 | + |
54 | +#. module: product |
55 | +#: code:addons/product/wizard/product_mass_update.py:383 |
56 | +#, python-format |
57 | +msgid "Please check the corresponding tab." |
58 | +msgstr "Veuillez vérifier l'onglet approprié." |
59 | |
60 | #. module: product |
61 | #: field:product.mass.update,name:0 |
62 | @@ -108977,6 +109001,16 @@ |
63 | msgid "more FMC" |
64 | msgstr "plus de PCM" |
65 | |
66 | +#. module: product |
67 | +#: field:product.mass.update,has_not_deactivable:0 |
68 | +msgid "Document has non-deactivable product(s)" |
69 | +msgstr "Le Document a des produits non-désactivables" |
70 | + |
71 | +#. module: product |
72 | +#: field:product.mass.update,has_not_activable:0 |
73 | +msgid "Document has non-activable product(s)" |
74 | +msgstr "Le Document a des produits non-activables" |
75 | + |
76 | #. module: msf_doc_import |
77 | #: code:addons/msf_doc_import/account.py:287 |
78 | #, python-format |
79 | @@ -108995,6 +109029,10 @@ |
80 | msgstr "Ligne %s. La période %s n'existe pas." |
81 | |
82 | #. module: product_attributes |
83 | +#: view:product.ask.activate.wizard:0 |
84 | +msgid "This is an NSL (Non-standard Local) product, please ensure that there is no duplicate “Local” product with which this product should be merged. If you activate and start to use this product it will no longer be possible to merge it with another." |
85 | +msgstr "Ce produit est NSL (Non-standard Local), veuillez vous assurer qu'il n'y a pas de produit “Local” doublon avec lequel ce produit devrait être fusionné. Si vous activez ce produit et commencez à l'utiliser, il ne sera plus possible de le fusionner avec un autre." |
86 | + |
87 | #: code:addons/product_attributes/product_attributes.py:1308 |
88 | #: code:addons/product_attributes/product_attributes.py:1445 |
89 | #, python-format |
90 | |
91 | === modified file 'bin/addons/product/wizard/product_mass_update.py' |
92 | --- bin/addons/product/wizard/product_mass_update.py 2019-11-21 09:09:59 +0000 |
93 | +++ bin/addons/product/wizard/product_mass_update.py 2020-03-27 09:04:35 +0000 |
94 | @@ -45,10 +45,14 @@ |
95 | 'percent_completed': fields.function(_get_percent_completed, method=True, string='% completed', type='integer', readonly=True), |
96 | 'message': fields.text(string='Message', readonly=True), |
97 | 'product_ids': fields.many2many('product.product', 'prod_mass_update_product_rel', 'product_id', |
98 | - 'prod_mass_update_id', string="Product selection", order_by="default_code"), |
99 | + 'prod_mass_update_id', string="Product selection", order_by="default_code", |
100 | + domain=[('active', 'in', ['t', 'f'])]), |
101 | 'not_deactivated_product_ids': fields.one2many('product.mass.update.errors', 'p_mass_upd_id', |
102 | string="Product(s) that can not be deactivated"), |
103 | 'has_not_deactivable': fields.boolean(string='Document has non-deactivable product(s)', readonly=True), |
104 | + 'not_activated_product_ids': fields.one2many('product.mass.update.errors', 'p_mass_upd_id', |
105 | + string="Product(s) that can not be deactivated"), |
106 | + 'has_not_activable': fields.boolean(string='Document has non-activable product(s)', readonly=True), |
107 | # Fields |
108 | 'active_product': fields.selection(selection=[('no', 'No'), ('yes', 'Yes')], string='Active', help="If the active field is set to False, it allows to hide the nomenclature without removing it."), |
109 | 'dangerous_goods': fields.selection(selection=[('False', 'No'), ('True', 'Yes'), ('no_know', 'tbd')], string='Dangerous Goods'), |
110 | @@ -142,6 +146,8 @@ |
111 | 'message': '', |
112 | 'not_deactivated_product_ids': [(6, 0, [])], |
113 | 'has_not_deactivable': False, |
114 | + 'not_activated_product_ids': [(6, 0, [])], |
115 | + 'has_not_activable': False, |
116 | 'empty_status': False, |
117 | 'empty_inc_account': False, |
118 | 'empty_exp_account': False, |
119 | @@ -210,6 +216,7 @@ |
120 | 'state': 'draft', |
121 | 'message': '', |
122 | 'has_not_deactivable': False, |
123 | + 'has_not_activable': False, |
124 | } |
125 | self.write(cr, uid, ids, vals, context=context) |
126 | |
127 | @@ -309,6 +316,7 @@ |
128 | upd_errors_obj = self.pool.get('product.mass.update.errors') |
129 | |
130 | p_mass_upd = self.browse(cr, uid, ids[0], context=context) |
131 | + instance_level = self.pool.get('res.users').browse(cr, uid, uid, context=context).company_id.instance_id.level |
132 | try: |
133 | # For the progress bar |
134 | upd_progress_ids = upd_progress_obj.search(cr, uid, [('p_mass_upd_id', '=', p_mass_upd.id)], context=context) |
135 | @@ -318,6 +326,7 @@ |
136 | upd_progress_id = upd_progress_obj.create(cr, uid, {'p_mass_upd_id': p_mass_upd.id}, context=context) |
137 | |
138 | num_prod = 0 |
139 | + not_activated = [] |
140 | not_deactivated = [] |
141 | for prod in p_mass_upd.product_ids: |
142 | # Check procurement method |
143 | @@ -330,7 +339,10 @@ |
144 | p_suppinfo_obj.create(cr, uid, {'product_id': prod.product_tmpl_id.id, 'name': p_mass_upd.seller_id.id, 'sequence': 0}, context=context) |
145 | if p_mass_upd.active_product: |
146 | if not prod.active and p_mass_upd.active_product == 'yes': |
147 | - prod_obj.reactivate_product(cr, uid, [prod.id], context=context) |
148 | + if instance_level in ['project', 'coordo'] and prod.standard_ok == 'non_standard_local': |
149 | + not_activated.append(prod.id) |
150 | + else: |
151 | + prod_obj.reactivate_product(cr, uid, [prod.id], context=context) |
152 | elif prod.active and p_mass_upd.active_product == 'no': |
153 | deactivated = prod_obj.deactivate_product(cr, uid, [prod.id], context=context) |
154 | if deactivated != True: # If doesn't return True, the product has not been deactivated |
155 | @@ -339,24 +351,43 @@ |
156 | percent_completed = float(num_prod) / float(len(p_mass_upd.product_ids)) * 100.0 |
157 | upd_progress_obj.write(cr, uid, upd_progress_id, {'percent_completed': percent_completed}, context=context) |
158 | |
159 | - if not_deactivated: |
160 | + p_mass_upd_vals = {} |
161 | + msg = '' |
162 | + if not_deactivated or not_activated: |
163 | cr.rollback() # Rollback deactivation and product seller creation |
164 | - for wiz_prod_error in self.pool.get('product.deactivation.error').browse(cr, uid, not_deactivated): |
165 | - err_vals = { |
166 | - 'p_mass_upd_id': p_mass_upd.id, |
167 | - 'product_id': wiz_prod_error.product_id.id, |
168 | - 'stock_exist': wiz_prod_error.stock_exist, |
169 | - 'open_documents': wiz_prod_error.error_lines and ', '.join([x.doc_ref for x in wiz_prod_error.error_lines if x.doc_ref]) or '', |
170 | - } |
171 | - upd_errors_obj.create(cr, uid, err_vals, context=context) |
172 | - |
173 | - p_mass_upd_vals = { |
174 | - 'has_not_deactivable': True, |
175 | - 'message': _('Some products could not be deactivated. No product will be changed until all of them can be deactivated. Please check the corresponding tab.'), |
176 | + if not_deactivated: |
177 | + for wiz_prod_error in self.pool.get('product.deactivation.error').browse(cr, uid, not_deactivated): |
178 | + err_vals = { |
179 | + 'p_mass_upd_id': p_mass_upd.id, |
180 | + 'product_id': wiz_prod_error.product_id.id, |
181 | + 'stock_exist': wiz_prod_error.stock_exist, |
182 | + 'open_documents': wiz_prod_error.error_lines and ', '.join([x.doc_ref for x in wiz_prod_error.error_lines if x.doc_ref]) or '', |
183 | + 'not_deactivable': True, |
184 | + } |
185 | + upd_errors_obj.create(cr, uid, err_vals, context=context) |
186 | + |
187 | + msg += _('Some products could not be deactivated. No product will be changed until all of them can be deactivated.\n') |
188 | + p_mass_upd_vals.update({'has_not_deactivable': True}) |
189 | + if not_activated: |
190 | + for prod_id in not_activated: |
191 | + err_vals = { |
192 | + 'p_mass_upd_id': p_mass_upd.id, |
193 | + 'product_id': prod_id, |
194 | + 'not_activable': True, |
195 | + } |
196 | + upd_errors_obj.create(cr, uid, err_vals, context=context) |
197 | + |
198 | + msg += _('Some NSL (Non-standard Local) products could not be activated to ensure that there is no duplicate “Local” product. No product will be changed and those NSL products should be activated manually.\n') |
199 | + p_mass_upd_vals.update({'has_not_activable': True}) |
200 | + |
201 | + msg += _('Please check the corresponding tab.') |
202 | + p_mass_upd_vals.update({ |
203 | + 'message': msg, |
204 | 'state': 'error', |
205 | - } |
206 | + }) |
207 | self.write(cr, uid, p_mass_upd.id, p_mass_upd_vals, context=context) |
208 | - else: |
209 | + |
210 | + if not not_deactivated and not not_activated: |
211 | prod_obj.write(cr, uid, [prod.id for prod in p_mass_upd.product_ids], vals, context=context) |
212 | user_id = self.pool.get('res.users').browse(cr, uid, uid, context=context).id |
213 | |
214 | @@ -366,9 +397,11 @@ |
215 | |
216 | p_mass_upd_vals = { |
217 | 'has_not_deactivable': False, |
218 | + 'has_not_activable': False, |
219 | 'date_done': time.strftime('%Y-%m-%d %H:%M'), |
220 | 'user_id': user_id, |
221 | 'state': 'done', |
222 | + 'message': '', |
223 | } |
224 | self.write(cr, uid, p_mass_upd.id, p_mass_upd_vals, context=context) |
225 | except Exception as e: |
226 | |
227 | === modified file 'bin/addons/product/wizard/product_mass_update_view.xml' |
228 | --- bin/addons/product/wizard/product_mass_update_view.xml 2019-10-28 16:42:13 +0000 |
229 | +++ bin/addons/product/wizard/product_mass_update_view.xml 2020-03-27 09:04:35 +0000 |
230 | @@ -43,7 +43,8 @@ |
231 | </group> |
232 | </group> |
233 | <field name="has_not_deactivable" invisible="1" /> |
234 | - <group colspan="4" attrs="{'invisible':[('has_not_deactivable', '=', False), ('state', 'not in', ['in_progress', 'error'])]}"> |
235 | + <field name="has_not_activable" invisible="1" /> |
236 | + <group colspan="4" attrs="{'invisible':[('has_not_deactivable', '=', False), ('has_not_activable', '=', False), ('state', 'not in', ['in_progress', 'error'])]}"> |
237 | <html> |
238 | <style> |
239 | #prod_mass_upd_error p, #prod_mass_upd_error span, #prod_mass_upd_error textarea { |
240 | @@ -88,6 +89,13 @@ |
241 | </tree> |
242 | </field> |
243 | </page> |
244 | + <page string="Non-Activable Products" attrs="{'invisible': [('has_not_activable', '=', False)]}"> |
245 | + <field name="not_activated_product_ids" colspan="4" nolabel="1" readonly="1"> |
246 | + <tree string="Products" noteditable="1"> |
247 | + <field name="product_id" /> |
248 | + </tree> |
249 | + </field> |
250 | + </page> |
251 | </notebook> |
252 | <group colspan="4"> |
253 | <field name="state" colspan="2" /> |
254 | @@ -148,7 +156,8 @@ |
255 | <field name="name" attrs="{'readonly': [('state', '!=', 'draft')]}" required="True"/> |
256 | <field name="type_of_ed_bn" required="True" attrs="{'readonly': [('state', '!=', 'draft')]}" /> |
257 | <field name="has_not_deactivable" invisible="1" /> |
258 | - <group colspan="4" attrs="{'invisible':[('has_not_deactivable', '=', False), ('state', 'not in', ['in_progress', 'error'])]}"> |
259 | + <field name="has_not_activable" invisible="1" /> |
260 | + <group colspan="4" attrs="{'invisible':[('has_not_deactivable', '=', False), ('has_not_activable', '=', False), ('state', 'not in', ['in_progress', 'error'])]}"> |
261 | <html> |
262 | <style> |
263 | #prod_mass_upd_error p, #prod_mass_upd_error span, #prod_mass_upd_error textarea { |
264 | |
265 | === modified file 'bin/addons/product_attributes/product_attributes.py' |
266 | --- bin/addons/product_attributes/product_attributes.py 2020-03-19 16:19:46 +0000 |
267 | +++ bin/addons/product_attributes/product_attributes.py 2020-03-27 09:04:35 +0000 |
268 | @@ -1578,9 +1578,22 @@ |
269 | ''' |
270 | Re-activate product. |
271 | ''' |
272 | + wiz_obj = self.pool.get('product.ask.activate.wizard') |
273 | + |
274 | + instance_level = self.pool.get('res.users').browse(cr, uid, uid, context=context).company_id.instance_id.level |
275 | for product in self.browse(cr, uid, ids, context=context): |
276 | if product.active: |
277 | raise osv.except_osv(_('Error'), _('The product [%s] %s is already active.') % (product.default_code, product.name)) |
278 | + if instance_level in ['project', 'coordo'] and product.standard_ok == 'non_standard_local': |
279 | + return { |
280 | + 'type': 'ir.actions.act_window', |
281 | + 'res_model': 'product.ask.activate.wizard', |
282 | + 'view_type': 'form', |
283 | + 'view_mode': 'form', |
284 | + 'res_id': wiz_obj.create(cr, uid, {'product_id': product.id}, context=context), |
285 | + 'target': 'new', |
286 | + 'context': context |
287 | + } |
288 | |
289 | self.write(cr, uid, ids, {'active': True}, context=context) |
290 | |
291 | @@ -2591,4 +2604,30 @@ |
292 | change_bn_ed_mandatory_wizard() |
293 | |
294 | |
295 | +class product_ask_activate_wizard(osv.osv_memory): |
296 | + _name = 'product.ask.activate.wizard' |
297 | + |
298 | + _columns = { |
299 | + 'product_id': fields.many2one('product.product', string='Product', required=True), |
300 | + } |
301 | + |
302 | + def do_activate_product(self, cr, uid, ids, context=None): |
303 | + if context is None: |
304 | + context = {} |
305 | + |
306 | + prod_id = self.browse(cr, uid, ids[0], context=context).product_id.id |
307 | + self.pool.get('product.product').write(cr, uid, prod_id, {'active': True}, context=context) |
308 | + |
309 | + return {'type': 'ir.actions.act_window_close'} |
310 | + |
311 | + def button_close(self, cr, uid, ids, context=None): |
312 | + if context is None: |
313 | + context = {} |
314 | + |
315 | + return {'type': 'ir.actions.act_window_close'} |
316 | + |
317 | + |
318 | +product_ask_activate_wizard() |
319 | + |
320 | + |
321 | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: |
322 | |
323 | === modified file 'bin/addons/product_attributes/product_attributes_view.xml' |
324 | --- bin/addons/product_attributes/product_attributes_view.xml 2020-02-19 10:24:30 +0000 |
325 | +++ bin/addons/product_attributes/product_attributes_view.xml 2020-03-27 09:04:35 +0000 |
326 | @@ -872,5 +872,26 @@ |
327 | <menuitem action="product.previous_mass_update_action" id="menu_import_request" sequence="1" parent="product.parent_product_mass_update" /> |
328 | <menuitem action="product.products_bn_ed_mass_update_action" id="products_bn_ed_mass_update_menu" sequence="20" parent="product.parent_product_mass_update" /> |
329 | |
330 | + <record id="product_ask_activate_wizard_form_view" model="ir.ui.view"> |
331 | + <field name="name">product.ask.activate.wizard.form.view</field> |
332 | + <field name="model">product.ask.activate.wizard</field> |
333 | + <field name="type">form</field> |
334 | + <field name="arch" type="xml"> |
335 | + <form string="Warning"> |
336 | + <field name="product_id" invisible="1" /> |
337 | + <group colspan="4" col="1"> |
338 | + <html> |
339 | + <h3 style="text-align: center; margin: 10px"><translate>This is an NSL (Non-standard Local) product, please ensure that there is no duplicate “Local” product with which this product should be merged. If you activate and start to use this product it will no longer be possible to merge it with another.</translate></h3> |
340 | + </html> |
341 | + </group> |
342 | + <group colspan="4" col="2"> |
343 | + <separator string="Actions" colspan="2" /> |
344 | + <button name="do_activate_product" string="OK" type="object" icon="gtk-ok" colspan="1" /> |
345 | + <button name="button_close" string="Cancel" type="object" icon="gtk-cancel" colspan="1" /> |
346 | + </group> |
347 | + </form> |
348 | + </field> |
349 | + </record> |
350 | + |
351 | </data> |
352 | </openerp> |