cr 与 _cr 之间的区别
Difference between cr vs _cr
这是 cr
与 _cr
和 uid
与 _uid
之间的区别,
它也显示为 self._cr
或 self._uid
.
它们本质上都是一样的,不同之处在于在odoo8中已经弃用了传递cr和uid,但是这些变量仍然可以供您使用,但是它们现在被认为是私有的内部属性 class 这就是为什么他们之前有 _
以这个为例
#old api
cursor = self._cr
#new api everything is contained in env (the environment)
self.env.cr
#api v7
def foo(self, cr, uid, ids, context=None):
#you can use cr here instead of self._cr because it is explicitly passed to the method
# api v8
def foo(self):
# you don't need to pass in cr, uid, ids and context
这是 cr
与 _cr
和 uid
与 _uid
之间的区别,
它也显示为 self._cr
或 self._uid
.
它们本质上都是一样的,不同之处在于在odoo8中已经弃用了传递cr和uid,但是这些变量仍然可以供您使用,但是它们现在被认为是私有的内部属性 class 这就是为什么他们之前有 _
以这个为例
#old api
cursor = self._cr
#new api everything is contained in env (the environment)
self.env.cr
#api v7
def foo(self, cr, uid, ids, context=None):
#you can use cr here instead of self._cr because it is explicitly passed to the method
# api v8
def foo(self):
# you don't need to pass in cr, uid, ids and context