-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of github.com:Comunitea/CMNT_00207_2020_ASC
- Loading branch information
Showing
22 changed files
with
409 additions
and
37 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
# © 2020 Comunitea | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
from . import crm_phonecall, phone_common, asterisk_server | ||
from . import crm_phonecall, phone_common, asterisk_server, res_users, res_partner |
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
37 changes: 37 additions & 0 deletions
37
project-addons/asterisk_phonecall_info/models/res_partner.py
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,37 @@ | ||
# © 2020 Comunitea | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
from odoo import api, models, _, fields | ||
from datetime import date | ||
|
||
|
||
class ResPartner(models.Model): | ||
_inherit = "res.partner" | ||
|
||
commercial_minutes = fields.Float(string="Total commercial minutes", compute="_compute_phonecall_minutes") | ||
technical_minutes = fields.Float(string="Total technical minutes", compute="_compute_phonecall_minutes") | ||
commercial_minutes_cur_month = fields.Float(string="Commercial minutes this month", compute="_compute_phonecall_minutes") | ||
technical_minutes_cur_month = fields.Float(string="Technical minutes this month", compute="_compute_phonecall_minutes") | ||
|
||
@api.multi | ||
def _compute_phonecall_minutes(self): | ||
for partner in self: | ||
cur_month = date.today().strftime('%B').lower() | ||
cur_year = date.today().year | ||
cur_date = "{} {}".format(cur_month, cur_year) | ||
|
||
commercial_calls = self.env['crm.phonecall'].read_group([ | ||
('partner_id', '=', partner.id), | ||
('asterisk_user_type', '=', 'commercial') | ||
], fields=['length', 'date'], groupby=['date']) | ||
|
||
partner.commercial_minutes = sum(call['length'] for call in commercial_calls)/60 | ||
partner.commercial_minutes_cur_month = sum(call['length'] for call in commercial_calls if call['date'] == cur_date)/60 | ||
|
||
technical_calls = self.env['crm.phonecall'].read_group([ | ||
('partner_id', '=', partner.id), | ||
('asterisk_user_type', '=', 'technical') | ||
], fields=['length', 'date'], groupby=['date']) | ||
|
||
partner.technical_minutes = sum(call['length'] for call in technical_calls)/60 | ||
partner.technical_minutes_cur_month = sum(call['length'] for call in technical_calls if call['date'] == cur_date)/60 |
22 changes: 22 additions & 0 deletions
22
project-addons/asterisk_phonecall_info/models/res_users.py
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,22 @@ | ||
# © 2020 Comunitea | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
from odoo import api, models, _, fields | ||
import logging | ||
from odoo.exceptions import UserError | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
class ResUsers(models.Model): | ||
_inherit = "res.users" | ||
|
||
asterisk_notify = fields.Boolean(string='Asterisk notify', default=True) | ||
asterisk_user_type = fields.Selection( | ||
[('commercial', 'Commercial'), | ||
('technical', 'Technical'), | ||
('undefined', 'Undefined')], | ||
string='User type', | ||
required=True, | ||
default='undefined', | ||
) |
Oops, something went wrong.