コード例 #1
0
 def updateDatas(self, group):
     self.datas = {}
     self.labels = {}
     self.ids = {}
     self.group = group
     minx = None
     maxx = None
     for model in group:
         x = model[self.xfield['name']].get(model)
         if not minx:
             minx = x
         if not maxx:
             maxx = x
         minx = min(minx, x)
         maxx = max(maxx, x)
         self.labels[x] = model[self.xfield['name']].get_client(model)
         self.ids.setdefault(x, [])
         self.ids[x].append(model.id)
         self.datas.setdefault(x, {})
         for yfield in self.yfields:
             key = yfield.get('key', yfield['name'])
             self.datas[x].setdefault(key, 0.0)
             if yfield.get('domain'):
                 context = rpc.CONTEXT.copy()
                 context['context'] = context.copy()
                 context['_user'] = rpc._USER
                 for field in model.group.fields:
                     context[field] = model[field].get(model)
                 if not PYSONDecoder(context).decode(yfield['domain']):
                     continue
             if yfield['name'] == '#':
                 self.datas[x][key] += 1
             else:
                 value = model[yfield['name']].get(model)
                 if isinstance(value, datetime.timedelta):
                     value = value.total_seconds()
                 self.datas[x][key] += float(value or 0)
     date_format = self.view.screen.context.get('date_format', '%x')
     datetime_format = date_format + ' %X'
     if isinstance(minx, datetime.datetime):
         date = minx
         while date <= maxx:
             self.labels[date] = datetime_strftime(date, datetime_format)
             self.datas.setdefault(date, {})
             for yfield in self.yfields:
                 self.datas[date].setdefault(
                     yfield.get('key', yfield['name']), 0.0)
             date += relativedelta(days=1)
     elif isinstance(minx, datetime.date):
         date = minx
         while date <= maxx:
             self.labels[date] = datetime_strftime(date, date_format)
             self.datas.setdefault(date, {})
             for yfield in self.yfields:
                 self.datas[date].setdefault(
                     yfield.get('key', yfield['name']), 0.0)
             date += relativedelta(days=1)
コード例 #2
0
 def updateDatas(self, group):
     self.datas = {}
     self.labels = {}
     self.ids = {}
     self.group = group
     minx = None
     maxx = None
     for model in group:
         x = model[self.xfield['name']].get(model)
         if not minx:
             minx = x
         if not maxx:
             maxx = x
         minx = min(minx, x)
         maxx = max(maxx, x)
         self.labels[x] = model[self.xfield['name']].get_client(model)
         self.ids.setdefault(x, [])
         self.ids[x].append(model.id)
         self.datas.setdefault(x, {})
         for yfield in self.yfields:
             key = yfield.get('key', yfield['name'])
             self.datas[x].setdefault(key, 0.0)
             if yfield.get('domain'):
                 context = rpc.CONTEXT.copy()
                 context['context'] = context.copy()
                 context['_user'] = rpc._USER
                 for field in model.group.fields:
                     context[field] = model[field].get(model,
                         check_load=False)
                 if not PYSONDecoder(context).decode(yfield['domain']):
                     continue
             if yfield['name'] == '#':
                 self.datas[x][key] += 1
             else:
                 self.datas[x][key] += \
                         float(model[yfield['name']].get(model) or 0)
     if isinstance(minx, datetime.datetime):
         date = minx
         while date <= maxx:
             self.labels[date] = datetime_strftime(date, date_format())
             self.datas.setdefault(date, {})
             for yfield in self.yfields:
                 self.datas[date].setdefault(
                         yfield.get('key', yfield['name']), 0.0)
             date += relativedelta(days=1)
     elif isinstance(minx, datetime.date):
         date = minx
         while date <= maxx:
             self.labels[date] = datetime_strftime(date, date_format())
             self.datas.setdefault(date, {})
             for yfield in self.yfields:
                 self.datas[date].setdefault(
                         yfield.get('key', yfield['name']), 0.0)
             date += relativedelta(days=1)
コード例 #3
0
ファイル: form.py プロジェクト: coopengo/tryton
    def sig_logs(self, widget=None):
        current_record = self.screen.current_record
        if not current_record or current_record.id < 0:
            self.message_info(
                _('You have to select one record.'), gtk.MESSAGE_INFO)
            return False

        fields = [
            ('id', _('ID:')),
            ('create_uid.rec_name', _('Creation User:'******'create_date', _('Creation Date:')),
            ('write_uid.rec_name', _('Latest Modification by:')),
            ('write_date', _('Latest Modification Date:')),
        ]

        try:
            res = RPCExecute('model', self.model, 'read', [current_record.id],
                [x[0] for x in fields], context=self.screen.context)
        except RPCException:
            return
        date_format = self.screen.context.get('date_format', '%x')
        datetime_format = date_format + ' %X.%f'
        message_str = ''
        for line in res:
            for (key, val) in fields:
                value = str(line.get(key, False) or '/')
                if line.get(key, False) \
                        and key in ('create_date', 'write_date'):
                    date = timezoned_date(line[key])
                    value = common.datetime_strftime(date, datetime_format)
                message_str += val + ' ' + value + '\n'
        message_str += _('Model:') + ' ' + self.model
        message(message_str)
        return True
コード例 #4
0
ファイル: form.py プロジェクト: manalaboutayeb/tryton
    def sig_logs(self, widget=None):
        current_record = self.screen.current_record
        if not current_record or current_record.id < 0:
            self.message_info(
                _('You have to select one record.'), gtk.MESSAGE_INFO)
            return False

        fields = [
            ('id', _('ID:')),
            ('create_uid.rec_name', _('Creation User:'******'create_date', _('Creation Date:')),
            ('write_uid.rec_name', _('Latest Modification by:')),
            ('write_date', _('Latest Modification Date:')),
        ]

        try:
            res = RPCExecute('model', self.model, 'read', [current_record.id],
                [x[0] for x in fields], context=self.screen.context)
        except RPCException:
            return
        date_format = self.screen.context.get('date_format', '%x')
        datetime_format = date_format + ' %H:%M:%S.%f'
        message_str = ''
        for line in res:
            for (key, val) in fields:
                value = str(line.get(key, False) or '/')
                if line.get(key, False) \
                        and key in ('create_date', 'write_date'):
                    date = timezoned_date(line[key])
                    value = common.datetime_strftime(date, datetime_format)
                message_str += val + ' ' + value + '\n'
        message_str += _('Model:') + ' ' + self.model
        message(message_str)
        return True
コード例 #5
0
ファイル: dictionary.py プロジェクト: webmavilchez/tryton
 def modified(self, value):
     if value.get(self.name):
         text = datetime_strftime(timezoned_date(value[self.name]),
                                  self.get_format())
     else:
         text = ''
     return self.widget.compute_date(self.widget.get_text()) != text
コード例 #6
0
    def sig_logs(self, widget=None):
        obj_id = self.id_get()
        if obj_id < 0 or obj_id is False:
            self.message_info(_('You have to select one record!'))
            return False

        fields = [
            ('id', _('ID:')),
            ('create_uid.rec_name', _('Creation User:'******'create_date', _('Creation Date:')),
            ('write_uid.rec_name', _('Latest Modification by:')),
            ('write_date', _('Latest Modification Date:')),
        ]

        try:
            res = RPCExecute('model', self.model, 'read', [obj_id],
                [x[0] for x in fields], context=self.screen.context)
        except RPCException:
            return
        message_str = ''
        for line in res:
            for (key, val) in fields:
                value = str(line.get(key, False) or '/')
                if line.get(key, False) \
                        and key in ('create_date', 'write_date'):
                    date = timezoned_date(line[key])
                    value = common.datetime_strftime(date, '%X')
                message_str += val + ' ' + value + '\n'
        message_str += _('Model:') + ' ' + self.model
        message(message_str)
        return True
コード例 #7
0
ファイル: form.py プロジェクト: sunny414/tryton-client
    def sig_logs(self, widget=None):
        obj_id = self.id_get()
        if obj_id < 0 or obj_id is False:
            self.message_info(_('You have to select one record!'))
            return False

        fields = [
            ('id', _('ID:')),
            ('create_uid.rec_name', _('Creation User:'******'create_date', _('Creation Date:')),
            ('write_uid.rec_name', _('Latest Modification by:')),
            ('write_date', _('Latest Modification Date:')),
        ]

        try:
            res = RPCExecute('model', self.model, 'read', [obj_id],
                [x[0] for x in fields], context=self.context)
        except RPCException:
            return
        message_str = ''
        for line in res:
            for (key, val) in fields:
                value = str(line.get(key, False) or '/')
                if line.get(key, False) \
                        and key in ('create_date', 'write_date'):
                    display_format = date_format() + ' %H:%M:%S'
                    date = timezoned_date(line[key])
                    value = common.datetime_strftime(date, display_format)
                message_str += val + ' ' + value + '\n'
        message_str += _('Model:') + ' ' + self.model
        message(message_str)
        return True
コード例 #8
0
ファイル: field.py プロジェクト: sunny414/tryton-client
 def get_client(self, record):
     value = super(DateTimeField, self).get_client(record)
     if value:
         value = common.timezoned_date(value)
         return datetime_strftime(value, date_format() + ' ' +
             self.time_format(record))
     return ''
コード例 #9
0
ファイル: dictionary.py プロジェクト: sunny414/tryton-client
 def modified(self, value):
     if value.get(self.name):
         text = datetime_strftime(timezoned_date(value[self.name]),
             self.get_format())
     else:
         text = ''
     return self.widget.compute_date(self.widget.get_text()) != text
コード例 #10
0
 def format_datetime():
     if not value:
         return ''
     format_ = date_format() + ' ' + HM_FORMAT
     if (not isinstance(value, datetime.datetime)
             or value.time() == datetime.time.min):
         format_ = date_format()
     return datetime_strftime(value, format_)
コード例 #11
0
 def get_client(self, record):
     value = super(DateTimeField, self).get_client(record)
     if value:
         value = common.timezoned_date(value)
         return datetime_strftime(
             value,
             date_format() + ' ' + self.time_format(record))
     return ''
コード例 #12
0
ファイル: domain_parser.py プロジェクト: coopengo/tryton
 def format_datetime():
     if not value:
         return ''
     format_ = context.get('date_format', '%x') + ' ' + time_format(field)
     if (not isinstance(value, datetime.datetime)
             or value.time() == datetime.time.min):
         format_ = '%x'
         time = value
     else:
         time = timezoned_date(value)
     return datetime_strftime(time, format_)
コード例 #13
0
 def format_datetime():
     if not value:
         return ''
     format_ = context.get('date_format', '%x') + ' ' + time_format(field)
     if not isinstance(value, datetime.datetime):
         time = datetime.datetime.combine(value, datetime.time.min)
     else:
         time = timezoned_date(value)
     if time.time() == datetime.time.min:
         format_ = '%x'
     return datetime_strftime(time, format_)
コード例 #14
0
ファイル: domain_parser.py プロジェクト: ClemFaure/tryton
 def format_datetime():
     if not value:
         return ''
     format_ = context.get('date_format', '%x') + ' ' + time_format(field)
     if (not isinstance(value, datetime.datetime)
             or value.time() == datetime.time.min):
         format_ = '%x'
         time = value
     else:
         time = timezoned_date(value)
     return datetime_strftime(time, format_)
コード例 #15
0
ファイル: graph.py プロジェクト: kret0s/gnuhealth-live
 def updateDatas(self, group):
     self.datas = {}
     self.labels = {}
     self.ids = {}
     self.group = group
     minx = None
     maxx = None
     for model in group:
         x = model[self.xfield['name']].get(model)
         if not minx:
             minx = x
         if not maxx:
             maxx = x
         if minx is None and maxx is None:
             if isinstance(x, datetime.datetime):
                 minx, maxx = datetime.datetime.min, datetime.datetime.max
             elif isinstance(x, datetime.date):
                 minx, maxx = datetime.date.min, datetime.date.max
             elif isinstance(x, datetime.timedelta):
                 minx, maxx = datetime.timedelta.min, datetime.timedelta.max
         try:
             minx = min(minx, x)
             maxx = max(maxx, x)
         except TypeError:
             continue
         self.labels[x] = model[self.xfield['name']].get_client(model)
         self.ids.setdefault(x, [])
         self.ids[x].append(model.id)
         self.datas.setdefault(x, {})
         for yfield in self.yfields:
             key = yfield.get('key', yfield['name'])
             self.datas[x].setdefault(key, 0.0)
             if yfield.get('domain'):
                 context = rpc.CONTEXT.copy()
                 context['context'] = context.copy()
                 context['_user'] = rpc._USER
                 for field in model.group.fields:
                     context[field] = model[field].get(model)
                 if not PYSONDecoder(context).decode(yfield['domain']):
                     continue
             if yfield['name'] == '#':
                 self.datas[x][key] += 1
             else:
                 value = model[yfield['name']].get(model)
                 if isinstance(value, datetime.timedelta):
                     value = value.total_seconds()
                 self.datas[x][key] += float(value or 0)
     date_format = self.view.screen.context.get('date_format', '%x')
     datetime_format = date_format + ' %X'
     if isinstance(minx, datetime.datetime):
         date = minx
         while date <= maxx:
             self.labels[date] = datetime_strftime(date, datetime_format)
             self.datas.setdefault(date, {})
             for yfield in self.yfields:
                 self.datas[date].setdefault(
                         yfield.get('key', yfield['name']), 0.0)
             date += relativedelta(days=1)
     elif isinstance(minx, datetime.date):
         date = minx
         while date <= maxx:
             self.labels[date] = datetime_strftime(date, date_format)
             self.datas.setdefault(date, {})
             for yfield in self.yfields:
                 self.datas[date].setdefault(
                         yfield.get('key', yfield['name']), 0.0)
             date += relativedelta(days=1)
コード例 #16
0
ファイル: field.py プロジェクト: sunny414/tryton-client
 def get_client(self, record):
     value = super(DateField, self).get_client(record)
     if value:
         return datetime_strftime(value, date_format())
     return ''
コード例 #17
0
ファイル: graph.py プロジェクト: webmavilchez/tryton
 def updateDatas(self, group):
     self.datas = {}
     self.labels = {}
     self.ids = {}
     self.group = group
     minx = None
     maxx = None
     for model in group:
         x = model[self.xfield['name']].get(model)
         if not minx:
             minx = x
         if not maxx:
             maxx = x
         if minx is None and maxx is None:
             if isinstance(x, datetime.datetime):
                 minx, maxx = datetime.datetime.min, datetime.datetime.max
             elif isinstance(x, datetime.date):
                 minx, maxx = datetime.date.min, datetime.date.max
             elif isinstance(x, datetime.timedelta):
                 minx, maxx = datetime.timedelta.min, datetime.timedelta.max
         try:
             minx = min(minx, x)
             maxx = max(maxx, x)
         except TypeError:
             continue
         self.labels[x] = model[self.xfield['name']].get_client(model)
         self.ids.setdefault(x, [])
         self.ids[x].append(model.id)
         self.datas.setdefault(x, {})
         for yfield in self.yfields:
             key = yfield.get('key', yfield['name'])
             self.datas[x].setdefault(key, 0.0)
             if yfield.get('domain'):
                 context = rpc.CONTEXT.copy()
                 context['context'] = context.copy()
                 context['_user'] = rpc._USER
                 for field in model.group.fields:
                     context[field] = model[field].get(model)
                 if not PYSONDecoder(context).decode(yfield['domain']):
                     continue
             if yfield['name'] == '#':
                 self.datas[x][key] += 1
             else:
                 self.datas[x][key] += \
                     float(model[yfield['name']].get(model) or 0)
     if isinstance(minx, datetime.datetime):
         date = minx
         while date <= maxx:
             self.labels[date] = datetime_strftime(date, date_format())
             self.datas.setdefault(date, {})
             for yfield in self.yfields:
                 self.datas[date].setdefault(
                     yfield.get('key', yfield['name']), 0.0)
             date += relativedelta(days=1)
     elif isinstance(minx, datetime.date):
         date = minx
         while date <= maxx:
             self.labels[date] = datetime_strftime(date, date_format())
             self.datas.setdefault(date, {})
             for yfield in self.yfields:
                 self.datas[date].setdefault(
                     yfield.get('key', yfield['name']), 0.0)
             date += relativedelta(days=1)
コード例 #18
0
ファイル: screen_container.py プロジェクト: sm2x/gnuHealth
 def _get_value(self, widget):
     value = widget.props.value
     if value:
         return common.datetime_strftime(
             value,
             widget.props.date_format + ' ' + widget.props.time_format)
コード例 #19
0
 def get_client(self, record):
     value = super(DateField, self).get_client(record)
     if value:
         return datetime_strftime(value, date_format())
     return ''
コード例 #20
0
ファイル: domain_parser.py プロジェクト: coopengo/tryton
 def format_date():
     if not value:
         return ''
     format_ = context.get('date_format', '%x')
     return datetime_strftime(value, format_)
コード例 #21
0
ファイル: screen_container.py プロジェクト: coopengo/tryton
 def _get_value(self, widget):
     value = widget.props.value
     if value:
         return common.datetime_strftime(value,
             widget.props.date_format + ' ' + widget.props.time_format)
コード例 #22
0
ファイル: domain_parser.py プロジェクト: ClemFaure/tryton
 def format_date():
     if not value:
         return ''
     format_ = context.get('date_format', '%x')
     return datetime_strftime(value, format_)
コード例 #23
0
ファイル: domain_parser.py プロジェクト: webmavilchez/tryton
 def format_date():
     if not value:
         return ''
     return datetime_strftime(value, date_format())