model sequence equipments
This commit is contained in:
parent
1a9b979e3b
commit
6883d20a7d
35
equipment.py
35
equipment.py
@ -1,12 +1,19 @@
|
||||
from collections import defaultdict
|
||||
from trytond.pool import Pool
|
||||
from trytond.model import ModelSQL, ModelView, Unique, fields
|
||||
from trytond.pyson import Eval
|
||||
from trytond.exceptions import UserError
|
||||
|
||||
class OpticalEquipment(ModelSQL, ModelView):
|
||||
'Optical 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")
|
||||
location = fields.Many2One('stock.location', "Location")
|
||||
propietary = fields.Many2One('party.party', "Propietary")
|
||||
@ -19,8 +26,13 @@ class OpticalEquipment(ModelSQL, ModelView):
|
||||
biomedical_class = fields.Char('Biomedical Class')
|
||||
main_tecnology = fields.Char('Main tecnology')
|
||||
calibration = fields.Boolean("Apply calibration", readonly=True)
|
||||
mark_category = fields.Many2One('product.category', 'Mark', required=True)
|
||||
model_category = fields.Many2One('product.category', "Model", required=True)
|
||||
mark_category = fields.Many2One('product.category', 'Mark', 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)
|
||||
origin_country = fields.Many2One('country.country',"Origin Country")
|
||||
software_version = fields.Char("Software version", size=None)
|
||||
@ -47,3 +59,22 @@ class OpticalEquipment(ModelSQL, ModelView):
|
||||
('serial_unique', Unique(t, t.serial),
|
||||
'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()
|
||||
|
||||
|
@ -2,6 +2,8 @@
|
||||
<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||
this repository contains the full copyright notices and license terms. -->
|
||||
<form>
|
||||
<label name="code"/>
|
||||
<field name="code"/>
|
||||
<label name="company"/>
|
||||
<field name="company"/>
|
||||
<label name="location"/>
|
||||
|
@ -2,6 +2,7 @@
|
||||
<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||
this repository contains the full copyright notices and license terms. -->
|
||||
<tree>
|
||||
<field name="code"/>
|
||||
<field name="company"/>
|
||||
<field name="location"/>
|
||||
<field name="propietary"/>
|
||||
|
Loading…
Reference in New Issue
Block a user