Add "Manual" field to "Yield allocate summary detail" model. This commit refs #1556
This commit is contained in:
parent
25215137f4
commit
c017bfdd36
|
@ -37,6 +37,14 @@ class YieldAllocationMixin(object):
|
|||
depends=['work'])
|
||||
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'])
|
||||
|
||||
@staticmethod
|
||||
def default_work():
|
||||
|
@ -71,14 +79,6 @@ class YieldAllocation(YieldAllocationMixin, ModelSQL, ModelView):
|
|||
And(Bool(Eval('procedure', False)),
|
||||
Equal(Eval('offset_', 0), 0))},
|
||||
depends=['offset_', 'procedure'])
|
||||
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'])
|
||||
offset_ = fields.Integer('Offset',
|
||||
domain=[
|
||||
If(Bool(Eval('offset_', None)),
|
||||
|
|
|
@ -360,4 +360,8 @@ msgstr "Cancelar"
|
|||
|
||||
msgctxt "wizard_button:labor.yield.enter,get_params,enter:"
|
||||
msgid "Enter"
|
||||
msgstr "Registrar"
|
||||
msgstr "Registrar"
|
||||
|
||||
msgctxt "field:labor.yield.allocate.summary.detail,manual:"
|
||||
msgid "Manual"
|
||||
msgstr "Manual"
|
|
@ -14,4 +14,6 @@
|
|||
<field name="offset_2"/>
|
||||
<label name="offset_3"/>
|
||||
<field name="offset_3"/>
|
||||
<label name="manual"/>
|
||||
<field name="manual"/>
|
||||
</form>
|
|
@ -8,4 +8,5 @@
|
|||
<field name="offset_1" sum="Offset 1"/>
|
||||
<field name="offset_2" sum="Offset 2"/>
|
||||
<field name="offset_3" sum="Offset 3"/>
|
||||
<field name="manual"/>
|
||||
</tree>
|
|
@ -2,7 +2,7 @@
|
|||
# this repository contains the full copyright notices and license terms.
|
||||
from trytond.model import ModelView, fields
|
||||
from trytond.pool import Pool
|
||||
from trytond.pyson import Eval, Bool, Not, PYSONEncoder, Date
|
||||
from trytond.pyson import Eval, Bool, Not, PYSONEncoder, Date, And
|
||||
from trytond.transaction import Transaction
|
||||
from trytond.wizard import Wizard, StateView, StateAction, Button
|
||||
from trytond.wizard import StateTransition
|
||||
|
@ -105,20 +105,34 @@ class YieldAllocateSummaryDet(YieldAllocationMixin, ModelView):
|
|||
readonly=True,
|
||||
depends=['quantity_digits'])
|
||||
|
||||
manual = fields.Float(
|
||||
'Manual', digits=(16, Eval('quantity_digits', 2)),
|
||||
readonly=True,
|
||||
depends=['quantity_digits'])
|
||||
|
||||
offset_1 = fields.Float(
|
||||
'Offset 1', digits=(16, Eval('quantity_digits', 2)),
|
||||
states={'readonly': Not(Bool(Eval('employee')))},
|
||||
depends=['quantity_digits', 'employee'])
|
||||
states={
|
||||
'readonly': Not(And(
|
||||
Bool(Eval('procedure')),
|
||||
Bool(Eval('employee'))))},
|
||||
depends=['quantity_digits', 'employee', 'procedure'])
|
||||
|
||||
offset_2 = fields.Float(
|
||||
'Offset 2', digits=(16, Eval('quantity_digits', 2)),
|
||||
states={'readonly': Not(Bool(Eval('employee')))},
|
||||
depends=['quantity_digits', 'employee'])
|
||||
states={
|
||||
'readonly': Not(And(
|
||||
Bool(Eval('procedure')),
|
||||
Bool(Eval('employee'))))},
|
||||
depends=['quantity_digits', 'employee', 'procedure'])
|
||||
|
||||
offset_3 = fields.Float(
|
||||
'Offset 3', digits=(16, Eval('quantity_digits', 2)),
|
||||
states={'readonly': Not(Bool(Eval('employee')))},
|
||||
depends=['quantity_digits', 'employee'])
|
||||
states={
|
||||
'readonly': Not(And(
|
||||
Bool(Eval('procedure')),
|
||||
Bool(Eval('employee'))))},
|
||||
depends=['quantity_digits', 'employee', 'procedure'])
|
||||
|
||||
@classmethod
|
||||
def __setup__(cls):
|
||||
|
@ -127,11 +141,13 @@ class YieldAllocateSummaryDet(YieldAllocationMixin, ModelView):
|
|||
cls.employee.readonly = True
|
||||
cls.quantity.readonly = True
|
||||
|
||||
@fields.depends('offset_1', 'offset_2', 'offset_3', 'quantity', 'employee')
|
||||
@fields.depends('offset_1', 'offset_2', 'offset_3', 'quantity',
|
||||
'employee', 'manual')
|
||||
def on_change_with_allocated(self):
|
||||
if self.employee:
|
||||
return ((self.quantity or 0) + (self.offset_1 or 0) +
|
||||
(self.offset_2 or 0) + (self.offset_3 or 0))
|
||||
(self.offset_2 or 0) + (self.offset_3 or 0) +
|
||||
(self.manual or 0))
|
||||
return 0
|
||||
|
||||
|
||||
|
@ -197,6 +213,7 @@ class YieldAllocate(Wizard):
|
|||
eallocs = list(eallocs_)
|
||||
quantity = sum(ea.get('quantity') for ea in eallocs)
|
||||
details.append({
|
||||
'procedure': eallocs[0].get('procedure'),
|
||||
'work': eallocs[0].get('work'),
|
||||
'employee': employee,
|
||||
'quantity': quantity,
|
||||
|
@ -205,6 +222,7 @@ class YieldAllocate(Wizard):
|
|||
|
||||
def _aggr_unallocated(self, unallocated, procedure_id):
|
||||
return [{
|
||||
'procedure': unallocated[0].get('procedure'),
|
||||
'work': unallocated[0].get('work'),
|
||||
'employee': None,
|
||||
'quantity': sum(ua.get('quantity') for ua in unallocated),
|
||||
|
@ -235,6 +253,26 @@ class YieldAllocate(Wizard):
|
|||
d['offset_%s' % i] = offsets.get((d['employee'], i), 0)
|
||||
return details
|
||||
|
||||
def _get_manuals(self, details):
|
||||
pool = Pool()
|
||||
procedure = self.procedure.procedure
|
||||
Allocation = pool.get('labor.yield.allocation')
|
||||
date_ = self.get_params.date
|
||||
res = Allocation.search([
|
||||
('work', '=', procedure.work.id),
|
||||
('procedure', '=', None),
|
||||
('date', '=', date_)])
|
||||
computed = {d['employee']: d for d in details
|
||||
if d.get('employee', None)}
|
||||
for r in res:
|
||||
d = computed.get(r.employee.id, {
|
||||
'work': procedure.work.id,
|
||||
'employee': r.employee.id})
|
||||
d['manual'] = r.quantity
|
||||
if not d.get('procedure', None):
|
||||
details.append(d)
|
||||
return details
|
||||
|
||||
def default_summary(self, fields):
|
||||
proc_id = self.procedure.procedure.id
|
||||
result = {'date': self.get_params.date}
|
||||
|
@ -247,6 +285,7 @@ class YieldAllocate(Wizard):
|
|||
details.extend(self._aggr_unallocated(unallocated, proc_id))
|
||||
if details:
|
||||
details = self._get_offset_(details)
|
||||
details = self._get_manuals(details)
|
||||
result['details'] = self._summ_detail_sort(details, proc_id)
|
||||
return result
|
||||
|
||||
|
|
Loading…
Reference in New Issue