我正在尝试覆盖product_template类类型选择字段的默认值。
原始字段:
class ProductTemplate(models.Model):
_name = "product.template"
_inherit = ['mail.thread']
_description = "Product Template"
_order = "name"
type = fields.Selection([
('consu', _('Consumable')),
('service', _('Service'))], string='Product Type', default='consu', required=True,
help='A stockable product is a product for which you manage stock. The "Inventory" app has to be installed.\n'
'A consumable product, on the other hand, is a product for which stock is not managed.\n'
'A service is a non-material product you provide.\n'
'A digital content is a non-material product you sell online. The files attached to the products are the one that are sold on '
'the e-commerce such as e-books, music, pictures,... The "Digital Product" module has to be installed.')
class ProductTemplate(models.Model):
_inherit = 'product.template'
type = fields.Selection(selection_add=[('product', 'Stockable Product')])
我覆盖的类型字段。
class product_template(models.Model):
_inherit = "product.template"
type = fields.Selection(default='product')
这是正确的方法还是应该以其他方式覆盖它?