mirror of
https://github.com/bringout/oca-ocb-technical.git
synced 2026-04-21 07:32:06 +02:00
19.0 vanilla
This commit is contained in:
parent
5faf7397c5
commit
2696f14ed7
721 changed files with 220375 additions and 91221 deletions
|
|
@ -1,17 +1,40 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
from odoo import api, models
|
||||
|
||||
from odoo import api, fields, models
|
||||
|
||||
|
||||
class IapAccount(models.Model):
|
||||
_inherit = 'iap.account'
|
||||
_name = 'iap.account'
|
||||
_inherit = ['iap.account', 'mail.thread']
|
||||
|
||||
# Add tracking to the base fields
|
||||
company_ids = fields.Many2many('res.company', tracking=True)
|
||||
warning_threshold = fields.Float("Email Alert Threshold", tracking=True)
|
||||
warning_user_ids = fields.Many2many('res.users', string="Email Alert Recipients", tracking=True)
|
||||
|
||||
@api.model
|
||||
def _send_iap_bus_notification(self, service_name, title, error_type=False):
|
||||
param = {
|
||||
'title': title,
|
||||
'error_type': 'danger' if error_type else 'success'
|
||||
def _send_success_notification(self, message, title=None):
|
||||
self._send_status_notification(message, 'success', title=title)
|
||||
|
||||
@api.model
|
||||
def _send_error_notification(self, message, title=None):
|
||||
self._send_status_notification(message, 'danger', title=title)
|
||||
|
||||
@api.model
|
||||
def _send_status_notification(self, message, status, title=None):
|
||||
params = {
|
||||
'message': message,
|
||||
'type': status,
|
||||
}
|
||||
if error_type == 'credit':
|
||||
param['url'] = self.env['iap.account'].get_credits_url(service_name)
|
||||
self.env['bus.bus']._sendone(self.env.user.partner_id, 'iap_notification', param)
|
||||
if title is not None:
|
||||
params['title'] = title
|
||||
self.env.user._bus_send("iap_notification", params)
|
||||
|
||||
@api.model
|
||||
def _send_no_credit_notification(self, service_name, title):
|
||||
params = {
|
||||
'title': title,
|
||||
'type': 'no_credit',
|
||||
'get_credits_url': self.env['iap.account'].get_credits_url(service_name),
|
||||
}
|
||||
self.env.user._bus_send("iap_notification", params)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue