-
Notifications
You must be signed in to change notification settings - Fork 2.7k
[ADD] estate: create new module #1016
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
base: 19.0
Are you sure you want to change the base?
Changes from 16 commits
ce05c66
d636571
f586eb5
c17a37d
d0ab7e7
155c627
12b8775
cefa841
315e008
78e37cc
191f8cc
26b7079
06c2487
e06e590
b633817
3aa257c
ae9a44d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,40 @@ | ||
| import { Component } from "@odoo/owl"; | ||
| import { registry } from "@web/core/registry"; | ||
| import { Layout } from "@web/search/layout"; | ||
| import { useService } from "@web/core/utils/hooks"; | ||
|
|
||
| class AwesomeDashboard extends Component { | ||
| static template = "awesome_dashboard.AwesomeDashboard"; | ||
| static components = { Layout } | ||
|
|
||
| setup() { | ||
| this.action = useService("action"); | ||
| } | ||
|
|
||
| openCustomers() { | ||
| this.action.doAction({ | ||
| type: "ir.actions.act_window", | ||
| name: "Customers", | ||
| res_model: "res.partner", | ||
| views: [ | ||
| [false, "kanban"], | ||
| [false, "form"], | ||
| [false, "list"], | ||
| ], | ||
| }); | ||
| } | ||
|
|
||
| openLeads() { | ||
| this.action.doAction({ | ||
| type: "ir.actions.act_window", | ||
| name: "Leads", | ||
| res_model: "crm.lead", | ||
| views: [ | ||
| [false, "list"], | ||
| [false, "form"], | ||
| ], | ||
| }); | ||
| } | ||
| } | ||
|
|
||
| registry.category("actions").add("awesome_dashboard.dashboard", AwesomeDashboard); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| .o_dashboard { | ||
| background-color: gray; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,15 @@ | ||
| <?xml version="1.0" encoding="UTF-8" ?> | ||
| <templates xml:space="preserve"> | ||
|
|
||
| <t t-name="awesome_dashboard.AwesomeDashboard"> | ||
| hello dashboard | ||
| <Layout className="'o_dashboard h-100'" display="{ controlPanel: {} }"> | ||
| <t t-set-slot="control-panel-always-buttons"> | ||
| <button class="btn btn-primary me-2" t-on-click="openCustomers"> | ||
| Customers | ||
| </button> | ||
| <button class="btn btn-primary me-2" t-on-click="openLeads"> | ||
| Leads | ||
| </button> | ||
| </t> | ||
| </Layout> | ||
| </t> | ||
|
|
||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. unnecessary diff. |
||
| </templates> | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| import { Component, useState } from "@odoo/owl"; | ||
|
|
||
|
|
||
| export class Card extends Component { | ||
| static template = "awesome_owl.card"; | ||
| static props = { | ||
| title: String, | ||
| slots: { | ||
| type: Object, | ||
| shape: { | ||
| default: {} | ||
| } | ||
| } | ||
| }; | ||
|
|
||
| setup() { | ||
| this.state = useState({visible: true}) | ||
| } | ||
|
|
||
| toggleContent() { | ||
| this.state.visible = !this.state.visible; | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| <?xml version="1.0" encoding="UTF-8" ?> | ||
| <templates xml:space="preserve"> | ||
| <t t-name="awesome_owl.card"> | ||
| <style> | ||
| .card-main{ | ||
| display: block; | ||
| border: 1px solid #ccc; | ||
| padding: 20px; | ||
| } | ||
| </style> | ||
| <button t-on-click="toggleContent">toggle visibility</button> | ||
| <div class="card-main"> | ||
| <h2 class="card-title" t-esc="props.title"></h2> | ||
| <t t-if="this.state.visible"> | ||
| <div class="card-body"> | ||
| <t t-slot="default"/> | ||
| </div> | ||
|
||
| </t> | ||
| </div> | ||
| </t> | ||
| </templates> | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| import { Component, useState } from "@odoo/owl"; | ||
|
|
||
|
|
||
| export class Counter extends Component { | ||
| static template = "awesome_owl.Counter"; | ||
| static props = { | ||
| onChange: { | ||
| type: Function, | ||
| } | ||
| }; | ||
|
|
||
| setup() { | ||
| this.state = useState({ value: 0 }); | ||
| } | ||
|
|
||
| increment() { | ||
| this.state.value++; | ||
| if (this.props.onChange) { | ||
| this.props.onChange(this.state.value,true); | ||
| } | ||
| } | ||
|
|
||
| decrement() { | ||
| this.state.value--; | ||
| if (this.props.onChange) { | ||
| this.props.onChange(this.state.value,false); | ||
| } | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| <?xml version="1.0" encoding="UTF-8" ?> | ||
| <templates xml:space="preserve"> | ||
| <t t-name="awesome_owl.Counter"> | ||
| <style> | ||
| .primary-counter{ | ||
| background-color: #FFFFE0; | ||
| border: 3px solid #ccc; | ||
| display: inline-block; | ||
| min-width: 300px; | ||
| padding: 20px; | ||
| margin: 20px; | ||
| } | ||
| .increment-button{ | ||
| background: purple; | ||
| color: white; | ||
| padding: 8px; | ||
| border-radius: 5px; | ||
| } | ||
| .decrement-button{ | ||
| background: purple; | ||
| color: white; | ||
| padding: 8px; | ||
| border-radius: 5px; | ||
| margin:5px | ||
| } | ||
| </style> | ||
| <div class="primary-counter"> | ||
| <p>Counter: <t t-esc="state.value"/></p> | ||
| <button class="increment-button" t-on-click="increment"> | ||
| Increment | ||
| </button> | ||
|
||
| <button class="decrement-button" t-on-click="decrement"> | ||
| Decrement | ||
| </button> | ||
| </div> | ||
| </t> | ||
| </templates> | ||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -1,5 +1,26 @@ | ||||||
| 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 props = {}; | ||||||
| static components = { Counter, Card, TodoList }; | ||||||
|
|
||||||
| setup() { | ||||||
| this.state = useState({ | ||||||
| content: markup('<h1>Welcome to dashboard</h1>'), | ||||||
| sum: 0, | ||||||
| }); | ||||||
|
|
||||||
| } | ||||||
|
|
||||||
| totalSum(newVal,Checker){ | ||||||
|
||||||
| totalSum(newVal,Checker){ | |
| totalSum(newVal,Checker) { |
Outdated
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.
| if(Checker) | |
| if (Checker) { |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,10 +1,23 @@ | ||
| <?xml version="1.0" encoding="UTF-8" ?> | ||
| <templates xml:space="preserve"> | ||
|
|
||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. unnecessary diff. |
||
| <t t-name="awesome_owl.playground"> | ||
| <div class="p-3"> | ||
| hello world | ||
| <t t-out="this.state.content"/> | ||
| <Counter onChange.bind="totalSum"/> | ||
| <Counter onChange.bind="totalSum"/> | ||
| <Counter onChange.bind="totalSum"/> | ||
| <div style="background-color: #90EE90; border: 3px solid #ccc; margin: 20px; padding: 20px"> | ||
| <h3>Sum of Counters: <t t-esc="state.sum"/></h3> | ||
| </div> | ||
| <TodoList/> | ||
| <div> | ||
| <Card title="'Card with text'"> | ||
| <p>This is arbitrary card content!</p> | ||
| </Card> | ||
| </div> | ||
| <div> | ||
| <Card title="'Card with a counter'"> | ||
| <Counter onChange.bind="totalSum"/> | ||
| </Card> | ||
| </div> | ||
| </t> | ||
|
|
||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. unnecessary diff. |
||
| </templates> | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| import { Component } from "@odoo/owl"; | ||
|
|
||
|
|
||
| export class TodoItem extends Component { | ||
| static template = "awesome_owl.TodoItem"; | ||
| static props = { | ||
| todo: Object, | ||
| toggleState: Function, | ||
| deleteTodo: Function, | ||
| }; | ||
|
|
||
| onChangeToggle() { | ||
| this.props.toggleState(this.props.todo.id); | ||
| } | ||
|
|
||
| onChangeDelete() { | ||
| this.props.deleteTodo(this.props.todo.id); | ||
| } | ||
| } |
| 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 class="p-1" t-att-class="props.todo.isCompleted ? 'text-decoration-line-through text-muted' : ''"> | ||
| <input class="form-check-input" type="checkbox" t-on-click="onChangeToggle"/> | ||
|
||
| <span t-esc="props.todo.id"/> - | ||
| <span t-esc="props.todo.description"/> | ||
| <span style="margin-left:10px; cursor:pointer;" t-on-click="onChangeDelete">❌</span> | ||
| </div> | ||
| </t> | ||
| </templates> | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| import { Component, useState } from "@odoo/owl"; | ||
| import { TodoItem } from "./todo_item"; | ||
| import { useAutofocus } from './../utils' | ||
|
|
||
|
|
||
| export class TodoList extends Component { | ||
| static template = "awesome_owl.TodoList"; | ||
| static props = {}; | ||
| static components = { TodoItem }; | ||
|
|
||
| setup() { | ||
| this.todos = useState([]) | ||
| useAutofocus('todoInputRef') | ||
| } | ||
|
|
||
| addTodo(ev) { | ||
| if(ev.keyCode == '13') { | ||
| if(ev.target.value != ""){ | ||
| this.todos.push({ | ||
| id: this.todos.length + 1, | ||
| description: ev.target.value, | ||
| isCompleted: false | ||
| }) | ||
| ev.target.value = '' | ||
| } | ||
| } | ||
| } | ||
|
|
||
| toggleState(id) { | ||
| const todo = this.todos.find(todo => todo.id == id) | ||
| todo.isCompleted = !todo.isCompleted | ||
| } | ||
|
|
||
| deleteTodo(id) { | ||
| const index = this.todos.findIndex(todo => todo.id === id) | ||
| if (index >= 0){ | ||
| this.todos.splice(index, 1) | ||
| } | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <templates xml:space="preserve"> | ||
| <t t-name="awesome_owl.TodoList"> | ||
| <style> | ||
| .todo-list-primary{ | ||
| background-color: #ADD8E6; | ||
| border: 3px solid #ccc; | ||
| display: inline-block; | ||
| min-width: 300px; | ||
| padding: 20px; | ||
| margin: 20px; | ||
| } | ||
| .todo-item-arrangement{ | ||
| padding: 20px; | ||
| margin: 20px; | ||
| } | ||
| </style> | ||
| <div class="todo-list-primary"> | ||
| <h3>Todo List</h3> | ||
| <input type="text" t-ref="todoInputRef" placeholder="Enter a new task" t-on-keyup="addTodo" class="form-control mb-2"/> | ||
| <div t-foreach="todos" t-as="todo" t-key="todo.id" class="todo-item-arrangement"> | ||
| <TodoItem todo="todo" toggleState.bind="toggleState" deleteTodo.bind="deleteTodo"/> | ||
| </div> | ||
| </div> | ||
| </t> | ||
| </templates> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| import { useRef, onMounted } from "@odoo/owl"; | ||
|
|
||
|
|
||
| export function useAutofocus(refName) { | ||
| const ref = useRef(refName); | ||
|
|
||
| onMounted(() => { | ||
| if (ref.el) { | ||
| ref.el.focus(); | ||
| } | ||
| }); | ||
| return ref; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| from . import models |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| { | ||
| 'author': 'Odoo S.A.', | ||
| 'name': 'Estate', | ||
| 'depends': ['base'], | ||
| 'license': 'LGPL-3', | ||
| 'data': [ | ||
| 'security/ir.model.access.csv', | ||
| 'data/service_cron.xml', | ||
| 'views/estate_property_views.xml', | ||
| 'views/estate_property_offer_views.xml', | ||
| 'views/estate_property_type_views.xml', | ||
| 'views/estate_property_tag_views.xml', | ||
| 'views/res_users_views.xml', | ||
| 'views/estate_menus.xml' | ||
| ], | ||
| 'application': True, | ||
| 'installable': True | ||
| } |
| 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_refuse_in_valid_entry" model="ir.cron"> | ||
| <field name="name">Estate: Refuse Offer on passing deadline</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._cron_auto_refuse_pass_deadline_entry()</field> | ||
| <field name="state">code</field> | ||
| </record> | ||
| </odoo> |
| 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 |
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.
unnecessary diff.