From 029fa85831af71ecda26b51a4ee8f5a8c458bb2c Mon Sep 17 00:00:00 2001 From: roen-odoo Date: Tue, 18 Oct 2022 11:39:12 +0000 Subject: [PATCH] [FIX] point_of_sale: fix traceback in pos_order studio Current behavior: If you try to edit the form view of pos.order in studio, you get a traceback. Steps to reproduce: - Install point_of_sale - Go to PoS order - Click on studio - Click on the button to edit the form view - You get a traceback opw-3008565 closes odoo/odoo#103838 X-original-commit: b616cad62a66aaaf8bfc7c79dbafd87174b9a1f6 Signed-off-by: Trinh Jacky (trj) --- addons/point_of_sale/models/pos_order.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/addons/point_of_sale/models/pos_order.py b/addons/point_of_sale/models/pos_order.py index dca446cb498..61c903d36e8 100644 --- a/addons/point_of_sale/models/pos_order.py +++ b/addons/point_of_sale/models/pos_order.py @@ -366,6 +366,8 @@ class PosOrder(models.Model): @api.onchange('payment_ids', 'lines') def _onchange_amount_all(self): for order in self: + if not order.pricelist_id.currency_id: + raise UserError(_("You can't: create a pos order from the backend interface, or unset the pricelist, or create a pos.order in a python test with Form tool, or edit the form view in studio if no PoS order exist")) currency = order.pricelist_id.currency_id order.amount_paid = sum(payment.amount for payment in order.payment_ids) order.amount_return = sum(payment.amount < 0 and payment.amount or 0 for payment in order.payment_ids)