-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Sébastien Laurent commit tutorials Chapter 1 -> 4 #1175
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
Open
selau-odoo
wants to merge
13
commits into
odoo:19.0
Choose a base branch
from
odoo-dev:19.0-tutorials-selau
base: 19.0
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
01338d7
[ADD] module: Estate module. Chapter 1->3
selau-odoo 6bcf6d1
[REF] Adding custom views to estate module
selau-odoo c41b9cd
[REF] Chapter 8 done. Added some compute methods for the estate prope…
selau-odoo 519fdbd
[REF] Adding Sold, cancelled, accept offer and refuse offer buttons
selau-odoo 99f8f4c
[REF] Creating constraints on the attributes
selau-odoo 2a6ac3b
[IMP] Chapter 11: Add sprinkles
selau-odoo b410971
[REF] Chapter 12 Adding a field to the res.users model and adding a t…
selau-odoo 53f5643
[IMP] Creating an invoice when solding an estate
selau-odoo ad54944
[IMP] Adding a kanban view for the estate module
selau-odoo 9e6f6a7
[IMP] Chapter 1: Owl components. 1. -> 10.
selau-odoo c3384ab
[IMP] Finishing the javascript/OWL tutorial
selau-odoo eead2ab
[IMP] Adding the add button to add a task by clicking on the button
selau-odoo 518311e
[IMP] Adding demo datas
selau-odoo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,5 @@ | ||
| **/.vscode/ | ||
|
|
||
| # Byte-compiled / optimized / DLL files | ||
| __pycache__/ | ||
| *.py[cod] | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| repos: | ||
| - repo: https://github.com/astral-sh/ruff-pre-commit | ||
| rev: v0.15.1 | ||
| hooks: | ||
| - id: ruff | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +0,0 @@ | ||
| # -*- coding: utf-8 -*- | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,2 @@ | ||
| # -*- coding: utf-8 -*- | ||
|
|
||
| from . import controllers |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,2 @@ | ||
| # -*- coding: utf-8 -*- | ||
|
|
||
| from . import controllers | ||
| from . import controllers |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1 @@ | ||
| # -*- coding: utf-8 -*- | ||
| from . import models |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,2 @@ | ||
| # -*- coding: utf-8 -*- | ||
| # import filename_python_file_within_folder_or_subfolder | ||
| from . import ir_action | ||
| from . import ir_ui_view | ||
| from . import ir_action, ir_ui_view |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,10 +1,9 @@ | ||
| # -*- coding: utf-8 -*- | ||
| from odoo import fields, models | ||
|
|
||
|
|
||
| class ActWindowView(models.Model): | ||
| _inherit = 'ir.actions.act_window.view' | ||
|
|
||
| view_mode = fields.Selection(selection_add=[ | ||
| ('gallery', "Awesome Gallery") | ||
| ], ondelete={'gallery': 'cascade'}) | ||
| ('gallery', "Awesome Gallery"), | ||
| ], ondelete={'gallery': 'cascade'}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,3 @@ | ||
| # -*- coding: utf-8 -*- | ||
| from odoo import fields, models | ||
|
|
||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +0,0 @@ | ||
| # -*- coding: utf-8 -*- | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,2 @@ | ||
| # -*- coding: utf-8 -*- | ||
|
|
||
| from . import controllers | ||
| from . import controllers |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,2 @@ | ||
| # -*- coding: utf-8 -*- | ||
|
|
||
| from . import controllers | ||
| from . import controllers |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| import { Component, useState } from "@odoo/owl"; | ||
|
|
||
| export class Card extends Component { | ||
| static template = "awesome_owl.Card"; | ||
| static props = { | ||
| title: String, | ||
| slots: Object | ||
| } | ||
|
|
||
| setup() { | ||
| super.setup(); | ||
|
|
||
| this.state = useState({ | ||
| open: true, | ||
| }) | ||
| } | ||
|
|
||
| toggleOpen() { | ||
| this.state.open = !this.state.open; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| <t t-name="awesome_owl.Card"> | ||
| <div class="card d-inline-block m-2" style="width: 18rem;"> | ||
| <div class="card-body"> | ||
| <div class="d-flex justify-content-between align-items-start mb-2"> | ||
| <h5 class="card-title mb-0" style="width: 70%; word-wrap: break-word;"> | ||
| <t t-out="props.title"/> | ||
| </h5> | ||
|
|
||
| <button class="btn btn-primary btn-sm" t-on-click="toggleOpen"> | ||
| <t t-esc="state.open ? 'Close' : 'Open'"/> | ||
| </button> | ||
| </div> | ||
|
|
||
| <div t-if="state.open"> | ||
| <p class="card-text"> | ||
| <t t-slot="default"/> | ||
| </p> | ||
| </div> | ||
| </div> | ||
| </div> | ||
| </t> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| import { Component, useState } from "@odoo/owl"; | ||
|
|
||
| export class Counter extends Component { | ||
| static template = "awesome_owl.Counter"; | ||
| static props = { | ||
| callback: { | ||
| type: Function, | ||
| optional: true, | ||
| } | ||
| } | ||
|
|
||
| setup() { | ||
| super.setup(); | ||
|
|
||
| this.state = useState({ value: 0 }); | ||
| } | ||
|
|
||
| increment() { | ||
| this.state.value++; | ||
|
|
||
| if (this.props.callback) { | ||
| this.props.callback(this.state.value); | ||
| } | ||
| } | ||
|
|
||
|
|
||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| <?xml version="1.0" encoding="UTF-8" ?> | ||
| <templates xml:space="preserve"> | ||
| <t t-name="awesome_owl.Counter"> | ||
| <div class="m-2 p-2 border d-inline-block"> | ||
| <span class="me-2">Counter: <t t-esc="state.value"/></span> | ||
| <button class="btn btn-primary" t-on-click="increment">Increment</button> | ||
| </div> | ||
| </t> | ||
| </templates> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,32 @@ | ||
| import { Component } from "@odoo/owl"; | ||
| import { Component, useState, markup } from "@odoo/owl"; | ||
| import { Counter } from "./counter/counter"; | ||
| import { Card } from "./card/card"; | ||
| import { TodoList } from "./todo_list/todo_list"; | ||
| import { TodoItem } from "./todo_item/todo_item"; | ||
|
|
||
| export class Playground extends Component { | ||
| static template = "awesome_owl.playground"; | ||
| static template = "awesome_owl.Playground"; | ||
| static components = { Counter, Card, TodoList }; | ||
|
|
||
| setup() { | ||
| super.setup(); | ||
|
|
||
| this.state = useState({ | ||
| html: "The sunset dipped below the jagged horizon, painting the sky in bruised purples and burnt oranges. Blablabla" , | ||
| html2: markup("<i>my html content</i>"), | ||
| counter1: 0, | ||
| counter2: 0, | ||
| }); | ||
|
|
||
| this.increment1 = this.increment1.bind(this); | ||
| this.increment2 = this.increment2.bind(this); | ||
| } | ||
|
|
||
| increment1(value) { | ||
| this.state.counter1 = value; | ||
| } | ||
|
|
||
| increment2(value) { | ||
| this.state.counter2 = value | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,10 +1,17 @@ | ||
| <?xml version="1.0" encoding="UTF-8" ?> | ||
| <templates xml:space="preserve"> | ||
|
|
||
| <t t-name="awesome_owl.playground"> | ||
| <div class="p-3"> | ||
| hello world | ||
| <t t-name="awesome_owl.Playground"> | ||
| <div> | ||
| <Counter callback="increment1"/><Counter callback="increment2"/> | ||
| </div> | ||
| This is the sum of the two counters: <t t-esc="state.counter1 + state.counter2"/> | ||
| <div> | ||
| <Card title="state.html"> | ||
| <Counter/> | ||
| </Card> | ||
| </div> | ||
| <div> | ||
| <TodoList/> | ||
| </div> | ||
| </t> | ||
|
|
||
| </templates> | ||
| </templates> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| import { Component } from "@odoo/owl"; | ||
|
|
||
| export class TodoItem extends Component { | ||
| static template = "awesome_owl.TodoItem"; | ||
| static props = { | ||
| id: Number, | ||
| description: String, | ||
| isCompleted: Boolean, | ||
| switchIsCompleted: Function, | ||
| deleteTodo: Function, | ||
| } | ||
|
|
||
| onChange() { | ||
| this.props.switchIsCompleted(this.props.id); | ||
| } | ||
|
|
||
| onDelete() { | ||
| console.log("delete", this.props.id) | ||
| this.props.deleteTodo(this.props.id); | ||
| } | ||
|
|
||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| <?xml version="1.0" encoding="UTF-8" ?> | ||
| <templates xml:space="preserve"> | ||
| <t t-name="awesome_owl.TodoItem"> | ||
| <div> | ||
| <b><input type="checkbox" t-att-checked="props.isCompleted" t-on-change="onChange"/> | ||
| <t t-esc="props.id"/>.</b> | ||
| <t t-esc="props.description"/> | ||
| <span class="fa fa-remove btn" t-on-click="onDelete"/> | ||
| </div> | ||
| </t> | ||
| </templates> |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpick: the last line here cointains a couple of spaces, that's why it does not count as empty line and github still displays the annoying
⛔icon