trytonpsk-crm_fiduprevisora/case.py

44 lines
1.6 KiB
Python

# 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 import ModelView, ModelSQL, fields
from trytond.pool import Pool, PoolMeta
from trytond.pyson import Eval, Bool, Not
class Case(metaclass=PoolMeta):
__name__ = "crm.case"
macroprocess = fields.Char('Macroprocess')
process_service = fields.Char('Process Service')
motives_health = fields.Char('Motives General Health')
type_request = fields.Char('Type Request')
priority = fields.Char('Priority')
time_max = fields.Numeric('Time Max Response (days)', digits=(2, 0))
quality_attribute = fields.Char('Quality Attribute')
required_attach = fields.Boolean('Required Attach')
attach_description = fields.Char('Attach Description', states={
'invisible': (Not(Bool(Eval('required_attach')))),
'required': (Bool(Eval('required_attach'))),
})
@classmethod
def import_data(cls, fields_names, data):
cont = 0
data_ = []
for row in data[1:]:
cases = cls.search([
('name', '=', row[0])
])
if not cases:
print('Case no found. ', row[0])
data_.append(row)
continue
case = cases[0]
cls.write([case], {'required_attach': True,
'attach_description': row[2]
})
print('registro actualizado --->', case.name)
return super(Case, cls).import_data(fields_names, data_)
def get_rec_name(self, name):
return self.name