本文整理汇总了Python中openerp.osv.fields.float方法的典型用法代码示例。如果您正苦于以下问题:Python fields.float方法的具体用法?Python fields.float怎么用?Python fields.float使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类openerp.osv.fields
的用法示例。
在下文中一共展示了fields.float方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_stock_now_price
# 需要导入模块: from openerp.osv import fields [as 别名]
# 或者: from openerp.osv.fields import float [as 别名]
def get_stock_now_price(self, stock_code):
"""
?????????
:param stock_id: ??id
:return:
"""
code = self._code_to_symbol(stock_code)
data = urllib.urlopen("http://hq.sinajs.cn/list=" + code).read().decode('gb2312')
stockInfo = data.split(',')
currentPrice = string.atof(stockInfo[3])
return float(currentPrice)
示例2: get_yesterday_price
# 需要导入模块: from openerp.osv import fields [as 别名]
# 或者: from openerp.osv.fields import float [as 别名]
def get_yesterday_price(self, stock_code):
"""
??????????
:param stock_code:
:return:
"""
code = self._code_to_symbol(stock_code)
data = urllib.urlopen("http://hq.sinajs.cn/list=" + code).read().decode('gb2312')
stockInfo = data.split(',')
currentPrice = string.atof(stockInfo[2])
return float(currentPrice)
示例3: update_balance
# 需要导入模块: from openerp.osv import fields [as 别名]
# 或者: from openerp.osv.fields import float [as 别名]
def update_balance(self, cr, uid, context=None):
"""
??????
:param cr:
:param uid:
:param context:
:return:
"""
trader = Trader().trader
balance_list = trader.balance
balance_cr = self.pool.get("stock.balance")
# out(balance_list) # ??
for balance in balance_list:
ids = balance_cr.search(cr, uid, [('money_type', '=', balance['money_type'])], context=context)
if len(ids) < 1:
balance_cr.create(cr, uid, {
'asset_balance': float(balance['asset_balance']),
'current_balance': float(balance['current_balance']),
'enable_balance': float(balance['enable_balance']),
'market_value': float(balance['market_value']),
'money_type': balance['money_type'],
'pre_interest': float(balance['pre_interest'])
}, context=context)
cr.commit()
else:
# write_ids = balance_cr.search(cr, uid, [('money_type', '=', balance['money_type'])])
balance_cr.write(cr, uid, ids, {
'asset_balance': float(balance['asset_balance']),
'current_balance': float(balance['current_balance']),
'enable_balance': float(balance['enable_balance']),
'market_value': float(balance['market_value']),
'pre_interest': float(balance['pre_interest'])
}, context=context)
cr.commit()
示例4: update_position
# 需要导入模块: from openerp.osv import fields [as 别名]
# 或者: from openerp.osv.fields import float [as 别名]
def update_position(self, cr, uid, context=None):
"""
??????
"""
trader = Trader().trader
position_cr = self.pool.get("stock.position")
position_list = trader.position
for position in position_list:
ids = position_cr.search(cr, uid, [
('stock_id.code', '=', position['stock_code']),
('state', '=', 'active')
], context=context)
if len(ids) < 1:
stock = self.pool.get('stock.basics').get_stock_by_code(cr, uid, position['stock_code'])
if stock is not None:
position_cr.create(cr, uid, {
'stock_id': stock.id,
'stock_code': stock.code,
'position_str': position['position_str'],
'market_value': float(position['market_value']),
'last_price': float(position['last_price']),
'keep_cost_price': float(position['keep_cost_price']),
'income_balance': float(position['income_balance']),
'cost_price': float(position['cost_price']),
'enable_amount': int(position['enable_amount']),
'current_amount': int(position['current_amount']),
}, context=context)
cr.commit()
else:
position_cr.write(cr, uid, ids, {
'position_str': position['position_str'],
'market_value': float(position['market_value']),
'last_price': float(position['last_price']),
'keep_cost_price': float(position['keep_cost_price']),
'income_balance': float(position['income_balance']),
'cost_price': float(position['cost_price']),
'enable_amount': int(position['enable_amount']),
'current_amount': int(position['current_amount']),
}, context=context)
# ????????????
ids = position_cr.search(cr, uid, [('state', '=', 'active')], context=context)
pos_obj_list = position_cr.read(cr, uid, ids, ['stock_code', 'id'], context)
for pos_list in pos_obj_list:
b = True
for position in position_list:
if position['stock_code'] == pos_list['stock_code']:
b = False
if b:
self.pool.get('stock.position').write(cr, uid, pos_list['id'],
{'state': 'lose', 'lose_time': self.get_now_time()},
context=context)