-
Notifications
You must be signed in to change notification settings - Fork 23.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[FIX] hr_expense: set main attachment on hr.expense.sheet
#142029
Conversation
8a809b2
to
07fc04f
Compare
Hi @xmo-odoo, thanks for your review.
I've reworked completely the patch to follow your suggestion, I've had a bit of a hard time maintaining the sync between the attachments of the expenses and those on the sheet, so I decided to use the Let me know what you think. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's good to me. Y ou'll just have to ask a runbot exception to the upgrade team to make the CI happy I think. :)
d75e136
to
de9bf7c
Compare
Upgrade exception #277 added. Waiting the forward-port of this pr, the exception will be applied on all builds, and create an inconsistent state for migrations. If you need to apply any change before it reaches master, please notify runbot team. Details:
|
Hi @JulienVR, The Runbot's template exception has been granted, it just need the r+ :) |
I don't have r+ rights 😓, but @csnauwaert do (I'm only pre-reviewing PRs) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello, some comments as I'm passing by.
Also, as this is rather tricky, we should have some tests to cover this behavior.
de9bf7c
to
e5ff916
Compare
@JulienVR @csnauwaert I've updated the PR, to apply @seb-odoo and @ryv-odoo suggestions of moving the syncing of the attachments to the CRUD operations. I've also added a test that covers the use-cases that I could think of. I guess the previous approval is considered outdated, since the patch completely changed. Since I'm extending ir.attachment now to override the create and unlink, I guess I need to reping @odoo/rd-security (@xmo-odoo) but I think it's ok. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't really get why you're now full-sync-ing the sheet with the expenses, my understanding of the original was just that the sheet should get an (any) attachment from its expenses in order not to be attachmentless, but 🤷
068ef92
to
0defce2
Compare
In an expense sheet, when an expense line is clicked on, its receipts are shown in the attachment viewer. This was broken in /pull/142029 since it duplicates the attachments from the expense, leaving inconsistency between the attachment ID of the lines and the ones in the sheet. To fix this, the checksum is used instead to find which attachment in the sheet corresponds to the one in the line that was clicked on. task-3758922 Part-of: #155417
In /pull/138387, a new feature was added where clicking on an expense line in an expense sheet will highlight the receipts of that line in the attachment viewer if any. A JS test was included for this feature that mocked the fetching of the sheet's attachment. Since this changed in the backend in /pull/142029, the feature no longer worked but the test never broke since it was mocking the backend. This commit adds a tour to prevent that from happening again. closes #155417 Signed-off-by: Habib Ayob (ayh) <ayh@odoo.com>
In an expense sheet, when an expense line is clicked on, its receipts are shown in the attachment viewer. This was broken in odoo/pull/142029 since it duplicates the attachments from the expense, leaving inconsistency between the attachment ID of the lines and the ones in the sheet. To fix this, the checksum is used instead to find which attachment in the sheet corresponds to the one in the line that was clicked on. task-3758922 X-original-commit: 912b91c
In odoo/pull/138387, a new feature was added where clicking on an expense line in an expense sheet will highlight the receipts of that line in the attachment viewer if any. A JS test was included for this feature that mocked the fetching of the sheet's attachment. Since this changed in the backend in odoo/pull/142029, the feature no longer worked but the test never broke since it was mocking the backend. This commit adds a tour to prevent that from happening again. X-original-commit: 0624487
In an expense sheet, when an expense line is clicked on, its receipts are shown in the attachment viewer. This was broken in /pull/142029 since it duplicates the attachments from the expense, leaving inconsistency between the attachment ID of the lines and the ones in the sheet. To fix this, the checksum is used instead to find which attachment in the sheet corresponds to the one in the line that was clicked on. task-3758922 X-original-commit: 912b91c Part-of: #164640
In /pull/138387, a new feature was added where clicking on an expense line in an expense sheet will highlight the receipts of that line in the attachment viewer if any. A JS test was included for this feature that mocked the fetching of the sheet's attachment. Since this changed in the backend in /pull/142029, the feature no longer worked but the test never broke since it was mocking the backend. This commit adds a tour to prevent that from happening again. closes #164640 X-original-commit: 0624487 Signed-off-by: Habib Ayob (ayh) <ayh@odoo.com>
In an expense sheet, when an expense line is clicked on, its receipts are shown in the attachment viewer. This was broken in odoo/pull/142029 since it duplicates the attachments from the expense, leaving inconsistency between the attachment ID of the lines and the ones in the sheet. To fix this, the checksum is used instead to find which attachment in the sheet corresponds to the one in the line that was clicked on. task-3758922
In odoo/pull/138387, a new feature was added where clicking on an expense line in an expense sheet will highlight the receipts of that line in the attachment viewer if any. A JS test was included for this feature that mocked the fetching of the sheet's attachment. Since this changed in the backend in odoo/pull/142029, the feature no longer worked but the test never broke since it was mocking the backend. This commit adds a tour to prevent that from happening again. closes odoo#155417 Signed-off-by: Habib Ayob (ayh) <ayh@odoo.com>
In an expense sheet, when an expense line is clicked on, its receipts are shown in the attachment viewer. This was broken in /pull/142029 since it duplicates the attachments from the expense, leaving inconsistency between the attachment ID of the lines and the ones in the sheet. To fix this, the checksum is used instead to find which attachment in the sheet corresponds to the one in the line that was clicked on. task-3758922 Part-of: #164645
In /pull/138387, a new feature was added where clicking on an expense line in an expense sheet will highlight the receipts of that line in the attachment viewer if any. A JS test was included for this feature that mocked the fetching of the sheet's attachment. Since this changed in the backend in /pull/142029, the feature no longer worked but the test never broke since it was mocking the backend. This commit adds a tour to prevent that from happening again. closes #155417 closes #164645 Signed-off-by: Habib Ayob (ayh) <ayh@odoo.com> Signed-off-by: Ali Alfie (alal) <alal@odoo.com>
In an expense sheet, when an expense line is clicked on, its receipts are shown in the attachment viewer. This was broken in odoo/pull/142029 since it duplicates the attachments from the expense, leaving inconsistency between the attachment ID of the lines and the ones in the sheet. To fix this, the checksum is used instead to find which attachment in the sheet corresponds to the one in the line that was clicked on. task-3758922
In odoo/pull/138387, a new feature was added where clicking on an expense line in an expense sheet will highlight the receipts of that line in the attachment viewer if any. A JS test was included for this feature that mocked the fetching of the sheet's attachment. Since this changed in the backend in odoo/pull/142029, the feature no longer worked but the test never broke since it was mocking the backend. This commit adds a tour to prevent that from happening again. closes odoo#155417 Signed-off-by: Habib Ayob (ayh) <ayh@odoo.com>
In an expense sheet, when an expense line is clicked on, its receipts are shown in the attachment viewer. This was broken in /pull/142029 since it duplicates the attachments from the expense, leaving inconsistency between the attachment ID of the lines and the ones in the sheet. To fix this, the checksum is used instead to find which attachment in the sheet corresponds to the one in the line that was clicked on. task-3758922 Part-of: #165117
In /pull/138387, a new feature was added where clicking on an expense line in an expense sheet will highlight the receipts of that line in the attachment viewer if any. A JS test was included for this feature that mocked the fetching of the sheet's attachment. Since this changed in the backend in /pull/142029, the feature no longer worked but the test never broke since it was mocking the backend. This commit adds a tour to prevent that from happening again. closes #155417 closes #165117 Signed-off-by: Habib Ayob (ayh) <ayh@odoo.com>
In an expense sheet, when an expense line is clicked on, its receipts are shown in the attachment viewer. This was broken in odoo/pull/142029 since it duplicates the attachments from the expense, leaving inconsistency between the attachment ID of the lines and the ones in the sheet. To fix this, the checksum is used instead to find which attachment in the sheet corresponds to the one in the line that was clicked on. task-3758922 Part-of: odoo#165117
In odoo/pull/138387, a new feature was added where clicking on an expense line in an expense sheet will highlight the receipts of that line in the attachment viewer if any. A JS test was included for this feature that mocked the fetching of the sheet's attachment. Since this changed in the backend in odoo/pull/142029, the feature no longer worked but the test never broke since it was mocking the backend. This commit adds a tour to prevent that from happening again. closes odoo#155417 closes odoo#165117 Signed-off-by: Habib Ayob (ayh) <ayh@odoo.com>
Issue
Main attachments on expense sheets was never correctly set, leading to missing attachment previews in the hr.expense.sheet form view, and unnecessary RPC requests to
register_main_attachment
, because the attachment was never set.Steps to reproduce
Cause
There are 2 main issues:
hr.expense.sheet
hasmessage_main_attachment_id
, but it's never set.register_main_attachment
, we pass only the id of the attachment. Then in the backend, the related record is based on the model of the attachment, but the attachment is linked tohr.expense
, nothr.expense.sheet
. Therefor we re-write the same attachment on the record we read the attachment from. And then the frontend will continue to callregister_main_attachment
everytime it tries to find the attachments linked to the sheet, but it's never done.Fix
message_main_attachment_id
based on the spec "we take the first line that has an attachment and we set it on the sheet"hr.expense.sheet
now maintains a copies of the attachments linked to it's expenses, for proper ACL and functionality ofregister_main_attachment
.Affected versions
16.0 up to master = saas-17.1
Reference
task-3572440
I confirm I have signed the CLA and read the PR guidelines at www.odoo.com/submit-pr