コンテンツへスキップ
Odoo メニュー
  • サインイン
  • 無料で15日試す
  • アプリ
    財務
    • 会計
    • 請求
    • 経費
    • スプレッドシート(BI)
    • ドキュメント管理
    • 署名
    販売
    • CRM
    • 販売
    • POS店舗
    • POSレストラン
    • サブスクリプション
    • レンタル
    ウェブサイト
    • ウェブサイトビルダー
    • eコマース
    • ブログ
    • フォーラム
    • ライブチャット
    • eラーニング
    サプライチェーン
    • 在庫
    • 製造
    • 製品ライフサイクル管理 (PLM)
    • 購買
    • 整備
    • 品質
    人事業務
    • 従業員管理
    • 採用
    • 休暇管理
    • 人事評価
    • リファラル
    • フリート
    マーケティング
    • ソーシャルマーケティング
    • メールマーケティング
    • SMSマーケティング
    • イベント
    • マーケティングオートメーション
    • アンケート調査
    サービス
    • プロジェクト管理
    • タイムシート
    • フィールドサービス
    • ヘルプデスク
    • 計画
    • アポイントメント
    生産性向上ツール
    • ディスカッション
    • 承認
    • IoT
    • VoIP
    • ナレッジ
    • WhatsApp
    サードパーティアプリ Odooスタジオ Odooクラウドプラットホーム
  • インダストリー(業種別ソリューション)
    小売
    • 書店
    • アパレルショップ
    • 家具専門店
    • 食料品店
    • 金物店
    • 玩具店
    飲食・ホスピタリティ業界
    • バー・パブ
    • レストラン
    • ファストフード
    • ゲストハウス
    • 飲料販売代理店
    • ホテル
    不動産
    • 不動産会社
    • 建築事務所
    • 建設
    • 不動産管理
    • 造園
    • 住宅所有者組合
    コンサルティング
    • 会計事務所
    • Odooパートナー
    • マーケティングエージェンシー
    • 法律事務所
    • 人材派遣
    • 監査・認証
    製造
    • テキスタイル
    • 金属
    • 家具
    • 飲食
    • 醸造所
    • コーポレートギフト
    ヘルス & フィットネス
    • スポーツクラブ
    • 眼鏡店
    • フィットネスセンター
    • ウェルネス専門家
    • 薬局
    • ヘアサロン
    業種
    • 便利屋
    • IT ハードウェア・サポート
    • 太陽エネルギーシステム
    • 靴メーカー
    • クリーニングサービス
    • 空調設備サービス
    その他
    • 非営利団体
    • 環境機関
    • ビルボードレンタル
    • 写真
    • 自転車リース
    • ソフトウェアリセラー
    すべての業種を見る
  • コミュニティ
    学ぶ
    • チュートリアル
    • ドキュメンテーション
    • 認定
    • トレーニング
    • ブログ
    • ポッドキャスト
    教育サポート
    • 教育プログラム
    • Scale Up! ビジネスゲーム
    • Odooオフィス訪問
    ソフトを入手
    • ダウンロード
    • エディションを比較
    • リリース
    コラボレーション
    • Github
    • フォーラム
    • イベント
    • 翻訳
    • パートナーになる
    • パートナー様向けサービス
    • 会計事務所を登録
    サービス利用
    • パートナー一覧
    • 会計事務所一覧
    • 今すぐ相談する
    • 導入支援サービス
    • お客様一覧
    • サポート
    • アップグレード
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    製品デモを利用する
  • 料金
  • ヘルプ

Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:

  • CRM
  • e-Commerce
  • 会計
  • 在庫
  • PoS
  • プロジェクト
  • MRP
All apps
コミュニティで交流するには登録する必要があります。
全てのポスト 人々 バッジ
タグ (全て表示)
odoo accounting v14 pos v15
このフォーラムについて
コミュニティで交流するには登録する必要があります。
全てのポスト 人々 バッジ
タグ (全て表示)
odoo accounting v14 pos v15
このフォーラムについて
ヘルプ

how i can override odoo POS point_of_sale.BarcodeReader?

購読

この投稿に活動があった際に通知を受け取ります

この質問にフラグが付けられました
posbarcodebarcodereader
2 返信
2814 ビュー
アバター
Mauro Donadel

Hi at all,

I need to override the function BarcordeReader ,cause i need to intercept what the barcode read and cancel the caracter "." if it exsist.

I tried to override the js original fuctionts for understand where i can modify the info ,and give me info about the barcode read, but this code give me error.

odoo.define('ro_pos_custom.BarcodeReader', function (require) {
"use strict";

var core = require('web.core');
const BarcodeReader = require('point_of_sale.BarcodeReader');
console.log("entro qui");
// this module interfaces with the barcode reader. It assumes the barcode reader
// is set-up to act like a keyboard. Use connect() and disconnect() to activate
// and deactivate the barcode reader. Use set_action_callbacks to tell it
// what to do when it reads a barcode.
const BarcodeReaderRo = (BarcodeReader) =>
class extends BarcodeReader{

set_barcode_parser: function (barcode_parser) {
this.barcode_parser = barcode_parser;
console.log("dato?",this.barcode_parser);
},

// when a barcode is scanned and parsed, the callback corresponding
// to its type is called with the parsed_barcode as a parameter.
// (parsed_barcode is the result of parse_barcode(barcode))
//
// callbacks is a Map of 'actions' : callback(parsed_barcode)
// that sets the callback for each action. if a callback for the
// specified action already exists, it is replaced.
//
// possible actions include :
// 'product' | 'cashier' | 'client' | 'discount'
set_action_callback: function (name, callback) {
console.log(name,callback);
if (this.action_callbacks[name]) {
this.action_callbacks[name].add(callback);
} else {
this.action_callbacks[name] = new Set([callback]);
}
},

remove_action_callback: function(name, callback) {
if (!callback) {
delete this.action_callbacks[name];
return;
}
const callbacks = this.action_callbacks[name];
if (callbacks) {
callbacks.delete(callback);
if (callbacks.size === 0) {
delete this.action_callbacks[name];
}
}
},

/**
* Allow setting of exclusive callbacks. If there are exclusive callbacks,
* these callbacks are called neglecting the regular callbacks. This is
* useful for rendered Components that wants to take exclusive access
* to the barcode reader.
*
* @param {String} name
* @param {Function} callback function that takes parsed barcode
*/
set_exclusive_callback: function (name, callback) {
if (this.exclusive_callbacks[name]) {
this.exclusive_callbacks[name].add(callback);
} else {
this.exclusive_callbacks[name] = new Set([callback]);
}
},

remove_exclusive_callback: function (name, callback) {
if (!callback) {
delete this.exclusive_callbacks[name];
return;
}
const callbacks = this.exclusive_callbacks[name];
if (callbacks) {
callbacks.delete(callback);
if (callbacks.size === 0) {
delete this.exclusive_callbacks[name];
}
}
},

scan: function (code) {
if (!code) return;

const callbacks = Object.keys(this.exclusive_callbacks).length
? this.exclusive_callbacks
: this.action_callbacks;

const parsed_result = this.barcode_parser.parse_barcode(code);
if (callbacks[parsed_result.type]) {
[...callbacks[parsed_result.type]].map((cb) => cb(parsed_result));
} else if (callbacks.error) {
[...callbacks.error].map((cb) => cb(parsed_result));
} else {
console.warn('Ignored Barcode Scan:', parsed_result);
}

},

// the barcode scanner will listen on the hw_proxy/scanner interface for
// scan events until disconnect_from_proxy is called
connect_to_proxy: function () {
var self = this;
this.remote_scanning = true;
if (this.remote_active >= 1) {
return;
}
this.remote_active = 1;

function waitforbarcode(){
return self.proxy.connection.rpc('/hw_proxy/scanner',{},{shadow: true, timeout:7500})
.then(function (barcode) {
console.log("codice?",barcode);
if (!self.remote_scanning) {
self.remote_active = 0;
return;
}
self.scan(barcode);
waitforbarcode();
},
function () {
if (!self.remote_scanning) {
self.remote_active = 0;
return;
}
waitforbarcode();
});
}
waitforbarcode();
},

// the barcode scanner will stop listening on the hw_proxy/scanner remote interface
disconnect_from_proxy: function () {
this.remote_scanning = false;
},
};

return BarcodeReader;

});

Thanks for help


0
アバター
破棄
アバター
Mauro Donadel
著作者 最善の回答

Thanks for the answer.


So i tried to put your js into a file and i had a little modify for debug info.Than the js have this name of file "barcode_reader_ro.js" and it's now this:


odoo.define('ro_pos_custom.CustomBarcodeReader', function (require) {

"use strict";


var BarcodeReader = require('point_of_sale.BarcodeReader');

    console.log("entro qui");


    const CustomBarcodeReader = BarcodeReader.extend({

        scan: function (code) {

            console.log("scan function",code);

            // Manipulate the barcode data before processing

            code = code.replace('.', ''); // Remove the character '.'


            // Call the original scan function

            this._super.apply(this, arguments);

        },

    });


    return CustomBarcodeReader;

});

After modify my pos_templates.xml for add the new js file:

 template id="pos_extend_assets" inherit_id="point_of_sale.assets">
xpath expr="." position="inside">
            link rel="stylesheet" href="/ro_pos_custom/static/src/css/product_discount.css"/>
            script type="text/javascript" src="/ro_pos_custom/static/src/js/pos_payment_button.js"/>
            script type="text/javascript" src="/ro_pos_custom/static/src/js/pos_print_custom.js"/>
            script type="text/javascript" src="/ro_pos_custom/static/src/js/pos_systray_button.js"/>
            script type="text/javascript" src="/ro_pos_custom/static/src/js/models.js"/>
            script type="text/javascript" src="/ro_pos_custom/static/src/js/pos_notes.js"/>
            script type="text/javascript" src="/ro_pos_custom/static/src/js/pos_sconto_righe.js"/>
            script type="text/javascript" src="/ro_pos_custom/static/src/js/prezzo_art.js"/>
            script type="text/javascript" src="/ro_pos_custom/static/src/js/pos_print_digi.js"/>
            script type="text/javascript" src="/ro_pos_custom/static/src/js/pos_crea_csv.js"/>
            script type="text/javascript" src="/ro_pos_custom/static/src/js/pos_arrotonda_subtotale.js"/>
            script type="text/javascript" src="/ro_pos_custom/static/src/js/barcode_reader_ro.js"/>
       /xpath>
    /template>       

So i added this pos_templates.xml into data list in my __manifest__.py :

'data': [
'security/ir.model.access.csv',
'views/pos_templates.xml',
'views/pos_roconfigure.xml',
'views/pos_maga_discount.xml',
'views/pos_digi.xml',
'wizards/wizard_confirm_refund.xml',
'wizards/wizard_confirm_refund_normal.xml',
'views/user_utenteQuadroCode.xml',
'views/pos_payment_to_show.xml',
],


.Then when i start the odoo POS, i see into chrome console the first console.log i'd added ("sono qui")  ,but when i tried to scan a product i not see the other console.log i'd added ...and i think all works but like not have the override..


I had wrong something?


Thanks for help


0
アバター
破棄
アバター
Zinfin Solutions Private Limited
最善の回答

Hello Mauro,

To achieve this, you can create a custom module that extends the existing BarcodeReader and overrides the scan function.

Here's an example of how you can achieve this:

odoo.define('your_module.CustomBarcodeReader', function (require) {
    "use strict";

    var BarcodeReader = require('point_of_sale.BarcodeReader');

    const CustomBarcodeReader = BarcodeReader.extend({
        scan: function (code) {
            // Manipulate the barcode data before processing
            code = code.replace('.', ''); // Remove the character '.'

            // Call the original scan function
            this._super.apply(this, arguments);
        },
    });

    return CustomBarcodeReader;
});

In this example, CustomBarcodeReader is created by extending the original BarcodeReader. The scan function is overridden to manipulate the barcode data (remove the '.' character in this case) before calling the original implementation using this._super.apply(this, arguments);.

Make sure to replace 'your_module' with the actual name of your custom module. Also, ensure that this module is loaded after the original point_of_sale.BarcodeReader module to override its behavior.

In your manifest file (__manifest__.py), make sure to include your custom module as a dependency


0
アバター
破棄
ディスカッションを楽しんでいますか?読むだけでなく、参加しましょう!

今すぐアカウントを作成して、限定機能を利用したり、素晴らしいコミュニティと交流しましょう!

登録
関連投稿 返信 ビュー 活動
Barcode Scanner works only partially with POS 解決済
barcodescanner pos barcode barcodereader
アバター
アバター
2
7月 15
10579
Barcode scanning on POS 解決済
pos barcode
アバター
アバター
アバター
2
10月 25
11449
Odoo V15 – Use of Price Barcodes and Barcode Aliases
pos barcode
アバター
0
6月 25
1657
Barcode not read in POS when adding to the cart
pos barcode
アバター
0
2月 25
1678
BARCODE Order sales POS
pos barcode
アバター
0
5月 24
2103
コミュニティ
  • チュートリアル
  • ドキュメンテーション
  • フォーラム
オープンソース
  • ダウンロード
  • Github
  • Runbot
  • 翻訳
サービス
  • Odoo.shホスティング
  • サポート
  • アップグレード
  • カスタム開発
  • 教育プログラム
  • 会計事務所一覧
  • パートナー一覧
  • パートナーになる
企業情報
  • 会社概要
  • ブランドアセット
  • お問い合わせ
  • 採用情報
  • イベント
  • ポッドキャスト
  • ブログ
  • お客様一覧
  • リーガル情報 • プライバシーポリシー
  • セキュリティ
الْعَرَبيّة Català 简体中文 繁體中文 (台灣) Čeština Dansk Nederlands English Suomi Français Deutsch हिंदी Bahasa Indonesia Italiano 日本語 한국어 (KR) Lietuvių kalba Język polski Português (BR) română русский язык Slovenský jazyk slovenščina Español (América Latina) Español ภาษาไทย Türkçe українська Tiếng Việt

Odoo(オドゥー)は、CRM、eコマース、会計、在庫管理、POS、プロジェクト管理など、企業のさまざまな業務を一つのシステムで管理できる、ベルギー発のオープンソースのERPソフトウェアです。

高機能で使いやすく、完全に統合されたERPとして、ユニークな価値を提供しています。

Website made with

Odoo Experience on YouTube

1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.

Live support on Youtube
Watch now