Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to Create procurements based on quantity ordered in openerp-9

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 181
    Comment on it

    To Create procurements based on quantity ordered in openerp-9 If the quantity is increased and new procurements are created then use this code given below in .py file

    def _action_procurement_create(self):
            precision = self.env['decimal.precision'].precision_get('Product Unit of Measure')
            new_procs = self.env['procurement.order'] #Empty recordset
            for line in self:
                if line.state != 'sale':
                    continue
                qty = 0.0
                for proc in line.procurement_ids:
                    qty += proc.product_qty
                if float_compare(qty, line.product_uom_qty, precision_digits=precision) >= 0:
                    return False
    
                if not line.order_id.procurement_group_id:
                    vals = line.order_id_prepare_procurement_group()
                    line.order_id.procurement_group_id = self.env["procurement.group"].create(vals)
    
                vals = line_prepare_order_line_procurement(group_id=line.order_id.procurement_group_id.id)
                vals['product_qty'] = line.product_uom_qty - qty
                new_proc = self.env["procurement.order"].create(vals)
                new_procs += new_proc
            new_procs.run()
            return new_procs
    

 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: