Skip to content

Commit

Permalink
[FIX] sale_timesheet: set is_so_line_edited when clearing so_line
Browse files Browse the repository at this point in the history
Versions:
---------
- 16.0+

Steps to reproduce:
-------------------
1. In Timesheets, add a new line;
2. link it to a Sale Order project;
3. make it non-billable by clearing the Sale Order Item field;
4. select related project in Project / Configuration / Projects;
5. in Invoicing tab, add yourself and a Sales Order Item, then save;
6. go back to Timesheets;
7. check the Sales Order Item field of the timesheet you created.

Issue:
------
Sales Order Item was changed automatically, this shouldn't happen after
a manual change.

Cause:
------
The `so_line_field` widget used the `this.changeOnEmpty` attribute to
check whether `is_so_line_edited` should be set, but this was removed in
1ecdbfc, hence the field will never be
set when clearing the `so_field` value.

Solution:
---------
On a field change, compare the previous ID of `so_line` with the new ID,
and set `is_so_line_edited` to `true` if they're different.

Related:
--------
odoo/enterprise#52544

opw-3547725

closes odoo#146062

X-original-commit: bc1ad08
Signed-off-by: Xavier Bol (xbo) <xbo@odoo.com>
Signed-off-by: Levi Siuzdak <sile@odoo.com>
  • Loading branch information
lvsz committed Dec 13, 2023
1 parent 8f6e89b commit 95f12b4
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ export class SoLineField extends Many2OneField {
const update = this.update;
this.update = (value, params = {}) => {
update(value, params);
if (value || this.updateOnEmpty) {
if ( // field is unset AND the old & new so_lines are different
!this.props.record.data.is_so_line_edited &&
this.props.value[0] != (value[0] && value[0].id)
) {
this.props.record.update({ is_so_line_edited: true });
}
};
Expand Down

0 comments on commit 95f12b4

Please sign in to comment.