-
Notifications
You must be signed in to change notification settings - Fork 2.4k
18.0 gato tutorials #657
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
gato-odoo
wants to merge
12
commits into
odoo:18.0
Choose a base branch
from
odoo-dev:18.0-gato-tutorials
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
18.0 gato tutorials #657
Changes from 6 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
426b023
[ADD] realestatinator: Helps you manage real estate properties.
gato-odoo 2aac821
[ADD] estateaccountinator: Helps you manage accouts related to real e…
gato-odoo 7538bd8
[ADD] Counter: a simple counter
gato-odoo 1b00261
[ADD] Card: a basic card component
gato-odoo df99155
[ADD] TodoList and TodoItem: Components to manage a todo list and its…
gato-odoo a10a151
[IMP] Card: modified Card component to use default slot.
gato-odoo bd151e8
[IMP] Card: Modified Card component to make it collapsable
gato-odoo c03fee4
[IMP] dashboard: Added Layout and two action buttons
gato-odoo 2dcfb8f
[IMP] awesome_dashboard: added pie chart.
gato-odoo b80c8df
[IMP] awesome_dashboard: load cards from registry
gato-odoo b43ff98
[FIX] awesome_dashboard: Fixed error on updating pie chart
gato-odoo 7f83284
[FIX] awesome_dashboard: Fixed error on updating pie chart. Again.
gato-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 |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { Component, markup } from '@odoo/owl'; | ||
|
||
export class Card extends Component { | ||
static template = 'card.card'; | ||
static props = { | ||
title: { | ||
type: 'String', | ||
optional: 'true', | ||
}, | ||
ace: { | ||
type: 'Function', | ||
optional: 'true', | ||
}, | ||
slots: { | ||
type: 'Object', | ||
optional: 'true', | ||
}, | ||
}; | ||
|
||
setup() { | ||
this.title = this.props.title ? this.props.title : 'No Title'; | ||
if (this.props.ace) { | ||
this.props.ace(this); | ||
} | ||
} | ||
} |
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,10 @@ | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
<templates xml:space="preserve"> | ||
<t t-name="card.card"> | ||
<div class="card" t-on-click="() => {console.log(this.props)}"> | ||
<h5><t t-out="title"/></h5> | ||
<t t-slot="default"/> | ||
</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 |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { Component, useState } from "@odoo/owl"; | ||
|
||
export class Counter extends Component { | ||
static template = 'counter.counter'; | ||
static props = { | ||
onChange: {type: 'Function', optional: 'true',}, | ||
} | ||
setup() { | ||
this.counter = useState({value: 0}); | ||
} | ||
|
||
increment() { | ||
this.counter.value++; | ||
this.props.onChange('Prout!'); | ||
} | ||
} |
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="counter.counter"> | ||
<div class="p-3" style="display: flex;flex-direction: column;justify-content: center;align-items: center;"> | ||
<p>COUNTER : <t t-esc="counter.value"/></p> | ||
<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,7 +1,21 @@ | ||
/** @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 './todo_list/todo_list'; | ||
|
||
export class Playground extends Component { | ||
static template = "awesome_owl.playground"; | ||
static template = "awesome_owl.playground"; | ||
static components = { Counter, Card, TodoList }; | ||
static props = {}; | ||
|
||
setup() { | ||
this.counter = useState({value: 0}); | ||
} | ||
|
||
|
||
updateTotal(str) { | ||
this.counter.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,57 @@ | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
<templates xml:space="preserve"> | ||
|
||
<t t-name="awesome_owl.playground"> | ||
<div class="p-3"> | ||
hello world | ||
</div> | ||
</t> | ||
<t t-name="awesome_owl.playground"> | ||
<style> | ||
.card { | ||
display: flex; | ||
flex-direction: column; | ||
justify-content: center; | ||
width: 50%; | ||
border-style: none; | ||
border-thickness: 2px; | ||
border-color: black; | ||
border-radius: 25px; | ||
margin: 1em auto; | ||
padding: 2em; | ||
transition: background-color ease-in-out 1s; | ||
} | ||
.card:hover { | ||
background-color: #f2f2f2; | ||
} | ||
.todolist { | ||
display: flex; | ||
flex-direction: column; | ||
justify-content: center; | ||
align-items: center; | ||
padding: 2em; | ||
} | ||
.completed { | ||
background-color: lightgreen; | ||
} | ||
|
||
.notcompleted { | ||
background-color: tomato; | ||
} | ||
</style> | ||
<div class="p-3"> | ||
<Card title="'Really cool title.'"> | ||
<p>I told you it was really cool!</p> | ||
</Card> | ||
<Card /> | ||
<Card title="'Card with cards inside!!!'"> | ||
<Card title="'Card with counters'"> | ||
<Counter onChange.bind="updateTotal"/> | ||
<Counter onChange.bind="updateTotal"/> | ||
<p>Total : <t t-esc="counter.value"/></p> | ||
</Card> | ||
<Card title="'Card with more counters'"> | ||
<Counter onChange.bind="updateTotal"/> | ||
<Counter onChange.bind="updateTotal"/> | ||
</Card> | ||
</Card> | ||
<TodoList /> | ||
</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 |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { Component, useState } from '@odoo/owl'; | ||
|
||
export class TodoItem extends Component { | ||
static template = 'todo_item.todo_item'; | ||
static props = { | ||
id: {type: 'Number',}, | ||
title: {type: 'String', optional: 'true',}, | ||
description: {type: 'String', optional: 'true',}, | ||
isCompleted: {type: 'Boolean', optional: 'true',}, | ||
update: {type: 'Function',}, | ||
remove: {type: 'Function',}, | ||
} | ||
setup() { | ||
this.contents = useState({ | ||
id: this.props.id, | ||
title: this.props.title ? this.props.title : 'No Title.', | ||
description: this.props.description ? this.props.description : 'No Description.', | ||
isCompleted: this.props.isCompleted, | ||
}); | ||
|
||
} | ||
|
||
click() { | ||
this.contents.isCompleted = !this.contents.isCompleted; | ||
this.props.update(this.contents); | ||
} | ||
|
||
rubbish_bin() { | ||
this.props.remove(this.contents); | ||
} | ||
} |
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,12 @@ | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
<templates xml:space="preserve"> | ||
|
||
<t t-name="todo_item.todo_item"> | ||
<div class="card" t-on-click="click" t-att-class="contents.isCompleted ? 'text-muted text-decoration-line-through completed' : 'notcompleted'"> | ||
<h5><t t-esc="contents.title"/></h5> | ||
<p><t t-esc="contents.description"/></p> | ||
<button t-on-click="rubbish_bin">delete</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 |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import { Component, useState, markup } from '@odoo/owl'; | ||
import { TodoItem } from '../todo_item/todo_item' | ||
|
||
export class TodoList extends Component { | ||
static template = 'todo_list.todo_list'; | ||
static props = {}; | ||
static components = {TodoItem}; | ||
|
||
setup() { | ||
this.list = useState({items: []}); | ||
|
||
this.list.items = JSON.parse(window.localStorage.getItem('todo')); | ||
} | ||
|
||
update(item) { | ||
for (let i = 0;i < this.list.items.length;i++) { | ||
if (this.list.items[i].id == item.id) { | ||
this.list.items[i].title = item.title; | ||
this.list.items[i].description = item.description; | ||
this.list.items[i].isCompleted = item.isCompleted; | ||
} | ||
} | ||
|
||
window.localStorage.setItem('todo', JSON.stringify(this.list.items)); | ||
} | ||
|
||
create_task(e) { | ||
if (e.keyCode != 13) return; | ||
let newTask = { | ||
id: 0, | ||
title: document.getElementById('title').value, | ||
description: document.getElementById('description').value, | ||
isCompleted: false, | ||
} | ||
|
||
if (newTask.title == '' || newTask.description == '') return; | ||
|
||
for (let i = 0;i < this.list.items.length;i++) { | ||
if (this.list.items[i].id >= newTask.id) { | ||
newTask.id = this.list.items[i].id; | ||
} | ||
} | ||
newTask.id++; | ||
this.list.items = [...this.list.items, newTask]; | ||
window.localStorage.setItem('todo', JSON.stringify(this.list.items)); | ||
document.getElementById('title').value = ''; | ||
document.getElementById('description').value = ''; | ||
} | ||
|
||
remove(item) { | ||
const index = this.list.items.findIndex((elt) => elt.id == item.id); | ||
if (index >= 0) { | ||
this.list.items.splice(index, 1); | ||
} | ||
|
||
|
||
window.localStorage.setItem('todo', JSON.stringify(this.list.items)); | ||
} | ||
} |
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,17 @@ | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
<templates xml:space="preserve"> | ||
|
||
<t t-name="todo_list.todo_list"> | ||
<div class="todolist"> | ||
<form t-on-keyup="create_task" style="display: flex;flex-direction: column;justify-content: center;align-items: center;margins: 0; padding: 0;"> | ||
<input type="text" name="title" id="title" placeholder="Title"/> | ||
<input type="text" name="description" id="description" placeholder="Description"/> | ||
</form> | ||
<t t-foreach="list.items" t-as="item" t-key="item.id"> | ||
|
||
<TodoItem id="item.id" title="item.title" description="item.description" isCompleted="item.isCompleted" update.bind="update" remove.bind="remove"/> | ||
</t> | ||
</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 |
---|---|---|
@@ -0,0 +1 @@ | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
'name': 'estate-accountinator', | ||
'description': 'Inator that helps you do accounting on real estate', | ||
'category': 'Tutorials/Accountinator', | ||
'author': 'gato', | ||
'depends': [ | ||
'realestatinator', | ||
'account', | ||
], | ||
'installable': True, | ||
'application': True, | ||
'auto_install': False, | ||
'version': '0.1', | ||
} |
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 @@ | ||
from . import estate_property |
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,24 @@ | ||
from odoo import api, Command, fields, models | ||
|
||
|
||
class EstateProperty(models.Model): | ||
_inherit = 'estate.property' | ||
|
||
def mark_sold(self): | ||
for record in self: | ||
line_defs = [ | ||
{ | ||
'name': f'selling price (6% of {record.selling_price})', | ||
'quantity': 1, | ||
'price_unit': 0.06*record.selling_price | ||
}, | ||
{ | ||
'name': 'administrative fees', | ||
'quantity': 1, | ||
'price_unit': 100 | ||
}, | ||
] | ||
lines = [Command.create(line) for line in line_defs] | ||
values = {'partner_id': record.buyer.id, 'move_type': 'out_invoice', 'line_ids': lines} | ||
moves = self.env['account.move'].create(values) | ||
return super().mark_sold() |
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 @@ | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
'name': 'real-estate-inator', | ||
'description': 'Inator that helps you find real estate.', | ||
'category': 'Tutorials/RealEstateInator', | ||
'author': 'gato', | ||
'depends': [ | ||
'base', | ||
'web', | ||
], | ||
'data': [ | ||
'security/ir.model.access.csv', | ||
'views/estate_property_views.xml', | ||
'views/estate_property_type_views.xml', | ||
'views/estate_property_tags_views.xml', | ||
'views/estate_property_offer_views.xml', | ||
'views/estate_menus.xml', | ||
], | ||
'installable': True, | ||
'application': True, | ||
'auto_install': False, | ||
'version': '0.1', | ||
} |
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 @@ | ||
from . import res_users | ||
from . import res_partner | ||
from . import estate_property | ||
from . import estate_property_type | ||
from . import estate_property_tags | ||
from . import estate_property_offer |
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.
alphabetical order