From 93c657914ca0529171cd3343e059f38340a2f8a9 Mon Sep 17 00:00:00 2001 From: Joseph Caburnay Date: Wed, 21 Aug 2019 10:31:32 +0000 Subject: [PATCH] [FIX] point_of_sale: reconcile invoice anglo-saxon lines Reconcile the stock output lines of the pos.order invoice for products with real-time valuation. This is to be more consistent with the sales module. closes odoo/odoo#38437 Task-id: 2048668 X-original-commit: 1eaea47c647cc3c3ed2d2b732992f64a411e2bd7 Signed-off-by: pimodoo --- addons/point_of_sale/models/account_move.py | 7 +++++++ addons/point_of_sale/tests/test_pos_stock_account.py | 4 ++++ 2 files changed, 11 insertions(+) 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.')