lineatarea.py
1.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# -*- 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