model sequence equipments

This commit is contained in:
sinergia 2022-07-04 15:51:08 -05:00
parent 1a9b979e3b
commit 6883d20a7d
3 changed files with 36 additions and 2 deletions

View File

@ -1,12 +1,19 @@
from collections import defaultdict from collections import defaultdict
from trytond.pool import Pool from trytond.pool import Pool
from trytond.model import ModelSQL, ModelView, Unique, fields from trytond.model import ModelSQL, ModelView, Unique, fields
from trytond.pyson import Eval
from trytond.exceptions import UserError from trytond.exceptions import UserError
class OpticalEquipment(ModelSQL, ModelView): class OpticalEquipment(ModelSQL, ModelView):
'Optical Equipment' 'Optical Equipment'
__name__ = 'optical_equipment.equipment' __name__ = 'optical_equipment.equipment'
code_readinly = fields.Function(
fields.Boolean("Code Readonly"), 'get_code_readonly')
code = fields.Char(
"Code", select=True,states={
'readonly': Eval('code_readonly', False),
})
company = fields.Many2One('company.company', "Company") company = fields.Many2One('company.company', "Company")
location = fields.Many2One('stock.location', "Location") location = fields.Many2One('stock.location', "Location")
propietary = fields.Many2One('party.party', "Propietary") propietary = fields.Many2One('party.party', "Propietary")
@ -19,8 +26,13 @@ class OpticalEquipment(ModelSQL, ModelView):
biomedical_class = fields.Char('Biomedical Class') biomedical_class = fields.Char('Biomedical Class')
main_tecnology = fields.Char('Main tecnology') main_tecnology = fields.Char('Main tecnology')
calibration = fields.Boolean("Apply calibration", readonly=True) calibration = fields.Boolean("Apply calibration", readonly=True)
mark_category = fields.Many2One('product.category', 'Mark', required=True) mark_category = fields.Many2One('product.category', 'Mark', required=True,
model_category = fields.Many2One('product.category', "Model", required=True) domain=[('parent', '=', None),
('accounting', '=', False)],
)
model_category = fields.Many2One('product.category', "Model", required=True,
domain=[('parent', '=', Eval('mark_category')),
('accounting', '=', False)],)
reference = fields.Char("Reference", size=None) reference = fields.Char("Reference", size=None)
origin_country = fields.Many2One('country.country',"Origin Country") origin_country = fields.Many2One('country.country',"Origin Country")
software_version = fields.Char("Software version", size=None) software_version = fields.Char("Software version", size=None)
@ -47,3 +59,22 @@ class OpticalEquipment(ModelSQL, ModelView):
('serial_unique', Unique(t, t.serial), ('serial_unique', Unique(t, t.serial),
'optical_equipment.msg_serial_unique') 'optical_equipment.msg_serial_unique')
] ]
def default_code_readonly(cls):
pool = Pool()
Configuration = pool.get('optical_equipment.configuration')
config = Configuration(1)
return bool(config.equipment_sequence)
def get_code_readonly(self, name):
return self.default_code_readonly()
@classmethod
def _new_code(cls):
pool = Pool()
Configuration = pool.get('optical_equipment.configuration')
config = Configuration(1)
sequence = config.equipment_sequence
if sequence:
return sequence.get()

View File

@ -2,6 +2,8 @@
<!-- This file is part of Tryton. The COPYRIGHT file at the top level of <!-- This file is part of Tryton. The COPYRIGHT file at the top level of
this repository contains the full copyright notices and license terms. --> this repository contains the full copyright notices and license terms. -->
<form> <form>
<label name="code"/>
<field name="code"/>
<label name="company"/> <label name="company"/>
<field name="company"/> <field name="company"/>
<label name="location"/> <label name="location"/>

View File

@ -2,6 +2,7 @@
<!-- This file is part of Tryton. The COPYRIGHT file at the top level of <!-- This file is part of Tryton. The COPYRIGHT file at the top level of
this repository contains the full copyright notices and license terms. --> this repository contains the full copyright notices and license terms. -->
<tree> <tree>
<field name="code"/>
<field name="company"/> <field name="company"/>
<field name="location"/> <field name="location"/>
<field name="propietary"/> <field name="propietary"/>