Browse Source

commit inicial

Deisy 8 years ago
commit
971fdf04a5

+ 1 - 0
__init__.py

@@ -0,0 +1 @@
+import entity_html_form, controllers

BIN
__init__.pyc


+ 23 - 0
__openerp__.py

@@ -0,0 +1,23 @@
+{
+    'name': "HTML Form Creator",
+    'version': "1.1",
+    'author': "Sythil",
+    'category': "Tools",
+    'summary': "Creates an HTML form that you can embed anywhere",
+    'description': "Creates an HTML form that you can embed anywhere",
+    'license':'GPL-3',
+    'data': [
+        'entity_html_form.xml',
+        'views/snippets.xml',
+        'views/website_templates.xml',
+        'security/ir.model.access.csv',
+    ],
+    'demo': [],
+    'images':[
+    'static/description/1.jpg',
+    'static/description/2.jpg',
+    ],
+
+    'depends': ['web','website'],
+    'installable': True,
+}

+ 3 - 0
controllers/__init__.py

@@ -0,0 +1,3 @@
+import main
+
+# vim:expandtab:tabstop=4:softtabstop=4:shiftwidth=4:

BIN
controllers/__init__.pyc


+ 54 - 0
controllers/main.py

@@ -0,0 +1,54 @@
+import openerp.http as http
+from openerp.http import request
+import logging
+_logger = logging.getLogger(__name__)
+import werkzeug
+import base64
+from psycopg2 import IntegrityError
+
+class MyController(http.Controller):
+
+    @http.route('/form/thankyou', type="http", auth="public", website=True)
+    def ehtml_thanks(self, **kw):
+        return http.request.render('entity_html_form.ehtml_thank_you', {})
+
+    @http.route('/form/myinsert',type="http", auth="public", website=True)
+    def my_insert(self, **kwargs):
+        try:
+    		values = {}
+    		for field_name, field_value in kwargs.items():
+    		    values[field_name] = field_value
+
+    		#the referral string is what the campaign looks for
+    		secure_values = {}
+    		history_values = {}
+
+    		ref_url = http.request.httprequest.headers['Referer']
+
+    		entity_form = http.request.env['ehtml.formgen'].sudo().browse(int(values['form_id']))
+
+    		new_history = http.request.env['ehtml.history'].sudo().create({'ref_url':ref_url, 'html_id': entity_form.id})
+
+    		#populate an array which has ONLY the fields that are in the form (prevent injection)
+    		for fi in entity_form.fields_ids:
+    		    if fi.field_id.ttype == "binary":
+    		        secure_values[fi.field_id.name] = base64.encodestring(values[fi.html_name].read() )
+    		    else:
+    		        secure_values[fi.field_id.name] = values[fi.html_name]
+    		    new_history.insert_data.sudo().create({'html_id': new_history.id, 'field_id':fi.field_id.id, 'insert_value':values[fi.html_name]})
+
+    		#default values
+    		for df in entity_form.defaults_values:
+    		    secure_values[df.field_id.name] = df.default_value
+    		    new_history.insert_data.sudo().create({'html_id': new_history.id, 'field_id':df.field_id.id, 'insert_value':df.default_value})
+
+    		new_record = http.request.env[entity_form.model_id.model].sudo().create(secure_values)
+    		new_history.record_id = entity_form.id
+
+    		return werkzeug.utils.redirect(entity_form.return_url)
+
+        except IntegrityError:
+            # can't use the usual `http.request.env.cr` style,
+            # because `env` queries db and everything explodes
+            http.request._cr.rollback()
+            return http.request.render('entity_html_form.myinsert')

BIN
controllers/main.pyc


+ 1 - 0
doc/changelog.rst

@@ -0,0 +1 @@
+1.0 Initial release

+ 128 - 0
doc/index.rst

@@ -0,0 +1,128 @@
+Menus
+=====
+HTML Embed Forms
+----------------
+Child of "Settings" menu, parent menu of all other eHTML menus
+
+Create Forms
+------------
+Child of "HTML Embed Forms" menu, place to create HTML forms
+
+Inserted Form Data
+------------------
+Child of "HTML Embed Forms" menu, history of all form submissions
+
+Models / Fields
+===============
+ehtml.formgen(An individual Form)
+---------------------------------
+Permissions
+^^^^^^^^^^^
+**Administration / Settings (base.group_system)**: Read, Write, Create and Delete
+
+Fields
+^^^^^^
+**Form Name (name)**: Human meaningful name for the form
+
+**Model (model_id)**: The model which the form is based around
+
+**HTML Fields (fields_ids)**: The list of Odoo fields in the HTML form
+
+**Embed Code (output_html)**: The output HTML designed to be copied and pasted into an external site
+
+**Required Fields (required_fields)**: Human readable list of fields that are required for that model
+
+**Default Values (defaults_values)**: List of fields and a corresponding default value which is set when the record is created
+
+**Return URL (return_url)**: After the form is submitted the user is redirected to this URL
+
+**Form Type (form_type)**: The format of the outputted HTML, Odoo or native
+
+ehtml.fieldentry(A field in the form)
+-------------------------------------
+Permissions
+^^^^^^^^^^^
+**Administration / Settings (base.group_system)**: Read, Write, Create and Delete
+
+Fields
+^^^^^^
+**Sequence (sequence)**: Drag and drop field order
+
+**HTML Form (html_id)**: ID pointing back to the HTML form
+
+**Model (model_id)**: The model ID of the field hidden from user sight
+
+**Related Model (model)**: The model name of the field hidden from user sight
+
+**Form Field (field_id)**: The Odoo field this form field inserts data into
+
+**Field Label (field_label)**: Human readable label for the field on the website
+
+**HTML Field Name (html_name)**: The HTML name of the field handy for autocomplete e.g auto fill email/mobile
+
+**HTML Field Type (html_field_type)**: The type of HTML input to use for this type of field
+
+ehtml.fielddefault (Stores the default values for each form)
+------------------------------------------------------------
+Permissions
+^^^^^^^^^^^
+**Administration / Settings (base.group_system)**: Read, Write, Create and Delete
+
+Fields
+^^^^^^
+**HTML Form (html_id)**: ID pointing back to the HTML form
+
+**Model (model_id)**: Model ID, hidden from user
+
+**Model Name (model)**: Model Name, hidden from user
+
+**Form Fields (field_id)**: The Odoo field your settings a default value for
+
+**Default Value (default_value)**: The value that is set for this Odoo field when the record is inserted
+
+ehtml.history (Stores all inserted records)
+-------------------------------------------
+Permissions
+^^^^^^^^^^^
+**Administration / Settings (base.group_system)**: Read
+
+Fields
+^^^^^^
+**HTML Form (html_id)**: ID pointing back to the HTML form
+
+**Reference URL (ref_url)**: The URL this form waas submitted from
+
+**Record ID (record_id)**: The ID of the inserted record
+
+**Form Name (form_name)**: No Idea...
+
+**HTML Fields (insert_data)**: List of data that was inserted with this submission
+
+ehtml.fieldinsert (History of the field data that was inserted)
+---------------------------------------------------------------
+Permissions
+^^^^^^^^^^^
+**Administration / Settings (base.group_system)**: Read
+
+Fields
+^^^^^^
+**HTML Form (html_id)**: ID pointing back to the HTML form history
+
+**Field (field_id)**: The field that data was inserted into
+
+**Insert Value (insert_value)**: The value inserted
+
+
+Security
+========
+Administration / Settings (base.group_system)
+---------------------------------------------
+**ehtml.formgen**: Read, Write, Create and Delete
+
+**ehtml.fieldentry**: Read, Write, Create and Delete
+
+**ehtml.fielddefault**: Read, Write, Create and Delete
+
+**ehtml.history**: Read
+
+**ehtml.fieldinsert**:  Read

+ 377 - 0
entity_html_form.py

@@ -0,0 +1,377 @@
+from openerp import models, fields, api
+from openerp.http import request
+import logging
+_logger = logging.getLogger(__name__)
+import cgi
+
+class EhtmlFormgen(models.Model):
+
+    _name = "ehtml.formgen"    
+    
+    def _default_return_url(self):
+        return request.httprequest.host_url + "form/thankyou"    
+    
+    name = fields.Char(string="Form Name", required=True)
+    model_id = fields.Many2one('ir.model', string="Model", required=True)
+    fields_ids = fields.One2many('ehtml.fieldentry', 'html_id', string="HTML Fields")
+    output_html = fields.Text(string='Embed Code', readonly=True)
+    required_fields = fields.Text(readonly=True, string="Required Fields")
+    defaults_values = fields.One2many('ehtml.fielddefault', 'html_id', string="Default Values", help="Sets the value of an field before it gets inserted into the database")
+    return_url = fields.Char(string="Return URL", default=_default_return_url, help="The URL that the user will be redirected to after submitting the form", required=True)
+    form_type = fields.Selection([('reg','Plain'),('odoo','Odoo Website')], default="odoo", string="Form Type")
+        
+    @api.onchange('model_id')
+    @api.one
+    def change_model(self):
+        #delete all existing fields
+        for field_entry in self.fields_ids:
+            field_entry.unlink()
+        
+        required_string = ""
+        for model_field in self.env['ir.model.fields'].search([('model_id','=', self.model_id.id),('required','=',True) ]):
+            required_string += model_field.field_description.encode("utf-8") + " (" + model_field.name.encode("utf-8") + ")\n"
+        
+        self.required_fields = required_string
+
+    @api.one
+    def generate_form(self):
+        if self.form_type == 'reg':
+            self.generate_form_reg()
+        elif self.form_type == 'odoo':
+            self.generate_form_odoo()
+        else:
+            self.generate_form_optimize()
+            
+    @api.one
+    def generate_form_reg(self):
+        html_output = ""
+        html_output += "<link href=\"http://code.jquery.com/ui/1.10.4/themes/ui-lightness/jquery-ui.css\" rel=\"stylesheet\">\n";
+	html_output += "<script src=\"http://code.jquery.com/jquery-1.10.2.js\"></script>\n";
+        html_output += "<script src=\"http://code.jquery.com/ui/1.10.4/jquery-ui.js\"></script>\n";
+        html_output += '<div id="ehtml_form">' + "\n"
+        html_output += '<form method="POST" action="' + request.httprequest.host_url + 'form/myinsert">' + "\n"
+        for fe in self.fields_ids:              
+            html_output += '<label for="' + fe.html_name + '">' + fe.field_id.field_description
+                
+            if fe.field_id.required == True:
+                html_output += ' *'
+                
+            html_output += '</label><br/>\n'
+                
+            if fe.html_field_type == "text":
+                html_output += '<input type="text" id="' + fe.html_name + '" name="' + fe.html_name + '"'
+                    
+                if fe.field_id.size > 0:
+                    html_output += ' maxlength="' + fe.field_id.size + '"'
+                    
+                if fe.field_id.required == True:
+                    html_output += ' required'
+                
+                html_output += '/><br>\n'
+                    
+            if fe.html_field_type == "textarea":
+                html_output += '<textarea id="' + fe.html_name + '" name="' + fe.html_name + '"'
+                   
+                if fe.field_id.required == True:
+    	            html_output += ' required'
+    	            
+    	        html_output += '></textarea><br>\n'
+    	        
+    	    if fe.html_field_type == "number":
+	        html_output += '<input type="number" id="' + fe.html_name + '" name="' + fe.html_name + '"'
+		    
+	        if fe.field_id.required == True:
+	            html_output += ' required'        
+		    	            
+    	        html_output += '/><br>\n'
+    	    
+    	    if fe.html_field_type == "search":
+                html_output += "<script>\n"
+                html_output += "$(document).ready(function() {\n"
+                html_output += '    $("#' + fe.html_name + '").autocomplete({' + "\n"
+                html_output += "        source: function( request, response ) {\n"
+                html_output += '            $.ajax({url: "' + request.httprequest.host_url + 'form/autocomplete?callback=?",dataType: "jsonp",' + "\n"
+                html_output += '            data: {'+ "\n"
+                html_output += "                q: request.term\n"
+                html_output += "            },\n"
+                html_output += "            success: function( data ) {\n"
+                html_output += "                response( data );\n"
+                html_output += "            }});\n"
+                html_output += "        }\n"
+                html_output += "    });\n"
+                html_output += "});\n"
+                html_output += "</script>\n"
+                html_output += '<input type="search" id="' + fe.html_name + '" name="' + fe.html_name + '"'
+		    
+	        if fe.field_id.required == True:
+	            html_output += ' required'        
+		    	            
+    	        html_output += '/><br>\n'
+    	    
+    	    html_output += "<br>\n"
+    	html_output += '<input type="hidden" name="form_id" value="' + str(self.id) + '"/>' + "\n"
+    	html_output += '<input type="submit" value="Submit Form"/>' + "\n"
+    	html_output += "</form>\n"
+        html_output += "</div>"
+        self.output_html = html_output
+       
+    @api.one
+    def generate_form_odoo(self):
+        html_output = ""
+        html_output += "<section id=\"ehtml_form\" class=\"oe_snippet_body ehtml_form container\">\n"
+        html_output += '  <form method="POST" action="' + request.httprequest.host_url + 'form/myinsert" enctype=\"multipart/form-data\">' + "\n"
+        html_output += "    <h1>" + self.name.encode("utf-8") + "</h1>\n"
+        html_output += "    <div id=\"ehtml_fields\" class=\"oe_structure\">\n"
+                                 
+        for fe in self.fields_ids:
+            html_output += "      <section class=\"oe_snippet_body ehtml_form_field\">\n"            
+            
+            if fe.html_field_type == "text":
+                html_output += "        <div class=\"form-group\">\n"
+		html_output += "          <label class=\"control-label\" for=\"" + fe.html_name + "\""
+		
+                if fe.field_id.required == False:
+                    html_output += ' style="font-weight: normal"'		
+		
+		html_output += ">" + fe.field_label + "</label>\n"
+                
+                html_output += '          <input type="text" class="form-control" id="' + fe.html_name + '" name="' + fe.html_name + '"'
+                
+                if fe.field_id.size > 0:
+                    html_output += ' maxlength="' + fe.field_id.size + '"'
+                    
+                if fe.field_id.required == True:
+                    html_output += ' required="required"'
+                
+                html_output += "/>\n"
+                html_output += "        </div>\n"
+            if fe.html_field_type == "textarea":
+                html_output += "        <div class=\"form-group\">\n"
+		html_output += "          <label class=\"control-label\" for=\"" + fe.html_name + "\""
+		                
+                if fe.field_id.required == False:
+                    html_output += ' style="font-weight: normal"'         
+                
+		html_output += ">" + fe.field_label + "</label>\n"
+                html_output += '          <textarea class="form-control" id="' + fe.html_name + '" name="' + fe.html_name + '"'
+                                
+                if fe.field_id.required == True:
+    	            html_output += ' required'
+    	            
+    	        html_output += "></textarea>\n"
+    	        
+    	        html_output += "        </div>\n"
+            if fe.html_field_type == "binary":
+                html_output += "        <div class=\"form-group\">\n"
+		html_output += "          <label class=\"control-label\" for=\"" + fe.html_name + "\""
+		
+                if fe.field_id.required == False:
+                    html_output += ' style="font-weight: normal"'		
+		
+		html_output += ">" + fe.field_label + "</label>\n"
+
+                html_output += '          <input type="file" id="' + fe.html_name + '" name="' + fe.html_name + '"'
+                                
+                if fe.field_id.required == True:
+    	            html_output += ' required'
+    	            
+    	        html_output += "/>\n"
+    	        
+    	        html_output += "        </div>\n"
+ 
+    	    if fe.html_field_type == "checkbox":
+	        html_output += "        <div class=\"checkbox\">\n"
+	        html_output += "          <label class=\"control-label\""
+	                        
+                if fe.field_id.required == False:
+                    html_output += ' style="font-weight: normal"'
+	        
+	        html_output += ">\n"
+	        
+	                        
+	        html_output += '          <input type="checkbox" id="' + fe.html_name + '" name="' + fe.html_name + '"'
+                                	                       
+	        if fe.field_id.required == True:
+	            html_output += ' required'
+	        	            
+	        html_output += '/>' + fe.field_label + "\n"
+	        
+	        html_output += "          </label>\n"
+	        html_output += "        </div>\n"
+    	    
+    	    if fe.html_field_type == "number":
+                html_output += "        <div class=\"form-group\">\n"
+		html_output += "          <label class=\"control-label\" for=\"" + fe.html_name + "\""
+		
+                
+                if fe.field_id.required == False:
+                    html_output += ' style="font-weight: normal"'		
+		
+		html_output += ">" + fe.field_label + "</label>\n"                	        
+	        
+	        html_output += '          <input type="number" class="form-control" id="' + fe.html_name + '" name="' + fe.html_name + '"'
+                                		    
+	        if fe.field_id.required == True:
+	            html_output += ' required'        
+		    	            
+    	        html_output += "/>\n"
+    	        html_output += "        </div>\n"
+    	    if fe.html_field_type == "selection":
+                html_output += "        <div class=\"form-group\">\n"
+		html_output += "          <label class=\"control-label\" for=\"" + fe.html_name + "\""
+		                
+                if fe.field_id.required == False:
+                    html_output += ' style="font-weight: normal"'                
+                		
+		html_output += ">" + fe.field_label
+                
+                                    
+                html_output += "</label>\n"
+	        html_output += '          <select class="form-control" id="' + fe.html_name + '" name="' + fe.html_name + '"'
+                		    
+	        if fe.field_id.required == True:
+	            html_output += ' required'        
+		    	            
+    	        html_output += ">\n"
+
+    	        html_output += "            <option value=\"\">Select Option</option>\n"
+
+    	        
+    	        selection_list = dict(self.env[self.model_id.model]._columns[fe.field_id.name].selection)
+    	        
+    	        for selection_value,selection_label in selection_list.items():
+    	            html_output += "            <option value=\"" + str(selection_value) + "\">" + str(selection_label) + "</option>\n"
+    	        
+    	        html_output += "          </select>\n"
+    	        html_output += "        </div>\n"
+    	        	    
+
+    	    if fe.html_field_type == "radiobuttons":
+                
+                html_output += "      <label class=\"control-label\""
+                
+                if fe.field_id.required == False:
+                    html_output += ' style="font-weight: normal"'                
+                
+                html_output += ">" + fe.field_label + "</label>\n"
+    	        
+    	        selection_list = dict(self.env[self.model_id.model]._columns[fe.field_id.name].selection)
+    	        
+    	        for selection_value,selection_label in selection_list.items():
+    	            html_output += "        <div class=\"radio\">\n"
+    	            
+    	            
+    	            html_output += "          <label><input type=\"radio\" name=\"" + fe.html_name + "\" value=\"" + str(selection_value) + "\""
+    	            
+    	            if fe.field_id.required == True:
+		        html_output += ' required'
+    	            
+    	            html_output += "/>" + str(selection_label) + "</label>\n"
+    	            html_output += "        </div>\n"
+    	            
+    	    if fe.html_field_type == "dropdownstatic":
+                html_output += "        <div class=\"form-group\">\n"
+		html_output += "          <label class=\"control-label\" for=\"" + fe.html_name + "\""
+		                
+                if fe.field_id.required == False:
+                    html_output += ' style="font-weight: normal"'		
+		
+		html_output += ">" + fe.field_label                                
+                    
+                html_output += "</label>\n"
+	        html_output += '          <select class="form-control" id="' + fe.html_name + '" name="' + fe.html_name + '"'
+		    
+	        if fe.field_id.required == True:
+	            html_output += ' required'
+		    	            
+    	        html_output += ">\n"
+    	        
+    	        for reco in self.env[str(fe.field_id.relation)].search([]):
+    	            html_output += "            <option value=\"" + str(reco.id) + "\">" + unicode(cgi.escape(reco.name)) + "</option>\n"
+    	        
+    	        html_output += "          </select>\n"
+    	        html_output += "        </div>\n"
+            
+            html_output += "      </section>\n"
+	html_output += '      <input type="hidden" name="form_id" value="' + str(self.id) + '"/>' + "\n"
+        html_output += "      <input type=\"submit\" class=\"btn btn-primary btn-lg\" value=\"Send\"/>\n"
+        
+        html_output += "    </div>\n"
+    	html_output += "  </form>\n"
+        html_output += "</section>\n"
+        self.output_html = html_output
+
+class EhtmlFieldEntry(models.Model):
+
+    _name = "ehtml.fieldentry"
+    _order = "sequence asc"
+    
+    sequence = fields.Integer(string="Sequence")
+    html_id = fields.Many2one('ehtml.formgen', string="HTML Form")
+    model_id = fields.Many2one('ir.model', string="Model", required=True)
+    model = fields.Char(related="model_id.model", string="Related Model")
+    field_id = fields.Many2one('ir.model.fields', domain="[('name','!=','create_date'),('name','!=','create_uid'),('name','!=','id'),('name','!=','write_date'),('name','!=','write_uid')]", string="Form Field")
+    field_label = fields.Char(string="Field Label")
+    html_name = fields.Char(string="HTML Field Name")
+    html_field_type = fields.Selection((('binary','Binary'),('text','Textbox'),('textarea','Textarea'),('number','Number'),('selection','Selection'),('radiobuttons','Radiobuttons'),('checkbox','Checkbox'),('search','Search'),('dropdownstatic','Dropdown(static)') ), string="HTML Field Type")
+    
+    @api.model
+    def create(self, values):
+        sequence=self.env['ir.sequence'].get('sequence')
+        values['sequence']=sequence
+        return super(EhtmlFieldEntry, self).create(values)
+                
+    @api.onchange('field_id')
+    def update_html_name(self):
+        self.html_name = self.field_id.name
+        self.field_label = self.field_id.field_description
+
+        if (self.field_id.ttype == "binary"):
+	    self.html_field_type = "binary"
+
+        if (self.field_id.ttype == "boolean"):
+	    self.html_field_type = "checkbox"        
+
+        if (self.field_id.ttype == "selection"):
+	    self.html_field_type = "selection"        
+        
+        if (self.field_id.ttype == "char"):
+            self.html_field_type = "text"
+            
+        if (self.field_id.ttype == "text"):
+	    self.html_field_type = "textarea"
+        
+        if (self.field_id.ttype == "integer"):
+            self.html_field_type = "number"
+            
+        if (self.field_id.ttype == "many2one"):
+	    self.html_field_type = "dropdownstatic"
+        
+class EhtmlFieldDefault(models.Model):
+
+    _name = "ehtml.fielddefault"
+
+    html_id = fields.Many2one('ehtml.formgen', string="HTML Form")
+    model_id = fields.Many2one('ir.model', string="Model", required=True)
+    model = fields.Char(related="model_id.model", string="Model Name")
+    field_id = fields.Many2one('ir.model.fields', string="Form Fields")
+    default_value = fields.Char(string="Default Value")
+    
+class EhtmlHistory(models.Model):
+
+    _name = "ehtml.history"
+
+    html_id = fields.Many2one('ehtml.formgen', string="HTML Form", readonly=True)
+    ref_url = fields.Char(string="Reference URL", readonly=True)
+    record_id = fields.Integer(string="Record ID", readonly=True)
+    form_name = fields.Char(string="Form Name", related="html_id.name")
+    insert_data = fields.One2many('ehtml.fieldinsert', 'html_id', string="HTML Fields", readonly=True)
+    
+class EhtmlFieldInsert(models.Model):
+
+    _name = "ehtml.fieldinsert"
+
+    html_id = fields.Many2one('ehtml.history')
+    field_id = fields.Many2one('ir.model.fields', string="Field")
+    insert_value = fields.Char(string="Insert Value")
+    

BIN
entity_html_form.pyc


+ 117 - 0
entity_html_form.xml

@@ -0,0 +1,117 @@
+<?xml version="1.0" encoding="utf-8"?>
+<openerp>
+  <data>
+
+      <record model="ir.sequence.type" id="seq_ehtml_id">
+          <field name="name">eHTML Field Sequence</field>
+          <field name="code">ehtml.fieldentry</field>
+      </record>
+
+      <record id="ehtml_seq_id" model="ir.sequence">
+          <field name="name">eHTML Field Sequence</field>
+          <field name="code">ehtml.fieldentry</field>
+      </record>
+
+      <record model="ir.ui.view" id="ehtml_form_view">
+         <field name="name">ehtml form</field>
+         <field name="model">ehtml.formgen</field>
+         <field name="arch" type="xml">
+             <form string="HTML Form">
+                  <sheet>
+                      <group>
+                          <field name="name"/>
+                          <field name="return_url" placeholder="http://www.google.com.au"/>
+                          <field name="model_id"/>
+                          <field name="form_type"/>
+                          <field name="fields_ids" context="{'html_id': active_id,'default_model_id':model_id}">
+		              <tree editable="bottom">
+		                  <field name="model_id" invisible="1"/>
+		                  <field name="model" invisible="1"/>
+		                  <field name="sequence" widget="handle"/>
+		                  <field name="field_id" domain="[('name','!=','create_date'),('name','!=','create_uid'),('name','!=','id'),('name','!=','write_date'),('name','!=','write_uid'),('model_id','=',model)]"/>
+		                  <field name="html_name"/>
+		                  <field name="field_label"/>
+		                  <field name="html_field_type"/>
+		              </tree>
+		          </field>
+		          
+		          <field name="defaults_values" context="{'html_id': active_id,'default_model_id':model_id}">
+			      <tree editable="bottom">
+			      	  <field name="model_id" invisible="1"/>
+		                  <field name="model" invisible="1" />
+			          <field name="field_id" domain="[('name','!=','create_date'),('name','!=','create_uid'),('name','!=','id'),('name','!=','write_date'),('name','!=','write_uid'),('model_id','=',model)]"/>
+			          <field name="default_value"/>
+			      </tree>
+			  </field>
+		          
+                          <field name="output_html"/>
+                      </group>
+                      <footer>
+                          <button type="object" name="generate_form" string="Make Embed Code"/> 
+                      </footer>
+                  </sheet>
+              </form>
+          </field>
+      </record>          
+
+      <record model="ir.ui.view" id="ehtml_history_form_view">
+         <field name="name">ehtml History Form</field>
+         <field name="model">ehtml.history</field>
+         <field name="arch" type="xml">
+             <form string="HTML Form History">
+                  <sheet>
+                      <group>		          
+                          <field name="html_id"/>
+                          <field name="ref_url"/>
+                          <field name="record_id"/>                          
+                          <field name="insert_data">
+                              <tree>
+                                  <field name="field_id"/>
+                                  <field name="insert_value"/>
+                              </tree>
+                          </field>
+                      </group>
+                  </sheet>
+              </form>
+          </field>
+      </record>          
+          
+      <record model="ir.ui.view" id="ehtml_history_tree_view">
+         <field name="name">ehtml History Tree</field>
+         <field name="model">ehtml.history</field>
+         <field name="arch" type="xml">
+             <tree string="HTML Embed Form History Tree">
+                 <field name="form_name"/>
+                 <field name="ref_url"/>
+             </tree>        
+          </field>
+      </record>          
+
+      
+      <record model="ir.actions.act_window" id="ehtml_action">
+          <field name="name">HTML</field>
+          <field name="res_model">ehtml.formgen</field>
+          <field name="view_type">form</field>
+          <field name="view_mode">tree,form</field>
+          <field name="help" type="html">
+              <p class="oe_view_nocontent_create">Create the first HTML Embed form</p>
+          </field>
+      </record>
+        
+      <record model="ir.actions.act_window" id="ehtml_history_action">
+          <field name="name">HTML</field>
+          <field name="res_model">ehtml.history</field>
+          <field name="view_type">form</field>
+          <field name="view_mode">tree,form</field>
+          <field name="help" type="html">
+              <p class="oe_view_nocontent_create">Create the first HTML Embed form</p>
+          </field>
+      </record>
+        
+        
+      <menuitem id="ehtml_menu" name="HTML Embed Forms" parent="base.menu_custom" sequence="160"/>
+      <menuitem id="ehtml_menu_insert" name="Create Forms" parent="ehtml_menu" action="ehtml_action" sequence="170"/>
+      <menuitem id="ehtml_menu_history" name="Inserted Form Data" parent="ehtml_menu" action="ehtml_history_action" sequence="180"/>
+        
+  </data>
+</openerp>

+ 6 - 0
security/ir.model.access.csv

@@ -0,0 +1,6 @@
+"id","name","model_id:id","group_id:id","perm_read","perm_write","perm_create","perm_unlink"
+"access_ehtml_formgen_system","Access ehtml.formgen System","model_ehtml_formgen","base.group_system",1,1,1,1
+"access_ehtml_fieldentry_system","Access ehtml.fieldentry System","model_ehtml_fieldentry","base.group_system",1,1,1,1
+"access_ehtml_fielddefault_system","Access ehtml.fielddefault System","model_ehtml_fielddefault","base.group_system",1,1,1,1
+"access_ehtml_history_system","Access ehtml.history System","model_ehtml_history","base.group_system",1,0,0,0
+"access_ehtml_fieldinsert_system","Access ehtml.fieldinsert System","model_ehtml_fieldinsert","base.group_system",1,0,0,0

BIN
static/description/1.jpg


BIN
static/description/2.jpg


BIN
static/description/3.jpg


BIN
static/description/Thumbs.db


BIN
static/description/icon.png


+ 70 - 0
static/description/index.html

@@ -0,0 +1,70 @@
+<div style="margin-left:100px;margin-right:100px;">
+<h2>Description</h2>
+Creates an HTML form that you can embed inside and outside Odoo<br>
+<br>
+<section class="oe_container">
+    <div class="oe_row oe_spaced">
+        <h2 class="oe_slogan">Create HTML Forms</h2>
+        <div class="oe_span6">
+            <div class="oe_row_img oe_centered">
+                <img class="oe_picture oe_screenshot" src="2.jpg" alt="Create HTML Form">
+            </div>
+        </div>
+        <div class="oe_span6">
+            <p class="oe_mt32">
+Creates an HTML form that you can embed inside and outside Odoo.<br>
+<br/>
+<b>Instructions</b><br/>
+1.  Go to Settings->HTML Embed Forms->Create Forms<br>
+2.  Select the model and the fields in the form<br>
+3.  Click "Make Embed Code" button and copy and paste the code into your website<br/>
+            </p>
+        </div>
+    </div>
+</section>
+
+<section class="oe_container oe_dark">
+    <div class="oe_row oe_spaced">
+        <h2 class="oe_slogan">View Form Submissions</h2>
+        <div class="oe_span6">
+            <p class="oe_mt32">
+Keep a  record of all the form submissions<br/>
+<br/>
+<b>Instructions</b><br/>
+1.  Go to Settings->HTML Embed Forms->Inserted Form Data<br>
+            </p>
+        </div>
+        <div class="oe_span6">
+            <div class="oe_row_img oe_centered">
+
+<img class="oe_picture oe_screenshot" src="3.jpg" alt="HTML Form Submissions">
+
+            </div>
+        </div>
+    </div>
+</section>
+
+<section class="oe_container">
+    <div class="oe_row oe_spaced">
+        <h2 class="oe_slogan">Rearange form fields on the website</h2>
+        <div class="oe_span6">
+            <div class="oe_row_img oe_centered">
+                <img class="oe_picture oe_screenshot" src="1.jpg" alt="Edit Website HTML Form">
+            </div>
+        </div>
+        <div class="oe_span6">
+            <p class="oe_mt32">
+Rearange form fields on the website.<br>
+<br/>
+<b>Instructions</b><br/>
+1.  Go to the webpage with the eHTML form<br>
+2.  Hit edit and drag and drop the fields around the form<br>
+            </p>
+        </div>
+    </div>
+</section>
+<br/>
+<b>NOTE</b> This module and 'HTML Snippet Form Builder' have reborn to thier v9 equivalent 'HTML Form Builder' and 'HTML Form Builder - Website Snippets'<br/>
+<br/>
+Find a bug? feature idea? send an email to steven@sythiltech.com.au<br>
+</div>

BIN
static/src/img/ui/snippet_thumb_field.jpg


BIN
static/src/img/ui/snippet_thumb_form.jpg


+ 36 - 0
static/src/js/ehtml_editor.js

@@ -0,0 +1,36 @@
+(function() {
+    'use strict';
+    var website = openerp.website;
+    website.openerp_website = {};
+
+    website.snippet.options.ehtml = website.snippet.Option.extend({
+        drop_and_build_snippet: function() {
+
+        }
+
+    })
+
+
+    website.snippet.options.ehtml_field = website.snippet.Option.extend({
+        drop_and_build_snippet: function() {
+
+
+            var self = this;
+            return website.prompt({
+                id: "editor_field_options_button",
+                window_title: "Edit Field Options",
+            }).then(function (ehtml_id) {
+                alert("edit");
+                //self.$target.attr("data-id", mail_group_id);
+
+            });
+
+
+        }
+
+    })
+
+
+
+
+})();

+ 89 - 0
views/snippets.xml

@@ -0,0 +1,89 @@
+<?xml version="1.0" encoding="utf-8"?>
+<openerp>
+  <data>
+
+    <template id="ehtml_editor" inherit_id="website.assets_editor" name="eHTML Resources">
+        <xpath expr="/t" position="inside">
+            <script type="text/javascript" src="/entity_html_form/static/src/js/ehtml_editor.js" />
+        </xpath>
+    </template>
+
+<template id="ehtml" inherit_id="website.snippets" name="eHTML Forms Snippet">
+  <xpath expr="//div[@id='snippet_structure']" position="inside">
+ 
+     <div>
+         <div class="oe_snippet_thumbnail">
+             <img class="oe_snippet_thumbnail_img" src="/entity_html_form/static/src/img/ui/snippet_thumb_form.jpg"/>
+             <span class="oe_snippet_thumbnail_title">HTML Form(Alpha)</span>
+         </div>
+ 
+         <section class="oe_snippet_body ehtml_form">
+             <div class="container">
+                 <div class="row">
+                     My Form
+                     <form method="POST" action="/form/myinsert">
+                         <div id="ehtml_fields" class="oe_structure">
+                         
+                         </div>
+                         <input type="submit" class="btn btn-primary btn-lg" value="Send"/>
+                     </form>
+                 </div>
+             </div>
+         </section>
+    </div>
+
+    
+    
+  </xpath>
+
+
+    <xpath expr="//div[@id='snippet_options']" position="inside">
+        <div data-snippet-option-id='ehtml'
+            data-selector=".ehtml_form"
+            data-selector-siblings="p, h1, h2, h3, blockquote, .well, .panel"
+           >
+            <li>
+                <a href="#" class="button">Change Form Settings</a>
+            </li>
+        </div>
+    </xpath>
+    
+</template>
+
+
+<template id="ehtml_field" inherit_id="website.snippets" name="eHTML Field Snippet">
+  <xpath expr="//div[@id='snippet_structure']" position="inside">
+ 
+     <div>
+         <div class="oe_snippet_thumbnail">
+             <img class="oe_snippet_thumbnail_img" src="/entity_html_form/static/src/img/ui/snippet_thumb_field.jpg"/>
+             <span class="oe_snippet_thumbnail_title">HTML Form Field Snippet(Alpha)</span>
+         </div>
+ 
+         <section class="oe_snippet_body ehtml_form_field">
+             <div class="form-group">
+	         <label for="field1">Field 1</label>
+                 <input type="text" class="form-control" id="field1" name="field1"/>
+             </div>
+         </section>
+    </div>
+
+  </xpath>
+  
+  
+      <xpath expr="//div[@id='snippet_options']" position="inside">
+          <div data-snippet-option-id='ehtml_field'
+              data-selector=".ehtml_form_field"
+              data-selector-siblings="form"
+             >
+              <li>
+                  <a href="#" class="button">Change Field Settings</a>
+              </li>
+          </div>
+    </xpath>
+    
+</template>
+
+
+  </data>
+</openerp>

+ 0 - 0
views/susbcribe.xml


+ 37 - 0
views/website_templates.xml

@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="utf-8"?>
+<openerp>
+    <data>
+
+        <template id="ehtml_thank_you" name="Thank You" page="True">
+            <t t-call="website.layout">
+                <div id="wrap" class="oe_structure oe_empty">
+                    <section>
+                        <div class="container">
+                            <div class="row">
+                                <div class="col-md-12">
+                                    <h1 class="text-center">Thank You</h1>
+                                </div>
+                            </div>
+                        </div>
+                    </section>
+                </div>
+            </t>
+        </template>
+        <template id="myinsert" name="Email_invalido" page="True">
+            <t t-call="website.layout">
+                <div id="wrap" class="oe_structure oe_empty">
+                    <section>
+                        <div class="container">
+                            <div class="row">
+                                <div class="col-md-12">
+                                    <h1 class="text-center">Email no valido</h1>
+                                </div>
+                            </div>
+                        </div>
+                    </section>
+                </div>
+            </t>
+        </template>
+
+    </data>
+</openerp>