diff --git a/cb_maintenance/__manifest__.py b/cb_maintenance/__manifest__.py index 8f6e001a..b5a73c7f 100644 --- a/cb_maintenance/__manifest__.py +++ b/cb_maintenance/__manifest__.py @@ -5,7 +5,7 @@ "name": "Cb Maintenance", "summary": """ CB maintenance base""", - "version": "14.0.3.0.0", + "version": "16.0.1.0.0", "license": "AGPL-3", "author": "CreuBlanca", "website": "https://github.com/tegin/cb-maintenance", @@ -17,7 +17,6 @@ "maintenance_equipment_image", "maintenance_equipment_hierarchy", "maintenance_location", - "maintenance_request_custom_info", "maintenance_request_sequence", "maintenance_request_stage_transition", "maintenance_team_hierarchy", diff --git a/cb_maintenance/i18n/cb_maintenance.pot b/cb_maintenance/i18n/cb_maintenance.pot index 362d9fbd..8ae62dca 100644 --- a/cb_maintenance/i18n/cb_maintenance.pot +++ b/cb_maintenance/i18n/cb_maintenance.pot @@ -150,16 +150,6 @@ msgstr "" msgid "Created on" msgstr "" -#. module: cb_maintenance -#: model:ir.model.fields,field_description:cb_maintenance.field_maintenance_equipment_category__custom_info_template_id -msgid "Custom Info Template" -msgstr "" - -#. module: cb_maintenance -#: model:ir.model.fields,field_description:cb_maintenance.field_maintenance_request__custom_info_template_id -msgid "Custom Information Template" -msgstr "" - #. module: cb_maintenance #: model:ir.model.fields,help:cb_maintenance.field_maintenance_request__request_date msgid "Date requested for the maintenance to happen" diff --git a/cb_maintenance/i18n/es.po b/cb_maintenance/i18n/es.po index c2e3aaec..88652b1f 100644 --- a/cb_maintenance/i18n/es.po +++ b/cb_maintenance/i18n/es.po @@ -152,16 +152,6 @@ msgstr "Creadas por mí" msgid "Created on" msgstr "Creado el" -#. module: cb_maintenance -#: model:ir.model.fields,field_description:cb_maintenance.field_maintenance_equipment_category__custom_info_template_id -msgid "Custom Info Template" -msgstr "Plantilla de inf. personalizada" - -#. module: cb_maintenance -#: model:ir.model.fields,field_description:cb_maintenance.field_maintenance_request__custom_info_template_id -msgid "Custom Information Template" -msgstr "Plantilla de inf. personalizada" - #. module: cb_maintenance #: model:ir.model.fields,help:cb_maintenance.field_maintenance_request__request_date msgid "Date requested for the maintenance to happen" diff --git a/cb_maintenance/models/maintenance_equipment.py b/cb_maintenance/models/maintenance_equipment.py index d1c7f702..674d1e3b 100644 --- a/cb_maintenance/models/maintenance_equipment.py +++ b/cb_maintenance/models/maintenance_equipment.py @@ -9,10 +9,9 @@ class MaintenanceEquipment(models.Model): _inherit = "maintenance.equipment" _rec_name = "complete_name" _order = "code desc" + _rec_names_search = ["complete_name", "code"] - complete_name = fields.Char( - "Complete Name", compute="_compute_complete_name", store=True - ) + complete_name = fields.Char(compute="_compute_complete_name", store=True) company_id = fields.Many2one("res.company", readonly=True) partner_technician_id = fields.Many2one( @@ -41,8 +40,6 @@ def _prepare_request_from_plan(self, maintenance_plan, next_maintenance_date): def _create_new_request(self, maintenance_plan): requests = super()._create_new_request(maintenance_plan) - for request in requests: - request._onchange_custom_info_template_id() return requests @api.depends("name", "code") @@ -62,17 +59,3 @@ def create(self, mvals): or "/" ) return equipments - - @api.model - def name_search(self, name="", args=None, operator="ilike", limit=100): - # Make a search with default criteria - names1 = super().name_search( - name=name, args=args, operator=operator, limit=limit - ) - # Make the other search - names2 = [] - if name: - domain = [("code", "=ilike", name + "%")] - names2 = self.search(domain, limit=limit).name_get() - # Merge both results - return list(set(names1) | set(names2))[:limit] diff --git a/cb_maintenance/models/maintenance_equipment_category.py b/cb_maintenance/models/maintenance_equipment_category.py index cabaf733..05026ebf 100644 --- a/cb_maintenance/models/maintenance_equipment_category.py +++ b/cb_maintenance/models/maintenance_equipment_category.py @@ -11,19 +11,15 @@ class MaintenanceEquipmentCategory(models.Model): maintenance_team_id = fields.Many2one("maintenance.team") selectable = fields.Boolean(string="Selectable by users") - requires_equipment = fields.Boolean(string="Requires Equipment") - requires_location = fields.Boolean(string="Requires Location") + requires_equipment = fields.Boolean() + requires_location = fields.Boolean() maintenance_team_id_member_ids = fields.Many2many( "res.users", relation="selectable_maintenance_members", compute="_compute_maintenance_team_id_member_ids", ) - sequence = fields.Integer(string="Sequence", default=10) - - custom_info_template_id = fields.Many2one( - "custom.info.template", domain=[("model", "=", "maintenance.request")] - ) + sequence = fields.Integer(default=10) @api.depends("maintenance_team_id") def _compute_maintenance_team_id_member_ids(self): diff --git a/cb_maintenance/models/maintenance_request.py b/cb_maintenance/models/maintenance_request.py index 0a8dc1e5..7ec9b4e4 100644 --- a/cb_maintenance/models/maintenance_request.py +++ b/cb_maintenance/models/maintenance_request.py @@ -9,9 +9,6 @@ class MaintenanceRequest(models.Model): _inherit = "maintenance.request" - custom_info_template_id = fields.Many2one( - related="category_id.custom_info_template_id", store=True - ) company_id = fields.Many2one(default=False) days_to_close = fields.Integer(store=True, compute="_compute_days_to_close") hours_to_close = fields.Float(store=True, compute="_compute_hours_to_close") diff --git a/cb_maintenance/tests/test_cb_maintenance.py b/cb_maintenance/tests/test_cb_maintenance.py index 5935e4bd..4288eb22 100644 --- a/cb_maintenance/tests/test_cb_maintenance.py +++ b/cb_maintenance/tests/test_cb_maintenance.py @@ -2,10 +2,10 @@ # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). from odoo.exceptions import ValidationError -from odoo.tests.common import Form, SavepointCase +from odoo.tests.common import Form, TransactionCase -class TestCbMaintenance(SavepointCase): +class TestCbMaintenance(TransactionCase): @classmethod def setUpClass(cls): super().setUpClass() @@ -186,30 +186,3 @@ def test_request_creation(self): for r in request: self.assertIn("Description", r.note) self.assertFalse(r.description) - - def test_custom_info(self): - model = self.env["ir.model"].search([("model", "=", "maintenance.request")]) - template_id = self.env["custom.info.template"].create( - { - "name": "Template", - "model_id": model.id, - "property_ids": [(0, 0, {"name": "Prop 1"})], - } - ) - self.categ_id.write({"custom_info_template_id": template_id.id}) - maintenance_plan = self.env["maintenance.plan"].create( - { - "equipment_id": self.equipment_id.id, - "category_id": self.categ_id.id, - "interval": 1, - "interval_step": "month", - "maintenance_plan_horizon": 1, - "planning_step": "week", - } - ) - requests = self.equipment_id.env["maintenance.equipment"]._create_new_request( - maintenance_plan - ) - requests.custom_info_ids.invalidate_cache() - self.assertTrue(requests.custom_info_template_id) - self.assertTrue(requests.custom_info_ids) diff --git a/cb_maintenance/views/maintenance_equipment_category.xml b/cb_maintenance/views/maintenance_equipment_category.xml index da466136..9af76746 100644 --- a/cb_maintenance/views/maintenance_equipment_category.xml +++ b/cb_maintenance/views/maintenance_equipment_category.xml @@ -25,7 +25,6 @@ - 1 diff --git a/cb_maintenance/views/maintenance_request.xml b/cb_maintenance/views/maintenance_request.xml index 110e7c6c..6cd712ee 100644 --- a/cb_maintenance/views/maintenance_request.xml +++ b/cb_maintenance/views/maintenance_request.xml @@ -5,10 +5,7 @@ maintenance.request.form (in cb_maintenance) maintenance.request - + 99
@@ -148,9 +145,6 @@ 1 - - 1 - 0 @@ -184,14 +178,11 @@ >maintenance.request.form (in cb_maintenance for manager) maintenance.request - true true + maintenance.group_equipment_manager
@@ -233,13 +224,11 @@ >maintenance.request.tree (in cb_maintenance for manager)
maintenance.request - + true + maintenance.group_equipment_manager @@ -273,13 +262,10 @@ >maintenance.request.kanban (in cb_maintenance for manager) maintenance.request - true + maintenance.group_equipment_manager diff --git a/cb_maintenance/wizards/wizard_create_maintenance_request.py b/cb_maintenance/wizards/wizard_create_maintenance_request.py index 8a69c69d..10ecc955 100644 --- a/cb_maintenance/wizards/wizard_create_maintenance_request.py +++ b/cb_maintenance/wizards/wizard_create_maintenance_request.py @@ -21,7 +21,6 @@ class WizardCreateMaintenanceRequest(models.TransientModel): priority = fields.Selection( [("0", "Normal"), ("1", "Low"), ("2", "High"), ("3", "Very High")], - string="Priority", default="0", ) equipment_category = fields.Many2one( @@ -62,7 +61,6 @@ def create_request_vals(self): def create_request(self): self.ensure_one() request = self.env["maintenance.request"].create(self.create_request_vals()) - request._onchange_custom_info_template_id() original_request = self.env.context.get("original_request", False) if original_request: original_request = self.env["maintenance.request"].browse(original_request) diff --git a/cb_maintenance/wizards/wizard_mass_change_stage.py b/cb_maintenance/wizards/wizard_mass_change_stage.py index f3d062cc..2d4648fc 100644 --- a/cb_maintenance/wizards/wizard_mass_change_stage.py +++ b/cb_maintenance/wizards/wizard_mass_change_stage.py @@ -19,13 +19,12 @@ def set_stage(self): if request.stage_id not in self.stage_id.previous_stage_ids: raise ValidationError( _( - "Stage of request %s is not valid." - " Transition from %s to %s is not allowed" - ) - % ( - request.display_name, - request.stage_id.name, - self.stage_id.name, + "Stage of request %(request_display_name)s is not valid." + " Transition from %(request_stage_name)s to" + " %(stage_name)s is not allowed", + request_display_name=request.display_name, + request_stage_name=request.stage_id.name, + stage_name=self.stage_id.name, ) ) return requests.with_context(