-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
[IMP] sales_security_team: revert changes to recover esencial functionality #3747
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
base: 18.0
Are you sure you want to change the base?
Conversation
|
Hi. Could you change message to explain the changes ? Thanks ! |
3e016de to
be27972
Compare
3b70e92 to
149cdcd
Compare
| user = self.env.user | ||
| group_my_records = "sales_team.group_sale_salesman" | ||
| group_all_records = "sales_team.group_sale_salesman_all_leads" | ||
| group1 = "sales_team.group_sale_salesman" |
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.
@matiasperalta1 IMHO, changing variables names from explicit to not explicit (groupX) is a drawback (and is not needed).
| ("id", "=", user.partner_id.id), | ||
| ] | ||
| domain_user = [("user_id", "in", [user.id, False])] | ||
| extra_domain = expression.OR([domain_followers, domain_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.
IMHO, using AND() and OR() is better in terms of readability.
| extra_domain = [ | ||
| "|", | ||
| ("message_partner_ids", "in", user.partner_id.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.
I think this is not useful as there is only one argument after this 'OR'
| ("team_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.
If I summarize the change here:
- If user is a manager, can see all contacts of a team (even with user assigned)
- either, user can see only its contacts or contacts with no assignation and (no team or same team).
This should be reflected in documentation
|
|
||
| # add indexes for better performance on record rules | ||
| user_id = fields.Many2one(index=True) | ||
| team_id = fields.Many2one( |
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.
You introduce a new functionality here. Maybe this should be done in another module.
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.
As @matiasperalta1 mentioned, and as I commented in the migration PR, Odoo removed this field in this commit odoo/odoo@d11691c
I'm not sure if reintroducing this field is good for the user experience.
For example, if I have the following settings in the sales teams:


With this new field, I can encounter inconsistencies like in the following image: the sales team is selected independently of the user, and the user is not a member of that team.

| if self.parent_id and self.parent_id.team_id and not self.team_id: | ||
| self.team_id = self.parent_id.team_id.id | ||
| if self.parent_id and self.parent_id.user_id and not self.user_id: | ||
| self.user_id = self.parent_id.user_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.
IMHO, this is totally out of scope. Moreover this is already done by: https://github.com/odoo/odoo/blob/18.0/odoo/addons/base/models/res_partner.py#L397
Those changes should be done in computes.
| """Sync followers in commercial partner + delivery/invoice contacts.""" | ||
| for record in self.commercial_partner_id: | ||
| followers = (record.child_ids + record).user_id.partner_id | ||
| for record in self.mapped("commercial_partner_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.
Those changes are not necessary as Odoo already include a mapped() when you access a relation through a multi recordset
|
Hi! First, in OCA’s runboat, the sales_team_security module is not working. You can test it as follows:
Second, we have reintroduced the sales team field in res.partner because, in cases where a salesperson belongs to multiple sales teams, we don’t want the res.partner to be visible across all teams, only in the one it's assigned to. (as it is v17). One thing to keep in mind is that Odoo deprecated the sales team in res.partner because they didn't use it. I’m sharing a video in Spanish, but you can use YouTube’s automatic translator. @rousseldenis @pedrobaeza @matiasperalta1 @carlos-lopez-tecnativa |
carlos-lopez-tecnativa
left a comment
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.
Please, check the CI
|
|
||
| # add indexes for better performance on record rules | ||
| user_id = fields.Many2one(index=True) | ||
| team_id = fields.Many2one( |
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.
As @matiasperalta1 mentioned, and as I commented in the migration PR, Odoo removed this field in this commit odoo/odoo@d11691c
I'm not sure if reintroducing this field is good for the user experience.
For example, if I have the following settings in the sales teams:


With this new field, I can encounter inconsistencies like in the following image: the sales team is selected independently of the user, and the user is not a member of that team.

|
In previous versions, it was possible to select a different team than the salesperson's team in res.partner. Regarding the development, we have two options:
We would prefer to go with option 1 because we believe it reflects the essence of the module, and several of our clients would be affected if we went with option 2. |
|
IMO, |
ac8d1eb to
ae393c0
Compare
ae393c0 to
a5b01a3
Compare

No description provided.