Fixed allocation quantity and offset domain bugs and other readonly state expresions
This commit is contained in:
parent
9120221f5a
commit
93fd261122
|
@ -14,7 +14,7 @@ pipeline:
|
|||
- pip install tox
|
||||
- tox -e "${TOXENV}-${DATABASE}"
|
||||
volumes:
|
||||
- cache:/root/.cache
|
||||
- /var/lib/cache:/root/.cache
|
||||
notify:
|
||||
image: drillster/drone-email
|
||||
from: drone@datalife.com.es
|
||||
|
|
|
@ -22,33 +22,31 @@ class YieldAllocationMixin(object):
|
|||
work = fields.Many2One('timesheet.work', 'Work', required=True,
|
||||
select=True, ondelete='RESTRICT',
|
||||
domain=[('yield_available', '=', True)])
|
||||
manual_yield_record = fields.Function(
|
||||
fields.Boolean('Allow manual yield record'),
|
||||
'get_manual_yield_record')
|
||||
employee = fields.Many2One('company.employee', 'Employee', select=True,
|
||||
ondelete='RESTRICT')
|
||||
ondelete='RESTRICT',
|
||||
states={'readonly': Not(Eval('manual_yield_record'))},
|
||||
depends=['manual_yield_record'])
|
||||
quantity = fields.Float('Quantity', required=True,
|
||||
digits=(16, Eval('quantity_digits', 2)),
|
||||
states={
|
||||
'readonly': Not(Eval('_parent_work',
|
||||
{}).get('manual_yield_record', True))},
|
||||
depends=['quantity_digits', 'work'])
|
||||
states={'readonly': Not(Eval('manual_yield_record'))},
|
||||
depends=['quantity_digits', 'manual_yield_record'])
|
||||
quantity_uom = fields.Many2One('product.uom', 'Quantity UoM',
|
||||
required=True,
|
||||
domain=[
|
||||
('category', '=',
|
||||
Eval('_parent_work', {}).get('uom_category'))],
|
||||
states={
|
||||
'readonly': Not(Eval('_parent_work',
|
||||
{}).get('manual_yield_record', True))},
|
||||
depends=['work'])
|
||||
states={'readonly': Not(Eval('manual_yield_record'))},
|
||||
depends=['manual_yield_record'])
|
||||
quantity_digits = fields.Function(
|
||||
fields.Integer('Quantity Digits'),
|
||||
'on_change_with_quantity_digits')
|
||||
procedure = fields.Many2One('labor.yield.allocation.procedure',
|
||||
'Procedure', readonly=True, select=True, ondelete='RESTRICT',
|
||||
states={
|
||||
'required':
|
||||
Not(Eval('_parent_work',
|
||||
{}).get('manual_yield_record', False))},
|
||||
depends=['work'])
|
||||
states={'required': Not(Eval('manual_yield_record'))},
|
||||
depends=['manual_yield_record'])
|
||||
|
||||
@classmethod
|
||||
def default_work(cls):
|
||||
|
@ -61,9 +59,17 @@ class YieldAllocationMixin(object):
|
|||
self.quantity_uom.category !=
|
||||
self.work.default_uom.category):
|
||||
self.quantity_uom = self.work.default_uom
|
||||
self.manual_yield_record = self.work.manual_yield_record
|
||||
else:
|
||||
self.quantity_uom = None
|
||||
|
||||
@staticmethod
|
||||
def default_manual_yield_record():
|
||||
return True
|
||||
|
||||
def get_manual_yield_record(self, name):
|
||||
return self.work.manual_yield_record
|
||||
|
||||
@classmethod
|
||||
def default_quantity_uom(cls):
|
||||
pool = Pool()
|
||||
|
@ -88,7 +94,9 @@ class YieldAllocationMixin(object):
|
|||
class YieldAllocation(YieldAllocationMixin, ModelSQL, ModelView):
|
||||
"""Labor Yield Allocation"""
|
||||
__name__ = 'labor.yield.allocation'
|
||||
date = fields.Date('Date', required=True, select=True)
|
||||
date = fields.Date('Date', required=True, select=True,
|
||||
states={'readonly': Not(Eval('manual_yield_record'))},
|
||||
depends=['manual_yield_record'])
|
||||
source = fields.Reference('Yield source', selection='get_source_name',
|
||||
select=True, readonly=True,
|
||||
states={
|
||||
|
@ -96,16 +104,18 @@ class YieldAllocation(YieldAllocationMixin, ModelSQL, ModelView):
|
|||
And(Bool(Eval('procedure', False)),
|
||||
Equal(Eval('offset_', 0), 0))},
|
||||
depends=['offset_', 'procedure'])
|
||||
offset_ = fields.Integer('Offset',
|
||||
allowed_offsets = fields.Function(
|
||||
fields.Integer('Allowed offsets'),
|
||||
'get_allowed_offsets')
|
||||
offset_ = fields.Integer('Offset', readonly=True,
|
||||
domain=[
|
||||
If(Bool(Eval('offset_', None)),
|
||||
('offset_', '<=', Eval('_parent_procedure',
|
||||
{}).get('allowed_offsets', 0)), ())],
|
||||
('offset_', '<=', Eval('allowed_offsets')), ())],
|
||||
states={
|
||||
'required':
|
||||
And(Bool(Eval('procedure', False)),
|
||||
Not(Bool(Eval('source', False))))},
|
||||
depends=['procedure', 'source'])
|
||||
'required': And(
|
||||
Bool(Eval('procedure', False)),
|
||||
Not(Bool(Eval('source', False))))},
|
||||
depends=['procedure', 'source', 'allowed_offsets'])
|
||||
|
||||
@classmethod
|
||||
def __setup__(cls):
|
||||
|
@ -128,6 +138,17 @@ class YieldAllocation(YieldAllocationMixin, ModelSQL, ModelView):
|
|||
fields.Many2One('production.work.center', 'Work center'),
|
||||
'get_work_center')
|
||||
|
||||
@staticmethod
|
||||
def default_allowed_offsets():
|
||||
return 0
|
||||
|
||||
def get_allowed_offsets(self, name=None):
|
||||
return self.procedure and self.procedure.allowed_offsets or 0
|
||||
|
||||
@fields.depends('procedure')
|
||||
def on_change_procedure(self):
|
||||
self.allowed_offsets = self.get_allowed_offsets()
|
||||
|
||||
@classmethod
|
||||
def _get_source_name(cls):
|
||||
return ['']
|
||||
|
@ -170,7 +191,7 @@ class YieldAllocation(YieldAllocationMixin, ModelSQL, ModelView):
|
|||
Work = pool.get('timesheet.work')
|
||||
work = Work(work_id)
|
||||
if (work.yield_available and
|
||||
work.yield_record_granularity == 'company'):
|
||||
work.yield_record_granularity == 'company'):
|
||||
attrs += [
|
||||
('/tree//field[@name="employee"]', 'tree_invisible', 1)]
|
||||
if _is_wcenter_on():
|
||||
|
|
|
@ -381,3 +381,11 @@ msgstr "Cancelar"
|
|||
msgctxt "wizard_button:labor.yield.enter,get_params,enter:"
|
||||
msgid "Enter"
|
||||
msgstr "Registrar"
|
||||
|
||||
msgctxt "field:labor.yield.allocation,allowed_offsets:"
|
||||
msgid "Allowed offsets"
|
||||
msgstr "Ajustes permitidos"
|
||||
|
||||
msgctxt "field:labor.yield.allocation,manual_yield_record:"
|
||||
msgid "Allow manual yield record"
|
||||
msgstr "Permite registro manual de productividad"
|
Loading…
Reference in New Issue