Odoo Procurement group dynamic run

22 views Asked by At

I'm trying to make the production check availability dynamically with my custom function. This is my function where the MO is being creating with the quantity difference for the child. I want to create the child MO with the ID linked with the source procurement group. The fields that i need to pass is:

  • Origin
  • Quantity
        origin = self.name
        procurement_group_id = self.procurement_group_id
        uom_reference = stock_move.product_id.uom_id
        quantity = stock_move.product_uom._compute_quantity((stock_move.product_uom_qty - stock_move.reserved_availability), uom_reference)
        try:
            procurement_group_id.with_context(clean_context(self.env.context)).run([
                procurement_group_id.Procurement(
                    stock_move.product_id, # Product
                    quantity, # Qty
                    uom_reference, # UoM
                    stock_move.warehouse_id.lot_stock_id,  # Location
                    origin,  # Name
                    origin,  # Origin
                    stock_move.warehouse_id.company_id,
                    {
                        'warehouse_id': stock_move.warehouse_id,
                        'route_ids': stock_move.route_ids,
                        'date_planned': stock_move.date,
                        'group_id': procurement_group_id,
                    } 
                )
            ])
        except UserError as error:
            raise UserError(error)

How can i have returned the id of document created?

I tried to search with reference on the database and retrieve the ID but sometimes it gets double+ ids returned. So i don't have trust of the datas returned.

0

There are 0 answers