-
Notifications
You must be signed in to change notification settings - Fork 3.1k
lugva - Technical Training #1240
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
lugva-odoo
wants to merge
2
commits into
odoo:19.0
Choose a base branch
from
odoo-dev:19.0-real-estate-lugva
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
2 commits
Select commit
Hold shift + click to select a range
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,24 @@ | ||
| import { Component, useState } from "@odoo/owl"; | ||
|
|
||
| export class Card extends Component { | ||
| static template = "awesome_owl.card"; | ||
|
|
||
| static props = { | ||
| title: {type: String}, | ||
| slots: { | ||
| type: Object, | ||
| shape: { | ||
| default: true | ||
| }, | ||
| } | ||
| }; | ||
|
|
||
| setup() { | ||
| this.state = useState({open: true}); | ||
| this.toggleOpen = this.toggleOpen.bind(this); | ||
| } | ||
|
|
||
| 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,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 t-on-click="() => toggleOpen()">Toggle</button> | ||
| </h5> | ||
| <t t-slot="default" t-if="state.open"/> | ||
| </div> | ||
| </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,20 @@ | ||
| import { Component, xml, 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: 1}); | ||
| } | ||
|
|
||
| increment() { | ||
| this.state.value++; | ||
| if (this.props.onChange) { | ||
| this.props.onChange(); | ||
| } | ||
| } | ||
| } | ||
|
|
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> | ||
| <p>Counter: <t t-esc="state.value"/></p> | ||
| <button 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,18 @@ | ||
| import { Component } from "@odoo/owl"; | ||
| import { Component, markup, useState } from "@odoo/owl"; | ||
| import { Card } from "./card/card" | ||
| import { Counter } from "./counter/counter" | ||
| import { TodoList } from "./todo/todo_list"; | ||
|
|
||
| export class Playground extends Component { | ||
| static template = "awesome_owl.playground"; | ||
| static components = { Card, Counter, TodoList }; | ||
|
|
||
| setup() { | ||
| this.state = useState({value: 2}); | ||
| this.onChange = this.onChange.bind(this); | ||
| } | ||
|
|
||
| onChange() { | ||
| 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 |
|---|---|---|
| @@ -1,10 +1,18 @@ | ||
| <?xml version="1.0" encoding="UTF-8" ?> | ||
| <templates xml:space="preserve"> | ||
|
|
||
| <t t-name="awesome_owl.playground"> | ||
| <div class="p-3"> | ||
| hello world | ||
| <p>hello world</p> | ||
| <p>The sum is <t t-esc="state.value" /></p> | ||
| </div> | ||
| <div> | ||
| <Card title="'Card 1'"> | ||
| <Counter onChange="onChange"/> | ||
| </Card> | ||
| <Card title="'Card 2'"> | ||
| <Counter onChange="onChange"/> | ||
| </Card> | ||
| </div> | ||
| <div><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,28 @@ | ||
| import { Component, xml, useState } from "@odoo/owl"; | ||
|
|
||
| export class TodoItem extends Component { | ||
| static template = "awesome_owl.todo_item"; | ||
| static props = { | ||
| item: {type: Object, shape: { | ||
| id: {type: Number}, | ||
| description: {type: String}, | ||
| isCompleted: {type: Boolean, optional: true} | ||
| }}, | ||
| toggleState: {type: Function}, | ||
| removeTodo: {type: Function}, | ||
| }; | ||
|
|
||
| setup() { | ||
| this.markCompleted = this.markCompleted.bind(this); | ||
| this.deleteTask = this.deleteTask.bind(this); | ||
| } | ||
|
|
||
| markCompleted() { | ||
| this.props.toggleState(this.props.item.id); | ||
| } | ||
|
|
||
| deleteTask() { | ||
| this.props.removeTodo(this.props.item.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,15 @@ | ||
| <?xml version="1.0" encoding="UTF-8" ?> | ||
| <templates xml:space="preserve"> | ||
| <t t-name="awesome_owl.todo_item"> | ||
| <div class="d-flex flex-row align-items-center gap-2"> | ||
| <input type="checkbox" class="m-0 p-0" t-on-change="() => markCompleted()"/> | ||
| <p | ||
| class="m-0" | ||
| t-att-class="{'text-muted': props.item.isCompleted, 'text-decoration-line-through': props.item.isCompleted}" | ||
| > | ||
| <t t-esc="props.item.id"/>. <t t-esc="props.item.description"/> | ||
| </p> | ||
| <span class="fa fa-remove" t-on-click="() => deleteTask()"/> | ||
| </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,47 @@ | ||
| import {Component, onMounted, toRaw, useRef, useState} from "@odoo/owl"; | ||
| import { TodoItem } from "./todo_item"; | ||
| import { useAutoFocus } from "../utils"; | ||
|
|
||
| export class TodoList extends Component { | ||
| static template = "awesome_owl.todo_list"; | ||
| static components = { TodoItem }; | ||
| numOfItems = 1; | ||
|
|
||
| setup() { | ||
| this.todos = useState([]); | ||
| this.state = useState({description: ""}); | ||
|
|
||
| this.addItem = this.addItem.bind(this); | ||
| this.toggleState = this.toggleState.bind(this); | ||
| this.removeTodo = this.removeTodo.bind(this); | ||
|
|
||
| useAutoFocus("input"); | ||
| } | ||
|
|
||
| addItem(ev) { | ||
| if (ev.keyCode === 13 && ev.target.value != "") { | ||
| this.todos.push( | ||
| { | ||
| id: this.numOfItems++, | ||
| description: ev.target.value, | ||
| isCompleted: false, | ||
| } | ||
| ); | ||
| ev.target.value = ""; | ||
| } | ||
| } | ||
|
|
||
| toggleState(id) { | ||
| const index = this.todos.findIndex((todo) => todo.id === id); | ||
| if (index >= 0) { | ||
| this.todos[index].isCompleted = !this.todos[index].isCompleted; | ||
| } | ||
| } | ||
|
|
||
| removeTodo(id) { | ||
| const index = this.todos.findIndex((todo) => todo.id === id); | ||
| if (index >= 0) { | ||
| this.todos.splice(index, 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,23 @@ | ||
| <?xml version="1.0" encoding="UTF-8" ?> | ||
| <templates xml:space="preserve"> | ||
| <t t-name="awesome_owl.todo_list"> | ||
| <div class="p-1"> | ||
| <input | ||
| name="description" | ||
| placeholder="Enter a new task" | ||
| t-model="state.description" | ||
| t-on-keydown="(ev) => addItem(ev)" | ||
| t-ref="input" | ||
| /> | ||
| <ul class="d-flex flex-column"> | ||
| <li t-foreach="todos" t-as="todoItem" t-key="todoItem.id"> | ||
| <TodoItem | ||
| item="todoItem" | ||
| toggleState="toggleState" | ||
| removeTodo="removeTodo" | ||
| /> | ||
| </li> | ||
| </ul> | ||
| </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,8 @@ | ||
| import { onMounted, useRef } from "@odoo/owl" | ||
|
|
||
| export function useAutoFocus(focusItem) { | ||
| const ref = useRef(focusItem); | ||
| onMounted(() => { | ||
| ref.el.focus() | ||
| }) | ||
| } |
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,28 @@ | ||
| { | ||
| 'name': 'Real Estate', | ||
| 'depends': [ | ||
| 'base', | ||
| ], | ||
| 'application': True, | ||
| 'installable': True, | ||
| 'author': 'Odoo S.A.', | ||
| 'data': [ | ||
| 'security/ir.model.access.csv', | ||
| 'views/estate_property_view_kanban.xml', | ||
| 'views/estate_property_views.xml', | ||
| 'views/estate_property_view_list.xml', | ||
| 'views/estate_property_type_views.xml', | ||
| 'views/estate_property_tag_views.xml', | ||
| 'views/estate_property_tag_view_list.xml', | ||
| 'views/estate_menus.xml', | ||
| 'views/estate_property_view_form.xml', | ||
| 'views/estate_property_view_search.xml', | ||
| 'views/estate_property_type_view_form.xml', | ||
| 'views/estate_property_type_view_list.xml', | ||
| 'views/estate_property_tag_view_form.xml', | ||
| 'views/estate_property_offer_view_list.xml', | ||
| 'views/estate_property_offer_view_form.xml', | ||
| 'views/estate_res_users_view_form.xml', | ||
| ], | ||
| 'license': 'LGPL-3', | ||
| } | ||
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,5 @@ | ||
| from . import estate_property | ||
| from . import estate_property_type | ||
| from . import estate_property_tag | ||
| from . import estate_property_offer | ||
| from . import estate_inherited_user |
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 @@ | ||
| from odoo import fields, models | ||
|
|
||
|
|
||
| class User(models.Model): | ||
| _inherit = "res.users" | ||
|
|
||
| property_ids = fields.One2many( | ||
| "estate.property", | ||
| "salesperson_id", | ||
| string="Related Property", | ||
| domain=["|", ("state", "=", "new"), ("state", "=", "received")], | ||
| ) |
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.
Uh oh!
There was an error while loading. Please reload this page.