将字段从自定义模块导入Odoo(V9)POS模块

Import field from custom module into Odoo (V9) POS module

本文关键字:模块 V9 POS Odoo 导入 字段 自定义      更新时间:2023-09-26

我在Odoo中编写了一个自定义模块,现在我想将一些字段值从自定义模块导入POS小部件。

假设我有一个名为"折扣"的字段在一个模块"客户.折扣"。

如何将自定义模块中的字段值加载到POS的小部件中?这是我目前为止的.js代码。有指针吗?备注:这适用于新的Odoo API(V9)。

odoo.define('pos_product_available.PosModel', function(require){
"use strict";

    var models = require('point_of_sale.models');
    var _super_posmodel = models.PosModel.prototype;
    models.PosModel = models.PosModel.extend({
        initialize: function (session, attributes) {
            var partner_model = _.find(this.models, function(model){ return model.model === 'product.product'; });
            partner_model.fields.push('qty_available');
            var customer_model = _.find(this.models, function(model){return
                this.models.push({
                      model: 'customer.discount',
                      fields: ['discount_price','percentage'],
                })
            }),
            return _super_posmodel.initialize.call(this, session, attributes);
        },
    })
})
odoo.pos_custom = function(instance){
module = instance.point_of_sale;
function pos_customer_discount(instance,module){
    var models = module.PosModel.prototype.models;
    models.model.push({ 
        model:  'customer.discount',
        fields: ['discount_price','percentage'],
        loaded: function(self,customer_discount){self.customer_discount = customer_discount[0]; },
});
}