Add work_center column to yield allocation model. This commit refs #1384
This commit is contained in:
parent
a732c04943
commit
0a81298875
|
@ -50,4 +50,17 @@ this repository contains the full copyright notices and license terms. -->
|
|||
action="act_yield_allocation"/>
|
||||
</data>
|
||||
|
||||
<data depends="production_work_employee">
|
||||
<record model="ir.ui.view" id="yield_allocation_wcenter_view_form">
|
||||
<field name="model">labor.yield.allocation</field>
|
||||
<field name="inherit" ref="yield_allocation_view_form"/>
|
||||
<field name="name">yield_allocation_wcenter_form</field>
|
||||
</record>
|
||||
<record model="ir.ui.view" id="yield_allocation_wcenter_view_tree">
|
||||
<field name="model">labor.yield.allocation</field>
|
||||
<field name="inherit" ref="yield_allocation_view_tree"/>
|
||||
<field name="name">yield_allocation_wcenter_tree</field>
|
||||
</record>
|
||||
</data>
|
||||
|
||||
</tryton>
|
||||
|
|
|
@ -15,6 +15,12 @@ __all__ = ['YieldAllocationMixin', 'YieldAllocation',
|
|||
'YieldAllocateSummaryDet']
|
||||
|
||||
|
||||
def _is_wcenter_on():
|
||||
pool = Pool()
|
||||
ULCase = pool.get('company.employee')
|
||||
return isinstance(getattr(ULCase, 'work_center', None), fields.Field)
|
||||
|
||||
|
||||
class YieldAllocationMixin(object):
|
||||
"""Base for Yield Allocations"""
|
||||
date = fields.Date('Date', required=True, select=True)
|
||||
|
@ -71,6 +77,11 @@ class YieldAllocation(YieldAllocationMixin, ModelSQL, ModelView):
|
|||
super(YieldAllocation, cls).__setup__()
|
||||
cls._error_messages.update({
|
||||
'invalid_offset_spec': ('Invalid offset specification: %s')})
|
||||
if _is_wcenter_on():
|
||||
cls.work_center = fields.Function(
|
||||
fields.Many2One('production.work.center',
|
||||
'Work center', readonly=True),
|
||||
'get_work_center')
|
||||
|
||||
@classmethod
|
||||
def _get_source_name(cls):
|
||||
|
@ -92,6 +103,12 @@ class YieldAllocation(YieldAllocationMixin, ModelSQL, ModelView):
|
|||
if offset_inv:
|
||||
cls.raise_user_error('invalid_offset_spec', offset_inv)
|
||||
|
||||
def get_work_center(self, name):
|
||||
with Transaction().set_context(date=self.date):
|
||||
if self.employee.work_center:
|
||||
return self.employee.work_center.id
|
||||
return None
|
||||
|
||||
|
||||
class YieldAllocationProcedure(ModelSQL, ModelView):
|
||||
"""Labor Yield Allocation Procedure"""
|
||||
|
|
|
@ -292,4 +292,8 @@ msgstr "Ajuste 3"
|
|||
|
||||
msgctxt "wizard_button:labor.yield.allocate,summary,offset_:"
|
||||
msgid "Save"
|
||||
msgstr "Guardar"
|
||||
msgstr "Guardar"
|
||||
|
||||
msgctxt "field:labor.yield.allocation,work_center:"
|
||||
msgid "Work center"
|
||||
msgstr "Centro trabajo"
|
|
@ -4,9 +4,11 @@ depends:
|
|||
ir
|
||||
res
|
||||
timesheet
|
||||
company_employee_team
|
||||
product
|
||||
|
||||
extras_depend:
|
||||
production_work_employee
|
||||
|
||||
xml:
|
||||
labor_yield.xml
|
||||
timesheet.xml
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
<?xml version="1.0"?>
|
||||
<!-- The COPYRIGHT file at the top level of
|
||||
this repository contains the full copyright notices and license terms. -->
|
||||
<data>
|
||||
<xpath expr="/form/field[@name='employee']" position="before">
|
||||
<label name="work_center"/>
|
||||
<field name="work_center"/>
|
||||
</xpath>
|
||||
</data>
|
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0"?>
|
||||
<!-- The COPYRIGHT file at the top level of
|
||||
this repository contains the full copyright notices and license terms. -->
|
||||
<data>
|
||||
<xpath expr="/tree/field[@name='employee']" position="before">
|
||||
<field name="work_center"/>
|
||||
</xpath>
|
||||
</data>
|
Loading…
Reference in New Issue