Skip to content
Snippets Groups Projects
Commit c42551b5 authored by Julien Castiaux's avatar Julien Castiaux
Browse files

[FIX] crm, sale: safe override of sales team


The user can delete teams created during the installation of the Sale
Team module, both CRM and Sale modify those teams but the way they
modify the teams doesn't take their deletion into account.

This reverts commit 30a848bf to replace
post_init_hooks by `forcecreate=False` in the datas.

closes odoo/odoo#32742

Signed-off-by: default avatarChristophe Simonis <chs@odoo.com>
parent 8631d3cc
Branches
Tags
No related merge requests found
......@@ -13,21 +13,3 @@ def uninstall_hook(cr, registry):
env = api.Environment(cr, SUPERUSER_ID, {})
teams = env['crm.team'].search([('dashboard_graph_model', '=', 'crm.opportunity.report')])
teams.update({'dashboard_graph_model': None})
def _update_sale_teams(cr, registry):
env = api.Environment(cr, SUPERUSER_ID, {})
sale_team = env.ref('sales_team.team_sales_department', False)
ws_team = env.ref('sales_team.salesteam_website_sales', False)
teams = [team for team in [sale_team, ws_team] if team]
if teams:
env['crm.team'].message_unsubscribe(teams, [env.ref('base.partner_root')])
env['crm.team'].message_subscribe(teams, [env.ref('base.partner_root')])
if sale_team:
sale_team.write({
'use_opportunities': True,
'alias_name': 'sales',
'dashboard_graph_model': 'crm.lead',
})
......@@ -56,5 +56,4 @@
'application': True,
'auto_install': False,
'uninstall_hook': 'uninstall_hook',
'post_init_hook': '_update_sale_teams',
}
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data noupdate="1">
<record id="sales_team.team_sales_department" model="crm.team" forcecreate="False">
<field name="use_opportunities">True</field>
<field name="alias_name">sales</field>
<field name="dashboard_graph_model">crm.lead</field>
<field name="company_id" eval="False"/>
</record>
<!--default alias for leads-->
<record id="mail_alias_lead_info" model="mail.alias">
<field name="alias_name"></field>
......
......@@ -5,7 +5,7 @@
<field name="groups_id" eval="[(4,ref('sales_team.group_sale_salesman'))]"/>
</record>
<record id="sales_team.team_sales_department" model="crm.team">
<record id="sales_team.team_sales_department" model="crm.team" forcecreate="False">
<field name="member_ids" eval="[(4, ref('base.user_demo'))]"/>
</record>
......
......@@ -60,6 +60,11 @@
<field name="relation_field">team_id</field>
</record>
<function model="crm.team" name="message_unsubscribe"
eval="[ref('sales_team.team_sales_department', False),ref('sales_team.salesteam_website_sales', False)], [ref('base.partner_root')]"/>
<function model="crm.team" name="message_subscribe"
eval="[ref('sales_team.team_sales_department', False),ref('sales_team.salesteam_website_sales', False)], [ref('base.partner_root')]"/>
<!--Definition of an email template with an empty body that will be used in opportunity mailing.
Used to give a basis for email recipients, name and to ease the definition of a further
elaborated template. -->
......
......@@ -22,13 +22,3 @@ def uninstall_hook(cr, registry):
rec._onchange_team_type()
cr.after("commit", partial(update_dashboard_graph_model, cr.dbname))
def _update_sale_teams(cr, registry):
env = api.Environment(cr, SUPERUSER_ID, {})
sale_team = env.ref('sales_team.team_sales_department', False)
if sale_team:
sale_team.write({
'use_quotations': True,
'use_invoices': True,
'dashboard_graph_model': 'sale.report'
})
\ No newline at end of file
......@@ -40,7 +40,6 @@ This module contains all the common features of Sales Management and eCommerce.
'data/product_product_demo.xml',
],
'uninstall_hook': "uninstall_hook",
'post_init_hook': '_update_sale_teams',
'installable': True,
'auto_install': False
}
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data noupdate="1">
<record model="crm.team" id="sales_team.team_sales_department" forcecreate="False">
<field name="use_quotations" eval="True"/>
<field name="use_invoices" eval="True"/>
<field name="dashboard_graph_model">sale.report</field>
</record>
<!-- Share Button in action menu -->
<record id="model_sale_order_action_share" model="ir.actions.server">
<field name="name">Share</field>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment