project_service_activity.py 1.1 KB

1234567891011121314151617181920212223242526272829
  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('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. task_id = fields.Many2one('project.service.task', string="Work id")
  11. work_cost = fields.Float(string="Service Cost")
  12. duration = fields.Float(string='Duration')
  13. completed = fields.Boolean(string="Completed")
  14. _defaults = {
  15. 'user_id': lambda obj, cr, uid, ctx=None: uid,
  16. 'work_date': fields.datetime.now(),
  17. }
  18. @api.onchange('product_id')
  19. def get_price(self):
  20. self.work_cost = self.product_id.lst_price
  21. api.one
  22. @api.depends('task_id','product_id')
  23. def _get_product_name(self):
  24. self.name = self.task_id.name + ' / ' + self.product_id.name