Overslaan naar inhoud
Menu
Je moet geregistreerd zijn om te kunnen communiceren met de community.
Deze vraag is gerapporteerd
2 Antwoorden
2105 Weergaven

I am working from the customer section in the sales module, I have this code.  


is_client = fields.Boolean(compute='_customize_filter', string="is a cliente")


is_prospect= fields.Boolean(compute='_customize_filter', string="is a prospect")


is_contact = fields.Boolean(compute='_customize_filter', string="is a contact")


def _customize_filter(self):

     for partner in self:

          partner.is_client = True if partner.total_invoiced > 0 else False 

          partner.is_prospect = True if partner.sale_order_count > 0 else False 

         partner.is_contact = True if partner.parent_id else False 


How can I put a double validation in the is_prospect field to tell it to deactivate if the is_client field is True and only activate if it has sales but no invoices?


Odoo 13 community, thank you.






Avatar
Annuleer
Beste antwoord

HI,

Try with this code:

def _customize_filter(self):
for partner in self:
partner.is_client = True if partner.total_invoiced > 0 else False
partner.is_prospect = True if partner.sale_order_count > 0 and partner.total_invoiced == 0 else False
partner.is_contact = True if partner.parent_id else False


Thanks

Avatar
Annuleer
Auteur

Hello, thanks for answering.. What I am trying to do is a filter of the clients in the sales module, where if the contact has neither sales nor invoices, no boolean will be activated, if the contact only has sales, the lead boolean will be activated, if the contact has invoices it will be activated the boolean of client... my question here is... Can I use those fields that are in res.partner to be able to do filtering? Since in the view try to apply a filter domain in the client, but it doesn't work... In the booleans I already put a store=True to store the value in the database, but it still doesn't work, I appreciate your answer....

Beste antwoord

Hi,

You can modify your _customize_filter function to include the double validation for the is_prospect field. Here's an updated version of the function:

def _customize_filter(self):
for partner in self:
partner.is_client = partner.total_invoiced > 0
partner.is_contact = bool(partner.parent_id)
if partner.sale_order_count > 0:
if partner.total_invoiced == 0 and not partner.is_client:
partner.is_prospect = True
else:
partner.is_prospect = False
else:
partner.is_prospect = False

Regards

Avatar
Annuleer
Auteur

Hello, thanks for answering.. What I am trying to do is a filter of the clients in the sales module, where if the contact has neither sales nor invoices, no boolean will be activated, if the contact only has sales, the lead boolean will be activated, if the contact has invoices it will be activated the boolean of client... my question here is... Can I use those fields that are in res.partner to be able to do filtering? Since in the view try to apply a filter domain in the client, but it doesn't work... In the booleans I already put a store=True to store the value in the database, but it still doesn't work, I appreciate your answer....

Gerelateerde posts Antwoorden Weergaven Activiteit
2
nov. 22
9959
2
jul. 17
8530
0
mrt. 25
1205
4
apr. 24
173862
1
feb. 24
26