From 13d0934f34c2b4450f14bb32f4b97dd3b9c2022a Mon Sep 17 00:00:00 2001 From: vrenaville Date: Fri, 28 Nov 2014 14:01:50 +0100 Subject: [PATCH 1/7] [FIX] account: chart of account opening period selection If a special period is present, it must be selected fist Fixes #3946 --- addons/account/wizard/account_chart.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/account/wizard/account_chart.py b/addons/account/wizard/account_chart.py index 32b83a0a670..62f99c3c854 100644 --- a/addons/account/wizard/account_chart.py +++ b/addons/account/wizard/account_chart.py @@ -51,7 +51,7 @@ class account_chart(osv.osv_memory): FROM account_period p LEFT JOIN account_fiscalyear f ON (p.fiscalyear_id = f.id) WHERE f.id = %s - ORDER BY p.date_start ASC + ORDER BY p.date_start ASC, p.special DESC LIMIT 1) AS period_start UNION ALL SELECT * FROM (SELECT p.id From bfadcdd5d6cd7e2a081efcc5f537d80be3812be8 Mon Sep 17 00:00:00 2001 From: Julien Legros Date: Fri, 28 Nov 2014 13:39:37 +0100 Subject: [PATCH 2/7] [FIX] stock: compute average price on action_done The average price computation is now deduplicated and moved to a separate function called in stock_move action_done. This makes sure it is always called when a stock.move is processed, even without going through the partial picking wizard. Fixes #2991 Closes #3949 OPW-615491 --- addons/stock/stock.py | 114 ++++++++++++++++++------------------------ 1 file changed, 50 insertions(+), 64 deletions(-) diff --git a/addons/stock/stock.py b/addons/stock/stock.py index 7dc39c150a2..23c72379919 100644 --- a/addons/stock/stock.py +++ b/addons/stock/stock.py @@ -1233,8 +1233,6 @@ class stock_picking(osv.osv): context = dict(context) res = {} move_obj = self.pool.get('stock.move') - product_obj = self.pool.get('product.product') - currency_obj = self.pool.get('res.currency') uom_obj = self.pool.get('product.uom') sequence_obj = self.pool.get('ir.sequence') wf_service = netsvc.LocalService("workflow") @@ -1263,40 +1261,12 @@ class stock_picking(osv.osv): else: too_many.append(move) - # Average price computation if (pick.type == 'in') and (move.product_id.cost_method == 'average'): - product = product_obj.browse(cr, uid, move.product_id.id) - move_currency_id = move.company_id.currency_id.id - context['currency_id'] = move_currency_id - qty = uom_obj._compute_qty(cr, uid, product_uom, product_qty, product.uom_id.id) - - if product.id not in product_avail: - # keep track of stock on hand including processed lines not yet marked as done - product_avail[product.id] = product.qty_available - - if qty > 0: - new_price = currency_obj.compute(cr, uid, product_currency, - move_currency_id, product_price, round=False) - new_price = uom_obj._compute_price(cr, uid, product_uom, new_price, - product.uom_id.id) - if product_avail[product.id] <= 0: - product_avail[product.id] = 0 - new_std_price = new_price - else: - # Get the standard price - amount_unit = product.price_get('standard_price', context=context)[product.id] - new_std_price = ((amount_unit * product_avail[product.id])\ - + (new_price * qty))/(product_avail[product.id] + qty) - # Write the field according to price type field - product_obj.write(cr, uid, [product.id], {'standard_price': new_std_price}) - - # Record the values that were chosen in the wizard, so they can be - # used for inventory valuation if real-time valuation is enabled. - move_obj.write(cr, uid, [move.id], - {'price_unit': product_price, - 'price_currency_id': product_currency}) - - product_avail[product.id] += qty + # Record the values that were chosen in the wizard, so they can be + # used for average price computation and inventory valuation + move_obj.write(cr, uid, [move.id], + {'price_unit': product_price, + 'price_currency_id': product_currency}) # every line of the picking is empty, do not generate anything empty_picking = not any(q for q in move_product_qty.values() if q > 0) @@ -2343,6 +2313,44 @@ class stock_move(osv.osv): return reference_amount, reference_currency_id + def _update_average_price(self, cr, uid, move, context=None): + product_obj = self.pool.get('product.product') + currency_obj = self.pool.get('res.currency') + uom_obj = self.pool.get('product.uom') + product_avail = {} + + if (move.picking_id.type == 'in') and (move.product_id.cost_method == 'average'): + product = product_obj.browse(cr, uid, move.product_id.id) + move_currency_id = move.company_id.currency_id.id + context['currency_id'] = move_currency_id + + product_qty = move.product_qty + product_uom = move.product_uom.id + product_price = move.price_unit + product_currency = move.price_currency_id.id + + if product.id not in product_avail: + # keep track of stock on hand including processed lines not yet marked as done + product_avail[product.id] = product.qty_available + + qty = uom_obj._compute_qty(cr, uid, product_uom, product_qty, product.uom_id.id) + if qty > 0: + new_price = currency_obj.compute(cr, uid, product_currency, + move_currency_id, product_price, round=False) + new_price = uom_obj._compute_price(cr, uid, product_uom, new_price, + product.uom_id.id) + if product_avail[product.id] <= 0: + product_avail[product.id] = 0 + new_std_price = new_price + else: + # Get the standard price + amount_unit = product.price_get('standard_price', context=context)[product.id] + new_std_price = ((amount_unit * product_avail[product.id])\ + + (new_price * qty))/(product_avail[product.id] + qty) + + product_obj.write(cr, uid, [product.id],{'standard_price': new_std_price}) + + product_avail[product.id] += qty def _create_product_valuation_moves(self, cr, uid, move, context=None): """ @@ -2430,6 +2438,7 @@ class stock_move(osv.osv): if move.move_dest_id.auto_validate: self.action_done(cr, uid, [move.move_dest_id.id], context=context) + self._update_average_price(cr, uid, move, context=context) self._create_product_valuation_moves(cr, uid, move, context=context) if move.state not in ('confirmed','done','assigned'): todo.append(move.id) @@ -2692,9 +2701,6 @@ class stock_move(osv.osv): """ res = {} picking_obj = self.pool.get('stock.picking') - product_obj = self.pool.get('product.product') - currency_obj = self.pool.get('res.currency') - uom_obj = self.pool.get('product.uom') wf_service = netsvc.LocalService("workflow") if context is None: @@ -2721,33 +2727,13 @@ class stock_move(osv.osv): else: too_many.append(move) - # Average price computation if (move.picking_id.type == 'in') and (move.product_id.cost_method == 'average'): - product = product_obj.browse(cr, uid, move.product_id.id) - move_currency_id = move.company_id.currency_id.id - context['currency_id'] = move_currency_id - qty = uom_obj._compute_qty(cr, uid, product_uom, product_qty, product.uom_id.id) - if qty > 0: - new_price = currency_obj.compute(cr, uid, product_currency, - move_currency_id, product_price, round=False) - new_price = uom_obj._compute_price(cr, uid, product_uom, new_price, - product.uom_id.id) - if product.qty_available <= 0: - new_std_price = new_price - else: - # Get the standard price - amount_unit = product.price_get('standard_price', context=context)[product.id] - new_std_price = ((amount_unit * product.qty_available)\ - + (new_price * qty))/(product.qty_available + qty) - - product_obj.write(cr, uid, [product.id],{'standard_price': new_std_price}) - - # Record the values that were chosen in the wizard, so they can be - # used for inventory valuation if real-time valuation is enabled. - self.write(cr, uid, [move.id], - {'price_unit': product_price, - 'price_currency_id': product_currency, - }) + # Record the values that were chosen in the wizard, so they can be + # used for average price computation and inventory valuation + self.write(cr, uid, [move.id], + {'price_unit': product_price, + 'price_currency_id': product_currency, + }) for move in too_few: product_qty = move_product_qty[move.id] From 5f9280e854ac435bdcf903128d5e9d5d0b592070 Mon Sep 17 00:00:00 2001 From: Julien Legros Date: Fri, 28 Nov 2014 13:45:11 +0100 Subject: [PATCH 3/7] [ADD] purchase: average price computation test --- addons/purchase/tests/__init__.py | 26 +++ addons/purchase/tests/test_average_price.py | 177 ++++++++++++++++++++ 2 files changed, 203 insertions(+) create mode 100644 addons/purchase/tests/__init__.py create mode 100644 addons/purchase/tests/test_average_price.py diff --git a/addons/purchase/tests/__init__.py b/addons/purchase/tests/__init__.py new file mode 100644 index 00000000000..295471b9aa3 --- /dev/null +++ b/addons/purchase/tests/__init__.py @@ -0,0 +1,26 @@ +# -*- 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 . +# +############################################################################## + +import test_average_price + +checks = [ + test_average_price, +] diff --git a/addons/purchase/tests/test_average_price.py b/addons/purchase/tests/test_average_price.py new file mode 100644 index 00000000000..4cc4849a33e --- /dev/null +++ b/addons/purchase/tests/test_average_price.py @@ -0,0 +1,177 @@ +# -*- 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.test.common import TransactionCase +from datetime import date +from openerp.tests import common +from openerp import netsvc + + +class TestAveragePrice(common.TransactionCase): + def setUp(self): + super(TestAveragePrice, self).setUp() + cr, uid, context = self.cr, self.uid, {} + self.ir_model_data = self.registry('ir.model.data') + self.product_product = self.registry('product.product') + self.purchase_order = self.registry('purchase.order') + self.purchase_order_line = self.registry('purchase.order.line') + self.pricelist = self.registry('product.pricelist') + self.stock_location = self.registry('stock.location') + self.stock_picking = self.registry('stock.picking') + self.stock_move = self.registry('stock.move') + self.stock_partial_move = self.registry('stock.partial.move') + self.stock_partial_move_line = self.registry('stock.partial.move.line') + self.partial_picking = self.registry('stock.partial.picking') + self.partial_picking_line = self.registry('stock.partial.picking.line') + change_product_qty = self.registry('stock.change.product.qty') + + _, partner_id = self.registry('ir.model.data').get_object_reference(cr, uid, 'base', 'res_partner_1') + _, pricelist_id = self.registry('ir.model.data').get_object_reference(cr, uid, 'product', 'list0') + _, self.location_id = self.registry('ir.model.data').get_object_reference(cr, uid, 'stock', 'stock_location_stock') + _, self.supplier_location_id = self.registry('ir.model.data').get_object_reference(cr, uid, 'stock', 'stock_location_suppliers') + _, input_account_id = self.registry('ir.model.data').get_object_reference(cr, uid, 'account', 'xfa') + _, output_account_id = self.registry('ir.model.data').get_object_reference(cr, uid, 'account', 'xfa') + wf_service = netsvc.LocalService("workflow") + + self.standard_price = 10 + self.order_price_unit = 20 + self.available_qty = 1 + self.order_qty = 1 + self.picking_qty = 1 + + self.product_id = self.product_product.create(cr, uid, { + 'name': 'Average product', + 'cost_method': 'average', + 'valuation': 'real_time', + 'property_stock_account_input': input_account_id, + 'property_stock_account_output': output_account_id, + }, context=context) + + self.product_product.do_change_standard_price( + cr, uid, [self.product_id], { + 'new_price': self.standard_price, + 'stock_input_account': input_account_id, + 'stock_output_account': output_account_id}) + + change_product_qty_id = change_product_qty.create( + cr, uid, { + 'location_id': self.location_id, + 'new_quantity': self.available_qty, + 'product_id': self.product_id}) + change_product_qty.change_product_qty( + cr, uid, [change_product_qty_id], { + 'active_model': 'product.product', + 'active_id': self.product_id, + 'active_ids': [self.product_id]}) + + self.po_01_id = self.purchase_order.create(cr, uid, { + 'partner_id': partner_id, + 'location_id': self.location_id, + 'pricelist_id': pricelist_id, + }, context=context) + + self.order_line_10 = self.purchase_order_line.create(cr, uid, { + 'order_id': self.po_01_id, + 'product_id': self.product_id, + 'name': 'description', + 'date_planned': date.today(), + 'product_qty': self.order_qty, + 'price_unit': self.order_price_unit + }, context=context) + + wf_service.trg_validate(uid, 'purchase.order', self.po_01_id, 'purchase_confirm', cr) + + + def test_10_stock_move_action_done(self): + cr, uid, context = self.cr, self.uid, {} + picking_id = self.purchase_order.read(cr, uid, [self.po_01_id], ['picking_ids'])[0]['picking_ids'] + move_lines_ids = self.stock_picking.read(cr, uid, picking_id, ['move_lines'])[0]['move_lines'] + for move in self.stock_move.browse(cr, uid, move_lines_ids, context=context): + move.action_done() + + new_price = self.product_product.read(cr, uid, self.product_id, ['standard_price'], context=context)['standard_price'] + self.assertAlmostEqual( + new_price, + (self.available_qty * self.standard_price + self.order_qty * self.order_price_unit) + /(self.available_qty + self.order_qty)) + + def test_20_partial_stock_move(self): + cr, uid, context = self.cr, self.uid, {} + picking_ids = self.purchase_order.read(cr, uid, [self.po_01_id], ['picking_ids'])[0]['picking_ids'] + product = self.product_product.browse(cr, uid, self.product_id, context=context) + + partial_move_id = self.stock_partial_move.create(cr, uid, { + 'date': date.today(), + 'picking_id': picking_ids[0] + }, context=context) + + move_lines_ids = self.stock_picking.read(cr, uid, picking_ids, ['move_lines'])[0]['move_lines'] + for move in self.stock_move.browse(cr, uid, move_lines_ids, context=context): + self.stock_partial_move_line.create(cr, uid, { + 'product_id': self.product_id, + 'quantity': self.picking_qty, + 'product_uom': product.uom_id.id, + 'location_dest_id': self.location_id, + 'location_id': self.supplier_location_id, + 'move_id': move.id, + 'cost': self.order_price_unit, + 'wizard_id': partial_move_id, + }, context=context) + + self.stock_partial_move.do_partial(cr, uid, [partial_move_id], context=context) + + new_price = self.product_product.read(cr, uid, self.product_id, ['standard_price'], context=context)['standard_price'] + self.assertAlmostEqual( + new_price, + (self.available_qty * self.standard_price + self.order_qty * self.order_price_unit) + /(self.available_qty + self.order_qty)) + + def test_30_partial_stock_picking(self): + cr, uid, context = self.cr, self.uid, {} + picking_ids = self.purchase_order.read(cr, uid, [self.po_01_id], ['picking_ids'])[0]['picking_ids'] + product = self.product_product.browse(cr, uid, self.product_id, context=context) + + partial_picking_id = self.partial_picking.create(cr, uid, { + 'date': date.today(), + 'picking_id': picking_ids[0], + }, context=context) + + move_lines_ids = self.stock_picking.read(cr, uid, picking_ids, ['move_lines'])[0]['move_lines'] + for move in self.stock_move.browse(cr, uid, move_lines_ids, context=context): + self.partial_picking_line.create(cr, uid, { + 'product_id': self.product_id, + 'quantity': self.picking_qty, + 'product_uom': product.uom_id.id, + 'location_dest_id': self.location_id, + 'location_id': self.supplier_location_id, + 'move_id': move.id, + 'cost': self.order_price_unit, + 'wizard_id': partial_picking_id, + }, context=context) + + self.partial_picking.do_partial(cr, uid, [partial_picking_id], context=context) + + new_price = self.product_product.read(cr, uid, self.product_id, ['standard_price'], context=context)['standard_price'] + self.assertAlmostEqual( + new_price, + (self.available_qty * self.standard_price + self.order_qty * self.order_price_unit) + /(self.available_qty + self.order_qty)) + From bc2a52fb28a1ce690a148e87cf9bc7e0797ca4d0 Mon Sep 17 00:00:00 2001 From: Benoit Guillot Date: Mon, 1 Dec 2014 13:13:51 +0100 Subject: [PATCH 4/7] [IMP] mrp: add prepare method for manufacturing orders to allow override Fixes #3973 --- addons/mrp/procurement.py | 50 +++++++++++++++++++++++---------------- 1 file changed, 30 insertions(+), 20 deletions(-) diff --git a/addons/mrp/procurement.py b/addons/mrp/procurement.py index b07f6f6de9d..0897aa4fd0f 100644 --- a/addons/mrp/procurement.py +++ b/addons/mrp/procurement.py @@ -25,6 +25,8 @@ from openerp.osv import fields from openerp.osv import osv from openerp.tools.translate import _ from openerp import netsvc +from openerp.tools import DEFAULT_SERVER_DATETIME_FORMAT + class procurement_order(osv.osv): _inherit = 'procurement.order' @@ -78,36 +80,44 @@ class procurement_order(osv.osv): res = procurement_obj.make_mo(cr, uid, ids, context=context) res = res.values() return len(res) and res[0] or 0 - + + def _get_date_planned(self, cr, uid, procurement, context=None): + format_date_planned = datetime.strptime(procurement.date_planned, + DEFAULT_SERVER_DATETIME_FORMAT) + date_planned = format_date_planned - relativedelta(days=procurement.product_id.produce_delay or 0.0) + date_planned = date_planned - relativedelta(days=procurement.company_id.manufacturing_lead) + return date_planned + + def _prepare_mo_vals(self, cr, uid, procurement, context=None): + res_id = procurement.move_id.id + newdate = self._get_date_planned(cr, uid, procurement, context=context) + return { + 'origin': procurement.origin, + 'product_id': procurement.product_id.id, + 'product_qty': procurement.product_qty, + 'product_uom': procurement.product_uom.id, + 'product_uos_qty': procurement.product_uos and procurement.product_uos_qty or False, + 'product_uos': procurement.product_uos and procurement.product_uos.id or False, + 'location_src_id': procurement.location_id.id, + 'location_dest_id': procurement.location_id.id, + 'bom_id': procurement.bom_id and procurement.bom_id.id or False, + 'date_planned': newdate.strftime(DEFAULT_SERVER_DATETIME_FORMAT), + 'move_prod_id': res_id, + 'company_id': procurement.company_id.id, + } + def make_mo(self, cr, uid, ids, context=None): """ Make Manufacturing(production) order from procurement @return: New created Production Orders procurement wise """ res = {} - company = self.pool.get('res.users').browse(cr, uid, uid, context).company_id production_obj = self.pool.get('mrp.production') move_obj = self.pool.get('stock.move') wf_service = netsvc.LocalService("workflow") procurement_obj = self.pool.get('procurement.order') for procurement in procurement_obj.browse(cr, uid, ids, context=context): - res_id = procurement.move_id.id - newdate = datetime.strptime(procurement.date_planned, '%Y-%m-%d %H:%M:%S') - relativedelta(days=procurement.product_id.produce_delay or 0.0) - newdate = newdate - relativedelta(days=company.manufacturing_lead) - produce_id = production_obj.create(cr, uid, { - 'origin': procurement.origin, - 'product_id': procurement.product_id.id, - 'product_qty': procurement.product_qty, - 'product_uom': procurement.product_uom.id, - 'product_uos_qty': procurement.product_uos and procurement.product_uos_qty or False, - 'product_uos': procurement.product_uos and procurement.product_uos.id or False, - 'location_src_id': procurement.location_id.id, - 'location_dest_id': procurement.location_id.id, - 'bom_id': procurement.bom_id and procurement.bom_id.id or False, - 'date_planned': newdate.strftime('%Y-%m-%d %H:%M:%S'), - 'move_prod_id': res_id, - 'company_id': procurement.company_id.id, - }) - + vals = self._prepare_mo_vals(cr, uid, procurement, context=context) + produce_id = production_obj.create(cr, uid, vals, context=context) res[procurement.id] = produce_id self.write(cr, uid, [procurement.id], {'state': 'running', 'production_id': produce_id}) bom_result = production_obj.action_compute(cr, uid, From a765876ffb946d52c2747617fdead3d3d7ffe172 Mon Sep 17 00:00:00 2001 From: Martin Trigaux Date: Wed, 3 Dec 2014 14:57:56 +0100 Subject: [PATCH 5/7] [IMP] web: do not fully hide pager in grouped view When the list view is grouped, the page count should be hidden as irrelevant. However if it's fully hidden, the limit can no longer be changed. Instead of hidding the pager, this commit hides the arrows and replaces the content by the current limit to allow to be changed. --- addons/web/static/src/js/view_list.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/addons/web/static/src/js/view_list.js b/addons/web/static/src/js/view_list.js index 3a3e8d55848..600e049d1ff 100644 --- a/addons/web/static/src/js/view_list.js +++ b/addons/web/static/src/js/view_list.js @@ -1578,7 +1578,9 @@ instance.web.ListView.Groups = instance.web.Class.extend( /** @lends instance.we .filter(function (column) { return column.tag === 'field' }) .pluck('name').value(), function (groups) { - self.view.$pager.hide(); + // page count is irrelevant on grouped page, replace by limit + self.view.$pager.find('.oe_pager_group').hide(); + self.view.$pager.find('.oe_list_pager_state').text(self.view._limit ? self.view._limit : '∞'); $el[0].appendChild( self.render_groups(groups)); if (post_render) { post_render(); } From d6daf5fa2f3960d40b0fdf7e93365d918dade565 Mon Sep 17 00:00:00 2001 From: Cedric Snauwaert Date: Fri, 12 Apr 2013 15:08:56 +0200 Subject: [PATCH 6/7] [FIX] product: add store=dict to field name_template Recompute the name_template field if the template changes. backport of 41628fc + f25c5d8 to 7.0 plus some optimisations in triggers Fixes #3277 --- addons/product/product.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/addons/product/product.py b/addons/product/product.py index 69dc23b3fb6..98a33a98f8a 100644 --- a/addons/product/product.py +++ b/addons/product/product.py @@ -530,6 +530,10 @@ class product_product(osv.osv): def _set_image(self, cr, uid, id, name, value, args, context=None): return self.write(cr, uid, [id], {'image': tools.image_resize_image_big(value)}, context=context) + def _get_name_template_ids(self, cr, uid, ids, context=None): + template_ids = self.pool.get('product.product').search(cr, uid, [('product_tmpl_id', 'in', ids)]) + return list(set(template_ids)) + _defaults = { 'active': lambda *a: 1, 'price_extra': lambda *a: 0.0, @@ -561,7 +565,11 @@ class product_product(osv.osv): 'price_extra': fields.float('Variant Price Extra', digits_compute=dp.get_precision('Product Price')), 'price_margin': fields.float('Variant Price Margin', digits_compute=dp.get_precision('Product Price')), 'pricelist_id': fields.dummy(string='Pricelist', relation='product.pricelist', type='many2one'), - 'name_template': fields.related('product_tmpl_id', 'name', string="Template Name", type='char', size=128, store=True, select=True), + 'name_template': fields.related('product_tmpl_id', 'name', string="Template Name", type='char', size=128, store={ + 'product.template': (_get_name_template_ids, ['name'], 10), + 'product.product': (lambda self, cr, uid, ids, c=None: ids, ['product_tmpl_id'], 10), + + }, select=True), 'color': fields.integer('Color Index'), # image: all image fields are base64 encoded and PIL-supported 'image': fields.binary("Image", From 7c49c6d79d2029023caad3394a791957f4637c85 Mon Sep 17 00:00:00 2001 From: Christophe Simonis Date: Wed, 3 Dec 2014 18:40:36 +0100 Subject: [PATCH 7/7] [FIX] purchase: do not use deprecated api --- addons/purchase/tests/test_average_price.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/addons/purchase/tests/test_average_price.py b/addons/purchase/tests/test_average_price.py index 4cc4849a33e..79d299a9080 100644 --- a/addons/purchase/tests/test_average_price.py +++ b/addons/purchase/tests/test_average_price.py @@ -22,7 +22,7 @@ #from openerp.test.common import TransactionCase from datetime import date from openerp.tests import common -from openerp import netsvc +from openerp import workflow class TestAveragePrice(common.TransactionCase): @@ -49,7 +49,6 @@ class TestAveragePrice(common.TransactionCase): _, self.supplier_location_id = self.registry('ir.model.data').get_object_reference(cr, uid, 'stock', 'stock_location_suppliers') _, input_account_id = self.registry('ir.model.data').get_object_reference(cr, uid, 'account', 'xfa') _, output_account_id = self.registry('ir.model.data').get_object_reference(cr, uid, 'account', 'xfa') - wf_service = netsvc.LocalService("workflow") self.standard_price = 10 self.order_price_unit = 20 @@ -97,8 +96,7 @@ class TestAveragePrice(common.TransactionCase): 'price_unit': self.order_price_unit }, context=context) - wf_service.trg_validate(uid, 'purchase.order', self.po_01_id, 'purchase_confirm', cr) - + workflow.trg_validate(uid, 'purchase.order', self.po_01_id, 'purchase_confirm', cr) def test_10_stock_move_action_done(self): cr, uid, context = self.cr, self.uid, {}