|
@@ -70,7 +70,8 @@ class CarWorkshop(models.Model):
|
|
|
remaining_hour = fields.Float(string='Remaining Hour',readonly=True, compute="hours_left")
|
|
|
effective_hour = fields.Float(string='Hours Spent', readonly=True, compute="hours_spent")
|
|
|
amount_total = fields.Float(string='Total Amount', readonly=True, compute="amount_total1")
|
|
|
-
|
|
|
+ include_materials = fields.Boolean('Incluir')
|
|
|
+
|
|
|
_defaults = {
|
|
|
'stage_id': 1,
|
|
|
'vehicle_id': lambda self, cr, uid, ctx=None: ctx.get('default_vehicle_id') if ctx is not None else False,
|
|
@@ -91,8 +92,9 @@ class CarWorkshop(models.Model):
|
|
|
amount_totall = 0.0
|
|
|
for line in hour.planned_works:
|
|
|
amount_totall += line.work_cost
|
|
|
- for line2 in hour.materials_used:
|
|
|
- amount_totall += line2.price
|
|
|
+ if self.include_materials==True:
|
|
|
+ for line2 in hour.materials_used:
|
|
|
+ amount_totall += line2.price
|
|
|
records.amount_total = amount_totall
|
|
|
|
|
|
@api.multi
|
|
@@ -101,14 +103,12 @@ class CarWorkshop(models.Model):
|
|
|
|
|
|
@api.multi
|
|
|
def workshop_create_invoices(self):
|
|
|
-
|
|
|
self.state = 'workshop_create_invoices'
|
|
|
inv_obj = self.env['account.invoice']
|
|
|
inv_line_obj = self.env['account.invoice.line']
|
|
|
customer = self.partner_id
|
|
|
if not customer.name:
|
|
|
raise osv.except_osv(_('UserError!'), _('Please select a Customer.'))
|
|
|
-
|
|
|
company_id = self.env['res.users'].browse(1).company_id
|
|
|
currency_value = company_id.currency_id.id
|
|
|
self.ensure_one()
|
|
@@ -142,29 +142,26 @@ class CarWorkshop(models.Model):
|
|
|
'invoice_id': inv_id.id,
|
|
|
}
|
|
|
inv_line_obj.create(inv_line_data)
|
|
|
-
|
|
|
for records in self.materials_used:
|
|
|
if records.material.id:
|
|
|
income_account = records.material.property_account_income.id
|
|
|
if not income_account:
|
|
|
raise osv.except_osv(_('UserError!'), _('There is no income account defined '
|
|
|
'for this product: "%s".') % (records.material.name,))
|
|
|
-
|
|
|
- inv_line_data = {
|
|
|
- 'name': records.material.name,
|
|
|
- 'account_id': records.material.property_account_income.id,
|
|
|
- 'price_unit': records.price,
|
|
|
- 'quantity': records.amount,
|
|
|
- 'product_id': records.material.id,
|
|
|
- 'invoice_id': inv_id.id,
|
|
|
- }
|
|
|
- inv_line_obj.create(inv_line_data)
|
|
|
-
|
|
|
+ if self.include_materials==True:
|
|
|
+ inv_line_data = {
|
|
|
+ 'name': records.material.name,
|
|
|
+ 'account_id': records.material.property_account_income.id,
|
|
|
+ 'price_unit': records.price,
|
|
|
+ 'quantity': records.amount,
|
|
|
+ 'product_id': records.material.id,
|
|
|
+ 'invoice_id': inv_id.id,
|
|
|
+ }
|
|
|
+ inv_line_obj.create(inv_line_data)
|
|
|
imd = self.env['ir.model.data']
|
|
|
action = imd.xmlid_to_object('account.action_invoice_tree1')
|
|
|
list_view_id = imd.xmlid_to_res_id('account.invoice_tree')
|
|
|
form_view_id = imd.xmlid_to_res_id('account.invoice_form')
|
|
|
-
|
|
|
result = {
|
|
|
'name': action.name,
|
|
|
'help': action.help,
|
|
@@ -183,7 +180,6 @@ class CarWorkshop(models.Model):
|
|
|
else:
|
|
|
result = {'type': 'ir.actions.act_window_close'}
|
|
|
invoiced_records = self.env['car.workshop']
|
|
|
-
|
|
|
total = 0
|
|
|
for rows in invoiced_records:
|
|
|
invoiced_date = rows.date
|
|
@@ -283,7 +279,6 @@ 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)
|
|
|
else:
|
|
|
values['stage_id'] = False
|
|
|
return {'value': values}
|