[MIG] V13 properties menu

This commit is contained in:
Pablo Quesada Barriuso
2020-08-05 17:20:52 +02:00
parent 7f485072f0
commit bd13457ee9
3 changed files with 14 additions and 14 deletions

View File

@@ -24,13 +24,13 @@ class IrHttp(models.AbstractModel):
}) })
# TODO: This user context update should be placed in other function ¿? # TODO: This user context update should be placed in other function ¿?
res['user_context'].update({'allowed_pms_property_ids': [(property.id) for property in user.pms_property_ids]}) res['user_context'].update({'allowed_pms_property_ids': [(property.id) for property in user.pms_property_ids]})
# update current_company based on current_pms_property # TODO: update current_company based on current_pms_property
if user.pms_property_id.company_id in user.company_ids: # if user.pms_property_id.company_id in user.company_ids:
user.company_id = user.pms_property_id.company_id # user.company_id = user.pms_property_id.company_id
res['company_id'] = user.pms_property_id.company_id.id # res['company_id'] = user.pms_property_id.company_id.id
else: # else:
raise MissingError( # raise MissingError(
_("Wrong property and company access settings for this user. " # _("Wrong property and company access settings for this user. "
"Please review property and company for user %s") % user.name) # "Please review property and company for user %s") % user.name)
return res return res

View File

@@ -18,10 +18,10 @@ odoo.define('web.SwitchPmsMenu', function(require) {
var SwitchPmsMenu = Widget.extend({ var SwitchPmsMenu = Widget.extend({
template: 'SwitchPmsMenu', template: 'SwitchPmsMenu',
events: { events: {
'click .dropdown-item[data-menu] div.log_into': '_onSwitchPmsPropertyClick', 'click .dropdown-item[data-menu] div.pms_log_into': '_onSwitchPmsPropertyClick',
'keydown .dropdown-item[data-menu] div.log_into': '_onSwitchPmsPropertyClick', 'keydown .dropdown-item[data-menu] div.pms_log_into': '_onSwitchPmsPropertyClick',
'click .dropdown-item[data-menu] div.toggle_pms_property': '_onTogglePmsPropertyClick', 'click .dropdown-item[data-menu] div.pms_toggle_property': '_onTogglePmsPropertyClick',
'keydown .dropdown-item[data-menu] div.toggle_pms_property': '_onTogglePmsPropertyClick', 'keydown .dropdown-item[data-menu] div.pms_toggle_property': '_onTogglePmsPropertyClick',
}, },
/** /**
* @override * @override

View File

@@ -12,7 +12,7 @@
<div class="dropdown-item d-flex py-0 px-0" data-menu="pms_property" t-att-data-pms_property-id="pms_property[0]"> <div class="dropdown-item d-flex py-0 px-0" data-menu="pms_property" t-att-data-pms_property-id="pms_property[0]">
<t t-set="is_allowed" t-value="widget.allowed_pms_property_ids.includes(pms_property[0])"/> <t t-set="is_allowed" t-value="widget.allowed_pms_property_ids.includes(pms_property[0])"/>
<t t-set="is_current" t-value="pms_property[0] === widget.current_pms_property"/> <t t-set="is_current" t-value="pms_property[0] === widget.current_pms_property"/>
<div role="menuitemcheckbox" t-att-aria-checked="is_allowed" t-att-aria-label="pms_property[1]" tabindex="0" class="ml-auto pl-3 pr-3 border border-top-0 border-left-0 border-bottom-0 toggle_company o_py"> <div role="menuitemcheckbox" t-att-aria-checked="is_allowed" t-att-aria-label="pms_property[1]" tabindex="0" class="ml-auto pl-3 pr-3 border border-top-0 border-left-0 border-bottom-0 pms_toggle_property o_py">
<span style="height: 2rem;"> <span style="height: 2rem;">
<t t-if="is_allowed"> <t t-if="is_allowed">
<i class="fa fa-fw fa-check-square pt-2"></i> <i class="fa fa-fw fa-check-square pt-2"></i>
@@ -22,7 +22,7 @@
</t> </t>
</span> </span>
</div> </div>
<div role="button" t-att-aria-pressed="is_current" aria-label="Switch to this property" tabindex="0" class="d-flex flex-grow-1 align-items-center py-0 log_into pl-3 o_py" t-att-style="is_current ? 'background-color: lightgrey;' : ''"> <div role="button" t-att-aria-pressed="is_current" aria-label="Switch to this property" tabindex="0" class="d-flex flex-grow-1 align-items-center py-0 pms_log_into pl-3 o_py" t-att-style="is_current ? 'background-color: lightgrey;' : ''">
<t t-if="is_allowed"> <t t-if="is_allowed">
<span class='mr-3 company_label'> <span class='mr-3 company_label'>
<t t-esc="pms_property[1]"/> <t t-esc="pms_property[1]"/>