diff --git a/addons/point_of_sale/models/account_move.py b/addons/point_of_sale/models/account_move.py index bc8efd2e5a5..db3857dc095 100644 --- a/addons/point_of_sale/models/account_move.py +++ b/addons/point_of_sale/models/account_move.py @@ -9,6 +9,13 @@ class AccountMove(models.Model): pos_order_ids = fields.One2many('pos.order', 'account_move') + def _stock_account_get_last_step_stock_moves(self): + stock_moves = super(AccountMove, self)._stock_account_get_last_step_stock_moves() + for invoice in self.filtered(lambda x: x.type == 'out_invoice'): + stock_moves += invoice.mapped('pos_order_ids.picking_id.move_lines').filtered(lambda x: x.state == 'done' and x.location_dest_id.usage == 'customer') + for invoice in self.filtered(lambda x: x.type == 'out_refund'): + stock_moves += invoice.mapped('pos_order_ids.picking_id.move_lines').filtered(lambda x: x.state == 'done' and x.location_id.usage == 'customer') + return stock_moves class AccountMoveLine(models.Model): _inherit = 'account.move.line' diff --git a/addons/point_of_sale/tests/test_pos_stock_account.py b/addons/point_of_sale/tests/test_pos_stock_account.py index 6616d70d1f7..536ca850329 100644 --- a/addons/point_of_sale/tests/test_pos_stock_account.py +++ b/addons/point_of_sale/tests/test_pos_stock_account.py @@ -190,5 +190,9 @@ class TestPoSStock(TestPoSCommon): invoiced_output_account_lines = invoiced_order.account_move.line_ids.filtered(lambda line: line.account_id == self.output_account) self.assertAlmostEqual(sum(invoiced_output_account_lines.mapped('balance')), -121.0) + # The stock output account move lines of the invoiced order should be properly reconciled + for move_line in invoiced_order.account_move.line_ids.filtered(lambda line: line.account_id == self.output_account): + self.assertTrue(move_line.full_reconcile_id) + self.assertTrue(receivable_line_cash.full_reconcile_id, msg='Cash receivable line should be fully-reconciled.') self.assertTrue(output_line.full_reconcile_id, msg='The stock output account line should be fully-reconciled.')