smartbuttons odoo
Transcript of smartbuttons odoo
-
7/21/2019 smartbuttons odoo
1/22
Smart Buttons in v8Gry Debongnie
-
7/21/2019 smartbuttons odoo
2/22
Content
1. What are Smart Buttons?
2. From Regular Buttons to Smart Buttons
3. Magic! (not really)
4. Customizing the Look
5. Customizing the Content
-
7/21/2019 smartbuttons odoo
3/22
What are Smart Buttons?
-
7/21/2019 smartbuttons odoo
4/22
Smart Buttons
-
7/21/2019 smartbuttons odoo
5/22
Smart Buttons (2)
FromFrom
ToTo
http://users/masklinn/projects/tiny/odoodays/smart_buttons/_build/slides/_images/oldstyle.png -
7/21/2019 smartbuttons odoo
6/22
Smart Buttons (3)
Two biggest advantages:
dynamic,
customizable.
-
7/21/2019 smartbuttons odoo
7/22
From Regular to Smartit's not hard
-
7/21/2019 smartbuttons odoo
8/22
Converting a plain button
Before:
After:
http://users/masklinn/projects/tiny/odoodays/smart_buttons/_build/slides/_images/opps_new.pnghttp://users/masklinn/projects/tiny/odoodays/smart_buttons/_build/slides/_images/opps_old.png -
7/21/2019 smartbuttons odoo
9/22
Converting a plain button (2)
Just add 'icon' attribute.
Font awesome:
http://fortawesome.github.io/Font-Awesome/
http://users/masklinn/projects/tiny/odoodays/smart_buttons/_build/slides/_images/opps_icon.pnghttp://fortawesome.github.io/Font-Awesome/ -
7/21/2019 smartbuttons odoo
10/22
Where is the magic?(next slide)
-
7/21/2019 smartbuttons odoo
11/22
Button tag can containanything
Before, the button tag was self-closed:
Now, it can contain literally anything:
literally anything
The form view parse the button and render anything inside(html/Odoo widgets)
-
7/21/2019 smartbuttons odoo
12/22
Example (html)
Pure html : Full control on the content
Hello Odoo
Result:
http://users/masklinn/projects/tiny/odoodays/smart_buttons/_build/slides/_images/helloodoo.png -
7/21/2019 smartbuttons odoo
13/22
Example (html+field)
Opportunities
Result:
This is fully dynamic!
http://users/masklinn/projects/tiny/odoodays/smart_buttons/_build/slides/_images/opphtml.png -
7/21/2019 smartbuttons odoo
14/22
Common situation:One2many fields
Example: phonecall_idsin res.partner.
Step 1: add functional !eld phonecall_countto res.partner
Step 2: add !eld with widget 'statinfo'
http://users/masklinn/projects/tiny/odoodays/smart_buttons/_build/slides/_images/calls.png -
7/21/2019 smartbuttons odoo
15/22
Customize your buttons
We can customize in two ways:
-
7/21/2019 smartbuttons odoo
16/22
Customizing Content
-
7/21/2019 smartbuttons odoo
17/22
Case study: Sum of allinvoices for a customer
1. add functional !eld
'total_invoiced':: fields..function((_invoice_total,,
string=="Total Invoiced",,
type=='float'))
defdef_invoice_total((self,, cr,, uid,, ids,, field_name,, arg,, context==None):):
result =={}{}
account_invoice_report ==self..pool..get(('account.invoice.report')) forforpartner ininself..browse((cr,, uid,, ids,, context==context):):
......
returnreturnresult
-
7/21/2019 smartbuttons odoo
18/22
Case study: Sum of allinvoices for a customer (2)
2. add !eld to button
3. pro!t!
http://users/masklinn/projects/tiny/odoodays/smart_buttons/_build/slides/_images/totalinvoiced.png -
7/21/2019 smartbuttons odoo
19/22
Customizing Look
-
7/21/2019 smartbuttons odoo
20/22
PercentPie Widget
Percentage (integer between 0 and 100)
http://users/masklinn/projects/tiny/odoodays/smart_buttons/_build/slides/_images/percentpie.png -
7/21/2019 smartbuttons odoo
21/22
Bar Chart Widget
Need to display some kind of trends? Use BarChart Widget!
(see mass_mailing.py for full details)
http://users/masklinn/projects/tiny/odoodays/smart_buttons/_build/slides/_images/barchartwidget.png -
7/21/2019 smartbuttons odoo
22/22
Thank you!