Skip to content
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

[14.0][FIX] donation: fix access rights on partner form buttons #134

Merged
merged 3 commits into from
Mar 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion donation/models/donation.py
Original file line number Diff line number Diff line change
Expand Up @@ -582,7 +582,7 @@ def done2cancel(self):
)
% donation.tax_receipt_id.number
)
if donation.move_id:
if donation.sudo().move_id:
donation.move_id.sudo().button_cancel()
donation.with_context(force_delete=True).sudo().move_id.unlink()
donation.write({"state": "cancel"})
Expand Down
1 change: 1 addition & 0 deletions donation/views/donation.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
groups="donation.group_donation_user"
states="done"
invisible="context.get('recurring_view')"
confirm="Are you sure you want to cancel this donation?"
/>
<button
type="object"
Expand Down
4 changes: 4 additions & 0 deletions donation/views/res_partner.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,8 @@
</button>
</field>
</record>
<!-- Add donation viewer group to tax receipt partner view -->
<record id="donation_base.view_partner_property_form" model="ir.ui.view">
<field name="groups_id" eval="[(4, ref('donation.group_donation_viewer'))]" />
</record>
</odoo>
18 changes: 11 additions & 7 deletions donation_direct_debit/models/donation.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,16 +116,20 @@
return res

def done2cancel(self):
for donation in self:
for donation in self.sudo():
if donation.move_id:
donation_mv_line_ids = [line.id for line in donation.move_id.line_ids]
if donation_mv_line_ids:
plines = self.env["account.payment.line"].search(
[
("move_line_id", "in", donation_mv_line_ids),
("company_id", "=", donation.company_id.id),
("state", "in", ("draft", "open")),
]
plines = (

Check warning on line 123 in donation_direct_debit/models/donation.py

View check run for this annotation

Codecov / codecov/patch

donation_direct_debit/models/donation.py#L123

Added line #L123 was not covered by tests
self.env["account.payment.line"]
.sudo()
.search(
[
("move_line_id", "in", donation_mv_line_ids),
("company_id", "=", donation.company_id.id),
("state", "in", ("draft", "open")),
]
)
)
if plines:
raise UserError(
Expand Down