跳至内容
菜单
此问题已终结
1 回复
3195 查看

I'm learning Rental Module for v7 and there is the function definition with "strange arguments" like these:

def _prepare_order_line_procurement(
            self, cr, uid, order, line, move_id, date_planned, context=None): ....

It's ok, but then the sentence

res = super(sale_order, self)._prepare_order_line_procurement(
            cr, uid, order, line, move_id, date_planned, context=context)

is coming.

Could anybody explain to me, if there is no setting value for these arguments - how can it work?

形象
丢弃
最佳答案

Hello Vladislav,

super(sale_order, self)._prepare_order_line_procurement(
            cr, uid, order, line, move_id, date_planned, context=context)

This statement is called special kind of overding in Inheritence concept.

 

Lets take a  simple example -

class Parent():
    def my_function(self,a,b):
        print 'Hi iam parent class'
       

class Child(Parent):
    def my_function(self,a,b):
        print 'Hi iam child class version 1'
        super(Child,self).my_function(a,b)
        print 'Hi iam child class version 2'


##create instance

obj=Child()
obj.my_function(1,2)

#output

'Hi iam child class version 1'
'Hi iam parent class'
'Hi iam child class version 2'

In your case you can find parent class function _prepare_order_line_procurement  in sale_stock module at line:292

Thanks

形象
丢弃
编写者

Thank you so much, shashank verma. I had the same idea but wasn't sure.