Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to calculates quantity and Confirms production order in OpenERP

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 291
    Comment on it

    In OpenERP first we create the product and then calculates the quantity of product. In product form picking Id is generated and picking id will return to the value of this product and then product will calculated automatically in stock.

    Use this function given below

    def product_confirm(self, cr, uid, ids):
         
            picking_id = super(mrp_production,self).action_confirm(cr, uid, ids)
            for production in self.browse(cr, uid, ids):
                source = production.product_id.product_tmpl_id.property_stock_production.id
                if not production.bom_id:
                    continue
                for sub_product in production.bom_id.sub_products:
                    qty1 = sub_product.product_qty
                    qty2 = production.product_uos and production.product_uos_qty or False
                    if sub_product.subproduct_type == 'variable':
                        if production.product_qty:
                            qty1 *= production.product_qty / (production.bom_id.product_qty or 1.0)
                        if production.product_uos_qty:
                            qty2 *= production.product_uos_qty / (production.bom_id.product_uos_qty or 1.0)
                    data = {
                        'name': 'PROD:'+production.name,
                        'date': production.date_planned,
                        'product_id': sub_product.product_id.id,
                        'product_qty': qty1,
                        'product_uom': sub_product.product_uom.id,
                        'product_uos_qty': qty2,
                        'product_uos': production.product_uos and production.product_uos.id or False,
                        'location_id': source,
                        'location_dest_id': production.location_dest_id.id,
                        'move_dest_id': production.move_prod_id.id,
                        'state': 'waiting',
                        'production_id': production.id
                    }
                    self.pool.get('stock.move').create(cr, uid, data)
            return picking_id

     

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: