Refactor allocate wizard abstracting summary calculation. This commit refs #1471 #1443

This commit is contained in:
Nicolás López 2016-09-27 20:31:25 +02:00
parent a80d8e467d
commit f1b318d4d0
4 changed files with 23 additions and 17 deletions

View File

@ -55,7 +55,7 @@ class YieldAllocation(YieldAllocationMixin, ModelSQL, ModelView):
"""Labor Yield Allocation"""
__name__ = 'labor.yield.allocation'
source = fields.Reference('Cost source', selection='get_source_name', required=True, select=True)
source = fields.Reference('Yield source', selection='get_source_name', required=True, select=True)
@classmethod
def _get_source_name(cls):
@ -139,19 +139,24 @@ class YieldAllocate(Wizard):
def transition_go_params(self):
return self._get_params_state(self.procedure.procedure.id)
def _get_allocations(self):
def _get_allocations(self, procedure_id):
return []
def default_summary(self, fields):
def _aggr_allocations(self, allocations, procedure_id):
details = []
yield_allocs = self._get_allocations()
if yield_allocs:
yield_allocs.sort(key=lambda a: a.get('employee'))
for employee, eallocs_ in groupby(yield_allocs, lambda x: x.get('employee')):
eallocs = list(eallocs_)
details.append({'employee': employee,
'work': self.procedure.procedure.work.id,
allocations.sort(key=lambda a: a.get('employee'))
for employee, eallocs_ in groupby(allocations, lambda x: x.get('employee')):
eallocs = list(eallocs_)
details.append({'employee': employee,
'work': eallocs[0]['work'],
'quantity': sum(ea.get('quantity') for ea in eallocs)})
return details
def default_summary(self, fields):
yield_allocs = self._get_allocations(self.procedure.procedure.id)
if yield_allocs:
details = self._aggr_allocations(yield_allocs,
self.procedure.procedure.id)
return {'details': details}

View File

@ -206,6 +206,10 @@ msgctxt "view:labor.yield.allocation.procedure:"
msgid "Labor Yield Allocation Procedure"
msgstr "Procedimiento Asignación Productividad"
msgctxt "view:labor.yield.allocation:"
msgid "Labor Yield Allocation"
msgstr "Asignación Productividad"
msgctxt "wizard_button:labor.yield.allocate,procedure,end:"
msgid "Cancel"
msgstr "Cancelar"
@ -221,7 +225,3 @@ msgstr "Asignar"
msgctxt "wizard_button:labor.yield.allocate,summary,end:"
msgid "Cancel"
msgstr "Cancelar"
msgctxt "view:labor.yield.allocation:"
msgid "Labor Yield Allocation"
msgstr "Asignación Productividad"

View File

@ -34,8 +34,8 @@ this repository contains the full copyright notices and license terms. -->
<field name="group" ref="timesheet.group_timesheet_admin"/>
<field name="perm_read" eval="True"/>
<field name="perm_write" eval="True"/>
<field name="perm_create" eval="True"/>
<field name="perm_delete" eval="True"/>
<field name="perm_create" eval="False"/>
<field name="perm_delete" eval="False"/>
</record>
<record model="ir.model.access" id="access_yield_allocation_procedure">
<field name="model" search="[('model', '=', 'labor.yield.allocation.procedure')]"/>

View File

@ -11,4 +11,5 @@ xml:
labor_yield.xml
timesheet.xml
allocation.xml
allocate_wizard.xml
allocate_wizard.xml
procedure.xml