diff --git a/__init__.py b/__init__.py
index 4f1c1b8..380d1c7 100644
--- a/__init__.py
+++ b/__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')
diff --git a/activity.py b/activity.py
index 5d94b42..86ee944 100644
--- a/activity.py
+++ b/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})
diff --git a/case.py b/case.py
index a86c47b..10ac433 100644
--- a/case.py
+++ b/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
diff --git a/configuration.py b/configuration.py
index 02f5685..afaeb93 100644
--- a/configuration.py
+++ b/configuration.py
@@ -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
diff --git a/configuration.xml b/configuration.xml
index 035161a..f2d356d 100644
--- a/configuration.xml
+++ b/configuration.xml
@@ -37,7 +37,6 @@ this repository contains the full copyright notices and license terms. -->
Customer Service
- crm.customer_service
@@ -51,28 +50,10 @@ this repository contains the full copyright notices and license terms. -->
Customer Service
- crm.customer_service
-
CRM Activity
- crm.customer_service
diff --git a/crm.xml b/crm.xml
index 3a52dce..3c8b9fd 100644
--- a/crm.xml
+++ b/crm.xml
@@ -33,7 +33,7 @@ this repository contains the full copyright notices and license terms. -->
icons/tryton-crm.svg
-
-
diff --git a/exceptions.py b/exceptions.py
new file mode 100644
index 0000000..a3a804b
--- /dev/null
+++ b/exceptions.py
@@ -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
diff --git a/message.xml b/message.xml
new file mode 100644
index 0000000..253b80f
--- /dev/null
+++ b/message.xml
@@ -0,0 +1,23 @@
+
+
+
+
+
+ The sequence for activity is missing!
+
+
+ The sequence for customer service is missing!
+
+
+ The sequence for survey is missing!
+
+
+ The configuration is missing for limit hours!
+
+
+ The numbered service "%s" can not be deleted.
+
+
+
+
diff --git a/party.py b/party.py
index e7349d3..02b46e9 100644
--- a/party.py
+++ b/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
diff --git a/survey.py b/survey.py
index 977dfd4..576e0f4 100644
--- a/survey.py
+++ b/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})
diff --git a/tryton.cfg b/tryton.cfg
index 00b1fab..42af418 100644
--- a/tryton.cfg
+++ b/tryton.cfg
@@ -1,5 +1,5 @@
[tryton]
-version=5.0.2
+version=6.0.0
depends:
party
company_department