[FIX] account: analytic widget UX

On the analytic widget, when putting an Analytic Account, a floppy disk appear
on top of the wizard.
This button is used to create a new analytic distribution template. It is
confusing for users that thinks that the purpose of the button is to save the
analytic distribution.

This PR will replace the button to be a link called "New model".

Also, this pr will fill some field (partner_id, account_prefix and product_id)
if there are populated.

closes odoo/odoo#155611

Task: 3736786
X-original-commit: c44367a2f67f305052d28a3b9e313ad63ff46907
Signed-off-by: Habib Ayob (ayh) <ayh@odoo.com>
Signed-off-by: Maximilien La Barre (malb) <malb@odoo.com>
This commit is contained in:
Maximilien (malb)
2024-02-29 16:00:31 +00:00
parent c0166b9535
commit 8ff33b212d
2 changed files with 8 additions and 2 deletions
@@ -458,8 +458,12 @@ export class AnalyticDistribution extends Component {
onSaveNew() {
this.closeAnalyticEditor();
const { record, product_field, account_field } = this.props;
this.openTemplate({ resId: false, context: {
'default_analytic_distribution': this.dataToJson(),
'default_partner_id': record.data['partner_id'] ? record.data['partner_id'][0] : undefined,
'default_product_id': product_field ? record.data[product_field][0] : undefined,
'default_account_prefix': account_field ? record.data[account_field][1].substr(0, 3) : undefined,
}});
}
@@ -16,9 +16,11 @@
<div class="analytic_distribution_popup dropdown-menu o-dropdown--menu show rounded py-0 overflow-x-hidden" t-if="state.showDropdown" t-ref="analyticDropdown">
<div class="popover-header sticky-top">
<div class="d-flex">
<div class="h5 mt-2 me-auto">Analytic</div>
<div class="h5 mt-2 me-auto">
Analytic
<span t-if="allowSave" class="btn btn-link" t-on-click="onSaveNew" title="Save as new analytic distribution model">New Model</span>
</div>
<div class="popupButtons">
<span t-if="allowSave" class="btn o_button" t-on-click="onSaveNew" title="Save as new analytic distribution model"><i class="fa fa-save"/></span>
<span class="btn o_button" t-on-click.stop="() => this.closeAnalyticEditor()" title="Close"><span class="fa fa-close"/></span>
</div>
</div>