diff --git a/__init__.py b/__init__.py
index 285e7b8..3eb0e1d 100644
--- a/__init__.py
+++ b/__init__.py
@@ -3,10 +3,10 @@
#the full copyright notices and license terms.
from trytond.pool import Pool
-import configuration
-import customer_service
-import case
-import party
+from . import configuration
+from . import customer_service
+from . import case
+from . import party
def register():
diff --git a/case.py b/case.py
index c453d77..4d5f50b 100644
--- a/case.py
+++ b/case.py
@@ -4,8 +4,6 @@ from trytond.model import ModelView, ModelSQL, fields
from trytond.pool import Pool, PoolMeta
from trytond.pyson import Eval, Bool, Not
-__all__ = ['Case']
-
class Case(metaclass=PoolMeta):
__name__ = "crm.case"
diff --git a/configuration.py b/configuration.py
index 9dbe802..b44adc5 100644
--- a/configuration.py
+++ b/configuration.py
@@ -4,8 +4,6 @@ from trytond.model import ModelView, ModelSQL, ModelSingleton, fields
from trytond.transaction import Transaction
from trytond.pool import Pool, PoolMeta
-__all__ = ['Configuration']
-
class Configuration(metaclass=PoolMeta):
__name__ = 'crm.configuration'
diff --git a/customer_service.py b/customer_service.py
index b91b7f3..5045022 100644
--- a/customer_service.py
+++ b/customer_service.py
@@ -9,9 +9,7 @@ from trytond.transaction import Transaction
from trytond.pool import Pool, PoolMeta
from trytond.wizard import Wizard, StateView, Button, StateReport, StateTransition
from trytond.report import Report
-
-__all__ = ['CustomerService', 'RegionDepartment',
- 'ReceiverService', 'DepartmentEmail', 'HealthProvider']
+from .exceptions import MessageUserError
STATES = {
'readonly': (Eval('state') != 'draft'),
@@ -85,24 +83,6 @@ class HealthProvider(ModelSQL, ModelView):
('party.name',) + tuple(clause[1:]),
]
- @classmethod
- def import_data(cls, fields_names, data):
- cont = 0
- data_ = []
- for row in data[0:]:
- providers = cls.search([
- ('party.id_number', '=', row[0])
- ])
- for provider in providers:
- print(provider.name)
- if not providers:
- data_.append(row)
- continue
- provider = providers[0]
- cls.write([provider], {'asset': row[2],
- })
- return super(HealthProvider, cls).import_data(fields_names, data_)
-
class CustomerService(metaclass=PoolMeta):
__name__ = 'crm.customer_service'
@@ -376,7 +356,7 @@ class CustomerService(metaclass=PoolMeta):
return response
def get_message(self, message):
- self.raise_user_error('message', message)
+ raise MessageUserError('message', message)
@classmethod
def dash_on_change_user(cls, args, ctx):
@@ -400,6 +380,7 @@ class CustomerService(metaclass=PoolMeta):
}
return res
+
class FiduprevisoraAttachments(ModelSQL, ModelView):
'Fiduprevisora - Attachments'
__name__ = 'crm.fiduprevisora.attachments'
@@ -479,8 +460,8 @@ class FiduprevisoraReport(Report):
__name__ = 'crm_fiduprevisora.fiduprevisora_report'
@classmethod
- def get_context(cls, records, data):
- report_context = super(FiduprevisoraReport, cls).get_context(records, data)
+ def get_context(cls, records, header, data):
+ report_context = super(FiduprevisoraReport, cls).get_context(records, header, data)
pool = Pool()
Company = pool.get('company.company')
Service = pool.get('crm.customer_service')
@@ -537,6 +518,7 @@ class FiduprevisoraReport(Report):
report_context['company'] = company.party.name
return report_context
+
class CustomerReceiver(ModelSQL, ModelView):
'Customer Receiver'
__name__ = 'crm.customer_receiver'
diff --git a/exceptions.py b/exceptions.py
new file mode 100644
index 0000000..fe6187e
--- /dev/null
+++ b/exceptions.py
@@ -0,0 +1,8 @@
+# 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.exceptions import UserError
+from trytond.model.exceptions import ValidationError
+
+
+class MessageUserError(UserError):
+ pass
diff --git a/message.xml b/message.xml
new file mode 100644
index 0000000..4e6d6f2
--- /dev/null
+++ b/message.xml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
diff --git a/party.py b/party.py
index aee0ced..df3a299 100644
--- a/party.py
+++ b/party.py
@@ -5,8 +5,6 @@ from trytond.pool import PoolMeta, Pool
from trytond.pyson import Eval, If, In, Get, Or, Bool, Not
from trytond.transaction import Transaction
-__all__ = ['RegionFiduprevisora', 'DepartmentCode', 'Party']
-
class RegionFiduprevisora(ModelSQL, ModelView):
'Region Fiduprevisora'
@@ -55,77 +53,3 @@ class Party(metaclass=PoolMeta):
],'Affiliation State', states={
'invisible': (Not(Bool(Eval('is_affiliate_user')))),
})
-
- @classmethod
- def import_data(cls, fields_names, data):
- City = Pool().get('party.city_code')
- number_ids = []
- cont = 0
- i = 0
- for row in data[1:]:
- cities = City.search([
- ('code', '=', row[6].replace(' ', '')),
- ])
- city_attention = cities[0].id if cities else None
- i += 1
- print(i)
- if row[5] in number_ids:
- continue
- number_ids.append(row[5])
- users = cls.search([
- ('id_number', '=', row[5]),
- ])
- state_ = ''
- if row[8] == 'Activo':
- state_ = 'activo'
- elif row[8] == 'Retirado':
- state_ = 'retirado'
- elif row[8] == 'Protección Laboral' or row[4].count('Laboral') > 0:
- state_ = 'proteccion_laboral'
-
- if users:
- user = users[0]
- if state_ != user.affiliation_state:
- cls.write([user], {'affiliation_state': state_})
- print('actualizado ----> ', user.name)
- if city_attention:
- cls.write([user], {'city_attention': city_attention})
- print('actualizado ----> ', user.name)
- else:
- try:
- cls.create_new_party(row, state_, city_attention)
- cont += 1
- print('creado ----> ', row[5])
- except:
- cls.raise_user_error('error_import', 'Error en la linea ' + row[5])
- return cont
-
- @classmethod
- def create_new_party(cls, row, state_, city_attention):
- cursor = Transaction().connection.cursor()
- code = cls._new_code()
- name = row[0] + ' ' + row[1] + ' ' + row[2] + ' ' + row[3]
- id_number = row[5]
- if row[4].count('Ciud') > 0:
- type_document = 13
- elif row[4].count('Pasa') > 0:
- type_document = 41
- elif row[4].count('Tarj') > 0:
- type_document = 12
- elif row[4].count('Regi') > 0:
- type_document = 11
- else:
- type_document = 0
- if city_attention:
- cursor.execute("INSERT INTO party_party (active, is_affiliate_user, code, \
- name, id_number, type_document, city_attention, affiliation_state) \
- VALUES ('true', 'true', '%s', '%s', '%s', '%s', %s, '%s')" % (
- code, name, id_number, type_document, city_attention, state_
- )
- )
- else:
- cursor.execute("INSERT INTO party_party (active, is_affiliate_user, code, \
- name, id_number, type_document, affiliation_state) \
- VALUES ('true', 'true', '%s', '%s', '%s', '%s', '%s')" % (
- code, name, id_number, type_document, state_)
- )
diff --git a/tryton.cfg b/tryton.cfg
index b1ece58..030d7f1 100644
--- a/tryton.cfg
+++ b/tryton.cfg
@@ -1,5 +1,5 @@
[tryton]
-version=5.0.0
+version=6.0.0
depends:
crm
email
@@ -9,3 +9,4 @@ xml:
party.xml
customer_service.xml
configuration.xml
+ message.xml
diff --git a/view/crm_fiduprevisora_department_email_tree.xml b/view/crm_fiduprevisora_department_email_tree.xml
index ffb4bb4..2a1afb2 100644
--- a/view/crm_fiduprevisora_department_email_tree.xml
+++ b/view/crm_fiduprevisora_department_email_tree.xml
@@ -1,6 +1,6 @@
-
+
diff --git a/view/crm_receiver_email_tree.xml b/view/crm_receiver_email_tree.xml
index ffb4bb4..2a1afb2 100644
--- a/view/crm_receiver_email_tree.xml
+++ b/view/crm_receiver_email_tree.xml
@@ -1,6 +1,6 @@
-
+
diff --git a/view/customer_receiver_view_tree.xml b/view/customer_receiver_view_tree.xml
index 6be1254..0b19ec0 100644
--- a/view/customer_receiver_view_tree.xml
+++ b/view/customer_receiver_view_tree.xml
@@ -1,7 +1,7 @@
-
+