Skip to Content
Odoo Menu
  • Sign in
  • Try it free
  • Apps
    Finance
    • Accounting
    • Invoicing
    • Expenses
    • Spreadsheet (BI)
    • Documents
    • Sign
    Sales
    • CRM
    • Sales
    • POS Shop
    • POS Restaurant
    • Subscriptions
    • Rental
    Websites
    • Website Builder
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Supply Chain
    • Inventory
    • Manufacturing
    • PLM
    • Purchase
    • Maintenance
    • Quality
    Human Resources
    • Employees
    • Recruitment
    • Time Off
    • Appraisals
    • Referrals
    • Fleet
    Marketing
    • Social Marketing
    • Email Marketing
    • SMS Marketing
    • Events
    • Marketing Automation
    • Surveys
    Services
    • Project
    • Timesheets
    • Field Service
    • Helpdesk
    • Planning
    • Appointments
    Productivity
    • Discuss
    • Approvals
    • IoT
    • VoIP
    • Knowledge
    • WhatsApp
    Third party apps Odoo Studio Odoo Cloud Platform
  • Industries
    Retail
    • Book Store
    • Clothing Store
    • Furniture Store
    • Grocery Store
    • Hardware Store
    • Toy Store
    Food & Hospitality
    • Bar and Pub
    • Restaurant
    • Fast Food
    • Guest House
    • Beverage Distributor
    • Hotel
    Real Estate
    • Real Estate Agency
    • Architecture Firm
    • Construction
    • Estate Management
    • Gardening
    • Property Owner Association
    Consulting
    • Accounting Firm
    • Odoo Partner
    • Marketing Agency
    • Law firm
    • Talent Acquisition
    • Audit & Certification
    Manufacturing
    • Textile
    • Metal
    • Furnitures
    • Food
    • Brewery
    • Corporate Gifts
    Health & Fitness
    • Sports Club
    • Eyewear Store
    • Fitness Center
    • Wellness Practitioners
    • Pharmacy
    • Hair Salon
    Trades
    • Handyman
    • IT Hardware & Support
    • Solar Energy Systems
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    Others
    • Nonprofit Organization
    • Environmental Agency
    • Billboard Rental
    • Photography
    • Bike Leasing
    • Software Reseller
    Browse all Industries
  • Community
    Learn
    • Tutorials
    • Documentation
    • Certifications
    • Training
    • Blog
    • Podcast
    Empower Education
    • Education Program
    • Scale Up! Business Game
    • Visit Odoo
    Get the Software
    • Download
    • Compare Editions
    • Releases
    Collaborate
    • Github
    • Forum
    • Events
    • Translations
    • Become a Partner
    • Services for Partners
    • Register your Accounting Firm
    Get Services
    • Find a Partner
    • Find an Accountant
    • Meet an advisor
    • Implementation Services
    • Customer References
    • Support
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Get a demo
  • Pricing
  • Help

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

  • CRM
  • e-Commerce
  • Accounting
  • Inventory
  • PoS
  • Project
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Tags (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Tags (View all)
odoo accounting v14 pos v15
About this forum
Help

cannot print Txt file to dot matrix printer using os.system

Subscribe

Get notified when there's activity on this post

This question has been flagged
systemprintingos
1 Reply
5975 Views
Avatar
rudyanto santoso

I have create custom module for v8 to print picking list using dot matrix printer.

My server using windows 7, so I run "NET USE LPT1: \\computername\printername", and the server successfully printing txt file to my remote dot matrix printer using command "Type namefile.txt > PRN".

And then from the server i execute "os.system("type namefile.txt > PRN"  using python command-line and also successfull to print the text file.

The problem is when I put that code on odoo custom modul, it is not working

Here is my code :

class stock_picking(models.Model):

_inherit = 'stock.picking'

def cetak(self, cr, uid, ids, context):

# Mendefinikan template report berdasarkan path modul terkait

tpl = tpl_lookup.get_template('picking.txt')

tpl_line = tpl_lookup.get_template('picking_line.txt')

# Mempersiapkan data-data yang diperlukan

user = self.pool.get('res.users').browse(cr, uid, uid)

order = self.browse(cr, uid, ids)[0]

date = time.strftime('%d/%m/%Y %H:%M', time.strptime(order.date,'%Y-%m-%d %H:%M:%S'))

tglo=order.date

no = 0

rows = []

for line in order.move_lines:

no += 1

s = tpl_line.render(no=str(no),

code="Kode Barang", #line.product_id.code,

uom=line.product_uom.name,

name=line.product_id.name_template, #line.product_id.name_template,

desk = line.product_tmpl_id.description.strip()[:49],

qty="{:,.0f}".format(line.product_uom_qty).replace(",","."))

rows.append(s)

# Merender data yang telah disiapkan ke dalam template report text

s = tpl.render(id=order.nomor_do, #order.name,

tgl=tglo[8:10]+"-"+tglo[5:7]+"-"+tglo[:4],

pelanggan=order.partner_id.name,

alamat=order.partner_id.street,

kota=order.partner_id.city,

rows=rows,

po=order.origin,

do=order.no_pesan,

tglp=order.tgl_pesan,

nmp=order.nama_pesan,

user='('+ user.name +')')

# Membuat temporary file yang akan dicetak beserta pathnya

filename = 'c:/temp/%s.txt' % uid

filename2 = '"c:\\temp\%s.txt"' % uid

filename3 = '"c:\\temp\\text.txt"'

# Mengisi file tersebut dengan data yang telah dirender

f = open(filename, 'w')

f.write(s)

f.close()

# Proses cetak dijalankan dan pastikan variabel nama_printer adalah nama printer yang anda setting atau tambahkan dengan webmin diatas

os.system("type %s > PRN:%filename2    #first

os.system('type %s > %s' % (filename2,filename3)) #second

# Hapus file yang telah dicetak

os.remove(filename)

return True

The first one cannot print the text file to remote printer, but the second one successfully create a backup file. Both of them using the same syntax, but different destination.

Are there any solustion ??

0
Avatar
Discard
Avatar
rudyanto santoso
Author Best Answer

there is a typo

the correct one is :

os.system("type %s > PRN"%filename2)    #first

os.system('type %s > %s' % (filename2,filename3)) #second

sorry, i cnnot edit the original post--error 403

0
Avatar
Discard
Enjoying the discussion? Don't just read, join in!

Create an account today to enjoy exclusive features and engage with our awesome community!

Sign up
Related Posts Replies Views Activity
COMO SE LA VERSION QUE TENGO DE ODO
system
Avatar
Avatar
Avatar
2
Nov 25
491
Free Odoo instance suddenly asking for payment
system
Avatar
Avatar
1
Nov 25
523
Student can not see all apps in my database?
system
Avatar
Avatar
Avatar
2
Oct 25
749
which features are add in odoo19 compare with odoo18 Solved
system
Avatar
Avatar
1
Oct 25
2067
Product Labels Configuration
printing
Avatar
Avatar
Avatar
Avatar
4
Sep 25
7780
Community
  • Tutorials
  • Documentation
  • Forum
Open Source
  • Download
  • Github
  • Runbot
  • Translations
Services
  • Odoo.sh Hosting
  • Support
  • Upgrade
  • Custom Developments
  • Education
  • Find an Accountant
  • Find a Partner
  • Become a Partner
About us
  • Our company
  • Brand Assets
  • Contact us
  • Jobs
  • Events
  • Podcast
  • Blog
  • Customers
  • Legal • Privacy
  • Security
الْعَرَبيّة 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 is a suite of open source business apps that cover all your company needs: CRM, eCommerce, accounting, inventory, point of sale, project management, etc.

Odoo's unique value proposition is to be at the same time very easy to use and fully integrated.

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