timesheet.py 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. # -*- coding: utf-8 -*-
  2. ##############################################################################
  3. #
  4. # Cybrosys Technologies Pvt. Ltd.
  5. # Copyright (C) 2008-TODAY Cybrosys Technologies(<http://www.cybrosys.com>).
  6. # Author: Nilmar Shereef(<http://www.cybrosys.com>)
  7. # you can modify it under the terms of the GNU LESSER
  8. # GENERAL PUBLIC LICENSE (LGPL v3), Version 3.
  9. #
  10. # It is forbidden to publish, distribute, sublicense, or sell copies
  11. # of the Software or modified copies of the Software.
  12. #
  13. # This program is distributed in the hope that it will be useful,
  14. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. # GNU LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details.
  17. #
  18. # You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE
  19. # GENERAL PUBLIC LICENSE (LGPL v3) along with this program.
  20. # If not, see <http://www.gnu.org/licenses/>.
  21. #
  22. ##############################################################################
  23. from openerp import fields, models, api
  24. class PlannedWork (models.Model):
  25. _name = 'planned.work'
  26. planned_work = fields.Many2one('product.template', string='Planned work', domain=[('type', '=', 'service'),('sale_ok','=',True)])
  27. time_spent = fields.Float(string='Estimated Time')
  28. work_date = fields.Datetime(string='Date')
  29. responsible = fields.Many2one('res.users', string='Responsible')
  30. work_id = fields.Many2one('car.workshop', string="Work id")
  31. work_cost = fields.Float(string="Service Cost")
  32. completed = fields.Boolean(string="Completed")
  33. duration = fields.Float(string='Duration')
  34. work_date2 = fields.Datetime(string='Date')
  35. @api.onchange('planned_work')
  36. def get_price(self):
  37. self.work_cost = self.planned_work.lst_price
  38. class MaterialUsed (models.Model):
  39. _name = 'material.used'
  40. material = fields.Many2one('product.template', string='Productos', domain=[('sale_ok','=',True)])
  41. amount = fields.Integer(string='Cantidad', default=1)
  42. price = fields.Float(string='Precio Unitario')
  43. material_id = fields.Many2one('car.workshop', string='Material')
  44. @api.onchange('material')
  45. def get_price(self):
  46. self.price = self.material.lst_price