Odoo Help

3

1
2 Answers
0
Avatar

Cyril Gaspard (GEM) France

--Cyril Gaspard (GEM)--
4364
| 6 6 10
Paris, France
--Cyril Gaspard (GEM)--

Forum contributor since 2008

Rank #1 on first OpenERP forum

OpenERP award "Top Contributor" 2011, for my actions on forum

Odoo forum moderator


Cyril Gaspard (GEM) France
10/12/18, 6:15 PM

Hi,

simply create a stored  boolean function field, which depends of the 2 fields you want to compare, test the operation you need in function, you can now filter by the boolean value.

using last api

in your python file

from odoo import api, fields, models

class ResPartner(models.Model):
    _inherit = 'res.partner'

    credit = fields.Float(string="Credit")
    credit_limit = fields.Float(string="Credit limit")
    is_credit_limit_exceeded = fields.Boolean(compute='_get_is_credit_limit_exceeded',
string="Credit limit exceeded",
compute_sudo=True, store=True)

   @api.multi
    @api.depends('credit', 'credit_limit')
    def _get_is_credit_limit_exceeded(self):
        self.is_credit_limit_exceeded = self.credit > self.credit_limit

in your xml file, in search view

<filter name="Credit limit" domain="[('is_credit_limit_exceeded', '=', True)]"/>
2 Comments
Ibrahim Boudmir Morocco
10/13/18, 4:24 PM

Without forgetting to add the boolean field with invisible="1"

Cyril Gaspard (GEM) France
10/14/18, 10:53 AM

Hi,

this is a stored field function with dependecies, no need to add the field in view.

Bye

Ask a Question
Writer
Keep Informed
2 follower(s)
About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

Register
Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now