From f78e5b1b1bcb59f1397ee3b1c163fe59811f08d2 Mon Sep 17 00:00:00 2001 From: "Mayur Maheshwari (OpenERP)" Date: Tue, 16 Oct 2012 18:07:41 +0530 Subject: [PATCH 01/10] [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 - + From 83b87bbedc55ba73059324c38bf470f46dbb1fe4 Mon Sep 17 00:00:00 2001 From: "Mayur Maheshwari (OpenERP)" Date: Wed, 17 Oct 2012 10:42:54 +0530 Subject: [PATCH 02/10] [IMP]mrp_subproduct,sale_mrp,stock_no_autopicking : remove name field of mrp.bom object from yml file bzr revid: mma@tinyerp.com-20121017051254-mv926h6mo72shhnq --- addons/mrp_subproduct/test/mrp_subproduct.yml | 1 - addons/sale_mrp/test/sale_mrp.yml | 1 - addons/stock_no_autopicking/test/stock_no_autopicking.yml | 1 - 3 files changed, 3 deletions(-) diff --git a/addons/mrp_subproduct/test/mrp_subproduct.yml b/addons/mrp_subproduct/test/mrp_subproduct.yml index 99da9f22baf..d25cd18f774 100644 --- a/addons/mrp_subproduct/test/mrp_subproduct.yml +++ b/addons/mrp_subproduct/test/mrp_subproduct.yml @@ -6,7 +6,6 @@ - !record {model: mrp.bom, id: mrp.mrp_bom_24}: product_id: product.product_product_28 - name: External Hard Disk + Subproduct product_uom: product.product_uom_unit sub_products: - product_id: product.product_product_33 diff --git a/addons/sale_mrp/test/sale_mrp.yml b/addons/sale_mrp/test/sale_mrp.yml index 6fd64301af2..22f57ff3939 100644 --- a/addons/sale_mrp/test/sale_mrp.yml +++ b/addons/sale_mrp/test/sale_mrp.yml @@ -51,7 +51,6 @@ - !record {model: mrp.bom, id: mrp_bom_slidermobile0}: company_id: base.main_company - name: Slider Mobile product_efficiency: 1.0 product_id: product_product_slidermobile0 product_qty: 1.0 diff --git a/addons/stock_no_autopicking/test/stock_no_autopicking.yml b/addons/stock_no_autopicking/test/stock_no_autopicking.yml index ad0ad0fbf9e..1554f0d6df2 100644 --- a/addons/stock_no_autopicking/test/stock_no_autopicking.yml +++ b/addons/stock_no_autopicking/test/stock_no_autopicking.yml @@ -90,7 +90,6 @@ - !record {model: mrp.bom, id: mrp_bom_cupoftea0}: company_id: base.main_company - name: Cup of Tea product_efficiency: 1.0 product_id: product_product_cupoftea0 product_qty: 1.0 From 5fef3eb23f8a0d4a5c8f078832322365401650fd Mon Sep 17 00:00:00 2001 From: "Mayur Maheshwari (OpenERP)" Date: Wed, 17 Oct 2012 11:09:40 +0530 Subject: [PATCH 03/10] [IMP]stock_no_autopicking : remove name field of mrp.bom object from yml file bzr revid: mma@tinyerp.com-20121017053940-kn3i1rlwocgyxws0 --- addons/stock_no_autopicking/test/stock_no_autopicking.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/addons/stock_no_autopicking/test/stock_no_autopicking.yml b/addons/stock_no_autopicking/test/stock_no_autopicking.yml index 1554f0d6df2..e6ef8e2d7dd 100644 --- a/addons/stock_no_autopicking/test/stock_no_autopicking.yml +++ b/addons/stock_no_autopicking/test/stock_no_autopicking.yml @@ -98,21 +98,18 @@ routing_id: mrp_routing_productionrouting0 bom_lines: - company_id: base.main_company - name: Tea product_efficiency: 1.0 product_id: product_product_tea0 product_qty: 200.0 product_uom: product.product_uom_gram type: normal - company_id: base.main_company - name: Sugar product_efficiency: 1.0 product_id: product_product_sugar0 product_qty: 200.0 product_uom: product.product_uom_gram type: normal - company_id: base.main_company - name: Water product_efficiency: 1.0 product_id: product_product_milk0 product_qty: 0.5 From f006171ab387838a71c111f6e4d06cc520125ddc Mon Sep 17 00:00:00 2001 From: "Mayur Maheshwari (OpenERP)" Date: Wed, 17 Oct 2012 11:46:59 +0530 Subject: [PATCH 04/10] [IMP]mrp : improve bom structure report bzr revid: mma@tinyerp.com-20121017061659-bam8qklr8frdl8wo --- addons/mrp/report/bom_structure.py | 2 +- addons/mrp/report/bom_structure.rml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/mrp/report/bom_structure.py b/addons/mrp/report/bom_structure.py index 458a0c19649..465e1d7bcfc 100644 --- a/addons/mrp/report/bom_structure.py +++ b/addons/mrp/report/bom_structure.py @@ -38,7 +38,7 @@ class bom_structure(report_sxw.rml_parse): def _get_rec(object, level): for l in object: res = {} - res['name'] = l.name + res['name'] = l.product_id.name res['pname'] = l.product_id.name res['pcode'] = l.product_id.default_code res['pqty'] = l.product_qty diff --git a/addons/mrp/report/bom_structure.rml b/addons/mrp/report/bom_structure.rml index cdc27c08d87..0b668e4f9e6 100644 --- a/addons/mrp/report/bom_structure.rml +++ b/addons/mrp/report/bom_structure.rml @@ -116,7 +116,7 @@ - [[ o.name ]] + [[ o.product_id.name ]] [ [[ (o.product_id.default_code) or removeParentNode('font') ]] ] [[ o.product_id.name ]] From 71f65114cd58494e3a55c92a2bf16456d80cacad Mon Sep 17 00:00:00 2001 From: "Mayur Maheshwari (OpenERP)" Date: Wed, 17 Oct 2012 14:35:36 +0530 Subject: [PATCH 05/10] [IMP]mrp : added a name_search method in mrp.bom object for serch via code and product name bzr revid: mma@tinyerp.com-20121017090536-6mejdgejv8dtmqeh --- addons/mrp/mrp.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/addons/mrp/mrp.py b/addons/mrp/mrp.py index ca100da6200..1f83e7564e6 100644 --- a/addons/mrp/mrp.py +++ b/addons/mrp/mrp.py @@ -148,6 +148,15 @@ class mrp_bom(osv.osv): res.append((record['id'], name)) return res + def name_search(self, cr, user, name, args=None, operator='ilike', context=None, limit=100): + if not args: + args = [] + if context is None: + context = {} + ids = self.search(cr, user, [('code', '=', name)]+ args, limit=limit, context=context) + ids += self.search(cr, user, [('product_id.name',operator,name)] + args, limit=limit, context=context) + return self.name_get(cr, user, ids, context) + def _child_compute(self, cr, uid, ids, name, arg, context=None): """ Gets child bom. @param self: The object pointer From 34e660c8e7a1869a185ef65d4d334b9ad0e9cc7a Mon Sep 17 00:00:00 2001 From: "Mayur Maheshwari (OpenERP)" Date: Wed, 17 Oct 2012 15:22:02 +0530 Subject: [PATCH 06/10] [IMP]mrp : improve litle bit code bzr revid: mma@tinyerp.com-20121017095202-eg3pedyqgjk0x22i --- addons/mrp/mrp.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/mrp/mrp.py b/addons/mrp/mrp.py index 1f83e7564e6..2386b8295a7 100644 --- a/addons/mrp/mrp.py +++ b/addons/mrp/mrp.py @@ -154,7 +154,7 @@ class mrp_bom(osv.osv): if context is None: context = {} ids = self.search(cr, user, [('code', '=', name)]+ args, limit=limit, context=context) - ids += self.search(cr, user, [('product_id.name',operator,name)] + args, limit=limit, context=context) + ids += self.search(cr, user, [('product_id',operator,name)] + args, limit=limit, context=context) return self.name_get(cr, user, ids, context) def _child_compute(self, cr, uid, ids, name, arg, context=None): From 4f51b5074f3d1dbad5e24014356289402ebe7a55 Mon Sep 17 00:00:00 2001 From: "Mayur Maheshwari (OpenERP)" Date: Wed, 17 Oct 2012 17:48:04 +0530 Subject: [PATCH 07/10] [IMP]mrp : improve name serch code bzr revid: mma@tinyerp.com-20121017121804-fqperqam3p2sg9bs --- addons/mrp/mrp.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/addons/mrp/mrp.py b/addons/mrp/mrp.py index 2386b8295a7..e69b3b961c8 100644 --- a/addons/mrp/mrp.py +++ b/addons/mrp/mrp.py @@ -153,8 +153,7 @@ class mrp_bom(osv.osv): args = [] if context is None: context = {} - ids = self.search(cr, user, [('code', '=', name)]+ args, limit=limit, context=context) - ids += self.search(cr, user, [('product_id',operator,name)] + args, limit=limit, context=context) + ids = self.search(cr, user, ['|', ('code', '=', name), ('product_id',operator,name)]+ args, limit=limit, context=context) return self.name_get(cr, user, ids, context) def _child_compute(self, cr, uid, ids, name, arg, context=None): From 8c47c971c5470562d0c9ee17dc77db6c2086da97 Mon Sep 17 00:00:00 2001 From: "Mayur Maheshwari (OpenERP)" Date: Thu, 18 Oct 2012 15:52:20 +0530 Subject: [PATCH 08/10] [FIX]Stock : Fix the Tracebility error Up & Down Server Error bzr revid: mma@tinyerp.com-20121018102220-x3jlqe126elzah1g --- addons/stock/wizard/stock_traceability.py | 1 - 1 file changed, 1 deletion(-) diff --git a/addons/stock/wizard/stock_traceability.py b/addons/stock/wizard/stock_traceability.py index 28007592f23..d61f6323f77 100644 --- a/addons/stock/wizard/stock_traceability.py +++ b/addons/stock/wizard/stock_traceability.py @@ -52,7 +52,6 @@ class action_traceability(osv.osv_memory): value = { 'domain': "[('id','in',["+','.join(map(str, ids))+"])]", 'name': ((type1=='move_history_ids2') and _('Upstream Traceability')) or _('Downstream Traceability'), - 'view_type': 'tree', 'view_mode': 'tree', 'res_model': 'stock.move', 'field_parent': type1, From 5cd70ef9e8baf7e0f7c41d808c5bdbcba77162d6 Mon Sep 17 00:00:00 2001 From: "Mayur Maheshwari (OpenERP)" Date: Mon, 29 Oct 2012 11:54:42 +0530 Subject: [PATCH 09/10] [IMP]mrp : improve little bit code bzr revid: mma@tinyerp.com-20121029062442-imihipixq7g7llcb --- addons/mrp/mrp.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/addons/mrp/mrp.py b/addons/mrp/mrp.py index 2de0641eb53..56a630ac4a8 100644 --- a/addons/mrp/mrp.py +++ b/addons/mrp/mrp.py @@ -139,10 +139,11 @@ class mrp_bom(osv.osv): return [] if isinstance(ids, (long, int)): ids = [ids] - reads = self.read(cr, uid, ids, ['code','product_id'], context=context) + product_obj = self.pool.get('product.product') + records = 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 + for record in records: + name = product_obj.browse(cr, uid, record['product_id'][0], context=context).name if record['code']: name = name +' - '+ record['code'] res.append((record['id'], name)) From b31df93d2b917c78ced2b5f8f5ad1b4400cbd84d Mon Sep 17 00:00:00 2001 From: "Mayur Maheshwari (OpenERP)" Date: Mon, 29 Oct 2012 12:37:17 +0530 Subject: [PATCH 10/10] [IMP]mrp : improve code bzr revid: mma@tinyerp.com-20121029070717-84dp16ivxzuk3b4j --- addons/mrp/mrp.py | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/addons/mrp/mrp.py b/addons/mrp/mrp.py index 56a630ac4a8..0ba5692f67a 100644 --- a/addons/mrp/mrp.py +++ b/addons/mrp/mrp.py @@ -135,18 +135,16 @@ class mrp_bom(osv.osv): _inherit = ['mail.thread'] def name_get(self, cr, uid, ids, context=None): - if isinstance(ids, (list, tuple)) and not ids: + if not ids: return [] if isinstance(ids, (long, int)): ids = [ids] - product_obj = self.pool.get('product.product') - records = self.read(cr, uid, ids, ['code','product_id'], context=context) res = [] - for record in records: - name = product_obj.browse(cr, uid, record['product_id'][0], context=context).name - if record['code']: - name = name +' - '+ record['code'] - res.append((record['id'], name)) + for bom in self.browse(cr, uid, ids, context=context): + name = bom.product_id.name + if bom.code: + name = name +' - '+ bom.code + res.append((bom['id'], name)) return res def name_search(self, cr, user, name, args=None, operator='ilike', context=None, limit=100):