Skip to content

Conversation

@matiasperalta1
Copy link
Contributor

No description provided.

@legalsylvain
Copy link
Contributor

Hi. Could you change message to explain the changes ?

Thanks !

@matiasperalta1 matiasperalta1 force-pushed the 18.0-h-92487-mnp branch 3 times, most recently from 3e016de to be27972 Compare June 9, 2025 20:28
@matiasperalta1 matiasperalta1 force-pushed the 18.0-h-92487-mnp branch 5 times, most recently from 3b70e92 to 149cdcd Compare June 19, 2025 18:07
@rousseldenis rousseldenis added this to the 18.0 milestone Jun 30, 2025
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"
Copy link
Contributor

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])
Copy link
Contributor

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),
"|",
Copy link
Contributor

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),
]

Copy link
Contributor

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(
Copy link
Contributor

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.

Copy link
Contributor

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:
image
image
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.
image

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
Copy link
Contributor

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"):
Copy link
Contributor

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

@nicolascol
Copy link

nicolascol commented Jul 4, 2025

Hi!

First, in OCA’s runboat, the sales_team_security module is not working. You can test it as follows:

  1. Create a sales team with both "admin" and "demo" in the same team.
  2. Assign a res.partner to "admin" as the "salesperson".
  3. Assign the "demo" user to the sales group "see documents of own team only".
  4. Log in as "demo".
  5. The user is not able to see the corresponding res.partner, although they should.

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.
https://www.youtube.com/watch?v=N2bgoG_EXUE
At the end of the video, you can see a small bug in this PR, which we're already working on.

sales_team_security

@rousseldenis @pedrobaeza @matiasperalta1 @carlos-lopez-tecnativa

Copy link
Contributor

@carlos-lopez-tecnativa carlos-lopez-tecnativa left a 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(
Copy link
Contributor

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:
image
image
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.
image

@nicolascol
Copy link

In previous versions, it was possible to select a different team than the salesperson's team in res.partner.
I understand that Odoo removed the field because it wasn't used much (it was a field visible only in debug mode) and it caused confusion for them in identifying which team a salesperson belonged to. On the other hand, with the "sales_team_security" module, our goal is to identify the customer.

Regarding the development, we have two options:

  1. We can make the team of the salesperson compute automatically in res.partner. If the salesperson belongs to more than one team, we take the one with the lowest sequence.
  2. We fix the display for the "Team Documents Only" group. We do not add team_id in res.partner and clarify in the README that the module, starting from version 18, may be non-functional if "multi-teams" is enabled.

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.

@pedrobaeza
Copy link
Member

IMO, team_id field shouldn't be restored in res.partner, but the security rules work on res.user~team_ids.

@matiasperalta1 matiasperalta1 force-pushed the 18.0-h-92487-mnp branch 4 times, most recently from ac8d1eb to ae393c0 Compare July 22, 2025 14:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants