跳至內容
選單
此問題已被標幟
1 回覆
136 瀏覽次數

Why doesn't Odoo use Sales Order and Invoice Warning Messages from the Contact Internal Notes to appear when you are creating Tickets in Odoo Helpdesk? If Helpdesk is used for billing this should be considered. Im looking at developing a customization for this

頭像
捨棄
最佳答案

Hi,


Odoo does not show Sales Order or Invoice warning messages in Helpdesk tickets because the Helpdesk module was designed as a support tool, not as part of the commercial workflow. The warning logic (sale_warn / invoice_warn) is only implemented in Sales Orders and Invoices, so when you select a customer in Helpdesk, those checks are never triggered.


If you need this (for example, when Helpdesk is used for billable services), you can add a customization to extend helpdesk.ticket so that it calls the same partner warning logic used in Sales and Invoicing. This way, when a ticket is created or a customer is selected, the system will display or block based on the customer’s warning settings.


If you want to integrate this (especially if Helpdesk is used for billing or customer agreements), you can extend helpdesk.ticket to check partner warnings on creation/change.


Try the following code,

from odoo import models, api, _

from odoo.exceptions import UserError


class HelpdeskTicket(models.Model):

    _inherit = "helpdesk.ticket"


    @api.onchange("partner_id")

    def _onchange_partner_id_warning(self):

        if not self.partner_id:

            return


        partner = self.partner_id


        # Check Sales Order Warning

        if partner.sale_warn and partner.sale_warn != "no-message":

            warning = {

                "title": _("Sales Warning for %s") % partner.name,

                "message": partner.sale_warn_msg

            }

            if partner.sale_warn == "block":

                self.partner_id = False

                return {"warning": warning}

            return {"warning": warning}


        # Check Invoice Warning

        if partner.invoice_warn and partner.invoice_warn != "no-message":

            warning = {

                "title": _("Invoice Warning for %s") % partner.name,

                "message": partner.invoice_warn_msg

            }

            if partner.invoice_warn == "block":

                self.partner_id = False

                return {"warning": warning}

            return {"warning": warning}


* This mimics the same warning logic as sale.order and account.move.

* The warning pops up when selecting a customer in a ticket.

* If set to Block, it prevents using that customer.



Hope it helps

頭像
捨棄
相關帖文 回覆 瀏覽次數 活動
0
3月 25
1590
0
10月 24
1532
1
9月 24
1668
1
8月 24
1781
1
7月 24
1603