Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(website.snipped.contact.form): Se agrega plantilla alternativa #3

Open
wants to merge 3 commits into
base: 8.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions website_snippet_contact_form/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from . import controllers
from . import models
2 changes: 2 additions & 0 deletions website_snippet_contact_form/__openerp__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,14 @@
"application": False,
"installable": True,
"depends": [
"base",
"crm",
"website_sale",
],
"data": [
"views/snippets.xml",
"views/assets.xml",
"views/pages.xml",
"views/contact_form_crm.xml",
],
}
24 changes: 19 additions & 5 deletions website_snippet_contact_form/controllers/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,27 @@ def preRenderThanks(self, values, kwargs):

def get_contactus_response(self, values, kwargs):
values = self.preRenderThanks(values, kwargs)
return request.website.render(
kwargs.get(
"view_callback",
"website_snippet_contact_form.contactus_thanks"
), values
type_form = request.env['contact.form'].sudo().search(
[],
order="create_date DESC",
limit=1,
)

if type_form.custom_form == True:
return request.website.render(
kwargs.get(
"view_callback",
"website_snippet_contact_form.custom_form_page"
), values
)
else:
return request.website.render(
kwargs.get(
"view_callback",
"website_snippet_contact_form.contactus_thanks"
), values
)

@http.route(['/crm/contactus'], type='http', auth="public", website=True)
def contactus(self, **kwargs):
def dict_to_str(title, dictvar):
Expand Down
3 changes: 3 additions & 0 deletions website_snippet_contact_form/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# -*- coding: utf-8 -*-

from . import contact_form_crm
13 changes: 13 additions & 0 deletions website_snippet_contact_form/models/contact_form_crm.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# -*- coding: utf-8 -*-

from openerp import fields, models


class ContactForm(models.Model):
_name = "contact.form"
_inherit = 'res.config.settings'

custom_form = fields.Boolean(
string="Use custom form",
help="Empty page",
)
40 changes: 40 additions & 0 deletions website_snippet_contact_form/views/contact_form_crm.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>

<record id="view_contact_form_configuration" model="ir.ui.view">
<field name="name">Configure Contact Form</field>
<field name="model">contact.form</field>
<field name="arch" type="xml">
<form string="Configure Contact Form" class="oe_form_configuration">
<header>
<button string="Apply" type="object" name="execute" class="oe_highlight"/>
or
<button string="Cancel" type="object" name="cancel" class="oe_link"/>
</header>
<separator string="Contact Form Type"/>
<group>
<label for="id" string="Settings"/>
<div>
<div name="custom_form">
<field name="custom_form" class="oe_inline"/>
<label for="custom_form"/>
</div>
</div>
</group>
</form>
</field>
</record>

<record id="contact_form_configuration_action" model="ir.actions.act_window">
<field name="name">Contact Form</field>
<field name="res_model">contact.form</field>
<field name="view_mode">form</field>
<field name="target">inline</field>
</record>

<menuitem id="contact_form_configuration_menu" name="CRM" parent="base.menu_config"
sequence="40" action="contact_form_configuration_action"/>

</data>
</openerp>
8 changes: 8 additions & 0 deletions website_snippet_contact_form/views/pages.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,14 @@
</t>
</template>

<template id="custom_form_page" name="Custom Form Page">
<t t-call="website.layout">
<div id="wrap">
<div class="oe_structure oe_empty"/>
</div>
</t>
</template>

<template id="validation_error_page">
<t t-call="website.layout">
<div id="wrap">
Expand Down