Skip to Content
Meniu
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
Această întrebare a fost marcată
1 Răspunde
4330 Vizualizări

Hello, 


By either using a computed field via studio or creating an automated action I am trying to display either a count of payment_tokens or a check box that will identify if any related child records has a credit cards on file? 

I am able to create a related field  that will display the count of payment tokens by contact, but I need to count all the related tokens based on the parent relationship. 

The ultimate goal is to let the sales rep know there is a credit card on file for any of the contacts related to the contact/ parent  that the sales order is created on.

I would appreciate any help on this as it seems possible from the front end developer tools 

Imagine profil
Abandonează
Cel mai bun răspuns

Hello Erich, 

You can do this by creating a new calculated field which checks changes on the partner_id.bank_ids. The specific code for counting the banks would be:

for record in self:
  total = len(record.partner_id.bank_ids)
  if record.partner_id.parent_id:
  total += len(record.partner_id.parent_id.bank_ids)
  record["x_bank_count"] = total

Set your dependencies as:

partner_id.bank_ids, partner_id.parent_id.bank_ids	

To create a new field you can go to Settings->Technical->Models search for "sale.order" add a new line on the model. 

If you wanted to change to a boolean, you would just check if the total is > 0. 

Then just inherit the form view and add to the sales order form using:

<?xml version="1.0"?>
<xpath expr="//field[@name='team_id']" position="after">
  <field name="x_bank_count"/>
</xpath>

If you need anything clarifying let me know,

Thanks, 

Imagine profil
Abandonează
Related Posts Răspunsuri Vizualizări Activitate
2
aug. 23
3198
1
dec. 17
6750
1
apr. 25
960
3
iul. 24
2517
2
apr. 24
1929