diff --git a/fieldservice_location_builder/__init__.py b/fieldservice_location_builder/__init__.py index f42ea8aff6..61498f2961 100644 --- a/fieldservice_location_builder/__init__.py +++ b/fieldservice_location_builder/__init__.py @@ -1,4 +1,3 @@ # Copyright (C) 2019 Open Source Integrators # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -from . import models from . import wizard diff --git a/fieldservice_location_builder/__manifest__.py b/fieldservice_location_builder/__manifest__.py index c8fd4ee473..7df584754a 100644 --- a/fieldservice_location_builder/__manifest__.py +++ b/fieldservice_location_builder/__manifest__.py @@ -2,24 +2,22 @@ # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). { - 'name': 'Field Service Location Builder', - 'summary': 'Adds a tool to help build out Location Hierarchies', - 'version': '14.0.1.0.0', - 'category': 'Field Service', - 'author': 'Open Source Integrators, Odoo Community Association (OCA)', - 'website': 'https://github.com/OCA/field-service', - 'depends': [ - 'fieldservice_account_analytic' + "name": "Field Service Location Builder", + "summary": "Adds a tool to help build out Location Hierarchies", + "version": "14.0.1.0.0", + "category": "Field Service", + "author": "Open Source Integrators, Odoo Community Association (OCA)", + "website": "https://github.com/OCA/field-service", + "depends": ["fieldservice"], + "data": [ + "security/ir.model.access.csv", + "wizard/fsm_location_builder_wizard.xml", + "wizard/fsm_location_level.xml", ], - 'data': [ - 'security/ir.model.access.csv', - 'wizard/fsm_location_builder_wizard.xml', - 'wizard/fsm_location_level.xml', - ], - 'license': 'AGPL-3', - 'development_status': 'Beta', - 'maintainers': [ - 'osi-scampbell', - 'max3903', + "license": "AGPL-3", + "development_status": "Beta", + "maintainers": [ + "osi-scampbell", + "max3903", ], } diff --git a/fieldservice_location_builder/readme/DESCRIPTION.rst b/fieldservice_location_builder/readme/DESCRIPTION.rst index 672e2440ab..10227cd87a 100644 --- a/fieldservice_location_builder/readme/DESCRIPTION.rst +++ b/fieldservice_location_builder/readme/DESCRIPTION.rst @@ -1,9 +1,9 @@ -With the Field Service App, building out a site like an apartment complex -with multiple buildings, floors, units can become cumbersome and -tedious to build all the records. Even building an importable spreadsheet +With the Field Service App, building out a site like an apartment complex +with multiple buildings, floors, units can become cumbersome and +tedious to build all the records. Even building an importable spreadsheet can be tedious to build, and new users will struggle with this. -This module is for organizations that needs to create the locations -structure (~100 sub-locations) of a new site in less than a minute. -It provides a wizard on a location that will assist in building the +This module is for organizations that needs to create the locations +structure (~100 sub-locations) of a new site in less than a minute. +It provides a wizard on a location that will assist in building the sub-location hierarchy. diff --git a/fieldservice_location_builder/wizard/fsm_location_builder_wizard.py b/fieldservice_location_builder/wizard/fsm_location_builder_wizard.py index 67314a75d3..d780590544 100644 --- a/fieldservice_location_builder/wizard/fsm_location_builder_wizard.py +++ b/fieldservice_location_builder/wizard/fsm_location_builder_wizard.py @@ -4,54 +4,52 @@ class FSMLocationBuilderWizard(models.TransientModel): - _name = 'fsm.location.builder.wizard' - _description = 'FSM Location Builder Wizard' - level_ids = fields.One2many('fsm.location.level', - 'wizard_id', string="Level ID's") - + _name = "fsm.location.builder.wizard" + _description = "FSM Location Builder Wizard" + level_ids = fields.One2many("fsm.location.level", "wizard_id", string="Level ID's") def create_sub_locations(self): levels = len(self.level_ids) - 1 - location = self.env['fsm.location'].\ - browse(self.env.context.get('active_id')) + location = self.env["fsm.location"].browse(self.env.context.get("active_id")) def build_location(parent, num): if self.level_ids[num].spacer: spacer = " " + self.level_ids[num].spacer + " " else: spacer = " " - for lev_id in range(self.level_ids[num].start_number, - self.level_ids[num].end_number + 1): + for lev_id in range( + self.level_ids[num].start_number, self.level_ids[num].end_number + 1 + ): vals = self.prepare_fsm_location_values( - location, parent, spacer, lev_id, num) - new_location = self.env['fsm.location'].create(vals) + location, parent, spacer, lev_id, num + ) + new_location = self.env["fsm.location"].create(vals) if num < levels: build_location(new_location, num + 1) + build_location(location, 0) - def prepare_fsm_location_values(self, location, parent, - spacer, lev_id, num): + def prepare_fsm_location_values(self, location, parent, spacer, lev_id, num): tags = self.level_ids[num].tag_ids.ids - vals = {'name': self.level_ids[num].name + spacer + str(lev_id), - 'owner_id': location.owner_id.id, - 'customer_id': location.customer_id.id, - 'fsm_parent_id': parent.id, - 'street': location.street, - 'street2': self.level_ids[num].name + spacer + str(lev_id), - 'city': location.city, - 'zip': location.zip, - } + vals = { + "name": self.level_ids[num].name + spacer + str(lev_id), + "owner_id": location.owner_id.id, + "customer_id": location.customer_id.id, + "fsm_parent_id": parent.id, + "street": location.street, + "street2": self.level_ids[num].name + spacer + str(lev_id), + "city": location.city, + "zip": location.zip, + } if tags: - vals.update({ - 'category_id': [(6, 0, tags)] - }) + vals.update({"category_id": [(6, 0, tags)]}) if location.state_id: - vals.update([('state_id', location.state_id.id)]) + vals.update([("state_id", location.state_id.id)]) if location.country_id: - vals.update([('country_id', location.country_id.id)]) + vals.update([("country_id", location.country_id.id)]) if location.territory_id: - vals.update([('territory_id', location.territory_id.id)]) + vals.update([("territory_id", location.territory_id.id)]) if location.tz: - vals.update([('tz', location.tz)]) + vals.update([("tz", location.tz)]) return vals diff --git a/fieldservice_location_builder/wizard/fsm_location_builder_wizard.xml b/fieldservice_location_builder/wizard/fsm_location_builder_wizard.xml index f5cdd0b1cd..6a1a6ce7a8 100644 --- a/fieldservice_location_builder/wizard/fsm_location_builder_wizard.xml +++ b/fieldservice_location_builder/wizard/fsm_location_builder_wizard.xml @@ -7,18 +7,27 @@
- - - - - - - + + + + + + +
@@ -30,7 +39,9 @@ new form - {'default_primary_location_id': active_id, 'default_owner_id': context.get('owner_id.id',False)} + {'default_primary_location_id': active_id, 'default_owner_id': context.get('owner_id.id',False)} diff --git a/fieldservice_location_builder/wizard/fsm_location_level.py b/fieldservice_location_builder/wizard/fsm_location_level.py index ae3f2cd32b..30ea6c1636 100644 --- a/fieldservice_location_builder/wizard/fsm_location_level.py +++ b/fieldservice_location_builder/wizard/fsm_location_level.py @@ -4,25 +4,25 @@ class FSMLocationLevel(models.TransientModel): - _name = 'fsm.location.level' - _description = 'Level in the FSM location tree structure' + _name = "fsm.location.level" + _description = "Level in the FSM location tree structure" sequence = fields.Integer("Sequence") name = fields.Char("Name", required=True) spacer = fields.Char("Spacer") start_number = fields.Integer("Start Number") end_number = fields.Integer("End Number") - total_number = fields.Integer("Total", compute='_compute_total_number') - tag_ids = fields.Many2many('res.partner.category', string="Tags", - readonly=False) - wizard_id = fields.Many2one('fsm.location.builder.wizard', "Wizard") + total_number = fields.Integer("Total", compute="_compute_total_number") + tag_ids = fields.Many2many("res.partner.category", string="Tags", readonly=False) + wizard_id = fields.Many2one("fsm.location.builder.wizard", "Wizard") - @api.depends('start_number', 'end_number') + @api.depends("start_number", "end_number") def _compute_total_number(self): for level_id in self: level_id.total_number = 0 - if (level_id.start_number is not None and - level_id.end_number is not None and - level_id.start_number < level_id.end_number): - level_id.total_number = (level_id.end_number - - level_id.start_number + 1) + if ( + level_id.start_number is not None + and level_id.end_number is not None + and level_id.start_number < level_id.end_number + ): + level_id.total_number = level_id.end_number - level_id.start_number + 1 diff --git a/fieldservice_location_builder/wizard/fsm_location_level.xml b/fieldservice_location_builder/wizard/fsm_location_level.xml index 462ea4a4d1..664e68a7da 100644 --- a/fieldservice_location_builder/wizard/fsm_location_level.xml +++ b/fieldservice_location_builder/wizard/fsm_location_level.xml @@ -6,13 +6,13 @@ fsm.location.level - - - - - - - + + + + + + + @@ -24,14 +24,14 @@
-
diff --git a/setup/fieldservice_location_builder/odoo/addons/fieldservice_location_builder b/setup/fieldservice_location_builder/odoo/addons/fieldservice_location_builder new file mode 120000 index 0000000000..a84d1f31e3 --- /dev/null +++ b/setup/fieldservice_location_builder/odoo/addons/fieldservice_location_builder @@ -0,0 +1 @@ +../../../../fieldservice_location_builder \ No newline at end of file diff --git a/setup/fieldservice_location_builder/setup.py b/setup/fieldservice_location_builder/setup.py new file mode 100644 index 0000000000..28c57bb640 --- /dev/null +++ b/setup/fieldservice_location_builder/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +)