def generate_label(self): label = Item() label.aisle = self.get_object('entry5').get_text() label.cart = self.get_object('entry6').get_text() label.rack = self.get_object('entry7').get_text() label.shelf = self.get_object('entry8').get_text() label.cabinet = self.get_object('entry9').get_text() label.drawer = self.get_object('entry10').get_text() label.bin = self.get_object('entry11').get_text() self.cursor.execute( "SELECT name, description, barcode FROM products " "WHERE id = (%s)", [self.product_id]) for row in self.cursor.fetchall(): label.name = row[0] label.description = row[1] label.code128 = barcode_generator.makeCode128(row[2]) label.barcode = row[2] price = pricing.product_retail_price(self.product_id) label.price = '${:,.2f}'.format(price) data = dict(label=label) from py3o.template import Template self.label_file = "/tmp/product_label.odt" t = Template(template_dir + "/product_label_template.odt", self.label_file) t.render(data) DB.rollback()
def print_label(self, widget): location_id = self.get_object('comboboxtext6').get_active_id() label = Item() self.cursor.execute("SELECT aisle, cart, rack, shelf, cabinet, drawer, " "bin FROM product_location " "WHERE (product_id, location_id) = (%s, %s)", (self.product_id, location_id)) for row in self.cursor.fetchall(): label.aisle = row[0] label.cart = row[1] label.rack = row[2] label.shelf = row[3] label.cabinet = row[4] label.drawer = row[5] label.bin = row[6] break else: label.aisle = '' label.cart = '' label.rack = '' label.shelf = '' label.cabinet = '' label.drawer = '' label.bin = '' self.cursor.execute("SELECT name, description, barcode FROM products " "WHERE id = (%s)",[self.product_id]) for row in self.cursor.fetchall(): label.name= row[0] label.description = row[1] label.code128 = barcode_generator.makeCode128(row[2]) label.barcode = row[2] self.cursor.execute("SELECT id FROM customer_markup_percent " "WHERE standard = True") default_markup_id = self.cursor.fetchone()[0] self.cursor.execute("SELECT price FROM products_markup_prices " "WHERE (product_id, markup_id) = (%s, %s)", (self.product_id, default_markup_id)) for row in self.cursor.fetchall(): label.price = '${:,.2f}'.format(row[0]) break else: cost = self.get_object('spinbutton1').get_value() self.cursor.execute("SELECT markup_percent " "FROM customer_markup_percent WHERE id = %s", (markup_id,)) markup = float(self.cursor.fetchone()[0]) margin = (markup / 100) * cost label.price = '${:,.2f}'.format(margin + cost) data = dict(label = label) from py3o.template import Template label_file = "/tmp/product_label.odt" t = Template(main.template_dir+"/product_label_template.odt", label_file ) t.render(data) #the self.data holds all the info subprocess.Popen(["soffice", label_file])
def reprint_serial_number_clicked(self, button): barcode = self.get_object('serial_number_entry').get_text() label = Item() label.code128 = barcode_generator.makeCode128(str(barcode)) label.barcode = barcode from py3o.template import Template label_file = "/tmp/manufacturing_serial_label.odt" t = Template(template_dir + "/manufacturing_serial_template.odt", label_file) data = dict(label=label) t.render(data) subprocess.call(["soffice", "--headless", "-p", label_file])
def print_serial_number(self, barcode, label_qty): label = Item() label.code128 = barcode_generator.makeCode128(str(barcode)) label.barcode = barcode from py3o.template import Template label_file = "/tmp/manufacturing_serial_label.odt" t = Template(template_dir + "/manufacturing_serial_template.odt", label_file) data = dict(label=label) t.render(data) #the self.data holds all the info for i in range(label_qty): subprocess.call(["soffice", "--headless", "-p", label_file])
def print_label(self, product_id): if self.builder.get_object('checkbutton1').get_active() == False: return location_id = self.builder.get_object('combobox2').get_active_id() label = Item() price = product_retail_price(product_id) label.price = '${:,.2f}'.format(price) self.cursor.execute( "SELECT aisle, cart, rack, shelf, cabinet, drawer, " "bin FROM product_location " "WHERE (product_id, location_id) = (%s, %s)", (product_id, location_id)) for row in self.cursor.fetchall(): label.aisle = row[0] label.cart = row[1] label.rack = row[2] label.shelf = row[3] label.cabinet = row[4] label.drawer = row[5] label.bin = row[6] break else: label.aisle = '' label.cart = '' label.rack = '' label.shelf = '' label.cabinet = '' label.drawer = '' label.bin = '' self.cursor.execute( "SELECT name, description, barcode " "FROM products WHERE id = (%s)", (product_id, )) for row in self.cursor.fetchall(): label.name = row[0] label.description = row[1] label.code128 = barcode_generator.makeCode128(row[2]) label.barcode = row[2] data = dict(label=label) from py3o.template import Template label_file = "/tmp/product_label.odt" t = Template(template_dir + "/product_label_template.odt", label_file) t.render(data) #the self.data holds all the info subprocess.call("soffice -p --headless " + label_file, shell=True) DB.rollback()