|
@@ -64,8 +64,6 @@ class CarWorkshop(models.Model):
|
|
|
('workshop_create_invoices', 'Invoiced'),
|
|
|
('cancel', 'Invoice Canceled'),
|
|
|
], string='Status', readonly=True, default='waiting', track_visibility='onchange', select=True)
|
|
|
- attachment_ids = fields.One2many('ir.attachment', 'res_id', domain=lambda self: [('res_model', '=', self._name)],
|
|
|
- auto_join=True, string='Attachments')
|
|
|
planned_works = fields.One2many('planned.work', 'work_id', string='Planned/Ordered Works')
|
|
|
works_done = fields.One2many('planned.work', 'work_id', string='Work Done', domain=[('completed', '=', True)])
|
|
|
materials_used = fields.One2many('material.used', 'material_id', string='Materials Used')
|
|
@@ -73,15 +71,6 @@ class CarWorkshop(models.Model):
|
|
|
effective_hour = fields.Float(string='Hours Spent', readonly=True, compute="hours_spent")
|
|
|
amount_total = fields.Float(string='Total Amount', readonly=True, compute="amount_total1")
|
|
|
|
|
|
- def _get_default_stages(self, cr, uid, context=None):
|
|
|
- """ Gives default stage_id """
|
|
|
- if context is None:
|
|
|
- context = {}
|
|
|
- default_vehicle_id = context.get('default_vehicle_id')
|
|
|
- if not default_vehicle_id:
|
|
|
- return False
|
|
|
- return self.find_stage(cr, uid, [], default_vehicle_id, [('fold', '=', False)], context=context)
|
|
|
-
|
|
|
_defaults = {
|
|
|
'stage_id': 1,
|
|
|
'vehicle_id': lambda self, cr, uid, ctx=None: ctx.get('default_vehicle_id') if ctx is not None else False,
|
|
@@ -220,36 +209,6 @@ class CarWorkshop(models.Model):
|
|
|
remaining_hour += line.time_spent
|
|
|
self.remaining_hour = remaining_hour-self.effective_hour
|
|
|
|
|
|
- # def process_demo_scheduler_queue(self, cr, uid, context=None):
|
|
|
- # obj = self.pool.get('car.workshop')
|
|
|
- # obj1 = obj.search(cr, uid, [])
|
|
|
- # now = fields.Datetime.from_string(fields.Datetime.now())
|
|
|
- # for obj2 in obj1:
|
|
|
- # obj3 = obj.browse(cr, uid, obj2, context=context)
|
|
|
- # if obj3.stage_id.name != 'Done' and obj3.stage_id.name != 'Cancelled' and obj3.stage_id.name != 'Verified':
|
|
|
- # start_date = fields.Datetime.from_string(obj3.date_start)
|
|
|
- # end_date = fields.Datetime.from_string(obj3.date_deadline)
|
|
|
- # if obj3.date_deadline and end_date > start_date:
|
|
|
- # if now < end_date:
|
|
|
- # diff1 = relativedelta(end_date, start_date)
|
|
|
- # if diff1.days == 0:
|
|
|
- # total_hr = int(diff1.minutes)
|
|
|
- # else:
|
|
|
- # total_hr = int(diff1.days) * 24 * 60 + int(diff1.minutes)
|
|
|
- # diff2 = relativedelta(now, start_date)
|
|
|
- # if diff2.days == 0:
|
|
|
- # current_hr = int(diff2.minutes)
|
|
|
- # else:
|
|
|
- # current_hr = int(diff2.days) * 24 * 60 + int(diff2.minutes)
|
|
|
- # if total_hr != 0:
|
|
|
- # obj3.progress = ((current_hr * 100) / total_hr)
|
|
|
- # else:
|
|
|
- # obj3.progress = 100
|
|
|
- # else:
|
|
|
- # obj3.progress = 100
|
|
|
- # else:
|
|
|
- # obj3.progress = 0
|
|
|
-
|
|
|
def _track_subtype(self, cr, uid, ids, init_values, context=None):
|
|
|
record = self.browse(cr, uid, ids[0], context=context)
|
|
|
if 'kanban_state' in init_values and record.kanban_state == 'blocked':
|
|
@@ -325,7 +284,7 @@ class CarWorkshop(models.Model):
|
|
|
vehicle = self.pool.get('fleet.vehicle').browse(cr, uid, vehicle_id, context=context)
|
|
|
if vehicle.exists():
|
|
|
values['partner_id'] = vehicle.partner_id.id
|
|
|
- values['stage_id'] = self.find_stage(cr, uid, [], vehicle_id, [('fold', '=', False)], context=context)
|
|
|
+ # values['stage_id'] = self.find_stage(cr, uid, [], vehicle_id, [('fold', '=', False)], context=context)
|
|
|
else:
|
|
|
values['stage_id'] = False
|
|
|
return {'value': values}
|
|
@@ -338,24 +297,3 @@ class CarWorkshop(models.Model):
|
|
|
if vehicle and vehicle.partner_id:
|
|
|
return vehicle.partner_id.id
|
|
|
return False
|
|
|
-
|
|
|
- def find_stage(self, cr, uid, cases, section_id, domain=[], order='sequence', context=None):
|
|
|
- if isinstance(cases, (int, long)):
|
|
|
- cases = self.browse(cr, uid, cases, context=context)
|
|
|
- section_ids = []
|
|
|
- if section_id:
|
|
|
- section_ids.append(section_id)
|
|
|
- for task in cases:
|
|
|
- if task.vehicle_id:
|
|
|
- section_ids.append(task.vehicle_id.id)
|
|
|
- search_domain = []
|
|
|
- if section_ids:
|
|
|
- search_domain = [('|')] * (len(section_ids) - 1)
|
|
|
- for section_id in section_ids:
|
|
|
- search_domain.append(('vehicle_ids', '=', section_id))
|
|
|
- search_domain += list(domain)
|
|
|
- # perform search, return the first found
|
|
|
- stage_ids = self.pool.get('worksheet.stages').search(cr, uid, search_domain, order=order, context=context)
|
|
|
- if stage_ids:
|
|
|
- return stage_ids[0]
|
|
|
- return False
|