Compare commits
3 Commits
1f6dfd5ab1
...
544fc3225b
Author | SHA1 | Date |
---|---|---|
Sergio Morillo | 544fc3225b | |
Nicolás López Solano | f2832af3db | |
Marcos Sabater | 939aa0a883 |
|
@ -21,3 +21,12 @@ def register():
|
|||
yield_wizards.YieldEnter,
|
||||
yield_wizards.YieldAllocate,
|
||||
module='labor_yield', type_='wizard')
|
||||
Pool.register(
|
||||
labor_yield.YieldAllocation2,
|
||||
module='labor_yield', type_='model',
|
||||
depends=['production_work_employee'])
|
||||
Pool.register(
|
||||
labor_yield.YieldAllocation3,
|
||||
yield_wizards.YieldAllocateSummaryDet3,
|
||||
module='labor_yield', type_='model',
|
||||
depends=['company_employee_code'])
|
||||
|
|
|
@ -63,4 +63,11 @@ this repository contains the full copyright notices and license terms. -->
|
|||
</record>
|
||||
</data>
|
||||
|
||||
<data depends="company_employee_code">
|
||||
<record model="ir.ui.view" id="yield_allocation_employee_code_view_tree">
|
||||
<field name="model">labor.yield.allocation</field>
|
||||
<field name="inherit" ref="yield_allocation_view_tree"/>
|
||||
<field name="name">yield_allocation_employee_code_tree</field>
|
||||
</record>
|
||||
</data>
|
||||
</tryton>
|
||||
|
|
|
@ -1,19 +1,14 @@
|
|||
# The COPYRIGHT file at the top level of
|
||||
# this repository contains the full copyright notices and license terms.
|
||||
from trytond.model import ModelSQL, ModelView, fields, DeactivableMixin
|
||||
from trytond.pool import Pool
|
||||
from trytond.pool import Pool, PoolMeta
|
||||
from trytond.pyson import Eval, Bool, Not, If, And, Equal
|
||||
from trytond.transaction import Transaction
|
||||
|
||||
|
||||
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"""
|
||||
|
||||
work = fields.Many2One('timesheet.work', 'Work', required=True,
|
||||
select=True, ondelete='RESTRICT',
|
||||
domain=[('yield_available', '=', True)])
|
||||
|
@ -125,11 +120,6 @@ class YieldAllocation(YieldAllocationMixin, ModelSQL, ModelView):
|
|||
'invisible': Not(rq_st)}
|
||||
cls.employee.depends = ['work']
|
||||
|
||||
if _is_wcenter_on():
|
||||
cls.work_center = fields.Function(
|
||||
fields.Many2One('production.work.center', 'Work center'),
|
||||
'get_work_center')
|
||||
|
||||
@staticmethod
|
||||
def default_allowed_offsets():
|
||||
return 0
|
||||
|
@ -139,7 +129,7 @@ class YieldAllocation(YieldAllocationMixin, ModelSQL, ModelView):
|
|||
|
||||
@fields.depends('procedure')
|
||||
def on_change_procedure(self):
|
||||
self.allowed_offsets = self.get_allowed_offsets()
|
||||
self.allowed_offsets = self.get_allowed_offsets()
|
||||
|
||||
@classmethod
|
||||
def _get_source_name(cls):
|
||||
|
@ -164,12 +154,6 @@ class YieldAllocation(YieldAllocationMixin, ModelSQL, ModelView):
|
|||
'labor_yield.msg_labor_yield_allocation_invalid_offset_spec',
|
||||
offset=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
|
||||
|
||||
@staticmethod
|
||||
def default_date():
|
||||
Date_ = Pool().get('ir.date')
|
||||
|
@ -183,14 +167,11 @@ class YieldAllocation(YieldAllocationMixin, ModelSQL, ModelView):
|
|||
if work_id:
|
||||
Work = pool.get('timesheet.work')
|
||||
work = Work(work_id)
|
||||
if (work.yield_available and
|
||||
work.yield_record_granularity == 'company'):
|
||||
if (work.yield_available
|
||||
and work.yield_record_granularity == 'company'):
|
||||
attrs += [
|
||||
('/tree//field[@name="employee"]', 'tree_invisible', 1)]
|
||||
if _is_wcenter_on():
|
||||
attrs += [
|
||||
('/tree//field[@name="work_center"]',
|
||||
'tree_invisible', 1)]
|
||||
|
||||
return attrs
|
||||
|
||||
|
||||
|
@ -214,3 +195,36 @@ class YieldAllocationProcedure(DeactivableMixin, ModelSQL, ModelView):
|
|||
|
||||
def get_unallocated(self, date):
|
||||
return []
|
||||
|
||||
|
||||
class YieldAllocation2(metaclass=PoolMeta):
|
||||
__name__ = 'labor.yield.allocation'
|
||||
|
||||
work_center = fields.Function(
|
||||
fields.Many2One('production.work.center', 'Work center'),
|
||||
'get_work_center')
|
||||
|
||||
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
|
||||
|
||||
@classmethod
|
||||
def view_attributes(cls):
|
||||
attrs = super(YieldAllocation, cls).view_attributes()
|
||||
if ('/tree//field[@name="employee"]', 'tree_invisible', 1) in attrs:
|
||||
attrs += [
|
||||
('/tree//field[@name="work_center"]', 'tree_invisible', 1)]
|
||||
return attrs
|
||||
|
||||
|
||||
class YieldAllocation3(metaclass=PoolMeta):
|
||||
__name__ = 'labor.yield.allocation'
|
||||
|
||||
employee_code = fields.Function(fields.Char('Employee Code'),
|
||||
'on_change_with_employee_code')
|
||||
|
||||
@fields.depends('employee')
|
||||
def on_change_with_employee_code(self, name=None):
|
||||
return self.employee.code if self.employee else None
|
||||
|
|
12
locale/es.po
12
locale/es.po
|
@ -38,6 +38,10 @@ msgctxt "field:labor.yield.allocate.summary.detail,allocated:"
|
|||
msgid "Allocated"
|
||||
msgstr "Asignado"
|
||||
|
||||
msgctxt "field:labor.yield.allocate.summary.detail,employee_code:"
|
||||
msgid "Employee Code"
|
||||
msgstr "Código Empleado"
|
||||
|
||||
msgctxt "field:labor.yield.allocate.summary.detail,employee:"
|
||||
msgid "Employee"
|
||||
msgstr "Empleado"
|
||||
|
@ -94,6 +98,14 @@ msgctxt "field:labor.yield.allocation,date:"
|
|||
msgid "Date"
|
||||
msgstr "Fecha"
|
||||
|
||||
msgctxt "field:labor.yield.allocation,work_center:"
|
||||
msgid "Work center"
|
||||
msgstr "Centro de trabajo"
|
||||
|
||||
msgctxt "field:labor.yield.allocation,employee_code:"
|
||||
msgid "Employee Code"
|
||||
msgstr "Código Empleado"
|
||||
|
||||
msgctxt "field:labor.yield.allocation,employee:"
|
||||
msgid "Employee"
|
||||
msgstr "Empleado"
|
||||
|
|
2
setup.py
2
setup.py
|
@ -9,7 +9,7 @@ import io
|
|||
from configparser import ConfigParser
|
||||
|
||||
MODULE2PREFIX = {
|
||||
'timesheet_work_notebook': 'datalife'
|
||||
'timesheet_work_notebook': 'datalife',
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -8,6 +8,7 @@ depends:
|
|||
timesheet_work_notebook
|
||||
|
||||
extras_depend:
|
||||
company_employee_code
|
||||
production_work_employee
|
||||
|
||||
xml:
|
||||
|
|
|
@ -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="employee_code"/>
|
||||
</xpath>
|
||||
</data>
|
|
@ -16,4 +16,6 @@
|
|||
<field name="offset_"/>
|
||||
<label name="procedure"/>
|
||||
<field name="procedure"/>
|
||||
<label name="source"/>
|
||||
<field name="source"/>
|
||||
</form>
|
||||
|
|
|
@ -9,4 +9,5 @@
|
|||
<field name="quantity_uom"/>
|
||||
<field name="offset_"/>
|
||||
<field name="procedure"/>
|
||||
<field name="source"/>
|
||||
</tree>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# The COPYRIGHT file at the top level of
|
||||
# this repository contains the full copyright notices and license terms.
|
||||
from trytond.model import ModelView, fields
|
||||
from trytond.pool import Pool
|
||||
from trytond.pool import Pool, PoolMeta
|
||||
from trytond.pyson import Eval, Bool, Not, PYSONEncoder, Date, And
|
||||
from trytond.transaction import Transaction
|
||||
from trytond.wizard import Wizard, StateView, StateAction, Button
|
||||
|
@ -339,3 +339,14 @@ class YieldAllocate(Wizard):
|
|||
self._delete_yield_allocations()
|
||||
self._write_yield_allocations()
|
||||
return 'end'
|
||||
|
||||
|
||||
class YieldAllocateSummaryDet3(metaclass=PoolMeta):
|
||||
__name__ = 'labor.yield.allocate.summary.detail'
|
||||
|
||||
employee_code = fields.Function(fields.Char('Employee Code'),
|
||||
'on_change_with_employee_code')
|
||||
|
||||
@fields.depends('employee')
|
||||
def on_change_with_employee_code(self, name=None):
|
||||
return self.employee.code if self.employee else None
|
||||
|
|
|
@ -53,6 +53,12 @@ this repository contains the full copyright notices and license terms. -->
|
|||
<field name="type">tree</field>
|
||||
<field name="name">allocate_summary_det_tree</field>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
<data depends="company_employee_code">
|
||||
<record model="ir.ui.view" id="allocate_summary_det_employee_code_view_tree">
|
||||
<field name="model">labor.yield.allocate.summary.detail</field>
|
||||
<field name="inherit" ref="allocate_summary_det_view_tree"/>
|
||||
<field name="name">yield_allocation_employee_code_tree</field>
|
||||
</record>
|
||||
</data>
|
||||
</tryton>
|
Loading…
Reference in New Issue