Making fields as Read only conditionally not working

Hi,

I am trying to make all the fields in Quote as "Read Only" when the Quote stage is "Invoiced/Credited"

Method 1:

For this I have created a file in src/custom/modules/Products/metadata/dependencydefs.php

<?php

$dependencies['Quotes']['read_only_fields'] = array();
      $fields = array(
            'description',
            'managing_business_c',
            'opportunity_name',
            'currency_id',
            'delivery_method_c',
            'quote_category_c',
      );

   $dependencies['Quotes']['read_only_fields'] = array(
         'hooks' => array("all"),
               'trigger' => 'or(equal(related($quotes,"quote_stage"),"Invoiced"),                                     equal(related($quotes,"quote_stage"),"Credited")

         )',
         'onload' => true,
         'actions' => array(),

   );

   foreach ($fields as $field) {
      $dependencies['Quotes']['read_only_fields']['actions'][] = array(
         'name' => 'ReadOnly',
         'params' => array(
         'target' => $field,
         'value' => 'or(equal(related($quotes,"quote_stage"),"Invoiced"), equal(related($quotes,"quote_stage"),"Credited")

          )',
      ),
   );

}

But the Method 1 doesn't make all the fields as "Read Only". Some fields are still editable.

Method 2:

But If I try to achieve the same using custom dependencies it will make all the fields as "Read Only"

For this I have created a file in src/custom/Extension/modules/Quotes/Ext/Dependencies/state-transition-invoiced-dep.php

<?php 

      $dependencies['Quotes']['state-transition-invoiced-dep'] = array(
               'hooks' => array('all'),
               'trigger' => 'or(equal($quote_stage,"Invoiced"),equal($quote_stage,"Credited"))',
               'onload' => true,
                'actions' => array(
                           array(
                                 'name' => 'ReadOnly',
                                 'params' => array(
                                 'target' => 'description',
                                 'value' => 'or(equal($quote_stage,"Invoiced"),equal($quote_stage,"Credited"))',
                           ),

                           array(
                                 'name' => 'ReadOnly',
                                 'params' => array(
                                 'target' => 'managing_business_c',
                                 'value' => 'or(equal($quote_stage,"Invoiced"),equal($quote_stage,"Credited"))',
                           ),

                           array(
                                 'name' => 'ReadOnly',
                                 'params' => array(
                                 'target' => 'opportunity_name',
                                 'value' => 'or(equal($quote_stage,"Invoiced"),equal($quote_stage,"Credited"))',
                           ),

                           array(
                                 'name' => 'ReadOnly',
                                 'params' => array(
                                 'target' => 'currency_id',
                                 'value' => 'or(equal($quote_stage,"Invoiced"),equal($quote_stage,"Credited"))',
                           ),

                           array(
                                 'name' => 'ReadOnly',
                                 'params' => array(
                                 'target' => 'delivery_method_c',
                                 'value' => 'or(equal($quote_stage,"Invoiced"),equal($quote_stage,"Credited"))',
                           ),

                           array(
                                 'name' => 'ReadOnly',
                                 'params' => array(
                                 'target' => 'quote_category_c',
                                 'value' => 'or(equal($quote_stage,"Invoiced"),equal($quote_stage,"Credited"))',
                           ),

                  )
      );