<commit_before># -*- coding: utf-8 -*-
##############################################################################
#
#    Copyright (C) 2017 Visiotech All Rights Reserved
#    $<NAME> <<EMAIL>>$
#
#    This program is free software: you can redistribute it and/or modify
#    it under the terms of the GNU Affero General Public License as published
#    by the Free Software Foundation, either version 3 of the License, or
#    (at your option) any later version.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU Affero General Public License for more details.
#
#    You should have received a copy of the GNU Affero General Public License
#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################

from openerp import models, api, fields, _
import datetime
from datetime import datetime
import pytz

CALL_TYPE = [
                   ('check_stock', 'Check Stock'),
                   ('check_prices', 'Check Prices'),
                   ('order', 'Order/Budget'),
                   ('counsel', 'Counsel'),
                   ('shipment_status', 'Shipments status'),
                   ('rma_complain', 'RMA Complain/Claim'),
                   ('tech_complain', 'Tech Complain/Claim'),
                   ('web_complain', 'Web Complain/Claim'),
                   ('shipment_complain', 'Shipment Complain/Claim'),
                   ('accounting_complain', 'Accounting Complain/Claim'),
                   ]

class crm_phonecall(models.Model):
    """ Wizard for CRM phonecalls"""
    _inherit = "crm.phonecall"

    local_tz = pytz.timezone('Europe/Madrid')

    name = fields.Char('Call Summary', readonly=True)
    partner_id = fields.Many2one('res.partner', 'Contact', required=True, onchange="")
    start_date = fields.Datetime('Start Date', readonly=True, default=fields.Datetime.now)
    user_id = fields.Many2one('res.users', 'Responsible', readonly=True)
    call_type = fields.Selection(CALL_TYPE,'Call type', required=True)
    description = fields.Text('Call Description')

    def utc_to_local(self, utc_dt):
        local_dt = utc_dt.replace(tzinfo=pytz.utc).astimezone(self.local_tz)
        return self.local_tz.normalize(local_dt)

    @api.onchange('partner_id')
    def _calc_name(self):
        if self.partner_id:
            start_date = datetime.strptime(self.start_date, '%Y-%m-%d %H:%M:%S')
            final_start_date = datetime.strptime(
                self.utc_to_local(start_date).strftime('%Y-%m-%d %H:%M:%S'), '%Y-%m-%d %H:%M:%S'
            )
            format_start_date_all = datetime.strftime(final_start_date, '%Y%m%d/%H%M')
            format_start_date = format_start_date_all.split('/')
            self.name = self.partner_id.ref + ' - ' + format_start_date[0] + ' - ' + format_start_date[1]<commit_msg>[IMP] 'crm_claim_rma_custom': Aplicado filtro de empresa a los clientes<commit_after># -*- coding: utf-8 -*-
##############################################################################
#
#    Copyright (C) 2017 Visiotech All Rights Reserved
#    $<NAME> <<EMAIL>>$
#
#    This program is free software: you can redistribute it and/or modify
#    it under the terms of the GNU Affero General Public License as published
#    by the Free Software Foundation, either version 3 of the License, or
#    (at your option) any later version.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU Affero General Public License for more details.
#
#    You should have received a copy of the GNU Affero General Public License
#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################

from openerp import models, api, fields, _
import datetime
from datetime import datetime
import pytz

CALL_TYPE = [
                   ('check_stock', 'Check Stock'),
                   ('check_prices', 'Check Prices'),
                   ('order', 'Order/Budget'),
                   ('counsel', 'Counsel'),
                   ('shipment_status', 'Shipments status'),
                   ('rma_complain', 'RMA Complain/Claim'),
                   ('tech_complain', 'Tech Complain/Claim'),
                   ('web_complain', 'Web Complain/Claim'),
                   ('shipment_complain', 'Shipment Complain/Claim'),
                   ('accounting_complain', 'Accounting Complain/Claim'),
                   ]

class crm_phonecall(models.Model):
    """ Wizard for CRM phonecalls"""
    _inherit = "crm.phonecall"

    local_tz = pytz.timezone('Europe/Madrid')

    name = fields.Char('Call Summary', readonly=True)
    partner_id = fields.Many2one('res.partner', 'Contact', required=True,
                                 domain="[['is_company', '=', 1], ['customer', '=', True]]")
    start_date = fields.Datetime('Start Date', readonly=True, default=fields.Datetime.now)
    user_id = fields.Many2one('res.users', 'Responsible', readonly=True)
    call_type = fields.Selection(CALL_TYPE,'Call type', required=True)
    description = fields.Text('Call Description')

    def utc_to_local(self, utc_dt):
        local_dt = utc_dt.replace(tzinfo=pytz.utc).astimezone(self.local_tz)
        return self.local_tz.normalize(local_dt)

    @api.onchange('partner_id')
    def _calc_name(self):
        if self.partner_id:
            start_date = datetime.strptime(self.start_date, '%Y-%m-%d %H:%M:%S')
            final_start_date = datetime.strptime(
                self.utc_to_local(start_date).strftime('%Y-%m-%d %H:%M:%S'), '%Y-%m-%d %H:%M:%S'
            )
            format_start_date_all = datetime.strftime(final_start_date, '%Y%m%d/%H%M')
            format_start_date = format_start_date_all.split('/')
            self.name = self.partner_id.ref + ' - ' + format_start_date[0] + ' - ' + format_start_date[1]
{'fraction_non_alphanumeric': 0.17077122488658458, 'fraction_numerical': 0.0034024627349319506, 'mean_word_length': 2.980012894906512, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6200399', 'n_tokens_mistral': 1840, 'n_tokens_neox': 1770, 'n_words': 456}