public static string CreateLanguage(ModuleData moduleData) { Dictionary<string, string> openerp_class_poValues = new Dictionary<string, string>(); string traductions = ""; foreach (KeyValuePair<string, string> traduction in Program.ProjectData.ListOfTraduction) { traductions += traduction.Value; } openerp_class_poValues["name"] = moduleData.Name; openerp_class_poValues["traductions"] = traductions; string filePo_FR = moduleData.DirectoryInfo_Base.FullName + "/i18n/fr.po"; Utils.MakeFileFromModel("language.po.model", filePo_FR, openerp_class_poValues); string filePo_EN = moduleData.DirectoryInfo_Base.FullName + "/i18n/en_GB.po"; Utils.MakeFileFromModel("language.po.model", filePo_EN, openerp_class_poValues); return filePo_FR; }
public ProjectData(XmlNode xmlNode) { XmlNode = xmlNode; ListOfModuleData = new List<ModuleData>(); ListOfTraduction = new Dictionary<string, string>(); foreach (XmlNode moduleXmlNode in xmlNode["uml:Model"]["packagedElement"].ChildNodes) { if (moduleXmlNode.Attributes["xmi:type"].Value.Equals("uml:Package")) { if (moduleXmlNode.Attributes["name"].Value.Equals("OpenERP")) { foreach (XmlNode nativeModuleXmlNode in xmlNode["xmi:Extension"]["elements"].ChildNodes) { if ((nativeModuleXmlNode.Attributes["xmi:type"] != null) && (nativeModuleXmlNode.Attributes["xmi:type"].Value.Equals("uml:Package"))) { if ((nativeModuleXmlNode["model"] != null) && (nativeModuleXmlNode["model"].Attributes["package"] != null) && (nativeModuleXmlNode["model"].Attributes["package"].Value.Equals(moduleXmlNode.Attributes["xmi:id"].Value))) { if (!nativeModuleXmlNode.Attributes["name"].Value.Equals("Enumerations")) { ModuleData moduleData = new ModuleData(this, nativeModuleXmlNode, xmlNode["xmi:Extension"]["elements"]); moduleData.Native = true; ListOfModuleData.Add(moduleData); } else { ListOfEnumerationData = new List<EnumerationData>(); foreach (XmlNode enumerationNode in xmlNode["xmi:Extension"]["elements"].ChildNodes) { if ((enumerationNode["model"] != null) && (enumerationNode["model"].Attributes["package"] != null) && (enumerationNode["model"].Attributes["package"].Value.Equals(nativeModuleXmlNode.Attributes["xmi:idref"].Value))) { EnumerationData enumerationData = new EnumerationData(enumerationNode); ListOfEnumerationData.Add(enumerationData); } } } } } } break; } } } foreach (XmlNode moduleXmlNode in xmlNode["uml:Model"]["packagedElement"].ChildNodes) { if (moduleXmlNode.Attributes["xmi:type"].Value.Equals("uml:Package")) { if (!moduleXmlNode.Attributes["name"].Value.Equals("OpenERP")) { ModuleData moduleData = new ModuleData(this, moduleXmlNode, xmlNode["xmi:Extension"]["elements"]); ListOfModuleData.Add(moduleData); } } } foreach (ModuleData moduleData in ListOfModuleData) { foreach (ClassData classData in moduleData.ListOfClass) { addTraduction(classData, classData.Alias); foreach (PropertyData propertyData in classData.ListOfProperties) { addTraduction(classData, propertyData.Alias); } } } }
public static string CreateView(ModuleData moduleData) { return ""; }
public static string CreateOpenERP(ModuleData moduleData) { Dictionary<string, string> __openerp__Values = new Dictionary<string, string>(); __openerp__Values["name"] = moduleData.Name; __openerp__Values["description"] = moduleData.Documentation; __openerp__Values["update_xml"] = (string)moduleData.Data["update_xml"]; __openerp__Values["demo_xml"] = (string)moduleData.Data["demo_xml"]; __openerp__Values["images"] = (string)moduleData.Data["images"]; __openerp__Values["category"] = (string)moduleData.Data["category"]; __openerp__Values["depends"] = (string)moduleData.Data["depends"]; __openerp__Values["test"] = (string)moduleData.Data["test"]; __openerp__Values["classicname"] = moduleData.ClassicName; Utils.MakeFileFromModel("__openerp__.py.model", moduleData.DirectoryInfo_Base.FullName + "/__openerp__.py", __openerp__Values); return moduleData.DirectoryInfo_Base.FullName + "/__openerp__.py"; }
public static string CreateWizardInit(ModuleData moduleData) { Dictionary<string, string> __init__Values = new Dictionary<string, string>(); __init__Values["imports"] = (string)moduleData.Data["wizard_imports"]; Utils.MakeFileFromModel("__init__.py.model", moduleData.DirectoryInfo_Base.FullName + "/wizard/__init__.py", __init__Values); return moduleData.DirectoryInfo_Base.FullName + "/wizard/__init__.py"; }
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++; } } } }