Skip to content
Open
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
2 changes: 1 addition & 1 deletion awesome_clicker/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
# -*- coding: utf-8 -*-

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

Expand Down
1 change: 0 additions & 1 deletion awesome_dashboard/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
# -*- 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
3 changes: 1 addition & 2 deletions awesome_dashboard/controllers/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
# -*- coding: utf-8 -*-

from . import controllers
from . import controllers
4 changes: 1 addition & 3 deletions awesome_dashboard/controllers/controllers.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
# -*- coding: utf-8 -*-

import logging
import random

from odoo import http
from odoo.http import request

logger = logging.getLogger(__name__)


class AwesomeDashboard(http.Controller):
@http.route('/awesome_dashboard/statistics', type='jsonrpc', auth='user')
def get_statistics(self):
Expand Down
3 changes: 1 addition & 2 deletions awesome_owl/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
# -*- coding: utf-8 -*-

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

Expand Down
3 changes: 1 addition & 2 deletions awesome_owl/controllers/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
# -*- coding: utf-8 -*-

from . import controllers
from . import controllers
1 change: 0 additions & 1 deletion awesome_shelter/__manifest__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
{
"name": "Awesome Shelter",
"summary": """
Expand Down
2 changes: 1 addition & 1 deletion awesome_shelter/models/animal.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,5 @@ class Animal(models.Model):
def _compute_is_present_for_six_month(self):
for record in self:
record.is_present_for_six_month = (
fields.Date.today() + relativedelta(months=-6) < record.drop_date
fields.Date.today() + relativedelta(months=-6) > record.drop_date
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import { registry } from "@web/core/registry";
import { statusBarField } from "@web/views/fields/statusbar/statusbar_field";
import { useService } from "@web/core/utils/hooks";


class AdoptedStatusBar extends statusBarField.component
{
static props = {...statusBarField.component.props, activationStage:{type : String}}
static template = statusBarField.component.template;

setup()
{
super.setup();
this.effect = useService("effect");
}
async selectItem(item)
{
super.selectItem(item);
if(item.value == this.props.activationStage)
{
this.effect.add({message : "A new happy life on the makeing !!"});
}

}

}

export const adoptedStatusBar =
{
...statusBarField,
component: AdoptedStatusBar,
extractProps({options})
{
const props = statusBarField.extractProps(...arguments);
props.activationStage = options.activationStage
return props;
}
}

registry.category("fields").add("adopt_status_bar",adoptedStatusBar);
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import { registry } from "@web/core/registry";
import {charField } from "@web/views/fields/char/char_field";


class CharGeneratorField extends charField.component
{
static template = "shelter.char_generator_field";
static props = {...charField.component.props}
static names = [
"Charlie",
"Daisy",
"Bella",
"Lola",
"Luna",
"Milo",
"Teddy",
"Cooper",
"Max",
"Bailey",
"Buddy",
"Coco",
"Leo",
"Loki",
"Lucy",
"Chloé",
"Oscar",
"Rocky",
"Sadie",
"Bonnie",
"Poppy",
]

generate()
{
const name = CharGeneratorField.names[Math.floor(Math.random() * CharGeneratorField.names.length)];
console.log(name)
this.props.record.update({[this.props.name]: name});
}
get isShow()
{
return !this.props.record.data[this.props.name];
}
}
export const charFieldGenerator=
{
...charField,
component: CharGeneratorField,
}
registry.category("fields").add("char_generator",charFieldGenerator);

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="shelter.char_generator_field">
<button t-on-click="generate" t-if="isShow">
Generate
</button>
<t t-call="web.CharField"/>

</t>
</templates>
16 changes: 16 additions & 0 deletions awesome_shelter/static/src/long_stay_banner/long_stay_banner.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { Component } from "@odoo/owl";
import { standardWidgetProps } from "@web/views/widgets/standard_widget_props";
import { registry } from "@web/core/registry";

class LongStayBanner extends Component {
static template = "shelter.long_stay_banner";
static props = {
...standardWidgetProps
};
}
export const longStayBanner=
{
component: LongStayBanner,
}
registry.category("view_widgets").add("long_stay_banner",longStayBanner);

11 changes: 11 additions & 0 deletions awesome_shelter/static/src/long_stay_banner/long_stay_banner.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="shelter.long_stay_banner">
<div class="bg-warning text-bg-warning p-2 rounded">
<p>Oh no, <t t-esc="props.record.data['display_name']"/> has stayed here for very long.
Quick find them a home
</p>

</div>
</t>
</templates>
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import { registry } from "@web/core/registry";
import {Many2OneField, buildM2OFieldDescription } from "@web/views/fields/many2one/many2one_field";
import { imageUrl } from "@web/core/utils/urls";


const field = buildM2OFieldDescription(Many2OneField);

class PictoMany2One extends Many2OneField
{
static template = "shelter.picto_many2one";
static props = {
...Many2OneField.props,
image: {optional : true, type: String}
};

get pictoUrl()
{
console.log(this.props.record.resModel)
console.log(this.props.record.resId)
console.log(this.props.image)
console.log(imageUrl(this.props.record.resModel, this.props.record.resId, this.props.image));
return imageUrl(this.props.record.resModel, this.props.record.resId, this.props.image);
}
get hasImage()
{
return Boolean(this.props.record.data[this.props.image]);
}

}


const pictoMany2One = {
...field,
component: PictoMany2One,
fieldDependencies: [...field.fieldDependencies || [], {name: "pictogram", type:"image"}],
extractProps({options})
{
const props = field.extractProps(...arguments)
props.image = options.image;
return props;
},
}
registry.category("fields").add("picto_many2one",pictoMany2One);
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="shelter.picto_many2one">
<xpath expr="//t" position="inside">
<t t-call="web.Many2OneField"/>
<img t-att-src="pictoUrl" t-if="hasImage" class="ms-2" style="width: 18px; height: 18px;"/>
</xpath>

</t>
</templates>
29 changes: 29 additions & 0 deletions awesome_shelter/static/src/updated_kanban/updated_kanban.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { registry } from "@web/core/registry";
import { kanbanView } from "@web/views/kanban/kanban_view";
import { useInterval } from "../utlis/utils";




class UpdatedKanban extends kanbanView.Controller
{
setup()
{
super.setup();
useInterval(this.reload.bind(this),10000);
}
reload()
{
console.log("reloaded");
this.model.load();
}

}
const updatedKanban =
{
...kanbanView,
Controller: UpdatedKanban,

};

registry.category("views").add("updated_kanban",updatedKanban);
9 changes: 9 additions & 0 deletions awesome_shelter/static/src/utlis/utils.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@

import { browser } from "@web/core/browser/browser";
import { onMounted, onWillUnmount } from "@odoo/owl";
export function useInterval(callback , duration)
{
let interval;
onMounted(() => (interval = browser.setInterval(callback, duration)));
onWillUnmount(() => (browser.clearInterval(interval)));
}
13 changes: 8 additions & 5 deletions awesome_shelter/views/views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<field name="arch" type="xml">
<list string="Animals">
<field name="name" />
<field name="type_id" />
<field name="type_id" widget="picto_many2one" options="{'image':'pictogram'}"/>
<field name="pictogram" widget="image" options="{ 'size': [18, 18] }"/>
<field name="owner_id" widget="many2one_avatar"/>
<field name="state" widget="badge" decoration-success="state == 'adopted'"/>
Expand All @@ -25,9 +25,10 @@
<field name="name">awesome_shelter.animal.kanban</field>
<field name="model">awesome_shelter.animal</field>
<field name="arch" type="xml">
<kanban>
<kanban js_class="updated_kanban">
<templates>
<t t-name="card" class="flex-row">
<widget name="web_ribbon" title="Adopted" bg_color="text-bg-success" invisible="state != 'adopted'"/>
<aside class="o_kanban_aside_full">
<field name="picture" class="w-100" widget="image" options="{'img_class': 'object-fit-cover w-100 h-100'}" invisible="not picture"/>
<field name="pictogram" class="w-100" widget="image" options="{'img_class': 'object-fit-content w-100 h-100'}" invisible="picture"/>
Expand All @@ -49,14 +50,16 @@
<field name="model">awesome_shelter.animal</field>
<field name="arch" type="xml">
<form>
<widget name="long_stay_banner" invisible="state == 'adopted' or not is_present_for_six_month" class="mb-2"/>
<header>
<field name="state" widget="statusbar" options="{ 'clickable': True }" />
<field name="state" widget="adopt_status_bar" options="{ 'clickable': True, 'activationStage':'adopted' }" />
</header>
<sheet>
<widget name="web_ribbon" title="Adopted" bg_color="text-bg-success" invisible="state != 'adopted'"/>
<group col="4">
<group col="2">
<field name="name" />
<field name="type_id" />
<field name="name" widget="char_generator"/>
<field name="type_id"/>
<field name="race_id" />
<field name="owner_id" widget="many2one_avatar" />
<field name="dropper_id" widget="many2one_avatar" />
Expand Down