Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
3 Trả lời
6081 Lượt xem

OpenERP Document

doc.openerp.com trunk server 03_module_dev_02

tells that:

To define a new object, you must define a new Python class then instantiate it. This class must inherit from the osv class in the osv module.

and gives a sample code:

class name_of_the_object( osv.osv ):
     _name = 'name.of.the.object'
     _columns = { ... }
    #...
name_of_the_object()  #instantiate here

However, in Product Variant Multi module, objects in product_variant.py like

product_variant_dimension_type

and

product_variant_dimension_option

do not have this kind of code to do instantiation.

class product_variant_dimension_type(orm.Model):
    _name = "product.variant.dimension.type"
    _description = "Dimension Type"
    _columns = {
        # fields...
    }
    # others...
# No instantiate code: "product_variant_dimension_type()" here

So when should we instantiate an object?

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

You don't need to instantiate objects since OpenERP V7. I struggled to find the commit, but eventually found where Odoo removed all instantiation of classes:

commit e69326ee3b32bf50805bf1aca73d941a3bbcd2fe
Author: Vo Minh Thu <vmt@openerp.com>
Date:   Mon Apr 15 12:23:49 2013 +0200
[REF] removed explicit model instanciations.
bzr revid: vmt@openerp.com-20130415102349-vgcrfok2k5y10cwz

I found this forum while searching, so even though it is a few years later, I hope this answers your question

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

orm.Model is more or less the same as osv.osv

Ảnh đại diện
Huỷ bỏ
Tác giả

I think it didn't answer my question above, but you're right that orm.Model is more or less the same as osv.osv.

Bài viết liên quan Trả lời Lượt xem Hoạt động
3
thg 3 15
6108
1
thg 9 19
18476
0
thg 3 15
5597
1
thg 3 15
9279
1
thg 3 15
5605