2017-12-19 20 views
0

私のレコードは、特定の日付(フィールド内)より前にのみ変更できます。フィールドアクセスルールで日付フィールドと現在の日付を比較する方法[odoo 10]

私はレコードルールを使用することを考えましたが、アクセスルールで日付フィールドと現在の日付を比較することはできません。

これを達成するための比較や別の方法はありますか?

<record id="my_rule_date_foo" model="ir.rule"> 
<field name="name">foo bar</field> 
<field name="model_id" ref="model_my_foo"/> 
<field name="domain_force"> 
    [('many2one_field.the_limit_date','&ge;', 'what_to_put_here_?')] 
</field> 
<field name="groups" eval="[(4, ref('group_peff'))]"/> 
<field name="perm_read" eval="False"/> 
<field name="perm_write" eval="True"/> 
<field name="perm_create" eval="False"/> 
<field name="perm_unlink" eval="False"/> 

+0

@Jean Pernier – Naveen

答えて

0

あなたはdomain_forcecontext_today()またはdatetimeを使用することができるはずです。

# Should be the best choice, considers user timezone 
[('many2one_field.the_limit_date','&gt;=', context_today())] 

# If context_today() doesn't work for some reason, you can use datetime 
[('many2one_field.the_limit_date','&gt;=', datetime.date.today().strftime('%Y-%m-%d'))] 

はここでコアとrelevant gist for referenceからthe context_today methodです。

+0

に感謝するスクリーンショットがありがとう、ありがとう。 –

関連する問題