def __setup__(cls): super().__setup__() table = cls.__table__() cls._sql_constraints += [ ('number_iban_exclude', Exclude(table, (table.number_compact, Equal), where=table.type == 'iban'), 'bank.msg_number_iban_unique'), ('account_iban_exclude', Exclude(table, (table.account, Equal), where=table.type == 'iban'), 'bank.msg_account_iban_unique'), ] cls.__access__.add('account') cls._order.insert(0, ('account', 'ASC'))
def __setup__(cls): super(ModelExclude, cls).__setup__() t = cls.__table__() cls._sql_constraints = [ ('exclude', Exclude(t, (t.value, Equal), where=t.value > 0), "Value must be unique."), ]
def __setup__(cls): super(Category, cls).__setup__() t = cls.__table__() cls._sql_constraints = [ ('name_parent_exclude', Exclude(t, (t.name, Equal), (Coalesce(t.parent, -1), Equal)), 'party.msg_category_name_unique'), ] cls._order.insert(0, ('name', 'ASC'))
def __setup__(cls): super().__setup__() t = cls.__table__() cls._sql_constraints = [ ('country_code_unique', Exclude(t, (t.country_code, Equal), where=t.active == True), 'party.msg_address_subdivision_country_code_unique') ] cls._order.insert(0, ('country_code', 'ASC NULLS LAST'))
def __setup__(cls): super().__setup__() t = cls.__table__() cls._sql_constraints = [ ('name_unique', Exclude(t, (t.name, Equal), where=t.active == Literal(True)), 'web_shop.msg_shop_name_unique'), ]
def __setup__(cls): super(Category, cls).__setup__() t = cls.__table__() cls._sql_constraints = [ ('name_parent_exclude', Exclude(t, (t.name, Equal), (Coalesce(t.parent, -1), Equal)), 'The name of a party category must be unique by parent.'), ] cls._order.insert(0, ('name', 'ASC'))
def __setup__(cls): pool = Pool() Template = pool.get('product.template') if not hasattr(cls, '_no_template_field'): cls._no_template_field = set() cls._no_template_field.update(['products']) super(Product, cls).__setup__() cls.__access__.add('template') cls._order.insert(0, ('rec_name', 'ASC')) t = cls.__table__() cls._sql_constraints = [ ('code_exclude', Exclude(t, (t.code, Equal), where=(t.active == Literal(True)) & (t.code != '')), 'product.msg_product_code_unique'), ] for attr in dir(Template): tfield = getattr(Template, attr) if not isinstance(tfield, fields.Field): continue if attr in cls._no_template_field: continue field = getattr(cls, attr, None) if not field or isinstance(field, TemplateFunction): tfield = copy.deepcopy(tfield) if hasattr(tfield, 'field'): tfield.field = None invisible_state = ~Eval('template') if 'invisible' in tfield.states: tfield.states['invisible'] |= invisible_state else: tfield.states['invisible'] = invisible_state setattr(cls, attr, TemplateFunction(tfield)) order_method = getattr(cls, 'order_%s' % attr, None) if (not order_method and not isinstance( tfield, (fields.Function, fields.One2Many, fields.Many2Many))): order_method = TemplateFunction.order(attr) setattr(cls, 'order_%s' % attr, order_method) if isinstance(tfield, fields.One2Many): getattr(cls, attr).setter = '_set_template_function'
def __setup__(cls): super(User, cls).__setup__() table = cls.__table__() cls._sql_constraints += [ ('email_exclude', Exclude(table, (table.email, Equal), where=table.active == True), 'web_user.msg_user_email_unique'), ] cls._buttons.update({ 'validate_email': { 'readonly': Eval('email_valid', False), 'depends': ['email_valid'], }, 'reset_password': { 'readonly': ~Eval('email_valid', False), 'depends': ['email_valid'], }, })