Skip to content

Commit

Permalink
[IMP] fieldservice_repair (OCA#158)
Browse files Browse the repository at this point in the history
* [IMP] fieldservice_repair
  • Loading branch information
osi-scampbell authored and aaladro-kernet committed Dec 11, 2024
1 parent 86b5ca0 commit 5009753
Showing 1 changed file with 10 additions and 2 deletions.
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

0 comments on commit 5009753

Please sign in to comment.