How to use the tryton.pyson.PYSONDecoder function in tryton

To help you get started, we’ve selected a few tryton examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github tryton / tryton / tryton / gui / window / view_tree / view_tree.py View on Github external
else:
                    if not isinstance(self.fields_type[field]['selection'],
                            (list, tuple)):
                        try:
                            selection = rpc.execute('model',
                                    self.view['model'],
                                    self.fields_type[field]['selection'],
                                    rpc.CONTEXT)
                        except Exception:
                            selection = []
                self.fields_type[field]['selection'] = selection
            elif field_type in ('float', 'numeric'):
                digits = self.fields_type[field].get('digits', (16, 2))
                for obj in res_ids:
                    if isinstance(digits, str):
                        digits = PYSONDecoder(obj).decode(digits)
                    obj[field] = locale.format('%.' + str(digits[1]) + 'f',
                            round(obj[field] or 0.0, digits[1]), True)
            elif field_type in ('integer',):
                for obj in res_ids:
                    obj[field] = locale.format('%d', obj[field] or 0, True)
            elif field_type in ('float_time',):
                conv = None
                if 'float_time' in self.fields_attrs[field]:
                    conv = rpc.CONTEXT.get(
                            self.fields_attrs[field]['float_time'])
                for obj in res_ids:
                    obj[field] = common.float_time_to_text(obj[field], conv)
            elif field_type in ('boolean',):
                for obj in res_ids:
                    obj[field] = bool(obj[field])
        return res_ids