-
-
Notifications
You must be signed in to change notification settings - Fork 297
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[MIG] asterisk_click2dial: Migration to 16.0
- Loading branch information
1 parent
2b1cbba
commit 7dab335
Showing
13 changed files
with
137 additions
and
185 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
89 changes: 89 additions & 0 deletions
89
asterisk_click2dial/static/src/components/asterisk_click2dial/asterisk_click2dial.esm.js
This file contains 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,89 @@ | ||
/** @odoo-module **/ | ||
|
||
/* | ||
Copyright 2024 Dixmit | ||
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
*/ | ||
|
||
import {Component} from "@odoo/owl"; | ||
import {_t} from "@web/core/l10n/translation"; | ||
import {registry} from "@web/core/registry"; | ||
import {useService} from "@web/core/utils/hooks"; | ||
|
||
const systrayRegistry = registry.category("systray"); | ||
|
||
export class Click2DialSystray extends Component { | ||
setup() { | ||
this.rpc = useService("rpc"); | ||
this.action = useService("action"); | ||
this.notification = useService("notification"); | ||
this.user = useService("user"); | ||
} | ||
|
||
async onOpenCaller() { | ||
// Var session = require('web.session'); | ||
|
||
const r = await this.rpc("/asterisk_click2dial/get_record_from_my_channel", { | ||
context: this.user.context, | ||
}); | ||
if (r === false) { | ||
this.notification.add( | ||
_t( | ||
"Calling party number not retreived from IPBX or IPBX unreachable by Odoo" | ||
), | ||
{ | ||
title: _t("IPBX error"), | ||
} | ||
); | ||
} else if (typeof r === "string" && isNaN(r)) { | ||
this.notification.add(_t("The calling number is not a phone number!"), { | ||
title: r, | ||
}); | ||
} else if (typeof r === "string") { | ||
var action = { | ||
name: _t("Number Not Found"), | ||
type: "ir.actions.act_window", | ||
res_model: "number.not.found", | ||
view_mode: "form", | ||
views: [[false, "form"]], | ||
target: "new", | ||
context: {default_calling_number: r}, | ||
}; | ||
this.action.doAction(action); | ||
} else if (typeof r === "object" && r.length === 3) { | ||
this.notification.add( | ||
`${_("Moving to form view of ")}${r[2]}${_("(")}${r[0]}${_(" ID ")}${ | ||
r[1] | ||
}${_(")")}`, | ||
{ | ||
title: `${_("On the phone with ")}${r[2]}`, | ||
} | ||
); | ||
var action_suc = { | ||
type: "ir.actions.act_window", | ||
res_model: r[0], | ||
res_id: r[1], | ||
view_mode: "form,tree", | ||
views: [[false, "form"]], | ||
/* If you want to make it work with the 'web' module | ||
of Odoo Enterprise edition, you have to change the line | ||
target: 'current', | ||
to: | ||
target: 'new', | ||
If you want to use target: 'current', with web/enterprise, | ||
you have to reload the Web page just after */ | ||
target: "current", | ||
context: {}, | ||
}; | ||
this.action.doAction(action_suc); | ||
} | ||
} | ||
} | ||
|
||
Click2DialSystray.template = "asterisk_click2dial.Click2DialSystray"; | ||
|
||
export const systrayItem = {Component: Click2DialSystray}; | ||
|
||
systrayRegistry.add("asterisk_click2dial.Click2DialSystray", systrayItem, { | ||
sequence: 99, | ||
}); |
13 changes: 13 additions & 0 deletions
13
asterisk_click2dial/static/src/components/asterisk_click2dial/asterisk_click2dial.xml
This file contains 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,13 @@ | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
<templates xml:space="preserve"> | ||
|
||
<t t-name="asterisk_click2dial.Click2DialSystray" owl="1"> | ||
<div | ||
class="o-dropdown dropdown o-dropdown--no-caret o-mail-DiscussSystray-class" | ||
> | ||
<button class="dropdown-toggle " t-on-click="() => this.onOpenCaller()"> | ||
<i class="fa fa-phone" /> | ||
</button> | ||
</div> | ||
</t> | ||
</templates> |
103 changes: 0 additions & 103 deletions
103
asterisk_click2dial/static/src/js/asterisk_click2dial.js
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.