On Friday, September 21, 2018 at 8:20:13 AM UTC, Cédric Krier wrote:
> On 2018-09-17 01:21, Markus Bala wrote:
> > Actually I have 3 questions, below is my case:
> >
> > I will doing barcode label for some warehouse operation.
> >
> > Case Study:
> > At the receiving area, during receiving & storage, it will need to print 2 labels. One label is product label. One label is storage label. The different between 2 labels are in the label's size.
> > Product label using 5cm x 10cm. Storage label using 15cm x 10cm.
> >
> > Because of this, I will have 2 labels printer. Printer (A) for product label. Printer (B) for storage Label.
> >
> > Question 1: for "Direct Print", how can set when I click on print "Product Label" it choose Printer (A) and vice versa.
>
> On windows, the client use the command 'print' which let the OS decide.
> So maybe you can use different file extension and configure the OS to
> choose the right printer.
> On MacOS, the client uses the 'open' command which just open the file.
> Maybe it is possible to configure the "opener" to select the right
> printer when requesting to print.
> On UNIX, it uses the 'xdg-open' command. In this case, I guess you can
> also customize xdg to select the right printer from the mime-type.
Reply: Thank, I never thought of this method. I will try this solution.
Reply: This will be alternative. I will try on the solution no 1.
>
> > Question 2: How to get "Tryton Client" IP from "Trytond"? the purpose to fixed the IP/PC for the label printers so other PC do not have label printer
>
> Since 4.8, the Transaction.context has an attribute '_request' which is
> the werkzeug request object and contain the IP address of the client.
> But there is no guarantee that this attribute will always be set (for
> example from proteus request or cron job).
Nice. I have been looking this. Missed to check the transaction.context.
Thank you
Could you give me example on this? Iam litte bit confuse.
Currently, I am using Relatio. It should be a dirty hack. I hope can use the method directly from Trytond instead.
Below is my code:
from relatorio import Report
class BarcodeLabel(Workflow, ModelSQL, ModelView):
@classmethod
def print_lpn(cls, records):
report = Report(abspath(join(dirname(__file__), 'lpn.odt')),
ODT_MIME)
data = report(records=records).render().getvalue()
file_name = join(dirname(__file__), 'output_basic.odt')
open(file_name, 'wb').write(data)