[FIX] l10n_es_pos,point_of_sale: ask for customer if split payment

Current behavior:
When in a spanish PoS, every order needs to be invoiced. If no customer
is specified, there is a default customer selected. But if the payment
method is split, the default customer should not be selected. And the
user should be asked for a customer.

Steps to reproduce:
- Install the l10n_es_pos module
- Go to PoS and create a new order
- Select a product and go to payment
- Select split payment (Customer Account)
- The default customer is selected, but you should be asked for a
  customer

Note:
To fix this we use the same behavior as in the base PoS, where the user
is asked for a customer if the payment method is split. If no user is
selected after being asked for a customer, the default customer is
selected. If a user is selected, the user is sent back to the payment
screen, as it's done in the base PoS.

opw-3736293

closes odoo/odoo#156570

Signed-off-by: Vlad Stroia (vlst) <vlst@odoo.com>
This commit is contained in:
roen-odoo
2024-03-07 15:12:17 +00:00
parent 8009250774
commit 7dcfefb700
4 changed files with 39 additions and 12 deletions
@@ -2,7 +2,7 @@
import { _t } from "@web/core/l10n/translation";
import {patch} from "@web/core/utils/patch";
import {ErrorPopup} from "@point_of_sale/app/errors/popups/error_popup";
import {PaymentScreen} from "@point_of_sale/app/screens/payment_screen/payment_screen";
import { PaymentScreen } from "@point_of_sale/app/screens/payment_screen/payment_screen";
patch(PaymentScreen.prototype, {
async validateOrder(isForceValidate) {
@@ -18,7 +18,10 @@ patch(PaymentScreen.prototype, {
}
if (order.is_l10n_es_simplified_invoice) {
order.to_invoice = Boolean(this.pos.config.l10n_es_simplified_invoice_journal_id)
order.partner = this.pos.db.partner_by_id[this.pos.config.simplified_partner_id[0]];
if (await this._askForCustomerIfRequired() === false) {
return false;
}
order.partner = order.partner || this.pos.db.partner_by_id[this.pos.config.simplified_partner_id[0]];
}
}
return await super.validateOrder(...arguments);
@@ -52,5 +52,16 @@ registry.category("web_tour.tours").add("spanish_pos_tour", {
...ProductScreen.addOrderline("Desk Pad", "1"),
...pay(),
...checkSimplifiedInvoiceNumber("0003"),
...ReceiptScreen.clickNextOrder(),
...ProductScreen.addOrderline("Desk Pad", "1"),
...ProductScreen.clickPayButton(),
...PaymentScreen.clickPaymentMethod("Customer Account"),
...PaymentScreen.clickValidate(),
{
content: "verify that the pos requires the selection of a partner",
trigger: `div.popup.popup-confirm .modal-header:contains('Customer Required')`,
},
],
});
@@ -13,6 +13,12 @@ class TestUi(TestPointOfSaleHttpCommon):
return cls.company_data["company"]
def test_spanish_pos(self):
split_payment_method = self.env['pos.payment.method'].create({
'name': 'Customer Account',
'split_transactions': True,
})
self.main_pos_config.payment_method_ids = [(4, split_payment_method.id)]
simp = self.env['account.journal'].create({
'name': 'Simplified Invoice Journal',
'type': 'sale',
@@ -407,17 +407,8 @@ export class PaymentScreen extends Component {
return "/point_of_sale/static/src/img/card-bank.png";
}
}
async _isOrderValid(isForceValidate) {
if (this.currentOrder.get_orderlines().length === 0 && this.currentOrder.is_to_invoice()) {
this.popup.add(ErrorPopup, {
title: _t("Empty Order"),
body: _t(
"There must be at least one product in your order before it can be validated and invoiced."
),
});
return false;
}
async _askForCustomerIfRequired() {
const splitPayments = this.paymentLines.filter(
(payment) => payment.payment_method.split_transactions
);
@@ -432,6 +423,22 @@ export class PaymentScreen extends Component {
}
return false;
}
}
async _isOrderValid(isForceValidate) {
if (this.currentOrder.get_orderlines().length === 0 && this.currentOrder.is_to_invoice()) {
this.popup.add(ErrorPopup, {
title: _t("Empty Order"),
body: _t(
"There must be at least one product in your order before it can be validated and invoiced."
),
});
return false;
}
if (await this._askForCustomerIfRequired() === false) {
return false;
}
if (
(this.currentOrder.is_to_invoice() || this.currentOrder.getShippingDate()) &&