예제 #1
0
    def openPdfManual(self):
        try:
            pdf = Rpc.session.call('/object', 'execute',
                                   'ir.documentation.paragraph',
                                   'export_to_pdf', Rpc.session.context)
        except:
            return False
        if not pdf:
            return False

        pdf = base64.decodestring(pdf)
        fd, fileName = tempfile.mkstemp('.pdf')
        os.write(fd, pdf)
        os.close(fd)
        Common.openFile(fileName)
        return True
예제 #2
0
    def open(self):
        if not self.record.value(self.name):
            return

        # Under windows platforms we need to create the temporary
        # file with an appropiate extension, otherwise the system
        # won't be able to know how to open it. The only way we have
        # to know what kind of file it is, is if the filename property
        # was set, and pick up the extension from that field.
        extension = ''
        if self.fileName() and '.' in self.fileName():
            extension = '.%s' % self.fileName().rpartition('.')[2]
        else:
            extension = ''

        fileName = tempfile.mktemp(extension)
        fp = file(fileName, 'wb+')
        fp.write(self.record.value(self.name))
        fp.close()
        Common.openFile(fileName)
예제 #3
0
    def openApplication(self):
        if not self.getImage():
            return
        extension = ''
        # Under windows platforms we need to create the temporary
        # file with an appropiate extension, otherwise the system
        # won't be able to know how to open it. So we let Qt guess
        # what image format it is and use that as an extension.
        byte = QByteArray(str(self.getImage()))
        buf = QBuffer(byte)
        buf.open(QBuffer.ReadOnly)
        reader = QImageReader(buf)
        if reader.canRead():
            extension = '.%s' % str(reader.format())

        fileName = tempfile.mktemp(extension)
        fp = file(fileName, 'wb')
        fp.write(self.getImage())
        fp.close()
        Common.openFile(fileName)
예제 #4
0
    def inheritView(self):
        view_id = self.attrs.get('x-view')
        if not view_id:
            return
        view_id = re.findall('\d+', view_id)
        if not view_id:
            return
        view_id = int(view_id[0])
        view = Rpc.RpcProxy('ir.ui.view')
        records = view.read([view_id], ['name', 'model', 'xml_id'])
        record = records[0]

        id = record['xml_id'].split('.')[-1]

        arch = """
<openerp>
<data>
    <record model="ir.ui.view" id="%(id)s">
        <field name="name">%(name)s</field>
        <field name="model">%(model)s</field>
	<field name="type">form</field>
        <field name="inherit_id" ref="%(xml_id)s"/>
        <field name="arch" type="xml">
            <field name="%(field)s" position="after">
		<field name=""/>
            </field>
        </field>
    </record>
</data>
</openerp>""" % {
            'id': id,
            'name': record['name'],
            'model': record['model'],
            'xml_id': record['xml_id'],
            'field': self.attrs.get('name', ''),
        }
        fd, fileName = tempfile.mkstemp(suffix='.txt')
        os.write(fd, arch)
        os.close(fd)
        Common.openFile(fileName)
예제 #5
0
 def open(fileName):
     Common.openFile(fileName)
예제 #6
0
 def openApplication(self):
     fileName = self.record.value(self.name)
     if not fileName:
         return
     Common.openFile(fileName)