我需要帮助在购买模块中设置purchase_ok
类product_template
字段的默认值
感谢
答案 0 :(得分:0)
您可以像这样设置默认属性:
class ProductTemplate(models.Model):
_inherit = 'product.template'
purchase_ok = fields.Boolean(
string='Selectable on purchase operations',
default=True,
)
或者你可以使用这样的lambda函数:
class ProductTemplate(models.Model):
_inherit = 'product.template'
purchase_ok = fields.Boolean(
string='Selectable on purchase operations',
default=lambda self: self._get_default_purchase_ok(),
)
@api.model
def _get_default_purchase_ok(self):
value = True
# some operations
return value