-
-
Notifications
You must be signed in to change notification settings - Fork 295
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
203 additions
and
113 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -71,13 +71,12 @@ Contributors | |
|
||
- Alexis de Lattre <[email protected]> | ||
- Sébastien Beau <[email protected]> | ||
|
||
- Nikul Chaudhary <[email protected]> | ||
- `Dixmit <https://www.dixmit.com>`__: | ||
|
||
- Luis David Rodríguez | ||
- Enric Tobella | ||
|
||
|
||
Maintainers | ||
----------- | ||
|
||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
from . import phone_validation_mixin | ||
from . import models | ||
from . import res_company | ||
from . import res_partner | ||
from . import phone_common |
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,21 @@ | ||
# Copyright 2018-2021 Akretion France (http://www.akretion.com/) | ||
# @author: Alexis de Lattre <[email protected]> | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
|
||
from odoo import models | ||
|
||
|
||
class BaseModel(models.AbstractModel): | ||
_inherit = "base" | ||
|
||
def _phone_format_number( | ||
self, number, country, force_format="E164", raise_exception=False | ||
): | ||
if "country_id" in self and self.country_id: | ||
country = self.country_id | ||
if "partner_id" in self and self.partner_id and self.partner_id.country_id: | ||
country = self.partner_id.country_id | ||
return super()._phone_format_number( | ||
number, country, force_format, raise_exception | ||
) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
- Alexis de Lattre \<<[email protected]>\> | ||
- Sébastien Beau \<<[email protected]>\> | ||
- Nikul Chaudhary \<<[email protected]>\> | ||
- [Dixmit](https://www.dixmit.com): | ||
- Luis David Rodríguez | ||
- Enric Tobella |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
/** @odoo-module **/ | ||
|
||
/* Base phone module for Odoo | ||
Copyright (C) 2013-2018 Akretion France | ||
@author: Alexis de Lattre <[email protected]> | ||
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). */ | ||
|
||
import {_t} from "@web/core/l10n/translation"; | ||
import { | ||
PhoneField, | ||
formPhoneField, | ||
phoneField, | ||
} from "@web/views/fields/phone/phone_field"; | ||
import {patch} from "@web/core/utils/patch"; | ||
import {Component} from "@odoo/owl"; | ||
import {useService} from "@web/core/utils/hooks"; | ||
|
||
export class Dial extends Component { | ||
setup() { | ||
this.orm = useService("orm"); | ||
this.action = useService("action"); | ||
} | ||
get phoneHref() { | ||
return "tel:" + this.props.record.data[this.props.name].replace(/\s+/g, ""); | ||
} | ||
async onClick() { | ||
await this.props.record.save(); | ||
var phone_num = this.props.record.data[this.props.name]; | ||
this.env.services.notification.add(_t('Click2dial to "%s"', phone_num), { | ||
type: "info", | ||
}); | ||
var params = { | ||
phone_number: phone_num, | ||
click2dial_model: this.props.record.resModel, | ||
click2dial_id: this.props.record.resId, | ||
}; | ||
const result = await this.orm.call( | ||
"phone.common", | ||
"click2dial", | ||
[phone_num], | ||
{} | ||
); | ||
if (result === false) { | ||
this.env.services.notification.add(_t("Click2dial failed"), { | ||
type: "warning", | ||
}); | ||
} else if (typeof result === "object") { | ||
this.env.services.notification.add( | ||
(_t("Number dialed: %s"), result.dialed_number), | ||
{title: _t("Click2dial successfull"), type: "success"} | ||
); | ||
if (result.action_model) { | ||
this.action.doAction({ | ||
type: "ir.actions.act_window", | ||
name: result.action_name, | ||
res_model: result.action_model, | ||
views: [[false, "form"]], | ||
target: "new", | ||
context: params, | ||
}); | ||
} | ||
} | ||
} | ||
} | ||
Dial.template = "base_phone.Dial"; | ||
Dial.props = ["*"]; | ||
|
||
patch(PhoneField, { | ||
components: { | ||
...PhoneField.components, | ||
Dial, | ||
}, | ||
defaultProps: { | ||
...PhoneField.defaultProps, | ||
enableButton: true, | ||
}, | ||
props: { | ||
...PhoneField.props, | ||
enableButton: {type: Boolean, optional: true}, | ||
}, | ||
}); | ||
|
||
const patchDescr = () => ({ | ||
extractProps({options}) { | ||
const props = super.extractProps(...arguments); | ||
props.enableButton = options.enable_sms; | ||
return props; | ||
}, | ||
}); | ||
|
||
patch(phoneField, patchDescr()); | ||
patch(formPhoneField, patchDescr()); |
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,34 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<!-- | ||
Copyright (C) 2013-2018 Akretion France | ||
@author: Alexis de Lattre <[email protected]> | ||
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
--> | ||
<templates xml:space="preserve"> | ||
|
||
<t t-name="base_phone.Dial"> | ||
<a | ||
t-att-title="title" | ||
t-att-href="phoneHref" | ||
t-on-click.prevent.stop="onClick" | ||
class="ms-3 d-inline-flex align-items-center o_field_phone_sms" | ||
><i>☎</i><small class="fw-bold ms-1">Dial</small></a> | ||
</t> | ||
|
||
<t t-inherit="web.PhoneField" t-inherit-mode="extension"> | ||
<xpath expr="//div[hasclass('o_phone_content')]//a" position="after"> | ||
<t t-if="props.enableButton and props.record.data[props.name].length > 0"> | ||
<Dial t-props="props" /> | ||
</t> | ||
</xpath> | ||
</t> | ||
|
||
<t t-inherit="web.FormPhoneField" t-inherit-mode="extension"> | ||
<xpath expr="//div[hasclass('o_phone_content')]" position="inside"> | ||
<t t-if="props.enableButton and props.record.data[props.name].length > 0"> | ||
<Dial t-props="props" /> | ||
</t> | ||
</xpath> | ||
</t> | ||
|
||
</templates> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,6 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<!-- | ||
Copyright 2012-2018 Akretion France | ||
@author: Alexis de Lattre <[email protected]> | ||
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
--> | ||
<!-- Copyright 2012-2018 Akretion France @author: Alexis de Lattre <[email protected]> | ||
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). --> | ||
<odoo> | ||
<record id="number_not_found_form" model="ir.ui.view"> | ||
<field name="name">number.not.found.form</field> | ||
|
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
Oops, something went wrong.