lineatarea.py 1.88 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='Tarea',
    #     comodel_name='hgt.tarea',
    #     relation='tarea_lineatarea_rel',
    #     column1='hgt_tarea_id',
    #     column2='hgt_linea_tarea_id',
    # )

    tarea = fields.Many2one(
        string=u'Tarea',
        comodel_name='hgt.tarea',
        ondelete='set null',
    )

    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    

    # def crear(self,usuario,desde,hasta,liquidacion):
    #     tareas = self.env['hgt.tarea'].search([])
    #     #tareas = self.env['hgt.tarea'].search([('ejecutor','=',usuario.id),('inicio', '>=', desde),('cierre', '<=', hasta)])

    #     for tarea in tareas.ids:

    #         nva_lin = self.create({
    #         'tarea': tarea,
    #         })

    #         nva_lin.liquidaciones: liquidacion