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

Hello,


I am trying to make my one2many field only show the counted number of records without the text "records" shown in the field. Like for example "1 record" to only be shown as "1". 

The XML code for the one2many field looks like this:






My one2many field reads the number of records perfectly, but i just want it to only show the number without the text. 

The one2many field has the technical name "x_studio_antal_paller", and is related to a many2one field called "x_studio_many2one_field_plimy".


Thank you in advance!

Ảnh đại diện
Huỷ bỏ

Your code is not visible can you update your question?

Câu trả lời hay nhất

You can't change the one2many field count text but you can count the records of a one2many field using a python method and put the result in a computed field by a custom module here is an example:

....
    records_count = fields.Integer(compute="_count_records")

    @api.depends("your_one2many_field")

    def _count_records(self):

       for rec in self:

           rec.records_count = len(rec.your_one2many_field)

.....



Happy to help :) an upvote will be awesome


Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
1
thg 4 25
1090
2
thg 10 22
21509
1
thg 6 22
6432
1
thg 4 24
6387
0
thg 10 23
1451