forked from OCA/field-service
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[IMP] OCA#122 Convert Locations from Contact
- Loading branch information
1 parent
c1b288b
commit 858cf3c
Showing
2 changed files
with
27 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,5 +7,6 @@ | |
stock, | ||
fsm_equipment, | ||
product_template, | ||
stock_production_lot | ||
stock_production_lot, | ||
fsm_wizard | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |