lims_project_implementation: change supplies domain

This commit is contained in:
Adrián Bernardi 2022-08-22 19:59:59 -03:00
parent 69b960d76b
commit 6fef39f779
3 changed files with 32 additions and 1 deletions

View File

@ -46,6 +46,10 @@ msgctxt "field:lims.project.mpi_professional,project:"
msgid "Implementation project"
msgstr "Proyecto implementación"
msgctxt "field:lims.project.solvent_reagent,product:"
msgid "Supply"
msgstr "Insumo"
msgctxt "field:lims.project.solvent_reagent,purchase_date:"
msgid "Purchase date"
msgstr "Fecha de compra"

View File

@ -7,6 +7,7 @@ from trytond.model import ModelSQL, ModelView, fields
from trytond.report import Report
from trytond.pool import PoolMeta, Pool
from trytond.pyson import Eval, Equal, Bool, Not
from trytond.transaction import Transaction
class Project(metaclass=PoolMeta):
@ -35,6 +36,8 @@ class Project(metaclass=PoolMeta):
cls.external_quality_control.states['invisible'] = Bool(
Equal(Eval('type'), 'implementation'))
cls.external_quality_control.depends = ['type']
cls.stp_solvents_and_reagents.context = {'project_type': Eval('type')}
cls.stp_solvents_and_reagents.depends = ['type', 'stp_state']
@classmethod
def view_attributes(cls):
@ -95,6 +98,30 @@ class ProjectSolventAndReagent(metaclass=PoolMeta):
purchase_date = fields.Date('Purchase date')
@classmethod
def __setup__(cls):
super().__setup__()
cls.product.string = 'Supply'
@staticmethod
def default_solvent_reagent_domain():
pool = Pool()
Config = pool.get('lims.configuration')
Category = pool.get('product.category')
if Transaction().context.get('project_type', '') == 'implementation':
return [c.id for c in Category.search([])]
config = Config(1)
return config.get_solvents() + config.get_reagents()
def get_solvent_reagent_domain(self, name=None):
pool = Pool()
Config = pool.get('lims.configuration')
Category = pool.get('product.category')
if self.project.type == 'implementation':
return [c.id for c in Category.search([])]
config = Config(1)
return config.get_solvents() + config.get_reagents()
@fields.depends('lot')
def on_change_lot(self, name=None):
pool = Pool()

View File

@ -33,7 +33,7 @@
view_ids="lims_project_study_plan.lims_sample_view_list,lims_project_study_plan.lims_sample_view_form"/>
</page>
<page string="Supplies" id="supplies">
<field name="stp_solvents_and_reagents" colspan="4" mode="tree,form"
<field name="stp_solvents_and_reagents" string="Supplies" colspan="4" mode="tree,form"
view_ids="lims_project_implementation.lims_project_solvent_reagent_view_list,lims_project_implementation.lims_project_solvent_reagent_view_form"/>
</page>
</notebook>