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

I have inherited the res.partner form and python, and made some mods. When using the following two fields for calculating an age/birth year, they work perfectly in the main form view.

When I open the form view from an embedded kanban view, I get the error below. It's the same form! Can anyone help me get rid of the error please?


UncaughtPromiseError > TypeError

Uncaught Promise > value.toFixed is not a function


birth_year = fields.Integer(string='Birth Year')
age = fields.Integer(string='Age', compute='_compute_age', inverse='_inverse_compute_age')


@api.onchange('age')
def _inverse_compute_age(self):
for record in self:
if record.age:
age = record.age
today = date.today()
birthYear = today - relativedelta.relativedelta(years=age)
record.birth_year = birthYear.year

@api.onchange('birth_year')
def _compute_age(self):
for record in self:
if record.birth_year:
birthYear = record.birth_year
thisYear = date.today().year
age = thisYear - birthYear
record.age = age


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

I am having the same problem. Did you find a solution?

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
1
thg 12 24
4086
0
thg 11 24
1670
2
thg 7 24
3414
0
thg 4 24
2201
3
thg 3 24
2351