Example #1
0
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
#
##############################################################################

from Koo.Common import Api
from Koo.Plugins import Plugins
from Koo import Rpc


## @brief Opens a new window with user's settings for the views of the current model
def editViewSettings(model, id, ids, context):
    domain = [('model', '=', model), ('user', '=', Rpc.session.uid)]
    Api.instance.createWindow(None,
                              'nan.koo.view.settings',
                              mode='tree,form',
                              domain=domain,
                              context=context)


Plugins.register('EditViewSettings', '.*', _('Edit View Settings'),
                 editViewSettings)

# vim:noexpandtab:smartindent:tabstop=8:softtabstop=8:shiftwidth=8:
Example #2
0
            widget.screen.currentView().ensureFieldVisible(field)
        widget.setFixedSize(800, 600)
        widget.ensurePolished()
        widget.show()
        pixmap = QPixmap.grabWidget(widget)
        widget.hide()

        Rpc.session.execute(
            '/object', 'execute', 'ir.documentation.screenshot', 'create', {
                'paragraph_id': paragraph_id,
                'view_id': view_id,
                'user_id': Rpc.session.uid,
                'reference': reference,
                'field': field,
                'image': base64.encodestring(pixmapToData(pixmap))
            }, context)


def pixmapToData(pixmap):
    if pixmap.isNull():
        return False
    bytes = QByteArray()
    buffer = QBuffer(bytes)
    buffer.open(QIODevice.WriteOnly)
    pixmap.save(buffer, "PNG")
    return str(bytes)


Plugins.register('screendocs', 'ir.documentation.paragraph',
                 _('Create Screenshots'), createScreenshots)
Example #3
0
    class DocumentSaverFactory(AbstractImageSaverFactory):
        def __init__(self, context):
            self.context = context

        def create(self, parent):
            saver = DocumentSaver(parent)
            saver.context = self.context
            return saver

    class DocumentSaver(AbstractImageSaver):
        def run(self):
            self.error = True

            image = QBuffer()
            if not self.item.image.save(image, 'PNG'):
                return

            id = Rpc.session.execute(
                '/object', 'execute', 'nan.document', 'create', {
                    'name': str(self.item.name),
                    'datas': base64.encodestring(str(image.buffer())),
                    'filename': _('document.png'),
                }, self.context)
            if not id:
                return

            self.error = False

    Plugins.register('scanner', 'nan.document', _('Scan Documents'), scan)
Example #4
0
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
#
##############################################################################

from Koo.Common import Api
from Koo.Plugins import Plugins
from Koo import Rpc


## @brief Opens a new window with all labels to be translated for the current view.
def searchModelData(model, id, ids, context):
    domain = [('model', '=', model), ('res_id', 'in', ids)]
    Api.instance.createWindow(None,
                              'ir.model.data',
                              mode='tree,form',
                              domain=domain,
                              context=context)


Plugins.register('SearchModelData', '.*', _('Search Model Data'),
                 searchModelData)
Example #5
0
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
#
##############################################################################

from Koo.Common import Api
from Koo.Common import Common
from Koo.Plugins import Plugins
from Koo import Rpc

# @brief Opens a new window with all labels to be translated for the current view.


def translateView(model, id, ids, context):
    domain = ['|', ('name', '=', model), ('name', 'like', '%s,' % model)]
    Api.instance.createWindow(None,
                              'ir.translation',
                              mode='tree,form',
                              domain=domain,
                              context=context)


Plugins.register('ViewTranslator', '.*', _('Translate View'), translateView)
Example #6
0
## @brief Executes the workflow graph report 'workflow.instance.graph'
# including subworkflows.
def printWorkflow(model, id, ids, context):
	# Plugins might be called with no record selected but that doesn't
	# make sense for this plugin so simply return.
	if not id:
		return
	Api.instance.executeReport('workflow.instance.graph', {
		'id' : id,
		'ids' : ids,
		'model' : model,
		'nested' : True,
	}, context=context)

## @brief Executes the workflow graph report 'workflow.instance.graph' without
# subworkflows.
def printSimpleWorkflow(model, id, ids, context):
	# Plugins might be called with no record selected but that doesn't
	# make sense for this plugin so simply return.
	if not id:
		return
	Api.instance.executeReport('workflow.instance.graph', {
		'id' : id,
		'ids' : ids,
		'model' : model,
		'nested' : False,
	}, context=context)

Plugins.register( 'SimpleWorkflowPrinter', '.*', _('Print Workflow'), printSimpleWorkflow )
Plugins.register( 'WorkflowPrinter', '.*', _('Print Workflow (Complex)'), printWorkflow )
Example #7
0
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
#
##############################################################################

from Koo.Common import Api
from Koo.Common import Common
from Koo.Plugins import Plugins
from Koo import Rpc


## @brief Opens a new window with the current model (ir.model) so the user can modify its fields.
def editModel(model, id, ids, context):
    domain = [('model', '=', model)]
    Api.instance.createWindow(None,
                              'ir.model',
                              mode='tree,form',
                              domain=domain,
                              context=context)


Plugins.register('ModelEditor', '.*', _('Edit Model'), editModel)
Example #8
0
        if not directory:
            return
        fileNames = QDir(directory).entryList()
        fileNames = [os.path.join(directory, str(x)) for x in fileNames]
    else:
        fileNames = QFileDialog.getOpenFileNames()
        fileNames = [str(x) for x in fileNames]

    for fileName in fileNames:
        try:
            # As fileName may not be a file, simply try the next file.
            f = open(fileName, 'rb')
        except:
            continue
        try:
            data = base64.encodestring(f.read())
        except:
            continue
        finally:
            f.close()
        id = Rpc.session.execute(
            '/object', 'execute', 'nan.document', 'create', {
                'name': Calendar.dateTimeToText(QDateTime.currentDateTime()),
                'datas': data,
                'filename': os.path.basename(fileName),
            }, context)


Plugins.register('document-importer', 'nan.document', _('Import Documents'),
                 scan)
Example #9
0
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
#
##############################################################################

from Koo.Common import Api
from Koo.Common import Common
from Koo.Plugins import Plugins
from Koo import Rpc

## @brief Opens a new window that allows setting the rating for the current document.
def semantic(model, id, ids, context):
	model_id = Rpc.session.execute( '/object', 'execute', 'ir.model', 'search', [('model','=',model)], 0, 0, False, context )
	ctx = context.copy()
	ctx['subject_model'] = model
	ctx['subject_id'] = id
	domain = [
		('subject_model','=',model_id), 
		('subject_id','=', id)
	]
	Api.instance.createWindow( None, 'nan.semantic.triple', mode='tree,form', domain=domain, context=ctx )

if Common.isKdeAvailable:
	Plugins.register( 'Semantic', '.*', _('Semantic Info'), semantic )
Example #10
0
# garantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
#
##############################################################################

from Koo.Common import Api
from Koo.Common import Common
from Koo.Plugins import Plugins
from Koo import Rpc

## @brief Opens a new window with all views for the current model so the user can modify them.
def editView(model, id, ids, context):
	domain = [('model','=',model)]
	Api.instance.createWindow( None, 'ir.ui.view', mode='tree,form', domain=domain, context=context )

Plugins.register( 'ViewEditor', '.*', _('Edit View'), editView )