Add ir.action.wizard_size to store prefered wizard size
This commit is contained in:
@@ -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
|
||||
|
||||
+95
-1
@@ -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'
|
||||
|
||||
@@ -307,6 +307,64 @@ this repository contains the full copyright notices and license terms. -->
|
||||
<menuitem parent="menu_action"
|
||||
action="act_action_wizard_form" id="menu_action_wizard"/>
|
||||
|
||||
<record model="ir.ui.view" id="action_wizard_size_view_form">
|
||||
<field name="model">ir.action.wizard_size</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<![CDATA[
|
||||
<form string="Wizard Size">
|
||||
<label name="wizard"/>
|
||||
<field name="wizard"/>
|
||||
<label name="model"/>
|
||||
<field name="model"/>
|
||||
<label name="user"/>
|
||||
<field name="user"/>
|
||||
<newline/>
|
||||
<label name="width"/>
|
||||
<field name="width"/>
|
||||
<label name="height"/>
|
||||
<field name="height"/>
|
||||
</form>
|
||||
]]>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.ui.view" id="action_wizard_size_view_tree">
|
||||
<field name="model">ir.action.wizard_size</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="arch" type="xml">
|
||||
<![CDATA[
|
||||
<tree string="Wizard Sizes">
|
||||
<field name="wizard"/>
|
||||
<field name="model"/>
|
||||
<field name="user"/>
|
||||
<field name="width"/>
|
||||
<field name="height"/>
|
||||
</tree>
|
||||
]]>
|
||||
</field>
|
||||
</record>
|
||||
<record model="ir.action.act_window" id="act_action_wizard_size_form">
|
||||
<field name="name">Wizard Sizes</field>
|
||||
<field name="type">ir.action.act_window</field>
|
||||
<field name="res_model">ir.action.wizard_size</field>
|
||||
<field name="view_type">form</field>
|
||||
</record>
|
||||
<record model="ir.action.act_window.view"
|
||||
id="act_action_wizard_size_form_view1">
|
||||
<field name="sequence" eval="1"/>
|
||||
<field name="view" ref="action_wizard_size_view_tree"/>
|
||||
<field name="act_window" ref="act_action_wizard_size_form"/>
|
||||
</record>
|
||||
<record model="ir.action.act_window.view"
|
||||
id="act_action_wizard_size_form_view2">
|
||||
<field name="sequence" eval="2"/>
|
||||
<field name="view" ref="action_wizard_size_view_form"/>
|
||||
<field name="act_window" ref="act_action_wizard_size_form"/>
|
||||
</record>
|
||||
<menuitem parent="menu_action_wizard"
|
||||
action="act_action_wizard_size_form" id="menu_action_wizard_size"/>
|
||||
|
||||
<record model="ir.ui.view" id="action_url_view_form">
|
||||
<field name="model">ir.action.url</field>
|
||||
<field name="type">form</field>
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user