Compare commits
2 Commits
new-helpde
...
16.0-helpd
Author | SHA1 | Date | |
---|---|---|---|
|
1273441f27 | ||
|
fcff556352 |
2
helpdesk_convert_ticket_to_task/.gitignore
vendored
2
helpdesk_convert_ticket_to_task/.gitignore
vendored
@@ -1,2 +0,0 @@
|
|||||||
*.*~
|
|
||||||
*pyc
|
|
@@ -1,42 +0,0 @@
|
|||||||
===============================
|
|
||||||
helpdesk_convert_ticket_to_task
|
|
||||||
===============================
|
|
||||||
|
|
||||||
This module aims to convert a ticket into a task.
|
|
||||||
For this, it adds a button in the ticket view "Convert to task".
|
|
||||||
|
|
||||||
It automatically fills up many fields (check the function button_convert_to_task for details)
|
|
||||||
|
|
||||||
# Installation
|
|
||||||
|
|
||||||
Use Odoo normal module installation procedure to install
|
|
||||||
`helpdesk_convert_ticket_to_task`.
|
|
||||||
|
|
||||||
# Known issues / Roadmap
|
|
||||||
|
|
||||||
A current limitation is that one task can be linked to many tickets.
|
|
||||||
Thus, the above task fields are filled up at the creation of the task from a ticket form
|
|
||||||
but are not updated when the linked tickets are updated.
|
|
||||||
|
|
||||||
# Bug Tracker
|
|
||||||
|
|
||||||
Bugs are tracked on `our issues website <https://github.com/elabore-coop/helpdesk-tools/issues>`\_. In case of
|
|
||||||
trouble, please check there if your issue has already been
|
|
||||||
reported. If you spotted it first, help us smashing it by providing a
|
|
||||||
detailed and welcomed feedback.
|
|
||||||
|
|
||||||
# Credits
|
|
||||||
|
|
||||||
## Contributors
|
|
||||||
|
|
||||||
- Quentin Mondot
|
|
||||||
|
|
||||||
## Funders
|
|
||||||
|
|
||||||
The development of this module has been financially supported by:
|
|
||||||
|
|
||||||
- Elabore (https://elabore.coop)
|
|
||||||
|
|
||||||
## Maintainer
|
|
||||||
|
|
||||||
This module is maintained by Elabore.
|
|
@@ -1 +0,0 @@
|
|||||||
from . import models
|
|
@@ -1,27 +0,0 @@
|
|||||||
# Copyright 2024 Quentin Mondot
|
|
||||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
|
||||||
{
|
|
||||||
"name": "helpdesk_convert_ticket_to_task",
|
|
||||||
"version": "16.0.1.0.0",
|
|
||||||
"author": "Elabore",
|
|
||||||
"website": "https://elabore.coop",
|
|
||||||
"maintainer": "Quentin Mondot",
|
|
||||||
"license": "AGPL-3",
|
|
||||||
"category": "Tools",
|
|
||||||
"summary": "This module adds a button to convert a ticket into a task.",
|
|
||||||
"depends": [
|
|
||||||
"base",
|
|
||||||
"helpdesk_mgmt",
|
|
||||||
"helpdesk_mgmt_project",
|
|
||||||
"helpdesk_request_type", # to create the helpdesk.request.type model and have the field request_type_id in the helpdesk.ticket model
|
|
||||||
"project_request_data", # to have the fields service_id and request_type_id in the project.task model
|
|
||||||
"project_task_add_very_high", # to have priority values 2 and 3 on tasks
|
|
||||||
"helpdesk_transfer_timesheet_to_task" # to copy timesheets from ticket to task
|
|
||||||
],
|
|
||||||
"data": [
|
|
||||||
"views/helpdesk_convert_ticket_to_task.xml",
|
|
||||||
],
|
|
||||||
"installable": True,
|
|
||||||
"auto_install": False,
|
|
||||||
"application": False,
|
|
||||||
}
|
|
@@ -1,64 +0,0 @@
|
|||||||
# Translation of Odoo Server.
|
|
||||||
# This file contains the translation of the following modules:
|
|
||||||
# * helpdesk_convert_ticket_to_task
|
|
||||||
#
|
|
||||||
msgid ""
|
|
||||||
msgstr ""
|
|
||||||
"Project-Id-Version: Odoo Server 16.0\n"
|
|
||||||
"Report-Msgid-Bugs-To: \n"
|
|
||||||
"POT-Creation-Date: 2025-07-08 14:02+0000\n"
|
|
||||||
"PO-Revision-Date: 2025-07-08 14:02+0000\n"
|
|
||||||
"Last-Translator: \n"
|
|
||||||
"Language-Team: \n"
|
|
||||||
"MIME-Version: 1.0\n"
|
|
||||||
"Content-Type: text/plain; charset=UTF-8\n"
|
|
||||||
"Content-Transfer-Encoding: \n"
|
|
||||||
"Plural-Forms: \n"
|
|
||||||
|
|
||||||
#. module: helpdesk_convert_ticket_to_task
|
|
||||||
#: model_terms:ir.ui.view,arch_db:helpdesk_convert_ticket_to_task.convert_to_task_helpdesk_ticket_view_form
|
|
||||||
msgid ""
|
|
||||||
"Are you sure you want to convert this ticket into a task ? You'll be "
|
|
||||||
"redirected to the created task and the ticket will be archived."
|
|
||||||
msgstr ""
|
|
||||||
"Êtes-vous sûr de vouloir convertir ce ticket en tâche ? Vous allez être "
|
|
||||||
"redirigé vers la tâche créée et ce ticket sera archivé."
|
|
||||||
|
|
||||||
#. module: helpdesk_convert_ticket_to_task
|
|
||||||
#: model_terms:ir.ui.view,arch_db:helpdesk_convert_ticket_to_task.convert_to_task_helpdesk_ticket_view_form
|
|
||||||
msgid "Convert to task"
|
|
||||||
msgstr "Convertir en tâche"
|
|
||||||
|
|
||||||
#. module: helpdesk_convert_ticket_to_task
|
|
||||||
#: model:ir.model,name:helpdesk_convert_ticket_to_task.model_helpdesk_ticket
|
|
||||||
msgid "Helpdesk Ticket"
|
|
||||||
msgstr "Ticket d'Assistance"
|
|
||||||
|
|
||||||
#. module: helpdesk_convert_ticket_to_task
|
|
||||||
#: model:ir.model.fields,field_description:helpdesk_convert_ticket_to_task.field_helpdesk_ticket__smart_search
|
|
||||||
msgid "Smart Search"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#. module: helpdesk_convert_ticket_to_task
|
|
||||||
#. odoo-python
|
|
||||||
#: code:addons/helpdesk_convert_ticket_to_task/models/helpdesk_ticket.py:0
|
|
||||||
#, python-format
|
|
||||||
msgid ""
|
|
||||||
"This task has been converted from a ticket. You can find the original ticket"
|
|
||||||
" <a href='%(ticket_url)s' target='_blank'>on this link</a>."
|
|
||||||
msgstr ""
|
|
||||||
"Cette tâche a été convertie depuis un ticket. Vous trouverez le ticket "
|
|
||||||
"original en cliquant <a href='%(ticket_url)s' target='_blank'>sur ce "
|
|
||||||
"lien</a>."
|
|
||||||
|
|
||||||
#. module: helpdesk_convert_ticket_to_task
|
|
||||||
#. odoo-python
|
|
||||||
#: code:addons/helpdesk_convert_ticket_to_task/models/helpdesk_ticket.py:0
|
|
||||||
#, python-format
|
|
||||||
msgid ""
|
|
||||||
"This ticket has been converted into a task. You can find it <a "
|
|
||||||
"href='%(task_url)s' target='_blank'>on this link</a>."
|
|
||||||
msgstr ""
|
|
||||||
"Ce ticket a été convertie en tâche. Vous trouverez la tâche "
|
|
||||||
"en cliquant <a href='%(task_url)s' target='_blank'>sur ce "
|
|
||||||
"lien</a>."
|
|
@@ -1 +0,0 @@
|
|||||||
from . import helpdesk_ticket
|
|
@@ -1,103 +0,0 @@
|
|||||||
from odoo import _, models, api
|
|
||||||
|
|
||||||
class HelpdeskTicket(models.Model):
|
|
||||||
_inherit = "helpdesk.ticket"
|
|
||||||
|
|
||||||
def button_convert_to_task(self):
|
|
||||||
user_ids = [self.user_id.id]
|
|
||||||
task_service_id, request_type_id = self._match_task_service_and_request_type(
|
|
||||||
ticket_category_id=self.category_id.id,
|
|
||||||
ticket_request_type_id=self.request_type_id.id
|
|
||||||
)
|
|
||||||
|
|
||||||
task = self.env["project.task"].create({
|
|
||||||
"name": self.name,
|
|
||||||
"description": self.description,
|
|
||||||
"project_id": self.project_id.id,
|
|
||||||
"user_ids": user_ids,
|
|
||||||
"partner_id": self.partner_id.id,
|
|
||||||
"service_id": task_service_id,
|
|
||||||
"request_type_id": request_type_id,
|
|
||||||
"priority": self.priority
|
|
||||||
})
|
|
||||||
|
|
||||||
# copy chatter
|
|
||||||
for msg in reversed(self.message_ids):
|
|
||||||
msg.copy({
|
|
||||||
'model': 'project.task',
|
|
||||||
'res_id': task.id
|
|
||||||
})
|
|
||||||
|
|
||||||
# copy attachments inserted in the messages
|
|
||||||
for attach in msg.attachment_ids:
|
|
||||||
attach.copy({
|
|
||||||
'res_model': 'project.task',
|
|
||||||
'res_id': task.id,
|
|
||||||
'res_name': task.name
|
|
||||||
})
|
|
||||||
|
|
||||||
# copy attachments not added in a message
|
|
||||||
for attachment in self.attachment_ids:
|
|
||||||
attachment.copy({
|
|
||||||
'res_model': 'project.task',
|
|
||||||
'res_id': task.id,
|
|
||||||
'res_name': task.name
|
|
||||||
})
|
|
||||||
|
|
||||||
# copy subscribers
|
|
||||||
task.message_subscribe(partner_ids=self.message_partner_ids.ids)
|
|
||||||
|
|
||||||
# warn (in the chatter) that the task is a copy
|
|
||||||
base_url = self.env["ir.config_parameter"].sudo().get_param("web.base.url")
|
|
||||||
ticket_url = f"{base_url}/web#id={self.id}&model=helpdesk.ticket&view_type=form"
|
|
||||||
task_message = _(
|
|
||||||
"This task has been converted from a ticket. You can find the original ticket <a href='%(ticket_url)s' target='_blank'>on this link</a>.",
|
|
||||||
ticket_url=ticket_url
|
|
||||||
)
|
|
||||||
task.message_post(body=task_message)
|
|
||||||
|
|
||||||
# warn (in the chatter) that the ticket has been converted
|
|
||||||
task_url = f"{base_url}/web#id={task.id}&model=project.task&view_type=form"
|
|
||||||
ticket_message = _(
|
|
||||||
"This ticket has been converted into a task. You can find it <a href='%(task_url)s' target='_blank'>on this link</a>.",
|
|
||||||
task_url=task_url
|
|
||||||
)
|
|
||||||
self.message_post(body=ticket_message)
|
|
||||||
|
|
||||||
# archive the ticket
|
|
||||||
self.write({
|
|
||||||
"active": False,
|
|
||||||
"task_id": task.id
|
|
||||||
})
|
|
||||||
# transfer timesheets from ticket to task
|
|
||||||
self._onchange_task_id()
|
|
||||||
|
|
||||||
return {
|
|
||||||
"type": "ir.actions.act_window",
|
|
||||||
"view_mode": "form",
|
|
||||||
"target": "current",
|
|
||||||
"res_model": "project.task",
|
|
||||||
"res_id": task.id,
|
|
||||||
}
|
|
||||||
|
|
||||||
def _match_task_service_and_request_type(
|
|
||||||
self,
|
|
||||||
ticket_category_id: int,
|
|
||||||
ticket_request_type_id: int
|
|
||||||
) -> tuple[int, int]:
|
|
||||||
"""
|
|
||||||
This function permits to match the task service_id and request_type from the ticket category and request type
|
|
||||||
"""
|
|
||||||
helpdesk_ticket_category = self.env["helpdesk.ticket.category"].search(
|
|
||||||
[("id", "=", ticket_category_id)],
|
|
||||||
limit=1
|
|
||||||
)
|
|
||||||
task_service = self.env["task.service"].search([("name", "=", helpdesk_ticket_category.name)])
|
|
||||||
|
|
||||||
helpdesk_ticket_request_type = self.env["helpdesk.request.type"].search(
|
|
||||||
[("id", "=", ticket_request_type_id)],
|
|
||||||
limit=1
|
|
||||||
)
|
|
||||||
task_request_type = self.env["request.type"].search([("name", "=", helpdesk_ticket_request_type.name)])
|
|
||||||
|
|
||||||
return task_service.id, task_request_type.id
|
|
@@ -1,21 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<odoo>
|
|
||||||
<record id="convert_to_task_helpdesk_ticket_view_form" model="ir.ui.view">
|
|
||||||
<field name="name">timesheet.helpdesk.ticket.form.view</field>
|
|
||||||
<field name="model">helpdesk.ticket</field>
|
|
||||||
<field name="inherit_id" ref="helpdesk_mgmt.ticket_view_form" />
|
|
||||||
<field name="priority" eval="20" />
|
|
||||||
<field name="arch" type="xml">
|
|
||||||
<div name="button_box" position="inside">
|
|
||||||
<button
|
|
||||||
name="button_convert_to_task"
|
|
||||||
title="Convert to task"
|
|
||||||
string="Convert to task"
|
|
||||||
icon="fa-tasks text-success"
|
|
||||||
type="object"
|
|
||||||
confirm="Are you sure you want to convert this ticket into a task ? You'll be redirected to the newly created task and this ticket will be archived."
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</field>
|
|
||||||
</record>
|
|
||||||
</odoo>
|
|
@@ -1,2 +0,0 @@
|
|||||||
*.*~
|
|
||||||
*pyc
|
|
@@ -1,39 +0,0 @@
|
|||||||
===================================
|
|
||||||
helpdesk_transfer_timesheet_to_task
|
|
||||||
===================================
|
|
||||||
|
|
||||||
This module assigns the field task of the timesheets' ticket to the task linked to the ticket.
|
|
||||||
Exception : the timesheet is not transfered to the task linked to the ticket if
|
|
||||||
it has already been invoiced (timesheet_invoice_id != False).
|
|
||||||
|
|
||||||
# Installation
|
|
||||||
|
|
||||||
Use Odoo normal module installation procedure to install
|
|
||||||
`helpdesk_transfer_timesheets_to_task`.
|
|
||||||
|
|
||||||
# Known issues / Roadmap
|
|
||||||
|
|
||||||
None.
|
|
||||||
|
|
||||||
# Bug Tracker
|
|
||||||
|
|
||||||
Bugs are tracked on `our issues website <https://github.com/elabore-coop/helpdesk-tools/issues>`\_. In case of
|
|
||||||
trouble, please check there if your issue has already been
|
|
||||||
reported. If you spotted it first, help us smashing it by providing a
|
|
||||||
detailed and welcomed feedback.
|
|
||||||
|
|
||||||
# Credits
|
|
||||||
|
|
||||||
## Contributors
|
|
||||||
|
|
||||||
- Quentin Mondot
|
|
||||||
|
|
||||||
## Funders
|
|
||||||
|
|
||||||
The development of this module has been financially supported by:
|
|
||||||
|
|
||||||
- Elabore (https://elabore.coop)
|
|
||||||
|
|
||||||
## Maintainer
|
|
||||||
|
|
||||||
This module is maintained by Elabore.
|
|
@@ -1 +0,0 @@
|
|||||||
from . import models
|
|
@@ -1,23 +0,0 @@
|
|||||||
# Copyright 2024 Quentin Mondot
|
|
||||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
|
||||||
{
|
|
||||||
"name": "helpdesk_transfer_timesheet_to_task",
|
|
||||||
"version": "16.0.1.0.0",
|
|
||||||
"author": "Elabore",
|
|
||||||
"website": "https://elabore.coop",
|
|
||||||
"maintainer": "Quentin Mondot",
|
|
||||||
"license": "AGPL-3",
|
|
||||||
"category": "Tools",
|
|
||||||
"summary": "This module assigns timesheets to the task linked to a ticket.",
|
|
||||||
"depends": [
|
|
||||||
"base",
|
|
||||||
"helpdesk_mgmt",
|
|
||||||
"helpdesk_mgmt_project",
|
|
||||||
"helpdesk_mgmt_timesheet",
|
|
||||||
"sale_timesheet"
|
|
||||||
],
|
|
||||||
"data": [],
|
|
||||||
"installable": True,
|
|
||||||
"auto_install": False,
|
|
||||||
"application": False,
|
|
||||||
}
|
|
@@ -1 +0,0 @@
|
|||||||
from . import helpdesk_ticket
|
|
@@ -1,12 +0,0 @@
|
|||||||
from odoo import models, api, Command
|
|
||||||
|
|
||||||
|
|
||||||
class HelpdeskTicket(models.Model):
|
|
||||||
_inherit = "helpdesk.ticket"
|
|
||||||
|
|
||||||
@api.onchange("task_id")
|
|
||||||
def _onchange_task_id(self):
|
|
||||||
for record in self:
|
|
||||||
if record.timesheet_ids and record.task_id:
|
|
||||||
not_yet_invoiced_timesheet_ids = [t.id for t in record.timesheet_ids if not t.timesheet_invoice_id]
|
|
||||||
record.task_id.timesheet_ids = [Command.link(t_id) for t_id in not_yet_invoiced_timesheet_ids]
|
|
@@ -1 +0,0 @@
|
|||||||
from . import test_helpdesk_ticket
|
|
@@ -1,181 +0,0 @@
|
|||||||
from odoo.tests.common import TransactionCase
|
|
||||||
|
|
||||||
|
|
||||||
class TestHelpdeskTicket(TransactionCase):
|
|
||||||
|
|
||||||
def setUp(self):
|
|
||||||
super(TestHelpdeskTicket, self).setUp()
|
|
||||||
self.HelpdeskTicket = self.env["helpdesk.ticket"]
|
|
||||||
self.ProjectTask = self.env["project.task"]
|
|
||||||
self.AccountAnalyticLine = self.env["account.analytic.line"]
|
|
||||||
self.AccountMove = self.env["account.move"]
|
|
||||||
self.Project = self.env["project.project"]
|
|
||||||
|
|
||||||
self.project = self.Project.create(
|
|
||||||
{"name": "Test project", "allow_timesheets": True}
|
|
||||||
)
|
|
||||||
self.analytic_account = self.project.analytic_account_id
|
|
||||||
# Create a sample task
|
|
||||||
self.task = self.ProjectTask.create(
|
|
||||||
{"name": "Sample Task", "project_id": self.project.id}
|
|
||||||
)
|
|
||||||
|
|
||||||
def test_timesheet_added_to_linked_task(self):
|
|
||||||
# Create a ticket
|
|
||||||
ticket = self.HelpdeskTicket.create(
|
|
||||||
{"name": "Test Ticket", "description": "My ticket"}
|
|
||||||
)
|
|
||||||
|
|
||||||
# Associate a task with the ticket
|
|
||||||
ticket.task_id = self.task.id
|
|
||||||
|
|
||||||
# Log time on the ticket
|
|
||||||
timesheet = self.AccountAnalyticLine.create(
|
|
||||||
{
|
|
||||||
"name": "Time Entry",
|
|
||||||
"ticket_id": ticket.id,
|
|
||||||
"unit_amount": 1.0,
|
|
||||||
"account_id": self.analytic_account.id,
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
timesheet.onchange_ticket_id()
|
|
||||||
|
|
||||||
# Check that timesheet is linked to the task
|
|
||||||
self.assertIn(timesheet, self.task.timesheet_ids)
|
|
||||||
|
|
||||||
def test_timesheet_added_to_new_task(self):
|
|
||||||
# Create a ticket
|
|
||||||
ticket = self.HelpdeskTicket.create(
|
|
||||||
{"name": "Test Ticket", "description": "My ticket"}
|
|
||||||
)
|
|
||||||
|
|
||||||
# Log time on the ticket
|
|
||||||
timesheet = self.AccountAnalyticLine.create(
|
|
||||||
{
|
|
||||||
"name": "Time Entry",
|
|
||||||
"ticket_id": ticket.id,
|
|
||||||
"unit_amount": 1.0,
|
|
||||||
"account_id": self.analytic_account.id,
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
# Associate a task with the ticket
|
|
||||||
ticket.task_id = self.task.id
|
|
||||||
ticket._onchange_task_id()
|
|
||||||
|
|
||||||
# Check that timesheet is linked to the task
|
|
||||||
self.assertIn(timesheet, self.task.timesheet_ids)
|
|
||||||
|
|
||||||
def test_timesheet_for_task_linked_to_several_tickets(self):
|
|
||||||
# Create a first ticket
|
|
||||||
ticket_1 = self.HelpdeskTicket.create(
|
|
||||||
{"name": "Test Ticket 1", "description": "My 1st ticket"}
|
|
||||||
)
|
|
||||||
|
|
||||||
# Log time on the first ticket
|
|
||||||
first_timesheet = self.AccountAnalyticLine.create(
|
|
||||||
{
|
|
||||||
"name": "First Time Entry",
|
|
||||||
"ticket_id": ticket_1.id,
|
|
||||||
"unit_amount": 1.0,
|
|
||||||
"account_id": self.analytic_account.id,
|
|
||||||
}
|
|
||||||
)
|
|
||||||
# Associate a task to the first ticket
|
|
||||||
ticket_1.task_id = self.task.id
|
|
||||||
ticket_1._onchange_task_id()
|
|
||||||
# Create a second ticket
|
|
||||||
ticket_2 = self.HelpdeskTicket.create(
|
|
||||||
{"name": "Test Ticket 2", "description": "My 2nd ticket"}
|
|
||||||
)
|
|
||||||
# Log time on the second ticket
|
|
||||||
second_timesheet = self.AccountAnalyticLine.create(
|
|
||||||
{
|
|
||||||
"name": "Second Time Entry",
|
|
||||||
"ticket_id": ticket_2.id,
|
|
||||||
"unit_amount": 2.0,
|
|
||||||
"account_id": self.analytic_account.id,
|
|
||||||
}
|
|
||||||
)
|
|
||||||
# Associate the same task to the second ticket
|
|
||||||
ticket_2.task_id = self.task.id
|
|
||||||
ticket_2._onchange_task_id()
|
|
||||||
|
|
||||||
# Check that both timesheets are linked to the task
|
|
||||||
self.assertIn(first_timesheet, self.task.timesheet_ids)
|
|
||||||
self.assertIn(second_timesheet, self.task.timesheet_ids)
|
|
||||||
|
|
||||||
def test_timesheet_moved_between_tasks(self):
|
|
||||||
# Create a second task
|
|
||||||
task_2 = self.ProjectTask.create(
|
|
||||||
{"name": "Second Task", "project_id": self.project.id}
|
|
||||||
)
|
|
||||||
|
|
||||||
# Create a ticket
|
|
||||||
ticket = self.HelpdeskTicket.create(
|
|
||||||
{"name": "Test Ticket", "description": "My ticket"}
|
|
||||||
)
|
|
||||||
|
|
||||||
# Log time on the ticket
|
|
||||||
timesheet = self.AccountAnalyticLine.create(
|
|
||||||
{
|
|
||||||
"name": "Time Entry for Moving",
|
|
||||||
"ticket_id": ticket.id,
|
|
||||||
"unit_amount": 1.0,
|
|
||||||
"account_id": self.analytic_account.id,
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
# Associate the first task with the ticket
|
|
||||||
ticket.task_id = self.task.id
|
|
||||||
ticket._onchange_task_id()
|
|
||||||
|
|
||||||
# Associate the second task with the ticket
|
|
||||||
ticket.task_id = task_2.id
|
|
||||||
ticket._onchange_task_id()
|
|
||||||
|
|
||||||
# Check if timesheet is moved to the second task
|
|
||||||
self.assertNotIn(timesheet, self.task.timesheet_ids)
|
|
||||||
self.assertIn(timesheet, task_2.timesheet_ids)
|
|
||||||
|
|
||||||
def test_timesheet_already_invoiced_are_not_moved(self):
|
|
||||||
journal = self.env["account.journal"].create(
|
|
||||||
{"name": "My journal", "code": "test", "type": "bank"}
|
|
||||||
)
|
|
||||||
account_move = self.AccountMove.create(
|
|
||||||
{"move_type": "entry", "journal_id": journal.id}
|
|
||||||
)
|
|
||||||
# Create a ticket
|
|
||||||
ticket = self.HelpdeskTicket.create(
|
|
||||||
{"name": "Test Ticket", "description": "My ticket"}
|
|
||||||
)
|
|
||||||
|
|
||||||
# Log already invoiced timesheet on the ticket
|
|
||||||
already_invoiced_timesheet = self.AccountAnalyticLine.create(
|
|
||||||
{
|
|
||||||
"name": "Already Invoiced Time Entry",
|
|
||||||
"ticket_id": ticket.id,
|
|
||||||
"unit_amount": 1.0,
|
|
||||||
"account_id": self.analytic_account.id,
|
|
||||||
"timesheet_invoice_id": account_move.id,
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
# Log not invoiced timesheet on the ticket
|
|
||||||
not_invoiced_timesheet = self.AccountAnalyticLine.create(
|
|
||||||
{
|
|
||||||
"name": "Not Invoiced Time Entry",
|
|
||||||
"ticket_id": ticket.id,
|
|
||||||
"unit_amount": 2.0,
|
|
||||||
"account_id": self.analytic_account.id,
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
# Associate a task with the ticket
|
|
||||||
ticket.task_id = self.task.id
|
|
||||||
ticket._onchange_task_id()
|
|
||||||
|
|
||||||
# Check already invoiced timesheet has not been moved
|
|
||||||
self.assertNotIn(already_invoiced_timesheet, self.task.timesheet_ids)
|
|
||||||
self.assertIn(not_invoiced_timesheet, self.task.timesheet_ids)
|
|
Reference in New Issue
Block a user