Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[16.0] [MIG] helpdesk_mgmt_fieldservice: Migration to 16.0 #608

Open
wants to merge 17 commits into
base: 16.0
Choose a base branch
from

Conversation

anusriNPS
Copy link

MIgrating helpdesk_mgmt_fieldservice to 16.0 version

@anusriNPS anusriNPS marked this pull request as draft July 22, 2024 08:36
marcelsavegnago and others added 16 commits July 22, 2024 10:46
When trying to open a res_partner form with a user who doesn't have permission for read fieldservice data, this view causes an error cause it try to set attributes to a button that doesn't exist. Specifying groups_id fix this, extending the view only if the current user has permissions to see that button.
Currently translated at 100.0% (32 of 32 strings)

Translation: helpdesk-12.0/helpdesk-12.0-helpdesk_mgmt_fieldservice
Translate-URL: https://translation.odoo-community.org/projects/helpdesk-12-0/helpdesk-12-0-helpdesk_mgmt_fieldservice/fr/
Currently translated at 100.0% (36 of 36 strings)

Translation: helpdesk-14.0/helpdesk-14.0-helpdesk_mgmt_fieldservice
Translate-URL: https://translation.odoo-community.org/projects/helpdesk-14-0/helpdesk-14-0-helpdesk_mgmt_fieldservice/it/
Currently translated at 100.0% (36 of 36 strings)

Translation: helpdesk-14.0/helpdesk-14.0-helpdesk_mgmt_fieldservice
Translate-URL: https://translation.odoo-community.org/projects/helpdesk-14-0/helpdesk-14-0-helpdesk_mgmt_fieldservice/es/
Currently translated at 100.0% (36 of 36 strings)

Translation: helpdesk-14.0/helpdesk-14.0-helpdesk_mgmt_fieldservice
Translate-URL: https://translation.odoo-community.org/projects/helpdesk-14-0/helpdesk-14-0-helpdesk_mgmt_fieldservice/pt_BR/
@anusriNPS anusriNPS force-pushed the 16.0-mig-helpdesk_mgmt_fieldservice branch 5 times, most recently from d0687ba to c8a33eb Compare July 23, 2024 09:55
@anusriNPS anusriNPS marked this pull request as ready for review July 23, 2024 10:03
<button name="action_view_helpdesk_tickets" position="attributes">
<attribute
name="context"
>{'default_partner_id': id, 'default_fsm_location_id': service_location_id}</attribute>
groups="fieldservice.group_fsm_user_own"
>{'default_partner_id': id}</attribute>
</button>

Choose a reason for hiding this comment

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

question: these changes are not really clear to me, could you give me some context and explain these?

Copy link
Author

Choose a reason for hiding this comment

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

With migration 16.0 page, this point was mentioned:
I am not able to use groups_id in views instead need to add groups attribute in the field itself. Hence this change was introduced

Any view with groups_id on it now has to move such groups to the elements of the view. But now you can put groups attribute in a view field instead of isolating it on a view without fear of an access error. Check it in odoo/odoo#98551.

Choose a reason for hiding this comment

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

Okay, looks great! But why the default location has been removed?

Copy link
Author

Choose a reason for hiding this comment

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

Sorry for delayed response. I shouldn't have removed service_location_id while incorporating "groups" for the button. Hope the latest code looks fine

Choose a reason for hiding this comment

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

Perfect, thanks!

@anusriNPS anusriNPS force-pushed the 16.0-mig-helpdesk_mgmt_fieldservice branch from c8a33eb to 99e9757 Compare July 30, 2024 09:55
Comment on lines 3 to 17
<record id="res_partner_form_ticket_context" model="ir.ui.view">
<field name="name">res.partner.form.ticket.context</field>
<field name="model">res.partner</field>
<field name="inherit_id" ref="base.view_partner_form" />
<field name="arch" type="xml">
<field name="service_location_id" invisible="1" />
<button name="action_view_helpdesk_tickets" position="attributes">
<attribute name="groups">fieldservice.group_fsm_user_own</attribute>
<attribute
name="context"
>{'default_partner_id': id, 'default_fsm_location_id': service_location_id}</attribute>
</button>
</field>
</record>

Choose a reason for hiding this comment

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

issue: it seems that in 14.0, this customization was made available only for users with the group fieldservice.group_fsm_user_own, while now you are making the whole button available only for the users with that group.

Could you please check and fix the issue to make the functionality the same as it was before?

Copy link
Author

@anusriNPS anusriNPS Aug 12, 2024

Choose a reason for hiding this comment

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

Removed groups_id and for accessing service_location_id field which can be accessed only with groups "fieldservice.group_fsm_user_own" is added in the parent view with invisible attribute so that functionality would remain the same.

Choose a reason for hiding this comment

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

Could you please double check? I feel like that to preserve the full functionality you should:

  • Use two buttons, the one already existing and create a new one
  • The first should be visible if you have the group, the other one not
  • The one visible if you have the group should also have the customization made in this inheritance

Let me know if everything is clear :)

Choose a reason for hiding this comment

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

This seems solved.

@anusriNPS anusriNPS force-pushed the 16.0-mig-helpdesk_mgmt_fieldservice branch from 99e9757 to 6b0d16d Compare August 12, 2024 13:42
@anusriNPS anusriNPS force-pushed the 16.0-mig-helpdesk_mgmt_fieldservice branch 2 times, most recently from 186f5dc to 39e4ab9 Compare August 28, 2024 06:02
@anusriNPS anusriNPS force-pushed the 16.0-mig-helpdesk_mgmt_fieldservice branch from 39e4ab9 to 8eb0982 Compare September 10, 2024 08:30
@anusriNPS
Copy link
Author

As per latest changes, when user is provided with group for helpdesk and not for fieldservice, below view is observed:
Screenshot from 2024-09-10 10-26-50

Provided user permission:

Screenshot from 2024-09-10 10-27-12

Copy link

@aleuffre aleuffre left a comment

Choose a reason for hiding this comment

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

Minor comment to fix a bug that was already present in previous versions

But in general, LGTM (Code review)

Comment on lines 5 to 10
<field name="inherit_id" ref="base.view_partner_form" />
<field name="arch" type="xml">
<button name="action_view_helpdesk_tickets" position="attributes">
<button name="action_view_helpdesk_tickets" position="before">
<field name="service_location_id" invisible="1" />
</button>
<button name="action_view_helpdesk_tickets" position="attributes">

Choose a reason for hiding this comment

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

chore: an issue that we should fix is that the <button name="action_view_helpdesk_tickets"> is not present in base.view_partner_form but is added by helpdesk_mgmt.view_partner_form so we should inherit from that view

Copy link
Author

Choose a reason for hiding this comment

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

Yes, this has to be inherited from helpdesk_mgmt.view_partner_form which is the right way to inherit as mentioned by you.

However, I see issue still persists with updating button with group attribute to "fieldservice.group_fsm_user_own" and having helpdesk_mgmt and fieldservice modules installed along with helpdesk_mgmt_fieldservice with user provided only with helpdesk_mgmt but not with fieldservice, helpdesk button is not visible in the contacts view as shown below:

image

image

Please let me know your views on it.

Comment on lines 3 to 17
<record id="res_partner_form_ticket_context" model="ir.ui.view">
<field name="name">res.partner.form.ticket.context</field>
<field name="model">res.partner</field>
<field name="inherit_id" ref="base.view_partner_form" />
<field name="arch" type="xml">
<field name="service_location_id" invisible="1" />
<button name="action_view_helpdesk_tickets" position="attributes">
<attribute name="groups">fieldservice.group_fsm_user_own</attribute>
<attribute
name="context"
>{'default_partner_id': id, 'default_fsm_location_id': service_location_id}</attribute>
</button>
</field>
</record>

Choose a reason for hiding this comment

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

This seems solved.

@anusriNPS anusriNPS force-pushed the 16.0-mig-helpdesk_mgmt_fieldservice branch 3 times, most recently from 1c883c1 to deb1d7b Compare September 17, 2024 11:06
@anusriNPS anusriNPS force-pushed the 16.0-mig-helpdesk_mgmt_fieldservice branch 2 times, most recently from 8a63a0f to deb512d Compare September 25, 2024 15:50
@anusriNPS
Copy link
Author

action_view_helpdesk_ticket function is overridden by replacing context when both groups "helpdesk_mgmt.group_helpdesk_user_own" and "fieldservice.group_fsm_user_own" are available

Functionality for button in 14 and 16 versions:

Odoo 14:

Helpdesk - Manager, Fieldservice - Manager - Has context with default_location_id, default_partner_id
Helpdesk - User, Fieldservice - Disable - Button is visible but context has search_default_open, default_partner_id
Helpdesk - disable, Fieldservice - User only - Button not visible context could not be checked

Odoo 16:

Helpdesk - Manager, Fieldservice - Manager - context contains default_location_id, default_partner_id
Helpdesk - User, Fieldservice - Disable - Button is visible but context has only search_default_open, default_partner_id
Helpdesk - disable, Fieldservice - User only - Button not visible context could not be checked

@anusriNPS anusriNPS force-pushed the 16.0-mig-helpdesk_mgmt_fieldservice branch from deb512d to 19100f3 Compare September 25, 2024 15:56
Copy link

@aleuffre aleuffre left a comment

Choose a reason for hiding this comment

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

Code review, LGTM

Copy link

@PicchiSeba PicchiSeba left a comment

Choose a reason for hiding this comment

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

Code review: LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.