diff --git a/.gitignore b/.gitignore
index 2f78cf5..0d20b64 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1 @@
*.pyc
-
diff --git a/__manifest__.py b/__manifest__.py
index ddf00be..fa19fd6 100644
--- a/__manifest__.py
+++ b/__manifest__.py
@@ -29,8 +29,11 @@
'license': 'OPL-1',
'depends': ['project', 'stock', 'sale', 'sale_project', 'sale_stock', 'industry_fsm_sale'],
'data': ['views/task_template_views.xml',
+ 'views/equipment.xml',
+ 'views/equipment_location.xml',
'security/ir.model.access.csv',
'views/product_views.xml',
+ 'views/res_partner.xml',
],
'assets': {
'web.assets_tests': [
diff --git a/__pycache__/__init__.cpython-310.pyc b/__pycache__/__init__.cpython-310.pyc
deleted file mode 100644
index c093db2..0000000
Binary files a/__pycache__/__init__.cpython-310.pyc and /dev/null differ
diff --git a/models/__init__.py b/models/__init__.py
index 08966cb..997de6e 100644
--- a/models/__init__.py
+++ b/models/__init__.py
@@ -1,3 +1,6 @@
from . import task_template
from . import product_template
from . import sale_order
+from . import equipment
+from . import task
+from . import res_partner
diff --git a/models/__pycache__/__init__.cpython-310.pyc b/models/__pycache__/__init__.cpython-310.pyc
deleted file mode 100644
index 1c58b7f..0000000
Binary files a/models/__pycache__/__init__.cpython-310.pyc and /dev/null differ
diff --git a/models/__pycache__/product_template.cpython-310.pyc b/models/__pycache__/product_template.cpython-310.pyc
deleted file mode 100644
index 9398263..0000000
Binary files a/models/__pycache__/product_template.cpython-310.pyc and /dev/null differ
diff --git a/models/__pycache__/sale_order.cpython-310.pyc b/models/__pycache__/sale_order.cpython-310.pyc
deleted file mode 100644
index c87196c..0000000
Binary files a/models/__pycache__/sale_order.cpython-310.pyc and /dev/null differ
diff --git a/models/__pycache__/task_template.cpython-310.pyc b/models/__pycache__/task_template.cpython-310.pyc
deleted file mode 100644
index 7334f4c..0000000
Binary files a/models/__pycache__/task_template.cpython-310.pyc and /dev/null differ
diff --git a/models/equipment.py b/models/equipment.py
new file mode 100644
index 0000000..c928988
--- /dev/null
+++ b/models/equipment.py
@@ -0,0 +1,119 @@
+from odoo import api, fields, models
+
+
+class EquipmentTag(models.Model):
+
+ _name = "bemade_fsm.equipment.tag"
+ _description = 'Field service equipment category'
+
+ name = fields.Char('Name', required=True, translate=True)
+ color = fields.Integer('Color Index', default=10)
+
+ _sql_constraints = [
+ ('name_uniq', 'unique (name)', "Tag name already exists !"),
+ ]
+
+
+class EquipmentType(models.Model):
+ _name = 'bemade_fsm.equipment.type'
+ _description = 'Field service equipment type'
+ _order = 'id'
+
+ name = fields.Char(string='Intervention Name', required=True, translate=True)
+
+
+class EquipmentLocation(models.Model):
+ _name = 'bemade_fsm.equipment.location'
+ _description = 'Field service location for equipment'
+ _inherit = ['mail.thread', 'mail.activity.mixin']
+
+ name = fields.Char(string='Name', required=True, translate=True)
+
+ more_info = fields.Char(string='MOre info')
+
+ partner_id = fields.Many2one(comodel_name='res.partner',
+ string="Address",
+ tracking=True,
+ domain="[('is_site', '=', True)]",
+ required=True)
+
+ equipment_count = fields.Integer(compute='_compute_equipment_count',
+ string='Equipment Count')
+
+ equipment_ids = fields.One2many(comodel_name='bemade_fsm.equipment',
+ inverse_name='equipment_location_id',
+ string='Equipments')
+
+ @api.depends('equipment_ids')
+ def _compute_equipment_count(self):
+ for rec in self:
+ all_equipmemt_ids = self.env['bemade_fsm.equipment'].search([('equipment_location_id', '=', rec.id)])
+ rec.equipment_count = len(all_equipmemt_ids)
+
+
+class Equipment(models.Model):
+ _name = 'bemade_fsm.equipment'
+ _rec_name = 'complete_name'
+ _description = 'Field service equipment'
+ _inherit = ['mail.thread', 'mail.activity.mixin']
+
+ pid_tag = fields.Char(string="P&ID Tag", tracking=True)
+
+ name = fields.Char(string="Name", tracking=True, required=True)
+
+ complete_name = fields.Char(string="Equipment Name", compute="_compute_complete_name", store=True)
+
+ tag_ids = fields.Many2many('bemade_fsm.equipment.tag',
+ string='Application',
+ tracking=True,
+ help="Classify and analyze your equipment categories like: Boiler, Laboratory, "
+ "Waste water, Pure water")
+
+ partner_id = fields.Many2one('res.partner',
+ string="Owner",
+ tracking=True,
+ domain="[('is_company', '=', True)]",
+ required=True)
+
+ description = fields.Text(string="Description",
+ tracking=True,
+ )
+
+ partner_location_id = fields.Many2one('res.partner',
+ string="Physical Location",
+ tracking=True,
+ domain="[('parent_id', '=', partner_id), ('is_site', '=', 'True')]",
+ required=True)
+
+ equipment_location_id = fields.Many2one('bemade_fsm.equipment.location',
+ string="Location",
+ tracking=True,
+ domain="[('partner_id', '=', partner_location_id)]")
+
+ location_notes = fields.Text(string="Physical Location Notes",
+ tracking=True,
+ )
+
+ intervention_ids = fields.One2many(comodel_name='project.task',
+ inverse_name='equipment_id',
+ string='Interventions')
+
+ @api.depends('pid_tag', 'name')
+ def _compute_complete_name(self):
+ for rec in self:
+ rec.complete_name = "[%s] %s" % (rec.pid_tag or ' ', rec.name)
+
+ @api.model
+ def name_search(self, name='', args=None, operator='ilike', limit=100):
+ args = args or []
+ if name:
+ equipments = self.search([
+ '|', '|', '|',
+ ('pid_tag', operator, name),
+ ('name', operator, name),
+ ('partner_id.name', operator, name),
+ ('partner_location_id.name', operator, name)],
+ limit=limit)
+ else:
+ equipments = self.search(args, limit=limit)
+ return equipments.name_get()
diff --git a/models/res_partner.py b/models/res_partner.py
new file mode 100644
index 0000000..ab516d3
--- /dev/null
+++ b/models/res_partner.py
@@ -0,0 +1,41 @@
+from odoo import api, fields, models
+
+
+class Partner(models.Model):
+ _inherit = 'res.partner'
+
+ equipment_count = fields.Integer(compute='_compute_equipment_count',
+ string='Equipment Count')
+
+ equipment_ids = fields.One2many(comodel_name='bemade_fsm.equipment',
+ inverse_name='partner_id',
+ string='Equipments')
+
+ equipment_location_count = fields.Integer(compute='_compute_equipment_location_count',
+ string='Equipment Location Count')
+
+ equipment_location_ids = fields.One2many(comodel_name='bemade_fsm.equipment.location',
+ inverse_name='partner_id',
+ string='Equipment Location')
+
+ is_site = fields.Boolean(string='Is an Equipment Site',
+ tracking=True,
+ default=False,
+ help="Check if the contact is an equipment site, otherwise it is not in that list")
+
+ is_site_contact = fields.Boolean(string='Is a site contact',
+ tracking=True,
+ default=False,
+ help="Check if the contact is a site contact, otherwise it is a not in that list")
+
+ @api.depends('equipment_ids')
+ def _compute_equipment_count(self):
+ for rec in self:
+ all_equipmemt_ids = self.env['bemade_fsm.equipment'].search([('partner_id', '=', rec.id)])
+ rec.equipment_count = len(all_equipmemt_ids)
+
+ @api.depends('equipment_location_ids')
+ def _compute_equipment_location_count(self):
+ for rec in self:
+ all_equipmemt_location_ids = self.env['bemade_fsm.equipment.location'].search([('partner_id', '=', rec.id)])
+ rec.equipment_location_count = len(all_equipmemt_location_ids)
diff --git a/models/task.py b/models/task.py
new file mode 100644
index 0000000..7ee4a71
--- /dev/null
+++ b/models/task.py
@@ -0,0 +1,7 @@
+from odoo import fields, models, api
+
+
+class Task(models.Model):
+ _inherit = "project.task"
+
+ equipment_id = fields.Many2one("bemade_fsm.equipment", string="Target Equipment")
diff --git a/security/ir.model.access.csv b/security/ir.model.access.csv
index e48e8e7..086f935 100644
--- a/security/ir.model.access.csv
+++ b/security/ir.model.access.csv
@@ -1,3 +1,7 @@
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_bemade_fsm_task_template,bemade_fsm_task_template,model_project_task_template,project.group_project_manager,1,1,1,1
-access_bemade_fsm_task_template,bemade_fsm_task_template,model_project_task_template,project.group_project_user,1,1,1,1
\ No newline at end of file
+access_bemade_fsm_task_template,bemade_fsm_task_template,model_project_task_template,project.group_project_user,1,1,1,1
+access_bemade_fsm_equipment,bemade_fsm_equipment,model_bemade_fsm_equipment,base.group_user,1,1,1,1
+access_bemade_fsm_equipment_tag,bemade_fsm_equipment_tag,model_bemade_fsm_equipment_tag,base.group_user,1,1,1,1
+access_bemade_fsm_equipment_type,access_bemade_fsm_equipment_type,model_bemade_fsm_equipment_type,base.group_user,1,0,0,0
+access_bemade_fsm_equipment_location,access_bemade_fsm_equipment_location,model_bemade_fsm_equipment_location,base.group_user,1,0,0,0
\ No newline at end of file
diff --git a/tests/__pycache__/__init__.cpython-310.pyc b/tests/__pycache__/__init__.cpython-310.pyc
deleted file mode 100644
index fad4092..0000000
Binary files a/tests/__pycache__/__init__.cpython-310.pyc and /dev/null differ
diff --git a/tests/__pycache__/test_task_template.cpython-310.pyc b/tests/__pycache__/test_task_template.cpython-310.pyc
deleted file mode 100644
index f21b926..0000000
Binary files a/tests/__pycache__/test_task_template.cpython-310.pyc and /dev/null differ
diff --git a/views/equipment.xml b/views/equipment.xml
new file mode 100644
index 0000000..0041182
--- /dev/null
+++ b/views/equipment.xml
@@ -0,0 +1,96 @@
+
+
+
+
+ durpro_fso.equipment.form
+ durpro_fso.equipment
+
+
+
+
+
+
+ durpro_fso.equipment.tree
+ durpro_fso.equipment
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Equipment
+ durpro_fso.equipment
+ tree,form
+
+
+
+ Equipment Tag
+ durpro_fso.equipment.tag
+ tree,form
+
+
+
diff --git a/views/equipment_location.xml b/views/equipment_location.xml
new file mode 100644
index 0000000..01776a9
--- /dev/null
+++ b/views/equipment_location.xml
@@ -0,0 +1,109 @@
+
+
+
+
+ bemade_fsm.partner.equipment.location.form
+ res.partner
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ bemade_fsm.equipment.location.form
+ bemade_fsm.equipment.location
+
+
+
+
+
+
+ bemade_fsm.equipment.location.tree
+ bemade_fsm.equipment.location
+
+
+
+
+
+
+
+
+
+
+
+
+ Equipment Location
+ bemade_fsm.equipment.location
+ tree,form
+
+
+
+
+
+
+
diff --git a/views/res_partner.xml b/views/res_partner.xml
new file mode 100644
index 0000000..165a83f
--- /dev/null
+++ b/views/res_partner.xml
@@ -0,0 +1,36 @@
+
+
+
+ Equipments
+ bemade_fsm.equipment
+ tree,form
+ {'default_partner_id': active_id}
+ [("partner_id", "=", active_id)]
+
+
+
+ res.partner.view.buttons.fso
+ res.partner
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+