Refactorizar módulo

This commit is contained in:
Sergio Morillo 2014-08-07 14:35:29 +02:00
parent ec2f410e92
commit cf53beb47e
2 changed files with 14 additions and 13 deletions

View File

@ -1,3 +1,5 @@
# The COPYRIGHT file at the top level of
# this repository contains the full copyright notices and license terms.
from trytond.model import fields
from trytond.pool import PoolMeta, Pool
from trytond.pyson import Eval

View File

@ -1,3 +1,5 @@
# The COPYRIGHT file at the top level of
# this repository contains the full copyright notices and license terms.
from trytond.model import fields
from trytond.pool import PoolMeta, Pool
from trytond.pyson import Eval, Equal, Not, Bool
@ -26,15 +28,15 @@ class Location:
help='Enables storage space control',
states={'invisible': Not(Equal(Eval('type'), 'storage'))},
depends=['type'])
storage_direction = fields.Selection([('', ''),
('longitudinal', 'Longitudinal')], 'Storage direction',
storage_direction = fields.Selection([('longitudinal', 'Longitudinal')],
'Storage direction',
states={'invisible': Not(Equal(Eval('type'), 'storage')),
'required': Bool(Eval('control_space')),
'readonly': True},
depends=['type', 'control_space'])
overload_behavior = fields.Selection([('', ''),
('warn', 'Warn'),
('stop', 'Stop')], 'Overload behavior',
overload_behavior = fields.Selection([('warn', 'Warn'),
('stop', 'Stop')],
'Overload behavior',
help='Determines system behavior when storage space is overloaded',
states={'required': Bool(Eval('control_space')),
'invisible': Not(Equal(Eval('type'), 'storage'))},
@ -48,7 +50,7 @@ class Location:
@staticmethod
def default_storage_direction():
return ''
return 'longitudinal'
@staticmethod
def default_control_space():
@ -56,7 +58,7 @@ class Location:
@staticmethod
def default_overload_behavior():
return ''
return 'warn'
@classmethod
def _extend_measure_field(cls, field):
@ -72,13 +74,10 @@ class Location:
@fields.depends('control_space')
def on_change_control_space(self):
result = {'storage_direction': '',
'overload_behavior': ''}
if not self.control_space:
return result
result['storage_direction'] = 'longitudinal'
result['overload_behavior'] = 'warn'
return result
return {}
return {'storage_direction': 'longitudinal',
'overload_behavior': 'warn'}
def storage_try(self, date, extra_space=float(0)):
""" Determines if store in the location at date is possible"""