[FIX] account, hr_expense: registering a payment for a multiple lines expense sheet
When registering a payment for an expense sheet with several expense lines, only the first line of the expense sheet was linked to the account move line of the payment. So the payment was considered as partially reconciled. Now when a payment is registered for an expense sheet with several expense lines, the user is redirected to the manual reconciliation widget to link the move line of the payment to all the expense lines. In this way, the payment will be considered as fully reconciled. DO NOT FORWARD-PORT! ONLY FOR v10 opw:772505
This commit is contained in:
@@ -214,6 +214,19 @@ class account_payment(models.Model):
|
||||
# FIXME: ondelete='restrict' not working (eg. cancel a bank statement reconciliation with a payment)
|
||||
move_line_ids = fields.One2many('account.move.line', 'payment_id', readonly=True, copy=False, ondelete='restrict')
|
||||
|
||||
def open_payment_matching_screen(self):
|
||||
# Open reconciliation view for customers/suppliers
|
||||
action_context = {'company_ids': [self.company_id.id], 'partner_ids': [self.partner_id.commercial_partner_id.id]}
|
||||
if self.partner_type == 'customer':
|
||||
action_context.update({'mode': 'customers'})
|
||||
elif self.partner_type == 'supplier':
|
||||
action_context.update({'mode': 'suppliers'})
|
||||
return {
|
||||
'type': 'ir.actions.client',
|
||||
'tag': 'manual_reconciliation_view',
|
||||
'context': action_context,
|
||||
}
|
||||
|
||||
@api.one
|
||||
@api.depends('invoice_ids', 'payment_type', 'partner_type', 'partner_id')
|
||||
def _compute_destination_account_id(self):
|
||||
|
||||
@@ -88,6 +88,10 @@ class HrExpenseRegisterPaymentWizard(models.TransientModel):
|
||||
for line in payment.move_line_ids + expense_sheet.account_move_id.line_ids:
|
||||
if line.account_id.internal_type == 'payable':
|
||||
account_move_lines_to_reconcile |= line
|
||||
account_move_lines_to_reconcile.reconcile()
|
||||
# DO NOT FORWARD-PORT! ONLY FOR v10
|
||||
if len(expense_sheet.expense_line_ids) > 1:
|
||||
return payment.open_payment_matching_screen()
|
||||
else:
|
||||
account_move_lines_to_reconcile.reconcile()
|
||||
|
||||
return {'type': 'ir.actions.act_window_close'}
|
||||
|
||||
Reference in New Issue
Block a user