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

remove unused import

37. By Yannick Vaucher @ Camptocamp

[PEP8] and cleaning

38. By Yannick Vaucher @ Camptocamp

Port wizard view to v 7

39. By Yannick Vaucher @ Camptocamp

improve __openerp__.py

40. By Yannick Vaucher @ Camptocamp

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

41. By Yannick Vaucher @ Camptocamp

add explanations on wizard view

42. By Yannick Vaucher @ Camptocamp

override constraint to get ride of it in template

Unmerged revisions

42. By Yannick Vaucher @ Camptocamp

override constraint to get ride of it in template

41. By Yannick Vaucher @ Camptocamp

add explanations on wizard view

40. By Yannick Vaucher @ Camptocamp

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

39. By Yannick Vaucher @ Camptocamp

improve __openerp__.py

38. By Yannick Vaucher @ Camptocamp

Port wizard view to v 7

37. By Yannick Vaucher @ Camptocamp

[PEP8] and cleaning

36. By Yannick Vaucher @ Camptocamp

remove unused import

35. By Matthieu Dietrich @ camptocamp

[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
=== modified file 'stock_orderpoint_creator/__init__.py'
--- stock_orderpoint_creator/__init__.py 2012-05-24 08:50:35 +0000
+++ stock_orderpoint_creator/__init__.py 2014-06-25 10:47:49 +0000
@@ -18,7 +18,6 @@
18# along with this program. If not, see <http://www.gnu.org/licenses/>.18# along with this program. If not, see <http://www.gnu.org/licenses/>.
19#19#
20##############################################################################20##############################################################################
2121from . import base_product_config_template # noqa
22from . import base_product_config_template22from . import orderpoint_template # noqa
23from . import orderpoint_template23import wizard # noqa
24import wizard
2524
=== modified file 'stock_orderpoint_creator/__openerp__.py'
--- stock_orderpoint_creator/__openerp__.py 2013-02-13 08:46:41 +0000
+++ stock_orderpoint_creator/__openerp__.py 2014-06-25 10:47:49 +0000
@@ -1,8 +1,8 @@
1# -*- coding: utf-8 -*-1# -*- coding: utf-8 -*-
2##############################################################################2##############################################################################
3#3#
4# Author: Yannick Vaucher (Camptocamp)4# Author: Yannick Vaucher, Matthieu Dietrich (Camptocamp)
5# Copyright 2012 Camptocamp SA5# Copyright 2012-2014 Camptocamp SA
6#6#
7# This program is free software: you can redistribute it and/or modify7# This program is free software: you can redistribute it and/or modify
8# it under the terms of the GNU Affero General Public License as8# it under the terms of the GNU Affero General Public License as
@@ -19,25 +19,36 @@
19#19#
20##############################################################################20##############################################################################
2121
22{'name': 'Configuration of order point in mass',22{'name': 'Order point creator',
23 'summary': 'Configuration of order point in mass',
23 'version': '1.0',24 'version': '1.0',
24 'author': 'Camptocamp',25 'author': 'Camptocamp',
25 'maintainer': 'Camptocamp',
26 'category': 'Warehouse',26 'category': 'Warehouse',
27 'license': 'AGPL-3',
27 'complexity': 'easy', #easy, normal, expert28 'complexity': 'easy', #easy, normal, expert
29 'website': "http://www.camptocamp.com",
28 'depends': ['procurement'],30 'depends': ['procurement'],
29 'description': """31 'description': """
30Add a wizard to configure massively order points for multiple product""",32Order point creator
33===================
34
35Add a wizard to configure massively order points for multiple product
36
37Contributors
38------------
39
40 * Yannick Vaucher <yannick.vaucher@camptocamp.com>
41 * Matthieu Dietrich <matthieu.dietrich@camptocamp.com>
42
43""",
31 'website': 'http://www.openerp.com',44 'website': 'http://www.openerp.com',
32 'init_xml': [],45 'demo': [],
33 'update_xml': ["wizard/orderpoint_creator_view.xml", "security/ir.model.access.csv"],46 'data': ["wizard/orderpoint_creator_view.xml",
34 'demo_xml': [],47 "security/ir.model.access.csv",
48 ],
35 'test': [],49 'test': [],
36 'installable': False,50 'installable': True,
37 'images': [],
38 'auto_install': False,51 'auto_install': False,
39 'license': 'AGPL-3',
40 'active': False,
41}52}
4253
43# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:54# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
4455
=== modified file 'stock_orderpoint_creator/base_product_config_template.py'
--- stock_orderpoint_creator/base_product_config_template.py 2012-05-31 09:30:50 +0000
+++ stock_orderpoint_creator/base_product_config_template.py 2014-06-25 10:47:49 +0000
@@ -22,10 +22,10 @@
22""" Base template for product config """22""" Base template for product config """
23from openerp.osv.orm import browse_record, browse_record_list23from openerp.osv.orm import browse_record, browse_record_list
2424
25
25class BaseProductConfigTemplate():26class BaseProductConfigTemplate():
26 """ Abstract class for product config """27 """ Abstract class for product config """
2728
28
29 def _get_model(self):29 def _get_model(self):
30 """ Get the model for which this template is defined30 """ Get the model for which this template is defined
3131
@@ -33,42 +33,41 @@
33 is represented by this template33 is represented by this template
34 """34 """
35 model = self._inherit35 model = self._inherit
36 model_obj = self.pool.get(model)36 model_obj = self.pool[model]
37 return model_obj37 return model_obj
3838
39 def _get_ids_2_clean(self, cursor, uid, template_br,39 def _get_ids_2_clean(self, cr, uid, template_br,
40 product_ids, context=None):40 product_ids, context=None):
41 """ hook to select model specific objects to clean41 """ hook to select model specific objects to clean
42 return must return a list of id"""42 return must return a list of id"""
43 return []43 return []
4444
45 def _disable_old_instances(self, cursor, uid, template_br_list,45 def _disable_old_instances(self, cr, uid, template_br_list,
46 product_ids, context=None):46 product_ids, context=None):
47 """ Clean old instance by setting those inactives """47 """ Clean old instance by setting those inactives """
48 model_obj = self._get_model()48 model_obj = self._get_model()
49 for template in template_br_list:49 for template in template_br_list:
50 ids2clean = self._get_ids_2_clean(cursor, uid, template,50 ids2clean = self._get_ids_2_clean(cr, uid, template,
51 product_ids, context=context)51 product_ids, context=context)
52 if self._clean_mode == 'deactivate':52 if self._clean_mode == 'deactivate':
53 model_obj.write(cursor, uid, ids2clean,53 model_obj.write(cr, uid, ids2clean,
54 {'active': False}, context=context)54 {'active': False}, context=context)
55 elif self._clean_mode == 'unlink':55 elif self._clean_mode == 'unlink':
56 model_obj.unlink(cursor, uid, ids2clean, context=context)56 model_obj.unlink(cr, uid, ids2clean, context=context)
5757
5858 def create_instances(self, cr, uid, template_br,
59 def create_instances(self, cursor, uid, template_br,
60 product_ids, context=None):59 product_ids, context=None):
61 """ Create instances of model using template inherited model """60 """ Create instances of model using template inherited model """
62 if not isinstance(product_ids, list):61 if not isinstance(product_ids, list):
63 product_ids = [product_ids]62 product_ids = [product_ids]
6463
65 # data = self.copy_data(cursor, uid, template_br.id, context=context)64 # not using self.copy_data(cr, uid, template_br.id, context=context)
66 # copy data will not work in all case and may retrieve erronus value65 # as copy data will not work in all case and may retrieve erronus value
6766
68 model_obj = self._get_model()67 model_obj = self._get_model()
6968
70 data = {}69 data = {}
71 #May rais error on function fields in future70 #May raise error on function fields in future
72 for key in model_obj._columns.keys():71 for key in model_obj._columns.keys():
73 tmp = template_br[key]72 tmp = template_br[key]
74 if isinstance(tmp, browse_record):73 if isinstance(tmp, browse_record):
@@ -79,7 +78,4 @@
7978
80 for product_id in product_ids:79 for product_id in product_ids:
81 data['product_id'] = product_id80 data['product_id'] = product_id
82 model_obj.create(cursor, uid, data, context=context)81 model_obj.create(cr, uid, data, context=context)
83
84
85# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
8682
=== modified file 'stock_orderpoint_creator/orderpoint_template.py'
--- stock_orderpoint_creator/orderpoint_template.py 2012-05-24 14:07:16 +0000
+++ stock_orderpoint_creator/orderpoint_template.py 2014-06-25 10:47:49 +0000
@@ -1,8 +1,8 @@
1# -*- coding: utf-8 -*-1# -*- coding: utf-8 -*-
2##############################################################################2##############################################################################
3#3#
4# Author: Yannick Vaucher (Camptocamp)4# Author: Yannick Vaucher, Matthieu Dietrich (Camptocamp)
5# Copyright 2012 Camptocamp SA5# Copyright 2012-2014 Camptocamp SA
6#6#
7# This program is free software: you can redistribute it and/or modify7# This program is free software: you can redistribute it and/or modify
8# it under the terms of the GNU Affero General Public License as8# it under the terms of the GNU Affero General Public License as
@@ -24,29 +24,49 @@
24from openerp.osv.orm import Model, fields24from openerp.osv.orm import Model, fields
25from base_product_config_template import BaseProductConfigTemplate25from base_product_config_template import BaseProductConfigTemplate
2626
27
27class OrderpointTemplate(BaseProductConfigTemplate, Model):28class OrderpointTemplate(BaseProductConfigTemplate, Model):
28 """ Template for orderpoints """29 """ Template for orderpoints
30
31 Here we use same model as stock.warhouse.orderpoint but set product_id
32 as non mandatory as we cannot remove it. This field will be ignored.
33
34 This has the advantage to ensure orderpoint and orderpoint template have
35 same fields.
36
37 _table is redifined to separate templates from orderpoints
38 """
29 _name = 'stock.warehouse.orderpoint.template'39 _name = 'stock.warehouse.orderpoint.template'
3040
31 _inherit = 'stock.warehouse.orderpoint'41 _inherit = 'stock.warehouse.orderpoint'
32 _table = 'stock_warehouse_orderpoint_template'42 _table = 'stock_warehouse_orderpoint_template'
33 _clean_mode = 'deactivate'43 _clean_mode = 'deactivate'
3444
35
36 _columns = {45 _columns = {
37 'product_id': fields.many2one('product.product',46 'product_id': fields.many2one(
38 'Product',47 'product.product',
39 required=False,48 'Product',
40 ondelete='cascade',49 required=False,
41 domain=[('type','=','product')]),50 ondelete='cascade',
42 }51 domain=[('type','=','product')]),
52 }
4353
44 def _get_ids_2_clean(self, cursor, uid, template_br, product_ids, context=None):54 def _get_ids_2_clean(self, cr, uid, template_br, product_ids,
55 context=None):
45 """ hook to select model specific objects to clean56 """ hook to select model specific objects to clean
46 return must return a list of id"""57 return must return a list of id"""
47 model_obj = self._get_model()58 model_obj = self._get_model()
48 ids_to_del = model_obj.search(cursor, uid,59 ids_to_del = model_obj.search(cr, uid,
49 [('product_id', 'in', product_ids)])60 [('product_id', 'in', product_ids)],
61 context=context)
50 return ids_to_del62 return ids_to_del
5163
52# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:64 def _check_product_uom(self, cr, uid, ids, context=None):
65 '''
66 Overwrite constraint _check_product_uom
67 '''
68 return True
69
70 _constraints = [
71 (_check_product_uom, 'Overriding constraint', ['product_id', 'product_uom']),
72 ]
5373
=== modified file 'stock_orderpoint_creator/wizard/__init__.py'
--- stock_orderpoint_creator/wizard/__init__.py 2012-05-23 15:45:56 +0000
+++ stock_orderpoint_creator/wizard/__init__.py 2014-06-25 10:47:49 +0000
@@ -18,5 +18,4 @@
18# along with this program. If not, see <http://www.gnu.org/licenses/>.18# along with this program. If not, see <http://www.gnu.org/licenses/>.
19#19#
20##############################################################################20##############################################################################
2121from . import orderpoint_creator # noqa
22from . import orderpoint_creator
2322
=== modified file 'stock_orderpoint_creator/wizard/orderpoint_creator.py'
--- stock_orderpoint_creator/wizard/orderpoint_creator.py 2012-05-24 14:07:16 +0000
+++ stock_orderpoint_creator/wizard/orderpoint_creator.py 2014-06-25 10:47:49 +0000
@@ -26,44 +26,44 @@
2626
27_template_register = ['orderpoint_template_id']27_template_register = ['orderpoint_template_id']
2828
29
29class OrderpointCreator(TransientModel):30class OrderpointCreator(TransientModel):
30 _name = 'stock.warehouse.orderpoint.creator'31 _name = 'stock.warehouse.orderpoint.creator'
31 _description = 'Orderpoint Creator'32 _description = 'Orderpoint Creator'
3233
33 _columns = {'orderpoint_template_id': fields.many2many(34 _columns = {
34 'stock.warehouse.orderpoint.template',35 'orderpoint_template_id': fields.many2many(
35 rel='order_point_creator_rel',36 'stock.warehouse.orderpoint.template',
36 string='Stock rule template')37 rel='order_point_creator_rel',
38 string='Stock rule template')
37 }39 }
3840
39
40 def _get_template_register(self):41 def _get_template_register(self):
41 """return a list of the field names which defines a template42 """return a list of the field names which defines a template
42 This is a hook to allow expending the list of template"""43 This is a hook to allow expending the list of template"""
43 return _template_register44 return _template_register
4445
4546 def action_configure(self, cr, uid, wiz_id, context=None):
46 def action_configure(self, cursor, uid, wiz_id, context=None):
47 """ action to retrieve wizard data and launch creation of items """47 """ action to retrieve wizard data and launch creation of items """
4848
49 product_ids = context['active_ids']49 product_ids = context.get('active_ids')
50 assert product_ids
51
50 if isinstance(wiz_id, list):52 if isinstance(wiz_id, list):
51 wiz_id = wiz_id[0]53 wiz_id = wiz_id[0]
52 current = self.browse(cursor, uid, wiz_id, context=context)54 this = self.browse(cr, uid, wiz_id, context=context)
53 for template_field in self._get_template_register():55 for template_field in self._get_template_register():
54 template_br_list = current[template_field]56 template_br_list = this[template_field]
55 if template_br_list:57 if template_br_list:
56 if isinstance(template_br_list, browse_record):58 if isinstance(template_br_list, browse_record):
57 template_br_list = [template_br_list]59 template_br_list = [template_br_list]
58 template_model = template_br_list[0]._model._name60 template_model = template_br_list[0]._model._name
59 template_obj = self.pool.get(template_model)61 template_obj = self.pool.get(template_model)
60 template_obj._disable_old_instances(cursor, uid, template_br_list,62 template_obj._disable_old_instances(cr, uid, template_br_list,
61 product_ids, context=context)63 product_ids,
64 context=context)
62 for template_br in template_br_list:65 for template_br in template_br_list:
63 template_obj.create_instances(cursor, uid, template_br,66 template_obj.create_instances(cr, uid, template_br,
64 product_ids, context=context)67 product_ids, context=context)
6568
66 return {}69 return {}
67
68
69# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
7070
=== modified file 'stock_orderpoint_creator/wizard/orderpoint_creator_view.xml'
--- stock_orderpoint_creator/wizard/orderpoint_creator_view.xml 2012-05-24 14:07:16 +0000
+++ stock_orderpoint_creator/wizard/orderpoint_creator_view.xml 2014-06-25 10:47:49 +0000
@@ -1,31 +1,32 @@
1<?xml version="1.0" encoding="utf-8"?>1<?xml version="1.0" encoding="utf-8"?>
2<openerp>2<openerp>
3 <data>3 <data>
44
5 <record id="orderpoint_creator_view" model="ir.ui.view">5 <record id="orderpoint_creator_view" model="ir.ui.view">
6 <field name="name">stock.warehouse.orderpoint.creator</field>6 <field name="name">stock.warehouse.orderpoint.creator</field>
7 <field name="model">stock.warehouse.orderpoint.creator</field>7 <field name="model">stock.warehouse.orderpoint.creator</field>
8 <field name="type">form</field>8 <field name="arch" type="xml">
9 <field name="arch" type="xml">9 <form string="Product warehouse config" version="7.0">
10 <form>10 <label string="This wizard will apply the following orderpoint to selected product(s)"/>
11 <group string="templates" colspan="4">11 <group string="Templates" colspan="4">
12 <field name="orderpoint_template_id" colspan="4"/>12 <field name="orderpoint_template_id" colspan="4"/>
13 </group>13 </group>
14 <group colspan="2" col="4">14 <footer>
15 <button special="cancel" string="Cancel" icon="gtk-cancel"/>15 <button name="action_configure" string="Apply" type="object" class="oe_highlight" icon="gtk-execute"/>
16 <button name="action_configure" string="Apply" type="object" icon="gtk-execute"/>16 or
17 </group>17 <button string="Cancel" class="oe_link" special="cancel"/>
18 </form>18 </footer>
19 </field>19 </form>
20 </record>20 </field>
2121 </record>
22 <act_window name="Product warehouse config"22
23 res_model="stock.warehouse.orderpoint.creator"23 <act_window name="Product warehouse config"
24 src_model="product.product"24 res_model="stock.warehouse.orderpoint.creator"
25 view_mode="form"25 src_model="product.product"
26 target="new"26 view_mode="form"
27 key2="client_action_multi"27 target="new"
28 id="act_create_product_conf"/>28 key2="client_action_multi"
2929 id="act_create_product_conf"/>
30 </data>30
31 </data>
31</openerp>32</openerp>

Subscribers

People subscribed via source and target branches