from odoo import api, fields, models from datetime import timedelta class HrExpenseSheet(models.Model): _inherit = 'hr.expense.sheet' @api.depends('account_move_ids.payment_state', 'account_move_ids.amount_residual') def _compute_state(self): # Store original states to detect transition to 'done' original_states = {sheet.id: sheet.state for sheet in self} super()._compute_state() for sheet in self: if original_states.get(sheet.id) != 'done' and sheet.state == 'done': # Transitioned to 'Paid' today = fields.Date.today() for expense in sheet.expense_line_ids: if not expense.receipt_due_date: due_days = expense.product_id.receipt_due_days or 0 expense.receipt_due_date = today + timedelta(days=due_days)