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.model import fields
from trytond.pool import PoolMeta, Pool from trytond.pool import PoolMeta, Pool
from trytond.pyson import Eval 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.model import fields
from trytond.pool import PoolMeta, Pool from trytond.pool import PoolMeta, Pool
from trytond.pyson import Eval, Equal, Not, Bool from trytond.pyson import Eval, Equal, Not, Bool
@ -26,15 +28,15 @@ class Location:
help='Enables storage space control', help='Enables storage space control',
states={'invisible': Not(Equal(Eval('type'), 'storage'))}, states={'invisible': Not(Equal(Eval('type'), 'storage'))},
depends=['type']) depends=['type'])
storage_direction = fields.Selection([('', ''), storage_direction = fields.Selection([('longitudinal', 'Longitudinal')],
('longitudinal', 'Longitudinal')], 'Storage direction', 'Storage direction',
states={'invisible': Not(Equal(Eval('type'), 'storage')), states={'invisible': Not(Equal(Eval('type'), 'storage')),
'required': Bool(Eval('control_space')), 'required': Bool(Eval('control_space')),
'readonly': True}, 'readonly': True},
depends=['type', 'control_space']) depends=['type', 'control_space'])
overload_behavior = fields.Selection([('', ''), overload_behavior = fields.Selection([('warn', 'Warn'),
('warn', 'Warn'), ('stop', 'Stop')],
('stop', 'Stop')], 'Overload behavior', 'Overload behavior',
help='Determines system behavior when storage space is overloaded', help='Determines system behavior when storage space is overloaded',
states={'required': Bool(Eval('control_space')), states={'required': Bool(Eval('control_space')),
'invisible': Not(Equal(Eval('type'), 'storage'))}, 'invisible': Not(Equal(Eval('type'), 'storage'))},
@ -48,7 +50,7 @@ class Location:
@staticmethod @staticmethod
def default_storage_direction(): def default_storage_direction():
return '' return 'longitudinal'
@staticmethod @staticmethod
def default_control_space(): def default_control_space():
@ -56,7 +58,7 @@ class Location:
@staticmethod @staticmethod
def default_overload_behavior(): def default_overload_behavior():
return '' return 'warn'
@classmethod @classmethod
def _extend_measure_field(cls, field): def _extend_measure_field(cls, field):
@ -72,13 +74,10 @@ class Location:
@fields.depends('control_space') @fields.depends('control_space')
def on_change_control_space(self): def on_change_control_space(self):
result = {'storage_direction': '',
'overload_behavior': ''}
if not self.control_space: if not self.control_space:
return result return {}
result['storage_direction'] = 'longitudinal' return {'storage_direction': 'longitudinal',
result['overload_behavior'] = 'warn' 'overload_behavior': 'warn'}
return result
def storage_try(self, date, extra_space=float(0)): def storage_try(self, date, extra_space=float(0)):
""" Determines if store in the location at date is possible""" """ Determines if store in the location at date is possible"""