Files
odoo_source/addons/partner_autocomplete/models/res_config_settings.py
T
Victor FeyensandThibault Delavallée 8194093f80 [IMP] crm(_*): improve compute in batch and remove unnecessary defaults
Purpose of this commit is to clean field definitions by

  * doing compute in batch: especially when the loop can be reduced to a single
    computation / batch assignment (based on groups or config parameter for
    example);
  * remove default when having a compute as computes should completely define
    the field value at any time;

Some side dish code cleaning is performed at the same time: unnecessary
import or dead code removal.

Task-2638444
PR odoo/odoo#76005

Co-Authored-By: Thibault Delavallée <tde@odoo.com>
Co-Authored-By: Victor Feyens <vfe@odoo.com>
2021-09-08 07:56:02 +00:00

22 lines
814 B
Python

# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import fields, models
class ResConfigSettings(models.TransientModel):
_inherit = 'res.config.settings'
partner_autocomplete_insufficient_credit = fields.Boolean('Insufficient credit', compute="_compute_partner_autocomplete_insufficient_credit")
def _compute_partner_autocomplete_insufficient_credit(self):
self.partner_autocomplete_insufficient_credit = self.env['iap.account'].get_credits('partner_autocomplete') <= 0
def redirect_to_buy_autocomplete_credit(self):
Account = self.env['iap.account']
return {
'type': 'ir.actions.act_url',
'url': Account.get_credits_url('partner_autocomplete'),
'target': '_new',
}