简体   繁体   English

修改付款方式pos odoo 8

[英]Modify payment lines pos odoo 8

someone have any idea how i should modify the payment-lines in the POS,I want to add a type of credit card(like a many2one, I did it) but every time I add a line my option change to the first and also when the order is finished not save the value in pos.order -> statement_id. 有人对我应该如何修改POS中的支付线有任何想法,我想添加一种信用卡类型(例如many2one,我做到了),但是每次我添加一条线时,我的选项都会更改为第一个,以及何时订单完成后,不将值保存在pos.order-> statement_id中。 enter image description here 在此处输入图片说明

here is my code: 这是我的代码:

function POS_CashRegister (instance, local) {
var pos = instance.point_of_sale;
var _t = instance.web._t;
var QWeb = instance.web.qweb;
var round_pr = instance.web.round_precision
const ParentOrder = pos.Order;

pos.PosModel.prototype.models.push({ //loaded model
model:  'pos.credit.card',
    fields: ['id', 'name'],
    domain: [['pos_active','=',true]],
    loaded: function(self,credit_cards){ //pass parameters
        self.credit_cards = credit_cards;
    },
});

pos.PaymentScreenWidget = pos.PaymentScreenWidget.extend({
    validate_order: function(options) {
        var self = this;
        var currentOrder = self.pos.get('selectedOrder');
        var plines = currentOrder.get('paymentLines').models;
        for (var i = 0; i < plines.length; i++) {
            if(plines[i].cashregister.journal_id[1] === 'Tarjeta de Credito (PEN)')
            {
                var value = plines[i].node.firstElementChild.nextElementSibling.nextElementSibling.firstElementChild.value;
                plines[i].set_credit_card(parseInt(value));
                //console.log(plines[i].node.firstElementChild.nextElementSibling.nextElementSibling.firstElementChild.value);
                //plines[i].node
            }

        }
        console.log(currentOrder);
        self._super(options);
    },
    render_paymentline: function (line) {
        var self = this;

        if(line.cashregister.journal_id[1] !== 'Tarjeta de Credito (PEN)'){
            if (line.cashregister.currency[1] !== 'USD') {
                return this._super(line);
            } else {
                var el_html  = openerp.qweb.render('Paymentline', {widget: this, line: line});
                el_html  = _.str.trim(el_html);

                var el_node  = document.createElement('tbody');

                el_node.innerHTML = el_html;
                el_node = el_node.childNodes[0];
                el_node.line = line;
                el_node.querySelector('.paymentline-delete')
                    .addEventListener('click', this.line_delete_handler);

                el_node.addEventListener('click', this.line_click_handler);
                var sourceInput = el_node.querySelector('.source-input');
                var convertedInput = el_node.querySelector('.converted-input');
                sourceInput.addEventListener('keyup', function (event) {
                    el_node.line.set_usd_amount(event.target.value);
                    convertedInput.value = el_node.line.get_amount_str();
                });
                line.node = el_node;
                return el_node;
            }
        }else {
            return this._super(line);
        }
    },
});

pos.Paymentline = pos.Paymentline.extend({
    initialize: function(attributes, options) {
        this.amount = 0;
        this.cashregister = options.cashregister;
        this.name = this.cashregister.journal_id[1];
        this.selected = false;
        this.credit_card = false;
        this.pos = options.pos;
    },
    set_credit_card: function(value){
        this.credit_card = value;
        this.trigger('change:credit_card',this);
    },
    get_credit_card: function(){
        return this.credit_card;
    },
    export_as_JSON: function(){
        return {
            name: instance.web.datetime_to_str(new Date()),
            statement_id: this.cashregister.id,
            account_id: this.cashregister.account_id[0],
            journal_id: this.cashregister.journal_id[0],
            amount: this.get_amount(),
            credit_card_id: this.get_credit_card(),
        };
    },
});

} }

any suggestions? 有什么建议么?

You can create 2 journals here too. 您也可以在这里创建2种日记。 One for visa and another for master If you don't want that drop down there. 一个是签证,另一个是主人,如果您不想在那儿放。 Another way is you have to store selected option in a variable and then print that variable in front. 另一种方法是您必须将选定的选项存储在变量中,然后在前面打印该变量。

To store selected option initially assigned ids to each values of option and after then while validating order you can get that id of that field and from that id you can get your value. 要存储最初为选项的每个值分配的选定选项的ID,然后在验证订单时,您可以获取该字段的ID,然后从该ID中获取您的值。 By this way also you can do that. 通过这种方式,您也可以做到这一点。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM