Skip to content

Commit

Permalink
[FIX] use of user_id fixed
Browse files Browse the repository at this point in the history
closes #642

Signed-off-by: Nicolas Mac Rouillon <nmr@adhoc.com.ar>
  • Loading branch information
JoelZilli committed Mar 16, 2023
1 parent 6274d9a commit f42e7c9
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 9 deletions.
2 changes: 1 addition & 1 deletion crm_teams_ux/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
{
'name': 'CRM Teams UX',
'version': "16.0.2.0.0",
'version': "16.0.2.1.0",
'sequence': 14,
'summary': '',
'author': 'ADHOC SA',
Expand Down
8 changes: 0 additions & 8 deletions crm_teams_ux/models/crm_lead.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,6 @@ class Lead(models.Model):
stage_id = fields.Many2one(
domain="['|', ('team_ids', '=', False), ('team_ids', '=', team_id)]",
group_expand='_read_group_stage_ids')
user_id = fields.Many2one(domain=lambda self: self._domain_user_id())

@api.model
def _domain_user_id(self):
if self.env.user.has_group('sale_ux.group_allow_any_user_as_salesman'):
return [('company_ids', 'in', user_company_ids)]
else:
return []

def _read_group_stage_ids(self, stages, domain, order):
team_id = self._context.get('default_team_id')
Expand Down
22 changes: 22 additions & 0 deletions crm_teams_ux/views/crm_lead_views.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,27 @@
<?xml version="1.0"?>
<odoo>
<record id="crm_lead_view_form" model="ir.ui.view">
<field name="name">crm.lead.form.inherit</field>
<field name="model">crm.lead</field>
<field name="inherit_id" ref="crm.crm_lead_view_form"/>
<field name="arch" type="xml">
<xpath expr="//group//field[@name='user_id']" position="attributes">
<attribute name="domain">[('company_ids', 'in', user_company_ids)]</attribute>
<attribute name="groups">sale_ux.group_allow_any_user_as_salesman</attribute>
</xpath>
<xpath expr="//field[@name='team_id']//../field[@name='user_id']" position="attributes">
<attribute name="domain">[('company_ids', 'in', user_company_ids)]</attribute>
<attribute name="groups">sale_ux.group_allow_any_user_as_salesman</attribute>
</xpath>
<xpath expr="//field[@name='user_id']" position="after">
<field name="user_id" groups="!sale_ux.group_allow_any_user_as_salesman" context="{'default_sales_team_id': team_id}" widget="many2one_avatar_user"/>
</xpath>
<xpath expr="//field[@name='team_id']//../field[@name='user_id']" position="after">
<field name="user_id" groups="!sale_ux.group_allow_any_user_as_salesman" context="{'default_sales_team_id': team_id}" widget="many2one_avatar_user"/>
</xpath>
</field>
</record>

<record id="crm_lead_form_view_inherit" model="ir.ui.view">
<field name="name">crm.lead.form.opportunity</field>
<field name="model">crm.lead</field>
Expand Down

0 comments on commit f42e7c9

Please sign in to comment.