Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
1 Trả lời
3897 Lượt xem

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 

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

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, 

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
2
thg 8 23
2701
1
thg 12 17
6334
1
thg 4 25
488
3
thg 7 24
1963
2
thg 4 24
1504