예제 #1
0
        public OdooModel GetModel <T>(bool populateFields = true) where T : class
        {
            Attribute attribute = typeof(T).GetCustomAttribute(typeof(OdooModelNameAttribute));

            if (attribute is OdooModelNameAttribute modelNameAttribute)
            {
                OdooModel model = GetModel(modelNameAttribute.Name);
                if (populateFields)
                {
                    model.AddFields(GetOdooFields(typeof(T)));
                }

                return(model);
            }

            return(null);
        }
예제 #2
0
        public List <SunAccount> GetSunAccounts()
        {
            OdooCredentials   creds           = new OdooCredentials();
            OdooApi           api             = new OdooApi(creds, serverCertificateValidation: false);
            OdooModel         sunAccountModel = api.GetModel <SunAccount>();
            List <SunAccount> sunAccounts     = new List <SunAccount>();

            List <OdooRecord> records = sunAccountModel.SearchAll();

            foreach (var record in records)
            {
                var account = record.GetEntity <SunAccount>();
                sunAccounts.Add(account);
            }

            return(sunAccounts);
        }