Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[IMP] fieldservice_repair #158

Merged
merged 2 commits into from
Mar 14, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions fieldservice_repair/models/fsm_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

from odoo import api, fields
from odoo.addons.base_geoengine import geo_model
from odoo import _
from odoo.exceptions import ValidationError


class FSMOrder(geo_model.GeoModel):
Expand All @@ -18,7 +20,8 @@ def create(self, vals):
# create a repair order
order = super(FSMOrder, self).create(vals)
if order.type == 'repair':
if order.equipment_id:
if (order.equipment_id and
order.equipment_id.current_stock_location_id):
equipment = order.equipment_id
repair_id = self.env['mrp.repair'].create({
'name': order.name or '',
Expand All @@ -28,12 +31,17 @@ def create(self, vals):
equipment.current_stock_location_id.id or False,
'location_dest_id': equipment.current_stock_location_id and
equipment.current_stock_location_id.id or False,
'lot_id': equipment.lot_id and equipment.lot_id.name or '',
'lot_id': equipment.lot_id.id or '',
'product_qty': 1,
'invoice_method': 'none',
'internal_notes': order.description,
'partner_id': order.customer_id and order.customer_id.id or
False,
})
order.repair_id = repair_id
elif not order.equipment_id.current_stock_location_id:
raise ValidationError(_("Cannot create Repair " +
"Order because Equipment does " +
"not have a Current Inventory " +
"Location"))
return order