Пример #1
0
    def print_document(self, report, content, **print_opts):
        if len(self) != 1:
            _logger.error(
                'Google cloud print called with %s but singleton is'
                'expeted. Check printers configuration.' % self)
            return super(PrintingPrinter, self).print_document(
                report, content, **print_opts)
        if self.printer_type != 'gcp':
            return super(PrintingPrinter, self).print_document(
                report, content, **print_opts)
        if get_mode():
            _logger.warning(_(
                "You Can not Send Mail Because Odoo is not in Production "
                "mode"))
            return True

        fd, file_name = mkstemp()
        try:
            os.write(fd, content)
        finally:
            os.close(fd)

        options = self.print_options(report, **print_opts)
        _logger.debug(
            'Going to Print via Google Cloud Printer %s' % (self.system_name))

        try:
            self.env['google.cloudprinter.configuration'].submit_job(self.uri,options.get('format', 'pdf'),file_name,options,)
            _logger.info("Printing Job: '%s'" % (file_name))
        except Exception as e:
            _logger.error(
                'Could not submit job to google cloud. This is what we get:\n'
                '%s' % e)
        return True
Пример #2
0
 def send_email(self,
                message,
                mail_server_id=None,
                smtp_server=None,
                smtp_port=None,
                smtp_user=None,
                smtp_password=None,
                smtp_encryption=None,
                smtp_debug=False,
                smtp_session=None):
     # TODO
     # if we raise ValidationError then can not install modules with demo
     # data, we should find a way to raise message when sending from
     # interface
     # raise ValidationError(_(
     if get_mode():
         _logger.log(
             25,
             _("You Can not Send Mail Because Odoo is not in Production "
               "mode"))
         return True
     return super(IrMailServer,
                  self).send_email(message,
                                   mail_server_id=mail_server_id,
                                   smtp_server=smtp_server,
                                   smtp_port=smtp_port,
                                   smtp_user=smtp_user,
                                   smtp_password=smtp_password,
                                   smtp_encryption=smtp_encryption,
                                   smtp_debug=smtp_debug,
                                   smtp_session=smtp_session)
Пример #3
0
    def print_document(self, report, content, format, copies=1):
        """ Print a file

        Format could be pdf, qweb-pdf, raw, ...

        """
        if len(self) != 1:
            _logger.error('Google cloud print called with %s but singleton is'
                          'expeted. Check printers configuration.' % self)
            return super(PrintingPrinter, self).print_document(report,
                                                               content,
                                                               format,
                                                               copies=copies)
        # self.ensure_one()
        if self.printer_type != 'gcp':
            return super(PrintingPrinter, self).print_document(report,
                                                               content,
                                                               format,
                                                               copies=copies)
        if get_mode():
            _logger.warning(
                _("You Can not Send Mail Because Odoo is not in Production "
                  "mode"))
            return True

        fd, file_name = mkstemp()
        try:
            os.write(fd, content)
        finally:
            os.close(fd)

        options = self.print_options(report, format, copies)

        _logger.debug('Sending job to Google Cloud printer %s' %
                      (self.system_name))

        # atrapamos el error y lo mandamos por el log para que no de piedrazo
        # y posiblemente rompa interfaz
        try:
            self.env['google.cloudprint.config'].submit_job(
                self.uri,
                format,
                file_name,
                options,
            )
        except Exception as e:
            # access_token = self.get_access_token()
            _logger.error(
                'Could not submit job to google cloud. This is what we get:\n'
                '%s' % e)

        _logger.info("Printing job: '%s'" % (file_name))
        return True
Пример #4
0
 def check_automatic_backup_enable(self):
     """
     Para que se hagan backups al hacer fix on con el cron, se requiere:
     1. Que no haya server mode definido
     2. Que haya un parametro database.backups.enable = 'True'
     """
     if get_mode():
         _logger.info(
             'Backups are disable by server_mode test or develop. '
             'If you want to enable it you should remove develop or test '
             'value for server_mode key on openerp server config file')
         return False
     backups_enable = self.env['ir.config_parameter'].get_param(
         'database.backups.enable')
     if backups_enable != 'True':
         _logger.info(
             'Backups are disable. If you want to enable it you should add '
             'the parameter database.backups.enable with value True')
         return False
     return True
Пример #5
0
 def button_confirm_login(self):
     if get_mode():
         raise UserError(_(
             "You Can not Confirm & Test Because Odoo is in %s mode.") % (
             get_mode()))
     return super(FetchmailServer, self).button_confirm_login()
Пример #6
0
 def connect(self):
     if get_mode():
         raise UserError(_(
             "Can not Connect to server because Odoo is in %s mode.") % (
             get_mode()))
     return super(FetchmailServer, self).connect()
Пример #7
0
 def fetch_mail(self):
     if get_mode():
         raise UserError(_(
             "You Can not Fetch Mail Because Odoo is in %s mode.") % (
             get_mode()))
     return super(FetchmailServer, self).fetch_mail()