Skip to content
  • Categories
  • Tags
  • Popular
  • Users
  • Groups
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (Flatly)
  • No Skin
Collapse

Odoo 中文社区

  1. Home
  2. Categories
  3. Odoo 开发与实施交流
  4. ODOO14 批次列印QR碼

ODOO14 批次列印QR碼

Scheduled Pinned Locked Moved Odoo 开发与实施交流
7 Posts 3 Posters 3.4k Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    samchou
    wrote on last edited by
    #1

    現行完成報表列印QR碼
    是先轉成PDF再列印
    要一張一張展開PDF然後列印到印表機
    效率極差
    請問有甚麼辦法批次列印不透過轉成PDF直接丟去印表機列印嗎?

    D 1 Reply Last reply
    0
    • S samchou

      現行完成報表列印QR碼
      是先轉成PDF再列印
      要一張一張展開PDF然後列印到印表機
      效率極差
      請問有甚麼辦法批次列印不透過轉成PDF直接丟去印表機列印嗎?

      D Offline
      D Offline
      digitalsatori
      管理员
      wrote on last edited by
      #2

      @samchou 用下面这个addons就可以啊:

      https://github.com/OCA/report-print-send/tree/14.0/base_report_to_printer

      【上海先安科技】(tony AT openerp.cn)

      1 Reply Last reply
      0
      • S Offline
        S Offline
        samchou
        wrote on last edited by
        #3

        windows 下無法安裝pycups套件
        導致無法安裝base_report_to_printer套件

        S 1 Reply Last reply
        0
        • S samchou

          windows 下無法安裝pycups套件
          導致無法安裝base_report_to_printer套件

          S Offline
          S Offline
          samchou
          wrote on last edited by samchou
          #4

          已解決
          使用
          c1394da5-0411-41b6-b2d7-409732a4b8de-圖片.png

          1 Reply Last reply
          0
          • S Offline
            S Offline
            samchou
            wrote on last edited by samchou
            #5
            ### 連續產生QR碼並直接列印至印表機
            import win32print
            import win32ui
            import win32con
            import qrcode
            import odoorpc
            from PIL import Image,ImageWin
            
            db_ip = '192.168.122.X'
            db_name = 'test'
            user_name = ''
            user_password = ''
            
            # Prepare the connection to the server
            odoo = odoorpc.ODOO(db_ip, port=8069)
            # Login
            odoo.login(db_name,user_name,user_password)
            Wt = odoo.env['workticket.wt']
            wt_ids = Wt.search([('wt_status', '=', 'Y')])
            for wt in Wt.browse(wt_ids):
                if wt.wk_status == 'N' :
                    total_prt = wt.total_prt + 1
                    part_descp = wt.parts.part_descp
                    pack_qty = format(int(wt.pack_qty), '.3f')  ##顯示小數點下三位
                    NQRCode = wt.name+'_'+wt.style+'_'+part_descp+'_'+wt.color+'_'+wt.size+'_'+wt.materiel+'_'+str(pack_qty)+'_'+str(total_prt)
                    qr = qrcode.QRCode(
                        version=3,
                        error_correction=qrcode.constants.ERROR_CORRECT_L,
                        box_size=100,
                        border=4,
                    )
                    qr.make(fit=True)
                    qr.add_data(NQRCode)
                    img = qr.make_image(fill_color="black", back_color="white")
                    printer_name = win32print.GetDefaultPrinter ()
                    hDC = win32ui.CreateDC ()
                    hDC.CreatePrinterDC (printer_name)
                    hDC.StartDoc ('QR')
                    hDC.StartPage ()
                    dib = ImageWin.Dib (img)
                    # 第一行
                    x1 = 15
                    y1 = 5
                    x2 = 485
                    y2 = 50
                    # 圖片
                    x11 = 305
                    y11 = 50
                    x12 = 485
                    y12 = 230
                    font = win32ui.CreateFont({
                        "name": "Arial",
                        # "underline": True, 底線
                        "height": 42,
                        "weight": 42,
                    })
                    show = wt.style 
                    hDC.SelectObject(font)
                    hDC.DrawText (show,(x1,y1,x2,y2), win32con.DT_LEFT)
                    
                    dib.draw (hDC.GetHandleOutput (),(x11,y11,x12,y12))
            
                    hDC.EndPage ()
                    hDC.EndDoc ()
                    hDC.DeleteDC ()
            

            直接寫成一個PY檔能確實執行
            但是把同樣程式寫入odoo內
            列印卻出現空白

            1 Reply Last reply
            0
            • S Offline
              S Offline
              samchou
              wrote on last edited by
              #6

              已解決
              要在程式內設定紙張格式大小

              D 1 Reply Last reply
              0
              • S samchou

                已解決
                要在程式內設定紙張格式大小

                D Offline
                D Offline
                digitalsatori
                管理员
                wrote on last edited by
                #7

                @samchou 感谢你的信息更新

                【上海先安科技】(tony AT openerp.cn)

                1 Reply Last reply
                0

                Hello! It looks like you're interested in this conversation, but you don't have an account yet.

                Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

                With your input, this post could be even better 💗

                Register Login
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Tags
                • Popular
                • Users
                • Groups