mirror of
https://github.com/Kalenis/kalenislims.git
synced 2023-12-14 07:13:04 +01:00
lims_interface: define decimals in float/numeric columns
This commit is contained in:
parent
083234ea84
commit
4b4658934c
5 changed files with 36 additions and 2 deletions
|
@ -78,7 +78,6 @@ class Adapter:
|
|||
obj.name = 'notebook_line'
|
||||
obj.readonly = True
|
||||
res['notebook_line'] = obj
|
||||
|
||||
return res
|
||||
|
||||
|
||||
|
@ -273,6 +272,7 @@ class Data(ModelSQL, ModelView):
|
|||
|
||||
table = cls.get_table()
|
||||
readonly = Transaction().context.get('lims_interface_readonly', False)
|
||||
encoder = PYSONEncoder()
|
||||
for field in table.fields_:
|
||||
res[field.name] = {
|
||||
'name': field.name,
|
||||
|
@ -298,6 +298,8 @@ class Data(ModelSQL, ModelView):
|
|||
if field.type in ['datetime', 'timestamp']:
|
||||
res[field.name]['format'] = PYSONEncoder().encode(
|
||||
'%H:%M:%S.%f')
|
||||
if field.type in ['float', 'numeric']:
|
||||
res[field.name]['digits'] = encoder.encode((16, field.digits))
|
||||
return res
|
||||
|
||||
@classmethod
|
||||
|
@ -634,6 +636,7 @@ class GroupedData(ModelView):
|
|||
|
||||
table = cls.get_table()
|
||||
readonly = Transaction().context.get('lims_interface_readonly', False)
|
||||
encoder = PYSONEncoder()
|
||||
for field in table.grouped_fields_:
|
||||
res[field.name] = {
|
||||
'name': field.name,
|
||||
|
@ -659,6 +662,8 @@ class GroupedData(ModelView):
|
|||
if field.type in ['datetime', 'timestamp']:
|
||||
res[field.name]['format'] = PYSONEncoder().encode(
|
||||
'%H:%M:%S.%f')
|
||||
if field.type in ['float', 'numeric']:
|
||||
res[field.name]['digits'] = encoder.encode((16, field.digits))
|
||||
return res
|
||||
|
||||
@classmethod
|
||||
|
|
|
@ -354,6 +354,7 @@ class Interface(Workflow, ModelSQL, ModelView):
|
|||
column.expression.startswith('=') else
|
||||
None),
|
||||
readonly=column.readonly,
|
||||
digits=column.digits,
|
||||
))
|
||||
continue
|
||||
|
||||
|
@ -373,6 +374,7 @@ class Interface(Workflow, ModelSQL, ModelView):
|
|||
expression.startswith('=') else
|
||||
None),
|
||||
readonly=column.readonly,
|
||||
digits=column.digits,
|
||||
))
|
||||
|
||||
expression = (column.expression and
|
||||
|
@ -389,6 +391,7 @@ class Interface(Workflow, ModelSQL, ModelView):
|
|||
formula=(expression if expression and
|
||||
expression.startswith('=') else None),
|
||||
readonly=column.readonly,
|
||||
digits=column.digits,
|
||||
))
|
||||
|
||||
table.fields_ = fields
|
||||
|
@ -657,6 +660,11 @@ class Column(sequence_ordered(), ModelSQL, ModelView):
|
|||
states={'readonly': Bool(Eval('expression'))},
|
||||
depends=['expression'])
|
||||
readonly = fields.Boolean('Read only')
|
||||
digits = fields.Integer('Digits',
|
||||
states={
|
||||
'required': Eval('type_').in_(['float', 'numeric']),
|
||||
'invisible': ~Eval('type_').in_(['float', 'numeric']),
|
||||
}, depends=['type_'])
|
||||
source_start = fields.Integer('Field start',
|
||||
states={
|
||||
'required': Eval('_parent_interface', {}).get(
|
||||
|
@ -713,6 +721,10 @@ class Column(sequence_ordered(), ModelSQL, ModelView):
|
|||
'lims_interface.msg_interface_column_alias_unique')
|
||||
]
|
||||
|
||||
@staticmethod
|
||||
def default_digits():
|
||||
return 2
|
||||
|
||||
@fields.depends('default_value', 'expression', 'singleton',
|
||||
'source_column')
|
||||
def on_change_default_value(self):
|
||||
|
@ -910,6 +922,7 @@ class CopyInterfaceColumn(Wizard):
|
|||
'related_line_field': (origin.related_line_field and
|
||||
origin.related_line_field.id or None),
|
||||
'grouped': origin.grouped,
|
||||
'digits': origin.digits,
|
||||
}
|
||||
return res
|
||||
|
||||
|
|
|
@ -78,6 +78,10 @@ msgctxt "field:lims.interface.column,default_value:"
|
|||
msgid "Default value"
|
||||
msgstr "Valor por defecto"
|
||||
|
||||
msgctxt "field:lims.interface.column,digits:"
|
||||
msgid "Digits"
|
||||
msgstr "Dígitos"
|
||||
|
||||
msgctxt "field:lims.interface.column,domain:"
|
||||
msgid "Domain Value"
|
||||
msgstr "Dominio"
|
||||
|
@ -266,6 +270,10 @@ msgctxt "field:lims.interface.table,views:"
|
|||
msgid "Views"
|
||||
msgstr "Vistas"
|
||||
|
||||
msgctxt "field:lims.interface.table.field,digits:"
|
||||
msgid "Digits"
|
||||
msgstr "Dígitos"
|
||||
|
||||
msgctxt "field:lims.interface.table.field,domain:"
|
||||
msgid "Domain Value"
|
||||
msgstr "Dominio"
|
||||
|
@ -314,6 +322,10 @@ msgctxt "field:lims.interface.table.field,type:"
|
|||
msgid "Field Type"
|
||||
msgstr "Tipo de campo"
|
||||
|
||||
msgctxt "field:lims.interface.table.grouped_field,digits:"
|
||||
msgid "Digits"
|
||||
msgstr "Dígitos"
|
||||
|
||||
msgctxt "field:lims.interface.table.grouped_field,domain:"
|
||||
msgid "Domain Value"
|
||||
msgstr "Dominio"
|
||||
|
|
|
@ -94,6 +94,7 @@ class TableField(ModelSQL, ModelView):
|
|||
inputs = fields.Function(fields.Char('On Change With Inputs'),
|
||||
'get_inputs')
|
||||
readonly = fields.Boolean('Read only')
|
||||
digits = fields.Integer('Digits')
|
||||
|
||||
def get_inputs(self, name=None):
|
||||
if not self.formula:
|
||||
|
@ -125,6 +126,7 @@ class TableGroupedField(ModelSQL, ModelView):
|
|||
inputs = fields.Function(fields.Char('On Change With Inputs'),
|
||||
'get_inputs')
|
||||
readonly = fields.Boolean('Read only')
|
||||
digits = fields.Integer('Digits')
|
||||
|
||||
def get_inputs(self, name=None):
|
||||
if not self.formula:
|
||||
|
|
|
@ -8,11 +8,13 @@
|
|||
<label name="evaluation_order"/>
|
||||
<field name="evaluation_order" xexpand="0"/>
|
||||
</group>
|
||||
<group id="type" colspan="4" col="4">
|
||||
<group id="type" colspan="4" col="6">
|
||||
<label name="type_"/>
|
||||
<field name="type_"/>
|
||||
<label name="related_model"/>
|
||||
<field name="related_model"/>
|
||||
<label name="digits"/>
|
||||
<field name="digits" xexpand="0"/>
|
||||
</group>
|
||||
<group id="expression" colspan="4" col="3">
|
||||
<label name="expression"/>
|
||||
|
|
Loading…
Reference in a new issue