跳至内容
菜单
此问题已终结
1 回复
4352 查看

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, 

形象
丢弃
相关帖文 回复 查看 活动
2
8月 23
3220
1
12月 17
6768
1
4月 25
986
3
7月 24
2550
2
4月 24
1946