第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

如何向 Odoo13 的 POS 訂單添加數(shù)據(jù)

如何向 Odoo13 的 POS 訂單添加數(shù)據(jù)

慕尼黑8549860 2022-06-16 10:30:53
我正在嘗試將數(shù)據(jù)添加到 POS 的訂單中,并將該數(shù)據(jù)發(fā)送到基于站點(diǎn)https://odoo-development.readthedocs.io/en/latest/dev/pos/load-data的“pos.order”模型-to-pos.html。為了使我的案例更通用,我正在創(chuàng)建一個(gè)名為“custom.model”的新 odoo 模型,我正在創(chuàng)建與“pos.config”的關(guān)系,以幫助我使用 javascritp 中的模型域,后者使用以下代碼:# -*- coding: utf-8 -*-from odoo import models, fieldsclass custom_model(models.Model):    _name = 'custom.model'    name = fields.Char(string='name')class myPosConfig(models.Model):    _inherit = 'pos.config'    custom_model_id = fields.Many2one('custom.model', string='My custom model')然后我使用以下 python 代碼添加我對(duì)“pos.order”模型感興趣的關(guān)系:# -*- coding: utf-8 -*-from odoo import models, fields, apiclass myPosOrder(models.Model):    _inherit = 'pos.order'    custom_model_id = fields.Many2one('custom.model', string='My model')然后我在前端添加我的自定義模型,其中包含一個(gè)帶有以下代碼的 javascript 文件:odoo.define('kyohei_pos_computerized_billing.billing_dosage', function (require) {    "use strict";    var models = require('point_of_sale.models');    var _super_order_model = models.Order.prototype;    models.load_models([{        model: 'custom.model',        label: 'custom_model',        fields: ['name'],        // Domain to recover the custom.model record related to my pos.config        domain: function(self){ return [['id', '=', self.config.custom_model_id[0]]];},        loaded: function(self, dosage){self.dosage = dosage[0]},    }]);});然后我將以下代碼添加到同一個(gè) javascript 文件中,因此記錄存儲(chǔ)在瀏覽器中,并在需要時(shí)將數(shù)據(jù)發(fā)送到后端:    models.Order = models.Order.extend({        initialize: function(){          _super_order_model.initialize.apply(this,arguments);          if (this.custom_model){              this.custom_model = this.pos.custom_model;          }        },        export_as_JSON: function () {            var data = _super_order_model.export_as_JSON.apply(this, arguments);            data.custom_model = this.custom_model;            return data        },        init_from_JSON: function (json) {            this.custom_model = json.custom_model;            _super_order_model.init_from_JSON.call(this. json);        },
查看完整描述

2 回答

?
慕絲7291255

TA貢獻(xiàn)1859條經(jīng)驗(yàn) 獲得超6個(gè)贊

由于方法上的參數(shù)不匹配導(dǎo)致此錯(cuò)誤,只需檢查 odoo-13 此方法 _process_order


在您的代碼中,您使用的是舊版本方法,并且從 odoo13 版本開(kāi)始,它已更改。


您必須更新此方法中的字段,其中數(shù)據(jù)來(lái)自export_as_JSON函數(shù)。


@api.model

def _order_fields(self, ui_order):

    pos_order = super(KyoheiComputerizedPosOrder, self)._order_fields(ui_order)

    # Get the data from ui_order  

    return pos_order


查看完整回答
反對(duì) 回復(fù) 2022-06-16
?
瀟瀟雨雨

TA貢獻(xiàn)1833條經(jīng)驗(yàn) 獲得超4個(gè)贊

終于讓代碼工作了。python 文件應(yīng)如下所示:


# -*- coding: utf-8 -*-


from odoo import models, fields, api



class MyPosOrder(models.Model):

    _inherit = 'pos.order'


    test_string = fields.Char(string='test_string')


    @api.model

    def _order_fields(self, ui_order):

        order_fields = super(MyPosOrder, self)._order_fields(ui_order)


        order_fields['test_string'] = ui_order.get('test_string')


        return order_fields

可以幫助理解這個(gè)問(wèn)題的文件是 pos_restaurant 的 pos_order.py


查看完整回答
反對(duì) 回復(fù) 2022-06-16
  • 2 回答
  • 0 關(guān)注
  • 107 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)