diff --git a/addons/point_of_sale/models/account_move.py b/addons/point_of_sale/models/account_move.py index dba398b7966..5223a4738d7 100644 --- a/addons/point_of_sale/models/account_move.py +++ b/addons/point_of_sale/models/account_move.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # Part of Odoo. See LICENSE file for full copyright and licensing details. -from odoo import fields, models +from odoo import fields, models, api class AccountMove(models.Model): @@ -17,6 +17,12 @@ class AccountMove(models.Model): stock_moves += invoice.sudo().mapped('pos_order_ids.picking_ids.move_lines').filtered(lambda x: x.state == 'done' and x.location_id.usage == 'customer') return stock_moves + def _compute_amount(self): + super(AccountMove, self)._compute_amount() + pos_invoices = self.filtered(lambda i: i.type in ['out_invoice', 'out_refund'] and i.pos_order_ids) + for invoice in pos_invoices: + invoice.invoice_payment_state = 'paid' + class AccountMoveLine(models.Model): _inherit = 'account.move.line' diff --git a/addons/point_of_sale/models/pos_order.py b/addons/point_of_sale/models/pos_order.py index 166fee3f439..4ec1285dfa3 100644 --- a/addons/point_of_sale/models/pos_order.py +++ b/addons/point_of_sale/models/pos_order.py @@ -140,7 +140,6 @@ class PosOrder(models.Model): pos_order._create_order_picking() if pos_order.to_invoice and pos_order.state == 'paid': pos_order.action_pos_order_invoice() - pos_order.account_move.sudo().post() return pos_order.id @@ -404,6 +403,7 @@ class PosOrder(models.Model): message = _("This invoice has been created from the point of sale session: %s") % (order.id, order.name) new_move.message_post(body=message) order.write({'account_move': new_move.id, 'state': 'invoiced'}) + new_move.sudo().with_company(order.company_id).post() moves += new_move if not moves: diff --git a/addons/point_of_sale/tests/test_anglo_saxon.py b/addons/point_of_sale/tests/test_anglo_saxon.py index 2d22a9d5fef..d6cf96843ea 100644 --- a/addons/point_of_sale/tests/test_anglo_saxon.py +++ b/addons/point_of_sale/tests/test_anglo_saxon.py @@ -214,7 +214,6 @@ class TestAngloSaxonFlow(TestAngloSaxonCommon): # Create the customer invoice pos_order_pos0.action_pos_order_invoice() - pos_order_pos0.account_move.post() # validate the session current_session_id = self.pos_config.current_session_id