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

Hello, I have Odoo8.

Sorry if my question is very simple, but I can't find my mistake.

In a model (sale.order), I have a related field:

acopiado_restante = fields.Float(digits=(8,2), related='pricelist_version_id.monto_acopiado_restante', string="Monto acopiado restante")

The field points to a computed field on model product.pricelist.version.

In a method of sale.order class, I need to use the value of field 'acopiado_restante', specifically in this method:

def onchange_pricelist_id(self, cr, uid, ids, pricelist_id, order_lines, context=None): ...

I try to access to the field using self.acopiado_restante, but I get the error 'sale.order don't have field _ids'.

What is the mistake and how can access to the field? Thanks!

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

@deep, I want to use the value of 'acopiado.restante' field, still need the _ids value?

Tác giả

@Ramanan, actually I have inherited the model that I want to use. If I do self.pool.get what record of the model I fetch?

Câu trả lời hay nhất

you simply inherit model, which you want to use. then inside the method use self.env["your_model_name"] or self.pool.get, you inherit all fields which u want from that model.

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

I have a feeling, you are not aware of Onchange definition and its semantics, please learn those before proceeding

Onchange will work in both on saved and unsaved records...

In case of saved records you can use self to fetch data, in case of unsaved of records, self will not be available to be used since record is not saved, hence ids wont be there....

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
2
thg 12 22
14943
1
thg 11 21
5071
0
thg 1 21
2360
8
thg 5 20
7944
0
thg 12 23
2998