Merge lp:~camptocamp/stock-logistic-warehouse/7.0-port-stock-orderpoint-creator-mdh into lp:stock-logistic-warehouse

Proposed by Matthieu Dietrich @ camptocamp
Status: Needs review
Proposed branch: lp:~camptocamp/stock-logistic-warehouse/7.0-port-stock-orderpoint-creator-mdh
Merge into: lp:stock-logistic-warehouse
Diff against target: 375 lines (+121/-95)
7 files modified
stock_orderpoint_creator/__init__.py (+3/-4)
stock_orderpoint_creator/__openerp__.py (+23/-12)
stock_orderpoint_creator/base_product_config_template.py (+13/-17)
stock_orderpoint_creator/orderpoint_template.py (+34/-14)
stock_orderpoint_creator/wizard/__init__.py (+1/-2)
stock_orderpoint_creator/wizard/orderpoint_creator.py (+18/-18)
stock_orderpoint_creator/wizard/orderpoint_creator_view.xml (+29/-28)
To merge this branch: bzr merge lp:~camptocamp/stock-logistic-warehouse/7.0-port-stock-orderpoint-creator-mdh
Reviewer Review Type Date Requested Status
Stock and Logistic Core Editors Pending
Review via email: mp+220466@code.launchpad.net

Commit message

[IMP] 7.0 version of stock_orderpoint_creator

Description of the change

Port of the existing module stock_orderpoint_creator for 7.0.

Modified:
- view to be valid in 7.0,
- removed the redefinition of the field product_id, since the product's UOM is verified by a constraint now in procurement; it's still there but mandatory.

To post a comment you must log in.
36. By Yannick Vaucher @ Camptocamp on 2014-06-23

remove unused import

37. By Yannick Vaucher @ Camptocamp on 2014-06-23

[PEP8] and cleaning

38. By Yannick Vaucher @ Camptocamp on 2014-06-23

Port wizard view to v 7

39. By Yannick Vaucher @ Camptocamp on 2014-06-23

improve __openerp__.py

40. By Yannick Vaucher @ Camptocamp on 2014-06-23

revert changes in rev 35 removing product_id overwrite and add some more comments

41. By Yannick Vaucher @ Camptocamp on 2014-06-23

add explanations on wizard view

42. By Yannick Vaucher @ Camptocamp on 2014-06-25

override constraint to get ride of it in template

Unmerged revisions

42. By Yannick Vaucher @ Camptocamp on 2014-06-25

override constraint to get ride of it in template

41. By Yannick Vaucher @ Camptocamp on 2014-06-23

add explanations on wizard view

40. By Yannick Vaucher @ Camptocamp on 2014-06-23

revert changes in rev 35 removing product_id overwrite and add some more comments

39. By Yannick Vaucher @ Camptocamp on 2014-06-23

improve __openerp__.py

38. By Yannick Vaucher @ Camptocamp on 2014-06-23

Port wizard view to v 7

37. By Yannick Vaucher @ Camptocamp on 2014-06-23

[PEP8] and cleaning

36. By Yannick Vaucher @ Camptocamp on 2014-06-23

remove unused import

35. By Matthieu Dietrich @ camptocamp on 2014-05-21

[IMP] 7.0 version for stock_orderpoint_creator

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'stock_orderpoint_creator/__init__.py'
2--- stock_orderpoint_creator/__init__.py 2012-05-24 08:50:35 +0000
3+++ stock_orderpoint_creator/__init__.py 2014-06-25 10:47:49 +0000
4@@ -18,7 +18,6 @@
5 # along with this program. If not, see <http://www.gnu.org/licenses/>.
6 #
7 ##############################################################################
8-
9-from . import base_product_config_template
10-from . import orderpoint_template
11-import wizard
12+from . import base_product_config_template # noqa
13+from . import orderpoint_template # noqa
14+import wizard # noqa
15
16=== modified file 'stock_orderpoint_creator/__openerp__.py'
17--- stock_orderpoint_creator/__openerp__.py 2013-02-13 08:46:41 +0000
18+++ stock_orderpoint_creator/__openerp__.py 2014-06-25 10:47:49 +0000
19@@ -1,8 +1,8 @@
20 # -*- coding: utf-8 -*-
21 ##############################################################################
22 #
23-# Author: Yannick Vaucher (Camptocamp)
24-# Copyright 2012 Camptocamp SA
25+# Author: Yannick Vaucher, Matthieu Dietrich (Camptocamp)
26+# Copyright 2012-2014 Camptocamp SA
27 #
28 # This program is free software: you can redistribute it and/or modify
29 # it under the terms of the GNU Affero General Public License as
30@@ -19,25 +19,36 @@
31 #
32 ##############################################################################
33
34-{'name': 'Configuration of order point in mass',
35+{'name': 'Order point creator',
36+ 'summary': 'Configuration of order point in mass',
37 'version': '1.0',
38 'author': 'Camptocamp',
39- 'maintainer': 'Camptocamp',
40 'category': 'Warehouse',
41+ 'license': 'AGPL-3',
42 'complexity': 'easy', #easy, normal, expert
43+ 'website': "http://www.camptocamp.com",
44 'depends': ['procurement'],
45 'description': """
46-Add a wizard to configure massively order points for multiple product""",
47+Order point creator
48+===================
49+
50+Add a wizard to configure massively order points for multiple product
51+
52+Contributors
53+------------
54+
55+ * Yannick Vaucher <yannick.vaucher@camptocamp.com>
56+ * Matthieu Dietrich <matthieu.dietrich@camptocamp.com>
57+
58+""",
59 'website': 'http://www.openerp.com',
60- 'init_xml': [],
61- 'update_xml': ["wizard/orderpoint_creator_view.xml", "security/ir.model.access.csv"],
62- 'demo_xml': [],
63+ 'demo': [],
64+ 'data': ["wizard/orderpoint_creator_view.xml",
65+ "security/ir.model.access.csv",
66+ ],
67 'test': [],
68- 'installable': False,
69- 'images': [],
70+ 'installable': True,
71 'auto_install': False,
72- 'license': 'AGPL-3',
73- 'active': False,
74 }
75
76 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
77
78=== modified file 'stock_orderpoint_creator/base_product_config_template.py'
79--- stock_orderpoint_creator/base_product_config_template.py 2012-05-31 09:30:50 +0000
80+++ stock_orderpoint_creator/base_product_config_template.py 2014-06-25 10:47:49 +0000
81@@ -22,10 +22,10 @@
82 """ Base template for product config """
83 from openerp.osv.orm import browse_record, browse_record_list
84
85+
86 class BaseProductConfigTemplate():
87 """ Abstract class for product config """
88
89-
90 def _get_model(self):
91 """ Get the model for which this template is defined
92
93@@ -33,42 +33,41 @@
94 is represented by this template
95 """
96 model = self._inherit
97- model_obj = self.pool.get(model)
98+ model_obj = self.pool[model]
99 return model_obj
100
101- def _get_ids_2_clean(self, cursor, uid, template_br,
102+ def _get_ids_2_clean(self, cr, uid, template_br,
103 product_ids, context=None):
104 """ hook to select model specific objects to clean
105 return must return a list of id"""
106 return []
107
108- def _disable_old_instances(self, cursor, uid, template_br_list,
109+ def _disable_old_instances(self, cr, uid, template_br_list,
110 product_ids, context=None):
111 """ Clean old instance by setting those inactives """
112 model_obj = self._get_model()
113 for template in template_br_list:
114- ids2clean = self._get_ids_2_clean(cursor, uid, template,
115+ ids2clean = self._get_ids_2_clean(cr, uid, template,
116 product_ids, context=context)
117 if self._clean_mode == 'deactivate':
118- model_obj.write(cursor, uid, ids2clean,
119+ model_obj.write(cr, uid, ids2clean,
120 {'active': False}, context=context)
121 elif self._clean_mode == 'unlink':
122- model_obj.unlink(cursor, uid, ids2clean, context=context)
123-
124-
125- def create_instances(self, cursor, uid, template_br,
126+ model_obj.unlink(cr, uid, ids2clean, context=context)
127+
128+ def create_instances(self, cr, uid, template_br,
129 product_ids, context=None):
130 """ Create instances of model using template inherited model """
131 if not isinstance(product_ids, list):
132 product_ids = [product_ids]
133
134- # data = self.copy_data(cursor, uid, template_br.id, context=context)
135- # copy data will not work in all case and may retrieve erronus value
136+ # not using self.copy_data(cr, uid, template_br.id, context=context)
137+ # as copy data will not work in all case and may retrieve erronus value
138
139 model_obj = self._get_model()
140
141 data = {}
142- #May rais error on function fields in future
143+ #May raise error on function fields in future
144 for key in model_obj._columns.keys():
145 tmp = template_br[key]
146 if isinstance(tmp, browse_record):
147@@ -79,7 +78,4 @@
148
149 for product_id in product_ids:
150 data['product_id'] = product_id
151- model_obj.create(cursor, uid, data, context=context)
152-
153-
154-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
155+ model_obj.create(cr, uid, data, context=context)
156
157=== modified file 'stock_orderpoint_creator/orderpoint_template.py'
158--- stock_orderpoint_creator/orderpoint_template.py 2012-05-24 14:07:16 +0000
159+++ stock_orderpoint_creator/orderpoint_template.py 2014-06-25 10:47:49 +0000
160@@ -1,8 +1,8 @@
161 # -*- coding: utf-8 -*-
162 ##############################################################################
163 #
164-# Author: Yannick Vaucher (Camptocamp)
165-# Copyright 2012 Camptocamp SA
166+# Author: Yannick Vaucher, Matthieu Dietrich (Camptocamp)
167+# Copyright 2012-2014 Camptocamp SA
168 #
169 # This program is free software: you can redistribute it and/or modify
170 # it under the terms of the GNU Affero General Public License as
171@@ -24,29 +24,49 @@
172 from openerp.osv.orm import Model, fields
173 from base_product_config_template import BaseProductConfigTemplate
174
175+
176 class OrderpointTemplate(BaseProductConfigTemplate, Model):
177- """ Template for orderpoints """
178+ """ Template for orderpoints
179+
180+ Here we use same model as stock.warhouse.orderpoint but set product_id
181+ as non mandatory as we cannot remove it. This field will be ignored.
182+
183+ This has the advantage to ensure orderpoint and orderpoint template have
184+ same fields.
185+
186+ _table is redifined to separate templates from orderpoints
187+ """
188 _name = 'stock.warehouse.orderpoint.template'
189
190 _inherit = 'stock.warehouse.orderpoint'
191 _table = 'stock_warehouse_orderpoint_template'
192 _clean_mode = 'deactivate'
193
194-
195 _columns = {
196- 'product_id': fields.many2one('product.product',
197- 'Product',
198- required=False,
199- ondelete='cascade',
200- domain=[('type','=','product')]),
201- }
202+ 'product_id': fields.many2one(
203+ 'product.product',
204+ 'Product',
205+ required=False,
206+ ondelete='cascade',
207+ domain=[('type','=','product')]),
208+ }
209
210- def _get_ids_2_clean(self, cursor, uid, template_br, product_ids, context=None):
211+ def _get_ids_2_clean(self, cr, uid, template_br, product_ids,
212+ context=None):
213 """ hook to select model specific objects to clean
214 return must return a list of id"""
215 model_obj = self._get_model()
216- ids_to_del = model_obj.search(cursor, uid,
217- [('product_id', 'in', product_ids)])
218+ ids_to_del = model_obj.search(cr, uid,
219+ [('product_id', 'in', product_ids)],
220+ context=context)
221 return ids_to_del
222
223-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
224+ def _check_product_uom(self, cr, uid, ids, context=None):
225+ '''
226+ Overwrite constraint _check_product_uom
227+ '''
228+ return True
229+
230+ _constraints = [
231+ (_check_product_uom, 'Overriding constraint', ['product_id', 'product_uom']),
232+ ]
233
234=== modified file 'stock_orderpoint_creator/wizard/__init__.py'
235--- stock_orderpoint_creator/wizard/__init__.py 2012-05-23 15:45:56 +0000
236+++ stock_orderpoint_creator/wizard/__init__.py 2014-06-25 10:47:49 +0000
237@@ -18,5 +18,4 @@
238 # along with this program. If not, see <http://www.gnu.org/licenses/>.
239 #
240 ##############################################################################
241-
242-from . import orderpoint_creator
243+from . import orderpoint_creator # noqa
244
245=== modified file 'stock_orderpoint_creator/wizard/orderpoint_creator.py'
246--- stock_orderpoint_creator/wizard/orderpoint_creator.py 2012-05-24 14:07:16 +0000
247+++ stock_orderpoint_creator/wizard/orderpoint_creator.py 2014-06-25 10:47:49 +0000
248@@ -26,44 +26,44 @@
249
250 _template_register = ['orderpoint_template_id']
251
252+
253 class OrderpointCreator(TransientModel):
254 _name = 'stock.warehouse.orderpoint.creator'
255 _description = 'Orderpoint Creator'
256
257- _columns = {'orderpoint_template_id': fields.many2many(
258- 'stock.warehouse.orderpoint.template',
259- rel='order_point_creator_rel',
260- string='Stock rule template')
261+ _columns = {
262+ 'orderpoint_template_id': fields.many2many(
263+ 'stock.warehouse.orderpoint.template',
264+ rel='order_point_creator_rel',
265+ string='Stock rule template')
266 }
267
268-
269 def _get_template_register(self):
270 """return a list of the field names which defines a template
271 This is a hook to allow expending the list of template"""
272 return _template_register
273
274-
275- def action_configure(self, cursor, uid, wiz_id, context=None):
276+ def action_configure(self, cr, uid, wiz_id, context=None):
277 """ action to retrieve wizard data and launch creation of items """
278
279- product_ids = context['active_ids']
280+ product_ids = context.get('active_ids')
281+ assert product_ids
282+
283 if isinstance(wiz_id, list):
284 wiz_id = wiz_id[0]
285- current = self.browse(cursor, uid, wiz_id, context=context)
286- for template_field in self._get_template_register():
287- template_br_list = current[template_field]
288+ this = self.browse(cr, uid, wiz_id, context=context)
289+ for template_field in self._get_template_register():
290+ template_br_list = this[template_field]
291 if template_br_list:
292 if isinstance(template_br_list, browse_record):
293 template_br_list = [template_br_list]
294 template_model = template_br_list[0]._model._name
295 template_obj = self.pool.get(template_model)
296- template_obj._disable_old_instances(cursor, uid, template_br_list,
297- product_ids, context=context)
298+ template_obj._disable_old_instances(cr, uid, template_br_list,
299+ product_ids,
300+ context=context)
301 for template_br in template_br_list:
302- template_obj.create_instances(cursor, uid, template_br,
303- product_ids, context=context)
304+ template_obj.create_instances(cr, uid, template_br,
305+ product_ids, context=context)
306
307 return {}
308-
309-
310-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
311
312=== modified file 'stock_orderpoint_creator/wizard/orderpoint_creator_view.xml'
313--- stock_orderpoint_creator/wizard/orderpoint_creator_view.xml 2012-05-24 14:07:16 +0000
314+++ stock_orderpoint_creator/wizard/orderpoint_creator_view.xml 2014-06-25 10:47:49 +0000
315@@ -1,31 +1,32 @@
316 <?xml version="1.0" encoding="utf-8"?>
317 <openerp>
318- <data>
319-
320- <record id="orderpoint_creator_view" model="ir.ui.view">
321- <field name="name">stock.warehouse.orderpoint.creator</field>
322- <field name="model">stock.warehouse.orderpoint.creator</field>
323- <field name="type">form</field>
324- <field name="arch" type="xml">
325- <form>
326- <group string="templates" colspan="4">
327- <field name="orderpoint_template_id" colspan="4"/>
328- </group>
329- <group colspan="2" col="4">
330- <button special="cancel" string="Cancel" icon="gtk-cancel"/>
331- <button name="action_configure" string="Apply" type="object" icon="gtk-execute"/>
332- </group>
333- </form>
334- </field>
335- </record>
336-
337- <act_window name="Product warehouse config"
338- res_model="stock.warehouse.orderpoint.creator"
339- src_model="product.product"
340- view_mode="form"
341- target="new"
342- key2="client_action_multi"
343- id="act_create_product_conf"/>
344-
345- </data>
346+ <data>
347+
348+ <record id="orderpoint_creator_view" model="ir.ui.view">
349+ <field name="name">stock.warehouse.orderpoint.creator</field>
350+ <field name="model">stock.warehouse.orderpoint.creator</field>
351+ <field name="arch" type="xml">
352+ <form string="Product warehouse config" version="7.0">
353+ <label string="This wizard will apply the following orderpoint to selected product(s)"/>
354+ <group string="Templates" colspan="4">
355+ <field name="orderpoint_template_id" colspan="4"/>
356+ </group>
357+ <footer>
358+ <button name="action_configure" string="Apply" type="object" class="oe_highlight" icon="gtk-execute"/>
359+ or
360+ <button string="Cancel" class="oe_link" special="cancel"/>
361+ </footer>
362+ </form>
363+ </field>
364+ </record>
365+
366+ <act_window name="Product warehouse config"
367+ res_model="stock.warehouse.orderpoint.creator"
368+ src_model="product.product"
369+ view_mode="form"
370+ target="new"
371+ key2="client_action_multi"
372+ id="act_create_product_conf"/>
373+
374+ </data>
375 </openerp>

Subscribers

People subscribed via source and target branches