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

I added 'A' attribute to sale.order model. I want the server to suggest a particular value for field A (value is computed in a function) based on partner_id value But I want it to be editable and I want no change to occur to already existing records as a result I cant use compute and inverse. what should I do?

thanks in advance.

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

done it like this:

class SaleOrderInherit(models.Model):
_inherit = 'sale.order'

A = fields.Char(string="A", required=True)
@api.onchange('partner_id')
def _set_A(self):
for r in self:
if not r.partner_id:
r.A = ''
else:
            // my case

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
1
thg 5 24
2683
0
thg 1 24
169
1
thg 8 21
2267
1
thg 9 24
1354
2
thg 4 24
4123