lineatarea.py 1.34 KB
# -*- coding: utf-8 -*-

from odoo import models, fields, api

class hgt_linea_tarea(models.Model):
    _name = 'hgt.linea_tarea'

    liquidaciones = fields.Many2one(
        string='Liquidaciones',
        comodel_name='hgt.liquidacionestareas',
        ondelete='restrict',
    )
    
    tarea = fields.Many2many(
        string='Tareas',
        comodel_name='hgt.tarea',
        relation='tarea_lineatarea_rel',
        column1='hgt_tarea_id',
        column2='hgt_linea_tarea_id',
    )

    name = fields.Char(
        related='tarea.name',
        readonly=True,
        store=True
    )
    
    inicio = fields.Datetime(
        related='tarea.inicio',
        readonly=True,
        store=True
    )

    cierre = fields.Datetime(
        related='tarea.cierre',
        readonly=True,
        store=True
    )

    minutos_reales = fields.Integer(
        related='tarea.minutos_reales',
        readonly=True,
        store=True
    )

    
    tipo_cargo = fields.One2many(
        string='Tipo de Cargo',
        comodel_name='hgt.tipo_cargo',
        inverse_name='linea_tarea',
    )

    subtotal = fields.Float(
        string='Subtotal',
        compute='obtener_subtotal',
    )

    state = fields.Selection(
        related='tarea.state',
        readonly=True,
        store=True
    )

    def obtener_subtotal(self):
        return 0