Skip to content

Commit

Permalink
[FIX] account: Analytical account tags should not appear
Browse files Browse the repository at this point in the history
Steps to reproduce the bug:
- Install account_asset
- Go to Accounting > Settings > Untick Analytic Tags
- Go to Accounting > Configuration > Asset Types
- Click on create

Bug:

The Analytic Tag field appeared even if the user was not in the group group_analytic_tags

opw:2119832

closes odoo#40648

Signed-off-by: Simon Goffin (sig) <sig@openerp.com>
  • Loading branch information
simongoffin committed Nov 25, 2019
1 parent 07ca1c7 commit c9e8ec5
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,12 @@ var LineRenderer = Widget.extend(FieldManagerMixin, {
};
self.fields.partner_id.appendTo(self.$('.accounting_view caption'));
});
session.user_has_group('analytic.group_analytic_tags').then(function(has_group) {
self.group_tags = has_group;
});
session.user_has_group('analytic.group_analytic_accounting').then(function(has_group) {
self.group_acc = has_group;
});
$('<span class="line_info_button fa fa-info-circle"/>')
.appendTo(this.$('thead .cell_info_popover'))
.attr("data-content", qweb.render('reconciliation.line.statement_line.details', {'state': this._initialState}));
Expand Down Expand Up @@ -602,7 +608,7 @@ var LineRenderer = Widget.extend(FieldManagerMixin, {
self.fields.date = new basic_fields.FieldDate(self,
'date', record, {mode: 'edit'});

var $create = $(qweb.render("reconciliation.line.create", {'state': state}));
var $create = $(qweb.render("reconciliation.line.create", {'state': state, 'group_tags': self.group_tags, 'group_acc': self.group_acc}));
self.fields.account_id.appendTo($create.find('.create_account_id .o_td_field'))
.then(addRequiredStyle.bind(self, self.fields.account_id));
self.fields.journal_id.appendTo($create.find('.create_journal_id .o_td_field'));
Expand Down
4 changes: 2 additions & 2 deletions addons/account/static/src/xml/account_reconciliation.xml
Original file line number Diff line number Diff line change
Expand Up @@ -186,11 +186,11 @@
<td class="o_td_label">Tax</td>
<td class="o_td_field"></td>
</tr>
<tr class="create_analytic_account_id" groups="analytic.group_analytic_accounting">
<tr class="create_analytic_account_id" t-if="group_acc">
<td class="o_td_label">Analytic Acc.</td>
<td class="o_td_field"></td>
</tr>
<tr class="create_analytic_tag_ids" groups="analytic.group_analytic_tags">
<tr class="create_analytic_tag_ids" t-if="group_tags">
<td class="o_td_label">Analytic Tags.</td>
<td class="o_td_field"></td>
</tr>
Expand Down
16 changes: 14 additions & 2 deletions addons/account/static/tests/reconciliation_tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -657,7 +657,13 @@ QUnit.module('account', {
position: "before",
symbol: "$"
}
}
},
user_has_group: function (group) {
if (group === 'analytic.group_analytic_tags' || group === 'analytic.group_analytic_accounting') {
return $.when(true);
}
return this._super.apply(this, arguments);
},
},
});
clientAction.appendTo($('#qunit-fixture'));
Expand Down Expand Up @@ -1834,7 +1840,13 @@ QUnit.module('account', {
position: "before",
symbol: "$"
}
}
},
user_has_group: function (group) {
if (group === 'analytic.group_analytic_tags' || group === 'analytic.group_analytic_accounting') {
return $.when(true);
}
return this._super.apply(this, arguments);
},
},
});

Expand Down
2 changes: 1 addition & 1 deletion addons/account/views/account_invoice_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@
<field name="currency_id" invisible="1"/>
</group>
<group>
<field name="analytic_tag_ids" groups="analytic.group_analytic_accounting" widget="many2many_tags" options="{'color_field': 'color'}"/>
<field name="analytic_tag_ids" groups="analytic.group_analytic_tags" widget="many2many_tags" options="{'color_field': 'color'}"/>
<field domain="[('company_id', '=', company_id)]" name="account_id" groups="account.group_account_user"/>
<field name="invoice_line_tax_ids" context="{'type': invoice_type}" domain="[('type_tax_use','!=','none'),('company_id', '=', company_id)]" widget="many2many_tags" options="{'no_create': True}"/>
<field domain="[('company_id', '=', company_id)]" name="account_analytic_id" groups="analytic.group_analytic_accounting"/>
Expand Down

0 comments on commit c9e8ec5

Please sign in to comment.