나는어떻게 함수 내에서 함수를 호출하는? Odoo9 검증
class product_pricelist_item(models.Model):
_inherit = 'product.pricelist.item'
myfield = fields.Boolean(string="CheckMark")
product.pricelist.item
에서 부울 필드를 추가 한 지금 product.pricelist.item
에 여러 줄이 있습니다.
(확인) 나는 사용자가 한 번에 True
수 있습니다 True
다수에게 myfield
하나 하나 개의 필드를 만들 수 없습니다 것을 원한다.
product.pricelist.item
에서 카운터를주고 myfields
의 숫자 인 True
을 전달하여이 작업을 시도했습니다.
하지만이 오류는 저에게 주어집니다.
global name '_get_counter' is not defined
def _get_counter(self):
for r in self:
p=[]
p= r.env['product.pricelist.item'].search_read([('myfield', '=', True)], ['myfield'])
counter = len(p)
return counter
@api.constrains('myfield')
def _check_myfield(self):
counter = _get_counter(self)
for r in self:
if counter > 1:
raise exceptions.ValidationError("Multiple myfield In a PriceList of a Product is not allowed.")
이제 두 번째 질문은 : -
당신이 가격표 항목을 만든 다음이 데이터베이스의 데이터를 반영하지 않습니다 가격표에 저장을 클릭
. pricelist를 클릭하면 데이터가 반영되어 저장됩니다 ... 왜 이렇게됩니까?
오류 : -'_get_counter()는 정확히 1 인수 (주어진 2)' – maharshi
'counter = self._get_counter()'잘 작동합니다. – maharshi