public ButtonData(OperationData operationData)
        {
            Parent = operationData;

            OnClick = operationData.Name;
            Typage = "object";

            Label = operationData.Alias;
            States = "";
            Name = "";
            Text = "";

            RenderXML = true;
        }
Ejemplo n.º 2
0
        public OperationData GetOperation(string typage, string key)
        {
            foreach (KeyValuePair <string, OperationData> operationDataKV in ListOfOperations)
            {
                OperationData operationData = operationDataKV.Value;

                string[] states = operationData.State.Split(new char[] { '.' });

                if (states.Length == 2)
                {
                    if ((states[0].Trim().ToLower().Equals(typage.ToLower())) && (states[1].Trim().ToLower().Equals(key.ToLower())))
                    {
                        return(operationData);
                    }
                }
            }

            return(null);
        }
Ejemplo n.º 3
0
        public void Create()
        {
            Name = Name.Replace(".", "_");

            List <PropertyData> listOfPropertyData_Code   = new List <PropertyData>();
            List <PropertyData> listOfPropertyData_Name   = new List <PropertyData>();
            List <PropertyData> listOfPropertyData_Others = new List <PropertyData>();

            foreach (PropertyData propertyData in ListOfProperties)
            {
                if (propertyData.Name.Equals("code"))
                {
                    listOfPropertyData_Code.Add(propertyData);
                }
                else if (propertyData.Name.Equals("name"))
                {
                    listOfPropertyData_Name.Add(propertyData);
                }
                else
                {
                    listOfPropertyData_Others.Add(propertyData);
                }
            }

            ListOfProperties = new List <PropertyData>();
            ListOfProperties.AddRange(listOfPropertyData_Code);
            ListOfProperties.AddRange(listOfPropertyData_Name);
            ListOfProperties.AddRange(listOfPropertyData_Others);


            ListOfGroups = new Dictionary <string, GroupData>();

            ListOfGroupsReport     = new Dictionary <string, GroupData>();
            ListOfPropertiesReport = new List <PropertyData>();

            GroupData rootGroupData = new GroupData("default");

            rootGroupData.Root      = true;
            rootGroupData.ClassData = this;
            rootGroupData.Report    = false;
            ListOfGroups.Add("default", rootGroupData);

            GroupData rootReportGroupData = new GroupData("default");

            rootReportGroupData.Root      = true;
            rootReportGroupData.ClassData = this;
            rootReportGroupData.Report    = true;


            string sel = "";
            List <PropertyData> listOfDates = new List <PropertyData>();

            foreach (PropertyData propertyData in ListOfProperties)
            {
                if (propertyData.Typage.Equals("date") || propertyData.Typage.Equals("datetime") || propertyData.Typage.Equals("time"))
                {
                    listOfDates.Add(propertyData);
                    ListOfPropertiesReport.Add(propertyData);
                }
            }

            if (listOfDates.Count > 0)
            {
                sel += "('date', 'Date'),";
            }

            if (!sel.Equals(""))
            {
                PropertyData property = new PropertyData();
                property.Name   = "filtrerpar";
                property.Alias  = "Filtrer par";
                property.Typage = "selection";

                sel = sel.Substring(0, sel.Length - 1);
                property.Selection = "[" + sel + "]";


                PageData pageFilter = new PageData("Filtres");
                pageFilter.ListOfGroups["default"]           = new GroupData("default");
                pageFilter.ListOfGroups["default"].ClassData = this;
                pageFilter.ListOfGroups["default"].ListOfProperties.Add(property);
                ListOfPropertiesReport.Add(property);

                if (listOfDates.Count > 0)
                {
                    pageFilter.ListOfGroups["default"].ListOfGroups.Add("dates", new GroupData("Dates", this));
                    pageFilter.ListOfGroups["default"].ListOfGroups["dates"].ListOfProperties = listOfDates;
                }

                rootReportGroupData.ListOfPages.Add("filter", pageFilter);
            }


            rootReportGroupData.ListOfPages.Add("avances", new PageData("Avancés"));
            rootReportGroupData.ListOfPages.Add("options", new PageData("Options"));

            ListOfGroupsReport.Add("default", rootReportGroupData);

            foreach (PropertyData propertyData in ListOfProperties)
            {
                bool dontthread = false;

                if (!propertyData.Name.Equals(Name + "_id"))
                {
                    propertyData.Update();


                    if ((propertyData.Name.Equals("state")) && (propertyData.Typage.Equals("selection")))
                    {
                        dontthread    = true;
                        StateWorkflow = true;
                        StateProperty = propertyData;

                        propertyData.Readonly = "1";
                        propertyData.Select   = "1";

                        ListOfWorkFlowButton   = new Dictionary <string, ButtonData>();
                        ListOfWorkFlowFunction = new Dictionary <string, OperationData>();
                        foreach (KeyValuePair <string, string> KeyValue in propertyData.SelectionData.ListOfValues)
                        {
                            OperationData operationData = GetOperation(propertyData.TypageInitial, KeyValue.Key);

                            if (operationData != null)
                            {
                                ButtonData buttonData = new ButtonData();
                                buttonData.States = KeyValue.Key;

                                if (operationData.CallBy.Equals("button"))
                                {
                                    buttonData.Text = KeyValue.Value;
                                    buttonData.Name = operationData.Name;
                                }
                                else if (operationData.CallBy.Equals(""))
                                {
                                    buttonData.RenderXML = false;
                                    ListOfWorkFlowFunction.Add(KeyValue.Key, operationData);

                                    operationData.ReturnType = "boolean";
                                }

                                ListOfWorkFlowButton.Add(KeyValue.Key, buttonData);
                            }
                        }
                    }
                    else if (propertyData.Name.Equals("name"))
                    {
                        //
                    }
                    else if (propertyData.Name.Equals("code"))
                    {
                        if (!Code.Equals(""))
                        {
                            CodeProperty      = propertyData;
                            propertyData.Uniq = true;
                        }
                    }
                    else if (propertyData.Name.Equals("sequence"))
                    {
                        //
                    }
                    else if (propertyData.Name.Equals("parent_id"))
                    {
                        //
                    }



                    if (!dontthread)
                    {
                        if (propertyData.Typage.Equals("text"))
                        {
                            if (propertyData.Group.Equals("") && propertyData.Page.Equals(""))
                            {
                                propertyData.Page      = propertyData.Alias;
                                propertyData.ColSpan   = "6";
                                propertyData.ShowLabel = false;
                            }
                        }
                        else if (propertyData.Typage.Equals("selection") || (propertyData.LinkData != null))
                        {
                            ListOfGroupsReport["default"].ListOfProperties.Add(propertyData);
                            ListOfPropertiesReport.Add(propertyData);
                        }


                        if (propertyData.Group.Equals(string.Empty) && propertyData.Page.Equals(string.Empty))
                        {
                            ListOfGroups["default"].ListOfProperties.Add(propertyData);
                        }
                        else if (!propertyData.Group.Equals(string.Empty) && propertyData.Page.Equals(string.Empty))
                        {
                            if (!ListOfGroups["default"].ListOfGroups.ContainsKey(propertyData.Group))
                            {
                                ListOfGroups["default"].ListOfGroups.Add(propertyData.Group, new GroupData(propertyData.Group, this));
                            }

                            ListOfGroups["default"].ListOfGroups[propertyData.Group].ListOfProperties.Add(propertyData);
                        }
                        else if (propertyData.Group.Equals(string.Empty) && !propertyData.Page.Equals(string.Empty))
                        {
                            if (!ListOfGroups["default"].ListOfPages.ContainsKey(propertyData.Page))
                            {
                                ListOfGroups["default"].ListOfPages.Add(propertyData.Page, new PageData(propertyData.Page));
                                ListOfGroups["default"].ListOfPages[propertyData.Page].ListOfGroups.Add("default", new GroupData("default", this));
                            }

                            ListOfGroups["default"].ListOfPages[propertyData.Page].ListOfGroups["default"].ListOfProperties.Add(propertyData);
                        }
                        else if (!propertyData.Group.Equals(string.Empty) && !propertyData.Page.Equals(string.Empty))
                        {
                            if (!ListOfGroups["default"].ListOfPages.ContainsKey(propertyData.Page))
                            {
                                ListOfGroups["default"].ListOfPages.Add(propertyData.Page, new PageData(propertyData.Page));
                                ListOfGroups["default"].ListOfPages[propertyData.Page].ListOfGroups.Add("default", new GroupData("default", this));
                            }

                            if (!ListOfGroups["default"].ListOfPages[propertyData.Page].ListOfGroups.ContainsKey(propertyData.Group))
                            {
                                ListOfGroups["default"].ListOfPages[propertyData.Page].ListOfGroups.Add(propertyData.Group, new GroupData(propertyData.Group, this));
                            }

                            ListOfGroups["default"].ListOfPages[propertyData.Page].ListOfGroups[propertyData.Group].ListOfProperties.Add(propertyData);
                        }
                    }
                    else
                    {
                        if (propertyData.Typage.Equals("selection") || (propertyData.LinkData != null))
                        {
                            ListOfGroupsReport["default"].ListOfProperties.Add(propertyData);
                            ListOfPropertiesReport.Add(propertyData);
                        }
                    }
                }
            }

            foreach (PropertyData propertyData in ListOfProperties)
            {
                if (propertyData.Typage.Equals("one2many"))
                {
                    foreach (PropertyData property in ListOfProperties)
                    {
                        if (!propertyData.Equals(property))
                        {
                            if (!property.ShareTo.Equals(""))
                            {
                                string[] shareto = property.ShareTo.Split(new char[] { '.' });

                                string clssppt = Parent.ClassicName + "." + shareto[0];

                                if (clssppt.Equals(propertyData.LinkManyClass))
                                {
                                    ClassData clssData = Parent.GetClass(propertyData.LinkManyClass.Split(new char[] { '.' })[1]);

                                    PropertyData propData = clssData.GetProperty(shareto[1]);

                                    propData.MaxUse = Name + "." + propData.Name;
                                }
                            }
                        }
                    }
                }
            }

            Dictionary <string, PageData> ListOfPages  = new Dictionary <string, PageData>();
            Dictionary <string, PageData> ListOfPages2 = new Dictionary <string, PageData>();

            foreach (KeyValuePair <string, PageData> pageData in ListOfGroups["default"].ListOfPages)
            {
                if ((pageData.Value.ListOfGroups != null) && (pageData.Value.ListOfGroups.Count > 0) &&
                    (pageData.Value.ListOfGroups.ContainsKey("default")) && (pageData.Value.ListOfGroups["default"].ListOfProperties != null) &&
                    (pageData.Value.ListOfGroups["default"].ListOfProperties.Count > 0) && (pageData.Value.ListOfGroups["default"].ListOfProperties[0].Typage.Equals("text")))
                {
                    ListOfPages2.Add(pageData.Value.Label, pageData.Value);
                }
                else
                {
                    ListOfPages.Add(pageData.Value.Label, pageData.Value);
                }
            }

            foreach (KeyValuePair <string, PageData> pageData in ListOfPages2)
            {
                ListOfPages.Add(pageData.Value.Label, pageData.Value);
            }

            ListOfGroups["default"].ListOfPages = ListOfPages;

            ListOfButton = new List <ButtonData>();
            foreach (KeyValuePair <string, OperationData> operationDataKV in ListOfOperations)
            {
                OperationData operationData = operationDataKV.Value;

                if ((operationData.CallBy.Equals("button")) && (operationData.State.Equals("")))
                {
                    ButtonData buttonData = new ButtonData(operationData);

                    ListOfButton.Add(buttonData);
                }
                else if ((operationData.CallBy.Equals("button")) && (!operationData.State.Equals("")))
                {
                    FunctionModel pythonCode = Utils.GetFunctionModel("function_caller_action_wkf", FunctionUsage.Classic);

                    string[] states = operationData.State.Split(new char[] { '.' });

                    string state = states[1].Trim(); //GetNextState(states[1].Trim());

                    if (!state.Equals(""))
                    {
                        /*Dictionary<string, string> pythonCode_values = new Dictionary<string, string>();
                         * pythonCode_values["function_name"] = operationData.Name;
                         * pythonCode_values["action_wkf"] = "action_" + state + "_wkf";
                         *
                         * pythonCode.Content = Utils.replaceValues(pythonCode.Content, pythonCode_values) + "\r\n\t";*/

                        pythonCode.ReplaceValues(operationData.Name, "action_" + state + "_wkf");

                        operationData.PythonCode = pythonCode.Content;
                    }
                }
                else if (!operationData.CallBy.Equals("button") && !operationData.CallBy.Equals(""))
                {
                    PropertyData propertyData = GetProperty(operationData.CallBy);

                    string param = "";
                    foreach (ParameterData parameterData in operationData.ListOfParameter)
                    {
                        param += parameterData.Name + ", ";
                    }

                    if (!param.Equals(""))
                    {
                        param = param.Substring(0, param.Length - 2);
                    }

                    propertyData.OnChange = operationData.Name + "(" + param + ")";
                }
            }

            ListOfGroups["default"].ListOfButtons = ListOfButton;

            PyGenerator.CreateClass(this);
            PyGenerator.CreateReportModel(this);
            PyGenerator.CreateReportWizardModel(this);

            XmlGenerator.CreateView(this);
            XmlGenerator.CreateReportView(this);
            XmlGenerator.CreateWizardReportView(this, MenuRapport);

            if (CodeProperty != null)
            {
                XmlGenerator.CreateDatas(this);
            }

            if (StateWorkflow)
            {
                XmlGenerator.CreateWorkFlow(this);
            }

            XslGenerator.CreateReport(this);
        }
Ejemplo n.º 4
0
        public ClassData(ModuleData moduleData, XmlNode xmlNode)
        {
            Parent           = moduleData;
            AssociationClass = false;

            Inherit = null;

            ListOfGroups = new Dictionary <string, GroupData>();

            InDashBoard   = false;
            StateWorkflow = false;
            Process       = false;

            DashboardAction = new Dictionary <string, string>();

            if (xmlNode.Attributes["xmi:type"] != null)
            {
                if (xmlNode.Attributes["xmi:type"].Value.Equals("uml:Class"))
                {
                    Name = xmlNode.Attributes["name"].Value.ToLower();

                    ID = xmlNode.Attributes["xmi:idref"].Value;

                    Alias = (xmlNode["properties"].Attributes["alias"] != null) ? xmlNode["properties"].Attributes["alias"].Value : Utils.firstCharUpper(Name.Replace("_", " "));

                    Documentation = (xmlNode["properties"].Attributes["documentation"] != null) ? xmlNode["properties"].Attributes["documentation"].Value : null;
                    if (Documentation == null)
                    {
                        Documentation = Alias;
                    }

                    ListOfProperties = new List <PropertyData>();

                    PropertyData Identifiant = new PropertyData();
                    Identifiant.Name   = Name + "_id";
                    Identifiant.Typage = "integer";
                    Identifiant.Parent = this;

                    ListOfProperties.Add(Identifiant);

                    if (xmlNode["attributes"] != null)
                    {
                        foreach (XmlNode propXmlNode in xmlNode["attributes"].ChildNodes)
                        {
                            PropertyData propertyData = new PropertyData(this, propXmlNode);

                            ListOfProperties.Add(propertyData);
                        }
                    }

                    ListOfOperations = new Dictionary <string, OperationData>();
                    if (xmlNode["operations"] != null)
                    {
                        foreach (XmlNode opXmlNode in xmlNode["operations"].ChildNodes)
                        {
                            OperationData operationData = new OperationData(this, opXmlNode);

                            ListOfOperations.Add(operationData.Name, operationData);
                        }
                    }

                    ListOfLinks = new List <LinkData>();
                    if (xmlNode["links"] != null)
                    {
                        foreach (XmlNode lnkXmlNode in xmlNode["links"].ChildNodes)
                        {
                            LinkData linkData = new LinkData(this, lnkXmlNode);

                            ListOfLinks.Add(linkData);
                        }
                    }

                    ListOfConstraints = new Dictionary <string, string>();
                    if (xmlNode["constraints"] != null)
                    {
                        foreach (XmlNode constXmlNode in xmlNode["constraints"].ChildNodes)
                        {
                            ListOfConstraints.Add(constXmlNode.Attributes["name"].Value, constXmlNode.Attributes["description"].Value);
                        }
                    }


                    Columns = Utils.getExtra(xmlNode, "col", "6")[0];
                    if (ListOfProperties.Count < 3)
                    {
                        Columns = "4";
                        if (ListOfProperties.Count < 2)
                        {
                            Columns = "2";
                        }
                    }

                    DateStart = Utils.getExtra(xmlNode, "date_start", "")[0];
                    DateStop  = Utils.getExtra(xmlNode, "date_stop", "")[0];

                    GraphX = Utils.getExtra(xmlNode, "graphx", "")[0];
                    GraphY = Utils.getExtra(xmlNode, "graphy", "");

                    Code   = Utils.getExtra(xmlNode, "code", "")[0];
                    Target = Utils.getExtra(xmlNode, "target", "")[0];

                    FormId = Utils.getExtra(xmlNode, "formid", "")[0];
                    TreeId = Utils.getExtra(xmlNode, "treeid", "")[0];

                    ModuleName = Utils.getExtra(xmlNode, "module", moduleData.ModuleName)[0];

                    XpathForm    = Utils.getExtra(xmlNode, "xpathform", "/form")[0];
                    FormPosition = Utils.getExtra(xmlNode, "formpos", "inside")[0];
                    XpathTree    = Utils.getExtra(xmlNode, "xpathtree", "/tree")[0];
                    TreePosition = Utils.getExtra(xmlNode, "treepos", "inside")[0];

                    Accounting         = Utils.getExtra(xmlNode, "accounting", "")[0];
                    AccountingFunction = "";
                    AccountingArgs     = new List <string>();

                    if (!Accounting.Equals(""))
                    {
                        string[] func = Accounting.Split(new char[] { '(' });

                        AccountingFunction = func[0];

                        if (AccountingFunction.Equals("move"))
                        {
                            string[] args = func[1].Substring(0, func[1].Length - 1).Split(new char[] { ',' });
                            for (int i = 0; i < args.Length; i++)
                            {
                                AccountingArgs.Add(args[i].Trim());
                            }
                        }
                    }

                    Picture = "";

                    string mode = "";

                    if (!DateStart.Equals(""))
                    {
                        mode += ",calendar";
                    }

                    if (!GraphX.Equals(""))
                    {
                        mode += ",graph";
                    }



                    ListOfAction = new List <ActionData>();

                    ListOfAction.Add(new ActionData("action_" + Name, Alias, this, "view_" + Name + "_tree", "form,tree" + mode));

                    if (Target.ToLower().Trim().Equals("new"))
                    {
                        ListOfAction[0].Data["target"] = "new";
                    }

                    ListOfAction.Add(new ActionData(ListOfAction[0], this, "view_" + Name + "_tree", ViewKind.Tree, "1"));
                    ListOfAction.Add(new ActionData(ListOfAction[0], this, "view_" + Name + "_form", ViewKind.Form, "2"));

                    int seq = 3;

                    if (!DateStart.Equals(""))
                    {
                        ListOfAction.Add(new ActionData(ListOfAction[0], this, "view_" + Name + "_calendar", ViewKind.Calendar, seq.ToString()));
                        seq++;
                    }

                    if (!GraphX.Equals(""))
                    {
                        ListOfAction.Add(new ActionData(ListOfAction[0], this, "view_" + Name + "_graph", ViewKind.Graph, seq.ToString()));
                        seq++;
                    }

                    if (!Picture.Equals(""))
                    {
                        ListOfAction.Add(new ActionData(ListOfAction[0], this, "view_" + Name + "_kanban", ViewKind.Kanban, seq.ToString()));
                        seq++;
                    }


                    //ActionRapportData = new ActionData("action_rapport_" + Name, Alias, this, "", "form");
                    //ActionRapportData.Data["res_model"] = "rapport." + Parent.ClassicName + "." + Name;;
                    //ActionRapportData.Data["view_type"] = "form";
                    //ActionRapportData.Data["search_view_id"] = "view_rapport_" + Name + "_search";
                    //ActionRapportData.Data["context"] = "";

                    //ListOfAction.Add(ActionRapportData);

                    /*ListOfAction.Add(new ActionData(ListOfAction[0], this, "view_" + Name + "_gantt", ViewKind.Gantt, "4"));*/



                    ListOfView = new List <ViewData>();

                    ListOfView.Add(new ActData("view_" + Name, Alias, this, "form,tree"));

                    ListOfView.Add(new TreeData("view_" + Name + "_tree", ListOfAction[0], Alias, this, "1"));
                    ListOfView.Add(new FormData("view_" + Name + "_form", ListOfAction[0], Alias, this, "2"));

                    seq = 3;

                    if (!DateStart.Equals(""))
                    {
                        ListOfView.Add(new CalendarData("view_" + Name + "_calendar", ListOfAction[0], Alias, this, seq.ToString()));
                        seq++;
                    }

                    if (!GraphX.Equals(""))
                    {
                        ListOfView.Add(new GraphData("view_" + Name + "_graph", ListOfAction[0], Alias, this, seq.ToString()));
                        seq++;
                    }

                    if (!Picture.Equals(""))
                    {
                        ListOfView.Add(new KanbanData("view_" + Name + "_kanban", ListOfAction[0], Alias, this, seq.ToString()));
                        seq++;
                    }

                    /*ListOfView.Add(new GanttData((ActData)ListOfView[0], ListOfAction[0], Alias, this, "4"));*/

                    if (Inherit == null)
                    {
                        ListOfView.Add(new SearchData("view_" + Name + "_search", ListOfAction[0], Alias, this, seq.ToString()));
                    }

                    //SearchData searchRapportData = new SearchData("view_rapport_" + Name + "_search", actionRapportData, Alias, this, seq.ToString());

                    //ListOfView.Add(searchRapportData);
                    //seq++;

                    string dashboard = Utils.getExtra(xmlNode, "dashboard", "")[0];

                    if (!dashboard.Equals(""))
                    {
                        string[] dashboards = dashboard.Split(new char[] { ':' });
                        dashboard = dashboards[0].Trim();

                        string dashboard_position = "1";
                        if (dashboard.Length > 1)
                        {
                            dashboard_position = dashboards[1].Trim();
                        }

                        InDashBoard = true;

                        DashboardAction["id"]        = "action_dashboard_" + Name + "_" + dashboard;
                        DashboardAction["name"]      = Alias;
                        DashboardAction["res_model"] = Parent.ClassicName + "." + Name;
                        DashboardAction["view_type"] = "form";
                        DashboardAction["view_mode"] = "tree,form" + mode;// dashboard;
                        //DashboardAction["context"] = "{}";
                        DashboardAction["view_id"]  = "view_" + Name + "_" + dashboard;
                        DashboardAction["position"] = dashboard_position;
                        //DashboardAction["domain"] = "[]";
                    }


                    ListOfMenu = new List <MenuData>();
                    Menu       = Utils.getExtra(xmlNode, "menu", "")[0];

                    if (!Menu.Equals("false"))
                    {
                        string menuParent        = "default";
                        string menuRapportParent = "leftsubmenu_rapport_" + Parent.ClassicName;

                        if (!Menu.Equals(""))
                        {
                            string classicName = Utils.ClassicName(Menu);

                            if (!Parent.ListOfMenu.ContainsKey("leftmenu_" + classicName))
                            {
                                Parent.Menus += "\r\n\t\t" + "<menuitem name=\"" + Menu + "\" parent=\"menu_" + Parent.ClassicName + "\" id=\"leftmenu_" + classicName + "\" sequence=\"" + Parent.menu_count.ToString() + "\"/>";

                                Parent.ListOfMenu["leftmenu_" + classicName] = "leftmenu_" + classicName;

                                Parent.menu_count++;

                                // ------------------------------

                                Parent.Menus += "\r\n\t\t" + "<menuitem name=\"" + Menu + "\" parent=\"leftmenu_rapport_" + Parent.ClassicName + "\" id=\"leftsubmenu_rapport_" + classicName + "\" sequence=\"" + Parent.menu_count.ToString() + "\"/>";

                                Parent.ListOfMenu["leftsubmenu_rapport_" + classicName] = "leftsubmenu_rapport_" + classicName;

                                Parent.menu_count++;
                            }

                            menuParent        = "leftmenu_" + classicName;
                            menuRapportParent = "leftsubmenu_rapport_" + classicName;
                        }


                        string menu_name         = "leftmenu_" + Name;
                        string menu_rapport_name = "leftsubmenu_rapport_" + Name;

                        if (Parent.ListOfMenu.ContainsKey(menu_name))
                        {
                            Random rnd = new Random(DateTime.Now.Second);
                            menu_name += "_" + rnd.Next(1000, 9999).ToString();
                        }

                        if (Parent.ListOfMenu.ContainsKey(menu_rapport_name))
                        {
                            Random rnd = new Random(DateTime.Now.Second);
                            menu_rapport_name += "_" + rnd.Next(1000, 9999).ToString();
                        }

                        ListOfMenu.Add(new MenuData(menu_name, Alias, Parent.ListOfMenu[menuParent], "action_" + Name, this));
                        MenuRapport = "\t\t" + "<menuitem name=\"" + Alias + "\" parent=\"" + menuRapportParent + "\" id=\"" + menu_name + "_rapport\" action=\"action_rapport_" + Name + "\" sequence=\"" + Parent.menu_count.ToString() + "\"/>";

                        Parent.menu_count++;
                    }
                }
            }
        }
Ejemplo n.º 5
0
        public static string CreateClass(ClassData classData)
        {
            Dictionary <string, string> openerp_classValues = new Dictionary <string, string>();

            string fields   = "";
            string defaults = "";

            string constraints           = "";
            string sql_constraints       = "";
            string constraints_functions = "";

            string inherit = "# delete this line";

            string functions        = "";
            string functions_before = "# delete this line";


            foreach (PropertyData propertyData in classData.ListOfProperties)
            {
                if (!propertyData.Typage.Equals("many2many") && !propertyData.Typage.Equals("one2many"))
                {
                    RenderPropertyPy(classData, propertyData, ref fields, ref defaults, ViewKind.Form);

                    if (propertyData.Uniq)
                    {
                        sql_constraints += ((sql_constraints.Equals(""))?"":"\r\n\t\t") + "('" + propertyData.Name + "_" + classData.Name + "_uniq', 'unique(" + propertyData.Name + ")', 'La valeur du champ [" + propertyData.Alias + "] doit être unique !'),";
                    }

                    if (!propertyData.Function.Equals(string.Empty))
                    {
                        functions_before += (functions_before.Equals(string.Empty)) ? "" : "\r\n\r\n\t";

                        string fieldFunctionType = Utils.GetFunctionName(propertyData.Function);

                        FunctionModel pythonCode = Utils.GetFunctionModel("function_" + fieldFunctionType, FunctionUsage.Field);

                        string result = "";
                        if (pythonCode.Default)
                        {
                            if ((new string[] { "int" }).Contains <string>(propertyData.Typage))
                            {
                                result = "0";
                            }

                            if ((new string[] { "float" }).Contains <string>(propertyData.Typage))
                            {
                                result = "0.0";
                            }

                            if ((new string[] { "char", "string", "text" }).Contains <string>(propertyData.Typage))
                            {
                                result = "''";
                            }
                        }

                        List <string> pythonCode_values = new List <string>();
                        pythonCode_values.Add(propertyData.Name + "_" + fieldFunctionType);

                        switch (fieldFunctionType)
                        {
                        case "sum":
                        {
                            string property_zero = "0";
                            if (propertyData.Typage.Equals("float"))
                            {
                                property_zero = "0.0";
                            }

                            pythonCode_values.Add(property_zero);

                            pythonCode_values.Add(propertyData.Name);

                            List <string> arguments = Utils.GetFunctionArguments(propertyData.Function);

                            pythonCode_values.Add(arguments[1]);
                            pythonCode_values.Add(arguments[0]);

                            break;
                        }

                        default:
                        {
                            pythonCode_values.Add(result);

                            break;
                        }
                        }

                        /*Dictionary<string, string> pythonCode_values = new Dictionary<string, string>();
                         * pythonCode_values["function_name"] = propertyData.Name + "_" + fieldFunctionType;
                         * pythonCode_values["property_name"] = propertyData.Name;
                         * pythonCode_values["property_to_sum"] = "";
                         * pythonCode_values["children"] = "";
                         *
                         * pythonCode.Content = Utils.replaceValues(pythonCode.Content, pythonCode_values) + "\r\n\t";*/

                        pythonCode.ReplaceValues(pythonCode_values);

                        functions_before += pythonCode;
                    }
                }
            }

            foreach (PropertyData propertyData in classData.ListOfProperties)
            {
                if (!propertyData.MaxUse.Equals(""))
                {
                    functions_before += (functions_before.Equals(string.Empty)) ? "" : "\r\n\r\n\t";

                    FunctionModel pythonCode = Utils.GetFunctionModel("function_label", FunctionUsage.Classic);

                    Dictionary <string, string> pythonCode_values = new Dictionary <string, string>();

                    pythonCode_values.Add("module", classData.Parent.ClassicName);

                    pythonCode_values.Add("classname", classData.Name);
                    pythonCode_values.Add("property_name", propertyData.Name);

                    string[] maxuse = propertyData.MaxUse.Split(new char[] { '.' });

                    pythonCode_values.Add("classlink", maxuse[0]);
                    pythonCode_values.Add("property_link", maxuse[1]);

                    pythonCode.ReplaceValues(pythonCode_values);

                    functions_before += pythonCode;



                    functions += (functions.Equals(string.Empty)) ? "" : "\r\n\r\n\t";

                    FunctionModel pythonCode2 = Utils.GetFunctionModel("function_onchange_maxuse", FunctionUsage.Classic);

                    Dictionary <string, string> pythonCode2_values = new Dictionary <string, string>();

                    pythonCode2_values.Add("property_name", propertyData.Name);
                    pythonCode2_values.Add("classlink", maxuse[0]);

                    pythonCode2.ReplaceValues(pythonCode2_values);

                    functions += pythonCode2;
                }
            }

            foreach (PropertyData propertyData in classData.ListOfProperties)
            {
                if (propertyData.Typage.Equals("many2many"))
                {
                    RenderPropertyPy(classData, propertyData, ref fields, ref defaults, ViewKind.Form);
                }
            }

            foreach (PropertyData propertyData in classData.ListOfProperties)
            {
                if (propertyData.Typage.Equals("one2many"))
                {
                    RenderPropertyPy(classData, propertyData, ref fields, ref defaults, ViewKind.Form);
                }
            }


            Dictionary <string, OperationData> listOfOperationsData = classData.ListOfOperations;

            if (classData.StateProperty != null)
            {
                int i = 1;

                foreach (KeyValuePair <string, string> KeyValue in classData.StateProperty.SelectionData.ListOfValues)
                {
                    string key = KeyValue.Key;

                    OperationData operationData = new OperationData();
                    operationData.Parent          = classData;
                    operationData.ListOfParameter = new List <ParameterData>();

                    FunctionModel pythonCode = new FunctionModel(FunctionUsage.Classic);

                    if (i == 1)
                    {
                        pythonCode = Utils.GetFunctionModel("function_first_action_wkf", FunctionUsage.Classic);
                    }
                    else
                    {
                        pythonCode = Utils.GetFunctionModel("function_action_wkf", FunctionUsage.Classic);
                    }

                    /*Dictionary<string, string> pythonCode_values = new Dictionary<string, string>();
                     * pythonCode_values["function_name"] = "action_" + key + "_wkf";
                     * pythonCode_values["state"] = key;
                     *
                     * pythonCode.Content = Utils.replaceValues(pythonCode.Content, pythonCode_values) + "\r\n\t";*/

                    pythonCode.ReplaceValues("action_" + key + "_wkf", key);

                    operationData.Name       = "action_" + key + "_wkf";
                    operationData.PythonCode = pythonCode.Content;

                    listOfOperationsData.Add(operationData.Name, operationData);

                    i++;
                }
            }

            Dictionary <string, string> accountArgs = Utils.FunctionArgs(classData.AccountingArgs);

            //string state = Utils.GetArg(accountArgs, "state", "");
            //string button = Utils.GetArg(accountArgs, "button", "");


            foreach (KeyValuePair <string, OperationData> operationDataKV in listOfOperationsData)
            {
                OperationData operationData = operationDataKV.Value;

                functions += (functions.Equals(string.Empty)) ? "" : "\r\n\r\n\t";

                string parameters = "";
                int    i          = 0;
                foreach (ParameterData param in operationData.ListOfParameter)
                {
                    if (!param.Name.Equals(""))
                    {
                        parameters += ", " + param.Name;
                    }
                    else
                    {
                        parameters += ", arg" + i.ToString();

                        i++;
                    }
                }

                if (operationData.PythonCode.Equals(""))
                {
                    functions += "def " + operationData.Name + "(self, cr, uid, ids" + parameters + ", context=None):\r\n";
                    functions += "\t\t# contenu généré, à modifier si besoin\r\n";
                    functions += "\t\treturn " + Utils.CorrectReturn(operationData.ReturnType);
                }
                else
                {
                    functions += operationData.PythonCode;
                }
            }


            //string add_after = "";
            foreach (KeyValuePair <string, string> constraint in classData.ListOfConstraints)
            {
                if (constraints_functions.Equals(""))
                {
                    constraints_functions = "\r\n\t";
                    //add_after += "\r\n";
                }

                string[] contrainte = constraint.Value.Split(new char[] { '\n' });

                string[] contrainte_property   = contrainte[0].Trim().Split(new char[] { ':' });
                string[] contrainte_constraint = contrainte[1].Trim().Split(new char[] { ':' });
                string[] contrainte_message    = contrainte[2].Trim().Split(new char[] { ':' });


                string[] con_properties        = contrainte_property[1].Split(new char[] { ',' });
                string   contrainte_properties = "";
                string   virgule = "";
                foreach (string con_property in con_properties)
                {
                    contrainte_properties += virgule + "'" + con_property.Trim() + "'";
                    virgule = ",";
                }

                string[] operandes = contrainte_constraint[1].Trim().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);

                string operande1 = operandes[0];
                string oprator   = operandes[1];
                string operande2 = operandes[2];

                FunctionModel function_content = Utils.GetFunctionModel("function_constraint_operator", FunctionUsage.Classic);

                /*Dictionary<string, string> constraint_content_values = new Dictionary<string, string>();
                 * constraint_content_values["constraint_name"] = constraint.Key;
                 * constraint_content_values["operande1"] = operande1;
                 * constraint_content_values["operator"] = Utils.TrueString(oprator);
                 * constraint_content_values["operande2"] = operande2;
                 *
                 * function_content.Content = Utils.replaceValues(function_content.Content, constraint_content_values);*/

                function_content.ReplaceValues(constraint.Key, operande1, Utils.TrueString(oprator), operande2);

                constraints_functions += function_content + "\r\n\t";

                constraints += "(_" + constraint.Key + ", \"" + contrainte_message[1].Trim() + "\", [" + contrainte_properties + "]),\r\n\t\t";
            }

            if (!constraints.Equals(""))
            {
                constraints = constraints.Substring(0, constraints.Length - 4);
            }

            //constraints_functions += add_after;

            openerp_classValues["name"] = classData.ModuleName + "." + classData.Name;
            if (classData.Inherit != null)
            {
                openerp_classValues["name"] = "# delete this line";
                inherit = "_inherit = \"" + classData.Inherit.ModuleName + "." + classData.Inherit.Name + "\"";
            }

            openerp_classValues["classname"]             = classData.Parent.ClassicName + "_" + classData.Name;
            openerp_classValues["description"]           = classData.Documentation;
            openerp_classValues["inherit"]               = inherit;
            openerp_classValues["fields"]                = fields;
            openerp_classValues["defaults"]              = defaults;
            openerp_classValues["constraints_functions"] = constraints_functions;
            openerp_classValues["constraints"]           = constraints;
            openerp_classValues["sql_constraints"]       = sql_constraints;
            openerp_classValues["functions"]             = functions;
            openerp_classValues["functions_before"]      = functions_before;



            string filePy = classData.Parent.DirectoryInfo_Base.FullName + "/" + classData.Parent.ClassicName + "_" + classData.Name + ".py";

            Utils.MakeFileFromModel("openerp_class.py.model", filePy, openerp_classValues);

            return(filePy);
        }
        public static string CreateClass(ClassData classData)
        {
            Dictionary<string, string> openerp_classValues = new Dictionary<string, string>();

            string fields = "";
            string defaults = "";

            string constraints = "";
            string sql_constraints = "";
            string constraints_functions = "";

            string inherit = "# delete this line";

            string functions = "";
            string functions_before = "# delete this line";
            

            foreach (PropertyData propertyData in classData.ListOfProperties)
            {
                if (!propertyData.Typage.Equals("many2many") && !propertyData.Typage.Equals("one2many"))
                {
                    RenderPropertyPy(classData, propertyData, ref fields, ref defaults, ViewKind.Form);

                    if (propertyData.Uniq)
                    {
                        sql_constraints += ((sql_constraints.Equals(""))?"":"\r\n\t\t") + "('" + propertyData.Name + "_" + classData.Name + "_uniq', 'unique(" + propertyData.Name + ")', 'La valeur du champ [" + propertyData.Alias + "] doit être unique !'),";
                    }

                    if (!propertyData.Function.Equals(string.Empty))
                    {
                        functions_before += (functions_before.Equals(string.Empty)) ? "" : "\r\n\r\n\t";

                        string fieldFunctionType = Utils.GetFunctionName(propertyData.Function);

                        FunctionModel pythonCode = Utils.GetFunctionModel("function_" + fieldFunctionType, FunctionUsage.Field);

                        string result = "";
                        if (pythonCode.Default)
                        {
                            if ((new string[] { "int" }).Contains<string>(propertyData.Typage))
                            {
                                result = "0";
                            }

                            if ((new string[] { "float" }).Contains<string>(propertyData.Typage))
                            {
                                result = "0.0";
                            }

                            if ((new string[] { "char", "string", "text" }).Contains<string>(propertyData.Typage))
                            {
                                result = "''";
                            }
                        }

                        List<string> pythonCode_values = new List<string>();
                        pythonCode_values.Add(propertyData.Name + "_" + fieldFunctionType);
                        
                        switch (fieldFunctionType)
                        {
                            case "sum":
                            {
                                string property_zero = "0";
                                if (propertyData.Typage.Equals("float"))
                                {
                                    property_zero = "0.0";
                                }

                                pythonCode_values.Add(property_zero);

                                pythonCode_values.Add(propertyData.Name);

                                List<string> arguments = Utils.GetFunctionArguments(propertyData.Function);

                                pythonCode_values.Add(arguments[1]);
                                pythonCode_values.Add(arguments[0]);

                                break;
                            }

                            default:
                            {
                                pythonCode_values.Add(result);

                                break;
                            }
                        }

                        /*Dictionary<string, string> pythonCode_values = new Dictionary<string, string>();
                        pythonCode_values["function_name"] = propertyData.Name + "_" + fieldFunctionType;
                        pythonCode_values["property_name"] = propertyData.Name;
                        pythonCode_values["property_to_sum"] = "";
                        pythonCode_values["children"] = "";

                        pythonCode.Content = Utils.replaceValues(pythonCode.Content, pythonCode_values) + "\r\n\t";*/

                        pythonCode.ReplaceValues(pythonCode_values);
                        
                        functions_before += pythonCode;
                    }
                }
            }

            foreach (PropertyData propertyData in classData.ListOfProperties)
            {
                if (!propertyData.MaxUse.Equals(""))
                {
                    functions_before += (functions_before.Equals(string.Empty)) ? "" : "\r\n\r\n\t";

                    FunctionModel pythonCode = Utils.GetFunctionModel("function_label", FunctionUsage.Classic);

                    Dictionary<string, string> pythonCode_values = new Dictionary<string, string>();

                    pythonCode_values.Add("module", classData.Parent.ClassicName);

                    pythonCode_values.Add("classname", classData.Name);
                    pythonCode_values.Add("property_name", propertyData.Name);

                    string[] maxuse = propertyData.MaxUse.Split(new char[] { '.' });

                    pythonCode_values.Add("classlink", maxuse[0]);
                    pythonCode_values.Add("property_link", maxuse[1]);

                    pythonCode.ReplaceValues(pythonCode_values);

                    functions_before += pythonCode;



                    functions += (functions.Equals(string.Empty)) ? "" : "\r\n\r\n\t";

                    FunctionModel pythonCode2 = Utils.GetFunctionModel("function_onchange_maxuse", FunctionUsage.Classic);

                    Dictionary<string, string> pythonCode2_values = new Dictionary<string, string>();

                    pythonCode2_values.Add("property_name", propertyData.Name);
                    pythonCode2_values.Add("classlink", maxuse[0]);

                    pythonCode2.ReplaceValues(pythonCode2_values);

                    functions += pythonCode2;
                }
            }

            foreach (PropertyData propertyData in classData.ListOfProperties)
            {
                if (propertyData.Typage.Equals("many2many"))
                {
                    RenderPropertyPy(classData, propertyData, ref fields, ref defaults, ViewKind.Form);
                }
            }

            foreach (PropertyData propertyData in classData.ListOfProperties)
            {
                if (propertyData.Typage.Equals("one2many"))
                {
                    RenderPropertyPy(classData, propertyData, ref fields, ref defaults, ViewKind.Form);
                }
            }


            Dictionary<string, OperationData> listOfOperationsData = classData.ListOfOperations;
            
            if (classData.StateProperty != null)
            {
                int i = 1;

                foreach (KeyValuePair<string, string> KeyValue in classData.StateProperty.SelectionData.ListOfValues)
                {
                    string key = KeyValue.Key;

                    OperationData operationData = new OperationData();
                    operationData.Parent = classData;
                    operationData.ListOfParameter = new List<ParameterData>();

                    FunctionModel pythonCode = new FunctionModel(FunctionUsage.Classic);

                    if (i == 1)
                    {
                        pythonCode = Utils.GetFunctionModel("function_first_action_wkf", FunctionUsage.Classic);
                    }
                    else
                    {
                        pythonCode = Utils.GetFunctionModel("function_action_wkf", FunctionUsage.Classic);
                    }

                    /*Dictionary<string, string> pythonCode_values = new Dictionary<string, string>();
                    pythonCode_values["function_name"] = "action_" + key + "_wkf";
                    pythonCode_values["state"] = key;

                    pythonCode.Content = Utils.replaceValues(pythonCode.Content, pythonCode_values) + "\r\n\t";*/

                    pythonCode.ReplaceValues("action_" + key + "_wkf", key);

                    operationData.Name = "action_" + key + "_wkf";
                    operationData.PythonCode = pythonCode.Content;

                    listOfOperationsData.Add(operationData.Name, operationData);

                    i++;
                }
            }

            Dictionary<string, string> accountArgs = Utils.FunctionArgs(classData.AccountingArgs);

            //string state = Utils.GetArg(accountArgs, "state", "");
            //string button = Utils.GetArg(accountArgs, "button", "");


            foreach (KeyValuePair<string, OperationData> operationDataKV in listOfOperationsData)
            {
                OperationData operationData = operationDataKV.Value;

                functions += (functions.Equals(string.Empty)) ? "" : "\r\n\r\n\t";

                string parameters = "";
                int i = 0;
                foreach (ParameterData param in operationData.ListOfParameter)
                {
                    if (!param.Name.Equals(""))
                    {
                        parameters += ", " + param.Name;
                    }
                    else
                    {
                        parameters += ", arg" + i.ToString();

                        i++;
                    }
                }

                if (operationData.PythonCode.Equals(""))
                {
                    functions += "def " + operationData.Name + "(self, cr, uid, ids" + parameters + ", context=None):\r\n";
                    functions += "\t\t# contenu généré, à modifier si besoin\r\n";
                    functions += "\t\treturn " + Utils.CorrectReturn(operationData.ReturnType);
                }
                else
                {
                    functions += operationData.PythonCode;
                }
            }


            //string add_after = "";
            foreach (KeyValuePair<string, string> constraint in classData.ListOfConstraints)
            {
                if (constraints_functions.Equals(""))
                {
                    constraints_functions = "\r\n\t";
                    //add_after += "\r\n";
                }

                string[] contrainte = constraint.Value.Split(new char[] { '\n' });

                string[] contrainte_property = contrainte[0].Trim().Split(new char[] { ':' });
                string[] contrainte_constraint = contrainte[1].Trim().Split(new char[] { ':' });
                string[] contrainte_message = contrainte[2].Trim().Split(new char[] { ':' });


                string[] con_properties = contrainte_property[1].Split(new char[] { ',' });
                string contrainte_properties = "";
                string virgule = "";
                foreach (string con_property in con_properties)
                {
                    contrainte_properties += virgule + "'" + con_property.Trim() + "'";
                    virgule = ",";
                }

                string[] operandes = contrainte_constraint[1].Trim().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);

                string operande1 = operandes[0];
                string oprator = operandes[1];
                string operande2 = operandes[2];

                FunctionModel function_content = Utils.GetFunctionModel("function_constraint_operator", FunctionUsage.Classic);

                /*Dictionary<string, string> constraint_content_values = new Dictionary<string, string>();
                constraint_content_values["constraint_name"] = constraint.Key;
                constraint_content_values["operande1"] = operande1;
                constraint_content_values["operator"] = Utils.TrueString(oprator);
                constraint_content_values["operande2"] = operande2;

                function_content.Content = Utils.replaceValues(function_content.Content, constraint_content_values);*/

                function_content.ReplaceValues(constraint.Key, operande1, Utils.TrueString(oprator), operande2);

                constraints_functions += function_content + "\r\n\t";

                constraints += "(_" + constraint.Key + ", \"" + contrainte_message[1].Trim() + "\", [" + contrainte_properties + "]),\r\n\t\t";
            }

            if (!constraints.Equals("")) constraints = constraints.Substring(0, constraints.Length - 4);

            //constraints_functions += add_after;

            openerp_classValues["name"] = classData.ModuleName + "." + classData.Name;
            if (classData.Inherit != null)
            {
                openerp_classValues["name"] = "# delete this line";
                inherit = "_inherit = \"" + classData.Inherit.ModuleName + "." + classData.Inherit.Name + "\"";
            }

            openerp_classValues["classname"] = classData.Parent.ClassicName +"_" + classData.Name;
            openerp_classValues["description"] = classData.Documentation;
            openerp_classValues["inherit"] = inherit;
            openerp_classValues["fields"] = fields;
            openerp_classValues["defaults"] = defaults;
            openerp_classValues["constraints_functions"] = constraints_functions;
            openerp_classValues["constraints"] = constraints;
            openerp_classValues["sql_constraints"] = sql_constraints;
            openerp_classValues["functions"] = functions;
            openerp_classValues["functions_before"] = functions_before;



            string filePy = classData.Parent.DirectoryInfo_Base.FullName + "/" + classData.Parent.ClassicName + "_" + classData.Name + ".py";
            
            Utils.MakeFileFromModel("openerp_class.py.model", filePy, openerp_classValues);

            return filePy;
        }
        public ClassData(ModuleData moduleData, XmlNode xmlNode)
        {
            Parent = moduleData;
            AssociationClass = false;

            Inherit = null;

            ListOfGroups = new Dictionary<string, GroupData>();

            InDashBoard = false;
            StateWorkflow = false;
            Process = false;

            DashboardAction = new Dictionary<string, string>();

            if (xmlNode.Attributes["xmi:type"] != null)
            {
                if (xmlNode.Attributes["xmi:type"].Value.Equals("uml:Class"))
                {
                    Name = xmlNode.Attributes["name"].Value.ToLower();
                    
                    ID = xmlNode.Attributes["xmi:idref"].Value;

                    Alias = (xmlNode["properties"].Attributes["alias"] != null) ? xmlNode["properties"].Attributes["alias"].Value : Utils.firstCharUpper(Name.Replace("_", " "));

                    Documentation = (xmlNode["properties"].Attributes["documentation"] != null) ? xmlNode["properties"].Attributes["documentation"].Value : null;
                    if (Documentation == null)
                    {
                        Documentation = Alias;
                    }

                    ListOfProperties = new List<PropertyData>();

                    PropertyData Identifiant = new PropertyData();
                    Identifiant.Name = Name + "_id";
                    Identifiant.Typage = "integer";
                    Identifiant.Parent = this;

                    ListOfProperties.Add(Identifiant);

                    if (xmlNode["attributes"] != null)
                    {
                        foreach (XmlNode propXmlNode in xmlNode["attributes"].ChildNodes)
                        {
                            PropertyData propertyData = new PropertyData(this, propXmlNode);

                            ListOfProperties.Add(propertyData);
                        }
                    }

                    ListOfOperations = new Dictionary<string, OperationData>();
                    if (xmlNode["operations"] != null)
                    {
                        foreach (XmlNode opXmlNode in xmlNode["operations"].ChildNodes)
                        {
                            OperationData operationData = new OperationData(this, opXmlNode);

                            ListOfOperations.Add(operationData.Name, operationData);
                        }
                    }

                    ListOfLinks = new List<LinkData>();
                    if (xmlNode["links"] != null)
                    {
                        foreach (XmlNode lnkXmlNode in xmlNode["links"].ChildNodes)
                        {
                            LinkData linkData = new LinkData(this, lnkXmlNode);

                            ListOfLinks.Add(linkData);
                        }
                    }

                    ListOfConstraints = new Dictionary<string, string>();
                    if (xmlNode["constraints"] != null)
                    {
                        foreach (XmlNode constXmlNode in xmlNode["constraints"].ChildNodes)
                        {
                            ListOfConstraints.Add(constXmlNode.Attributes["name"].Value, constXmlNode.Attributes["description"].Value);
                        }
                    }

                    
                    Columns = Utils.getExtra(xmlNode, "col", "6")[0];
                    if (ListOfProperties.Count < 3)
                    {
                        Columns = "4";
                        if (ListOfProperties.Count < 2) Columns = "2";
                    }

                    DateStart = Utils.getExtra(xmlNode, "date_start", "")[0];
                    DateStop = Utils.getExtra(xmlNode, "date_stop", "")[0];

                    GraphX = Utils.getExtra(xmlNode, "graphx", "")[0];
                    GraphY = Utils.getExtra(xmlNode, "graphy", "");

                    Code = Utils.getExtra(xmlNode, "code", "")[0];
                    Target = Utils.getExtra(xmlNode, "target", "")[0];

                    FormId = Utils.getExtra(xmlNode, "formid", "")[0];
                    TreeId = Utils.getExtra(xmlNode, "treeid", "")[0];

                    ModuleName = Utils.getExtra(xmlNode, "module", moduleData.ModuleName)[0];

                    XpathForm = Utils.getExtra(xmlNode, "xpathform", "/form")[0];
                    FormPosition = Utils.getExtra(xmlNode, "formpos", "inside")[0];
                    XpathTree = Utils.getExtra(xmlNode, "xpathtree", "/tree")[0];
                    TreePosition = Utils.getExtra(xmlNode, "treepos", "inside")[0];

                    Accounting = Utils.getExtra(xmlNode, "accounting", "")[0];
                    AccountingFunction = "";
                    AccountingArgs = new List<string>();

                    if (!Accounting.Equals(""))
                    {
                        string[] func = Accounting.Split(new char[] { '(' });

                        AccountingFunction = func[0];

                        if (AccountingFunction.Equals("move"))
                        {
                            string[] args = func[1].Substring(0, func[1].Length - 1).Split(new char[] { ',' });
                            for (int i = 0; i < args.Length; i++)
                            {
                                AccountingArgs.Add(args[i].Trim());
                            }
                        }
                    }

                    Picture = "";

                    string mode = "";

                    if (!DateStart.Equals(""))
                    {
                        mode += ",calendar";
                    }

                    if (!GraphX.Equals(""))
                    {
                        mode += ",graph";
                    }



                    ListOfAction = new List<ActionData>();

                    ListOfAction.Add(new ActionData("action_" + Name, Alias, this, "view_" + Name + "_tree", "form,tree" + mode));

                    if (Target.ToLower().Trim().Equals("new"))
                    {
                        ListOfAction[0].Data["target"] = "new";
                    }

                    ListOfAction.Add(new ActionData(ListOfAction[0], this, "view_" + Name + "_tree", ViewKind.Tree, "1"));
                    ListOfAction.Add(new ActionData(ListOfAction[0], this, "view_" + Name + "_form", ViewKind.Form, "2"));

                    int seq = 3;

                    if (!DateStart.Equals(""))
                    {
                        ListOfAction.Add(new ActionData(ListOfAction[0], this, "view_" + Name + "_calendar", ViewKind.Calendar, seq.ToString()));
                        seq++;
                    }

                    if (!GraphX.Equals(""))
                    {
                        ListOfAction.Add(new ActionData(ListOfAction[0], this, "view_" + Name + "_graph", ViewKind.Graph, seq.ToString()));
                        seq++;
                    }

                    if (!Picture.Equals(""))
                    {
                        ListOfAction.Add(new ActionData(ListOfAction[0], this, "view_" + Name + "_kanban", ViewKind.Kanban, seq.ToString()));
                        seq++;
                    }


                    //ActionRapportData = new ActionData("action_rapport_" + Name, Alias, this, "", "form");
                    //ActionRapportData.Data["res_model"] = "rapport." + Parent.ClassicName + "." + Name;;
                    //ActionRapportData.Data["view_type"] = "form";
                    //ActionRapportData.Data["search_view_id"] = "view_rapport_" + Name + "_search";
                    //ActionRapportData.Data["context"] = "";

                    //ListOfAction.Add(ActionRapportData);
                    
                    /*ListOfAction.Add(new ActionData(ListOfAction[0], this, "view_" + Name + "_gantt", ViewKind.Gantt, "4"));*/


                    
                    ListOfView = new List<ViewData>();

                    ListOfView.Add(new ActData("view_" + Name, Alias, this, "form,tree"));

                    ListOfView.Add(new TreeData("view_" + Name + "_tree", ListOfAction[0], Alias, this, "1"));
                    ListOfView.Add(new FormData("view_" + Name + "_form", ListOfAction[0], Alias, this, "2"));

                    seq = 3;

                    if (!DateStart.Equals(""))
                    {
                        ListOfView.Add(new CalendarData("view_" + Name + "_calendar", ListOfAction[0], Alias, this, seq.ToString()));
                        seq++;
                    }

                    if (!GraphX.Equals(""))
                    {
                        ListOfView.Add(new GraphData("view_" + Name + "_graph", ListOfAction[0], Alias, this, seq.ToString()));
                        seq++;
                    }

                    if (!Picture.Equals(""))
                    {
                        ListOfView.Add(new KanbanData("view_" + Name + "_kanban", ListOfAction[0], Alias, this, seq.ToString()));
                        seq++;
                    }
                    
                    /*ListOfView.Add(new GanttData((ActData)ListOfView[0], ListOfAction[0], Alias, this, "4"));*/

                    if (Inherit == null)
                    {
                        ListOfView.Add(new SearchData("view_" + Name + "_search", ListOfAction[0], Alias, this, seq.ToString()));
                    }

                    //SearchData searchRapportData = new SearchData("view_rapport_" + Name + "_search", actionRapportData, Alias, this, seq.ToString());

                    //ListOfView.Add(searchRapportData);
                    //seq++;

                    string dashboard = Utils.getExtra(xmlNode, "dashboard", "")[0];

                    if (!dashboard.Equals(""))
                    {
                        string[] dashboards = dashboard.Split(new char[] { ':' });
                        dashboard = dashboards[0].Trim();

                        string dashboard_position = "1";
                        if (dashboard.Length > 1)
                        {
                            dashboard_position = dashboards[1].Trim();
                        }

                        InDashBoard = true;

                        DashboardAction["id"] = "action_dashboard_" + Name + "_" + dashboard;
                        DashboardAction["name"] = Alias;
                        DashboardAction["res_model"] = Parent.ClassicName + "." + Name;
                        DashboardAction["view_type"] = "form";
                        DashboardAction["view_mode"] = "tree,form" + mode;// dashboard;
                        //DashboardAction["context"] = "{}";
                        DashboardAction["view_id"] = "view_" + Name + "_" + dashboard;
                        DashboardAction["position"] = dashboard_position;
                        //DashboardAction["domain"] = "[]";
                    }


                    ListOfMenu = new List<MenuData>();
                    Menu = Utils.getExtra(xmlNode, "menu", "")[0];

                    if (!Menu.Equals("false"))
                    {
                        string menuParent = "default";
                        string menuRapportParent = "leftsubmenu_rapport_" + Parent.ClassicName;

                        if (!Menu.Equals(""))
                        {
                            string classicName = Utils.ClassicName(Menu);

                            if (!Parent.ListOfMenu.ContainsKey("leftmenu_" + classicName))
                            {
                                Parent.Menus += "\r\n\t\t" + "<menuitem name=\"" + Menu + "\" parent=\"menu_" + Parent.ClassicName + "\" id=\"leftmenu_" + classicName + "\" sequence=\"" + Parent.menu_count.ToString() + "\"/>";

                                Parent.ListOfMenu["leftmenu_" + classicName] = "leftmenu_" + classicName;

                                Parent.menu_count++;

                                // ------------------------------

                                Parent.Menus += "\r\n\t\t" + "<menuitem name=\"" + Menu + "\" parent=\"leftmenu_rapport_" + Parent.ClassicName + "\" id=\"leftsubmenu_rapport_" + classicName + "\" sequence=\"" + Parent.menu_count.ToString() + "\"/>";

                                Parent.ListOfMenu["leftsubmenu_rapport_" + classicName] = "leftsubmenu_rapport_" + classicName;

                                Parent.menu_count++;
                            }

                            menuParent = "leftmenu_" + classicName;
                            menuRapportParent = "leftsubmenu_rapport_" + classicName;
                        }


                        string menu_name = "leftmenu_" + Name;
                        string menu_rapport_name = "leftsubmenu_rapport_" + Name;

                        if (Parent.ListOfMenu.ContainsKey(menu_name))
                        {
                            Random rnd = new Random(DateTime.Now.Second);
                            menu_name += "_" + rnd.Next(1000, 9999).ToString();
                        }

                        if (Parent.ListOfMenu.ContainsKey(menu_rapport_name))
                        {
                            Random rnd = new Random(DateTime.Now.Second);
                            menu_rapport_name += "_" + rnd.Next(1000, 9999).ToString();
                        }

                        ListOfMenu.Add(new MenuData(menu_name, Alias, Parent.ListOfMenu[menuParent], "action_" + Name, this));
                        MenuRapport = "\t\t" + "<menuitem name=\"" + Alias + "\" parent=\"" + menuRapportParent + "\" id=\"" + menu_name + "_rapport\" action=\"action_rapport_" + Name + "\" sequence=\"" + Parent.menu_count.ToString() + "\"/>";

                        Parent.menu_count++;
                    }
                }
            }
        }