|
@@ -9,9 +9,9 @@ class ProjectServiceTask(models.Model):
|
|
|
_name = 'project.service.task'
|
|
|
|
|
|
name = fields.Char(string='Title', required=True)
|
|
|
- project_id = fields.Many2one('project.service', string='Vehicle', required=True, track_visibility='onchange')
|
|
|
+ project_id = fields.Many2one('project.service', string='Project', required=True, track_visibility='onchange')
|
|
|
user_id = fields.Many2one('res.users', string='Assigned to', select=True)
|
|
|
- description = fields.Html('Description')
|
|
|
+ description = fields.Html(string='Description')
|
|
|
priority = fields.Selection([('0', 'Normal'), ('1', 'High')], string='Priority', select=True)
|
|
|
partner_id = fields.Many2one('res.partner', string='Customer')
|
|
|
date_assign = fields.Datetime(string='Assigning Date', select=True, copy=False, readonly=True)
|
|
@@ -20,9 +20,12 @@ class ProjectServiceTask(models.Model):
|
|
|
stage_id = fields.Many2one('project.service.stage', string='Stage', track_visibility='onchange', copy=False)
|
|
|
effective_hour = fields.Float(string='Hours Spent', compute="hours_spent",readonly=True)
|
|
|
activity_ids = fields.One2many('project.service.activity', 'task_id', string='Planned/Ordered Works')
|
|
|
+ commission_ids = fields.One2many('project.service.commission', 'task_id', string='Commissions')
|
|
|
+ budget_ids = fields.One2many('project.service.budget', 'task_id', string='Budgets')
|
|
|
materials_used = fields.One2many('project.service.material', 'task_id', string='Materials Used')
|
|
|
amount_total = fields.Float(string='Total Amount', compute="get_amount_total", readonly=True)
|
|
|
include_materials = fields.Boolean('Incluir')
|
|
|
+ payment_term = fields.Many2one('account.payment.term', string='Payment Term')
|
|
|
state = fields.Selection([
|
|
|
('Preparado', 'Preparado'),
|
|
|
('Facturado', 'Facturado'),
|
|
@@ -34,12 +37,14 @@ class ProjectServiceTask(models.Model):
|
|
|
string='Facturas',
|
|
|
compute='_get_invoice_count',
|
|
|
)
|
|
|
+ approved = fields.Boolean(string="Aprobado")
|
|
|
works_done = fields.One2many('project.service.activity', 'task_id', string='Work Done', domain=[('completed', '=', True)])
|
|
|
_defaults = {
|
|
|
'stage_id': 1,
|
|
|
'state': 'Preparado',
|
|
|
'user_id': lambda obj, cr, uid, ctx=None: uid,
|
|
|
'date_start': fields.datetime.now(),
|
|
|
+ 'date_deadline': fields.datetime.now(),
|
|
|
}
|
|
|
|
|
|
@api.one
|
|
@@ -100,9 +105,11 @@ class ProjectServiceTask(models.Model):
|
|
|
@api.multi
|
|
|
def Facturado(self):
|
|
|
activity = self.activity_ids
|
|
|
- # print('****************************',activity,'**********************************')
|
|
|
+ approved = self.approved
|
|
|
if not activity:
|
|
|
- raise osv.except_osv(_('UserError!'), _('No puedes facturas una tarea sin actividades.'))
|
|
|
+ raise osv.except_osv(_('UserError!'), _('No puedes facturar una tarea sin actividades.'))
|
|
|
+ if not approved:
|
|
|
+ raise osv.except_osv(_('UserError!'), _('No puedes facturar un presupuesto no aprobado.'))
|
|
|
self.state = 'Facturado'
|
|
|
inv_obj = self.env['account.invoice']
|
|
|
inv_line_obj = self.env['account.invoice.line']
|
|
@@ -119,6 +126,7 @@ class ProjectServiceTask(models.Model):
|
|
|
'partner_id': customer.id,
|
|
|
'origin': self.name,
|
|
|
'task_invoice_id': self.id,
|
|
|
+ 'payment_term': self.payment_term.id,
|
|
|
}
|
|
|
inv_id = inv_obj.create(inv_data)
|
|
|
for records in self.activity_ids:
|