Overslaan naar inhoud
Menu
Je moet geregistreerd zijn om te kunnen communiceren met de community.
Deze vraag is gerapporteerd
2 Antwoorden
9697 Weergaven

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




Avatar
Annuleer
Beste antwoord

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

Avatar
Annuleer
Beste antwoord

Nice Clean Answer

Avatar
Annuleer
Gerelateerde posts Antwoorden Weergaven Activiteit
1
jun. 25
5084
3
jul. 20
11725
4
okt. 24
5267
0
nov. 16
4087
1
aug. 15
4622