(self, )
Get related dispensings and orders. Also sets dispense qty's
Get related dispensings and orders. Also sets dispense qty's
Get related dispensings and orders . Also sets dispense qty s
def _compute_dispensings_and_orders(self, ):
        ''' Get related dispensings and orders. Also sets dispense qty's '''

        dispense_ids, order_ids = [], []
        dispense_qty, pending_qty, cancel_qty, except_qty = 0.0, 0.0, 0.0, 0.0
        for line_id in self.sale_order_line_ids:

            order_ids.append(line_id.order_id)
            for proc_id in line_id.procurement_ids:

                dispense_ids.append(proc_id.id)

                if proc_id.product_uom.id != self.dispense_uom_id.id:
                    _qty = proc_id.product_uom._compute_qty_obj(
                        proc_id.product_qty, self.dispense_uom_id
                    )
                else:
                    _qty = self.dispense_uom_id

                if proc_id.state == 'done':
                    dispense_qty += _qty
                elif proc_id.state in ['confirmed', 'running']:
                    pending_qty += _qty
                elif proc_id.state == 'cancel':
                    cancel_qty += _qty
                else:
                    except_qty += _qty

        self.cancelled_dispense_qty = cancel_qty
        self.dispensed_qty = dispense_qty
        self.pending_dispense_qty = pending_qty
        self.exception_dispense_qty = except_qty

        self.order_ids = self.env['sale.order'].browse(set(order_ids))
        self.dispensed_ids = self.env['procurement.order'].browse(dispense_ids)
def _compute_dispensings_and_orders ( self , ) : dispense_ids , order_ids = [ ] , [ ] dispense_qty , pending_qty , cancel_qty , except_qty = 0.0 , 0.0 , 0.0 , 0.0 for line_id in self . sale_order_line_ids : order_ids . append ( line_id . order_id ) for proc_id in line_id . procurement_ids : dispense_ids . append ( proc_id . id ) if proc_id . product_uom . id != self . dispense_uom_id . id : _qty = proc_id . product_uom . _compute_qty_obj ( proc_id . product_qty , self . dispense_uom_id ) else : _qty = self . dispense_uom_id if proc_id . state == 'done' : dispense_qty += _qty elif proc_id . state in [ 'confirmed' , 'running' ] : pending_qty += _qty elif proc_id . state == 'cancel' : cancel_qty += _qty else : except_qty += _qty self . cancelled_dispense_qty = cancel_qty self . dispensed_qty = dispense_qty self . pending_dispense_qty = pending_qty self . exception_dispense_qty = except_qty self . order_ids = self . env [ 'sale.order' ] . browse ( set ( order_ids ) ) self . dispensed_ids = self . env [ 'procurement.order' ] . browse ( dispense_ids )