Skip to content

[IMP] sale_timesheet_invoice_link: link pending timesheets from invoice form - #946

Open
EmilioPascual wants to merge 1 commit into
OCA:19.0from
moduon:19.0-imp-link-inv2ts
Open

[IMP] sale_timesheet_invoice_link: link pending timesheets from invoice form#946
EmilioPascual wants to merge 1 commit into
OCA:19.0from
moduon:19.0-imp-link-inv2ts

Conversation

@EmilioPascual

Copy link
Copy Markdown
Contributor

After invoicing a sale order with fixed price, milestone, or manual billing policies, timesheets are never linked to the invoice automatically. This adds a warning alert on the invoice form that detects unlinked timesheets and offers "Link All", "Select Manually", or "Dismiss" actions.

@chienandalu @rafaelbn @Gelojr please review it. Thank you.

MT-14588 @moduon

@EmilioPascual
EmilioPascual force-pushed the 19.0-imp-link-inv2ts branch from 1bb08d0 to e748db1 Compare July 27, 2026 06:24
@OCA-git-bot OCA-git-bot added series:19.0 mod:sale_timesheet_invoice_link Module sale_timesheet_invoice_link labels Jul 27, 2026

@fcvalgar fcvalgar left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the work on this improvement @EmilioPascual.

I reviewed the module and found one scenario that I would like to clarify before approval: when an invoice is posted and then reset to draft, the warning to link pending timesheets is no longer displayed again, so it is not possible to link additional timesheets from the invoice form in that scenario.

The following tests were performed:
Test 1: OK - A fixed-price service invoice correctly shows the warning alert when there are timesheets linked to the related sale order line but not yet linked to the invoice.
Test 2: OK - The Link All action correctly links all pending timesheets to the invoice and the warning alert disappears.
Test 3: OK - The Select Manually action opens the filtered list of pending timesheets and allows linking only the selected timesheet entries.
Test 4: OK - The Dismiss action hides the warning alert without linking the pending timesheets to the invoice.
Test 5: OK - Once all pending timesheets are linked to the invoice, the warning alert is no longer displayed.
Test 6: OK - The standard timesheet-based invoicing flow is not affected, and no pending-timesheet warning is shown when Odoo links the timesheets automatically.
Test 7: Not OK / scope clarification - If a posted invoice is reset to draft, the pending-timesheet warning is not displayed again, preventing additional timesheets from being linked from the invoice form.
Test 8: OK - Multiple pending timesheets are correctly counted in the warning alert and can be linked together with Link All.

Could you please confirm whether the reset-to-draft / new pending timesheets scenario is intended to be covered by this module? If it is in scope, I think the dismissed state could be reset when an invoice is reset to draft, or when new pending timesheets are detected after the alert was previously dismissed/linked. If it is not in scope, could you please add this limitation to the README so that users know that additional timesheets created after the alert was dismissed or after the invoice was reset to draft may need to be linked manually outside the invoice alert flow?

…ce form

After invoicing a sale order with fixed price, milestone, or manual
billing policies, timesheets are never linked to the invoice automatically.
This adds a warning alert on the invoice form that detects unlinked
timesheets and offers "Link All", "Select Manually", or "Dismiss" actions.

- Add computed fields timesheet_pending_ids, timesheet_pending_count,
  timesheet_alert_dismissed to account.move
- Add warning alert on invoice form with Link All / Select Manually /
  Dismiss buttons
- Add "Link to Invoice" header button on timesheet list view
- Reuse _timesheet_domain_get_invoiced_lines for domain logic

Assisted-by: OpenCode + DeepSeek V4 Flash

MT-14588 @moduon
@EmilioPascual
EmilioPascual force-pushed the 19.0-imp-link-inv2ts branch from e748db1 to 1e17f6d Compare July 28, 2026 10:05
@EmilioPascual

Copy link
Copy Markdown
Contributor Author

Could you please confirm whether the reset-to-draft / new pending timesheets scenario is intended to be covered by this module? If it is in scope, I think the dismissed state could be reset when an invoice is reset to draft, or when new pending timesheets are detected after the alert was previously dismissed/linked. If it is not in scope, could you please add this limitation to the README so that users know that additional timesheets created after the alert was dismissed or after the invoice was reset to draft may need to be linked manually outside the invoice alert flow?

@fcvalgar I add new flow when invoice is reset to draft and there are timesheets pending yet. Could you review againt? Thank you

@fcvalgar fcvalgar left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work on this improvement @EmilioPascual and on addressing the reported scenario.

The following tests were performed:
Test 1: OK - A fixed-price service invoice correctly shows the warning alert when there are timesheets linked to the related sale order line but not yet linked to the invoice.
Test 2: OK - The Link All action correctly links all pending timesheets to the invoice and the warning alert disappears.
Test 3: OK - The Select Manually action opens the filtered list of pending timesheets and allows linking only the selected timesheet entries.
Test 4: OK - The Dismiss action hides the warning alert without linking the pending timesheets to the invoice.
Test 5: OK - Once all pending timesheets are linked to the invoice, the warning alert is no longer displayed.
Test 6: OK - The standard timesheet-based invoicing flow is not affected, and no pending-timesheet warning is shown when Odoo links the timesheets automatically.
Test 7: OK - When a posted invoice is reset to draft and pending timesheets still exist, the warning alert is displayed again and allows linking the remaining timesheets.
Test 8: OK - Multiple pending timesheets are correctly counted in the warning alert and can be linked together with Link All.

LGTM

Image

@chienandalu chienandalu left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code review 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants