diff --git a/CHANGELOG b/CHANGELOG
index 1bbed0167b..aa6c5567c7 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,3 +1,4 @@
+* Add ir.action.wizard_size to store prefered wizard size
* Add delete_all action on One2Many field
* Read, write, create, delete permission on record rules
* Add reset_default method to ir.default
diff --git a/trytond/ir/action.py b/trytond/ir/action.py
index 89fb679a1e..5e346b8490 100644
--- a/trytond/ir/action.py
+++ b/trytond/ir/action.py
@@ -2,7 +2,7 @@
#this repository contains the full copyright notices and license terms.
"Action"
from trytond.model import ModelView, ModelSQL, fields
-from trytond.tools import file_open
+from trytond.tools import file_open, Cache
from trytond.backend import TableHandler
import base64
import os
@@ -483,6 +483,100 @@ class ActionWizard(ModelSQL, ModelView):
ActionWizard()
+class ActionWizardSize(ModelSQL, ModelView):
+ "Action Wizard Size"
+ _name = 'ir.action.wizard_size'
+ _description = __doc__
+ wizard = fields.Char('Wizard', required=True, select=1)
+ model = fields.Char('Model', required=True, select=1)
+ user = fields.Many2One('res.user', 'User', required=True,
+ ondelete='CASCADE', select=1)
+ width = fields.Integer('Width')
+ height = fields.Integer('Height')
+
+ def __init__(self):
+ super(ActionWizardSize, self).__init__()
+ self._rpc.update({
+ 'set_size': True,
+ })
+
+ def create(self, cursor, user, vals, context=None):
+ res = super(ActionWizardSize, self).create(cursor, user, vals,
+ context=context)
+ # Restart the cache for get_size
+ self.get_size(cursor.dbname)
+ return res
+
+ def write(self, cursor, user, ids, vals, context=None):
+ res = super(ActionWizardSize, self).write(cursor, user, ids,
+ vals, context=context)
+ # Restart the cache for get_size
+ self.get_size(cursor.dbname)
+ return res
+
+ def delete(self, cursor, user, ids, context=None):
+ res = super(ActionWizardSize, self).delete(cursor, user, ids,
+ context=context)
+ # Restart the cache for get_size
+ self.get_size(cursor.dbname)
+ return res
+
+ def set_size(self, cursor, user, wizard, model, width, height,
+ context=None):
+ '''
+ Set size for wizard dialog.
+ :param cursor: the database cursor
+ :param user: the user id
+ :param wizard: the wizard name
+ :param model: the model name
+ :param width: the width
+ :param height: the height
+ :param context: the context
+ '''
+ ids = self.search(cursor, user, [
+ ('user', '=', user),
+ ('wizard', '=', wizard),
+ ('model', '=', model),
+ ], context=context)
+ if ids:
+ self.write(cursor, user, ids, {
+ 'width': width,
+ 'height': height,
+ }, context=context)
+ else:
+ self.create(cursor, user, {
+ 'wizard': wizard,
+ 'model': model,
+ 'user': user,
+ 'width': width,
+ 'height': height,
+ }, context=context)
+
+ def get_size(self, cursor, user, wizard, model, context=None):
+ '''
+ Get size for wizard dialog.
+ :param cursor: the database cursor
+ :param user: the user id
+ :param wizard: the wizard name
+ :param model: the model name
+ :param context: the context
+ :return: (width, height)
+ '''
+ ids = self.search(cursor, user, [
+ ('user', '=', user),
+ ('wizard', '=', wizard),
+ ('model', '=', model),
+ ], limit=1, context=context)
+ if ids:
+ wizard_size = self.browse(cursor, user, ids[0], context=context)
+ return wizard_size.width, wizard_size.height
+ return (0, 0)
+
+ get_size = Cache('ir.action.wizard_size.get_size')(get_size)
+
+ActionWizardSize()
+
+
class ActionURL(ModelSQL, ModelView):
"Action URL"
_name = 'ir.action.url'
diff --git a/trytond/ir/action.xml b/trytond/ir/action.xml
index 64d42bc6e6..bdd334390d 100644
--- a/trytond/ir/action.xml
+++ b/trytond/ir/action.xml
@@ -307,6 +307,64 @@ this repository contains the full copyright notices and license terms. -->
+
+ ir.action.wizard_size
+ form
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ ]]>
+
+
+
+
+ ir.action.wizard_size
+ tree
+
+
+
+
+
+
+
+
+ ]]>
+
+
+
+ Wizard Sizes
+ ir.action.act_window
+ ir.action.wizard_size
+ form
+
+
+
+
+
+
+
+
+
+
+
+
+
ir.action.url
form
diff --git a/trytond/wizard/wizard.py b/trytond/wizard/wizard.py
index 4c8aab408a..91252ed2d3 100644
--- a/trytond/wizard/wizard.py
+++ b/trytond/wizard/wizard.py
@@ -131,6 +131,7 @@ class Wizard(object):
def execute(self, cursor, user, wiz_id, data, state='init', context=None):
translation_obj = self.pool.get('ir.translation')
+ wizard_size_obj = self.pool.get('ir.action.wizard_size')
if context is None:
context = {}
res = {}
@@ -192,6 +193,8 @@ class Wizard(object):
res['fields'] = fields
res['arch'] = arch
res['state'] = button_list
+ res['size'] = wizard_size_obj.get_size(cursor, user, self._name,
+ result_def['object'], context=context)
elif result_def['type'] == 'choice':
next_state = getattr(self, result_def['next_state'])(cursor, user,
data, context)