domain openerp how to compare 2 date fields in odoo -
i create method when change date received product , qty date of stock.move, declare  start_date = fields.datetime() in class 
def onchange_project(self, cr, uid,start_date):     """     onchange handler of start date.     """       pool_stockmove =self.pool.get('stock.move')     domain =[('date','>=',start_date)]       ids = pool_stockmove.search(cr, uid, domain)   it works fine method want compare "date of stock" between start_date date >= start_date , date <= start_date. want format date method on hr_timesheet
cr.execute('select id \                 hr_timesheet_sheet_sheet \                 (date_from <= %s , %s <= date_to) \                     , user_id=%s \                     , id <> %s',(sheet.date_to, sheet.date_from, new_user_id, sheet.id))             if cr.fetchall():                 return false   thanks
dates stored in string format. can compare using sql in hr example, suggest compare using orm, not raw sql. more convenient , recommended use it, because sql escapes security , other checks written in code (but maybe not case in code).
it's hard understand date want compare , why can't it.
i guess want this:
[('date', '>=', 'start_date'), ('date', '<=', 'start_date')]   domain defined list of tuples. such syntax means and used between tuples on default. can specify (but same thing):
['&', ('date', '>=', 'start_date'), ('date', '<=', 'start_date')]   it means same thing above line (if used '|', means or).
odoo damains use polish notation: https://en.wikipedia.org/wiki/polish_notation
and dates formating, can use python module datetime change formatting of date if need to.
Comments
Post a Comment