project_service_activity.py 1.2 KB

123456789101112131415161718192021222324252627282930
  1. # -*- coding: utf-8 -*-
  2. from openerp import fields, models, api
  3. class ProjectServiceActivity(models.Model):
  4. _name = 'project.service.activity'
  5. name = fields.Char(string='Nombre', compute='_get_product_name')
  6. product_id = fields.Many2one('product.product', string='Planned work', domain=[('type', '=', 'service'),('sale_ok','=',True)])
  7. time_spent = fields.Float(string='Estimated Time')
  8. work_date = fields.Datetime(string='Date')
  9. user_id = fields.Many2one('res.users', string='Responsible')
  10. user2_id = fields.Many2one('res.users', string='Responsible')
  11. task_id = fields.Many2one('project.service.task', string="Work id")
  12. work_cost = fields.Float(string="Service Cost")
  13. duration = fields.Float(string='Duration')
  14. completed = fields.Boolean(string="Completed")
  15. _defaults = {
  16. 'user_id': lambda obj, cr, uid, ctx=None: uid,
  17. 'work_date': fields.datetime.now(),
  18. }
  19. @api.onchange('product_id')
  20. def get_price(self):
  21. self.work_cost = self.product_id.lst_price
  22. @api.one
  23. @api.depends('task_id','product_id')
  24. def _get_product_name(self):
  25. self.name = self.task_id.name + ' / ' + self.product_id.name