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

Good Day, Gonna asked how to inherit the two models from different model. I want to inherit the field "min_date" from stock.picking and also the field "date_invoice" from account.invoice. But I can only inherit the min_date

from odoo import fields,models,api


class Picking(models.Model):
_inherit ='stock.picking'

force_date = fields.Datetime("Put Dates")
min_date = fields.Datetime('Please Change', related="force_date",store=True)


@api.multi
def write(self,vals):
record = super(Picking,self).write(vals)
print("Test the Edit Button")
print("Schedule " + self.min_date)
print("Next")
return record

class SaleOrder(models.Model):
_inherit = 'sale.order'

confirmation_date = field.DateTime('Change This')


I think this is not right............................

Please help me, any hint or documentation that I can study to, Thank in advance and what is related mean in the field? Does it update the record in the database? 

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

Thank u so much sires :) 

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

Check this out: Inheritance in Odoo

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

Hi,

If you want to inherit two models, you can use inherits

Class NewClassName(models.Model):

_inherits = {
'a.model': 'a_field_id',
'b.model': 'b_field_id'
}
Thanks.

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
3
thg 1 24
15391
5
thg 6 21
17655
1
thg 11 19
3549
4
thg 2 25
2074
1
thg 8 24
1878