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

I am trying to edit the "default_code" field on the product.product model. I am attempting to make it so the field is no longer copied when duplicating a record. This is my XML record:


<record id="product.field_product_product_default_code" model="ir.model.fields">

      <field name="copy" eval="False"/>

</record>


When I import the module, I can an error. If I comment out this record, the rest of my module imports without an issue, so I believe this is causing the problem. Is it not possible to alter a base field in this manner?

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

@Michael Leff

That is not the way to do it since that info in ir.model.fields is not completelly merged into python class _fields attribute. You could do it like this

class product_product(model.Model):
     _inherit = 'product.product'
     
     default_code = fields.Char(copy=False)


Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
3
thg 5 25
2910
1
thg 4 25
2119
3
thg 9 24
15595
2
thg 2 24
3134
1
thg 7 23
3242