python 知识

def action_cancel_sale_order(self,cr,uid,ids,context=None):

self.message_post(cr, uid, ids, body=u"完结", context=context)

 def on_change_cust_order(self,cr,uid,ids,cust_order_no,context=None):

 def write(self, cr, uid, ids, vals, context=None):

def unlink(self, cr, uid, ids, context=None):

return super(sale_or_line, self).unlink(cr, uid, ids, context=context)


def unlink(self, cr, uid, ids, context=None):
        sale_origins = self.read(cr, uid, ids, ['state'], context=context)
        unlink_ids = []
        for s in sale_origins:
            if s['state'] in ['draft','cancel']:
                unlink_ids.append(s['id'])
            else:
                raise osv.except_osv((u'警告!'),(u'已确认订单不可删除'))

        return osv.osv.unlink(self, cr, uid, unlink_ids, context=context)


已经存在数据里 ids就存在


def create(self,cr,uid,vals,context=None):
 ids  无

res_model=self._name   获取当前页面模块名字
obj=self.pool.get('od.op.people')   
obj.adds_follower_ids(cr,uid,res_model,new_id)   调用当前页面模块中的方法



python 集合的添加有两种常用方法,分别是add和update。
集合add方法:是把要传入的元素做为一个整个添加到集合中,例如:
>>> a = set('boy')
>>> a.add('python')
>>> a
set(['y', 'python', 'b', 'o'])


集合update方法:是把要传入的元素拆分,做为个体传入到集合中,例如:
>>> a = set('boy')
>>> a.update('python')
>>> a
set(['b', 'h', 'o', 'n', 'p', 't', 'y'])


集合删除操作方法:remove
set(['y', 'python', 'b', 'o'])
>>> a.remove('python')
>>> a
set(['y', 'b', 'o'])


a&b  交集   a-b  相对补集     和   a|b合集

dir()函数操作方法很简单,只需要把你想要查询和对像添写到( )括号中就可以使用了。

你可以在( )中直接传入空列表对像[ ]或是一个列表数据类型的变量名,
>>>dir([ ])

x = ['a','b']
>>>dir(x)



例 4.21. split 不带参数

>>> s = "this   is a test"  1
>>> print s
this   is
a    test
>>> print s.split()           2
['this', 'is', 'a', 'test']
>>> print " ".join(s.split()) 3
'this is a test'

是一个多行字符串,通过使用转义字符的定义代替了 三重引号。 是一个回车, 是一个制表符。
不带参数的 split 按照空格进行分割。所以三个空格、一个回车和一个制表符都是一样的。
通过 split 分割字符串你可以将空格统一化;然后再以单个空格作为分隔符用 join 将其重新连接起来。这也就是 info 函数将多行 doc string 合并成单行所做的事情。

>>> from apihelper import info
>>> li = []
>>> info(li)
append     L.append(object) -- append object to end
count      L.count(value) -> integer -- return number of occurrences of value
extend     L.extend(list) -- extend list by appending list elements
index      L.index(value) -> integer -- return index of first occurrence of value
insert     L.insert(index, object) -- insert object before index
pop        L.pop([index]) -> item -- remove and return item at index (default last)
remove     L.remove(value) -- remove first occurrence of value
reverse    L.reverse() -- reverse *IN PLACE*
sort       L.sort([cmpfunc]) -- sort *IN PLACE*; if given, cmpfunc(x, y) -> -1, 0, 1

原文地址:https://www.cnblogs.com/1314520xh/p/7907932.html