chore: import enterprise addons 19.0 bulk snapshot

This commit is contained in:
1b-agent committed 2026-09-16 10:13:08 +00:00
commit ca4af030d3
39951 files changed
+15570005

No files matched your search

+6
View File
@@ -0,0 +1,6 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from . import test_helpdesk_forum
from . import test_helpdesk_forum_tour
from . import test_website_forum_ticket_creation
@@ -0,0 +1,93 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo.fields import Command
from odoo.tests import Form
from odoo.addons.helpdesk.tests.common import HelpdeskCommon
from odoo.addons.website_forum.tests.common import TestForumCommon
class TestHelpdeskForum(HelpdeskCommon, TestForumCommon):
@classmethod
def setUpClass(cls):
super().setUpClass()
cls.test_team.use_website_helpdesk_forum = True
cls.ticket_name = 'Help Me'
cls.ticket_description = 'Please Help'
cls.ticket = cls.env['helpdesk.ticket'].create({
'name': cls.ticket_name,
'description': cls.ticket_description,
'team_id': cls.test_team.id,
})
cls._activate_multi_website()
def test_share_ticket(self):
self.assertTrue(self.ticket.can_share_forum, 'Ticket should be able to be shared on the forums.')
form = Form(self.env['helpdesk.ticket.select.forum.wizard'].with_context({'active_id': self.ticket.id}))
wizard = form.save()
wizard.tag_ids = [Command.create({'name': 'tag_1', 'forum_id': self.forum.id}), Command.create({'name': 'tag_2', 'forum_id': self.forum.id})]
post = wizard._create_forum_post()
self.assertEqual(post.name, self.ticket_name, 'The created post should have the same name as the ticket.')
self.assertEqual(post.plain_content, self.ticket_description, 'The created post should have the same description as the ticket.')
self.assertEqual(post.ticket_id, self.ticket, 'The created post should point to the ticket.')
self.assertEqual(len(post.tag_ids), 2, 'The created post should have the tags defined in the wizard.')
def test_show_knowledge_base_forum(self):
# see /website_helpdesk_forum:HelpdeskTeam._compute_show_knowledge_base_forum() for more info
test_team_public = self.test_team.with_user(self.env.ref('base.public_user'))
forums = self.env['forum.forum'].search([])
self.test_team.use_website_helpdesk_forum = False
self.assertFalse(test_team_public.show_knowledge_base_forum, 'This team does not use Forums')
self.test_team.use_website_helpdesk_forum = True
self.test_team.website_forum_ids = False
forums.privacy = 'private'
self.assertFalse(test_team_public.show_knowledge_base_forum, 'User does not have access to any forum')
self.test_team.website_forum_ids = False
forums[0].privacy = 'public'
self.assertTrue(test_team_public.show_knowledge_base_forum, 'User has access to a forum')
self.test_team.website_forum_ids = forums
self.assertTrue(test_team_public.show_knowledge_base_forum, 'User has access to one of the help forums')
self.test_team.website_forum_ids = forums[1]
forums[1].privacy = 'private'
self.assertFalse(test_team_public.show_knowledge_base_forum, 'User does not have access to any of the help forums')
def test_top_forum_posts(self):
# We first create a new nice, interesting forum for our helpdesk team
forum = self.env['forum.forum'].create({
'name': 'Discussions on Mushrooms',
})
self.test_team['website_forum_ids'] = forum
# Then we create 7 different forum posts for our forum
forum_posts = self.env['forum.post'].create([{
'name': f'This is forum post number {post_record}',
'forum_id': forum.id,
} for post_record in range(1, 8)])
# Then we need to create some users which will vote the forum posts
# We create 28 users because we need one for each vote.
forum_users = self.env['res.users'].create([{
'name': f"Theodore the {index}'th",
'login': f'usr{index}',
'email': f'user{index}@example.com',
} for index in range(0, 28)])
# Finally it's time to create the votes for each of the forum posts
forum_user_ids = forum_users.ids
self.env['forum.post.vote'].create([{
'post_id': forum_value.id,
'user_id': forum_user_ids.pop(),
'vote': '1',
} for index, forum_value in enumerate(forum_posts) for _ in range(index+1)])
self.assertEqual(self.test_team.top_forum_posts, forum_posts[6:1:-1], 'The top posts should be the ones with the most votes, in this case the last 5 from last to first')
@@ -0,0 +1,41 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo.fields import Command
from odoo.tests.common import HttpCase, tagged
from odoo.addons.helpdesk.tests.common import HelpdeskCommon
from odoo.addons.website_forum.tests.common import TestForumCommon
@tagged('post_install', '-at_install')
class websiteHelpdeskForumUi(HelpdeskCommon, TestForumCommon, HttpCase):
@classmethod
def setUpClass(cls):
super().setUpClass()
cls.test_team.use_website_helpdesk_forum = True
cls._activate_multi_website()
cls.env['forum.post'].create({
'name': 'Very Smart Question',
'forum_id': cls.env.ref('website_forum.forum_help').id,
})
def test_website_helpdesk_forum_tour(self):
partner = self.env['res.partner'].create({
'name': 'Jean-Luc',
'email': '[email protected]',
})
helpdesk_user = self.env['res.users'].create({
'partner_id': partner.id,
'name': 'Test User',
'login': '[email protected]',
'password': 'testpass',
'group_ids': [Command.link(self.env.ref('helpdesk.group_helpdesk_manager').id)],
})
forum = self.env.ref('website_forum.forum_help')
self.test_team['website_forum_ids'] = [Command.link(forum.id)]
helpdesk_user.karma = forum.karma_post + 1
self.start_tour("/", 'website_helpdesk_forum_tour', login=helpdesk_user.login)
@@ -0,0 +1,77 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo.tests.common import HttpCase
from odoo.addons.helpdesk.tests.common import HelpdeskCommon
from odoo.addons.http_routing.tests.common import MockRequest
from odoo.addons.website_forum.tests.common import TestForumCommon
from odoo.addons.website_helpdesk_forum.controllers.website_forum import WebsiteForumHelpdesk
class TestHelpdeskForumTicketCreation(HttpCase, TestForumCommon, HelpdeskCommon):
@classmethod
def setUpClass(cls):
super().setUpClass()
cls.test_team.use_website_helpdesk_forum = True
cls.ticket_name = 'Help Me'
cls.ticket_description = 'Please Help'
cls.ticket = cls.env['helpdesk.ticket'].create({
'name': cls.ticket_name,
'description': cls.ticket_description,
'team_id': cls.test_team.id,
})
cls._activate_multi_website()
def test_create_ticket_through_the_post(self):
""" Check if a ticket is created through the post.
Steps:
1. Install the module `website_helpdesk_forum`.
2. Create a team and activate Community Forum.
3. Go to the website.
4. Open the forum.
5. Create a post.
6. Check if the "Create Ticket" button is visible in the post.
7. Verify that the post is linked with the ticket.
8. Check if the "View Ticket" button is visible in the post.
"""
password = 'Pl1bhD@2!kXZ'
login_user = self.env['res.users'].create({
"email": "[email protected]",
"login": "test1",
"name": "test1",
"password": password,
})
self.authenticate(login_user.login, password)
forum = self.env['forum.forum'].create({
'name': 'Discussions on Mushrooms',
})
self.test_team['website_forum_ids'] = forum
forum_post = self.env['forum.post'].create({
'name': 'This is forum post',
'forum_id': forum.id,
})
slug = self.env['ir.http']._slug
url = f'/forum/{slug(forum)}/{slug(forum_post)}/get-forum-data'
forum_data = self.make_jsonrpc_request(url)
with self.with_user(login_user.login), MockRequest(self.env, website=self.base_website):
template_vals = WebsiteForumHelpdesk()._prepare_question_template_vals(forum=forum, post={}, question=forum_post)
self.assertTrue(not template_vals.get('question').show_ticket and not template_vals.get('answer', False)
and template_vals.get('show_create_ticket'), 'The Create Ticket button should be visible.')
forum.create_ticket(forum_post.id, {
'post_creator_id': forum_data.get('post_creator_id'),
'post_creator_name': forum_data.get('post_creator_name'),
'post_description': forum_data.get('post_description'),
'post_title': forum_data.get('post_title'),
'team_id': forum_data.get('teams')[0][0],
})
self.assertEqual(forum_post.ticket_id.team_id, self.test_team, 'The ticket is linked with the forum post.')
with self.with_user(login_user.login), MockRequest(self.env, website=self.base_website):
template_vals = WebsiteForumHelpdesk()._prepare_question_template_vals(forum=forum, post={}, question=forum_post)
self.assertTrue(template_vals.get('question').show_ticket, 'The View Ticket button should be visible.')