Skip to content

Commit

Permalink
Merge b75ae9e into 906a74b
Browse files Browse the repository at this point in the history
  • Loading branch information
lmgr0312 committed Jul 18, 2018
2 parents 906a74b + b75ae9e commit 356823c
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 15 deletions.
4 changes: 2 additions & 2 deletions vms/demo/fleet_vehicle_model_brand.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
<odoo>
<record id="fleet_vehicle_model_brand_kenworth" model="fleet.vehicle.model.brand">
<field name="name">Kenworth</field>
<field name="image" type="base64" file="tms/static/src/img/brand_kenworth-image.png"/>
<field name="image" type="base64" file="vms/static/src/img/brand_kenworth-image.png"/>
</record>
<record id="fleet_vehicle_model_brand_trailking" model="fleet.vehicle.model.brand">
<field name="name">Trail King</field>
<field name="image" type="base64" file="tms/static/src/img/brand_trailking-image.png"/>
<field name="image" type="base64" file="vms/static/src/img/brand_trailking-image.png"/>
</record>
<record id="fleet_vehicle_model_t800" model="fleet.vehicle.model">
<field name="name">T800</field>
Expand Down
29 changes: 18 additions & 11 deletions vms/models/fleet_vehicle.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
from __future__ import division

from datetime import timedelta

from odoo import api, fields, models
from odoo import _, api, fields, models


class FleetVehicle(models.Model):
Expand Down Expand Up @@ -48,15 +47,23 @@ def cron_vehicle_maintenance(self):
'program_id': vehicle.program_id.id,

})
mail_invite = follower.with_context({
'default_res_model': 'vms.order',
'default_res_id': new_order.id
}).create({
'partner_ids': [(
4, vehicle.supervisor_id.address_home_id.id)],
'send_mail': True,
})
mail_invite.add_followers()
new_order.get_tasks_from_cycle(cycle, new_order)
if vehicle.supervisor_id.address_home_id.id:
mail_invite = follower.with_context({
'default_res_model': 'vms.order',
'default_res_id': new_order.id
}).create({
'partner_ids': [(
4, vehicle.supervisor_id.address_home_id.id
)],
'send_mail': True,
})
mail_invite.add_followers()
else:
msg = (_('The supervisor was not added as '
'a document follower because does '
'not have a home_address assigned'))
new_order.message_post(body=msg)
else:
order_date = (
time.from_string(order.date) -
Expand Down
10 changes: 10 additions & 0 deletions vms/models/vms_order_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ class VmsOrderLine(models.Model):
compute='_compute_purchase_state')
order_id = fields.Many2one('vms.order', string='Order', readonly=True)
real_time_total = fields.Integer()
create_purchase_order = fields.Boolean(
compute='_compute_create_purchase_order')

@api.multi
def unlink(self):
Expand Down Expand Up @@ -115,6 +117,13 @@ def _compute_purchase_state(self):
rec.purchase_order_id.id and
rec.purchase_order_id.state == 'done')

@api.depends('spare_part_ids')
def _compute_create_purchase_order(self):
for rec in self:
rec.create_purchase_order = bool(
rec.spare_part_ids.filtered(
lambda x: x.external_spare_parts))

@api.multi
def action_process(self):
for rec in self:
Expand All @@ -128,6 +137,7 @@ def action_process(self):
if not rec.spare_part_ids:
return True
rec.spare_part_ids.procurement_create()
return True

@api.multi
def get_real_duration(self):
Expand Down
9 changes: 8 additions & 1 deletion vms/tests/test_fleet_vehicle.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from datetime import timedelta

from odoo import fields
from odoo import _, fields
from odoo.tests.common import TransactionCase


Expand Down Expand Up @@ -44,3 +44,10 @@ def test_cron_vehicle_maintenance(self):
mail = self.env['mail.message'].search(
[('res_id', '=', order.id)])
self.assertTrue(mail)

def test_cron_vehicle_maintenance_raise(self):
self.unit_id._compute_distance_averange()
self.supervisor.address_home_id = False
self.unit_id.cron_vehicle_maintenance()
order = self.env['vms.order'].search([])
self.assertEqual(len(order.message_ids), 2, 'error in supervisor')
3 changes: 2 additions & 1 deletion vms/views/vms_order_line_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
<field name="arch" type="xml">
<form string="Order lines">
<header>
<button name="create_po" string="Create Purchase Order" type="object"/>
<field name="create_purchase_order" invisible="1"/>
<button name="create_po" string="Create Purchase Order" type="object" attrs="{'invisible':[('create_purchase_order','=',False)]}"/>
<button name="action_cancel_draft" states="cancel" string="Set to Draft" type="object"/>
<button name="action_process" class="oe_highlight" states="draft" string="Start" type="object"/>
<button name="action_cancel" states="draft,process" string="Cancel" type="object" confirm="Are you sure to cancel this task?"/>
Expand Down
1 change: 1 addition & 0 deletions vms_activity/models/vms_order_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ def get_real_duration(self):
raise ValidationError(
_('All the activities must be finished.'))
rec.real_duration = duration_sum
return True

@api.multi
def action_cancel(self):
Expand Down
3 changes: 3 additions & 0 deletions vms_activity_kiosk/static/src/css/style.less
Original file line number Diff line number Diff line change
Expand Up @@ -156,4 +156,7 @@
margin-bottom: 3px;
opacity: 0.5;
}
}
#stop_task, #start_task, #pause_task{
font-size: 10px;
}

0 comments on commit 356823c

Please sign in to comment.