lims_interface: readonly data when compilation is validated or done
This commit is contained in:
parent
c4aa1338a7
commit
d6c5aeb441
|
@ -29,6 +29,7 @@ def register():
|
|||
data.GroupedData,
|
||||
module='lims_interface', type_='model')
|
||||
Pool.register(
|
||||
interface.OpenCompilationData,
|
||||
interface.CopyInterfaceColumn,
|
||||
interface.TestFormula,
|
||||
module='lims_interface', type_='wizard')
|
||||
|
|
|
@ -272,6 +272,7 @@ class Data(ModelSQL, ModelView):
|
|||
res = super(Data, cls).fields_get(fields_names)
|
||||
|
||||
table = cls.get_table()
|
||||
readonly = Transaction().context.get('lims_interface_readonly', False)
|
||||
for field in table.fields_:
|
||||
res[field.name] = {
|
||||
'name': field.name,
|
||||
|
@ -279,7 +280,7 @@ class Data(ModelSQL, ModelView):
|
|||
'type': FIELD_TYPE_TRYTON[field.type],
|
||||
'relation': (field.related_model.model if
|
||||
field.related_model else None),
|
||||
'readonly': bool(field.formula),
|
||||
'readonly': bool(readonly or field.formula),
|
||||
'help': field.help,
|
||||
'domain': field.domain,
|
||||
}
|
||||
|
@ -632,6 +633,7 @@ class GroupedData(ModelView):
|
|||
res = super(GroupedData, cls).fields_get(fields_names)
|
||||
|
||||
table = cls.get_table()
|
||||
readonly = Transaction().context.get('lims_interface_readonly', False)
|
||||
for field in table.grouped_fields_:
|
||||
res[field.name] = {
|
||||
'name': field.name,
|
||||
|
@ -639,7 +641,7 @@ class GroupedData(ModelView):
|
|||
'type': FIELD_TYPE_TRYTON[field.type],
|
||||
'relation': (field.related_model.model if
|
||||
field.related_model else None),
|
||||
'readonly': bool(field.formula),
|
||||
'readonly': bool(readonly or field.formula),
|
||||
'help': field.help,
|
||||
'domain': field.domain,
|
||||
}
|
||||
|
|
|
@ -18,10 +18,11 @@ from itertools import chain
|
|||
from trytond.config import config
|
||||
from trytond.model import (Workflow, ModelView, ModelSQL, fields,
|
||||
sequence_ordered, Unique)
|
||||
from trytond.wizard import Wizard, StateTransition, StateView, Button
|
||||
from trytond.wizard import (Wizard, StateTransition, StateView, StateAction,
|
||||
Button)
|
||||
from trytond.pool import Pool
|
||||
from trytond.pyson import PYSONEncoder, Eval, Bool, Not, And, Or
|
||||
from trytond.transaction import Transaction
|
||||
from trytond.pyson import Eval, Bool, Not, And, Or
|
||||
from trytond.i18n import gettext
|
||||
from trytond.exceptions import UserError
|
||||
from .function import custom_functions
|
||||
|
@ -29,8 +30,8 @@ from .function import custom_functions
|
|||
|
||||
__all__ = ['Interface', 'Column', 'CopyInterfaceColumnStart',
|
||||
'CopyInterfaceColumn', 'Compilation', 'CompilationOrigin',
|
||||
'TestFormulaView', 'TestFormulaViewVariable', 'TestFormula',
|
||||
'Variable', 'VariableValue']
|
||||
'OpenCompilationData', 'TestFormulaView', 'TestFormulaViewVariable',
|
||||
'TestFormula', 'Variable', 'VariableValue']
|
||||
|
||||
|
||||
FUNCTIONS = formulas.get_functions()
|
||||
|
@ -990,7 +991,7 @@ class Compilation(Workflow, ModelSQL, ModelView):
|
|||
self.revision = self.interface.revision if self.interface else None
|
||||
|
||||
@classmethod
|
||||
@ModelView.button_action('lims_interface.act_open_compilation_data')
|
||||
@ModelView.button_action('lims_interface.wiz_compilation_open_data')
|
||||
def view_data(cls, compilations):
|
||||
pass
|
||||
|
||||
|
@ -1436,6 +1437,35 @@ class CompilationOrigin(ModelSQL, ModelView):
|
|||
file_name=self.file_name))
|
||||
|
||||
|
||||
class OpenCompilationData(Wizard):
|
||||
'Open Compilation Data'
|
||||
__name__ = 'lims.interface.compilation.open_data'
|
||||
|
||||
start = StateAction('lims_interface.act_open_compilation_data')
|
||||
|
||||
def do_start(self, action):
|
||||
Compilation = Pool().get('lims.interface.compilation')
|
||||
|
||||
context = {
|
||||
'lims_interface_compilation': None,
|
||||
'lims_interface_table': None,
|
||||
'lims_interface_readonly': False,
|
||||
}
|
||||
domain = [('compilation', '=', None)]
|
||||
|
||||
compilation_id = Transaction().context.get('active_id', None)
|
||||
if compilation_id:
|
||||
compilation = Compilation(compilation_id)
|
||||
readonly = (compilation.state in ('validated', 'done'))
|
||||
context['lims_interface_compilation'] = compilation.id
|
||||
context['lims_interface_table'] = compilation.table.id
|
||||
context['lims_interface_readonly'] = readonly
|
||||
domain = [('compilation', '=', compilation.id)]
|
||||
action['pyson_context'] = PYSONEncoder().encode(context)
|
||||
action['pyson_domain'] = PYSONEncoder().encode(domain)
|
||||
return action, {}
|
||||
|
||||
|
||||
class TestFormulaView(ModelView):
|
||||
'Test Formula'
|
||||
__name__ = 'lims.interface.formula.test'
|
||||
|
|
|
@ -127,14 +127,6 @@
|
|||
<field name="model" search="[('model', '=', 'lims.interface.compilation')]"/>
|
||||
</record>
|
||||
|
||||
<!-- Compilation Data -->
|
||||
<record model="ir.action.act_window" id="act_open_compilation_data">
|
||||
<field name="name">Compilation Data</field>
|
||||
<field name="res_model">lims.interface.data</field>
|
||||
<field name="context" eval="{'lims_interface_compilation': Eval('active_id'), 'lims_interface_table': Eval('table')}" pyson="1"/>
|
||||
<field name="domain" eval="[('compilation', '=', Eval('active_id'))]" pyson="1"/>
|
||||
</record>
|
||||
|
||||
<!-- Compilation Origin -->
|
||||
<record model="ir.ui.view" id="lims_interface_compilation_origin_view_form">
|
||||
<field name="model">lims.interface.compilation.origin</field>
|
||||
|
@ -147,6 +139,20 @@
|
|||
<field name="name">compilation_origin_list</field>
|
||||
</record>
|
||||
|
||||
<!-- Wizard Open Compilation Data -->
|
||||
<record model="ir.action.wizard" id="wiz_compilation_open_data">
|
||||
<field name="name">Open Compilation Data</field>
|
||||
<field name="wiz_name">lims.interface.compilation.open_data</field>
|
||||
</record>
|
||||
|
||||
<!-- Compilation Data -->
|
||||
<record model="ir.action.act_window" id="act_open_compilation_data">
|
||||
<field name="name">Compilation Data</field>
|
||||
<field name="res_model">lims.interface.data</field>
|
||||
<field name="context" eval="{'lims_interface_compilation': Eval('active_id'), 'lims_interface_table': Eval('table')}" pyson="1"/>
|
||||
<field name="domain" eval="[('compilation', '=', Eval('active_id'))]" pyson="1"/>
|
||||
</record>
|
||||
|
||||
<!-- Wizard Test Formula -->
|
||||
<record model="ir.ui.view" id="interface_formula_test_view_form">
|
||||
<field name="model">lims.interface.formula.test</field>
|
||||
|
|
|
@ -462,6 +462,10 @@ msgctxt "model:ir.action,name:act_open_compilation_data"
|
|||
msgid "Compilation Data"
|
||||
msgstr "Datos"
|
||||
|
||||
msgctxt "model:ir.action,name:wiz_compilation_open_data"
|
||||
msgid "Open Compilation Data"
|
||||
msgstr "Abrir datos"
|
||||
|
||||
msgctxt "model:ir.action,name:wiz_interface_copy_column"
|
||||
msgid "Copy Interface Column"
|
||||
msgstr "Copiar columna"
|
||||
|
|
Loading…
Reference in New Issue