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
    • 306
    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

    1. def product_confirm(self, cr, uid, ids):
    2. picking_id = super(mrp_production,self).action_confirm(cr, uid, ids)
    3. for production in self.browse(cr, uid, ids):
    4. source = production.product_id.product_tmpl_id.property_stock_production.id
    5. if not production.bom_id:
    6. continue
    7. for sub_product in production.bom_id.sub_products:
    8. qty1 = sub_product.product_qty
    9. qty2 = production.product_uos and production.product_uos_qty or False
    10. if sub_product.subproduct_type == 'variable':
    11. if production.product_qty:
    12. qty1 *= production.product_qty / (production.bom_id.product_qty or 1.0)
    13. if production.product_uos_qty:
    14. qty2 *= production.product_uos_qty / (production.bom_id.product_uos_qty or 1.0)
    15. data = {
    16. 'name': 'PROD:'+production.name,
    17. 'date': production.date_planned,
    18. 'product_id': sub_product.product_id.id,
    19. 'product_qty': qty1,
    20. 'product_uom': sub_product.product_uom.id,
    21. 'product_uos_qty': qty2,
    22. 'product_uos': production.product_uos and production.product_uos.id or False,
    23. 'location_id': source,
    24. 'location_dest_id': production.location_dest_id.id,
    25. 'move_dest_id': production.move_prod_id.id,
    26. 'state': 'waiting',
    27. 'production_id': production.id
    28. }
    29. self.pool.get('stock.move').create(cr, uid, data)
    30. return picking_id

     

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Reset Password
Fill out the form below and reset your password: