[FIX] sale_project : fix the SOL click on project update

Currently, when we click on SOL and having one record of stock.move
or timesheet then it was not going to display the form view of that
particular record and also not showing that single record on list view
too due to the invalid view_type passed in doActionButton.

So in this commit, if res_id exist then open the form view of particular
record.

PS: we can not pass the options inside the doActionButton so we can not
change the viewType from that method. second we have only action_id instead
of whole action data so we can not directly switch the views without rpc call.

task-2992368

closes odoo/odoo#109111

X-original-commit: 2cda1de1a924b7e81278f01ee0fd693be930a47f
Signed-off-by: Xavier Bol (xbo) <xbo@odoo.com>
This commit is contained in:
hiroh-odoo
2023-01-05 10:31:03 +01:00
committed by Prakash Prajapati
parent c02c3d5dc1
commit 01c8727ff4
2 changed files with 24 additions and 2 deletions
@@ -29,5 +29,27 @@ patch(ProjectRightSidePanel.prototype, '@sale_project/components/project_right_s
formatValue(value, unit) {
return unit === 'Hours' ? formatFloatTime(value) : formatFloat(value);
}
},
//---------------------------------------------------------------------
// Handlers
//---------------------------------------------------------------------
/**
* @private
* @param {Object} params
*/
async onSaleItemActionClick(params) {
if (params.resId && params.type !== 'object') {
const action = await this.actionService.loadAction(params.name, this.context);
this.actionService.doAction({
...action,
res_id: params.resId,
views: [[false, 'form']]
});
} else {
this.onProjectActionClick(params);
}
},
});
@@ -24,7 +24,7 @@
<t t-set="uom_name" t-value="sale_item.product_uom and sale_item.product_uom[1]"/>
<td>
<t t-set="sol_name" t-value="sale_item.display_name"/>
<a t-if="sale_item.action" class="o_rightpanel_button" href="#" t-on-click="() => this.onProjectActionClick(sale_item.action)">
<a t-if="sale_item.action" class="o_rightpanel_button" href="#" t-on-click="() => this.onSaleItemActionClick(sale_item.action)">
<t t-esc="sol_name"/>
</a>
<t t-else="" t-esc="sol_name"/>