【问题标题】:odoo 14 get selected recored is tree view JSodoo 14 被选中记录是树视图 JS
【发布时间】:2021-07-26 13:50:47
【问题描述】:

我想从树形视图中获取所选记录的 ID

所做的是向视图添加一个按钮,单击该按钮时,我在我的 python 函数 test_func 中得到了 self.selectedRecords,但我没有得到

但我收到了['sale.order_33', 'sale.order_40', 'sale.order_48']

而不是['sale.order_19', 'sale.order_18', 'sale.order_2']


ListController.include({
        renderButtons: function($node) {
            this._super.apply(this, arguments);
            var self = this;
            if (this.$buttons) {
                $(this.$buttons).find('.oe_new_custom_button').on('click', function() {
                    rpc.query({
                        model: 'sale.order',
                        method: 'test_func',
                        args: [self.selectedRecords],
                    }).then(function(res){
                        console.log(self.selectedRecords);
                        console.log(res);
                    });
                });
            }
        },
    });

class test_func_report(models.Model):
    _inherit = 'sale.order'
        
    @api.model
    def test_func(self,selectedRecords):
        _logger.warning(self)
        _logger.warning(selectedRecords)

【问题讨论】:

    标签: javascript python odoo rpc


    【解决方案1】:

    使用getSelectedIds()方法获取当前选中的记录id。

    使用self.getSelectedIds() 而不是self.selectedRecords

    【讨论】:

    • 我要做的是创建excel文件| consumer[key] | Country | product | Inventory Units | Sales Units |是为了获取产品的销售记录谢谢你的帮助如果它很大我可以创建一个新问题
    • 你说is the a was to get the sales record for a product我没听懂。
    • 我在产品中创建了一个品牌模块,例如apple。要在表product 中添加第二个项目,我需要遍历域apple 的行如何在此销售期间始终获取库存中的剩余项目
    • 我需要创建一个新文件并保存它还是在odoo中记录
    • 您可以在产品记录上调用_product_available方法,它应该返回产品数量的字典{"qty_available": , "virtual_available": , "incoming_qty": , "outgoing_qty": ,}
    猜你喜欢
    • 1970-01-01
    • 2021-02-07
    • 1970-01-01
    • 2021-07-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-06-13
    相关资源
    最近更新 更多