-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
romc - Technical Training #208
Open
romaincarlier4
wants to merge
25
commits into
odoo:18.0
Choose a base branch
from
odoo-dev:18.0-training-romc
base: 18.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 20 commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
d98b856
[ADD] estate: start new module for training
romaincarlier4 6123ef7
[IMP] add fields for real estate table
romaincarlier4 7d89dad
[IMP] estate: add security access rules
romaincarlier4 42bf41b
[IMP] estate: add views and menu
romaincarlier4 973bf38
[IMP] estate: add list, form and search views
romaincarlier4 720e52a
[IMP] estate: relations between models
romaincarlier4 eb9b85a
[IMP] estate: add compute and onchange fields
romaincarlier4 66a5c8d
[IMP] estate: add sold/cancel and accept/refuse buttons
romaincarlier4 2120538
[FIX] estate: fix bug for accepting offers
romaincarlier4 99ca07a
[IMP] estate: coding guidelines improvements
romaincarlier4 4f294be
[IMP] estate: add SQL and python constraints
romaincarlier4 b0417e3
[IMP] estate: add the sprinkles ✨
romaincarlier4 63f631c
[IMP] estate: add inheritance
romaincarlier4 9c873c0
[IMP] estate: refactor code
romaincarlier4 d6db194
[IMP] estate: link sold properties to invoices
romaincarlier4 c745b80
[IMP] estate: add kanban view
romaincarlier4 b22d5d9
[FIX] estate: fix kanban warning
romaincarlier4 977f427
[IMP] estate: refactor code
romaincarlier4 dbcf657
[ADD] awesome owl: chapter 1
romaincarlier4 f1c5751
[IMP] estate: add tests
romaincarlier4 6704364
[ADD] awesome dashboard: chapter 2
romaincarlier4 2e5e8f1
[IMP] awesome owl: refactor code
romaincarlier4 ccfc291
[IMP] estate: follow coding guidelines
romaincarlier4 e34aacb
[IMP] estate: add demo data
romaincarlier4 488345e
[FIX] estate: fix demo data
romaincarlier4 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 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,19 @@ | ||
/** @odoo-module **/ | ||
|
||
import { Component, useState } from "@odoo/owl"; | ||
|
||
export class Card extends Component { | ||
static template = "awesome_owl.Card"; | ||
static props = { | ||
title: { type: String }, | ||
slots: { type: Object } | ||
}; | ||
|
||
setup() { | ||
this.state = useState({ hidden: false }); | ||
} | ||
|
||
toggle() { | ||
this.state.hidden = !this.state.hidden; | ||
} | ||
} |
This file contains 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,14 @@ | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
<templates xml:space="preserve"> | ||
<t t-name="awesome_owl.Card"> | ||
<div class="card d-inline-block m-2" style="width: 18rem;"> | ||
<div class="card-body"> | ||
<h5 class="card-title"> | ||
<t t-esc="props.title"/> | ||
<button class="btn btn-primary" t-on-click="toggle">Toggle</button> | ||
</h5> | ||
<t t-slot="default" t-if="!state.hidden"/> | ||
</div> | ||
</div> | ||
</t> | ||
</templates> |
This file contains 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,23 @@ | ||
/** @odoo-module **/ | ||
|
||
import { Component, useState } from "@odoo/owl"; | ||
|
||
export class Counter extends Component { | ||
static template = "awesome_owl.Counter"; | ||
static props = { | ||
onChange: { type: Function, optional: true } | ||
}; | ||
|
||
setup() { | ||
this.state = useState({ | ||
value: 0 | ||
}); | ||
}; | ||
|
||
increment() { | ||
this.state.value++; | ||
if (this.props.onChange) { | ||
this.props.onChange(); | ||
} | ||
}; | ||
} |
This file contains 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.Counter"> | ||
<div> | ||
<p>Counter: | ||
<t t-esc="state.value"/> | ||
</p> | ||
<button class="btn btn-primary" t-on-click="increment">Increment</button> | ||
</div> | ||
</t> | ||
</templates> |
This file contains 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,7 +1,23 @@ | ||
/** @odoo-module **/ | ||
|
||
import { Component } from "@odoo/owl"; | ||
import { Component, markup, useState } from "@odoo/owl"; | ||
import { Counter } from "./counter/counter" | ||
import { Card } from "./card/card" | ||
import { TodoList } from "./todolist/todolist"; | ||
|
||
export class Playground extends Component { | ||
static template = "awesome_owl.playground"; | ||
static components = { Counter, Card, TodoList }; | ||
html = "<b>This is bold</b>"; | ||
html_markup = markup("<b>This is bold</b>"); | ||
|
||
setup() { | ||
this.state = useState({ | ||
sum: 0 | ||
}); | ||
}; | ||
|
||
incrementSum() { | ||
this.state.sum++; | ||
} | ||
} |
This file contains 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,27 @@ | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
<templates xml:space="preserve"> | ||
|
||
<t t-name="awesome_owl.playground"> | ||
<div class="p-3"> | ||
hello world | ||
<div style="margin: 20px;"> | ||
<div> | ||
<h1>Counters</h1> | ||
<div style="display: flex;"> | ||
<Counter onChange.bind="incrementSum"/> | ||
<Counter onChange.bind="incrementSum"/> | ||
</div> | ||
<p> The sum is | ||
<t t-esc="state.sum"/> | ||
</p> | ||
</div> | ||
<div> | ||
<h1>Cards</h1> | ||
<Card title="'Embedded counter'"> | ||
<Counter onChange.bind="incrementSum"/> | ||
</Card> | ||
</div> | ||
<div> | ||
<h1>Todo list</h1> | ||
<TodoList/> | ||
</div> | ||
</div> | ||
</t> | ||
|
||
</templates> |
This file contains 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 @@ | ||
/** @odoo-module **/ | ||
|
||
import { Component, useState } from "@odoo/owl"; | ||
|
||
export class TodoItem extends Component { | ||
static template = "awesome_owl.TodoItem"; | ||
static props = { | ||
id: { type: Number }, | ||
description: { type: String }, | ||
isCompleted: { type: Boolean }, | ||
toggleState: { Function }, | ||
removeTodo: { Function } | ||
}; | ||
|
||
toggleState() { | ||
this.props.toggleState(this.props.id); | ||
} | ||
|
||
removeTodo() { | ||
this.props.removeTodo(this.props.id); | ||
} | ||
} |
This file contains 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 t-att-class="{'text-muted text-decoration-line-through': props.isCompleted}"> | ||
<input type="checkbox" t-att-checked="props.isCompleted" t-on-change="toggleState"/> | ||
<t t-esc="props.id"/>. | ||
<t t-esc="props.description"/> | ||
<span class="fa fa-remove" t-on-click="removeTodo" style="margin-left: 5px"/> | ||
</div> | ||
</t> | ||
</templates> |
This file contains 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,50 @@ | ||
/** @odoo-module **/ | ||
|
||
import { Component, useState } from "@odoo/owl"; | ||
import { TodoItem } from "./todoitem"; | ||
import { useAutofocus } from "../utils"; | ||
|
||
export class TodoList extends Component { | ||
static template = "awesome_owl.TodoList"; | ||
static components = { TodoItem } | ||
|
||
setup() { | ||
this.todos = useState([ | ||
{ id: 0, description: "Buy house", isCompleted: true }, | ||
{ id: 1, description: "Buy milk", isCompleted: false }, | ||
{ id: 2, description: "Buy chocolate", isCompleted: true }, | ||
{ id: 3, description: "Clean house", isCompleted: false }, | ||
{ id: 4, description: "Pay bills", isCompleted: false }, | ||
{ id: 5, description: "Call mom", isCompleted: true }, | ||
{ id: 6, description: "Go on holiday", isCompleted: false }, | ||
]); | ||
this.id_counter = this.todos.length; | ||
useAutofocus("todolist_input"); | ||
}; | ||
|
||
addTodo(ev) { | ||
if (ev.keyCode === 13) { | ||
let desc = ev.target.value; | ||
if (desc) { | ||
this.todos.push({ | ||
id: this.id_counter++, | ||
description: desc, | ||
isCompleted: false | ||
}); | ||
ev.target.value = ""; | ||
} | ||
} | ||
}; | ||
|
||
toggleState(id) { | ||
const index = this.todos.findIndex((elem) => elem.id === id); | ||
this.todos[index].isCompleted = !this.todos[index].isCompleted; | ||
} | ||
|
||
removeTodo(id) { | ||
const index = this.todos.findIndex((elem) => elem.id === id); | ||
if (index >= 0) { | ||
this.todos.splice(index, 1); | ||
} | ||
} | ||
} |
This file contains 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.TodoList"> | ||
<input t-ref="todolist_input" placeholder="Enter a new task." t-on-keyup="addTodo"/> | ||
<t t-foreach="this.todos" t-as="i" t-key="i.id"> | ||
<p> | ||
<TodoItem id="i.id" description="i.description" isCompleted="i.isCompleted" toggleState.bind="toggleState" removeTodo.bind="removeTodo"/> | ||
</p> | ||
</t> | ||
</t> | ||
</templates> |
This file contains 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 @@ | ||
import { useRef, useEffect } from "@odoo/owl" | ||
|
||
export function useAutofocus(name) { | ||
let ref = useRef(name); | ||
useEffect( | ||
(el) => el && el.focus(), | ||
() => [ref.el] | ||
) | ||
} |
This file contains 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,15 +1,14 @@ | ||
<odoo> | ||
<data> | ||
<template id="awesome_owl.playground" name="Awesome T-Shirt thank you"> | ||
<template id="awesome_owl.playground" name="Awesome T-Shirt thank you"> | ||
<html> | ||
<head> | ||
<link type="image/x-icon" rel="shortcut icon" href="/web/static/img/favicon.ico"/> | ||
<t t-call-assets="awesome_owl.assets_playground"/> | ||
</head> | ||
|
||
<body> | ||
</body> | ||
</html> | ||
</template> | ||
</template> | ||
</data> | ||
</odoo> |
This file contains 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 @@ | ||
from . import models |
This file contains 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,16 @@ | ||
{ | ||
"name": "Real Estate", | ||
"depends": ["base"], | ||
"application": True, | ||
"installable": True, | ||
"license": "LGPL-3", | ||
"data": [ | ||
"security/ir.model.access.csv", | ||
"views/estate_property_views.xml", | ||
"views/estate_property_type_views.xml", | ||
"views/estate_property_tag_views.xml", | ||
"views/estate_property_offer_views.xml", | ||
"views/res_users_views.xml", | ||
"views/estate_menus.xml", | ||
], | ||
} |
This file contains 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,5 @@ | ||
from . import estate_property | ||
from . import estate_property_type | ||
from . import estate_property_tag | ||
from . import estate_property_offer | ||
from . import res_users |
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.
It is surprising that this props may not exists. The best approach would be to figure out why it is not provided sometime, fix the issue and remove this if check.
If it is inevitable, here is an alternative syntax that you may (or not) want to use
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.
This is what is expected. The counter component can optionnally have a callback prop, but can also very well be a simple counter with no callback needed. I changed with the better '?' syntax.