Ejemplo n.º 1
0
 def open_data(attachment, context):
     try:
         value, = RPCExecute('model', 'ir.attachment', 'read',
             [attachment['id']], ['data'], context=context)
     except RPCException:
         return
     filepath = file_write(attachment['name'], value['data'])
     file_open(filepath)
Ejemplo n.º 2
0
 def clicked(self, renderer, path):
     record, field = self._get_record_field_from_path(path)
     filename_field = record.group.fields.get(self.attrs.get('filename'))
     filename = filename_field.get(record)
     file_path = file_write(filename, self.binary.get_data(record, field))
     root, type_ = os.path.splitext(filename)
     if type_:
         type_ = type_[1:]
     GLib.idle_add(file_open, file_path, type_)
Ejemplo n.º 3
0
 def callback(result):
     try:
         result = result()
     except RPCException:
         return
     type, data, print_p, name = result
     if not print_p and direct_print:
         print_p = True
     fp_name = file_write((name, type), data)
     file_open(fp_name, type, print_p=print_p)
Ejemplo n.º 4
0
 def open_(self, widget=None):
     if not self.filename_field:
         return
     filename = self.filename_field.get(self.record)
     if not filename:
         return
     file_path = file_write(filename, self.get_data())
     root, type_ = os.path.splitext(filename)
     if type_:
         type_ = type_[1:]
     file_open(file_path, type_)
Ejemplo n.º 5
0
 def open_binary(self, renderer, path):
     if not self.filename:
         return
     record, field = self._get_record_field(path)
     filename_field = record.group.fields.get(self.filename)
     filename = filename_field.get(record)
     if not filename:
         return
     file_path = file_write(filename, self.get_data(record, field))
     root, type_ = os.path.splitext(filename)
     if type_:
         type_ = type_[1:]
     file_open(file_path, type_)
Ejemplo n.º 6
0
    def exec_report(name,
                    data,
                    direct_print=False,
                    email_print=False,
                    email=None,
                    context=None):
        if context is None:
            context = {}
        if email is None:
            email = {}
        data = data.copy()
        ctx = rpc.CONTEXT.copy()
        ctx.update(context)
        ctx['direct_print'] = direct_print
        ctx['email_print'] = email_print
        ctx['email'] = email
        args = ('report', name, 'execute', data.get('ids', []), data, ctx)
        try:
            res = RPCProgress('execute', args).run()
        except RPCException:
            return False
        if not res:
            return False
        (type, data, print_p, name) = res
        if not print_p and direct_print:
            print_p = True

        fp_name = file_write((name, type), data)
        if email_print:
            mailto(to=email.get('to'),
                   cc=email.get('cc'),
                   subject=email.get('subject'),
                   body=email.get('body'),
                   attachment=fp_name)
        else:
            file_open(fp_name, type, print_p=print_p)
        return True