[MERGE] 'Invite & Quick Create User' update. The server branch holds in res_users.create() the support of key in context, allowing to put xml_ids of user groups in the context of relational fields linking to res.users. The purpose of this modification is to quick-create users that will have the access rights related to the functional meaning of the field. For example creating an user in the 'Responsible' field of a task should add him in the group related to project management.
Example of use : <field name="user_id" string="Project Manager" context="{'default_groups_ref': ['base.group_user', 'project.group_project_manager']}"/> will add Employee (base.group_user) and Project Manager (project.group_project_manager) groups, as well as implied groups. res_users: - [add] added support of key in context of default_get. It contains a list of xml_ids of user groups; those groups, if found, are added to the newly created user, - [ref] refactored simplified (quick create) view that is now more like a contact card, with login and email required because of the login email that will be send to the user bzr revid: tde@openerp.com-20130318120905-1w9xpoyppnj62wlj
This commit is contained in:
commit
027c419181
|
@ -269,7 +269,8 @@
|
||||||
<page string="Sales & Purchases">
|
<page string="Sales & Purchases">
|
||||||
<group>
|
<group>
|
||||||
<group>
|
<group>
|
||||||
<field name="user_id"/>
|
<field name="user_id"
|
||||||
|
context="{'default_groups_ref': ['base.group_partner_manager']}"/>
|
||||||
<field name="company_id" groups="base.group_multi_company" widget="selection"/>
|
<field name="company_id" groups="base.group_multi_company" widget="selection"/>
|
||||||
</group>
|
</group>
|
||||||
<group>
|
<group>
|
||||||
|
|
|
@ -744,6 +744,7 @@ class users_view(osv.osv):
|
||||||
|
|
||||||
def create(self, cr, uid, values, context=None):
|
def create(self, cr, uid, values, context=None):
|
||||||
self._set_reified_groups(values)
|
self._set_reified_groups(values)
|
||||||
|
|
||||||
return super(users_view, self).create(cr, uid, values, context)
|
return super(users_view, self).create(cr, uid, values, context)
|
||||||
|
|
||||||
def write(self, cr, uid, ids, values, context=None):
|
def write(self, cr, uid, ids, values, context=None):
|
||||||
|
@ -782,6 +783,21 @@ class users_view(osv.osv):
|
||||||
fields1 = (fields + ['groups_id']) if group_fields else fields
|
fields1 = (fields + ['groups_id']) if group_fields else fields
|
||||||
values = super(users_view, self).default_get(cr, uid, fields1, context)
|
values = super(users_view, self).default_get(cr, uid, fields1, context)
|
||||||
self._get_reified_groups(group_fields, values)
|
self._get_reified_groups(group_fields, values)
|
||||||
|
|
||||||
|
# add "default_groups_ref" inside the context to set default value for group_id with xml values
|
||||||
|
if 'groups_id' in fields and isinstance(context.get("default_groups_ref"), list):
|
||||||
|
groups = []
|
||||||
|
ir_model_data = self.pool.get('ir.model.data')
|
||||||
|
for group_xml_id in context["default_groups_ref"]:
|
||||||
|
group_split = group_xml_id.split('.')
|
||||||
|
if len(group_split) != 2:
|
||||||
|
raise osv.except_osv(_('Invalid context value'), _('Invalid context default_groups_ref value (model.name_id) : "%s"') % group_xml_id)
|
||||||
|
try:
|
||||||
|
temp, group_id = ir_model_data.get_object_reference(cr, uid, group_split[0], group_split[1])
|
||||||
|
except ValueError:
|
||||||
|
group_id = False
|
||||||
|
groups += [group_id]
|
||||||
|
values['groups_id'] = groups
|
||||||
return values
|
return values
|
||||||
|
|
||||||
def read(self, cr, uid, ids, fields=None, context=None, load='_classic_read'):
|
def read(self, cr, uid, ids, fields=None, context=None, load='_classic_read'):
|
||||||
|
|
|
@ -84,46 +84,37 @@
|
||||||
</record>
|
</record>
|
||||||
<menuitem action="action_res_groups" id="menu_action_res_groups" parent="base.menu_users" groups="base.group_no_one"/>
|
<menuitem action="action_res_groups" id="menu_action_res_groups" parent="base.menu_users" groups="base.group_no_one"/>
|
||||||
|
|
||||||
|
|
||||||
<!-- res.users -->
|
<!-- res.users -->
|
||||||
<record id="view_users_simple_form" model="ir.ui.view">
|
<record id="view_users_simple_form" model="ir.ui.view">
|
||||||
<field name="name">res.users.simplified.form</field>
|
<field name="name">res.users.simplified.form</field>
|
||||||
<field name="model">res.users</field>
|
<field name="model">res.users</field>
|
||||||
<field name="priority">1</field>
|
<field name="priority">1</field>
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<form string="Contact" version="7.0">
|
<form string="Users" version="7.0">
|
||||||
<sheet>
|
<sheet>
|
||||||
<field name="image" widget='image' class="oe_left oe_avatar" options='{"preview_image": "image_medium", "size": [90, 90]}'/>
|
<field name="id" invisible="1"/>
|
||||||
|
<div class="oe_form_box_info oe_text_center" style="margin-bottom: 10px" attrs="{'invisible': [('id', '>', 0)]}">
|
||||||
|
You are creating a new user. After saving, the user will receive an invite email containing a link to set its password.
|
||||||
|
</div>
|
||||||
|
<field name="image" widget='image' class="oe_avatar oe_left" options='{"preview_image": "image_medium"}'/>
|
||||||
<div class="oe_title">
|
<div class="oe_title">
|
||||||
<div class="oe_edit_only">
|
<label for="name" class="oe_edit_only"/>
|
||||||
<label for="name"/>
|
<h1><field name="name"/></h1>
|
||||||
</div>
|
<label for="login" class="oe_edit_only"/>
|
||||||
<h1>
|
<h2><field name="login"/></h2>
|
||||||
<field name="name" default_focus="1" placeholder="Name" />
|
<label for="company_id" class="oe_edit_only" groups="base.group_multi_company"/>
|
||||||
</h1>
|
<field name="company_id" context="{'user_preference': 0}" groups="base.group_multi_company"/>
|
||||||
<field name="category_id" widget="many2many_tags" placeholder="Tags..."/>
|
|
||||||
</div>
|
</div>
|
||||||
<group>
|
<group>
|
||||||
<group>
|
<label for="groups_id" string="Access Rights"
|
||||||
<label for="street" string="Address"/>
|
attrs="{'invisible': [('id', '>', 0)]}"/>
|
||||||
<div>
|
<div attrs="{'invisible': [('id', '>', 0)]}">
|
||||||
<field name="street" placeholder="Street..."/>
|
<field name="groups_id" readonly="1" widget="many2many_tags" style="display: inline;"/> You will be able to define additional access rights by editing the newly created user under the Settings / Users menu.
|
||||||
<field name="street2"/>
|
|
||||||
<div class="address_format">
|
|
||||||
<field name="city" placeholder="City" style="width: 40%%"/>
|
|
||||||
<field name="state_id" class="oe_no_button" placeholder="State" style="width: 37%%" options='{"no_open": True}' on_change="onchange_state(state_id)"/>
|
|
||||||
<field name="zip" placeholder="ZIP" style="width: 20%%"/>
|
|
||||||
</div>
|
</div>
|
||||||
<field name="country_id" placeholder="Country" class="oe_no_button" options='{"no_open": True}'/>
|
|
||||||
</div>
|
|
||||||
<field name="website" widget="url" placeholder="e.g. www.openerp.com"/>
|
|
||||||
</group>
|
|
||||||
<group>
|
|
||||||
<field name="phone" placeholder="e.g. +32.81.81.37.00"/>
|
<field name="phone" placeholder="e.g. +32.81.81.37.00"/>
|
||||||
<field name="mobile"/>
|
<field name="mobile"/>
|
||||||
<field name="fax"/>
|
<field name="fax"/>
|
||||||
<field name="email" widget="email"/>
|
<field name="email" widget="email" required="True"/>
|
||||||
</group>
|
|
||||||
</group>
|
</group>
|
||||||
</sheet>
|
</sheet>
|
||||||
</form>
|
</form>
|
||||||
|
@ -134,8 +125,8 @@
|
||||||
<field name="model">res.users</field>
|
<field name="model">res.users</field>
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<form string="Users" version="7.0">
|
<form string="Users" version="7.0">
|
||||||
<field name="id" invisible="1"/>
|
|
||||||
<sheet>
|
<sheet>
|
||||||
|
<field name="id" invisible="1"/>
|
||||||
<div class="oe_right oe_button_box">
|
<div class="oe_right oe_button_box">
|
||||||
<button string="Change Password" type="action" name="%(change_password_wizard_action)d"
|
<button string="Change Password" type="action" name="%(change_password_wizard_action)d"
|
||||||
help="Change the user password."/>
|
help="Change the user password."/>
|
||||||
|
@ -146,17 +137,29 @@
|
||||||
<h1><field name="name"/></h1>
|
<h1><field name="name"/></h1>
|
||||||
<label for="login" class="oe_edit_only"/>
|
<label for="login" class="oe_edit_only"/>
|
||||||
<h2><field name="login"/></h2>
|
<h2><field name="login"/></h2>
|
||||||
|
<label for="company_id" class="oe_edit_only" groups="base.group_multi_company"/>
|
||||||
|
<field name="company_id" context="{'user_preference': 0}" groups="base.group_multi_company"/>
|
||||||
</div>
|
</div>
|
||||||
<group>
|
<notebook colspan="4">
|
||||||
<group>
|
<page string="Access Rights">
|
||||||
<field name="company_id" context="{'user_preference': 0}"/>
|
|
||||||
</group>
|
|
||||||
<group>
|
<group>
|
||||||
<field name="active"/>
|
<field name="active"/>
|
||||||
</group>
|
</group>
|
||||||
|
<group string="Allowed Companies" groups="base.group_multi_company">
|
||||||
|
<field name="company_ids" nolabel="1" widget="many2many_tags"/>
|
||||||
</group>
|
</group>
|
||||||
|
<group col="4">
|
||||||
<notebook colspan="4">
|
<field name="groups_id"/>
|
||||||
|
</group>
|
||||||
|
</page>
|
||||||
|
<page string="Contact">
|
||||||
|
<group>
|
||||||
|
<field name="phone" placeholder="e.g. +32.81.81.37.00"/>
|
||||||
|
<field name="mobile"/>
|
||||||
|
<field name="fax"/>
|
||||||
|
<field name="email" widget="email"/>
|
||||||
|
</group>
|
||||||
|
</page>
|
||||||
<page string="Preferences">
|
<page string="Preferences">
|
||||||
<group>
|
<group>
|
||||||
<group name="preferences">
|
<group name="preferences">
|
||||||
|
@ -168,24 +171,16 @@
|
||||||
<field domain="[('usage','=','menu')]" name="menu_id" required="True"/>
|
<field domain="[('usage','=','menu')]" name="menu_id" required="True"/>
|
||||||
</group>
|
</group>
|
||||||
</group>
|
</group>
|
||||||
<group>
|
<group string="Email preferences">
|
||||||
<field name="email" widget="email"/>
|
|
||||||
<field name="signature"/>
|
<field name="signature"/>
|
||||||
</group>
|
</group>
|
||||||
</page>
|
</page>
|
||||||
<page string="Access Rights">
|
|
||||||
<group string="Allowed Companies" groups="base.group_multi_company">
|
|
||||||
<field name="company_ids" nolabel="1" widget="many2many_tags"/>
|
|
||||||
</group>
|
|
||||||
<group col="4">
|
|
||||||
<field name="groups_id"/>
|
|
||||||
</group>
|
|
||||||
</page>
|
|
||||||
</notebook>
|
</notebook>
|
||||||
</sheet>
|
</sheet>
|
||||||
</form>
|
</form>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
<record id="view_users_tree" model="ir.ui.view">
|
<record id="view_users_tree" model="ir.ui.view">
|
||||||
<field name="name">res.users.tree</field>
|
<field name="name">res.users.tree</field>
|
||||||
<field name="model">res.users</field>
|
<field name="model">res.users</field>
|
||||||
|
|
Loading…
Reference in New Issue