@@ -6015,6 +6015,56 @@ describe("A Form", () => {
6015
6015
expect ( field_char ?. type ) . toBe ( "arrow_steps" ) ;
6016
6016
expect ( field_char ?. id ) . toBe ( "field_char" ) ;
6017
6017
} ) ;
6018
+ it ( "a field with autorefresh evaluated in attrs should be present in form autorefreshable fields property" , ( ) => {
6019
+ const fields = {
6020
+ field_char : {
6021
+ string : "Etapa" ,
6022
+ type : "char" ,
6023
+ } ,
6024
+ state : {
6025
+ readonly : true ,
6026
+ required : true ,
6027
+ selection : [
6028
+ [ "esborrany" , "Borrador" ] ,
6029
+ [ "validar" , "Validar" ] ,
6030
+ [ "pendent" , "Pendiente" ] ,
6031
+ [ "activa" , "Activa" ] ,
6032
+ [ "cancelada" , "Cancelada" ] ,
6033
+ [ "contracte" , "Activación Contrato" ] ,
6034
+ [ "novapolissa" , "Creación nuevo contrato" ] ,
6035
+ [ "modcontractual" , "Modificación Contractual" ] ,
6036
+ [ "impagament" , "Impago" ] ,
6037
+ [ "tall" , "Corte" ] ,
6038
+ [ "running" , "En ejecución" ] ,
6039
+ [ "baixa" , "Baja" ] ,
6040
+ [ "facturacio" , "Facturación" ] ,
6041
+ ] ,
6042
+ string : "Estado" ,
6043
+ type : "selection" ,
6044
+ views : { } ,
6045
+ } ,
6046
+ } ;
6047
+
6048
+ const xmlViewForm = `<?xml version="1.0"?>
6049
+ <form string="Form1">
6050
+ <field name="field_char" widget="arrow_steps" colspan="4" nolabel="1" attrs="{'autorefresh':[('state', '=', 'running')]}" />
6051
+ </form>` ;
6052
+
6053
+ const form = new Form ( fields ) ;
6054
+ form . parse ( xmlViewForm , {
6055
+ values : {
6056
+ field_char : "test" ,
6057
+ state : "running" ,
6058
+ } ,
6059
+ } ) ;
6060
+
6061
+ const field_char = form . findById ( "field_char" ) as Field ;
6062
+ expect ( field_char ) . toBeDefined ( ) ;
6063
+ expect ( field_char ?. autoRefresh ) . toBeTruthy ( ) ;
6064
+ expect ( field_char ?. readOnly ) . toBeTruthy ( ) ;
6065
+ expect ( form . autorefreshableFields . length ) . toBe ( 1 ) ;
6066
+ expect ( form . autorefreshableFields [ 0 ] ) . toBe ( "field_char" ) ;
6067
+ } ) ;
6018
6068
describe ( "If the field has widget_props" , ( ) => {
6019
6069
it ( "should merge widget_props from fields definition and xml" , ( ) => {
6020
6070
const fields = {
0 commit comments