Implemented work's "default uom" column.

This commits refs #7415
This commit is contained in:
Nicolás López 2019-02-20 15:50:38 +01:00
parent a5853ec39b
commit 46e9fa3011
5 changed files with 206 additions and 155 deletions

View File

@ -54,17 +54,24 @@ class YieldAllocationMixin(object):
def default_work(cls):
return Transaction().context.get('work', None)
@fields.depends('work', 'quantity_uom')
def on_change_work(self):
if self.work:
if (not self.quantity_uom or
self.quantity_uom.category !=
self.work.default_uom.category):
self.quantity_uom = self.work.default_uom
else:
self.quantity_uom = None
@classmethod
def default_quantity_uom(cls):
pool = Pool()
Modeldata = pool.get('ir.model.data')
Work = pool.get('timesheet.work')
work = cls.default_work()
work = Work(work) if work else None
if work:
cat_unit = Modeldata.get_id('product', 'uom_cat_unit')
if work.uom_category and work.uom_category.id == cat_unit:
return Modeldata.get_id('product', 'uom_unit')
return work.default_uom.id
@fields.depends('quantity_uom')
def on_change_with_quantity_digits(self, name=None):

View File

@ -2,6 +2,18 @@
msgid ""
msgstr "Content-Type: text/plain; charset=utf-8\n"
msgctxt "error:labor.yield.allocation:"
msgid "Invalid offset specification: %s"
msgstr "Especificación de compensación no valida"
msgctxt "field:labor.yield.allocate.get_params,date:"
msgid "Date"
msgstr "Fecha"
msgctxt "field:labor.yield.allocate.get_params,id:"
msgid "ID"
msgstr "Identificador"
msgctxt "field:labor.yield.allocate.procedure,id:"
msgid "ID"
msgstr "Identificador"
@ -10,6 +22,10 @@ msgctxt "field:labor.yield.allocate.procedure,procedure:"
msgid "Procedure"
msgstr "Procedimiento"
msgctxt "field:labor.yield.allocate.summary,date:"
msgid "Date"
msgstr "Fecha"
msgctxt "field:labor.yield.allocate.summary,details:"
msgid "Yield Details"
msgstr "Detalles productividad"
@ -18,9 +34,9 @@ msgctxt "field:labor.yield.allocate.summary,id:"
msgid "ID"
msgstr "Identificador"
msgctxt "field:labor.yield.allocate.summary.detail,date:"
msgid "Date"
msgstr "Fecha"
msgctxt "field:labor.yield.allocate.summary.detail,allocated:"
msgid "Allocated"
msgstr "Asignado"
msgctxt "field:labor.yield.allocate.summary.detail,employee:"
msgid "Employee"
@ -30,6 +46,26 @@ msgctxt "field:labor.yield.allocate.summary.detail,id:"
msgid "ID"
msgstr "Identificador"
msgctxt "field:labor.yield.allocate.summary.detail,manual:"
msgid "Manual"
msgstr "Manual"
msgctxt "field:labor.yield.allocate.summary.detail,offset_1:"
msgid "Offset 1"
msgstr "Ajuste 1"
msgctxt "field:labor.yield.allocate.summary.detail,offset_2:"
msgid "Offset 2"
msgstr "Ajuste 2"
msgctxt "field:labor.yield.allocate.summary.detail,offset_3:"
msgid "Offset 3"
msgstr "Ajuste 3"
msgctxt "field:labor.yield.allocate.summary.detail,procedure:"
msgid "Procedure"
msgstr "Procedimiento"
msgctxt "field:labor.yield.allocate.summary.detail,quantity:"
msgid "Quantity"
msgstr "Cantidad"
@ -42,6 +78,10 @@ msgctxt "field:labor.yield.allocate.summary.detail,quantity_uom:"
msgid "Quantity UoM"
msgstr "UdM Cantidad"
msgctxt "field:labor.yield.allocate.summary.detail,work:"
msgid "Work"
msgstr "Trabajo"
msgctxt "field:labor.yield.allocation,create_date:"
msgid "Create Date"
msgstr "Fecha creación"
@ -62,6 +102,14 @@ msgctxt "field:labor.yield.allocation,id:"
msgid "ID"
msgstr "Identificador"
msgctxt "field:labor.yield.allocation,offset_:"
msgid "Offset"
msgstr "Ajuste"
msgctxt "field:labor.yield.allocation,procedure:"
msgid "Procedure"
msgstr "Procedimiento"
msgctxt "field:labor.yield.allocation,quantity:"
msgid "Quantity"
msgstr "Cantidad"
@ -75,13 +123,17 @@ msgid "Quantity UoM"
msgstr "UdM Cantidad"
msgctxt "field:labor.yield.allocation,rec_name:"
msgid "Name"
msgid "Record Name"
msgstr "Nombre"
msgctxt "field:labor.yield.allocation,source:"
msgid "Yield source"
msgstr "Origen"
msgctxt "field:labor.yield.allocation,work:"
msgid "Work"
msgstr "Trabajo"
msgctxt "field:labor.yield.allocation,write_date:"
msgid "Write Date"
msgstr "Fecha modificación"
@ -94,6 +146,10 @@ msgctxt "field:labor.yield.allocation.procedure,active:"
msgid "Active"
msgstr "Activo"
msgctxt "field:labor.yield.allocation.procedure,allowed_offsets:"
msgid "Allowed offsets"
msgstr "Ajustes permitidos"
msgctxt "field:labor.yield.allocation.procedure,create_date:"
msgid "Create Date"
msgstr "Fecha creación"
@ -111,7 +167,7 @@ msgid "Name"
msgstr "Nombre"
msgctxt "field:labor.yield.allocation.procedure,rec_name:"
msgid "Name"
msgid "Record Name"
msgstr "Nombre"
msgctxt "field:labor.yield.allocation.procedure,work:"
@ -126,10 +182,42 @@ msgctxt "field:labor.yield.allocation.procedure,write_uid:"
msgid "Write User"
msgstr "Usuario que escribe."
msgctxt "field:labor.yield.enter.get_params,date:"
msgid "Date"
msgstr "Fecha"
msgctxt "field:labor.yield.enter.get_params,id:"
msgid "ID"
msgstr "Identificador"
msgctxt "field:labor.yield.enter.get_params,work:"
msgid "Work"
msgstr "Trabajo"
msgctxt "field:timesheet.work,default_uom:"
msgid "Default uom"
msgstr "UdM por defecto"
msgctxt "field:timesheet.work,manual_yield_record:"
msgid "Allow manual yield record"
msgstr "Permite registro manual de productividad"
msgctxt "field:timesheet.work,uom_category:"
msgid "Uom category"
msgstr "Categoría UdM"
msgctxt "field:timesheet.work,yield_available:"
msgid "Available on yield"
msgstr "Disponible en productividad"
msgctxt "field:timesheet.work,yield_record_granularity:"
msgid "Yield record granularity"
msgstr "Granularidad registro de productividad"
msgctxt "help:labor.yield.allocation.procedure,active:"
msgid "Uncheck to exclude from future use."
msgstr "Desmarcar para eliminar el uso del registro en el futuro."
msgctxt "model:ir.action,name:act_yield_allocation"
msgid "Labor Yield Allocation"
msgstr "Asignación Productividad"
@ -142,6 +230,10 @@ msgctxt "model:ir.action,name:wizard_yield_allocate"
msgid "Labor Yield Allocate"
msgstr "Asignar Productividad"
msgctxt "model:ir.action,name:wizard_yield_enter"
msgid "Labor Yield Enter"
msgstr "Registrar Productividad"
msgctxt "model:ir.ui.menu,name:menu_yield"
msgid "Yield"
msgstr "Productividad"
@ -162,6 +254,14 @@ msgctxt "model:ir.ui.menu,name:menu_yield_configuration"
msgid "Yield"
msgstr "Productividad"
msgctxt "model:ir.ui.menu,name:menu_yield_enter"
msgid "Yield enter"
msgstr "Registrar productividad"
msgctxt "model:labor.yield.allocate.get_params,name:"
msgid "Labor Yield Allocate Get Params"
msgstr "Asignar productividad obtener parámetros"
msgctxt "model:labor.yield.allocate.procedure,name:"
msgid "Labor Yield Allocate Procedure Select"
msgstr "Asignar productividad selección de procedimiento"
@ -182,14 +282,50 @@ msgctxt "model:labor.yield.allocation.procedure,name:"
msgid "Labor Yield Allocation Procedure"
msgstr "Procedimiento de asignación de productividad"
msgctxt "model:labor.yield.enter.get_params,name:"
msgid "Labor Yield Enter Get Params"
msgstr "Registrar productividad obtener parámetros"
msgctxt "selection:timesheet.work,yield_record_granularity:"
msgid "Company"
msgstr "Empresa"
msgctxt "selection:timesheet.work,yield_record_granularity:"
msgid "Employee"
msgstr "Empleado"
msgctxt "view:labor.yield.allocate.get_params:"
msgid "Labor Yield Allocate"
msgstr "Asignar Productividad"
msgctxt "view:labor.yield.allocate.procedure:"
msgid "Labor Yield Allocate"
msgstr "Asignar Productividad"
msgctxt "view:labor.yield.allocate.summary.detail:"
msgid "Allocated"
msgstr "Asignado"
msgctxt "view:labor.yield.allocate.summary.detail:"
msgid "Labor Yield Allocate"
msgstr "Asignar Productividad"
msgctxt "view:labor.yield.allocate.summary.detail:"
msgid "Offset 1"
msgstr "Ajuste 1"
msgctxt "view:labor.yield.allocate.summary.detail:"
msgid "Offset 2"
msgstr "Ajuste 2"
msgctxt "view:labor.yield.allocate.summary.detail:"
msgid "Offset 3"
msgstr "Ajuste 3"
msgctxt "view:labor.yield.allocate.summary.detail:"
msgid "Quantity"
msgstr "Cantidad"
msgctxt "view:labor.yield.allocate.summary:"
msgid "Labor Yield Allocate"
msgstr "Asignar Productividad"
@ -202,11 +338,27 @@ msgctxt "view:labor.yield.allocation:"
msgid "Labor Yield Allocation"
msgstr "Asignación Productividad"
msgctxt "view:labor.yield.enter.get_params:"
msgid "Labor Yield Enter"
msgstr "Registrar Productividad"
msgctxt "view:timesheet.work:"
msgid "Labor yield"
msgstr "Productividad"
msgctxt "wizard_button:labor.yield.allocate,get_params,end:"
msgid "Cancel"
msgstr "Cancelar"
msgctxt "wizard_button:labor.yield.allocate,get_params,summary:"
msgid "Summary"
msgstr "Resumen"
msgctxt "wizard_button:labor.yield.allocate,procedure,end:"
msgid "Cancel"
msgstr "Cancelar"
msgctxt "wizard_button:labor.yield.allocate,procedure,go_params:"
msgctxt "wizard_button:labor.yield.allocate,procedure,get_params:"
msgid "OK"
msgstr "Aceptar"
@ -218,142 +370,10 @@ msgctxt "wizard_button:labor.yield.allocate,summary,end:"
msgid "Cancel"
msgstr "Cancelar"
msgctxt "view:labor.yield.allocate.summary.detail:"
msgid "Quantity"
msgstr "Cantidad"
msgctxt "view:labor.yield.allocate.summary.detail:"
msgid "Allocated"
msgstr "Asignado"
msgctxt "field:labor.yield.allocate.summary.detail,allocated:"
msgid "Allocated"
msgstr "Asignado"
msgctxt "field:labor.yield.allocate.get_params,date:"
msgid "Date"
msgstr "Fecha"
msgctxt "field:labor.yield.allocate.get_params,id:"
msgid "ID"
msgstr "Identificador"
msgctxt "model:labor.yield.allocate.get_params,name:"
msgid "Labor Yield Allocate Get Params"
msgstr "Asignar productividad obtener parámetros"
msgctxt "view:labor.yield.allocate.get_params:"
msgid "Labor Yield Allocate"
msgstr "Asignar Productividad"
msgctxt "field:labor.yield.allocate.summary.detail,offset_1:"
msgid "Offset 1"
msgstr "Ajuste 1"
msgctxt "field:labor.yield.allocate.summary.detail,offset_2:"
msgid "Offset 2"
msgstr "Ajuste 2"
msgctxt "field:labor.yield.allocate.summary.detail,offset_3:"
msgid "Offset 3"
msgstr "Ajuste 3"
msgctxt "field:labor.yield.allocation.procedure,allowed_offsets:"
msgid "Allowed offsets"
msgstr "Ajustes permitidos"
msgctxt "field:labor.yield.allocation,offset_:"
msgid "Offset"
msgstr "Ajuste"
msgctxt "error:labor.yield.allocation:"
msgid "Invalid offset specification: %s"
msgstr "Especificación de compensación no valida"
msgctxt "wizard_button:labor.yield.allocate,get_params,end:"
msgid "Cancel"
msgstr "Cancelar"
msgctxt "wizard_button:labor.yield.allocate,get_params,summary:"
msgid "Summary"
msgstr "Resumen"
msgctxt "view:labor.yield.allocate.summary.detail:"
msgid "Offset 1"
msgstr "Ajuste 1"
msgctxt "view:labor.yield.allocate.summary.detail:"
msgid "Offset 2"
msgstr "Ajuste 2"
msgctxt "view:labor.yield.allocate.summary.detail:"
msgid "Offset 3"
msgstr "Ajuste 3"
msgctxt "wizard_button:labor.yield.allocate,summary,offset_:"
msgid "Save"
msgstr "Guardar"
msgctxt "field:labor.yield.allocation,work_center:"
msgid "Work center"
msgstr "Centro trabajo"
msgctxt "field:timesheet.work,yield_record_granularity:"
msgid "Yield record granularity"
msgstr "Granularidad registro de productividad"
msgctxt "field:timesheet.work,manual_yield_record:"
msgid "Allow manual yield record"
msgstr "Permite registro manual de productividad"
msgctxt "view:timesheet.work:"
msgid "Labor yield"
msgstr "Productividad"
msgctxt "selection:timesheet.work,yield_record_granularity:"
msgid "Employee"
msgstr "Empleado"
msgctxt "selection:timesheet.work,yield_record_granularity:"
msgid "Company"
msgstr "Empresa"
msgctxt "field:labor.yield.allocation,work:"
msgid "Work"
msgstr "Trabajo"
msgctxt "field:labor.yield.allocation,procedure:"
msgid "Procedure"
msgstr "Procedimiento"
msgctxt "model:ir.action,name:wizard_yield_enter"
msgid "Labor Yield Enter"
msgstr "Registrar Productividad"
msgctxt "model:ir.ui.menu,name:menu_yield_enter"
msgid "Yield enter"
msgstr "Registrar productividad"
msgctxt "field:labor.yield.enter.get_params,work:"
msgid "Work"
msgstr "Trabajo"
msgctxt "field:labor.yield.enter.get_params,date:"
msgid "Date"
msgstr "Fecha"
msgctxt "field:labor.yield.enter.get_params,id:"
msgid "ID"
msgstr "Identificador"
msgctxt "model:labor.yield.enter.get_params,name:"
msgid "Labor Yield Enter Get Params"
msgstr "Registrar productividad obtener parámetros"
msgctxt "view:labor.yield.enter.get_params:"
msgid "Labor Yield Enter"
msgstr "Registrar Productividad"
msgctxt "wizard_button:labor.yield.enter,get_params,end:"
msgid "Cancel"
msgstr "Cancelar"
@ -361,7 +381,3 @@ msgstr "Cancelar"
msgctxt "wizard_button:labor.yield.enter,get_params,enter:"
msgid "Enter"
msgstr "Registrar"
msgctxt "field:labor.yield.allocate.summary.detail,manual:"
msgid "Manual"
msgstr "Manual"

View File

@ -2,7 +2,7 @@
# this repository contains the full copyright notices and license terms.
from trytond.model import fields
from trytond.pool import PoolMeta, Pool
from trytond.pyson import Eval, Not
from trytond.pyson import Eval, Not, Bool
__all__ = ['Work']
@ -11,17 +11,26 @@ class Work:
__metaclass__ = PoolMeta
__name__ = 'timesheet.work'
_RQ_ST = Bool(Eval('yield_available'))
yield_available = fields.Boolean('Available on yield')
yield_record_granularity = fields.Selection([
('company', 'Company'),
('employee', 'Employee')], 'Yield record granularity',
states={
'readonly': Not(Eval('yield_available', False))})
states={'readonly': Not(_RQ_ST)},
depends=['yield_available'])
manual_yield_record = fields.Boolean('Allow manual yield record',
states={'readonly': Not(_RQ_ST)},
depends=['yield_available'])
default_uom = fields.Many2One('product.uom', 'Default uom',
ondelete='RESTRICT',
states={
'readonly': Not(Eval('yield_available', False))})
uom_category = fields.Many2One('product.uom.category', 'Uom category',
ondelete='CASCADE')
'required': _RQ_ST,
'readonly': Not(_RQ_ST)},
depends=['yield_available'])
uom_category = fields.Function(
fields.Many2One('product.uom.category', 'Uom category'),
'get_uom_category')
@classmethod
def default_yield_record_granularity(cls):
@ -39,8 +48,24 @@ class Work:
def default_uom_category():
pool = Pool()
ModelData = pool.get('ir.model.data')
return ModelData.get_id('product',
'uom_cat_unit')
return ModelData.get_id('product', 'uom_cat_unit')
def get_uom_category(self, name):
if self.default_uom:
return self.default_uom.category.id
@staticmethod
def default_default_uom():
pool = Pool()
ModelData = pool.get('ir.model.data')
return ModelData.get_id('product', 'uom_unit')
@fields.depends('default_uom')
def on_change_default_uom(self):
if self.default_uom:
self.uom_category = self.default_uom.category
else:
self.uom_category = None
@classmethod
def view_attributes(cls):

View File

@ -12,6 +12,8 @@ this repository contains the full copyright notices and license terms. -->
<field name="yield_record_granularity"/>
<label name="manual_yield_record"/>
<field name="manual_yield_record"/>
<label name="default_uom"/>
<field name="default_uom"/>
</page>
</xpath>
</data>

View File

@ -315,7 +315,8 @@ class YieldAllocate(Wizard):
'offset_': i,
'date': date_,
'employee': sd.employee.id,
'quantity': offset_qty})
'quantity': offset_qty,
'quantity_uom': procedure.work.default_uom.id})
return offset_allocs
def transition_offset_(self):