[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 <pimodoo@users.noreply.github.com>
This commit is contained in:
@@ -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'
|
||||
|
||||
@@ -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.')
|
||||
|
||||
Reference in New Issue
Block a user