pos_usability: order pos.payment.method by sequence

This commit is contained in:
Alexis de Lattre
2023-10-19 11:12:09 +02:00
parent a7022e899f
commit 0781cb7ba7
4 changed files with 45 additions and 0 deletions

View File

@@ -34,6 +34,7 @@ Akretion:
"views/pos_order.xml",
"views/pos_config.xml",
"views/product.xml",
"views/pos_payment_method.xml",
],
"installable": True,
}

View File

@@ -8,5 +8,7 @@ from odoo import fields, models
class PosPaymentMethod(models.Model):
_inherit = 'pos.payment.method'
_check_company_auto = True
_order = 'sequence, id'
cash_journal_id = fields.Many2one(check_company=True)
sequence = fields.Integer(default=10)

View File

@@ -0,0 +1,22 @@
diff --git a/addons/point_of_sale/static/src/js/models.js b/addons/point_of_sale/static/src/js/models.js
index 86a7b44bcfb..06b46ba5645 100644
--- a/addons/point_of_sale/static/src/js/models.js
+++ b/addons/point_of_sale/static/src/js/models.js
@@ -514,16 +514,7 @@ exports.PosModel = Backbone.Model.extend({
fields: ['name', 'is_cash_count', 'use_payment_terminal'],
domain: function(self){return ['|',['active', '=', false], ['active', '=', true]]; },
loaded: function(self, payment_methods) {
- self.payment_methods = payment_methods.sort(function(a,b){
- // prefer cash payment_method to be first in the list
- if (a.is_cash_count && !b.is_cash_count) {
- return -1;
- } else if (!a.is_cash_count && b.is_cash_count) {
- return 1;
- } else {
- return a.id - b.id;
- }
- });
+ self.payment_methods = payment_methods;
self.payment_methods_by_id = {};
_.each(self.payment_methods, function(payment_method) {
self.payment_methods_by_id[payment_method.id] = payment_method;

View File

@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright 2023 Akretion France (http://www.akretion.com/)
@author: Alexis de Lattre <alexis.delattre@akretion.com>
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
-->
<odoo>
<record id="pos_payment_method_view_tree" model="ir.ui.view">
<field name="model">pos.payment.method</field>
<field name="inherit_id" ref="point_of_sale.pos_payment_method_view_tree"/>
<field name="arch" type="xml">
<field name="name" position="before">
<field name="sequence" widget="handle"/>
</field>
</field>
</record>
</odoo>