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

How can I add a new parameter to the 'name' field in the product.template base 'product' modul?

I don't want to do it like this in my new module:

class ProductTemplate(models.Model):
    _inherit = 'product.template'

    name = fields.Char('Name', index=True, required=True, translate=True, track_visibility='onchange')

I want to add 1 more parameter to the field without writing all parameters again and without overriting the base fields.


Thanks




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

Hi,

You don't want to re write the field entirely. Suppose if we have a field like this in base module:

class ProductTemplate(models.Model):
_name = 'product.template'

name = fields.Char('Name', index=True, required=True, translate=True, track_visibility='onchange')

And in the custom module if we want to change the string of the field(you can do it in xml where the field is defined with string=""),  do it like this,

class ProductTemplate(models.Model):
_inherit = 'product.template'

name = fields.Char(string='New Name')

For more info: https://www.youtube.com/watch?v=ZrCN3L0oAKE


Thanks

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

Nice Clean Answer

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
1
thg 6 25
5085
3
thg 7 20
11727
4
thg 10 24
5278
0
thg 11 16
4096
1
thg 8 15
4630