Skip to content

Commit b16e643

Browse files
ged-odoofdardenne
authored andcommittedOct 24, 2024·
[ADD] Discover the JavaScript framework
1 parent 6326255 commit b16e643

29 files changed

+355
-6
lines changed
 

‎README.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
# Odoo tutorials
22

33
This repository hosts the code for the bases and solutions of the
4-
[official Odoo tutorials](https://www.odoo.com/documentation/16.0/developer/howtos.html).
4+
[official Odoo tutorials](https://www.odoo.com/documentation/17.0/developer/tutorials.html).
55

6-
It has 2 branches for each Odoo version: one for the bases and one for
7-
the solutions. For example, `16.0` and `16.0-solutions`. The first
8-
contains the code of the modules that serve as base for the tutorials,
9-
and the second contains the code of the same modules with the complete
10-
solution.
6+
It has 3 branches for each Odoo version: one for the bases, one for
7+
[Discover the JS framework](https://www.odoo.com/documentation/17.0/developer/tutorials/discover_js_framework.html) solutions and one for [Master the Odoo web framework](https://www.odoo.com/documentation/17.0/developer/tutorials/master_odoo_web_framework.html) solutions. For example, `17.0`, `17.0-discover-js-framework-solutions` and `17.0-master-odoo-web-framework-solutions`.
8+
The first contains the code of the modules that serve as base for the tutorials,
9+
and the others contains the code of each chapter with the complete
10+
solution.

‎awesome_clicker/__init__.py

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# -*- coding: utf-8 -*-

‎awesome_clicker/__manifest__.py

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# -*- coding: utf-8 -*-
2+
{
3+
'name': "Awesome Clicker",
4+
5+
'summary': """
6+
Starting module for "Master the Odoo web framework, chapter 1: Build a Clicker game"
7+
""",
8+
9+
'description': """
10+
Starting module for "Master the Odoo web framework, chapter 1: Build a Clicker game"
11+
""",
12+
13+
'author': "Odoo",
14+
'website': "https://www.odoo.com/",
15+
'category': 'Tutorials/AwesomeClicker',
16+
'version': '0.1',
17+
'application': True,
18+
'installable': True,
19+
'depends': ['base', 'web'],
20+
21+
'data': [],
22+
'assets': {
23+
'web.assets_backend': [
24+
'awesome_clicker/static/src/**/*',
25+
],
26+
27+
},
28+
'license': 'AGPL-3'
29+
}

‎awesome_dashboard/__init__.py

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# -*- coding: utf-8 -*-
2+
3+
from . import controllers

‎awesome_dashboard/__manifest__.py

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# -*- coding: utf-8 -*-
2+
{
3+
'name': "Awesome Dashboard",
4+
5+
'summary': """
6+
Starting module for "Discover the JS framework, chapter 2: Build a dashboard"
7+
""",
8+
9+
'description': """
10+
Starting module for "Discover the JS framework, chapter 2: Build a dashboard"
11+
""",
12+
13+
'author': "Odoo",
14+
'website': "https://www.odoo.com/",
15+
'category': 'Tutorials/AwesomeDashboard',
16+
'version': '0.1',
17+
'application': True,
18+
'installable': True,
19+
'depends': ['base', 'web', 'mail', 'crm'],
20+
21+
'data': [
22+
'views/views.xml',
23+
],
24+
'assets': {
25+
'web.assets_backend': [
26+
'awesome_dashboard/static/src/**/*',
27+
],
28+
},
29+
'license': 'AGPL-3'
30+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# -*- coding: utf-8 -*-
2+
3+
from . import controllers
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# -*- coding: utf-8 -*-
2+
3+
import logging
4+
import random
5+
6+
from odoo import http
7+
from odoo.http import request
8+
9+
logger = logging.getLogger(__name__)
10+
11+
class AwesomeDashboard(http.Controller):
12+
@http.route('/awesome_dashboard/statistics', type='json', auth='user')
13+
def get_statistics(self):
14+
"""
15+
Returns a dict of statistics about the orders:
16+
'average_quantity': the average number of t-shirts by order
17+
'average_time': the average time (in hours) elapsed between the
18+
moment an order is created, and the moment is it sent
19+
'nb_cancelled_orders': the number of cancelled orders, this month
20+
'nb_new_orders': the number of new orders, this month
21+
'total_amount': the total amount of orders, this month
22+
"""
23+
24+
return {
25+
'average_quantity': random.randint(4, 12),
26+
'average_time': random.randint(4, 123),
27+
'nb_cancelled_orders': random.randint(0, 50),
28+
'nb_new_orders': random.randint(10, 200),
29+
'orders_by_size': {
30+
'm': random.randint(0, 150),
31+
's': random.randint(0, 150),
32+
'xl': random.randint(0, 150),
33+
},
34+
'total_amount': random.randint(100, 1000)
35+
}
36+
+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/** @odoo-module **/
2+
3+
import { Component } from "@odoo/owl";
4+
import { registry } from "@web/core/registry";
5+
6+
class AwesomeDashboard extends Component {
7+
static template = "awesome_dashboard.AwesomeDashboard";
8+
}
9+
10+
registry.category("actions").add("awesome_dashboard.dashboard", AwesomeDashboard);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
<templates xml:space="preserve">
3+
4+
<t t-name="awesome_dashboard.AwesomeDashboard">
5+
hello dashboard
6+
</t>
7+
8+
</templates>

‎awesome_dashboard/views/views.xml

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<odoo>
2+
<data>
3+
<record model="ir.actions.client" id="dashboard">
4+
<field name="name">Dashboard</field>
5+
<field name="tag">awesome_dashboard.dashboard</field>
6+
</record>
7+
8+
<menuitem name="Awesome Dashboard" id="awesome_dashboard.menu_root" groups="base.group_user" web_icon="awesome_dashboard,static/description/icon.png"/>
9+
<menuitem name="Dashboard" id="awesome_dashboard.dashboard_menu" parent="awesome_dashboard.menu_root" action="awesome_dashboard.dashboard" sequence="1"/>
10+
</data>
11+
</odoo>

‎awesome_gallery/__init__.py

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# -*- coding: utf-8 -*-
2+
from . import models

‎awesome_gallery/__manifest__.py

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# -*- coding: utf-8 -*-
2+
{
3+
'name': "Gallery View",
4+
'summary': """
5+
Starting module for "Master the Odoo web framework, chapter 3: Create a Gallery View"
6+
""",
7+
8+
'description': """
9+
Starting module for "Master the Odoo web framework, chapter 3: Create a Gallery View"
10+
""",
11+
12+
'version': '0.1',
13+
'application': True,
14+
'category': 'Tutorials/AwesomeGallery',
15+
'installable': True,
16+
'depends': ['web', 'contacts'],
17+
'data': [
18+
'views/views.xml',
19+
],
20+
'assets': {
21+
'web.assets_backend': [
22+
'awesome_gallery/static/src/**/*',
23+
],
24+
},
25+
'license': 'AGPL-3'
26+
}

‎awesome_gallery/models/__init__.py

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# -*- coding: utf-8 -*-
2+
# import filename_python_file_within_folder_or_subfolder
3+
from . import ir_action
4+
from . import ir_ui_view

‎awesome_gallery/models/ir_action.py

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# -*- coding: utf-8 -*-
2+
from odoo import fields, models
3+
4+
5+
class ActWindowView(models.Model):
6+
_inherit = 'ir.actions.act_window.view'
7+
8+
view_mode = fields.Selection(selection_add=[
9+
('gallery', "Awesome Gallery")
10+
], ondelete={'gallery': 'cascade'})

‎awesome_gallery/models/ir_ui_view.py

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# -*- coding: utf-8 -*-
2+
from odoo import fields, models
3+
4+
5+
class View(models.Model):
6+
_inherit = 'ir.ui.view'
7+
8+
type = fields.Selection(selection_add=[('gallery', "Awesome Gallery")])
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/** @odoo-module */
2+
3+
// TODO: Begin here!

‎awesome_gallery/views/views.xml

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<odoo>
3+
<data>
4+
<record id="contacts.action_contacts" model="ir.actions.act_window">
5+
<field name="name">Contacts</field>
6+
<field name="res_model">res.partner</field>
7+
<field name="view_mode">kanban,tree,form,activity</field>
8+
<field name="search_view_id" ref="base.view_res_partner_filter"/>
9+
<field name="context">{'default_is_company': True}</field>
10+
<field name="help" type="html">
11+
<p class="o_view_nocontent_smiling_face">
12+
Create a Contact in your address book
13+
</p><p>
14+
Odoo helps you track all activities related to your contacts.
15+
</p>
16+
</field>
17+
</record>
18+
</data>
19+
</odoo>

‎awesome_kanban/__init__.py

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# -*- coding: utf-8 -*-

‎awesome_kanban/__manifest__.py

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# -*- coding: utf-8 -*-
2+
{
3+
'name': "Awesome Kanban",
4+
'summary': """
5+
Starting module for "Master the Odoo web framework, chapter 4: Customize a kanban view"
6+
""",
7+
8+
'description': """
9+
Starting module for "Master the Odoo web framework, chapter 4: Customize a kanban view.
10+
""",
11+
12+
'version': '0.1',
13+
'application': True,
14+
'category': 'Tutorials/AwesomeKanban',
15+
'installable': True,
16+
'depends': ['web', 'crm'],
17+
'data': [
18+
'views/views.xml',
19+
],
20+
'assets': {
21+
'web.assets_backend': [
22+
'awesome_kanban/static/src/**/*',
23+
],
24+
},
25+
'license': 'AGPL-3'
26+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/** @odoo-module */
2+
3+
// TODO: Define here your AwesomeKanban view

‎awesome_kanban/views/views.xml

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<odoo>
3+
<data>
4+
<record id="crm_lead_kanban_inherited" model="ir.ui.view">
5+
<field name="name">crm.lead.kanban.lead.awesome_gallery</field>
6+
<field name="model">crm.lead</field>
7+
<field name="inherit_id" ref="crm.crm_case_kanban_view_leads"/>
8+
<field name="arch" type="xml">
9+
<xpath expr="//kanban" position="attributes">
10+
<attribute name="js_class">awesome_kanban</attribute>
11+
</xpath>
12+
</field>
13+
</record>
14+
</data>
15+
</odoo>

‎awesome_owl/__init__.py

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# -*- coding: utf-8 -*-
2+
3+
from . import controllers

‎awesome_owl/__manifest__.py

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# -*- coding: utf-8 -*-
2+
{
3+
'name': "Awesome Owl",
4+
5+
'summary': """
6+
Starting module for "Discover the JS framework, chapter 1: Owl components"
7+
""",
8+
9+
'description': """
10+
Starting module for "Discover the JS framework, chapter 1: Owl components"
11+
""",
12+
13+
'author': "Odoo",
14+
'website': "https://www.odoo.com",
15+
16+
# Categories can be used to filter modules in modules listing
17+
# Check https://github.com/odoo/odoo/blob/15.0/odoo/addons/base/data/ir_module_category_data.xml
18+
# for the full list
19+
'category': 'Tutorials/AwesomeOwl',
20+
'version': '0.1',
21+
22+
# any module necessary for this one to work correctly
23+
'depends': ['base', 'web'],
24+
'application': True,
25+
'installable': True,
26+
'data': [
27+
'views/templates.xml',
28+
],
29+
'assets': {
30+
'awesome_owl.assets_playground': [
31+
('include', 'web._assets_helpers'),
32+
'web/static/src/scss/pre_variables.scss',
33+
'web/static/lib/bootstrap/scss/_variables.scss',
34+
'web/static/lib/bootstrap/scss/_maps.scss',
35+
('include', 'web._assets_bootstrap'),
36+
('include', 'web._assets_core'),
37+
'web/static/src/libs/fontawesome/css/font-awesome.css',
38+
'awesome_owl/static/src/**/*',
39+
],
40+
},
41+
'license': 'AGPL-3'
42+
}

‎awesome_owl/controllers/__init__.py

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# -*- coding: utf-8 -*-
2+
3+
from . import controllers
+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
from odoo import http
2+
from odoo.http import request, route
3+
4+
class OwlPlayground(http.Controller):
5+
@http.route(['/awesome_owl'], type='http', auth='public')
6+
def show_playground(self):
7+
"""
8+
Renders the owl playground page
9+
"""
10+
return request.render('awesome_owl.playground')

‎awesome_owl/static/src/main.js

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { whenReady } from "@odoo/owl";
2+
import { mountComponent } from "@web/env";
3+
import { Playground } from "./playground";
4+
5+
const config = {
6+
dev: true,
7+
name: "Owl Tutorial",
8+
};
9+
10+
// Mount the Playground component when the document.body is ready
11+
whenReady(() => mountComponent(Playground, document.body, config));

‎awesome_owl/static/src/playground.js

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/** @odoo-module **/
2+
3+
import { Component } from "@odoo/owl";
4+
5+
export class Playground extends Component {
6+
static template = "awesome_owl.playground";
7+
}

‎awesome_owl/static/src/playground.xml

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
<templates xml:space="preserve">
3+
4+
<t t-name="awesome_owl.playground">
5+
<div class="p-3">
6+
hello world
7+
</div>
8+
</t>
9+
10+
</templates>

‎awesome_owl/views/templates.xml

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<odoo>
2+
<data>
3+
<template id="awesome_owl.playground" name="Awesome T-Shirt thank you">
4+
<html>
5+
<head>
6+
<link type="image/x-icon" rel="shortcut icon" href="/web/static/img/favicon.ico"/>
7+
<t t-call-assets="awesome_owl.assets_playground"/>
8+
</head>
9+
10+
<body>
11+
</body>
12+
</html>
13+
</template>
14+
</data>
15+
</odoo>

0 commit comments

Comments
 (0)
Please sign in to comment.