feat: force synchronization of expense deductions before posting account payments
This commit is contained in:
parent
ce614c273d
commit
a91e13991e
@ -6,6 +6,17 @@ class AccountPayment(models.Model):
|
|||||||
|
|
||||||
realization_id = fields.Many2one('hr.expense.realization', string='Originating Realization', readonly=True)
|
realization_id = fields.Many2one('hr.expense.realization', string='Originating Realization', readonly=True)
|
||||||
|
|
||||||
|
def action_post(self):
|
||||||
|
"""
|
||||||
|
Force synchronization before posting to ensure deductions are included,
|
||||||
|
even if the payment was previously 'Reset to Draft' without edits.
|
||||||
|
"""
|
||||||
|
for payment in self:
|
||||||
|
if payment.state == 'draft' and payment.expense_sheet_id:
|
||||||
|
# Force sync by pretending amount changed to refresh the lines
|
||||||
|
payment._synchronize_to_moves({'amount', 'deduction_line_ids', 'amount_substract'})
|
||||||
|
return super().action_post()
|
||||||
|
|
||||||
def _synchronize_to_moves(self, changed_fields):
|
def _synchronize_to_moves(self, changed_fields):
|
||||||
"""
|
"""
|
||||||
Bypass standard Odoo restriction for payments linked to expense reports
|
Bypass standard Odoo restriction for payments linked to expense reports
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user