-
-
Notifications
You must be signed in to change notification settings - Fork 1k
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
[17.0][MIG] sales_team_security_crm: Migration to 17.0 #3429
base: 17.0
Are you sure you want to change the base?
Conversation
b4b9174
to
5dbaa96
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<field name="model_id" ref="crm.model_crm_lead" /> | ||
<field | ||
name="domain_force" | ||
>['|', '|', ('user_id', '=', user.id), ('user_id', '=', False), '|', ('team_id', '=', user.sale_team_id.id), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this can be simplified to: What do you think?
>['|', '|', ('user_id', '=', user.id), ('user_id', '=', False), '|', ('team_id', '=', user.sale_team_id.id), | |
>['|', ('user_id', 'in', [user.id, False]), ('team_id', 'in', [user.sale_team_id.id, False]), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moreover, you must take into account the multi team that has been introduced in odoo v15. In that case, user.sale_team_id can be false if a user is in several teams (ie https://github.com/odoo/odoo/blob/b7abee1f64d6812d66c5ac61d1d8f841310c81d7/addons/sales_team/models/res_users.py#L32)
IMHO the correct rule should be
['|', '|', ('user_id', 'in', [user.id, False]), ('team_id', '=', user.sale_team_id.id), ('team_id', 'in', user.crm_team_ids.ids)]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in our case, we did not want the users in Team Only group to access to leads without a user_id so we finally did
['|', '|', ('user_id', '=', user.id), ('team_id', '=', user.sale_team_id.id), ('team_id', 'in', user.crm_team_ids.ids)]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The original module should include leads without user.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The original module should include leads without user.
You are right considering that odoo standard has the same policy with crm ('my document only' group includes lead without user)
Anyway, the rule can be customized after on.
But natively, please include crm_team_ids because if not, the rule does not work out of the box in multi-team configuration
<field name="model_id" ref="crm.model_crm_activity_report" /> | ||
<field | ||
name="domain_force" | ||
>['|', '|', ('user_id', '=', user.id), ('user_id', '=', False), '|', ('team_id', '=', user.sale_team_id.id), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the same here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here
['|', '|', ('user_id', 'in', [user.id, False]), ('team_id', '=', user.sale_team_id.id), ('team_id', 'in', user.crm_team_ids.ids)]
<field name="model_id" ref="crm.model_crm_lead" /> | ||
<field | ||
name="domain_force" | ||
>['|', '|', ('user_id', '=', user.id), ('user_id', '=', False), '|', ('team_id', '=', user.sale_team_id.id), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moreover, you must take into account the multi team that has been introduced in odoo v15. In that case, user.sale_team_id can be false if a user is in several teams (ie https://github.com/odoo/odoo/blob/b7abee1f64d6812d66c5ac61d1d8f841310c81d7/addons/sales_team/models/res_users.py#L32)
IMHO the correct rule should be
['|', '|', ('user_id', 'in', [user.id, False]), ('team_id', '=', user.sale_team_id.id), ('team_id', 'in', user.crm_team_ids.ids)]
<field name="model_id" ref="crm.model_crm_activity_report" /> | ||
<field | ||
name="domain_force" | ||
>['|', '|', ('user_id', '=', user.id), ('user_id', '=', False), '|', ('team_id', '=', user.sale_team_id.id), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here
['|', '|', ('user_id', 'in', [user.id, False]), ('team_id', '=', user.sale_team_id.id), ('team_id', 'in', user.crm_team_ids.ids)]
<record id="sales_team_team_rule" model="ir.rule"> | ||
<field name="name">Own Sale Teams</field> | ||
<field name="model_id" ref="sales_team.model_crm_team" /> | ||
<field name="domain_force">[('id', '=', user.sale_team_id.id)]</field> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and here
['|', ('id', '=', user.sale_team_id.id), ('id', 'in', user.crm_team_ids.ids)]
205ce85
to
4cd5e82
Compare
@cvinh the tests fail with the domains you gave me, could you check it? |
Humm there should be something to do in sales_team_security |
"team_id": cls.team.id, | ||
} | ||
) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tests with the case multi-team should be added and see why this one fails
Can you commit again to see where it fails ? |
@cvinh The failure occurs in the following line https://github.com/adhoc-dev/sale-workflow/blob/4cd5e8211dceceece3b54121c9b0e6c7c7420e63/sales_team_security/tests/common.py#L88 When searching with the self.user in the following line it does not find anything https://github.com/adhoc-dev/sale-workflow/blob/4cd5e8211dceceece3b54121c9b0e6c7c7420e63/sales_team_security/tests/common.py#L69 |
4cd5e82
to
f0d2461
Compare
@cvinh I think that's it, I also added a multi-team test, what do you think? |
f0d2461
to
5825dd1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think if a user is in one team only, the crm_team_ids are empty
If I'm wrong then it's ok as you did
<record id="sales_team_team_rule" model="ir.rule"> | ||
<field name="name">Own Sale Teams</field> | ||
<field name="model_id" ref="sales_team.model_crm_team" /> | ||
<field name="domain_force">[('id', 'in', user.crm_team_ids.ids)]</field> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<field name="domain_force">[('id', 'in', user.crm_team_ids.ids)]</field> | |
<field name="domain_force">['|', ('id', '=', 'user.sale_team_id.id'), ('id', 'in', user.crm_team_ids.ids)]</field> |
I migrated the module through this PR #2461