Example #1
0
    def __init__(self):
        self._setup_params()
        self.default_store = get_default_store()
        StartApplicationEvent.connect(self._on_StartApplicationEvent)
        EditorCreateEvent.connect(self._on_EditorCreateEvent)
        RunDialogEvent.connect(self._on_RunDialogEvent)
        PrintReportEvent.connect(self._on_PrintReportEvent)
        SearchDialogSetupSearchEvent.connect(
            self._on_SearchDialogSetupSearchEvent)
        WorkOrderStatusChangedEvent.connect(
            self._on_WorkOrderStatusChangedEvent)
        ApplicationSetupSearchEvent.connect(
            self._on_ApplicationSetupSearchEvent)

        add_bindings([
            ('plugin.optical.pre_sale', ''),
            ('plugin.optical.search_medics', ''),
        ])

        # Whenever the model of WorkOrderActions change, we should also change ours
        actions = WorkOrderActions.get_instance()
        actions.connect('model-set', self._on_work_order_actions__model_set)

        # Add a new option to the WorkOrderRow options menu
        WorkOrderRow.options.append((_('Create new purchase...'),
                                     'optical_work_order.OpticalNewPurchase'))
Example #2
0
 def __init__(self):
     self._ui = None
     self.default_store = get_default_store()
     StartApplicationEvent.connect(self._on_StartApplicationEvent)
     StopApplicationEvent.connect(self._on_StopApplicationEvent)
     EditorCreateEvent.connect(self._on_EditorCreateEvent)
     RunDialogEvent.connect(self._on_RunDialogEvent)
     PrintReportEvent.connect(self._on_PrintReportEvent)
     add_bindings([
         ('plugin.optical.pre_sale', ''),
         ('plugin.optical.search_medics', ''),
     ])
Example #3
0
def print_report(report_class, *args, **kwargs):
    rv = PrintReportEvent.emit(report_class, *args, **kwargs)
    if rv:
        return rv

    filters = kwargs.pop('filters', None)
    if filters:
        kwargs = describe_search_filters_for_reports(filters, **kwargs)

    tmp = tempfile.mktemp(suffix='.pdf', prefix='stoqlib-reporting')
    report = report_class(tmp, *args, **kwargs)
    report.filename = tmp
    if _system == "Windows":
        report.save()
        log.info("Starting PDF reader for %r" % (report.filename, ))
        # Simply execute the file
        os.startfile(report.filename)
        return

    if isinstance(report, HTMLReport):
        op = PrintOperationWEasyPrint(report)
        op.set_threaded()
    else:
        op = PrintOperationPoppler(report)

    rv = op.run()
    return rv
Example #4
0
def print_report(report_class, *args, **kwargs):
    rv = PrintReportEvent.emit(report_class, *args, **kwargs)
    if rv:
        return rv

    filters = kwargs.pop('filters', None)
    if filters:
        kwargs = describe_search_filters_for_reports(filters, **kwargs)

    tmp = tempfile.mktemp(suffix='.pdf', prefix='stoqlib-reporting')
    report = report_class(tmp, *args, **kwargs)
    report.filename = tmp
    if _system == "Windows":
        report.save()
        log.info("Starting PDF reader for %r" % (report.filename, ))
        # Simply execute the file
        os.startfile(report.filename)
        return

    if isinstance(report, HTMLReport):
        op = PrintOperationWEasyPrint(report)
        op.set_threaded()
    else:
        op = PrintOperationPoppler(report)

    rv = op.run()
    return rv
Example #5
0
    def test_print_report_event(self, print_report):
        # We need the UI for the events setup
        ui = BikeShopUI()

        # We need to save this in a variable, even though we dont use it,
        # otherwise the callback will not be triggered, since it is a weakref
        ui  # pyflakes

        # Emitting with something different from WorkOrderQuoteReport
        rv = PrintReportEvent.emit(object)
        self.assertFalse(rv)
        self.assertEqual(print_report.call_count, 0)

        # Emitting with a WorkOrderQuoteReport
        order = self.create_workorder()
        rv = PrintReportEvent.emit(WorkOrderQuoteReport, order)
        self.assertTrue(rv)
        print_report.assert_called_once_with(BikeShopWorkOrderQuoteReport,
                                             order)
Example #6
0
    def __init__(self):
        # This will contain a mapping of (appname, uimanager) -> extra_ui
        # We need to store that like this because each windows has it's unique
        # uimanager, and we have an extra_ui for different apps
        self._app_ui = dict()

        self.default_store = get_default_store()
        StartApplicationEvent.connect(self._on_StartApplicationEvent)
        StopApplicationEvent.connect(self._on_StopApplicationEvent)
        EditorCreateEvent.connect(self._on_EditorCreateEvent)
        RunDialogEvent.connect(self._on_RunDialogEvent)
        PrintReportEvent.connect(self._on_PrintReportEvent)
        SearchDialogSetupSearchEvent.connect(self._on_SearchDialogSetupSearchEvent)
        ApplicationSetupSearchEvent.connect(self._on_ApplicationSetupSearchEvent)

        add_bindings([
            ('plugin.optical.pre_sale', ''),
            ('plugin.optical.search_medics', ''),
        ])
Example #7
0
    def test_print_report_event(self, print_report):
        # We need the UI for the events setup
        ui = BikeShopUI()

        # We need to save this in a variable, even though we dont use it,
        # otherwise the callback will not be triggered, since it is a weakref
        ui  # pyflakes

        # Emitting with something different from WorkOrderQuoteReport
        rv = PrintReportEvent.emit(object)
        self.assertFalse(rv)
        self.assertEqual(print_report.call_count, 0)

        # Emitting with a WorkOrderQuoteReport
        order = self.create_workorder()
        rv = PrintReportEvent.emit(WorkOrderQuoteReport, order)
        self.assertTrue(rv)
        print_report.assert_called_once_with(BikeShopWorkOrderQuoteReport,
                                             order)
Example #8
0
    def test_print_report_event(self, print_report):

        # Emitting with something different from SaleOrderReport
        rv = PrintReportEvent.emit(object)
        self.assertFalse(rv)
        self.assertEquals(print_report.call_count, 0)

        # Emitting with SaleOrderReport, but without workorders
        sale = self.create_sale()
        rv = PrintReportEvent.emit(SaleOrderReport, sale)
        self.assertFalse(rv)
        self.assertEquals(print_report.call_count, 0)

        # Emitting with SaleOrderReport and with workorders
        optical_wo = self.create_optical_work_order()
        optical_wo.work_order.sale = sale
        rv = PrintReportEvent.emit(SaleOrderReport, sale)
        self.assertTrue(rv)
        print_report.assert_called_once_with(OpticalWorkOrderReceiptReport,
                                             [optical_wo.work_order])
Example #9
0
    def test_print_report_event(self, print_report):

        # Emitting with something different from SaleOrderReport
        rv = PrintReportEvent.emit(object)
        self.assertFalse(rv)
        self.assertEquals(print_report.call_count, 0)

        # Emitting with SaleOrderReport, but without workorders
        sale = self.create_sale()
        rv = PrintReportEvent.emit(SaleOrderReport, sale)
        self.assertFalse(rv)
        self.assertEquals(print_report.call_count, 0)

        # Emitting with SaleOrderReport and with workorders
        optical_wo = self.create_optical_work_order()
        optical_wo.work_order.sale = sale
        rv = PrintReportEvent.emit(SaleOrderReport, sale)
        self.assertTrue(rv)
        print_report.assert_called_once_with(OpticalWorkOrderReceiptReport,
                                             [optical_wo.work_order])
Example #10
0
    def __init__(self):
        # This will contain a mapping of (appname, uimanager) -> extra_ui
        # We need to store that like this because each windows has it's unique
        # uimanager, and we have an extra_ui for different apps
        self._app_ui = dict()

        self.default_store = get_default_store()
        StartApplicationEvent.connect(self._on_StartApplicationEvent)
        StopApplicationEvent.connect(self._on_StopApplicationEvent)
        EditorCreateEvent.connect(self._on_EditorCreateEvent)
        RunDialogEvent.connect(self._on_RunDialogEvent)
        PrintReportEvent.connect(self._on_PrintReportEvent)
        SearchDialogSetupSearchEvent.connect(
            self._on_SearchDialogSetupSearchEvent)
        ApplicationSetupSearchEvent.connect(
            self._on_ApplicationSetupSearchEvent)

        add_bindings([
            ('plugin.optical.pre_sale', ''),
            ('plugin.optical.search_medics', ''),
        ])
Example #11
0
    def __init__(self):
        self._setup_params()
        self.default_store = get_default_store()
        StartApplicationEvent.connect(self._on_StartApplicationEvent)
        EditorCreateEvent.connect(self._on_EditorCreateEvent)
        RunDialogEvent.connect(self._on_RunDialogEvent)
        PrintReportEvent.connect(self._on_PrintReportEvent)
        SearchDialogSetupSearchEvent.connect(self._on_SearchDialogSetupSearchEvent)
        WorkOrderStatusChangedEvent.connect(self._on_WorkOrderStatusChangedEvent)
        ApplicationSetupSearchEvent.connect(self._on_ApplicationSetupSearchEvent)

        add_bindings([
            ('plugin.optical.pre_sale', ''),
            ('plugin.optical.search_medics', ''),
        ])

        # Whenever the model of WorkOrderActions change, we should also change ours
        actions = WorkOrderActions.get_instance()
        actions.connect('model-set', self._on_work_order_actions__model_set)

        # Add a new option to the WorkOrderRow options menu
        WorkOrderRow.options.append((_('Create new purchase...'),
                                     'optical_work_order.OpticalNewPurchase'))
Example #12
0
 def __init__(self):
     PrintReportEvent.connect(self._on_PrintReportEvent)
Example #13
0
 def __init__(self):
     PrintReportEvent.connect(self._on_PrintReportEvent)