fsm_equipment, bemade_fsm: Multiple UX improvements + migration script
- Task list view (bemade_fsm) cleaned up - Add equipment to service to task list view (bemade_fsm) - Give base.group_user access to read client application details - Add migration script for fsm_equipment to refactor components into a hierarchy of equipment. - Add the notion of equipment hierarchy instead of components. partner_id field is only to be filled on the root equipment, to facilitate viewing client equipment lists without the clutter of all the subcomponents. - Add the notion of "inherited partner id" to show the root's partner_id on child equipment (components) form view. - Improve the interventions list on the equipment form view. Added a custom embedded tree view with limited fields, ordered by date. - Make the default search for equipment only search for root equipments (parent_id = False)
This commit is contained in:
parent
bb9ad5afbe
commit
e4eb57e349
8 changed files with 92 additions and 12 deletions
|
|
@ -80,7 +80,7 @@
|
|||
<tree position="attributes">
|
||||
<attribute name="js_class">project_list</attribute>
|
||||
</tree>
|
||||
<field name="partner_id" position="after">
|
||||
<field name="name" position="before">
|
||||
<field name="work_order_number" optional="show" />
|
||||
</field>
|
||||
<field name="company_id" position="attributes">
|
||||
|
|
@ -92,6 +92,12 @@
|
|||
<field name="project_id" position="attributes">
|
||||
<attribute name="optional">hide</attribute>
|
||||
</field>
|
||||
<field name="progress" position="attributes">
|
||||
<attribute name="optional">hide</attribute>
|
||||
</field>
|
||||
<field name="activity_ids" position="attributes">
|
||||
<attribute name="optional">hide</attribute>
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
<record id="industry_fsm.project_task_action_fsm_map" model="ir.actions.act_window">
|
||||
|
|
|
|||
|
|
@ -1,12 +1,14 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<odoo>
|
||||
<data>
|
||||
<record id="group_applications_admin" model="res.groups">
|
||||
<field name="name">Applications Admin</field>
|
||||
<field name="implied_ids" eval="[ref('group_applications_user')]"/>
|
||||
</record>
|
||||
<record id="group_applications_user" model="res.groups">
|
||||
<field name="name">Applications User</field>
|
||||
</record>
|
||||
<record id="group_applications_admin" model="res.groups">
|
||||
<field name="name">Applications Admin</field>
|
||||
</record>
|
||||
<record id="base.group_user" model="res.groups">
|
||||
<field name="implied_ids" eval="[(4, ref('group_applications_user'))]"/>
|
||||
</record>
|
||||
</data>
|
||||
</odoo>
|
||||
|
|
@ -30,6 +30,7 @@
|
|||
"security/ir.model.access.csv",
|
||||
"views/equipment_views.xml",
|
||||
"views/res_partner_views.xml",
|
||||
"views/project_task_views.xml",
|
||||
],
|
||||
"assets": {},
|
||||
"installable": True,
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ from odoo.tools.sql import SQL
|
|||
|
||||
|
||||
def migrate(cr, version):
|
||||
sql = "select * from equipment_component"
|
||||
sql = "select * from fsm_equipment_component"
|
||||
cr.execute(SQL(sql))
|
||||
components = cr.dictfetchall()
|
||||
sql = "select * from fsm_equipment_component_purpose"
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
from odoo import models, fields, api, _
|
||||
from odoo.osv import expression
|
||||
from odoo.exceptions import ValidationError
|
||||
|
||||
|
||||
class Equipment(models.Model):
|
||||
|
|
@ -28,7 +29,7 @@ class Equipment(models.Model):
|
|||
string="Physical Address",
|
||||
tracking=True,
|
||||
ondelete="restrict",
|
||||
required=True,
|
||||
required=False,
|
||||
)
|
||||
|
||||
location_notes = fields.Text(
|
||||
|
|
@ -55,6 +56,13 @@ class Equipment(models.Model):
|
|||
"fsm.equipment",
|
||||
tracking=True,
|
||||
)
|
||||
inherited_partner_id = fields.Many2one(
|
||||
comodel_name="res.partner",
|
||||
string="Main Equipment Location",
|
||||
readonly=True,
|
||||
compute="_compute_inherited_partner_id",
|
||||
recursive=True,
|
||||
)
|
||||
|
||||
child_ids = fields.One2many(
|
||||
"fsm.equipment",
|
||||
|
|
@ -69,6 +77,28 @@ class Equipment(models.Model):
|
|||
help="The product that represents this equipment, if any.",
|
||||
)
|
||||
|
||||
@api.depends("parent_id", "parent_id.partner_id")
|
||||
def _compute_inherited_partner_id(self):
|
||||
for rec in self:
|
||||
if not rec.parent_id:
|
||||
rec.inherited_partner_id = False
|
||||
continue
|
||||
rec.inherited_partner_id = (
|
||||
rec.parent_id.partner_id or rec.parent_id.inherited_partner_id
|
||||
)
|
||||
|
||||
@api.constrains("product_id", "partner_id")
|
||||
def _constrain_only_root_has_partner(self):
|
||||
for rec in self:
|
||||
if rec.partner_id and rec.parent_id:
|
||||
raise ValidationError(
|
||||
_("Only top-level (root) equipments can be linked to a partner.")
|
||||
)
|
||||
if not rec.parent_id and not rec.partner_id:
|
||||
raise ValidationError(
|
||||
_("Top-level (root) equipments must be linked to a partner.")
|
||||
)
|
||||
|
||||
@api.model
|
||||
def name_search(self, name="", args=None, operator="ilike", limit=100):
|
||||
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ class Partner(models.Model):
|
|||
def _compute_equipment_count(self):
|
||||
for rec in self:
|
||||
all_equipment_ids = self.env["fsm.equipment"].search(
|
||||
[("partner_id", "=", rec.id)]
|
||||
[("partner_id", "=", rec.id), ("parent_id", "=", False)]
|
||||
)
|
||||
rec.equipment_count = len(all_equipment_ids)
|
||||
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@
|
|||
<group name="left">
|
||||
<field name="code"/>
|
||||
<field name="name"/>
|
||||
<field name="parent_id" invisible="partner_id"/>
|
||||
<field name="description"/>
|
||||
<field name="location_notes"/>
|
||||
</group>
|
||||
|
|
@ -22,6 +23,17 @@
|
|||
'show_address': 1
|
||||
}"
|
||||
options='{"always_reload": True}'
|
||||
invisible="parent_id"
|
||||
required="not parent_id"
|
||||
/>
|
||||
<field
|
||||
name="inherited_partner_id"
|
||||
context="{
|
||||
'default_type': 'delivery',
|
||||
'show_address': 1
|
||||
}"
|
||||
options='{"always_reload": True}'
|
||||
invisible="partner_id or parent_id"
|
||||
/>
|
||||
<field
|
||||
name="tag_ids"
|
||||
|
|
@ -33,17 +45,26 @@
|
|||
<notebook>
|
||||
<page string="Components">
|
||||
<field name="child_ids">
|
||||
<tree editable="bottom">
|
||||
<tree editable="bottom" open_form_view="True">
|
||||
<field name="sequence" widget="handle"/>
|
||||
<field name="name"/>
|
||||
<field name="description"/>
|
||||
<field name="product_id"/>
|
||||
<field name="tag_ids" widget="many2many_tags"/>
|
||||
<field name="description"/>
|
||||
</tree>
|
||||
</field>
|
||||
</page>
|
||||
<page string="Interventions">
|
||||
<field name="task_ids" groupby="root_ancestor"/>
|
||||
<field name="task_ids" readonly="True">
|
||||
<tree open_form_view="True" default_order="date_deadline desc">
|
||||
<field name="date_deadline" widget="date" string="Date"/>
|
||||
<field name="name"/>
|
||||
<field name="user_ids" widget="many2many_avatar_user"/>
|
||||
<field name="description" class="text-truncate"/>
|
||||
<field name="effective_hours" optional="show"/>
|
||||
<field name="stage_id" optional="show"/>
|
||||
</tree>
|
||||
</field>
|
||||
</page>
|
||||
</notebook>
|
||||
</sheet>
|
||||
|
|
@ -102,6 +123,9 @@
|
|||
<field name="name">Equipment</field>
|
||||
<field name="res_model">fsm.equipment</field>
|
||||
<field name="view_mode">tree,form</field>
|
||||
<field name="context">
|
||||
{'search_default_parent_only': True}
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="equipment_view_search" model="ir.ui.view">
|
||||
|
|
@ -109,12 +133,14 @@
|
|||
<field name="model">fsm.equipment</field>
|
||||
<field name="arch" type="xml">
|
||||
<search>
|
||||
<field name="parent_id"/>
|
||||
<field name="code"/>
|
||||
<field name="name"/>
|
||||
<field name="description"/>
|
||||
<field name="tag_ids"/>
|
||||
<field name="partner_id"/>
|
||||
|
||||
<filter string="Parent Only" name="parent_only"
|
||||
domain="[('parent_id', '=', False)]"/>
|
||||
<filter string="Has Description" name="has_description"
|
||||
domain="[('description', '!=', False)]"/>
|
||||
<filter string="No Description" name="no_description"
|
||||
|
|
@ -132,6 +158,7 @@
|
|||
<field name="res_model">fsm.equipment.tag</field>
|
||||
<field name="view_mode">tree,form</field>
|
||||
</record>
|
||||
|
||||
<menuitem
|
||||
id="menu_contact_equipment"
|
||||
name="Customer Equipment"
|
||||
|
|
|
|||
14
fsm_equipment/views/project_task_views.xml
Normal file
14
fsm_equipment/views/project_task_views.xml
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<odoo>
|
||||
<record id="project_task_view_tree_equipment" model="ir.ui.view">
|
||||
<field name="name">project.task.view.tree.equipment</field>
|
||||
<field name="model">project.task</field>
|
||||
<field name="inherit_id" ref="industry_fsm.project_task_view_list_fsm"/>
|
||||
<field name="arch" type="xml">
|
||||
<field name="partner_id" position="after">
|
||||
<field name="equipment_ids" widget="many2many_tags"
|
||||
string="Equipment" optional="show"/>
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
</odoo>
|
||||
Loading…
Reference in a new issue