From 5bce036a6a1b6fbcdaf1beccc06ce1d5758e829e Mon Sep 17 00:00:00 2001 From: jke-openerp Date: Tue, 15 Oct 2013 14:22:16 +0200 Subject: [PATCH 1/3] Test on multiCompany updated + some other tiny bug bzr revid: jke@openerp.com-20131015122216-m5itjbwouetc3loj --- addons/stock/product.py | 2 +- addons/stock/stock.py | 6 +- addons/stock/tests/__init__.py | 28 ------ addons/stock/tests/test_multicompany.py | 86 ------------------- .../stock/wizard/stock_change_product_qty.py | 3 +- .../security/ir.model.access.csv | 2 + addons/stock_location/stock_location.py | 10 +-- 7 files changed, 13 insertions(+), 124 deletions(-) delete mode 100644 addons/stock/tests/__init__.py delete mode 100644 addons/stock/tests/test_multicompany.py diff --git a/addons/stock/product.py b/addons/stock/product.py index 9e436dd49c3..a4eae7f2c9d 100644 --- a/addons/stock/product.py +++ b/addons/stock/product.py @@ -141,7 +141,7 @@ class product_product(osv.osv): moves_in = dict(map(lambda x: (x['product_id'][0], x['product_qty']), moves_in)) moves_out = dict(map(lambda x: (x['product_id'][0], x['product_qty']), moves_out)) - + res = {} for id in ids: res[id] = { diff --git a/addons/stock/stock.py b/addons/stock/stock.py index 0b215c6f6af..6c394111d55 100644 --- a/addons/stock/stock.py +++ b/addons/stock/stock.py @@ -397,7 +397,7 @@ class stock_quant(osv.osv): #solving_quant, dummy = self._reconcile_single_negative_quant(cr, uid, to_solve_quant, solving_quant, quant_neg, qty, context=context) def _price_update(self, cr, uid, ids, newprice, context=None): - self.write(cr, SUPERSER_ID, ids, {'cost': newprice}, context=context) + self.write(cr, SUPERUSER_ID, ids, {'cost': newprice}, context=context) def write(self, cr, uid, ids, vals, context=None): #We want to trigger the move with nothing on reserved_quant_ids for the store of the remaining quantity @@ -1327,7 +1327,7 @@ class stock_move(osv.osv): default['origin_returned_move_id'] = False default['state'] = 'draft' return super(stock_move, self).copy(cr, uid, id, default, context) - + def _default_location_destination(self, cr, uid, context=None): context = context or {} if context.get('default_picking_type_id', False): @@ -1335,7 +1335,7 @@ class stock_move(osv.osv): return pick_type.default_location_dest_id and pick_type.default_location_dest_id.id or False return False - def _default_location_source(self, cr, uid, context=None): + def _default_location_source(self, cr, uid, context=None): context = context or {} if context.get('default_picking_type_id', False): pick_type = self.pool.get('stock.picking.type').browse(cr, uid, context['default_picking_type_id'], context=context) diff --git a/addons/stock/tests/__init__.py b/addons/stock/tests/__init__.py deleted file mode 100644 index a3f647212c5..00000000000 --- a/addons/stock/tests/__init__.py +++ /dev/null @@ -1,28 +0,0 @@ -# -*- coding: utf-8 -*- -############################################################################## -# -# OpenERP, Open Source Business Applications -# Copyright (c) 2012-TODAY OpenERP S.A. -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . -# -############################################################################## - -#from . import test_multicompany -# -#checks = [ -# test_multicompany, -#] - -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/stock/tests/test_multicompany.py b/addons/stock/tests/test_multicompany.py deleted file mode 100644 index 3f76231492b..00000000000 --- a/addons/stock/tests/test_multicompany.py +++ /dev/null @@ -1,86 +0,0 @@ -# -*- coding: utf-8 -*- -############################################################################## -# -# OpenERP, Open Source Business Applications -# Copyright (c) 2012-TODAY OpenERP S.A. -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . -# -############################################################################## - -from openerp.tests import common - - -class TestStockMulticompany(common.TransactionCase): - - def setUp(self): - super(TestStockMulticompany, self).setUp() - cr, uid = self.cr, self.uid - - # Usefull models - self.ir_model_data = self.registry('ir.model.data') - self.res_users = self.registry('res.users') - self.stock_location = self.registry('stock.location') - self.stock_move = self.registry('stock.move') - self.stock_warehouse = self.registry('stock.warehouse') - - model, group_user_id = self.registry('ir.model.data').get_object_reference(cr, uid, 'base', 'group_user') - model, group_stock_manager_id = self.registry('ir.model.data').get_object_reference(cr, uid, 'stock', 'group_stock_manager') - model, company_2_id = self.registry('ir.model.data').get_object_reference(cr, uid, 'stock', 'res_company_2') - self.multicompany_user_id = self.res_users.create(cr, uid, - {'name': 'multicomp', 'login': 'multicomp', - 'groups_id': [(6, 0, [group_user_id, group_stock_manager_id])], - 'company_id': company_2_id, 'company_ids': [(6,0,[company_2_id])]}) - - def test_00_multicompany_default_stock_move(self): - """check no error on getting default stock.move values in multicompany setting""" - cr, uid, context = self.cr, self.multicompany_user_id, {} - fields = ['location_id', 'location_dest_id'] - for type in ('in', 'internal', 'out'): - context['picking_type'] = type - defaults = self.stock_move.default_get(cr, uid, ['location_id', 'location_dest_id', 'type'], context) - for field in fields: - if defaults.get(field): - try: - self.stock_location.check_access_rule(cr, uid, [defaults[field]], 'read', context) - except Exception, exc: - assert False, "unreadable location %s: %s" % (field, exc) - self.assertEqual(defaults['type'], type, "wrong move type") - - - def test_10_multicompany_onchange_move_type(self): - """check onchange_move_type does not return unreadable in multicompany setting""" - cr, uid, context = self.cr, self.multicompany_user_id, {} - fields = ['location_id', 'location_dest_id'] - for type in ('in', 'internal', 'out'): - result = self.stock_move.onchange_move_type(cr, uid, [], type, context)['value'] - for field in fields: - if result.get(field): - try: - self.stock_location.check_access_rule(cr, uid, [result[field]], 'read', context) - except Exception, exc: - assert False, "unreadable location %s: %s" % (field, exc) - - - def test_30_multicompany_default_warehouse_location(self): - """check default locations for warehouse in multicompany setting""" - cr, uid, context = self.cr, self.multicompany_user_id, {} - fields = ['lot_input_id', 'lot_stock_id', 'lot_output_id'] - defaults = self.stock_warehouse.default_get(cr, uid, fields, context) - for field in fields: - if defaults.get(field): - try: - self.stock_location.check_access_rule(cr, uid, [defaults[field]], 'read', context) - except Exception, exc: - assert False, "unreadable default %s: %s" % (field, exc) diff --git a/addons/stock/wizard/stock_change_product_qty.py b/addons/stock/wizard/stock_change_product_qty.py index 8c601c7e101..243ea7304d8 100644 --- a/addons/stock/wizard/stock_change_product_qty.py +++ b/addons/stock/wizard/stock_change_product_qty.py @@ -104,7 +104,8 @@ class stock_change_product_qty(osv.osv_memory): } inventry_line_obj.create(cr , uid, line_data, context=context) - inventry_obj.action_confirm(cr, uid, [inventory_id], context=context) + #doesn't exist + #inventry_obj.action_confirm(cr, uid, [inventory_id], context=context) inventry_obj.action_done(cr, uid, [inventory_id], context=context) return {} diff --git a/addons/stock_location/security/ir.model.access.csv b/addons/stock_location/security/ir.model.access.csv index 6339ccf579a..8e4217acec9 100644 --- a/addons/stock_location/security/ir.model.access.csv +++ b/addons/stock_location/security/ir.model.access.csv @@ -8,8 +8,10 @@ access_stock_location_path_internal_user,stock location path internal user,model access_stock_location_path_sale_manager,stock.location.path partner salemanager,model_stock_location_path,base.group_sale_manager,1,1,1,1 access_stock_location_path_stock_user,stock.location.path stock user,model_stock_location_path,stock.group_stock_user,1,1,1,1 access_stock_location_path,stock.location.path,model_stock_location_path,base.group_sale_salesman,1,0,0,0 +access_stock_location_route,stock.location.route,model_stock_location_route,stock.group_stock_manager,1,0,1,0 access_procurement_rule,procurement.rule.flow,model_procurement_rule,base.group_sale_salesman,1,0,0,0 access_procurement_rule_internal,procurement.rule.flow internal,model_procurement_rule,base.group_user,1,0,0,0 access_stock_putaway_all,stock.putaway all users,model_stock_move_putaway,base.group_user,1,0,0,0 access_product_putaway_all,product.putaway all users,model_product_putaway,base.group_user,1,0,0,0 access_stock_removal_all,product.removal all users,model_product_removal,base.group_user,1,0,0,0 + diff --git a/addons/stock_location/stock_location.py b/addons/stock_location/stock_location.py index 4cd932773d7..8126b089eb0 100644 --- a/addons/stock_location/stock_location.py +++ b/addons/stock_location/stock_location.py @@ -370,11 +370,11 @@ class stock_warehouse(osv.osv): vals[values['field']] = location_id #create new sequences - in_seq_id = seq_obj.create(cr, uid, values={'name': vals.get('name', '') + _(' Sequence in'), 'prefix': vals.get('code', '') + '\IN\\', 'padding': 5}, context=context) - out_seq_id = seq_obj.create(cr, uid, values={'name': vals.get('name', '') + _(' Sequence out'), 'prefix': vals.get('code', '') + '\OUT\\', 'padding': 5}, context=context) - pack_seq_id = seq_obj.create(cr, uid, values={'name': vals.get('name', '') + _(' Sequence packing'), 'prefix': vals.get('code', '') + '\PACK\\', 'padding': 5}, context=context) - pick_seq_id = seq_obj.create(cr, uid, values={'name': vals.get('name', '') + _(' Sequence picking'), 'prefix': vals.get('code', '') + '\PICK\\', 'padding': 5}, context=context) - int_seq_id = seq_obj.create(cr, uid, values={'name': vals.get('name', '') + _(' Sequence internal'), 'prefix': vals.get('code', '') + '\INT\\', 'padding': 5}, context=context) + in_seq_id = seq_obj.create(cr, SUPERUSER_ID, values={'name': vals.get('name', '') + _(' Sequence in'), 'prefix': vals.get('code', '') + '\IN\\', 'padding': 5}, context=context) + out_seq_id = seq_obj.create(cr, SUPERUSER_ID, values={'name': vals.get('name', '') + _(' Sequence out'), 'prefix': vals.get('code', '') + '\OUT\\', 'padding': 5}, context=context) + pack_seq_id = seq_obj.create(cr, SUPERUSER_ID, values={'name': vals.get('name', '') + _(' Sequence packing'), 'prefix': vals.get('code', '') + '\PACK\\', 'padding': 5}, context=context) + pick_seq_id = seq_obj.create(cr, SUPERUSER_ID, values={'name': vals.get('name', '') + _(' Sequence picking'), 'prefix': vals.get('code', '') + '\PICK\\', 'padding': 5}, context=context) + int_seq_id = seq_obj.create(cr, SUPERUSER_ID, values={'name': vals.get('name', '') + _(' Sequence internal'), 'prefix': vals.get('code', '') + '\INT\\', 'padding': 5}, context=context) #create WH new_id = super(stock_warehouse, self).create(cr, uid, vals=vals, context=context) From c076e83b087381ea5af89d7d55c313044976fb83 Mon Sep 17 00:00:00 2001 From: jke-openerp Date: Tue, 15 Oct 2013 14:23:00 +0200 Subject: [PATCH 2/3] move test en stock location -> add file bzr revid: jke@openerp.com-20131015122300-7yay3o0ys2sn94qa --- addons/stock_location/tests/__init__.py | 28 +++++++ .../stock_location/tests/test_multicompany.py | 75 +++++++++++++++++++ 2 files changed, 103 insertions(+) create mode 100644 addons/stock_location/tests/__init__.py create mode 100644 addons/stock_location/tests/test_multicompany.py diff --git a/addons/stock_location/tests/__init__.py b/addons/stock_location/tests/__init__.py new file mode 100644 index 00000000000..39ebd5e451f --- /dev/null +++ b/addons/stock_location/tests/__init__.py @@ -0,0 +1,28 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Business Applications +# Copyright (c) 2012-TODAY OpenERP S.A. +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## + +from . import test_multicompany + +checks = [ + test_multicompany, +] + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/stock_location/tests/test_multicompany.py b/addons/stock_location/tests/test_multicompany.py new file mode 100644 index 00000000000..5f64d01c45e --- /dev/null +++ b/addons/stock_location/tests/test_multicompany.py @@ -0,0 +1,75 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Business Applications +# Copyright (c) 2012-TODAY OpenERP S.A. +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## + +from openerp.tests import common + + +class TestStockMulticompany(common.TransactionCase): + + def setUp(self): + super(TestStockMulticompany, self).setUp() + cr, uid = self.cr, self.uid + + # Usefull models + self.ir_model_data = self.registry('ir.model.data') + self.res_users = self.registry('res.users') + self.stock_location = self.registry('stock.location') + self.stock_move = self.registry('stock.move') + self.stock_warehouse = self.registry('stock.warehouse') + + model, group_user_id = self.registry('ir.model.data').get_object_reference(cr, uid, 'base', 'group_user') + model, group_stock_manager_id = self.registry('ir.model.data').get_object_reference(cr, uid, 'stock', 'group_stock_manager') + model, company_2_id = self.registry('ir.model.data').get_object_reference(cr, uid, 'stock', 'res_company_2') + self.company_2_id = company_2_id + self.multicompany_user_id = self.res_users.create(cr, uid, + {'name': 'multicomp', 'login': 'multicomp', + 'groups_id': [(6, 0, [group_user_id, group_stock_manager_id])], + 'company_id': company_2_id, 'company_ids': [(6,0,[company_2_id])]}) + + def test_00_multicompany_default_stock_move(self): + """check no error on getting default stock.move values in multicompany setting""" + cr, uid, context = self.cr, self.multicompany_user_id, {} + fields = ['location_id', 'location_dest_id'] + + new_warehouse_id = self.registry('stock.warehouse').create(cr, uid, {'name':'DemoWH_MultiComp','reception_steps':'three_steps', 'delivery_steps' : 'pick_pack_ship', 'company_id':self.company_2_id,'code':'dmwh'}, context=context) + warehouse = self.registry('stock.warehouse').browse(cr, uid, new_warehouse_id, context=context) + + for type in ('in', 'int', 'out'): + + type_id = warehouse[type + '_type_id'].id + context['default_picking_type_id'] = type_id + defaults = self.stock_move.default_get(cr, uid, ['location_id', 'location_dest_id','picking_type_id'], context=context) + if defaults and defaults['picking_type_id']: + def_type = self.registry('stock.picking.type').browse(cr,uid,defaults['picking_type_id'],context).code_id + else: + assert False, "Picking type undefined " + + for field in fields: + + if defaults.get(field): + try: + print("try : ",defaults[field]) + self.stock_location.check_access_rule(cr, uid, [defaults[field]], 'read', context) + except Exception, exc: + print("catch : ",defaults[field]) + assert False, "unreadable location %s: %s" % (field, exc) + + self.assertEqual(def_type[0:len(type)].lower(), type, "wrong move type") From 18a9318cfd01b52594fc0d658c105b3aea25b50e Mon Sep 17 00:00:00 2001 From: jke-openerp Date: Wed, 16 Oct 2013 09:12:09 +0200 Subject: [PATCH 3/3] [FIX] mrp: removed picking_id field on mrp.production bzr revid: jke@openerp.com-20131016071209-pryay03jucyezjje --- addons/mrp/mrp.py | 12 ++++++------ addons/mrp/mrp_view.xml | 3 +-- addons/mrp/test/cancel_order.yml | 6 ------ addons/mrp/tests/test_multicompany.py | 3 +-- 4 files changed, 8 insertions(+), 16 deletions(-) diff --git a/addons/mrp/mrp.py b/addons/mrp/mrp.py index 27cb2d09583..da8a9e4b99c 100644 --- a/addons/mrp/mrp.py +++ b/addons/mrp/mrp.py @@ -511,8 +511,8 @@ class mrp_production(osv.osv): help="Bill of Materials allow you to define the list of required raw materials to make a finished product."), 'routing_id': fields.many2one('mrp.routing', string='Routing', on_delete='set null', readonly=True, states={'draft':[('readonly',False)]}, help="The list of operations (list of work centers) to produce the finished product. The routing is mainly used to compute work center costs during operations and to plan future loads on work centers based on production plannification."), - 'picking_id': fields.many2one('stock.picking', 'Picking List', readonly=True, ondelete="restrict", - help="This is the Internal Picking List that brings the finished product to the production plan"), +# 'picking_id': fields.many2one('stock.picking', 'Picking List', readonly=True, ondelete="restrict", +# help="This is the Internal Picking List that brings the finished product to the production plan"), 'move_prod_id': fields.many2one('stock.move', 'Product Move', readonly=True), 'move_lines': fields.one2many('stock.move', 'raw_material_production_id', 'Products to Consume', domain=[('state','not in', ('done', 'cancel'))], readonly=True, states={'draft':[('readonly',False)]}), @@ -717,10 +717,10 @@ class mrp_production(osv.osv): context = {} move_obj = self.pool.get('stock.move') for production in self.browse(cr, uid, ids, context=context): - if production.state == 'confirmed' and production.picking_id.state not in ('draft', 'cancel'): - raise osv.except_osv( - _('Cannot cancel manufacturing order!'), - _('You must first cancel related internal picking attached to this manufacturing order.')) + if production.state == 'confirmed': #and production.picking_id.state not in ('draft', 'cancel'): + raise osv.except_osv( + _('Cannot cancel manufacturing order!'), + _('You must first cancel related internal picking attached to this manufacturing order.')) if production.move_created_ids: move_obj.action_cancel(cr, uid, [x.id for x in production.move_created_ids]) move_obj.action_cancel(cr, uid, [x.id for x in production.move_lines]) diff --git a/addons/mrp/mrp_view.xml b/addons/mrp/mrp_view.xml index e1ea16cdec9..010e9077bc6 100644 --- a/addons/mrp/mrp_view.xml +++ b/addons/mrp/mrp_view.xml @@ -788,8 +788,7 @@ - - + diff --git a/addons/mrp/test/cancel_order.yml b/addons/mrp/test/cancel_order.yml index 2f721b6c653..17905906e3b 100644 --- a/addons/mrp/test/cancel_order.yml +++ b/addons/mrp/test/cancel_order.yml @@ -7,12 +7,6 @@ I first confirm order for PC Assemble SC349. - !workflow {model: mrp.production, action: button_confirm, ref: mrp_production_test1} -- - In order to cancel the production order, I first cancel its picking. -- - !function {model: stock.picking, name: action_cancel}: - - model: mrp.production - eval: "[obj(ref('mrp_production_test1')).picking_id.id]" - Now I cancel the production order. - diff --git a/addons/mrp/tests/test_multicompany.py b/addons/mrp/tests/test_multicompany.py index f38a31a70de..5d1a0a50bcb 100644 --- a/addons/mrp/tests/test_multicompany.py +++ b/addons/mrp/tests/test_multicompany.py @@ -47,8 +47,7 @@ class TestMrpMulticompany(common.TransactionCase): cr, uid, context = self.cr, self.multicompany_user_id, {} fields = ['location_src_id', 'location_dest_id'] defaults = self.stock_location.default_get(cr, uid, ['location_id', 'location_dest_id', 'type'], context) - for field in fields: - print field, uid, defaults + for field in fields: if defaults.get(field): try: self.stock_location.check_access_rule(cr, uid, [defaults[field]], 'read', context)