[16.0][ADD] helpdesk_mgmt_livechat: add new module - #884
Conversation
2fefc1c to
4379492
Compare
4379492 to
0b1fa91
Compare
marcos-mendez
left a comment
There was a problem hiding this comment.
Automated Review -- Tests Failed
1. Root Cause of the Test Failure
The test failure occurs because the database connection fails during the Odoo server startup, likely due to misconfiguration or an issue with the test environment setup (e.g., missing PostgreSQL service or invalid connection parameters). This is not directly caused by the module code but indicates a failure in the CI/CD pipeline or test runner environment.
2. Suggested Fix
There is no code-level fix needed for this failure since it's an infrastructure or environment issue. However, to prevent such failures in the future:
- Ensure that the
runboatenvironment is properly configured with access to a valid PostgreSQL instance. - Verify that the database connection string in the test config is correct.
- Confirm that the test database is created and accessible before running tests.
⚠️ This error is unrelated to the module code changes and should be resolved at the CI level.
3. Additional Code Issues
🔴 Potential Bug in chatbot_script_step.py line ~77
create_values.update(
self._chatbot_helpdesk_prepare_ticket_values(
mail_channel, customer_values["description"]
)
)- The method
_chatbot_helpdesk_prepare_ticket_valuesis not defined in the base classchatbot.script.step, and it's expected to be overridden or defined in this module. - It should be a protected method (e.g.,
_prepare_ticket_values) or at least documented as an extension point.
✅ Suggested Fix:
Rename _chatbot_helpdesk_prepare_ticket_values to _prepare_ticket_values and ensure it's a documented hook, e.g.,:
def _prepare_ticket_values(self, mail_channel, description):
return {
"description": description + mail_channel._get_channel_history(),
"name": _("%s's New Ticket", self.chatbot_script_id.title),
"team_id": self.helpdesk_team_id.id,
"user_id": False,
}Then update the call to:
create_values.update(self._prepare_ticket_values(mail_channel, customer_values["description"]))🔴 Inefficient Domain Search in chatbot_script.py line ~25
.search_count(
[
("description", "ilike", script.title),
("channel_id.name", "=", "Livechat"),
]
)- The
search_countusesilikeondescriptionwhich is inefficient and may cause performance issues if there are many tickets. - It's also fragile since ticket descriptions may not always contain the chatbot title.
✅ Suggested Fix:
Use a more robust way to track tickets created from chatbots, such as adding a related field or using a computed field with a proper link to the chatbot script.
4. Test Improvements
✅ Add Tests for the Following Scenarios (using SavepointCase or TransactionCase)
-
Test
/ticketcommand execution:- Simulate a livechat conversation.
- Execute
/ticket Some issue. - Assert that a ticket is created with correct title, description, and channel.
-
Test chatbot
create_ticketstep:- Create a chatbot script with a
create_ticketstep. - Configure a helpdesk team.
- Simulate a visitor reaching that step.
- Assert that a ticket is created with correct team, description, and channel.
- Create a chatbot script with a
-
Test channel creation fallback logic:
- Delete the
helpdesk.ticket.channelrecord. - Trigger ticket creation via chatbot or
/ticket. - Assert that the channel is recreated automatically.
- Delete the
-
Test
ticket_countcomputation:- Create multiple tickets with matching descriptions.
- Run
_compute_ticket_counton a chatbot script. - Assert that the
ticket_countis correctly updated.
✅ Use OCA Testing Patterns
- Use
SavepointCasefor tests involving data isolation and performance. - Use
TransactionCasefor tests requiring transactional behavior. - Tag tests with
@tagged('post_install')if they rely on data loaded from XML files.
✅ Example Test Snippet
def test_ticket_creation_from_chatbot_step(self):
script = self.env.ref("helpdesk_mgmt_livechat.chatbot_script_ticket_generation_bot")
step = self.env["chatbot.script.step"].create({
"step_type": "create_ticket",
"chatbot_script_id": script.id,
"helpdesk_team_id": self.env.ref("helpdesk_mgmt.helpdesk_team_1").id,
})
# Simulate channel and run step
channel = self.env["mail.channel"].create({"name": "Test"})
# Assert ticket is createdSummary
| Area | Issue |
|---|---|
| Root Cause | Test environment/database connection issue, not code |
| Code Bug | Inefficient domain search and fragile description matching |
| Extension Hook | _chatbot_helpdesk_prepare_ticket_values should be renamed and documented |
| Testing | Add tests for /ticket command, chatbot steps, and fallback channel logic |
Let me know if you'd like a patch file or test code examples.
⏰ PR Aging Alert
This PR by @marcelsavegnago has been open for 121 days (4 months).
Every ignored PR is a contributor who might not come back. Review time matters. (OCA Aging Report)
Reciprocal Review Request
Hi everyone! I found some test failures on this PR and left detailed feedback above. I am happy to discuss or help debug. In the meantime, if any of you get a chance, I would appreciate a look at my open PR(s):
My open PRs across OCA:
- server-tools#3554 [MIG] datetime_formatter: Migration to 18.0
- server-tools#3548 [18.0][MIG] base_kanban_stage: Migration to 18.0
- hr-attendance#262 [16.0][ADD] Hr_attendance_idsecure: iDSecure (ControliD) attendance integration
- stock-logistics-workflow#2276 [16.0][ADD] stock_move_line_devaluation
- stock-logistics-workflow#2275 [16.0][ADD] Stock move line analytic account
- stock-logistics-workflow#2268 [16.0][ADD] stock_move_line_picking_partner
- purchase-workflow#2694 [16.0][IMP]Purchase workflow added to review state & exception fix
Reviewing each other's work helps the whole community move forward. Thank you!
Environment via OCA Neural Reviewer: Minikube + K8s Job + oca-ci/py3.10-odoo16.0 | Odoo 16.0
Automated review by OCA Neural Reviewer + qwen3-coder:30b
|
There hasn't been any activity on this pull request in the past 4 months, so it has been marked as stale and it will be closed automatically if no further activity occurs in the next 30 days. |
This module extends the helpdesk management functionality by allowing you to create tickets directly from livechat conversations.
Main Features
/ticketcommandBenefits
Dependencies
This module requires:
helpdesk_mgmt: Base helpdesk management moduleim_livechat: Odoo's livechat module