Skip to Content
Меню
Чтобы взаимодействовать с сообществом, необходимо зарегистрироваться.
Этот вопрос был отмечен
1 Ответить
3807 Представления

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 

Аватар
Отменить
Лучший ответ

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, 

Аватар
Отменить
Related Posts Ответы Просмотры Активность
2
авг. 23
2627
1
дек. 17
6281
1
апр. 25
402
3
июл. 24
1905
2
апр. 24
1414