0

次のことを聞きたい

  1. 2 つのフィールドがありますが、フィールド A とフィールド B の内容が同じであってはなりません
  2. ここに私のコード:

    def _check_date(self,cr,uid,ids,context=None):
            sessions = self.browse(cr,uid,ids,context=context)
            check = True
    
            for session in sessions:
                check = check and (not session.depart_date < time.strftime('%Y-%m-%d'))
    
            return check
    
    def check_date_validation(self,depart_date):
    
                check = True
                check = check and (not depart_date< time.strftime('%Y-%m-%d'))
    
                return check
    
    _constraints = [(_check_date, 'Date cannot earlier than today',['depart_date'])]
    
    def check_constraints(self,cr,uid,id,depart_date,context=None):
            warning = {}
    
            if not self.check_date_validation(depart_date):
                title = _("Warning Title")
                message = _("Warning Message")
                warning = {
                        'title': title,
                        'message': message,
                }
                depart_date = time.strftime('%Y-%m-%d')
            else:
                depart_date = depart_date
            return {'value': {'depart_date': depart_date},'warning':warning}
    

その関数の平均日付は現在の日付よりも小さくてはいけませんが ..もう一度作りたいです。フィールド日付 A と B は同じであってはなりません。手伝って頂けますか。お願いします....

ありがとうございました

4

1 に答える 1

0

私が理解したのは、depart_date が現在の日付よりも大きく、現在の日付と等しくないことを望んでいるということです。

だから試してみてください

check = check and (not session.depart_date <= time.strftime('%Y-%m-%d'))

私が対処できなかった場合は、詳しく説明してください。また、dept_date が上記のステートメントの check の値よりも小さい場合は、アドバイスをお願いします。

于 2012-07-20T16:29:05.933 に答える