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

Hello !

I added a field in the sale order form and in the product template.

When, in the sale order form, I add an item, i want that the field I added in the form take the value of the field in the product template.

Do you know how can I do that ?

Sorry for my english.

Thanks.

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

You can inherit product onchange of sale order line form and and update value from product template in your new field. 

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

Hi,

Rather you use @api.onchange to update the sale order line field by any value you want

@api.onchange('field1', 'field2') # if these fields are changed, call method
def check_change(self):
    if self.field1 < self.field2:
        self.field3 = True # filed3 get True in the form view if field1 < field2

Or you can use related field. The field will be updated automatically by the ORM

field_x = fields.Char(related='product_id.field_x', store=True)

Best regards


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

Thanks for your answers.


I used a related field and it worked fine. But when I change the value of my field in order line, it also change the value in product template.


Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
0
thg 8 17
4591
1
thg 7 16
6475
1
thg 2 16
5107
0
thg 2 16
4843
0
thg 3 25
1420