Skip to content

Commit

Permalink
[IMP] OCA#122 Convert Locations from Contact
Browse files Browse the repository at this point in the history
  • Loading branch information
osi-scampbell authored and gbrito committed Nov 3, 2022
1 parent c1b288b commit 858cf3c
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
3 changes: 2 additions & 1 deletion fieldservice_stock/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@
stock,
fsm_equipment,
product_template,
stock_production_lot
stock_production_lot,
fsm_wizard
)
25 changes: 25 additions & 0 deletions fieldservice_stock/models/fsm_wizard.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Copyright (C) 2018 - TODAY, Open Source Integrators
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import api, fields, models, _
from odoo.exceptions import UserError


class FSMWizard(models.TransientModel):
_inherit = 'fsm.wizard'


def action_convert_location(self, partner):
res = self.env['fsm.location'].search_count(
[('partner_id', '=', partner.id)])
if res == 0:
vals = {'partner_id': partner.id,
'owner_id': partner.id,
'customer_id': partner.id,
'inventory_location_id': partner.property_stock_customer.id}
self.env['fsm.location'].create(vals)
partner.write({'fsm_location': True})
else:
raise UserError(_('A Field Service Location related to that'
' partner already exists.'))
return res

0 comments on commit 858cf3c

Please sign in to comment.