Skip to content

18.0 server tutorial frva #737

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
wants to merge 22 commits into
base: 18.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
c12884e
[IMP] estate: End of chapter 4 commit
frva-odoo Apr 22, 2025
d7696ab
[IMP] estate: End of Chapter 5
frva-odoo Apr 22, 2025
8c00a6e
[IMP] estate: End of chapter 6
frva-odoo Apr 23, 2025
4c39311
[FIX] estate: Clean code and correction of reported issues
frva-odoo Apr 23, 2025
6f18a4b
[IMP] estate: End of chapter 7
frva-odoo Apr 23, 2025
438818c
[IMP] estate: End of day 2
frva-odoo Apr 23, 2025
dbbf98e
[IMP] estate: End of chapter 8
frva-odoo Apr 24, 2025
d1cf2bc
[IMP] estate: End of chapter 9
frva-odoo Apr 24, 2025
ecd1179
[IMP] estate: End of chapter 11
frva-odoo Apr 25, 2025
d9ff057
[IMP] estate: End of chapter 12
frva-odoo Apr 25, 2025
10d9c53
[ADD] estate_account: end of tutorial chapter 13
frva-odoo Apr 28, 2025
0475bd5
[IMP] estate: End of tutorial chapter 14
frva-odoo Apr 28, 2025
dda9737
[FIX] estate,estate_account: Correction of issues
frva-odoo Apr 28, 2025
4f9e253
[IMP] awesome_owl: component, subcomponent and props
frva-odoo Apr 29, 2025
89d84e7
[IMP] awesome_owl: markup, props validation and callback prop
frva-odoo Apr 30, 2025
7dd734d
[IMP] awesome_owl: todo, dynamic attributes and adding todos
frva-odoo Apr 30, 2025
5c6eb35
[IMP] awesome_owl: focusing input, togglin and deleting todos
frva-odoo May 2, 2025
3f63141
[IMP] awesome_owl: generic cards and minimizing
frva-odoo May 2, 2025
ea5a464
[IMP] awesome_dashboard: a new layout
frva-odoo May 2, 2025
d48b0ae
[IMP] awesome_dashboard: Add some buttons for quick navigation (2)
frva-odoo May 2, 2025
5a12840
[IMP] awesome_dashboard: Add a dashboard item (3)
frva-odoo May 2, 2025
1b8a7ab
[FIX] awesome_owl, awesome_dashboard, estate_account: correction of r…
frva-odoo May 2, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions awesome_dashboard/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
# -*- coding: utf-8 -*-

from . import controllers
1 change: 0 additions & 1 deletion awesome_dashboard/__manifest__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
{
'name': "Awesome Dashboard",

Expand Down
28 changes: 26 additions & 2 deletions awesome_dashboard/static/src/dashboard.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,34 @@
/** @odoo-module **/

import { Component } from "@odoo/owl";
import { registry } from "@web/core/registry";
import { Layout } from "@web/search/layout";
import { useService } from "@web/core/utils/hooks";
import { DashboardItem } from "./dashboard_item";


class AwesomeDashboard extends Component {
static template = "awesome_dashboard.AwesomeDashboard";
static components = { Layout, DashboardItem };

setup(){
this.myDisplay = {controlPanel: {}};
this.action = useService("action");
}

openCustomersView(){
this.action.doAction("base.action_partner_form");
}

openLeads(){
this.action.doAction({
type: 'ir.actions.act_window',
name: 'All leads',
res_model: 'crm.lead',
views: [
[false, 'list'],
[false, 'form'],
],
});
}
}

registry.category("actions").add("awesome_dashboard.dashboard", AwesomeDashboard);
3 changes: 3 additions & 0 deletions awesome_dashboard/static/src/dashboard.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.o_dashboard{
background-color: rgb(124, 124, 190);
}
19 changes: 18 additions & 1 deletion awesome_dashboard/static/src/dashboard.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,24 @@
<templates xml:space="preserve">

<t t-name="awesome_dashboard.AwesomeDashboard">
hello dashboard
<Layout className="'o_dashboard h-100'" display="myDisplay">
<t t-set-slot="layout-buttons">
<button t-on-click="openCustomersView">Customers</button>
<button t-on-click="openLeads">Leads</button>
</t>
<div class="d-flex flex-wrap">
<DashboardItem>
Some content
</DashboardItem>
<DashboardItem>
Ceci est un item dashboard
</DashboardItem>
<DashboardItem size="2">
Some Content
</DashboardItem>
</div>
</Layout>

</t>

</templates>
24 changes: 24 additions & 0 deletions awesome_dashboard/static/src/dashboard_item.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@

import { Component } from "@odoo/owl";


export class DashboardItem extends Component {
static template = "awesome_dashboard.dashboard_item";
static props = {
slots: Object,
size: {
type: Number,
optional: true
}
};


calculate_width(){
if (this.props.size){
this.width = (18*this.props.size)
}else{
this.width = 18
}
return this.width
}
}
12 changes: 12 additions & 0 deletions awesome_dashboard/static/src/dashboard_item.xml
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="awesome_dashboard.dashboard_item">
<div class="card m-2 border-dark" t-attf-style="width: {{18*props.size}}rem;">
<div class="card-body">
<t t-slot="default"/>
</div>
</div>
</t>

</templates>
20 changes: 20 additions & 0 deletions awesome_owl/static/src/card/card.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { Component, useState } from "@odoo/owl";

export class Card extends Component {
static template = "Card";
static props = {
title: String,
slots: {
type: Object,
optional: true,
}
};

setup(){
this.state = useState({ open: true });
}

changeOpenState(){
this.state.open = this.state.open;
}
}
16 changes: 16 additions & 0 deletions awesome_owl/static/src/card/card.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8" ?>
<templates xml:space="preserve">

<t t-name="Card">
<div class="card d-inline-block m-2" style="width: 18rem;">
<div class="card-body">
<h5>
<t class="card-title" t-esc="props.title"/>
<span class="fa fa-bars" t-on-click="changeOpenState"/>
</h5>
<p><t t-if="state.open" t-slot="default"/></p>
</div>
</div>
</t>

</templates>
17 changes: 17 additions & 0 deletions awesome_owl/static/src/counter/counter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { Component, useState } from "@odoo/owl";

export class Counter extends Component {
static template = "Counter";
static props = {
onChange: {type: Function, optional: true}
}

setup() {
this.state = useState({ value: 0 });
}

increment(){
this.state.value++;
this.props.onChange?.();
}
}
9 changes: 9 additions & 0 deletions awesome_owl/static/src/counter/counter.xml
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="Counter">
Counter: <t t-esc="state.value"/>
<button class="btn btn-primary" t-on-click="increment">Increment</button>
</t>

</templates>
19 changes: 17 additions & 2 deletions awesome_owl/static/src/playground.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,22 @@
/** @odoo-module **/
import { Component, useState, markup } from "@odoo/owl";
import { Counter } from "./counter/counter";
import { Card } from "./card/card";
import { TodoList } from "./todolist/todolist";

import { Component } from "@odoo/owl";

export class Playground extends Component {
static template = "awesome_owl.playground";
static components = { Counter, Card, TodoList };
static props = [];

setup(){
this.state = useState({ title: "string", content: "string" });
this.html_value_1 = "<div>some text 1</div>";
this.html_value_2 = markup("<div>some text 2</div>");
Comment on lines +13 to +15
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you use this anywhere?

this.sum = useState({ value: 4 })
}

incrementSum(){
this.sum.value++;
}
}
10 changes: 9 additions & 1 deletion awesome_owl/static/src/playground.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,15 @@

<t t-name="awesome_owl.playground">
<div class="p-3">
hello world
hello world <Counter onChange.bind="incrementSum"/><Counter onChange.bind="incrementSum"/><Counter onChange.bind="incrementSum"/><br/>
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

newlines are free don't worry 🙃

<Card title="'cool title'">
<Counter onChange.bind="incrementSum"/>
</Card>
<Card title="'boring title'">
Some text egjpojges
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

segjopjge

</Card>
<p>The sum is : <t t-esc="sum.value"/></p>
<p><TodoList/></p>
</div>
</t>

Expand Down
18 changes: 18 additions & 0 deletions awesome_owl/static/src/todolist/todoitem.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { Component } from "@odoo/owl";

export class TodoItem extends Component {
static template = "TodoItem";
static props = ["todo","onDelete"];

setup(){
this.toggleState = this.toggleState.bind(this);
}

toggleState(){
this.props.todo.isCompleted = !this.props.todo.isCompleted;
}

deleteTodo(){
this.props.onDelete(this.props.todo.id);
}
}
13 changes: 13 additions & 0 deletions awesome_owl/static/src/todolist/todoitem.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8" ?>
<templates xml:space="preserve">

<t t-name="TodoItem">
<div t-att-class="{'text-muted text-decoration-line-through':props.todo.isCompleted}">
<input type="checkbox" t-att="{'checked': props.todo.isCompleted}" t-on-change="toggleState"/>
<t t-esc="props.todo.id"/>.
<t t-esc="props.todo.description"/>
<span class="fa fa-remove" t-on-click="deleteTodo" icon="fa-close"/>
</div>
</t>

</templates>
34 changes: 34 additions & 0 deletions awesome_owl/static/src/todolist/todolist.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { Component, useState } from "@odoo/owl";
import { TodoItem } from "./todoitem";
import { UseAutofocus } from "../utils";

export class TodoList extends Component {
static template = "TodoList";
static components = { TodoItem };
static props = [];

setup(){
this.todos = useState([]);
this.nextId = 1;
UseAutofocus("todo_input");
}

addTodo(ev){
if (ev.keyCode == 13 && ev.target.value != ""){
this.todos.push({
id: this.nextId,
description: ev.target.value,
isCompleted: false
});
this.nextId++;
ev.target.value = "";
}
}

removeTodo(todoId){
const todoIdInArray = this.todos.findIndex((todo) => todo.id == todoId);
if (todoIdInArray >= 0) {
this.todos.splice(todoIdInArray, 1);
}
}
}
11 changes: 11 additions & 0 deletions awesome_owl/static/src/todolist/todolist.xml
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="TodoList">
<p><input placeholder="Enter a new task" t-on-keyup="event => this.addTodo(event)" t-ref="todo_input"/></p>
<t t-foreach="todos" t-as="todo" t-key="todo.id">
<TodoItem todo="todo" onDelete.bind="removeTodo"/>
</t>
</t>

</templates>
9 changes: 9 additions & 0 deletions awesome_owl/static/src/utils.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { useRef, onMounted } from "@odoo/owl";


export function UseAutofocus(refString){
const inputRef = useRef(refString);
onMounted(() => {
inputRef.el.focus();
});
}
1 change: 1 addition & 0 deletions estate/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
18 changes: 18 additions & 0 deletions estate/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
'name': 'frva-estate',
'license': 'LGPL-3',
'depends': [
'base'
],
'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/estate_menus.xml',
'views/inherited_users_view.xml'
],
'installable': True,
'application': True
}
5 changes: 5 additions & 0 deletions estate/models/__init__.py
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 inherited_users
Loading