odoo(二)

#! /usr/bin/env python2  
# encoding=utf-8
import sys
reload(sys) 
sys.setdefaultencoding('utf8')
import os
ScriptPath = os.path.split( os.path.realpath( sys.argv[0] ) )[0]
import ConfigParser
import datetime
import get_base_config

threeday=(datetime.datetime.today()-datetime.timedelta(days=3)).strftime('%Y-%m-%d')
def auto_good():
     try:
        config = get_base_config.get_odoo_config()
        contract_ids = config['models'].execute_kw(config['db'], config['uid'], config['pwd'],
            'tw.main.work.order', 'search',
            [
                [
                    ['plan_state','=','order'],
                    ['order_state','in',['doing',False]],
                    ['end_time','<',threeday]
                ]
            ])
        print 'contract_ids:',contract_ids
        score = {"score":"5"}
        result = config['models'].execute_kw(config['db'], config['uid'], config['pwd'],
            'tw.main.work.order','order_praise',
            [
                contract_ids,score
            ])

        print result
    except Exception as e:

        print(e)

def main():
    try:
        print "------------------“
        auto_good()
        print "------------------"
    except Exception as e:
        print(e)

if __name__ == "__main__":
    main()

筛选出ids去模块中利用方法改变值

猜你喜欢

转载自www.cnblogs.com/languid/p/12010696.html