İçereği Atla
Menü
Bu soru işaretlendi
3 Cevaplar
175 Görünümler

To preface this, I am a Odoo newbie. I saw from a previous post on a previous version of Odoo that I can set parameters into the approval step of the send button to restrict a quotation from being send by an employee if the credit limit of the customer has been exceeded.

I've followed the step by step guide but it does not work. The error was "Domain is invalid. Please correct it". Please if anyone knows what is the issue, do let me know. Thank you.

I am using Odoo v19 on the web if that provides any context.


The code that I entered was [("partner_credit_warning", "=", False)] in the filter parameter of the add approval step for the send button. Sorry I can't add images as I do not have enough Karma points.

Avatar
Vazgeç
Üretici

I'm not sure if I have done something wrong. I still can't add the code in the approval filter.


I added a checkbox field

Under "more" settings, I check the "Readonly" and "Stored" boxes.

For properties, I added partner_credit_warning as a dependency and copied the code into compute


partner_credit_warning_bool = fields.Boolean(

    compute="_compute_partner_credit_warning_bool",

    store=True

)


@api.depends('partner_credit_warning')

def _compute_partner_credit_warning_bool(self):

    for rec in self:

        rec.partner_credit_warning_bool = bool(rec.partner_credit_warning)


Was I suppose to add other type of fields? Or was there something wrong in my inputs?

Üretici En İyi Yanıt

Ok I managed to get the partner_credit_warning to work. But then the manager doesn't receive a TO-DO to approve or reject the quotation from being sent. 

Avatar
Vazgeç
En İyi Yanıt

There may be a simpler solution here with Studio.  You can make the button invisible if  partner_credit_warning is set:

Note that the button is already invisible if the status is Sales Order, so you need to add a second condition - with "any" rather than "all":


Avatar
Vazgeç
En İyi Yanıt

Hi,


The partner_credit_warning field in sale.order is a compute field with no store. So when odoo tries to translate this into SQL, it can't find a column for partner_credit_warning, and fails with “Domain is invalid.”


Solution: Add a field to sale.order :

partner_credit_warning_bool = fields.Boolean(

    compute="_compute_partner_credit_warning_bool",

    store=True

)


@api.depends('partner_credit_warning')

def _compute_partner_credit_warning_bool(self):

    for rec in self:

        rec.partner_credit_warning_bool = bool(rec.partner_credit_warning)

Change domain: [("partner_credit_warning_bool", "=", False)]


Hope it helps

Avatar
Vazgeç
İlgili Gönderiler Cevaplar Görünümler Aktivite
2
Ağu 25
809
1
Mar 24
2253
0
Kas 22
3155
0
Tem 21
3960
2
Kas 20
2695