From 6cb195a3eb90ea1db8d3dda2fd7f22b300fc37ac Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Fri, 3 Feb 2017 12:06:09 +0100 Subject: [PATCH] Remove stored field product_supplier_code on stock.move because it takes a very very long time to compute on existing large DB and it is not needed by everybody. (#27) --- stock_usability/stock.py | 24 ------------------------ stock_usability/stock_view.xml | 3 --- 2 files changed, 27 deletions(-) diff --git a/stock_usability/stock.py b/stock_usability/stock.py index 4354be4..6172a25 100644 --- a/stock_usability/stock.py +++ b/stock_usability/stock.py @@ -77,30 +77,6 @@ class StockWarehouseOrderpoint(models.Model): class StockMove(models.Model): _inherit = 'stock.move' - product_supplier_code = fields.Char( - string='Supplier Code', compute='_compute_supplier_code', - store=True, readonly=True, - help="Supplier product code if Partner is the supplier") - -# It seems that it is not necessary any more to -# have the digits= on these 2 fields to fix the bug -# https://github.com/odoo/odoo/pull/10038 -# reserved_availability = fields.Float( -# digits=dp.get_precision('Product Unit of Measure')) -# availability = fields.Float( -# digits=dp.get_precision('Product Unit of Measure')) - - @api.multi - @api.depends('product_id', 'picking_id.partner_id') - def _compute_supplier_code(self): - for rec in self: - supplier_code = False - if rec.picking_id.partner_id and rec.product_id: - for supplier_info in rec.product_id.seller_ids: - if supplier_info.name == rec.picking_id.partner_id: - supplier_code = supplier_info.product_code - rec.product_supplier_code = supplier_code - def name_get(self, cr, uid, ids, context=None): '''name_get of stock_move is important for the reservation of the quants: so want to add the name of the customer and the expected date diff --git a/stock_usability/stock_view.xml b/stock_usability/stock_view.xml index e23c828..1dda15b 100644 --- a/stock_usability/stock_view.xml +++ b/stock_usability/stock_view.xml @@ -161,9 +161,6 @@ icon="STOCK_UNDO" groups="stock.group_stock_user" states="confirmed,assigned"/> - - -