0
生年月日フィールドを持つ人物モデルを作成する必要があります。私は生年月日から人の年齢を数えるロジックを入れていません。計算フィールドをモデル化する方法
ここで計算フィールド内で使用するためにpythonのdatetime
をインポートする必要がありますか? datetime
関数を呼び出そうとすると、Odooは私に未定義のエラーを与えます。
これは、これはここで
class Person(models.Model):
_name = 'earth.person'
first_name = fields.Char(string="First Name", required=True)
last_name = fields.Char(string="Last Name")
date_of_birth = fields.Date()
age = fields.Integer(compute='_compute_person_age')
@api.depends('date_of_birth')
def _compute_person_age(self):
for record in self:
record.age = 30