<?xml version="1.0" ?>
<domain-models xmlns="http://axelor.com/xml/ns/domain-models"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://axelor.com/xml/ns/domain-models http://axelor.com/xml/ns/domain-models/domain-models_4.2.xsd">

  <module name="auth" package="com.axelor.auth.db"/>

  <entity name="User" cachable="true">
    <![CDATA[
    This object store the users.
    ]]>
    
    <string name="code" required="true" unique="true" min="2" title="Login"/>
    <string name="name" required="true" unique="true" min="2"/>
    <string name="password" password="true" required="true" min="4"/>

    <binary name="image" title="Photo" help="Max size 4MB." image="true"/>
    <string name="email" unique="true"/>
    <string name="language" selection="select.language"/>
    <string name="homeAction"/>
    <string name="theme" />
    <boolean name="singleTab" help="Whether to use tabbed ui."/>
    <boolean name="noHelp" help="Whether to show help messages." />

    <boolean name="blocked" default="false" help="Specify whether to block the user for an indeterminate times."/>
    <date name="activateOn" help="Activate the user from the specified date."/>
    <date name="expiresOn" help="Disable the user from the specified date."/>

    <many-to-one name="group" ref="Group" column="group_id"/>
    <many-to-many name="roles" ref="Role"/>
    <many-to-many name="permissions" ref="Permission"/>
    <many-to-many name="metaPermissions" ref="com.axelor.meta.db.MetaPermission" title="Permissions (fields)"/>
    
    <finder-method name="findByGroup" using="Long:groupId" filter="self.group[].id = :groupId" cacheable="true" all="false"/>
    <finder-method name="findByGroup" using="String:groupCode" filter="self.group[].code = :groupCode" cacheable="true" all="false"/>
    <finder-method name="findByEmail" using="email" cacheable="true" />
  </entity>
  
</domain-models>
