(self, )
return True
Validate whether the line can be dispensed based on Rx, pending
        dispensings, etc.
        :returns: bool -- If line can be processed
        :raises: :class:`openerp.exceptions.ValidationError`
Validate whether the line can be dispensed based on Rx, pending
        dispensings, etc.
        :returns: bool -- If line can be processed
        :raises: :class:`openerp.exceptions.ValidationError`
Validate whether the line can be dispensed based on Rx pending dispensings etc . : returns : bool -- If line can be processed : raises : : class : openerp . exceptions . ValidationError
def _check_sale_line_prescription(self, ):
        '''
        Validate whether the line can be dispensed based on Rx, pending
        dispensings, etc.
        :returns: bool -- If line can be processed
        :raises: :class:`openerp.exceptions.ValidationError`
        '''

        if not self.medication_id.medicament_id.is_medicament:
            return True
        if not self.medication_id.medicament_id.is_prescription:
            return True

        rx_line = self.prescription_order_line_id

        if self.patient_id != rx_line.patient_id:
            raise ValidationError(_(
                'Patients must be same on Order and Rx lines. '
                'Got %s on order line %d, expected %s from rx line %d' % (
                    self.patient_id.name, self.id,
                    rx_line.patient_id.name, rx_line.id,
                ),
            ))

        if rx_line.product_id != self.product_id:
            if not self.is_substitutable:
                raise ValidationError(_(
                    'Products must be same on Order and Rx lines. '
                    'Got %s on order line %d, expected %s from rx line %d' % (
                        self.product_id.name, self.id,
                        rx_line.product_id.name, rx_line.id,
                    ),
                ))
            else:
                raise NotImplementedError(_(
                    'Drug substitution validation has not been implemented.'
                ))

        if not rx_line.can_dispense:
            raise ValidationError(_(
                'Cannot dispense - currently %f pending and %f exception.' % (
                    rx_line.pending_dispense_qty,
                    rx_line.exception_dispense_qty,
                )
            ))

        if self.dispense_qty > rx_line.can_dispense_qty:
            raise ValidationError(_(
                'Cannot dispense - Order line %s goes over Rx qty by %d' % (
                    self.name, self.dispense_qty - rx_line.can_dispense_qty
                )
            ))

        return True
def _check_sale_line_prescription ( self , ) : if not self . medication_id . medicament_id . is_medicament : return True if not self . medication_id . medicament_id . is_prescription : return True rx_line = self . prescription_order_line_id if self . patient_id != rx_line . patient_id : raise ValidationError ( _ ( 'Patients must be same on Order and Rx lines. ' 'Got %s on order line %d, expected %s from rx line %d' % ( self . patient_id . name , self . id , rx_line . patient_id . name , rx_line . id , ) , ) ) if rx_line . product_id != self . product_id : if not self . is_substitutable : raise ValidationError ( _ ( 'Products must be same on Order and Rx lines. ' 'Got %s on order line %d, expected %s from rx line %d' % ( self . product_id . name , self . id , rx_line . product_id . name , rx_line . id , ) , ) ) else : raise NotImplementedError ( _ ( 'Drug substitution validation has not been implemented.' ) ) if not rx_line . can_dispense : raise ValidationError ( _ ( 'Cannot dispense - currently %f pending and %f exception.' % ( rx_line . pending_dispense_qty , rx_line . exception_dispense_qty , ) ) ) if self . dispense_qty > rx_line . can_dispense_qty : raise ValidationError ( _ ( 'Cannot dispense - Order line %s goes over Rx qty by %d' % ( self . name , self . dispense_qty - rx_line . can_dispense_qty ) ) ) return True