lims_industry: edit sample wizard: add controls

This commit is contained in:
Adrián Bernardi 2020-12-29 17:13:17 -03:00
parent 8558c3d5db
commit 0618cd4311
3 changed files with 31 additions and 5 deletions

View File

@ -807,6 +807,14 @@ msgctxt "model:ir.message,text:msg_edit_results_report_party"
msgid "Sample \"%(sample)s\" has a Results report already released"
msgstr "La muestra «%(sample)s» tiene un Informe de resultados ya publicado"
msgctxt "model:ir.message,text:msg_edit_sample_component"
msgid "The Component in sample \"%(sample)s\" does not belong to the Equipment"
msgstr "El componente de la muestra «%(sample)s» no pertenece al equipo"
msgctxt "model:ir.message,text:msg_edit_sample_equipment"
msgid "The Equipment in sample \"%(sample)s\" does not belong to the Party"
msgstr "El equipo de la muestra «%(sample)s» no pertenece a la entidad"
msgctxt "model:ir.message,text:msg_equipment_name_unique"
msgid "There is already an equipment with the same name for the plant"
msgstr "Ya existe un equipo con el mismo nombre para la planta"

View File

@ -49,6 +49,12 @@
<record model="ir.message" id="msg_equipment_template_unique">
<field name="text">There is already a equipment template with the same type, brand and model</field>
</record>
<record model="ir.message" id="msg_edit_sample_equipment">
<field name="text">The Equipment in sample "%(sample)s" does not belong to the Party</field>
</record>
<record model="ir.message" id="msg_edit_sample_component">
<field name="text">The Component in sample "%(sample)s" does not belong to the Equipment</field>
</record>
<record model="ir.message" id="msg_edit_entry_party">
<field name="text">You must select all samples from the same entry to change the Party</field>
</record>

View File

@ -602,8 +602,11 @@ class EditSample(Wizard):
for sample in samples:
check_typifications = False
log = []
sample_party = sample.party
if (self.start.party and
self.start.party != sample.party):
sample_party = self.start.party
log.append({
'sample': sample.id,
'field': 'party',
@ -621,7 +624,11 @@ class EditSample(Wizard):
sample.equipment.rec_name or None),
'final_value': self.start.equipment.rec_name,
})
sample.equipment = self.start.equipment.id
sample.equipment = self.start.equipment
if (sample.equipment and sample.equipment.party != sample_party):
raise UserError(gettext(
'lims_industry.msg_edit_sample_equipment',
sample=sample.rec_name))
if (self.start.component and
self.start.component != sample.component):
@ -632,7 +639,7 @@ class EditSample(Wizard):
sample.component.rec_name or None),
'final_value': self.start.component.rec_name,
})
sample.component = self.start.component.id
sample.component = self.start.component
if (self.start.component.product_type and
self.start.component.product_type !=
sample.product_type):
@ -644,7 +651,12 @@ class EditSample(Wizard):
'final_value': (
self.start.component.product_type.rec_name),
})
sample.product_type = self.start.component.product_type.id
sample.product_type = self.start.component.product_type
if (sample.component and (not sample.equipment or
sample.component.equipment != sample.equipment)):
raise UserError(gettext(
'lims_industry.msg_edit_sample_component',
sample=sample.rec_name))
if (self.start.comercial_product and
self.start.comercial_product != sample.comercial_product):
@ -655,7 +667,7 @@ class EditSample(Wizard):
sample.comercial_product.rec_name),
'final_value': self.start.comercial_product.rec_name,
})
sample.comercial_product = self.start.comercial_product.id
sample.comercial_product = self.start.comercial_product
if (self.start.comercial_product.matrix and
self.start.comercial_product.matrix !=
self.start.comercial_product.matrix):
@ -667,7 +679,7 @@ class EditSample(Wizard):
'final_value': (
self.start.comercial_product.matrix.rec_name),
})
sample.matrix = self.start.comercial_product.matrix.id
sample.matrix = self.start.comercial_product.matrix
if check_typifications:
self.check_typifications(sample)