Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 1 addition & 3 deletions awesome_owl/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
# -*- coding: utf-8 -*-

from . import controllers
from . import controllers
52 changes: 23 additions & 29 deletions awesome_owl/__manifest__.py
Original file line number Diff line number Diff line change
@@ -1,42 +1,36 @@
# -*- coding: utf-8 -*-
{
'name': "Awesome Owl",

'summary': """
"name": "Awesome Owl",

Choose a reason for hiding this comment

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

unnecessary changes.

"summary": """
Starting module for "Discover the JS framework, chapter 1: Owl components"
""",

'description': """
"description": """

Choose a reason for hiding this comment

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

unnecessary changes.

Starting module for "Discover the JS framework, chapter 1: Owl components"
""",

'author': "Odoo",
'website': "https://www.odoo.com",

"author": "Odoo",
"website": "https://www.odoo.com",
Comment on lines +9 to +10

Choose a reason for hiding this comment

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

unnecessary changes.

# Categories can be used to filter modules in modules listing
# Check https://github.com/odoo/odoo/blob/15.0/odoo/addons/base/data/ir_module_category_data.xml
# for the full list
'category': 'Tutorials/AwesomeOwl',
'version': '0.1',

"category": "Tutorials/AwesomeOwl",
"version": "0.1",
# any module necessary for this one to work correctly
'depends': ['base', 'web'],
'application': True,
'installable': True,
'data': [
'views/templates.xml',
"depends": ["base", "web"],
"application": True,
"installable": True,
"data": [
"views/templates.xml",
],
'assets': {
'awesome_owl.assets_playground': [
('include', 'web._assets_helpers'),
'web/static/src/scss/pre_variables.scss',
'web/static/lib/bootstrap/scss/_variables.scss',
'web/static/lib/bootstrap/scss/_maps.scss',
('include', 'web._assets_bootstrap'),
('include', 'web._assets_core'),
'web/static/src/libs/fontawesome/css/font-awesome.css',
'awesome_owl/static/src/**/*',
"assets": {
"awesome_owl.assets_playground": [
("include", "web._assets_helpers"),
"web/static/src/scss/pre_variables.scss",
"web/static/lib/bootstrap/scss/_variables.scss",
"web/static/lib/bootstrap/scss/_maps.scss",
("include", "web._assets_bootstrap"),
("include", "web._assets_core"),
"web/static/src/libs/fontawesome/css/font-awesome.css",
"awesome_owl/static/src/**/*",
],
},
'license': 'AGPL-3'
"license": "AGPL-3",
}
4 changes: 1 addition & 3 deletions awesome_owl/controllers/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
# -*- coding: utf-8 -*-

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

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

setup() {
this.toggle = useState({ value : true });
}

onToggle() {
this.toggle.value = !this.toggle.value;
}
}

Choose a reason for hiding this comment

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

Should be one empty line at the end of the file.

14 changes: 14 additions & 0 deletions awesome_owl/static/src/card/card.xml
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-out="props.title"/></h5>
<button class="btn btn-primary" t-on-click="onToggle" >Toggle</button>
</div>
<t t-if="toggle.value" t-slot="default"/>
</div>
</t>

</templates>
19 changes: 19 additions & 0 deletions awesome_owl/static/src/counter/counter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
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.counter = useState({ value : 0 })
}

increment() {
this.counter.value++;
if (this.props.onChange) {
this.props.onChange();
}
}
}
11 changes: 11 additions & 0 deletions awesome_owl/static/src/counter/counter.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="awesome_owl.Counter">
<div class="m-2 p-2 border d-inline-block">
<span class="me-2">Counter: <t t-esc="counter.value"/></span>
<button class="btn btn-primary" t-on-click="increment" style="background-color: purple; color: white;">Increment</button>
</div>
</t>

</templates>
19 changes: 16 additions & 3 deletions awesome_owl/static/src/playground.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,20 @@
/** @odoo-module **/

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/todo_list";

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

setup() {
this.state = useState( { value:0 } );
this.content1 = "<b>hello content1</b>";
this.content2 = markup("<b>hello content2</b>");
}

incrementSum() {
this.state.value++;
}

}
14 changes: 14 additions & 0 deletions awesome_owl/static/src/playground.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,21 @@
<t t-name="awesome_owl.playground">
<div class="p-3">
hello world
<Counter onChange.bind="incrementSum"/>
<Counter onChange.bind="incrementSum"/>
</div>
<div>
<span>Sum of the two counter: <t t-esc="this.state.value;"/></span>
</div>
<div>
<Card title="'card 1'">
<Counter onChange.bind="incrementSum"/>
</Card>
<Card title="'card 2'">
<Counter onChange.bind="incrementSum"/>
</Card>
</div>
<TodoList/>
</t>

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

export class TodoItem extends Component {
static template = "awesome_owl.TodoItem";
static props = {
todo : { type : Object },
toggleState : { type : Function},
removeTodo : { type : Function}
}

onChange(todoId) {
this.props.toggleState(todoId);
}

onRemove(todoId) {
this.props.removeTodo(todoId);
}
}

Choose a reason for hiding this comment

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

Should be one empty line at the end of the file.

12 changes: 12 additions & 0 deletions awesome_owl/static/src/todo/todo_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_owl.TodoItem">
<div t-att-class="{'text-muted text-decoration-line-through': props.todo.isCompleted}">
<input type="checkbox" name="status" t-att-checked="props.todo.isCompleted" t-on-change="() => this.onChange(props.todo.id)"/>
<t t-esc="props.todo.id"/>. <t t-esc="props.todo.description"/>
<span class="fa fa-remove" t-on-click="() => this.onRemove(props.todo.id)"/>
</div>
</t>

</templates>
33 changes: 33 additions & 0 deletions awesome_owl/static/src/todo/todo_list.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { Component, useState, useRef } from "@odoo/owl";
import { TodoItem } from "./todo_item";
import { useAutofocus } from "../utils"

export class TodoList extends Component {
static template = "awesome_owl.TodoList";
static components = { TodoItem };

setup(){
this.todos = useState([]);
useAutofocus('input');
}

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

inputStatus(todoId) {
const todo = this.todos.find(item => item.id === todoId);
todo.isCompleted = !todo.isCompleted;
}

removeTodo(todoId){
const index = this.todos.findIndex(item => item.id === todoId);
this.todos.splice(index, 1);
}
}

Choose a reason for hiding this comment

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

Should be one empty line at the end of the file.

13 changes: 13 additions & 0 deletions awesome_owl/static/src/todo/todo_list.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="awesome_owl.TodoList">
<div class="d-inline-block border p-2 m-2">
<input placeholder="Add a todo" t-on-keyup="addTodo" t-ref="input" />
<t t-foreach="todos" t-as="todo" t-key="todo.id">
<TodoItem todo="todo" toggleState.bind="inputStatus" removeTodo.bind="removeTodo"/>
</t>
</div>
</t>

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

export function useAutofocus(refName) {
const ref = useRef(refName);
onMounted(() => {
ref.el.focus();
});
}

Choose a reason for hiding this comment

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

Should be one empty line at the end of the file.

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
24 changes: 24 additions & 0 deletions estate/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"name": "Real Estate",
"version": "0.1",
"depends": ["base"],
"author": "Madhav Pancholi",
"category": "Real Estate",
"description": """
Manage properties, rentals, and real estate sales.
""",
"installable": True,
"application": True,
"data": [
"data/auto_reject_offer_cron.xml",
"security/ir.model.access.csv",
"security/demo_group.xml",
"security/salesperson_own_records_rule.xml",
"views/estate_property_view.xml",
"views/estate_property_type_view.xml",
"views/estate_property_tag_view.xml",
"views/estate_menus.xml",
"views/res_users_view.xml",
],
"demo": [],
}
11 changes: 11 additions & 0 deletions estate/data/auto_reject_offer_cron.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="ir_cron_auto_reject_offer" model="ir.cron">
<field name="name">Offers: Reject Offer Once validity expires</field>
<field name="interval_number">1</field>
<field name="interval_type">days</field>
<field name="model_id" ref="model_estate_property_offer"/>
<field name="code">model._auto_reject_offer()</field>
<field name="state">code</field>
</record>
</odoo>

Choose a reason for hiding this comment

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

Should be one empty line at the end of the file.

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 res_users
Loading