mirror of
https://github.com/Kalenis/kalenislims.git
synced 2023-12-14 07:13:04 +01:00
lims: copy/move typification: show when additional is not typified
This commit is contained in:
parent
87c5723688
commit
22868d6c65
|
@ -111,6 +111,7 @@ def register():
|
||||||
sample.DuplicateSampleFromEntryStart,
|
sample.DuplicateSampleFromEntryStart,
|
||||||
analysis.CopyTypificationStart,
|
analysis.CopyTypificationStart,
|
||||||
analysis.CopyTypificationConfirm,
|
analysis.CopyTypificationConfirm,
|
||||||
|
analysis.CopyTypificationError,
|
||||||
analysis.CopyCalculatedTypificationStart,
|
analysis.CopyCalculatedTypificationStart,
|
||||||
analysis.UpdateTypificationStart,
|
analysis.UpdateTypificationStart,
|
||||||
analysis.RelateAnalysisStart,
|
analysis.RelateAnalysisStart,
|
||||||
|
|
|
@ -2088,6 +2088,13 @@ class CopyTypificationConfirm(ModelView):
|
||||||
summary = fields.Text('Summary', readonly=True)
|
summary = fields.Text('Summary', readonly=True)
|
||||||
|
|
||||||
|
|
||||||
|
class CopyTypificationError(ModelView):
|
||||||
|
'Copy/Move Typification'
|
||||||
|
__name__ = 'lims.typification.copy.error'
|
||||||
|
|
||||||
|
message = fields.Text('Message', readonly=True)
|
||||||
|
|
||||||
|
|
||||||
class CopyTypification(Wizard):
|
class CopyTypification(Wizard):
|
||||||
'Copy/Move Typification'
|
'Copy/Move Typification'
|
||||||
__name__ = 'lims.typification.copy'
|
__name__ = 'lims.typification.copy'
|
||||||
|
@ -2103,6 +2110,10 @@ class CopyTypification(Wizard):
|
||||||
Button('Confirm', 'confirm', 'tryton-ok', default=True),
|
Button('Confirm', 'confirm', 'tryton-ok', default=True),
|
||||||
])
|
])
|
||||||
confirm = StateTransition()
|
confirm = StateTransition()
|
||||||
|
error = StateView('lims.typification.copy.error',
|
||||||
|
'lims.lims_copy_typification_error_view_form', [
|
||||||
|
Button('Cancel', 'end', 'tryton-cancel', default=True),
|
||||||
|
])
|
||||||
|
|
||||||
def default_ask(self, fields):
|
def default_ask(self, fields):
|
||||||
summary = '%s\n' % gettext(
|
summary = '%s\n' % gettext(
|
||||||
|
@ -2160,10 +2171,15 @@ class CopyTypification(Wizard):
|
||||||
|
|
||||||
return {'summary': summary}
|
return {'summary': summary}
|
||||||
|
|
||||||
|
def default_error(self, fields):
|
||||||
|
return {'message': self.error.message}
|
||||||
|
|
||||||
def transition_confirm(self):
|
def transition_confirm(self):
|
||||||
cursor = Transaction().connection.cursor()
|
cursor = Transaction().connection.cursor()
|
||||||
pool = Pool()
|
pool = Pool()
|
||||||
Typification = pool.get('lims.typification')
|
Typification = pool.get('lims.typification')
|
||||||
|
ProductType = pool.get('lims.product.type')
|
||||||
|
Matrix = pool.get('lims.matrix')
|
||||||
|
|
||||||
clause = [
|
clause = [
|
||||||
('valid', '=', True),
|
('valid', '=', True),
|
||||||
|
@ -2176,11 +2192,6 @@ class CopyTypification(Wizard):
|
||||||
clause.append(('method', '=', self.start.origin_method.id))
|
clause.append(('method', '=', self.start.origin_method.id))
|
||||||
|
|
||||||
origins = Typification.search(clause)
|
origins = Typification.search(clause)
|
||||||
if origins and self.start.action == 'move':
|
|
||||||
Typification.write(origins, {
|
|
||||||
'valid': False,
|
|
||||||
'by_default': False,
|
|
||||||
})
|
|
||||||
|
|
||||||
product_type_id = self.start.destination_product_type.id
|
product_type_id = self.start.destination_product_type.id
|
||||||
if self.start.action == 'copy':
|
if self.start.action == 'copy':
|
||||||
|
@ -2190,6 +2201,7 @@ class CopyTypification(Wizard):
|
||||||
method_id = (self.start.destination_method.id if
|
method_id = (self.start.destination_method.id if
|
||||||
self.start.destination_method else None)
|
self.start.destination_method else None)
|
||||||
|
|
||||||
|
error_additionals = ''
|
||||||
to_copy = {}
|
to_copy = {}
|
||||||
new_by_defaults = []
|
new_by_defaults = []
|
||||||
for origin in origins:
|
for origin in origins:
|
||||||
|
@ -2200,6 +2212,7 @@ class CopyTypification(Wizard):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
for matrix_id in matrix_ids:
|
for matrix_id in matrix_ids:
|
||||||
|
# check if typification already exists
|
||||||
cursor.execute('SELECT COUNT(*) '
|
cursor.execute('SELECT COUNT(*) '
|
||||||
'FROM "' + Typification._table + '" '
|
'FROM "' + Typification._table + '" '
|
||||||
'WHERE product_type = %s '
|
'WHERE product_type = %s '
|
||||||
|
@ -2211,6 +2224,29 @@ class CopyTypification(Wizard):
|
||||||
if cursor.fetchone()[0] != 0:
|
if cursor.fetchone()[0] != 0:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
# check if additionals are typified
|
||||||
|
for a in origin.additionals:
|
||||||
|
cursor.execute('SELECT COUNT(*) '
|
||||||
|
'FROM "' + Typification._table + '" '
|
||||||
|
'WHERE product_type = %s '
|
||||||
|
'AND matrix = %s '
|
||||||
|
'AND analysis = %s '
|
||||||
|
'AND valid IS TRUE',
|
||||||
|
(product_type_id, matrix_id, a.id))
|
||||||
|
if cursor.fetchone()[0] == 0:
|
||||||
|
error_additionals += '* %s\n' % gettext('lims.msg_not_typified',
|
||||||
|
analysis=a.rec_name,
|
||||||
|
product_type=ProductType(product_type_id).rec_name,
|
||||||
|
matrix=Matrix(matrix_id).rec_name)
|
||||||
|
if error_additionals:
|
||||||
|
continue
|
||||||
|
|
||||||
|
if self.start.action == 'move':
|
||||||
|
Typification.write([origin], {
|
||||||
|
'valid': False,
|
||||||
|
'by_default': False,
|
||||||
|
})
|
||||||
|
|
||||||
if origin not in to_copy:
|
if origin not in to_copy:
|
||||||
to_copy[origin] = []
|
to_copy[origin] = []
|
||||||
|
|
||||||
|
@ -2239,6 +2275,12 @@ class CopyTypification(Wizard):
|
||||||
|
|
||||||
to_copy[origin].append(default)
|
to_copy[origin].append(default)
|
||||||
|
|
||||||
|
if error_additionals:
|
||||||
|
self.error.message = '%s\n%s' % (
|
||||||
|
gettext('lims.msg_typification_copy_additional'),
|
||||||
|
error_additionals)
|
||||||
|
return 'error'
|
||||||
|
|
||||||
for typification, defaults in to_copy.items():
|
for typification, defaults in to_copy.items():
|
||||||
for default in defaults:
|
for default in defaults:
|
||||||
Typification.copy([typification], default=default)
|
Typification.copy([typification], default=default)
|
||||||
|
|
|
@ -493,6 +493,11 @@
|
||||||
<field name="type">form</field>
|
<field name="type">form</field>
|
||||||
<field name="name">typification_copy_confirm_form</field>
|
<field name="name">typification_copy_confirm_form</field>
|
||||||
</record>
|
</record>
|
||||||
|
<record model="ir.ui.view" id="lims_copy_typification_error_view_form">
|
||||||
|
<field name="model">lims.typification.copy.error</field>
|
||||||
|
<field name="type">form</field>
|
||||||
|
<field name="name">typification_copy_error_form</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
<record model="ir.action.wizard" id="wiz_lims_copy_typification">
|
<record model="ir.action.wizard" id="wiz_lims_copy_typification">
|
||||||
<field name="name">Copy/Move Typification</field>
|
<field name="name">Copy/Move Typification</field>
|
||||||
|
|
|
@ -6195,6 +6195,10 @@ msgctxt "field:lims.typification.copy.confirm,summary:"
|
||||||
msgid "Summary"
|
msgid "Summary"
|
||||||
msgstr "Resumen"
|
msgstr "Resumen"
|
||||||
|
|
||||||
|
msgctxt "field:lims.typification.copy.error,message:"
|
||||||
|
msgid "Message"
|
||||||
|
msgstr "Mensaje"
|
||||||
|
|
||||||
msgctxt "field:lims.typification.copy.start,action:"
|
msgctxt "field:lims.typification.copy.start,action:"
|
||||||
msgid "Action"
|
msgid "Action"
|
||||||
msgstr "Acción"
|
msgstr "Acción"
|
||||||
|
@ -8252,6 +8256,10 @@ msgctxt "model:ir.message,text:msg_typification_copy_action"
|
||||||
msgid "You are going to %(action)s"
|
msgid "You are going to %(action)s"
|
||||||
msgstr "Está por %(action)s"
|
msgstr "Está por %(action)s"
|
||||||
|
|
||||||
|
msgctxt "model:ir.message,text:msg_typification_copy_additional"
|
||||||
|
msgid "Missing typification for additional analysis:"
|
||||||
|
msgstr "Falta tipificación para análisis adicional:"
|
||||||
|
|
||||||
msgctxt "model:ir.message,text:msg_typification_copy_analysis"
|
msgctxt "model:ir.message,text:msg_typification_copy_analysis"
|
||||||
msgid " * Analysis: %(analysis)s"
|
msgid " * Analysis: %(analysis)s"
|
||||||
msgstr " * Análisis: %(analysis)s"
|
msgstr " * Análisis: %(analysis)s"
|
||||||
|
@ -9761,6 +9769,10 @@ msgctxt "model:lims.typification.copy.confirm,name:"
|
||||||
msgid "Copy/Move Typification"
|
msgid "Copy/Move Typification"
|
||||||
msgstr "Copiar/Mover tipificación"
|
msgstr "Copiar/Mover tipificación"
|
||||||
|
|
||||||
|
msgctxt "model:lims.typification.copy.error,name:"
|
||||||
|
msgid "Copy/Move Typification"
|
||||||
|
msgstr "Copiar/Mover tipificación"
|
||||||
|
|
||||||
msgctxt "model:lims.typification.copy.start,name:"
|
msgctxt "model:lims.typification.copy.start,name:"
|
||||||
msgid "Copy/Move Typification"
|
msgid "Copy/Move Typification"
|
||||||
msgstr "Copiar/Mover tipificación"
|
msgstr "Copiar/Mover tipificación"
|
||||||
|
@ -15324,6 +15336,10 @@ msgctxt "wizard_button:lims.typification.copy,ask,end:"
|
||||||
msgid "Cancel"
|
msgid "Cancel"
|
||||||
msgstr "Cancelar"
|
msgstr "Cancelar"
|
||||||
|
|
||||||
|
msgctxt "wizard_button:lims.typification.copy,error,end:"
|
||||||
|
msgid "Cancel"
|
||||||
|
msgstr "Cancelar"
|
||||||
|
|
||||||
msgctxt "wizard_button:lims.typification.copy,start,ask:"
|
msgctxt "wizard_button:lims.typification.copy,start,ask:"
|
||||||
msgid "Continue"
|
msgid "Continue"
|
||||||
msgstr "Continuar"
|
msgstr "Continuar"
|
||||||
|
|
|
@ -529,6 +529,9 @@
|
||||||
<record model="ir.message" id="msg_typification_copy_matrices">
|
<record model="ir.message" id="msg_typification_copy_matrices">
|
||||||
<field name="text"> * Matrices:</field>
|
<field name="text"> * Matrices:</field>
|
||||||
</record>
|
</record>
|
||||||
|
<record model="ir.message" id="msg_typification_copy_additional">
|
||||||
|
<field name="text">Missing typification for additional analysis:</field>
|
||||||
|
</record>
|
||||||
<record model="ir.message" id="msg_additional_no_method">
|
<record model="ir.message" id="msg_additional_no_method">
|
||||||
<field name="text">Missing typification for additional analysis "%(additional)s" of analysis "%(analysis)s".</field>
|
<field name="text">Missing typification for additional analysis "%(additional)s" of analysis "%(analysis)s".</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
4
lims/view/typification_copy_error_form.xml
Normal file
4
lims/view/typification_copy_error_form.xml
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
<?xml version="1.0"?>
|
||||||
|
<form>
|
||||||
|
<field name="message" colspan="4" height="300"/>
|
||||||
|
</form>
|
Loading…
Reference in a new issue