Skip to Content
Meniu
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
Această întrebare a fost marcată
5 Răspunsuri
17641 Vizualizări

What should I do? Do i need to use inherits? 


If I will use inherits, how can I inherit the function and also the needed fields from each model from  the specific class, like this:


_name = 'newClassName'

_inherits = ['stock.picking', #1st model

'account.invoice'] #2nd model

min_date = fields.Datetime() #stock.picking field

date_invoice = fields.Date()#account.invoice  field


@api.multi

def _write(self,vals): #function from account.invoice

#codes...........

Imagine profil
Abandonează
Cel mai bun răspuns

Hi Marychan,

Try following code


class TestClass1(models.Model):
_name = 'test.class1'

name1 = fields.Char()

@api.multi
def my_new_fun(self):
print(self.name1)
# Your Main Class Method


class TestClass2(models.Model):
_name = 'test.class2'

name2 = fields.Char()


class TestClass3(models.Model):
_inherit = ['test.class1', 'test.class2']

@api.multi
def my_new_fun(self):
# You can Add your Functionality and also you can access name1 and name2 Variables here
print(self.name1, self.name2)
return super(TestClass3, self).my_new_fun()
Thanks.
Imagine profil
Abandonează
Related Posts Răspunsuri Vizualizări Activitate
1
nov. 19
3536
3
dec. 22
4418
4
sept. 19
4795
0
mar. 15
4239
1
aug. 23
3713