SlideShare a Scribd company logo
1 of 20
Download to read offline
CMS Dynamic Widgets
Thibault Delavallée, R&D Engineer
Dynamic widgets
ThibaultDelavallée(tde@odoo.com)
Dynamic widgets
Widgets, Snippets -> CMS building blocks
Dynamic widgets: Discussion Groups, Mailing Lists
ThibaultDelavallée(tde@odoo.com)
Dynamic widgets
Efficient and simple way to customize your website
Integrates with Odoo apps: subscribe to a discussion
group, create leads, fill issues, ...
Use the full power of odoo
·
·
·
ThibaultDelavallée(tde@odoo.com)
Show me the stuff !
Running example: Contact WidgetContact Widget
small contact form
create leads from questions
drag 'n drop it anywhere usefull
·
·
·
ThibaultDelavallée(tde@odoo.com)
Demo
Talk structure
Running example: Contact Widget
body, content
addition in CMS editor
dynamic configuration: choosing
the sales team
link with backend: linking the
button to the lead creation
·
·
·
·
ThibaultDelavallée(tde@odoo.com)
Body: widget content
Body = HTMLHTML + CSSCSS (bootstrap)
a (hidden) sales team
a question
an email
a submit button
<input<input type="hidden" name="section_id" value="0"/>/>
<textarea<textarea name="description"></textarea>></textarea>
<div<div class="input-group">>
<input<input type="email" name="email_from"/>/>
<button<button type="submit">>Contact Us</button></button>
</div></div>
·
·
·
·
ThibaultDelavallée(tde@odoo.com)
Addition in Editor
Snippets ? QWeb template !
<?xml version="1.0" encoding="utf-8"?>
<openerp><openerp>
<data><data>
<template<template id="snippets">>
<!-- here be snippets by categories -->
...
</template></template>
</data></data>
</openerp></openerp>
ThibaultDelavallée(tde@odoo.com)
Addition in Editor
Snippet addition: extend the editor QWeb template
<template<template id="contact_snippet"
name="Contact Snippet"
inherit_id="website.snippets">>
<xpath<xpath expr="//div[@id='snippet_feature']" position="inside">>
<!-- begin snippet declaration -->
<div><div>
...
</div></div>
<!-- end of snippet declaration -->
</xpath></xpath>
</template></template>
ThibaultDelavallée(tde@odoo.com)
Addition in Editor
thumbnail: icon in editor
<xpath<xpath expr="//div[@id='snippet_feature']" position="inside">>
...
<div<div class="oe_snippet_thumbnail">>
<img<img class="oe_snippet_thumbnail_img" src="/images/icon.png"/>/>
<span<span class="oe_snippet_thumbnail_title">>Contact Snippet</span></span>
</div></div>
</xpath></xpath>
body of the snippet
<xpath<xpath expr="//div[@id='snippet_feature']" position="inside">>
...
<section<section class="oe_snippet_body js_contact">>
<!-- snippet HTML content -->
</section></section>
</xpath></xpath>
·
·
ThibaultDelavallée(tde@odoo.com)
Snippet options
placement: data-selector-...
menu option: li, option menu entry
<div<div data-snippet-option-id='contact_snippet'
data-selector=".js_contact"
data-selector-siblings="p, h1, h2, h3, blockquote,
div, .well, .panel">>
<li><li>
<a<a href="#" class="button js_contact_sales_team">>
Change Sales Team
</a></a>
</li></li>
</div></div>
·
·
ThibaultDelavallée(tde@odoo.com)
Widget -> Dynamic Widget
Dynamic customize
Customize menu
To link with
ThibaultDelavallée(tde@odoo.com)
Dynamic customize
Add a snippet.Option to add dynamic configuration
Example: Discussion Group choice, Sales Team choice, ...
snippet..options..contact_snippet == snippet..Option..extend({({
on_prompt:: functionfunction ()() {{
returnreturn website..prompt({({
window_title:: _t(("Add a Contact Snippet"),),
init:: functionfunction ((field)) {{
returnreturn website..session..model(('crm.case.section'))
..call(('name_search',, [['',, []])},[]])},
}).}).then((functionfunction ((sales_team_id)) {{
self..$(('.js_section_id').).attr(("value",, sales_team_id););
});});
}}
});});
ThibaultDelavallée(tde@odoo.com)
Link with back-end
To contact the back-end: define a new routeroute
Route: URL -> action performed by server
Defined in Python, in a controller
classclass ContactUsShort((http..Controller):):
# define my custom controller
@http.route@http.route(('/my/route',, ......))
defdef my_route((......):):
{http://myodoo.com/}crm/contact_short will be a route
creating a lead from data coming from the form
·
·
ThibaultDelavallée(tde@odoo.com)
Link with back-end
crm/contact_short definition
@http.route@http.route([(['/crm/contact_short'],], type=='json'))
defdef contactus((self,, question==None,, email==None,,
section_id==None,, ****kwargs):):
lead_values == {{
'name':: 'Lead from %s (Contact Snippet)' %% email,,
'description':: question,,
'email_from':: email,,
'section_id':: section_id,,
'user_id':: False,,
}}
returnreturn request..registry[['crm.lead']]..create((cr,, uid,, lead_values,,
context))
ThibaultDelavallée(tde@odoo.com)
Dynamic behavior
Bind Contact Us to the back-end
snippet..animationRegistry..contact == snippet..Animation..extend({({
start:: functionfunction ((editable_mode)) {{
thisthis..$(('.js_contact_btn').).on(('click',, functionfunction ((event)) {{
// perform verification
......
// json call to a route
returnreturn openerp..jsonRpc(('/crm/contact_short',, 'call',, {{
'section_id':: ++section_id,,
'email':: email,,
'question':: question,,
}).}).then((functionfunction ((result)) {{ ...... });});
});});
},},
});});
ThibaultDelavallée(tde@odoo.com)
And we are done !
Definition: an HTML body in
a template
Placement: XML declaration
Configuration: JS Option
Behavior: JS Animation
Link: Python controller and routes
·
·
·
·
·
ThibaultDelavallée(tde@odoo.com)
Thanks for your attention
Any questions ? tde@odoo.com / chm@odoo.com

More Related Content

What's hot

Odoo - Open chatter integration
Odoo - Open chatter integrationOdoo - Open chatter integration
Odoo - Open chatter integration
Odoo
 
Document Object Model
Document Object ModelDocument Object Model
Document Object Model
chomas kandar
 

What's hot (20)

Dynamic HTML (DHTML)
Dynamic HTML (DHTML)Dynamic HTML (DHTML)
Dynamic HTML (DHTML)
 
Odoo - Open chatter integration
Odoo - Open chatter integrationOdoo - Open chatter integration
Odoo - Open chatter integration
 
Le Wagon - UI and Design Crash Course
Le Wagon - UI and Design Crash CourseLe Wagon - UI and Design Crash Course
Le Wagon - UI and Design Crash Course
 
Document Object Model
Document Object ModelDocument Object Model
Document Object Model
 
HTML & CSS Masterclass
HTML & CSS MasterclassHTML & CSS Masterclass
HTML & CSS Masterclass
 
Html forms
Html formsHtml forms
Html forms
 
Odoo Experience 2018 - Visualizing Data in Odoo: How to Create a New View
Odoo Experience 2018 - Visualizing Data in Odoo: How to Create a New ViewOdoo Experience 2018 - Visualizing Data in Odoo: How to Create a New View
Odoo Experience 2018 - Visualizing Data in Odoo: How to Create a New View
 
Htmltag.ppt
Htmltag.pptHtmltag.ppt
Htmltag.ppt
 
Java script errors &amp; exceptions handling
Java script  errors &amp; exceptions handlingJava script  errors &amp; exceptions handling
Java script errors &amp; exceptions handling
 
Introduction to HTML and CSS
Introduction to HTML and CSSIntroduction to HTML and CSS
Introduction to HTML and CSS
 
Jquery
JqueryJquery
Jquery
 
Xhtml
XhtmlXhtml
Xhtml
 
Odoo - Smart buttons
Odoo - Smart buttonsOdoo - Smart buttons
Odoo - Smart buttons
 
HTML Introduction
HTML IntroductionHTML Introduction
HTML Introduction
 
Developing New Widgets for your Views in Owl
Developing New Widgets for your Views in OwlDeveloping New Widgets for your Views in Owl
Developing New Widgets for your Views in Owl
 
Reactjs workshop (1)
Reactjs workshop (1)Reactjs workshop (1)
Reactjs workshop (1)
 
Asp.net state management
Asp.net state managementAsp.net state management
Asp.net state management
 
HTML (Web) basics for a beginner
HTML (Web) basics for a beginnerHTML (Web) basics for a beginner
HTML (Web) basics for a beginner
 
Html basic
Html basicHtml basic
Html basic
 
HTML5
HTML5HTML5
HTML5
 

Similar to Odoo - CMS dynamic widgets

Official Presentation
Official PresentationOfficial Presentation
Official Presentation
Ajay Yadav
 

Similar to Odoo - CMS dynamic widgets (20)

Building beautiful websites with bootstrap a case study (DevelopMentor webcast)
Building beautiful websites with bootstrap  a case study (DevelopMentor webcast)Building beautiful websites with bootstrap  a case study (DevelopMentor webcast)
Building beautiful websites with bootstrap a case study (DevelopMentor webcast)
 
Rapid development & integration of real time communication in websites
Rapid development & integration of real time communication in websitesRapid development & integration of real time communication in websites
Rapid development & integration of real time communication in websites
 
Add Clarity to Communications to Delight Customers
Add Clarity to Communications to Delight CustomersAdd Clarity to Communications to Delight Customers
Add Clarity to Communications to Delight Customers
 
Modifying your themes design - Learning CSS - Atlanta WordPress users group
Modifying your themes design - Learning CSS - Atlanta WordPress users groupModifying your themes design - Learning CSS - Atlanta WordPress users group
Modifying your themes design - Learning CSS - Atlanta WordPress users group
 
Chapter3b McHaney
Chapter3b McHaneyChapter3b McHaney
Chapter3b McHaney
 
Chapter3b McHaney 2nd edition
Chapter3b McHaney 2nd editionChapter3b McHaney 2nd edition
Chapter3b McHaney 2nd edition
 
Monetate Implementation Cheat Sheet
Monetate Implementation Cheat SheetMonetate Implementation Cheat Sheet
Monetate Implementation Cheat Sheet
 
Adxstudio Portals provide solutions to access webpage for Microsoft dynamics CRM
Adxstudio Portals provide solutions to access webpage for Microsoft dynamics CRMAdxstudio Portals provide solutions to access webpage for Microsoft dynamics CRM
Adxstudio Portals provide solutions to access webpage for Microsoft dynamics CRM
 
WordPress Basics
WordPress BasicsWordPress Basics
WordPress Basics
 
Miva ReadyThemes for Store Owners
Miva ReadyThemes for Store OwnersMiva ReadyThemes for Store Owners
Miva ReadyThemes for Store Owners
 
Web-First Design Patterns
Web-First Design PatternsWeb-First Design Patterns
Web-First Design Patterns
 
Advantages & Disadvantages of Wordpress
Advantages & Disadvantages of WordpressAdvantages & Disadvantages of Wordpress
Advantages & Disadvantages of Wordpress
 
Employee Community
Employee CommunityEmployee Community
Employee Community
 
Continuous integration using thucydides(bdd) with selenium
Continuous integration using thucydides(bdd) with seleniumContinuous integration using thucydides(bdd) with selenium
Continuous integration using thucydides(bdd) with selenium
 
Nabdslide
NabdslideNabdslide
Nabdslide
 
TopicHero Descriptions Tutorial
TopicHero Descriptions TutorialTopicHero Descriptions Tutorial
TopicHero Descriptions Tutorial
 
Introduction to modern front-end with Vue.js
Introduction to modern front-end with Vue.jsIntroduction to modern front-end with Vue.js
Introduction to modern front-end with Vue.js
 
Desk.Com
Desk.ComDesk.Com
Desk.Com
 
Official Presentation
Official PresentationOfficial Presentation
Official Presentation
 
WordCamp Praga 2015
WordCamp Praga 2015WordCamp Praga 2015
WordCamp Praga 2015
 

More from Odoo

More from Odoo (20)

Timesheet Workshop: The Timesheet App People Love!
Timesheet Workshop: The Timesheet App People Love!Timesheet Workshop: The Timesheet App People Love!
Timesheet Workshop: The Timesheet App People Love!
 
Odoo 3D Product View with Google Model-Viewer
Odoo 3D Product View with Google Model-ViewerOdoo 3D Product View with Google Model-Viewer
Odoo 3D Product View with Google Model-Viewer
 
Keynote - Vision & Strategy
Keynote - Vision & StrategyKeynote - Vision & Strategy
Keynote - Vision & Strategy
 
Opening Keynote - Unveilling Odoo 14
Opening Keynote - Unveilling Odoo 14Opening Keynote - Unveilling Odoo 14
Opening Keynote - Unveilling Odoo 14
 
Extending Odoo with a Comprehensive Budgeting and Forecasting Capability
Extending Odoo with a Comprehensive Budgeting and Forecasting CapabilityExtending Odoo with a Comprehensive Budgeting and Forecasting Capability
Extending Odoo with a Comprehensive Budgeting and Forecasting Capability
 
Managing Multi-channel Selling with Odoo
Managing Multi-channel Selling with OdooManaging Multi-channel Selling with Odoo
Managing Multi-channel Selling with Odoo
 
Product Configurator: Advanced Use Case
Product Configurator: Advanced Use CaseProduct Configurator: Advanced Use Case
Product Configurator: Advanced Use Case
 
Accounting Automation: How Much Money We Saved and How?
Accounting Automation: How Much Money We Saved and How?Accounting Automation: How Much Money We Saved and How?
Accounting Automation: How Much Money We Saved and How?
 
Rock Your Logistics with Advanced Operations
Rock Your Logistics with Advanced OperationsRock Your Logistics with Advanced Operations
Rock Your Logistics with Advanced Operations
 
Transition from a cost to a flow-centric organization
Transition from a cost to a flow-centric organizationTransition from a cost to a flow-centric organization
Transition from a cost to a flow-centric organization
 
Synchronization: The Supply Chain Response to Overcome the Crisis
Synchronization: The Supply Chain Response to Overcome the CrisisSynchronization: The Supply Chain Response to Overcome the Crisis
Synchronization: The Supply Chain Response to Overcome the Crisis
 
Running a University with Odoo
Running a University with OdooRunning a University with Odoo
Running a University with Odoo
 
Down Payments on Purchase Orders in Odoo
Down Payments on Purchase Orders in OdooDown Payments on Purchase Orders in Odoo
Down Payments on Purchase Orders in Odoo
 
Odoo Implementation in Phases - Success Story of a Retail Chain 3Sach food
Odoo Implementation in Phases - Success Story of a Retail Chain 3Sach foodOdoo Implementation in Phases - Success Story of a Retail Chain 3Sach food
Odoo Implementation in Phases - Success Story of a Retail Chain 3Sach food
 
Migration from Salesforce to Odoo
Migration from Salesforce to OdooMigration from Salesforce to Odoo
Migration from Salesforce to Odoo
 
Preventing User Mistakes by Using Machine Learning
Preventing User Mistakes by Using Machine LearningPreventing User Mistakes by Using Machine Learning
Preventing User Mistakes by Using Machine Learning
 
Becoming an Odoo Expert: How to Prepare for the Certification
Becoming an Odoo Expert: How to Prepare for the Certification Becoming an Odoo Expert: How to Prepare for the Certification
Becoming an Odoo Expert: How to Prepare for the Certification
 
Instant Printing of any Odoo Report or Shipping Label
Instant Printing of any Odoo Report or Shipping LabelInstant Printing of any Odoo Report or Shipping Label
Instant Printing of any Odoo Report or Shipping Label
 
How Odoo helped an Organization Grow 3 Fold
How Odoo helped an Organization Grow 3 FoldHow Odoo helped an Organization Grow 3 Fold
How Odoo helped an Organization Grow 3 Fold
 
From Shopify to Odoo
From Shopify to OdooFrom Shopify to Odoo
From Shopify to Odoo
 

Recently uploaded

Structuring Teams and Portfolios for Success
Structuring Teams and Portfolios for SuccessStructuring Teams and Portfolios for Success
Structuring Teams and Portfolios for Success
UXDXConf
 
Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo Diehl
Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo DiehlFuture Visions: Predictions to Guide and Time Tech Innovation, Peter Udo Diehl
Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo Diehl
Peter Udo Diehl
 

Recently uploaded (20)

Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...
Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...
Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...
 
What's New in Teams Calling, Meetings and Devices April 2024
What's New in Teams Calling, Meetings and Devices April 2024What's New in Teams Calling, Meetings and Devices April 2024
What's New in Teams Calling, Meetings and Devices April 2024
 
Designing for Hardware Accessibility at Comcast
Designing for Hardware Accessibility at ComcastDesigning for Hardware Accessibility at Comcast
Designing for Hardware Accessibility at Comcast
 
Oauth 2.0 Introduction and Flows with MuleSoft
Oauth 2.0 Introduction and Flows with MuleSoftOauth 2.0 Introduction and Flows with MuleSoft
Oauth 2.0 Introduction and Flows with MuleSoft
 
Extensible Python: Robustness through Addition - PyCon 2024
Extensible Python: Robustness through Addition - PyCon 2024Extensible Python: Robustness through Addition - PyCon 2024
Extensible Python: Robustness through Addition - PyCon 2024
 
How we scaled to 80K users by doing nothing!.pdf
How we scaled to 80K users by doing nothing!.pdfHow we scaled to 80K users by doing nothing!.pdf
How we scaled to 80K users by doing nothing!.pdf
 
Simplified FDO Manufacturing Flow with TPMs _ Liam at Infineon.pdf
Simplified FDO Manufacturing Flow with TPMs _ Liam at Infineon.pdfSimplified FDO Manufacturing Flow with TPMs _ Liam at Infineon.pdf
Simplified FDO Manufacturing Flow with TPMs _ Liam at Infineon.pdf
 
Choosing the Right FDO Deployment Model for Your Application _ Geoffrey at In...
Choosing the Right FDO Deployment Model for Your Application _ Geoffrey at In...Choosing the Right FDO Deployment Model for Your Application _ Geoffrey at In...
Choosing the Right FDO Deployment Model for Your Application _ Geoffrey at In...
 
Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...
Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...
Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...
 
Structuring Teams and Portfolios for Success
Structuring Teams and Portfolios for SuccessStructuring Teams and Portfolios for Success
Structuring Teams and Portfolios for Success
 
How Red Hat Uses FDO in Device Lifecycle _ Costin and Vitaliy at Red Hat.pdf
How Red Hat Uses FDO in Device Lifecycle _ Costin and Vitaliy at Red Hat.pdfHow Red Hat Uses FDO in Device Lifecycle _ Costin and Vitaliy at Red Hat.pdf
How Red Hat Uses FDO in Device Lifecycle _ Costin and Vitaliy at Red Hat.pdf
 
10 Differences between Sales Cloud and CPQ, Blanka Doktorová
10 Differences between Sales Cloud and CPQ, Blanka Doktorová10 Differences between Sales Cloud and CPQ, Blanka Doktorová
10 Differences between Sales Cloud and CPQ, Blanka Doktorová
 
WebAssembly is Key to Better LLM Performance
WebAssembly is Key to Better LLM PerformanceWebAssembly is Key to Better LLM Performance
WebAssembly is Key to Better LLM Performance
 
Introduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdf
Introduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdfIntroduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdf
Introduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdf
 
Salesforce Adoption – Metrics, Methods, and Motivation, Antone Kom
Salesforce Adoption – Metrics, Methods, and Motivation, Antone KomSalesforce Adoption – Metrics, Methods, and Motivation, Antone Kom
Salesforce Adoption – Metrics, Methods, and Motivation, Antone Kom
 
SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...
SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...
SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...
 
Optimizing NoSQL Performance Through Observability
Optimizing NoSQL Performance Through ObservabilityOptimizing NoSQL Performance Through Observability
Optimizing NoSQL Performance Through Observability
 
WSO2CONMay2024OpenSourceConferenceDebrief.pptx
WSO2CONMay2024OpenSourceConferenceDebrief.pptxWSO2CONMay2024OpenSourceConferenceDebrief.pptx
WSO2CONMay2024OpenSourceConferenceDebrief.pptx
 
Strategic AI Integration in Engineering Teams
Strategic AI Integration in Engineering TeamsStrategic AI Integration in Engineering Teams
Strategic AI Integration in Engineering Teams
 
Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo Diehl
Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo DiehlFuture Visions: Predictions to Guide and Time Tech Innovation, Peter Udo Diehl
Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo Diehl
 

Odoo - CMS dynamic widgets

  • 1. CMS Dynamic Widgets Thibault Delavallée, R&D Engineer
  • 3. Dynamic widgets Widgets, Snippets -> CMS building blocks Dynamic widgets: Discussion Groups, Mailing Lists ThibaultDelavallée(tde@odoo.com)
  • 4. Dynamic widgets Efficient and simple way to customize your website Integrates with Odoo apps: subscribe to a discussion group, create leads, fill issues, ... Use the full power of odoo · · · ThibaultDelavallée(tde@odoo.com)
  • 5. Show me the stuff ! Running example: Contact WidgetContact Widget small contact form create leads from questions drag 'n drop it anywhere usefull · · · ThibaultDelavallée(tde@odoo.com)
  • 7. Talk structure Running example: Contact Widget body, content addition in CMS editor dynamic configuration: choosing the sales team link with backend: linking the button to the lead creation · · · · ThibaultDelavallée(tde@odoo.com)
  • 8. Body: widget content Body = HTMLHTML + CSSCSS (bootstrap) a (hidden) sales team a question an email a submit button <input<input type="hidden" name="section_id" value="0"/>/> <textarea<textarea name="description"></textarea>></textarea> <div<div class="input-group">> <input<input type="email" name="email_from"/>/> <button<button type="submit">>Contact Us</button></button> </div></div> · · · · ThibaultDelavallée(tde@odoo.com)
  • 9. Addition in Editor Snippets ? QWeb template ! <?xml version="1.0" encoding="utf-8"?> <openerp><openerp> <data><data> <template<template id="snippets">> <!-- here be snippets by categories --> ... </template></template> </data></data> </openerp></openerp> ThibaultDelavallée(tde@odoo.com)
  • 10. Addition in Editor Snippet addition: extend the editor QWeb template <template<template id="contact_snippet" name="Contact Snippet" inherit_id="website.snippets">> <xpath<xpath expr="//div[@id='snippet_feature']" position="inside">> <!-- begin snippet declaration --> <div><div> ... </div></div> <!-- end of snippet declaration --> </xpath></xpath> </template></template> ThibaultDelavallée(tde@odoo.com)
  • 11. Addition in Editor thumbnail: icon in editor <xpath<xpath expr="//div[@id='snippet_feature']" position="inside">> ... <div<div class="oe_snippet_thumbnail">> <img<img class="oe_snippet_thumbnail_img" src="/images/icon.png"/>/> <span<span class="oe_snippet_thumbnail_title">>Contact Snippet</span></span> </div></div> </xpath></xpath> body of the snippet <xpath<xpath expr="//div[@id='snippet_feature']" position="inside">> ... <section<section class="oe_snippet_body js_contact">> <!-- snippet HTML content --> </section></section> </xpath></xpath> · · ThibaultDelavallée(tde@odoo.com)
  • 12. Snippet options placement: data-selector-... menu option: li, option menu entry <div<div data-snippet-option-id='contact_snippet' data-selector=".js_contact" data-selector-siblings="p, h1, h2, h3, blockquote, div, .well, .panel">> <li><li> <a<a href="#" class="button js_contact_sales_team">> Change Sales Team </a></a> </li></li> </div></div> · · ThibaultDelavallée(tde@odoo.com)
  • 14. Dynamic customize Customize menu To link with ThibaultDelavallée(tde@odoo.com)
  • 15. Dynamic customize Add a snippet.Option to add dynamic configuration Example: Discussion Group choice, Sales Team choice, ... snippet..options..contact_snippet == snippet..Option..extend({({ on_prompt:: functionfunction ()() {{ returnreturn website..prompt({({ window_title:: _t(("Add a Contact Snippet"),), init:: functionfunction ((field)) {{ returnreturn website..session..model(('crm.case.section')) ..call(('name_search',, [['',, []])},[]])}, }).}).then((functionfunction ((sales_team_id)) {{ self..$(('.js_section_id').).attr(("value",, sales_team_id);); });}); }} });}); ThibaultDelavallée(tde@odoo.com)
  • 16. Link with back-end To contact the back-end: define a new routeroute Route: URL -> action performed by server Defined in Python, in a controller classclass ContactUsShort((http..Controller):): # define my custom controller @http.route@http.route(('/my/route',, ......)) defdef my_route((......):): {http://myodoo.com/}crm/contact_short will be a route creating a lead from data coming from the form · · ThibaultDelavallée(tde@odoo.com)
  • 17. Link with back-end crm/contact_short definition @http.route@http.route([(['/crm/contact_short'],], type=='json')) defdef contactus((self,, question==None,, email==None,, section_id==None,, ****kwargs):): lead_values == {{ 'name':: 'Lead from %s (Contact Snippet)' %% email,, 'description':: question,, 'email_from':: email,, 'section_id':: section_id,, 'user_id':: False,, }} returnreturn request..registry[['crm.lead']]..create((cr,, uid,, lead_values,, context)) ThibaultDelavallée(tde@odoo.com)
  • 18. Dynamic behavior Bind Contact Us to the back-end snippet..animationRegistry..contact == snippet..Animation..extend({({ start:: functionfunction ((editable_mode)) {{ thisthis..$(('.js_contact_btn').).on(('click',, functionfunction ((event)) {{ // perform verification ...... // json call to a route returnreturn openerp..jsonRpc(('/crm/contact_short',, 'call',, {{ 'section_id':: ++section_id,, 'email':: email,, 'question':: question,, }).}).then((functionfunction ((result)) {{ ...... });}); });}); },}, });}); ThibaultDelavallée(tde@odoo.com)
  • 19. And we are done ! Definition: an HTML body in a template Placement: XML declaration Configuration: JS Option Behavior: JS Animation Link: Python controller and routes · · · · · ThibaultDelavallée(tde@odoo.com)
  • 20. Thanks for your attention Any questions ? tde@odoo.com / chm@odoo.com