From f78e5b1b1bcb59f1397ee3b1c163fe59811f08d2 Mon Sep 17 00:00:00 2001 From: "Mayur Maheshwari (OpenERP)" Date: Tue, 16 Oct 2012 18:07:41 +0530 Subject: [PATCH] [IMP]mrp : improve string and remove name field from mrp.bom object bzr revid: mma@tinyerp.com-20121016123741-g042zhrmmyfqb0sa --- addons/mrp/mrp.py | 21 ++++++++-- addons/mrp/mrp_demo.xml | 41 ------------------- addons/mrp/mrp_view.xml | 12 ++---- .../wizard/stock_fill_inventory_view.xml | 2 +- 4 files changed, 22 insertions(+), 54 deletions(-) diff --git a/addons/mrp/mrp.py b/addons/mrp/mrp.py index 3ae27bf2c41..ca100da6200 100644 --- a/addons/mrp/mrp.py +++ b/addons/mrp/mrp.py @@ -134,6 +134,20 @@ class mrp_bom(osv.osv): _description = 'Bill of Material' _inherit = ['mail.thread'] + def name_get(self, cr, uid, ids, context=None): + if isinstance(ids, (list, tuple)) and not ids: + return [] + if isinstance(ids, (long, int)): + ids = [ids] + reads = self.read(cr, uid, ids, ['code','product_id'], context=context) + res = [] + for record in reads: + name = self.pool.get('product.product').browse(cr, uid, record['product_id'][0], context=context).name + if record['code']: + name = name +' - '+ record['code'] + res.append((record['id'], name)) + return res + def _child_compute(self, cr, uid, ids, name, arg, context=None): """ Gets child bom. @param self: The object pointer @@ -192,7 +206,6 @@ class mrp_bom(osv.osv): return res _columns = { - 'name': fields.char('Name', size=64, required=True), 'code': fields.char('Reference', size=16), 'active': fields.boolean('Active', help="If the active field is set to False, it will allow you to hide the bills of material without removing it."), 'type': fields.selection([('normal','Normal BoM'),('phantom','Sets / Phantom')], 'BoM Type', required=True, @@ -263,7 +276,7 @@ class mrp_bom(osv.osv): (_check_product, 'BoM line product should not be same as BoM product.', ['product_id']), ] - def onchange_product_id(self, cr, uid, ids, product_id, name, context=None): + def onchange_product_id(self, cr, uid, ids, product_id, context=None): """ Changes UoM and name if product_id changes. @param name: Name of the field @param product_id: Changed product_id @@ -271,7 +284,7 @@ class mrp_bom(osv.osv): """ if product_id: prod = self.pool.get('product.product').browse(cr, uid, product_id, context=context) - return {'value': {'name': prod.name, 'product_uom': prod.uom_id.id}} + return {'value': {'product_uom': prod.uom_id.id}} return {} def onchange_uom(self, cr, uid, ids, product_id, product_uom, context=None): @@ -371,7 +384,7 @@ class mrp_bom(osv.osv): if default is None: default = {} bom_data = self.read(cr, uid, id, [], context=context) - default.update(name=_("%s (copy)") % (bom_data['name']), bom_id=False) + default.update(bom_id=False) return super(mrp_bom, self).copy_data(cr, uid, id, default, context=context) def create(self, cr, uid, vals, context=None): diff --git a/addons/mrp/mrp_demo.xml b/addons/mrp/mrp_demo.xml index 952a5e0e3de..f13d2517460 100644 --- a/addons/mrp/mrp_demo.xml +++ b/addons/mrp/mrp_demo.xml @@ -244,7 +244,6 @@ - HDD 500GB 1 @@ -254,7 +253,6 @@ - 320GB HDD 2 @@ -264,7 +262,6 @@ - HDD 2TB on Demand 1 @@ -274,7 +271,6 @@ - HDD 500GB 4 @@ -284,7 +280,6 @@ - HDD on Demand 1 @@ -293,7 +288,6 @@ - 320GB HDD 1 @@ -303,7 +297,6 @@ - Laptop Customized 1 @@ -313,7 +306,6 @@ - Windows 7 Professional 1 @@ -323,7 +315,6 @@ - USB Keyboard, QWERTY 1 @@ -333,7 +324,6 @@ - Mouse, Wireless 1 @@ -343,7 +333,6 @@ - Laptop Customized + Azerty 1 @@ -352,7 +341,6 @@ - Windows 7 Professional 1 @@ -362,7 +350,6 @@ - USB Keyboard, AZERTY 1 @@ -372,7 +359,6 @@ - Mouse, Laser 1 @@ -382,7 +368,6 @@ - Computer Case-1 1 @@ -391,7 +376,6 @@ - Processesor AMD 8-Core 1 @@ -401,7 +385,6 @@ - Motherboard I9P57 1 @@ -411,7 +394,6 @@ - HDD 320GB 1 @@ -421,7 +403,6 @@ - Computer Case-2 1 @@ -430,7 +411,6 @@ - Processor Core i5 2.70 Ghz 1 @@ -440,7 +420,6 @@ - Motherboard A20Z7 1 @@ -450,7 +429,6 @@ - HDD 500GB 1 @@ -460,7 +438,6 @@ - Graphics Card 1 @@ -470,7 +447,6 @@ - PC Assemble + 2GB RAM 1 @@ -479,7 +455,6 @@ - 15" LCD Monitor 1 @@ -489,7 +464,6 @@ - Computer Case-1 1 @@ -499,7 +473,6 @@ - Mouse, Laser 1 @@ -509,7 +482,6 @@ - USB Keyboard, QWERTY 1 @@ -519,7 +491,6 @@ - RAM DDR2 1GB 2 @@ -529,7 +500,6 @@ - PC Assemble + 512MB RAM 1 @@ -539,7 +509,6 @@ - 17" LCD Monitor 1 @@ -549,7 +518,6 @@ - Computer Case-2 1 @@ -559,7 +527,6 @@ - Mouse, Laser 1 @@ -569,7 +536,6 @@ - USB Keyboard, QWERTY 1 @@ -579,7 +545,6 @@ - RAM DDR 512MB 1 @@ -589,7 +554,6 @@ - PC Assemble + Custom RAM (PC on Demand) 1 @@ -599,7 +563,6 @@ - 15" LCD Monitor 1 @@ -609,7 +572,6 @@ - Computer Case-1 1 @@ -619,7 +581,6 @@ - RAM DDR 512MB 1 @@ -629,7 +590,6 @@ - Mouse, Laser 1 @@ -639,7 +599,6 @@ - USB Keyboard, QWERTY 1 diff --git a/addons/mrp/mrp_view.xml b/addons/mrp/mrp_view.xml index 9d1ae9eae8a..0e47331bcbf 100644 --- a/addons/mrp/mrp_view.xml +++ b/addons/mrp/mrp_view.xml @@ -347,7 +347,7 @@
- + -

@@ -380,10 +379,9 @@ - + - @@ -421,7 +419,7 @@ mrp.bom - + @@ -442,7 +440,6 @@ - @@ -462,9 +459,8 @@ - - + diff --git a/addons/stock/wizard/stock_fill_inventory_view.xml b/addons/stock/wizard/stock_fill_inventory_view.xml index 5533bf0580e..3f25cd27f86 100644 --- a/addons/stock/wizard/stock_fill_inventory_view.xml +++ b/addons/stock/wizard/stock_fill_inventory_view.xml @@ -6,7 +6,7 @@ stock.fill.inventory - +