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

I need to clean the categories attached to partners: some category links to keep, others to delete!

My only possibility is to create a server action as I am a Saas user for V11 CE

Thanks for any direction

Ảnh đại diện
Huỷ bỏ
Tác giả

V11 EE instead of CE

Tác giả Câu trả lời hay nhất

Thanks Niyas Raphy

I understand that your coding allows to

a) filter the contacts according to the search condition

    (but I don't know how to write the condition itself (search['name', 'ilike', 'biblio'] creates an error)

and b) replaces the field 'category_id' with ' ' )

This means that if 2 or more categories are attached to the contact, they will all be erased: Is this correct?

I need to erase only one known category, leaving the others if any.

How to achieve this? (I have hundreds of contacts to clean!

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

Hi,

You can create a scheduled action for it and run it manually using the run manually button, after the use case just remove it. Create a scheduled action which executes the Python code and inside the Python code you can make the partner categories to empty based on the condition in code.


See the sample below,



Code:

partner_rec = env['res.partner'].search([])
# you can filter the unncessary partners using the condition in search
for partner in partner_rec:
  partner.write({'field_name':
''})


Thanks

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
0
thg 2 19
3553
1
thg 3 19
4862
1
thg 3 15
4802
0
thg 8 17
3721
1
thg 10 23
3670