Release v6.0
This commit is contained in:
parent
f562a0b187
commit
3d2f55541d
58
__init__.py
58
__init__.py
|
@ -1,43 +1,39 @@
|
|||
# This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||
# this repository contains the full copyright notices and license terms.
|
||||
from trytond.pool import Pool
|
||||
from .case import Case
|
||||
from .customer_service import (CustomerService, CustomerServiceReport,
|
||||
CustomerServiceIndicatorsStart, CustomerServiceIndicators,
|
||||
CustomerServiceIndicatorsReport, EfficacyMonthStart, EfficacyMonth,
|
||||
EfficacyMonthReport, MonitoringReport, PrintCustomerService)
|
||||
from .configuration import Configuration
|
||||
from .party import Party
|
||||
from .survey import (SurveyTemplate, Survey, SurveyLine,
|
||||
SurveyTemplateLine, SurveyGroup, SurveyReport)
|
||||
from .activity import Activity
|
||||
from . import case
|
||||
from . import customer_service
|
||||
from . import configuration
|
||||
from . import party
|
||||
from . import survey
|
||||
from . import activity
|
||||
|
||||
|
||||
def register():
|
||||
Pool.register(
|
||||
SurveyGroup,
|
||||
SurveyTemplate,
|
||||
SurveyTemplateLine,
|
||||
Survey,
|
||||
SurveyLine,
|
||||
Configuration,
|
||||
Case,
|
||||
CustomerService,
|
||||
CustomerServiceIndicatorsStart,
|
||||
EfficacyMonthStart,
|
||||
Party,
|
||||
Activity,
|
||||
survey.SurveyGroup,
|
||||
survey.urveyTemplate,
|
||||
survey.SurveyTemplateLine,
|
||||
survey.Survey,
|
||||
survey.SurveyLine,
|
||||
configuration.Configuration,
|
||||
case.Case,
|
||||
customer_service.CustomerService,
|
||||
customer_service.CustomerServiceIndicatorsStart,
|
||||
customer_service.EfficacyMonthStart,
|
||||
party.Party,
|
||||
activity.Activity,
|
||||
module='crm', type_='model')
|
||||
Pool.register(
|
||||
CustomerServiceReport,
|
||||
CustomerServiceIndicators,
|
||||
EfficacyMonth,
|
||||
PrintCustomerService,
|
||||
customer_service.CustomerServiceReport,
|
||||
customer_service.CustomerServiceIndicators,
|
||||
customer_service.EfficacyMonth,
|
||||
customer_service.PrintCustomerService,
|
||||
module='crm', type_='wizard')
|
||||
Pool.register(
|
||||
CustomerServiceReport,
|
||||
CustomerServiceIndicatorsReport,
|
||||
EfficacyMonthReport,
|
||||
MonitoringReport,
|
||||
SurveyReport,
|
||||
customer_service.CustomerServiceReport,
|
||||
customer_service.CustomerServiceIndicatorsReport,
|
||||
customer_service.EfficacyMonthReport,
|
||||
customer_service.MonitoringReport,
|
||||
survey.SurveyReport,
|
||||
module='crm', type_='report')
|
||||
|
|
20
activity.py
20
activity.py
|
@ -6,8 +6,8 @@ from trytond.model import Workflow, ModelView, ModelSQL, fields
|
|||
from trytond.pyson import Eval, If, In, Get
|
||||
from trytond.transaction import Transaction
|
||||
from trytond.pool import Pool
|
||||
|
||||
__all__ = ['Activity']
|
||||
from .exceptions import CrmConfigurationError
|
||||
from i18n import gettext
|
||||
|
||||
STATES = {
|
||||
'readonly': (Eval('state') != 'draft'),
|
||||
|
@ -31,7 +31,6 @@ class Activity(Workflow, ModelSQL, ModelView):
|
|||
media_info = fields.Char('Media Info', states=STATES)
|
||||
planned_date = fields.Date('Planned Date', states=STATES, required=True)
|
||||
effective_date = fields.Date('Effective Date', states=STATES)
|
||||
# salesman = fields.Many2One('company.employee', 'Salesman', states=STATES)
|
||||
notes = fields.Text('Notes', states=STATES)
|
||||
company = fields.Many2One('company.company', 'Company', required=True,
|
||||
states=STATES, domain=[ ('id', If(In('company',
|
||||
|
@ -44,19 +43,12 @@ class Activity(Workflow, ModelSQL, ModelView):
|
|||
('cancelled', 'Cancelled'),
|
||||
], 'State', readonly=True, required=True)
|
||||
state_string = state.translated('state')
|
||||
# sale = fields.Many2One('sale.sale', 'Sale', states=STATES,
|
||||
# domain=[('party', '=', Eval('customer'))])
|
||||
# next_activity = put here next activity planned for customer
|
||||
|
||||
@classmethod
|
||||
def __setup__(cls):
|
||||
super(Activity, cls).__setup__()
|
||||
cls._order.insert(0, ('planned_date', 'DESC'))
|
||||
cls._order.insert(1, ('id', 'DESC'))
|
||||
cls._error_messages.update({
|
||||
'missing_sequence_activity': ('The sequence for '
|
||||
'activity is missing!'),
|
||||
})
|
||||
cls._transitions |= set((
|
||||
('draft', 'pending'),
|
||||
('pending', 'done'),
|
||||
|
@ -120,10 +112,10 @@ class Activity(Workflow, ModelSQL, ModelView):
|
|||
return
|
||||
pool = Pool()
|
||||
Config = pool.get('crm.configuration')
|
||||
Sequence = pool.get('ir.sequence')
|
||||
config = Config.get_configuration()
|
||||
if not config.crm_activity_sequence:
|
||||
self.raise_user_error('missing_sequence_activity')
|
||||
raise CrmConfigurationError(
|
||||
gettext('crm.msg_missing_sequence_activity')
|
||||
|
||||
seq_id = config.crm_activity_sequence.id
|
||||
self.write([self], {'number': Sequence.get_id(seq_id)})
|
||||
seq = config.crm_activity_sequence.get()
|
||||
self.write([self], {'number': seq})
|
||||
|
|
4
case.py
4
case.py
|
@ -2,14 +2,12 @@
|
|||
# this repository contains the full copyright notices and license terms.
|
||||
from trytond.model import ModelView, ModelSQL, fields
|
||||
|
||||
__all__ = ['Case']
|
||||
|
||||
|
||||
class Case(ModelSQL, ModelView):
|
||||
"CRM Case"
|
||||
__name__ = "crm.case"
|
||||
name = fields.Char('Name', required=True, translate=True)
|
||||
parent = fields.Many2One('crm.case','Parent', select=True)
|
||||
parent = fields.Many2One('crm.case', 'Parent', select=True)
|
||||
childs = fields.One2Many('crm.case', 'parent', string='Children')
|
||||
|
||||
@classmethod
|
||||
|
|
|
@ -2,24 +2,26 @@
|
|||
# this repository contains the full copyright notices and license terms.
|
||||
from trytond.model import ModelView, ModelSQL, ModelSingleton, fields
|
||||
from trytond.transaction import Transaction
|
||||
|
||||
__all__ = ['Configuration']
|
||||
from trytond.pyson import Id
|
||||
|
||||
|
||||
class Configuration(ModelSingleton, ModelSQL, ModelView):
|
||||
'CRM Configuration'
|
||||
__name__ = 'crm.configuration'
|
||||
crm_customer_service_sequence = fields.Many2One('ir.sequence',
|
||||
'Customer Service Sequence', required=True, domain=[
|
||||
('code', '=', 'crm.customer_service')])
|
||||
'Customer Service Sequence', required=True,
|
||||
domain=[('sequence_type', '=',
|
||||
Id('crm', 'sequence_type_crm')), ])
|
||||
crm_survey_sequence = fields.Many2One('ir.sequence',
|
||||
'Survey Sequence', required=True, domain=[
|
||||
('code', '=', 'crm.customer_service')])
|
||||
'Survey Sequence', required=True,
|
||||
domain=[('sequence_type', '=',
|
||||
Id('crm', 'sequence_crm_customer_service'))])
|
||||
efficay_hour_limit = fields.Integer('Efficay Hour Limit',
|
||||
required=True)
|
||||
crm_activity_sequence = fields.Many2One('ir.sequence',
|
||||
'Activity Sequence', required=True, domain=[
|
||||
('code', '=', 'crm.customer_service')])
|
||||
'Activity Sequence', required=True,
|
||||
domain=[('sequence_type', '=',
|
||||
Id('crm', 'sequence_crm_activity')])
|
||||
company = fields.Many2One('company.company', 'Company', required=True)
|
||||
|
||||
@staticmethod
|
||||
|
|
|
@ -37,7 +37,6 @@ this repository contains the full copyright notices and license terms. -->
|
|||
|
||||
<record model="ir.sequence.type" id="sequence_type_crm">
|
||||
<field name="name">Customer Service</field>
|
||||
<field name="code">crm.customer_service</field>
|
||||
</record>
|
||||
<record model="ir.sequence.type-res.group"
|
||||
id="sequence_type_crm_group_admin">
|
||||
|
@ -51,28 +50,10 @@ this repository contains the full copyright notices and license terms. -->
|
|||
</record>
|
||||
<record model="ir.sequence" id="sequence_crm_customer_service">
|
||||
<field name="name">Customer Service</field>
|
||||
<field name="code">crm.customer_service</field>
|
||||
</record>
|
||||
|
||||
<!--
|
||||
<record model="ir.sequence.type" id="sequence_type_crm_activity">
|
||||
<field name="name">CRM Activity</field>
|
||||
<field name="code">crm.activity</field>
|
||||
</record>
|
||||
<record model="ir.sequence.type-res.group"
|
||||
id="sequence_type_crm_group_admin">
|
||||
<field name="sequence_type" ref="sequence_type_crm_activity"/>
|
||||
<field name="group" ref="res.group_admin"/>
|
||||
</record>
|
||||
<record model="ir.sequence.type-res.group"
|
||||
id="sequence_type_crm_group_crm_admin">
|
||||
<field name="sequence_type" ref="sequence_type_crm_activity"/>
|
||||
<field name="group" ref="crm.group_crm_admin"/>
|
||||
</record>
|
||||
-->
|
||||
<record model="ir.sequence" id="sequence_crm_activity">
|
||||
<field name="name">CRM Activity</field>
|
||||
<field name="code">crm.customer_service</field>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
|
|
2
crm.xml
2
crm.xml
|
@ -33,7 +33,7 @@ this repository contains the full copyright notices and license terms. -->
|
|||
<field name="path">icons/tryton-crm.svg</field>
|
||||
</record>
|
||||
|
||||
<menuitem name="CRM" sequence="10" id="menu_crm"
|
||||
<menuitem name="CRM" sequence="130" id="menu_crm"
|
||||
icon="tryton-crm" />
|
||||
|
||||
<record model="ir.ui.menu-res.group" id="menu_crm_group_crm">
|
||||
|
|
|
@ -9,11 +9,8 @@ from trytond.transaction import Transaction
|
|||
from trytond.pool import Pool
|
||||
from trytond.wizard import Wizard, StateView, Button, StateReport, StateTransition
|
||||
from trytond.report import Report
|
||||
|
||||
__all__ = ['CustomerService', 'CustomerServiceReport',
|
||||
'CustomerServiceIndicatorsStart', 'CustomerServiceIndicators',
|
||||
'CustomerServiceIndicatorsReport', 'EfficacyMonthStart', 'EfficacyMonth',
|
||||
'EfficacyMonthReport', 'MonitoringReport', 'PrintCustomerService']
|
||||
from .exceptions import CustomerServiceError, CrmConfigurationError
|
||||
from i18n import gettext
|
||||
|
||||
STATES = {
|
||||
'readonly': (Eval('state') != 'draft'),
|
||||
|
@ -107,14 +104,6 @@ class CustomerService(Workflow, ModelSQL, ModelView):
|
|||
super(CustomerService, cls).__setup__()
|
||||
cls._order.insert(0, ('create_date', 'DESC'))
|
||||
cls._order.insert(1, ('id', 'DESC'))
|
||||
cls._error_messages.update({
|
||||
'missing_sequence_customer_service': ('The sequence for '
|
||||
'customer service is missing!'),
|
||||
'missing_configuration_limit_hour': ('The configuration '
|
||||
'is missing for limit hours!'),
|
||||
'delete_numbered': ('The numbered service "%s" can not be '
|
||||
'deleted.'),
|
||||
})
|
||||
cls._transitions |= set((
|
||||
('draft', 'open'),
|
||||
('open', 'draft'),
|
||||
|
@ -185,7 +174,9 @@ class CustomerService(Workflow, ModelSQL, ModelView):
|
|||
def delete(cls, records):
|
||||
for record in records:
|
||||
if record.number:
|
||||
cls.raise_user_error('delete_numbered', (record.number,))
|
||||
raise CustomerServiceError(
|
||||
gettext('crm.msg_delete_numbered', s=record.number)
|
||||
)
|
||||
super(CustomerService, cls).delete(records)
|
||||
|
||||
@fields.depends('party', 'address', 'phone')
|
||||
|
@ -202,7 +193,8 @@ class CustomerService(Workflow, ModelSQL, ModelView):
|
|||
config = pool.get('crm.configuration')(1)
|
||||
now = datetime.now()
|
||||
if not config.efficay_hour_limit:
|
||||
self.raise_user_error('missing_configuration_limit_hour')
|
||||
raise CrmConfigurationError(
|
||||
gettext('crm.msg_missing_configuration_limit_hour'))
|
||||
val_hr = config.efficay_hour_limit
|
||||
if self.effective_date:
|
||||
lapse = self.effective_date - self.create_date
|
||||
|
@ -220,12 +212,11 @@ class CustomerService(Workflow, ModelSQL, ModelView):
|
|||
'''
|
||||
pool = Pool()
|
||||
config = pool.get('crm.configuration')(1)
|
||||
Sequence = pool.get('ir.sequence')
|
||||
if not config.crm_customer_service_sequence:
|
||||
self.raise_user_error('missing_sequence_customer_service')
|
||||
|
||||
seq_id = config.crm_customer_service_sequence.id
|
||||
self.write([self], {'number': Sequence.get_id(seq_id)})
|
||||
raise CrmConfigurationError(
|
||||
gettext('crm.msg_missing_sequence_customer_service'))
|
||||
seq = config.crm_customer_service_sequence.get()
|
||||
self.write([self], {'number': seq})
|
||||
|
||||
|
||||
class PrintCustomerService(Wizard):
|
||||
|
@ -249,7 +240,6 @@ class PrintCustomerService(Wizard):
|
|||
except:
|
||||
action['email'] = {}
|
||||
if service and service.party.email:
|
||||
print('No debe ejecutarse')
|
||||
action['email'].update({"to": service.party.email})
|
||||
return action, data
|
||||
|
||||
|
@ -263,8 +253,8 @@ class CustomerServiceReport(Report):
|
|||
__name__ = 'crm.customer_service'
|
||||
|
||||
@classmethod
|
||||
def get_context(cls, records, data):
|
||||
report_context = super(CustomerServiceReport, cls).get_context(records, data)
|
||||
def get_context(cls, records, header, data):
|
||||
report_context = super().get_context(records, header, data)
|
||||
Company = Pool().get('company.company')
|
||||
report_context['company'] = Company(Transaction().context.get('company'))
|
||||
return report_context
|
||||
|
@ -289,7 +279,7 @@ class CustomerServiceIndicatorsStart(ModelView):
|
|||
def default_fiscalyear():
|
||||
FiscalYear = Pool().get('account.fiscalyear')
|
||||
return FiscalYear.find(
|
||||
Transaction().context.get('company'), exception=False)
|
||||
Transaction().context.get('company'), exception=False)
|
||||
|
||||
|
||||
class CustomerServiceIndicators(Wizard):
|
||||
|
@ -323,8 +313,8 @@ class CustomerServiceIndicatorsReport(Report):
|
|||
__name__ = 'crm.customer_service_indicators_report'
|
||||
|
||||
@classmethod
|
||||
def get_context(cls, records, data):
|
||||
report_context = super(CustomerServiceIndicatorsReport, cls).get_context(records, data)
|
||||
def get_context(cls, records, header, data):
|
||||
report_context = super().get_context(records, header, data)
|
||||
pool = Pool()
|
||||
Company = pool.get('company.company')
|
||||
Fiscalyear = pool.get('account.fiscalyear')
|
||||
|
@ -446,7 +436,7 @@ class EfficacyMonthReport(Report):
|
|||
|
||||
def _get_months():
|
||||
return {'month' + str(i + 1): {'num_req': 0, 'efficacy': 0, 'rate': None}
|
||||
for i in range(12)}
|
||||
for i in range(12)}
|
||||
|
||||
total_months = {}
|
||||
|
||||
|
@ -557,8 +547,8 @@ class EfficacyMonthReport(Report):
|
|||
return departments, values
|
||||
|
||||
@classmethod
|
||||
def get_context(cls, records, data):
|
||||
report_context = super(EfficacyMonthReport, cls).get_context(records, data)
|
||||
def get_context(cls, records, header, data):
|
||||
report_context = super().get_context(records, header, data)
|
||||
pool = Pool()
|
||||
Fiscalyear = pool.get('account.fiscalyear')
|
||||
Company = pool.get('company.company')
|
||||
|
@ -578,7 +568,7 @@ class EfficacyMonthReport(Report):
|
|||
|
||||
services = Service.search(dom_service)
|
||||
departments, values = cls._get_departments(services)
|
||||
records_months, total_months = cls._get_records_months(services)
|
||||
records_months, total_months = cls._get_records_months(services)
|
||||
|
||||
report_context.update(values)
|
||||
report_context.update(total_months)
|
||||
|
@ -595,8 +585,8 @@ class MonitoringReport(Report):
|
|||
__name__ = 'crm.monitoring_report'
|
||||
|
||||
@classmethod
|
||||
def get_context(cls, records, data):
|
||||
report_context = super(MonitoringReport, cls).get_context(records, data)
|
||||
def get_context(cls, records, header, data):
|
||||
report_context = super().get_context(records, header, data)
|
||||
user = Pool().get('res.user')(Transaction().user)
|
||||
report_context['company'] = user.company
|
||||
return report_context
|
||||
|
|
|
@ -71,7 +71,7 @@ this repository contains the full copyright notices and license terms. -->
|
|||
<field name="domain"></field>
|
||||
<field name="act_window" ref="act_customer_service_form"/>
|
||||
</record>
|
||||
<menuitem parent="menu_crm" sequence="20"
|
||||
<menuitem parent="menu_crm" sequence="120"
|
||||
action="act_customer_service_form" id="menu_customer_service_form"/>
|
||||
|
||||
<!-- Buttons -->
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
# This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||
# this repository contains the full copyright notices and license terms.
|
||||
|
||||
from trytond.model.exceptions import ValidationError
|
||||
from trytond.exceptions import UserError, UserWarning
|
||||
|
||||
|
||||
class CrmConfigurationError(UserError):
|
||||
pass
|
||||
|
||||
|
||||
class CustomerServiceError(ValidationError):
|
||||
pass
|
|
@ -0,0 +1,23 @@
|
|||
<?xml version="1.0"?>
|
||||
<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||
this repository contains the full copyright notices and license terms. -->
|
||||
<tryton>
|
||||
<data grouped="1">
|
||||
<record model="ir.message" id="msg_missing_sequence_activity">
|
||||
<field name="text">The sequence for activity is missing!</field>
|
||||
</record>
|
||||
<record model="ir.message" id="msg_missing_sequence_customer_service">
|
||||
<field name="text">The sequence for customer service is missing!</field>
|
||||
</record>
|
||||
<record model="ir.message" id="msg_missing_sequence_survey">
|
||||
<field name="text">The sequence for survey is missing!</field>
|
||||
</record>
|
||||
<record model="ir.message" id="msg_missing_configuration_limit_hour">
|
||||
<field name="text">The configuration is missing for limit hours!</field>
|
||||
</record>
|
||||
<record model="ir.message" id="msg_delete_numbered">
|
||||
<field name="text">The numbered service "%s" can not be deleted.</field>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</tryton>
|
2
party.py
2
party.py
|
@ -4,8 +4,6 @@ from trytond.model import fields, ModelView
|
|||
from trytond.pool import PoolMeta, Pool
|
||||
from trytond.pyson import Eval
|
||||
|
||||
__all__ = ['Party']
|
||||
|
||||
# Size photo default
|
||||
WIDTH = 200
|
||||
HEIGHT = 250
|
||||
|
|
11
survey.py
11
survey.py
|
@ -7,11 +7,6 @@ from trytond.pyson import Eval, If, In, Get
|
|||
from trytond.pool import Pool
|
||||
from trytond.transaction import Transaction
|
||||
|
||||
__all__ = ['SurveyTemplate', 'SurveyTemplateLine',
|
||||
'Survey', 'SurveyLine', 'SurveyGroup',
|
||||
'SurveyReport']
|
||||
|
||||
|
||||
STATES = {'readonly': (Eval('state') != 'draft')}
|
||||
|
||||
RESPONSE = {
|
||||
|
@ -169,7 +164,6 @@ class Survey(Workflow, ModelSQL, ModelView):
|
|||
Fill the number field with the survey sequence
|
||||
'''
|
||||
pool = Pool()
|
||||
Sequence = pool.get('ir.sequence')
|
||||
Config = pool.get('crm.configuration')
|
||||
config = Config(1)
|
||||
|
||||
|
@ -177,8 +171,9 @@ class Survey(Workflow, ModelSQL, ModelView):
|
|||
if record.number:
|
||||
continue
|
||||
if not config.crm_survey_sequence:
|
||||
continue
|
||||
number = Sequence.get_id(config.crm_survey_sequence.id)
|
||||
raise CrmConfigurationError(
|
||||
gettext('crm.msg_missing_sequence_survey')
|
||||
number = config.crm_survey_sequence.get()
|
||||
cls.write([record], {'number': number})
|
||||
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
[tryton]
|
||||
version=5.0.2
|
||||
version=6.0.0
|
||||
depends:
|
||||
party
|
||||
company_department
|
||||
|
|
Loading…
Reference in New Issue