Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
2 ตอบกลับ
9745 มุมมอง

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




อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

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

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

Nice Clean Answer

อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
How to find the field type? แก้ไขแล้ว
1
มิ.ย. 25
5111
3
ก.ค. 20
11757
4
ต.ค. 24
5301
0
พ.ย. 16
4123
1
ส.ค. 15
4687