From d8be2f47c48b45349442bcdaba02143c1ca2bc13 Mon Sep 17 00:00:00 2001 From: Matthieu Dietrich Date: Wed, 8 Oct 2014 11:16:51 +0200 Subject: [PATCH] Correct comments + add unit test --- stock_orderpoint_generator/__openerp__.py | 7 ++-- .../base_product_config_template.py | 2 +- .../orderpoint_template.py | 8 ++--- .../test/orderpoint_generator.yml | 35 +++++++++++++++++++ 4 files changed, 43 insertions(+), 9 deletions(-) create mode 100644 stock_orderpoint_generator/test/orderpoint_generator.yml diff --git a/stock_orderpoint_generator/__openerp__.py b/stock_orderpoint_generator/__openerp__.py index 2c9a1525c..1436036fc 100644 --- a/stock_orderpoint_generator/__openerp__.py +++ b/stock_orderpoint_generator/__openerp__.py @@ -20,7 +20,7 @@ ############################################################################## {'name': 'Order point generator', - 'summary': 'Configuration of order point in mass', + 'summary': 'Mass configuration of stock order points', 'version': '1.0', 'author': 'Camptocamp', 'category': 'Warehouse', @@ -32,7 +32,7 @@ Order point generator ===================== -Add a wizard to configure massively order points for multiple products. +Add a wizard to configure order points for multiple products in one go. Contributors ------------ @@ -41,12 +41,11 @@ Contributors * Matthieu Dietrich """, - 'website': 'http://www.openerp.com', 'demo': [], 'data': ["wizard/orderpoint_generator_view.xml", "security/ir.model.access.csv", ], - 'test': [], + 'test': ['test/orderpoint_generator.yml'], 'installable': True, 'auto_install': False, } diff --git a/stock_orderpoint_generator/base_product_config_template.py b/stock_orderpoint_generator/base_product_config_template.py index 903690dc0..24dcd7e6a 100644 --- a/stock_orderpoint_generator/base_product_config_template.py +++ b/stock_orderpoint_generator/base_product_config_template.py @@ -62,7 +62,7 @@ class BaseProductConfigTemplate(): product_ids = [product_ids] # 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 + # as copy data will not work in all case and may return erroneous value model_obj = self._get_model() diff --git a/stock_orderpoint_generator/orderpoint_template.py b/stock_orderpoint_generator/orderpoint_template.py index 4973157a9..dc5af826c 100644 --- a/stock_orderpoint_generator/orderpoint_template.py +++ b/stock_orderpoint_generator/orderpoint_template.py @@ -28,13 +28,13 @@ from base_product_config_template import BaseProductConfigTemplate class OrderpointTemplate(BaseProductConfigTemplate, Model): """ Template for orderpoints - Here we use same model as stock.warhouse.orderpoint but set product_id + Here we use same model as stock.warehouse.orderpoint but set product_id as non mandatory as we cannot remove it. This field will be ignored. - This has the advantage to ensure orderpoint and orderpoint template have - same fields. + This has the advantage the advantage of ensuring that the order point + and the order point template have the same fields. - _table is redifined to separate templates from orderpoints + _table is redefined to separate templates from orderpoints """ _name = 'stock.warehouse.orderpoint.template' diff --git a/stock_orderpoint_generator/test/orderpoint_generator.yml b/stock_orderpoint_generator/test/orderpoint_generator.yml new file mode 100644 index 000000000..2319829d3 --- /dev/null +++ b/stock_orderpoint_generator/test/orderpoint_generator.yml @@ -0,0 +1,35 @@ +- + To test the orderpoint generator, I first create a template to apply. +- + I check that no orderpoint was created for the product +- + !python {model: stock.warehouse.orderpoint}: | + orderpoint_ids = self.search(cr, uid, [('product_id','=', ref('product.product_product_32')), + ('name', '=', 'OP/000445')]) + assert len(orderpoint_ids) == 0, 'Orderpoint already created for product' +- + I create the template +- + !record {model: stock.warehouse.orderpoint.template, id: stock_warehouse_orderpoint_template_op0}: + company_id: base.main_company + location_id: stock.stock_location_stock + logic: max + name: OP/000445 + product_max_qty: 15.0 + product_min_qty: 5.0 + product_uom: product.product_uom_unit + qty_multiple: 1 + warehouse_id: stock.warehouse0 +- + I apply the template to a product. +- + !python {model: stock.warehouse.orderpoint.generator}: | + wizard = self.create(cr, uid, {'orderpoint_template_id': [(6, 0, [ref('stock_warehouse_orderpoint_template_op0')])]}) + self.action_configure(cr, uid, wizard, context={'active_ids': [ref('product.product_product_32')]}) +- + I check that a new orderpoint was created for the product +- + !python {model: stock.warehouse.orderpoint}: | + orderpoint_ids = self.search(cr, uid, [('product_id','=', ref('product.product_product_32')), + ('name', '=', 'OP/000445')]) + assert len(orderpoint_ids) > 0, 'Orderpoint not created for product'