From e8d8813c4fbcc10398b4590973e46cdcba17447b Mon Sep 17 00:00:00 2001 From: "Vir (Open ERP)" Date: Wed, 12 May 2010 19:35:51 +0530 Subject: [PATCH] [IMP,MOD] mrp_modules : Usability Improvements in MRP modules bzr revid: vir@tinyerp.com-20100512140551-bx331bz90n0bh5qp --- addons/mrp/mrp.py | 84 ++--- addons/mrp/mrp_view.xml | 78 ++-- .../mrp/report/mrp_production_order_view.xml | 4 +- .../mrp_operations/mrp_operations_report.xml | 2 +- addons/mrp_operations/mrp_operations_view.xml | 34 +- .../mrp_procurement/mrp_procurement_view.xml | 20 +- addons/mrp_repair/mrp_repair_view.xml | 339 ++++++++++-------- addons/resource/resource_view.xml | 9 +- 8 files changed, 321 insertions(+), 249 deletions(-) diff --git a/addons/mrp/mrp.py b/addons/mrp/mrp.py index d5cea81933b..b3b33ee0fd1 100644 --- a/addons/mrp/mrp.py +++ b/addons/mrp/mrp.py @@ -119,7 +119,7 @@ class mrp_bom(osv.osv): """ _name = 'mrp.bom' _description = 'Bills of Material' - + def _child_compute(self, cr, uid, ids, name, arg, context={}): """ Gets child bom. @param self: The object pointer @@ -154,13 +154,13 @@ class mrp_bom(osv.osv): result[bom.id] += map(lambda x: x.id, bom2.bom_lines) return result - + def _compute_type(self, cr, uid, ids, field_name, arg, context): """ Sets particular method for the selected bom type. @param field_name: Name of the field @param arg: User defined argument @return: Dictionary of values - """ + """ res = dict(map(lambda x: (x,''), ids)) for line in self.browse(cr, uid, ids): if line.type == 'phantom' and not line.bom_id: @@ -174,10 +174,10 @@ class mrp_bom(osv.osv): else: res[line.id] = 'order' return res - + _columns = { 'name': fields.char('Name', size=64, required=True), - 'code': fields.char('Code', size=16), + 'code': fields.char('Reference', size=16), 'active': fields.boolean('Active', help="If the active field is set to true, 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, help= "If a sub-product is used in several products, it can be useful to create its own BoM."\ @@ -212,7 +212,7 @@ class mrp_bom(osv.osv): 'product_rounding': lambda *a: 1.0, 'type': lambda *a: 'normal', 'company_id': lambda self,cr,uid,c: self.pool.get('res.company')._company_default_get(cr, uid, 'mrp.bom', context=c), - 'multi_level_bom': lambda *a: 0, + 'multi_level_bom': lambda *a: 0, } _order = "sequence" _sql_constraints = [ @@ -247,7 +247,7 @@ class mrp_bom(osv.osv): v['name'] = prod.name return {'value': v} return {} - + def _bom_find(self, cr, uid, product_id, product_uom, properties=[]): """ Finds BoM for particular product and product uom. @param product_id: Selected product. @@ -352,7 +352,7 @@ mrp_bom() class mrp_bom_revision(osv.osv): _name = 'mrp.bom.revision' _description = 'Bill of material revisions' - + _columns = { 'name': fields.char('Modification name', size=64, required=True), 'description': fields.text('Description'), @@ -399,7 +399,7 @@ class one2many_domain(fields.one2many): def set(self, cr, obj, id, field, values, user=None, context=None): if not values: return - return super(one2many_domain, self).set(cr, obj, id, field, values, + return super(one2many_domain, self).set(cr, obj, id, field, values, user=user, context=context) def get(self, cr, obj, ids, name, user=None, offset=0, context=None, values=None): @@ -420,12 +420,12 @@ class mrp_production(osv.osv): """ _name = 'mrp.production' _description = 'Production' - _date_name = 'date_planned' + _date_name = 'date_planned' def _production_calc(self, cr, uid, ids, prop, unknow_none, context={}): """ Calculates total hours and total no. of cycles for a production order. @param prop: Name of field. - @param unknow_none: + @param unknow_none: @return: Dictionary of values. """ result = {} @@ -442,7 +442,7 @@ class mrp_production(osv.osv): def _production_date_end(self, cr, uid, ids, prop, unknow_none, context={}): """ Finds production end date. @param prop: Name of field. - @param unknow_none: + @param unknow_none: @return: Dictionary of values. """ result = {} @@ -453,7 +453,7 @@ class mrp_production(osv.osv): def _production_date(self, cr, uid, ids, prop, unknow_none, context={}): """ Finds production planned date. @param prop: Name of field. - @param unknow_none: + @param unknow_none: @return: Dictionary of values. """ result = {} @@ -526,7 +526,7 @@ class mrp_production(osv.osv): 'company_id': lambda self, cr, uid, c: self.pool.get('res.company')._company_default_get(cr, uid, 'mrp.production', context=c), } _order = 'date_planned asc, priority desc'; - + def unlink(self, cr, uid, ids, context=None): productions = self.read(cr, uid, ids, ['state']) unlink_ids = [] @@ -586,7 +586,7 @@ class mrp_production(osv.osv): def action_picking_except(self, cr, uid, ids): """ Changes the state to Exception. - @return: True + @return: True """ self.write(cr, uid, ids, {'state': 'picking_except'}) return True @@ -669,12 +669,12 @@ class mrp_production(osv.osv): @return: True or False """ res = True - for production in self.browse(cr, uid, ids): - if production.move_lines: + for production in self.browse(cr, uid, ids): + if production.move_lines: res = False - if production.move_created_ids: - res = False + if production.move_created_ids: + res = False return res def action_produce(self, cr, uid, production_id, production_qty, production_mode, context=None): @@ -686,15 +686,15 @@ class mrp_production(osv.osv): @param production_qty: specify qty to produce @param production_mode: specify production mode (consume/consume&produce). @return: True - """ + """ stock_mov_obj = self.pool.get('stock.move') production = self.browse(cr, uid, production_id) - + raw_product_todo = [] - final_product_todo = [] - + final_product_todo = [] + if production_mode in ['consume','consume_produce']: - # To consume remaining qty of raw materials + # To consume remaining qty of raw materials consumed_products = {} produced_qty = 0 for consumed_product in production.move_lines2: @@ -703,18 +703,18 @@ class mrp_production(osv.osv): if not consumed_products.get(consumed_product.product_id.id, False): consumed_products[consumed_product.product_id.id] = 0 consumed_products[consumed_product.product_id.id] += consumed_product.product_qty - + for produced_product in production.move_created_ids2: if produced_product.scraped: continue produced_qty += produced_product.product_qty - for raw_product in production.move_lines: - consumed_qty = consumed_products.get(raw_product.product_id.id, 0) - consumed_qty -= produced_qty - rest_qty = production_qty - consumed_qty + for raw_product in production.move_lines: + consumed_qty = consumed_products.get(raw_product.product_id.id, 0) + consumed_qty -= produced_qty + rest_qty = production_qty - consumed_qty if rest_qty > production.product_qty: - rest_qty = production.product_qty + rest_qty = production.product_qty if rest_qty > 0: stock_mov_obj.action_consume(cr, uid, [raw_product.id], rest_qty, production.location_src_id.id, context=context) @@ -731,17 +731,17 @@ class mrp_production(osv.osv): produced_products[produced_product.product_id.id] = 0 produced_products[produced_product.product_id.id] += produced_product.product_qty - for produce_product in production.move_created_ids: - produced_qty = produced_products.get(produce_product.product_id.id, 0) + for produce_product in production.move_created_ids: + produced_qty = produced_products.get(produce_product.product_id.id, 0) rest_qty = production.product_qty - produced_qty if rest_qty <= production_qty: - production_qty = rest_qty + production_qty = rest_qty if rest_qty > 0 : - stock_mov_obj.action_consume(cr, uid, [produce_product.id], production_qty, production.location_dest_id.id, context=context) - - - for raw_product in production.move_lines2: - new_parent_ids = [] + stock_mov_obj.action_consume(cr, uid, [produce_product.id], production_qty, production.location_dest_id.id, context=context) + + + for raw_product in production.move_lines2: + new_parent_ids = [] parent_move_ids = [x.id for x in raw_product.move_history_ids] for final_product in production.move_created_ids2: if final_product.id not in parent_move_ids: @@ -792,9 +792,9 @@ class mrp_production(osv.osv): def action_in_production(self, cr, uid, ids): """ Changes state to In Production and writes starting date. - @return: True + @return: True """ - move_ids = [] + move_ids = [] self.write(cr, uid, ids, {'state': 'in_production', 'date_start': time.strftime('%Y-%m-%d %H:%M:%S')}) return True @@ -936,7 +936,7 @@ class mrp_production_workcenter_line(osv.osv): _name = 'mrp.production.workcenter.line' _description = 'Work Orders' _order = 'sequence' - + _columns = { 'name': fields.char('Work Order', size=64, required=True), 'workcenter_id': fields.many2one('mrp.workcenter', 'Work Center', required=True), @@ -955,7 +955,7 @@ mrp_production_workcenter_line() class mrp_production_product_line(osv.osv): _name = 'mrp.production.product.line' _description = 'Production scheduled products' - + _columns = { 'name': fields.char('Name', size=64, required=True), 'product_id': fields.many2one('product.product', 'Product', required=True), diff --git a/addons/mrp/mrp_view.xml b/addons/mrp/mrp_view.xml index dcea7ac4f9e..0aa4cf00f5f 100644 --- a/addons/mrp/mrp_view.xml +++ b/addons/mrp/mrp_view.xml @@ -7,7 +7,7 @@ - +
- - + + + + @@ -122,7 +124,7 @@ - + @@ -245,21 +247,21 @@ - + - + - + - - + + - + @@ -274,7 +276,7 @@ - + @@ -282,6 +284,27 @@ + + mrp.bom.select + mrp.bom + search + + + + + + + + + + + + + + + + + mrp.bom.tree mrp.bom @@ -308,7 +331,7 @@ mrp.bom form [('bom_id','=',False)] - + Bill of Material Components @@ -386,8 +409,8 @@ - + + @@ -406,7 +429,7 @@ mrp.production tree - + @@ -477,25 +500,25 @@ - +