Skip to content

[16.0][ADD] helpdesk_mgmt_maintenance#35

Open
Anxo82 wants to merge 2 commits into16.0from
16.0-add-helpdesk_mgmt_maintenance
Open

[16.0][ADD] helpdesk_mgmt_maintenance#35
Anxo82 wants to merge 2 commits into16.0from
16.0-add-helpdesk_mgmt_maintenance

Conversation

@Anxo82
Copy link
Copy Markdown

@Anxo82 Anxo82 commented Nov 6, 2023

Links Odoo's maintenance with OCA's helpdek_mgmt.

Comment thread helpdesk_mgmt_maintenance/models/maintenance_equipment.py
<field name="inherit_id" ref="helpdesk_mgmt.helpdesk_ticket_view_search"/>
<field name="arch" type="xml">
<search>
<field name="name" string="Name Equipment" filter_domain="[('equipment_ids.name', 'ilike', self)]"/>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please also add groups management to search field

Comment on lines +13 to +15
<button class="oe_stat_button" type="object" name="action_view_tickets_equipment" string="Tickets" icon="fa-life-ring">
<field name="num_tickets" string="Tickets" widget="statinfo" groups="helpdesk_mgmt.group_helpdesk_user"/>
</button>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please move groups management to whole button.


allow_ticket = fields.Boolean(string="Allow Tickets", default=False)

num_tickets = fields.Integer(string="Tickets", compute="_compute_num_tickets", store=True)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please rename field to a more Odoo standard conventions one:

Suggested change
num_tickets = fields.Integer(string="Tickets", compute="_compute_num_tickets", store=True)
ticket_count = fields.Integer(string="Ticket count", compute="_compute_ticket_count", store=True)

class MaintenanceEquipment(models.Model):
_inherit = "maintenance.equipment"

ticket_ids = fields.Many2many('helpdesk.ticket', string = "Tickets")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

python attributes should be defined without spaces:

Suggested change
ticket_ids = fields.Many2many('helpdesk.ticket', string = "Tickets")
ticket_ids = fields.Many2many('helpdesk.ticket', string="Tickets")

<field name="inherit_id" ref="maintenance.hr_equipment_view_kanban" />
<field name="arch" type="xml">
<xpath expr="//t[@t-name='kanban-box']//field[@name='activity_ids']" position="before">
<field name="num_tickets" string=" Tickets" widget="statinfo" groups="helpdesk_mgmt.group_helpdesk_user"/>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo in label:

Suggested change
<field name="num_tickets" string=" Tickets" widget="statinfo" groups="helpdesk_mgmt.group_helpdesk_user"/>
<field name="num_tickets" string="Tickets" widget="statinfo" groups="helpdesk_mgmt.group_helpdesk_user"/>

<field name="inherit_id" ref="helpdesk_mgmt.ticket_view_tree" />
<field name="arch" type="xml">
<xpath expr="//field[@name='number']" position="after">
<field name="has_equipment" groups="base_maintenance_group.group_maintenance_user"/>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please set hidden by default:

Suggested change
<field name="has_equipment" groups="base_maintenance_group.group_maintenance_user"/>
<field name="has_equipment" groups="base_maintenance_group.group_maintenance_user" optional="hide"/>

<field name="inherit_id" ref="maintenance.hr_equipment_view_tree" />
<field name="arch" type="xml">
<xpath expr="//field[@name='name']" position="after">
<field name="num_tickets" string="Tickets" groups="helpdesk_mgmt.group_helpdesk_user"/>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please set optional:

Suggested change
<field name="num_tickets" string="Tickets" groups="helpdesk_mgmt.group_helpdesk_user"/>
<field name="num_tickets" string="Tickets" groups="helpdesk_mgmt.group_helpdesk_user" optional="show"/>

@ChristianSantamaria
Copy link
Copy Markdown

ChristianSantamaria commented Nov 15, 2023

LGTM, only see that it would be necessary to add the translations
And add comments adding licenses in manifest

@Anxo82 Anxo82 force-pushed the 16.0-add-helpdesk_mgmt_maintenance branch from 462ea83 to 4da8242 Compare November 16, 2023 10:22
class MaintenanceEquipment(models.Model):
_inherit = "maintenance.equipment"

ticket_ids = fields.Many2many('helpdesk.ticket', string="Tickets")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This works fine, but we should code it in a more secure way. Please look a this example

https://github.com/OCA/purchase-workflow/blob/338dbfa7768b76c6674400fbdffcf59f35f98873/purchase_request/models/purchase_order.py#L103-L110

and

https://github.com/OCA/purchase-workflow/blob/338dbfa7768b76c6674400fbdffcf59f35f98873/purchase_request/models/purchase_request_line.py#L97-L105

, in order to explicity link ticket_ids here and equipment_ids in ticket model. This is because other addons could create some alternative Many2many relations between these two models, that can cause conflict.

Moreover, both fields should be marked as copy=False, because e.g. when a ticket and/or an equipment are duplicated, relations shouldn't be kept.

Anb ticket_ids should be readonly IMO (not tested, I don't know if it can be a source of problems).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants