diff --git a/__unported__/stock_orderpoint_creator/stock_orderpoint_creator/__init__.py b/__unported__/stock_orderpoint_creator/stock_orderpoint_creator/__init__.py
index 34ffb14a7..c081a718f 100644
--- a/__unported__/stock_orderpoint_creator/stock_orderpoint_creator/__init__.py
+++ b/__unported__/stock_orderpoint_creator/stock_orderpoint_creator/__init__.py
@@ -18,7 +18,6 @@
# along with this program. If not, see .
#
##############################################################################
-
-from . import base_product_config_template
-from . import orderpoint_template
-import wizard
+from . import base_product_config_template # noqa
+from . import orderpoint_template # noqa
+import wizard # noqa
diff --git a/__unported__/stock_orderpoint_creator/stock_orderpoint_creator/base_product_config_template.py b/__unported__/stock_orderpoint_creator/stock_orderpoint_creator/base_product_config_template.py
index 1f6cd9389..86b0e8818 100644
--- a/__unported__/stock_orderpoint_creator/stock_orderpoint_creator/base_product_config_template.py
+++ b/__unported__/stock_orderpoint_creator/stock_orderpoint_creator/base_product_config_template.py
@@ -22,10 +22,10 @@
""" Base template for product config """
from openerp.osv.orm import browse_record, browse_record_list
+
class BaseProductConfigTemplate():
""" Abstract class for product config """
-
def _get_model(self):
""" Get the model for which this template is defined
@@ -33,42 +33,41 @@ class BaseProductConfigTemplate():
is represented by this template
"""
model = self._inherit
- model_obj = self.pool.get(model)
+ model_obj = self.pool[model]
return model_obj
- def _get_ids_2_clean(self, cursor, uid, template_br,
+ def _get_ids_2_clean(self, cr, uid, template_br,
product_ids, context=None):
""" hook to select model specific objects to clean
return must return a list of id"""
return []
- def _disable_old_instances(self, cursor, uid, template_br_list,
+ def _disable_old_instances(self, cr, uid, template_br_list,
product_ids, context=None):
""" Clean old instance by setting those inactives """
model_obj = self._get_model()
for template in template_br_list:
- ids2clean = self._get_ids_2_clean(cursor, uid, template,
+ ids2clean = self._get_ids_2_clean(cr, uid, template,
product_ids, context=context)
if self._clean_mode == 'deactivate':
- model_obj.write(cursor, uid, ids2clean,
+ model_obj.write(cr, uid, ids2clean,
{'active': False}, context=context)
elif self._clean_mode == 'unlink':
- model_obj.unlink(cursor, uid, ids2clean, context=context)
+ model_obj.unlink(cr, uid, ids2clean, context=context)
-
- def create_instances(self, cursor, uid, template_br,
+ def create_instances(self, cr, uid, template_br,
product_ids, context=None):
""" Create instances of model using template inherited model """
if not isinstance(product_ids, list):
product_ids = [product_ids]
- # data = self.copy_data(cursor, uid, template_br.id, context=context)
- # copy data will not work in all case and may retrieve erronus value
+ # not using self.copy_data(cr, uid, template_br.id, context=context)
+ # as copy data will not work in all case and may retrieve erronus value
model_obj = self._get_model()
data = {}
- #May rais error on function fields in future
+ #May raise error on function fields in future
for key in model_obj._columns.keys():
tmp = template_br[key]
if isinstance(tmp, browse_record):
@@ -79,7 +78,4 @@ class BaseProductConfigTemplate():
for product_id in product_ids:
data['product_id'] = product_id
- model_obj.create(cursor, uid, data, context=context)
-
-
-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+ model_obj.create(cr, uid, data, context=context)
diff --git a/__unported__/stock_orderpoint_creator/stock_orderpoint_creator/orderpoint_template.py b/__unported__/stock_orderpoint_creator/stock_orderpoint_creator/orderpoint_template.py
index 82767b7f5..414cdad1c 100644
--- a/__unported__/stock_orderpoint_creator/stock_orderpoint_creator/orderpoint_template.py
+++ b/__unported__/stock_orderpoint_creator/stock_orderpoint_creator/orderpoint_template.py
@@ -24,6 +24,7 @@
from openerp.osv.orm import Model
from base_product_config_template import BaseProductConfigTemplate
+
class OrderpointTemplate(BaseProductConfigTemplate, Model):
""" Template for orderpoints """
_name = 'stock.warehouse.orderpoint.template'
@@ -32,12 +33,12 @@ class OrderpointTemplate(BaseProductConfigTemplate, Model):
_table = 'stock_warehouse_orderpoint_template'
_clean_mode = 'deactivate'
- def _get_ids_2_clean(self, cursor, uid, template_br, product_ids, context=None):
+ def _get_ids_2_clean(self, cr, uid, template_br, product_ids,
+ context=None):
""" hook to select model specific objects to clean
return must return a list of id"""
model_obj = self._get_model()
- ids_to_del = model_obj.search(cursor, uid,
- [('product_id', 'in', product_ids)])
+ ids_to_del = model_obj.search(cr, uid,
+ [('product_id', 'in', product_ids)],
+ context=context)
return ids_to_del
-
-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/__unported__/stock_orderpoint_creator/stock_orderpoint_creator/wizard/__init__.py b/__unported__/stock_orderpoint_creator/stock_orderpoint_creator/wizard/__init__.py
index f6057e212..567728147 100644
--- a/__unported__/stock_orderpoint_creator/stock_orderpoint_creator/wizard/__init__.py
+++ b/__unported__/stock_orderpoint_creator/stock_orderpoint_creator/wizard/__init__.py
@@ -18,5 +18,4 @@
# along with this program. If not, see .
#
##############################################################################
-
-from . import orderpoint_creator
+from . import orderpoint_creator # noqa
diff --git a/__unported__/stock_orderpoint_creator/stock_orderpoint_creator/wizard/orderpoint_creator.py b/__unported__/stock_orderpoint_creator/stock_orderpoint_creator/wizard/orderpoint_creator.py
index f84abd5d0..e70949865 100644
--- a/__unported__/stock_orderpoint_creator/stock_orderpoint_creator/wizard/orderpoint_creator.py
+++ b/__unported__/stock_orderpoint_creator/stock_orderpoint_creator/wizard/orderpoint_creator.py
@@ -26,44 +26,44 @@ from openerp.osv.orm import browse_record, TransientModel, fields
_template_register = ['orderpoint_template_id']
+
class OrderpointCreator(TransientModel):
_name = 'stock.warehouse.orderpoint.creator'
_description = 'Orderpoint Creator'
- _columns = {'orderpoint_template_id': fields.many2many(
- 'stock.warehouse.orderpoint.template',
- rel='order_point_creator_rel',
- string='Stock rule template')
+ _columns = {
+ 'orderpoint_template_id': fields.many2many(
+ 'stock.warehouse.orderpoint.template',
+ rel='order_point_creator_rel',
+ string='Stock rule template')
}
-
def _get_template_register(self):
"""return a list of the field names which defines a template
This is a hook to allow expending the list of template"""
return _template_register
-
- def action_configure(self, cursor, uid, wiz_id, context=None):
+ def action_configure(self, cr, uid, wiz_id, context=None):
""" action to retrieve wizard data and launch creation of items """
- product_ids = context['active_ids']
+ product_ids = context.get('active_ids')
+ assert product_ids
+
if isinstance(wiz_id, list):
wiz_id = wiz_id[0]
- current = self.browse(cursor, uid, wiz_id, context=context)
- for template_field in self._get_template_register():
- template_br_list = current[template_field]
+ this = self.browse(cr, uid, wiz_id, context=context)
+ for template_field in self._get_template_register():
+ template_br_list = this[template_field]
if template_br_list:
if isinstance(template_br_list, browse_record):
template_br_list = [template_br_list]
template_model = template_br_list[0]._model._name
template_obj = self.pool.get(template_model)
- template_obj._disable_old_instances(cursor, uid, template_br_list,
- product_ids, context=context)
+ template_obj._disable_old_instances(cr, uid, template_br_list,
+ product_ids,
+ context=context)
for template_br in template_br_list:
- template_obj.create_instances(cursor, uid, template_br,
- product_ids, context=context)
+ template_obj.create_instances(cr, uid, template_br,
+ product_ids, context=context)
return {}
-
-
-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: