From f2117bf48215482aa4b8efc8b96e37645c0bc726 Mon Sep 17 00:00:00 2001 From: "uco (OpenERP)" Date: Mon, 5 Apr 2010 17:58:03 +0530 Subject: [PATCH] [ADD, IMP] mrp: Added doc strings in functions and classes. Improve spacing in docstrings of wizard files. bzr revid: uco@tinyerp.co.in-20100405122803-lvkh410ncgj2tte6 --- addons/mrp/mrp.py | 260 +++++++++++++++--- addons/mrp/stock.py | 36 ++- addons/mrp/wizard/change_production_qty.py | 35 +-- addons/mrp/wizard/make_procurement_product.py | 54 ++-- addons/mrp/wizard/mrp_price.py | 15 +- addons/mrp/wizard/mrp_product_produce.py | 32 +-- addons/mrp/wizard/mrp_track_prod.py | 9 +- addons/mrp/wizard/mrp_workcenter_load.py | 15 +- addons/mrp/wizard/orderpoint_procurement.py | 21 +- addons/mrp/wizard/schedulers_all.py | 20 +- 10 files changed, 337 insertions(+), 160 deletions(-) diff --git a/addons/mrp/mrp.py b/addons/mrp/mrp.py index a238658302c..9ca9fee3e91 100644 --- a/addons/mrp/mrp.py +++ b/addons/mrp/mrp.py @@ -65,6 +65,9 @@ mrp_workcenter() class mrp_property_group(osv.osv): + """ + Group of mrp properties. + """ _name = 'mrp.property.group' _description = 'Property Group' _columns = { @@ -74,6 +77,9 @@ class mrp_property_group(osv.osv): mrp_property_group() class mrp_property(osv.osv): + """ + Properties of mrp. + """ _name = 'mrp.property' _description = 'Property' _columns = { @@ -88,6 +94,9 @@ class mrp_property(osv.osv): mrp_property() class mrp_routing(osv.osv): + """ + For specifying the routings of workcenters. + """ _name = 'mrp.routing' _description = 'Routing' _columns = { @@ -110,6 +119,9 @@ class mrp_routing(osv.osv): mrp_routing() class mrp_routing_workcenter(osv.osv): + """ + Defines working cycles and hours of a workcenter using routings. + """ _name = 'mrp.routing.workcenter' _description = 'Routing workcenter usage' _columns = { @@ -131,19 +143,22 @@ class mrp_routing_workcenter(osv.osv): mrp_routing_workcenter() class mrp_bom(osv.osv): + """ + Defines bills of material for a product. + """ _name = 'mrp.bom' _description = 'Bills of Material' + def _child_compute(self, cr, uid, ids, name, arg, context={}): - """ - @param self: The object pointer. - @param cr: A database cursor - @param uid: ID of the user currently logged in - @param ids: the ID of mrp.production object - @param name: name of the field - @param arg: user defined argument - - @return: True - + """ Gets child bom. + @param self: The object pointer + @param cr: The current row, from the database cursor, + @param uid: The current user ID for security checks + @param ids: List of selected IDs + @param name: Name of the field + @param arg: User defined argument + @param context: A standard dictionary for contextual values + @return: Dictionary of values """ result = {} for bom in self.browse(cr, uid, ids, context=context): @@ -158,7 +173,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: @@ -172,6 +193,7 @@ 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), @@ -234,6 +256,11 @@ class mrp_bom(osv.osv): def onchange_product_id(self, cr, uid, ids, product_id, name, context={}): + """ Changes UoM and name if product_id changes. + @param name: Name of the field + @param product_id: Changed product_id + @return: Dictionary of changed values + """ if product_id: prod=self.pool.get('product.product').browse(cr,uid,[product_id])[0] v = {'product_uom':prod.uom_id.id} @@ -243,6 +270,12 @@ class mrp_bom(osv.osv): 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. + @param product_uom: Unit of measure of a product. + @param properties: List of related properties. + @return: False or BoM id. + """ bom_result = False # Why searching on BoM without parent ? cr.execute('select id from mrp_bom where product_id=%s and bom_id is null order by sequence', (product_id,)) @@ -260,6 +293,15 @@ class mrp_bom(osv.osv): return result def _bom_explode(self, cr, uid, bom, factor, properties, addthis=False, level=0): + """ Finds Products and Workcenters for related BoM for manufacturing order. + @param bom: BoM of particular product. + @param factor: Factor of product UoM. + @param properties: A dictionary for contextual values. + @param addthis: If BoM found then True else False. + @param level: Depth level to find BoM lines starts from 10. + @return: result: List of dictionaries containing product details. + result2: List of dictionaries containing workcenter details. + """ factor = factor / (bom.product_efficiency or 1.0) factor = rounding(factor, bom.product_rounding) if factor