[FIX] point_of_sale: invoice correctly marked as paid
Current behavior: When the default intermediary account is the same as the default receivable account define on customers, and you make a payment with 2 differents payment methods the invoice is not marked as paid. Steps to reproduce: - Set the Default Intermediary Account to be the same as the default receivable account on customers. (You can get the default account by creating a new customer and go in the accounting section and look for "Account receivable") - Start a PoS session, select a customer - Add some product to the order and click on payment - Click on invoice - Pay with 2 differents payment methods (cash and bank) - Validate the order - The invoice is not marked as paid (Amount due > 0) opw-2972726 closes odoo/odoo#101106 X-original-commit: 439f7ee0ceae01eaba6a5a352e45531d5e9c9167 Signed-off-by: Joseph Caburnay (jcb) <jcb@odoo.com> Signed-off-by: Engels Robin (roen) <roen@odoo.com>
This commit is contained in:
@@ -852,7 +852,7 @@ class PosOrder(models.Model):
|
||||
# Reconcile the invoice to the created payment moves.
|
||||
# But not when the invoice's total amount is zero because it's already reconciled.
|
||||
if not invoice_receivable.reconciled and receivable_account.reconcile:
|
||||
payment_receivables = payment_moves.mapped('line_ids').filtered(lambda line: line.account_id == receivable_account)
|
||||
payment_receivables = payment_moves.mapped('line_ids').filtered(lambda line: line.account_id == receivable_account and line.partner_id)
|
||||
(invoice_receivable | payment_receivables).sudo().with_company(self.company_id).reconcile()
|
||||
return payment_moves
|
||||
|
||||
|
||||
@@ -1261,3 +1261,52 @@ class TestPointOfSaleFlow(TestPointOfSaleCommon):
|
||||
closing_entry_receivable_line = closing_entry.line_ids.filtered(lambda line: line.account_id == self.company_data['default_account_receivable']) # Because the payment method use the default receivable
|
||||
statement_receivable_line = statement.line_ids.filtered(lambda line: line.account_id == self.company_data['default_account_receivable'] and line.name == pos_order.session_id.name) # Because the payment method use the default receivable
|
||||
self.assertEqual(closing_entry_receivable_line.matching_number, statement_receivable_line.matching_number)
|
||||
|
||||
def test_order_pos_tax_same_as_company(self):
|
||||
"""Test that when the default_pos_receivable_account and the partner account_receivable are the same,
|
||||
payment are correctly reconciled and the invoice is correctly marked as paid.
|
||||
"""
|
||||
self.pos_config.open_ui()
|
||||
current_session = self.pos_config.current_session_id
|
||||
current_session.company_id.account_default_pos_receivable_account_id = self.partner1.property_account_receivable_id
|
||||
|
||||
product5_order = {'data':
|
||||
{'amount_paid': 750,
|
||||
'amount_tax': 0,
|
||||
'amount_return':0,
|
||||
'amount_total': 750,
|
||||
'creation_date': fields.Datetime.to_string(fields.Datetime.now()),
|
||||
'fiscal_position_id': False,
|
||||
'pricelist_id': self.pos_config.available_pricelist_ids[0].id,
|
||||
'lines': [[0, 0, {
|
||||
'discount': 0,
|
||||
'id': 42,
|
||||
'pack_lot_ids': [],
|
||||
'price_unit': 750.0,
|
||||
'product_id': self.product3.id,
|
||||
'price_subtotal': 750.0,
|
||||
'price_subtotal_incl': 750.0,
|
||||
'tax_ids': [[6, False, []]],
|
||||
'qty': 1,
|
||||
}]],
|
||||
'name': 'Order 12345-123-1234',
|
||||
'partner_id': self.partner1.id,
|
||||
'pos_session_id': current_session.id,
|
||||
'sequence_number': 2,
|
||||
'statement_ids': [[0, 0, {
|
||||
'amount': 450,
|
||||
'name': fields.Datetime.now(),
|
||||
'payment_method_id': self.cash_payment_method.id
|
||||
}], [0, 0, {
|
||||
'amount': 300,
|
||||
'name': fields.Datetime.now(),
|
||||
'payment_method_id': self.bank_payment_method.id
|
||||
}]],
|
||||
'uid': '12345-123-1234',
|
||||
'user_id': self.env.uid,
|
||||
'to_invoice': True, }
|
||||
}
|
||||
|
||||
pos_order_id = self.PosOrder.create_from_ui([product5_order])[0]['id']
|
||||
pos_order = self.PosOrder.search([('id', '=', pos_order_id)])
|
||||
self.assertEqual(pos_order.account_move.amount_residual, 0)
|
||||
|
||||
Reference in New Issue
Block a user