Esempio n. 1
0
    def test_conn_clicksend(self):
        sms_body = "Clicksend Test Connection Successful........"
        mobile_number = self.user_mobile_no
        response = send_sms_using_clicksend(sms_body,
                                            mobile_number,
                                            sms_gateway=self)

        if "response_code" in response and response[
                "response_code"] == "SUCCESS":
            if self.sms_debug:
                _logger.info(
                    "===========Test Connection status has been sent on %r mobile number",
                    mobile_number)
            raise Warning(
                "Test Connection status has been sent on %s mobile number" %
                mobile_number)

        if 'response_code' in response and response["response_code"] in (
                "BAD_REQUEST", "UNAUTHORIZED"):
            if self.sms_debug:
                _logger.error(
                    "==========One of the information given by you is wrong. It may be [Mobile Number] [Username] or [Password] or [Api key]"
                )
            raise Warning(
                "One of the information given by you is wrong. It may be [Mobile Number] [Username] or [Password] or [Api key]"
            )
Esempio n. 2
0
 def onchange_discount_amount(self):
     values = self.get_maximum_per_amount()
     if self.discount < 0:
         raise Warning(_("Discount should be less than Gross Amount"))
     discount = self.discount or self.discount_amount
     if discount > self.gross_amount:
         raise Warning(_("Discount (%s) should be less than "
                         "Gross Amount (%s).") % (
             formatLang(self.env, discount, digits=2),
             formatLang(self.env, self.gross_amount, digits=2)))
     if self.discount_amount > values.get('max_amount', False) \
             and values.get('check_group', False):
         raise Warning(_("You're not allowed to apply Discount Amount "
                         "(%s) more than configured amount (%s) in "
                         "configuration setting!") % (
             formatLang(self.env, self.discount_amount, digits=2),
             formatLang(self.env, values['max_amount'], digits=2)))
     config_id = self.env['res.config.settings'].search(
         [], order='id desc', limit=1)
     if config_id and config_id.global_discount_apply:
         if config_id.global_discount_fix_amount < self.discount_amount:
             raise Warning(_("You're not allowed to apply Discount "
                             "Amount (%s) more than configured amount "
                             "(%s) in configuration setting!") % (
                 formatLang(self.env, self.discount_amount, digits=2),
                 formatLang(self.env, config_id.global_discount_fix_amount,
                            digits=2)))
Esempio n. 3
0
    def generate_cfdi_invoice(self):
        # after validate, send invoice data to external system via http post
        for invoice in self:
            if self.estado_factura == 'factura_correcta':
                raise UserError(
                    _('Error para timbrar factura, Factura ya generada.'))
            if self.estado_factura == 'factura_cancelada':
                raise UserError(
                    _('Error para timbrar factura, Factura ya generada y cancelada.'
                      ))
            self.fecha_factura = datetime.datetime.now()
            values = invoice.to_json()
            if self.company_id.proveedor_timbrado == 'multifactura':
                url = '%s' % ('http://facturacion.itadmin.com.mx/api/invoice')
            elif invoice.company_id.proveedor_timbrado == 'multifactura2':
                url = '%s' % ('http://facturacion2.itadmin.com.mx/api/invoice')
            elif invoice.company_id.proveedor_timbrado == 'multifactura3':
                url = '%s' % ('http://facturacion3.itadmin.com.mx/api/invoice')
            elif self.company_id.proveedor_timbrado == 'gecoerp':
                url = '%s' % (
                    'https://itadmin.gecoerp.com/invoice/?handler=FlectraHandler33'
                )
            try:
                response = requests.post(
                    url,
                    auth=None,
                    verify=False,
                    data=json.dumps(values),
                    headers={"Content-type": "application/json"})
            except Exception as e:
                error = str(e)
                if "Name or service not known" in error or "Failed to establish a new connection" in error:
                    raise Warning(
                        "Servidor fuera de servicio, favor de intentar mas tarde"
                    )
                else:
                    raise Warning(error)

            #_logger.info('something ... %s', response.text)
            json_response = response.json()
            xml_file_link = False
            estado_factura = json_response['estado_factura']
            if estado_factura == 'problemas_factura':
                raise UserError(_(json_response['problemas_message']))
            # Receive and stroe XML invoice
            if json_response.get('factura_xml'):
                xml_file_link = invoice.company_id.factura_dir + '/' + invoice.number.replace(
                    '/', '_') + '.xml'
                xml_file = open(xml_file_link, 'w')
                xml_invoice = base64.b64decode(json_response['factura_xml'])
                xml_file.write(xml_invoice.decode("utf-8"))
                xml_file.close()
                invoice._set_data_from_xml(xml_invoice)
            invoice.write({
                'estado_factura': estado_factura,
                'xml_invoice_link': xml_file_link,
                'factura_cfdi': True
            })
            invoice.message_post(body="CFDI emitido")
        return True
Esempio n. 4
0
    def action_confirm(self):
        if self._uid != self.create_uid.id:
            raise Warning(
                _("You can't confirm purchase indent which is \
            requested by %s!") % (self.create_uid.name))
        if not self.indent_line:
            raise Warning(_('No Product Line(s) were found!'))
        check_pro_qty = [
            line.id for line in self.indent_line if line.product_qty
        ]
        if not check_pro_qty:
            raise Warning(_("No Quantity were found for any line!"))
        self.check_duplicate_product()
        group_id = self.sudo().env.ref('purchase.group_purchase_manager')
        if not group_id.users:
            raise AccessError(
                _("Please contact your Administrator \n \
                  No user found under 'Purchase Manager'"))
        server_id = self.env['ir.mail_server'].search([])
        if not server_id:
            raise AccessError(_("Please configure outgoing mail server"))
        email_to = ",".join(
            [user.email for user in group_id.users if user.email])
        recipient_ids = [user.partner_id.id for user in group_id.users]
        if self.env.user.email:
            product_qty = '''
                    <table width=100%% border="0" style="font-family: 'Arial';
                    font-size: 12px;">
                    <tr>
                        <td><b>''' + _("Product Name") + '''</b></td>
                        <td><b>''' + _("Quantity") + '''</b></td>
                        <td><b>''' + _("Expected Date") + '''</b></td>
                    </tr>'''
            for line in self.indent_line:
                qty = (str(formatLang(self.env, line.product_qty, digits=2)))
                product_qty += '<tr>\
                                    <td>' + str(line.product_id.name) + '</td>\
                                    <td>' + qty + '</td>\
                                    <td>' + str(line.expected_date) + '</td>\
                                </tr>'

            msg1 = '<p>Purchase Indent "%s" Confirmed by "%s" for following \
            Products Details.</p>' % (self.name, self.env.user.name)
            msg1 += '<p> %s </p>' % (product_qty)
            create_values = {
                'body_html': msg1,
                'subject':
                'Purchase Indent Confirmed by %s' % (self.env.user.name),
                'email_from': self.env.user.email,
                'email_to': email_to,
                'model': 'purchase.indent',
                'res_id': self.id,
                'reply_to': '',
                'recipient_ids': [(6, 0, recipient_ids)],
            }
            email_id = self.env['mail.mail'].create(create_values)
            email_id.send()
        else:
            raise AccessError(_("Please configure your email"))
        self.state = 'confirm'
Esempio n. 5
0
 def onchange_discount_per(self):
     values = self.get_maximum_per_amount()
     if self.discount_method == 'per' and (
             self.discount_per > 100 or self.discount_per < 0) \
             and values.get('check_group', False):
         raise Warning(_("Percentage should be between 0% to 100%"))
     if self.discount_per > values.get('max_percentage', False) \
             and values.get('check_group', False):
         raise Warning(
             _("You are not allowed to apply Discount Percentage "
               "(%s) more than configured Discount Percentage "
               "(%s) in configuration setting!") %
             (formatLang(self.env, self.discount_per, digits=2),
              formatLang(self.env, values['max_percentage'], digits=2)))
     config_id = self.env['res.config.settings'].search([],
                                                        order='id desc',
                                                        limit=1)
     if config_id and config_id.global_discount_invoice_apply:
         global_percentage = config_id.global_discount_percentage_invoice
         if global_percentage < self.discount_per:
             raise Warning(
                 _("You are not allowed to apply Discount "
                   "Percentage(%s) more than configured Discount"
                   " Percentage (%s) in configuration setting!") %
                 (formatLang(self.env, self.discount_per, digits=2),
                  formatLang(self.env,
                             config_id.global_discount_percentage_invoice,
                             digits=2)))
Esempio n. 6
0
 def onchange_discount_amount(self):
     values = self.get_maximum_per_amount()
     if self.discount < 0:
         raise Warning(_("Discount should be less than Gross Amount"))
     discount = self.discount or self.discount_amount
     if self.gross_amount and discount > self.gross_amount:
         raise Warning(
             _("Discount (%s) should be less than "
               "Gross Amount (%s).") %
             (formatLang(self.env, discount, digits=2),
              formatLang(self.env, self.gross_amount, digits=2)))
     if self.discount > values.get('max_amount', False) \
             and values.get('check_group', False):
         raise Warning(
             _("You're not allowed to apply this amount of "
               "discount as discount Amount (%s) is greater than"
               " assign Fix Amount (%s).") %
             (formatLang(self.env, self.discount, digits=2),
              formatLang(self.env, values['max_amount'], digits=2)))
     config_id = self.env['res.config.settings'].search([],
                                                        order='id desc',
                                                        limit=1)
     if config_id and config_id.global_discount_invoice_apply:
         fix_amount = config_id.global_discount_fix_invoice_amount
         if fix_amount < self.discount_amount:
             raise Warning(
                 _("You're not allowed to apply this amount of"
                   " discount as discount Amount (%s) is greater"
                   " than Configuration Amount (%s).") %
                 (formatLang(self.env, self.discount, digits=2),
                  formatLang(self.env,
                             config_id.global_discount_fix_invoice_amount,
                             digits=2)))
Esempio n. 7
0
    def onchange_discount_per(self):
        if self.discount_method != 'per':
            return

        values = self.get_maximum_per_amount()
        if self.discount_method == 'per' and (
                self.discount_per > 100 or self.discount_per < 0) and \
                values.get('check_group', False):
            raise Warning(_("Percentage should be between 0% to 100%"))
        if self.discount_per > values.get('max_percentage', False) and \
                values.get('check_group', False):
            raise Warning(_("You are not allowed to apply Discount Percentage"
                            " (%s) more than configured Discount Percentage "
                            "(%s) in configuration setting!") % (
                formatLang(self.env,  self.discount_per, digits=2),
                formatLang(self.env, values['max_percentage'], digits=2)))
        config_data = self.env['res.config.settings'].sudo().get_values()
        if config_data.get('global_discount_apply'):
            if config_data.get('global_discount_percentage') < self.discount_per:
                raise Warning(_("You are not allowed to apply Discount "
                                "Percentage (%s) more than configured "
                                "Discount Percentage (%s) in configuration "
                                "setting!") % (
                    formatLang(self.env, self.discount_per, digits=2),
                    formatLang(self.env, config_data.get('global_discount_percentage'),
                               digits=2)))
Esempio n. 8
0
    def onchange_discount_amount(self):
        if self.discount_method != 'fixed':
            return

        values = self.get_maximum_per_amount()
        if self.discount < 0 < self.gross_amount:
            raise Warning(_("Discount should be less than Gross Amount"))
        if self.discount > 0 > self.gross_amount:
            raise Warning(_("Discount should be less than Gross Amount"))
        discount = self.discount or self.discount_amount
        if (0 < self.gross_amount < discount) or (0 > self.gross_amount > discount):
            raise Warning(_("Discount (%s) should be less than "
                            "Gross Amount (%s).") % (
                formatLang(self.env, discount, digits=2),
                formatLang(self.env, self.gross_amount, digits=2)))
        if self.gross_amount > 0 and self.discount > values.get('max_amount', False) and values.get('check_group', False):
            raise Warning(_("You're not allowed to apply Discount Amount "
                            "(%s) more than configured amount (%s) in "
                            "configuration setting!") % (
                formatLang(self.env, self.discount_amount, digits=2),
                formatLang(self.env, values['max_amount'], digits=2)))
        config_data = self.env['res.config.settings'].sudo().get_values()
        if config_data.get('global_discount_apply'):
            fix_amount = config_data.get('global_discount_fix_amount')
            if self.gross_amount > 0 and fix_amount < self.discount_amount:
                raise Warning(_("You're not allowed to apply Discount "
                                "Amount (%s) more than configured amount "
                                "(%s) in configuration setting!") % (
                    formatLang(self.env, self.discount_amount, digits=2),
                    formatLang(self.env, config_data.get('global_discount_fix_amount'),
                               digits=2)))
Esempio n. 9
0
    def update_document(self):

        if not self.vat:
            return False
        if self.catalog_06_id and self.catalog_06_id.code == '1':
            #Valida DNI
            if self.vat and len(self.vat) != 8:
                raise Warning('El Dni debe tener 8 caracteres')
            else:
                d = get_data_doc_number('dni', self.vat, format='json')
                if not d['error']:
                    d = d['data']
                    self.name = '%s %s %s' % (d['nombres'], d['ape_paterno'],
                                              d['ape_materno'])

        elif self.catalog_06_id and self.catalog_06_id.code == '6':
            # Valida RUC
            if self.vat and len(self.vat) != 11:
                raise Warning('El Ruc debe tener 11 caracteres')
            else:
                d = get_data_doc_number('ruc', self.vat, format='json')
                if d['error']:
                    return True
                d = d['data']
                #~ Busca el distrito
                ditrict_obj = self.env['res.country.state']
                prov_ids = ditrict_obj.search([('name', '=', d['provincia']),
                                               ('province_id', '=', False),
                                               ('state_id', '!=', False)])
                dist_id = ditrict_obj.search(
                    [('name', '=', d['distrito']),
                     ('province_id', '!=', False), ('state_id', '!=', False),
                     ('province_id', 'in', [x.id for x in prov_ids])],
                    limit=1)
                if dist_id:
                    self.district_id = dist_id.id
                    self.province_id = dist_id.province_id.id
                    self.state_id = dist_id.state_id.id
                    self.country_id = dist_id.country_id.id

                # Si es HABIDO, caso contrario es NO HABIDO
                tstate = d['condicion_contribuyente']
                if tstate == 'HABIDO':
                    tstate = 'habido'
                else:
                    tstate = 'nhabido'
                self.state = tstate

                self.name = d['nombre_comercial'] != '-' and d[
                    'nombre_comercial'] or d['nombre']
                self.registration_name = d['nombre']
                self.street = d['domicilio_fiscal']
                self.vat_subjected = True
                self.is_company = True
        else:
            True
Esempio n. 10
0
 def on_change_url(self):
     self.ensure_one()
     if self.url:
         res = self._parse_document_url(self.url)
         if res.get('error'):
             raise Warning(_('Could not fetch data from url. Document or access right not available:\n%s') % res['error'])
         values = res['values']
         if not values.get('document_id'):
             raise Warning(_('Please enter valid Youtube or Google Doc URL'))
         for key, value in values.items():
             self[key] = value
Esempio n. 11
0
 def _on_change_url(self):
     self.ensure_one()
     if self.url:
         res = self._parse_document_url(self.url)
         if res.get('error'):
             raise Warning(res.get('error'))
         values = res['values']
         if not values.get('document_id'):
             raise Warning(
                 _('Please enter valid Youtube or Google Doc URL'))
         for key, value in values.items():
             self[key] = value
Esempio n. 12
0
 def check_date(self):
     for rule_line_id in self:
         parent_start_date = rule_line_id.rule_id_start_date
         child_start_date = rule_line_id.start_date
         if parent_start_date and \
                 child_start_date and parent_start_date > child_start_date:
             raise Warning(_("Start Date date not valid in "
                             "Product Rule Lines!"))
         parent_end_date = rule_line_id.rule_id_end_date
         child_end_date = rule_line_id.end_date
         if parent_end_date and \
                 child_end_date and parent_end_date < child_end_date:
             raise Warning(_("End Date date not valid in "
                             "Product Rule Lines!"))
    def check_access_right(self, obj, ict_uid, company):
        if not obj.sudo(ict_uid).check_access_rights(
                'create', raise_exception=False):
            raise Warning(_("Please contact Administrator for Access Rights. "
                            "It seems like the Inter-company user of "
                            "company %s doesn't have access rights to "
                            "perform the inter-company operations."
                            ) % company.name)

        if not company.warehouse_id:
            raise Warning(_('No Warehouse Found! Configure an '
                            'appropriate warehouse for Company (%s) '
                            'from General Settings/Settings.' % (company.name)
                            ))
Esempio n. 14
0
 def unlink(self):
     for account in self:
         project_ids = self.env['project.project'].search([
             ('analytic_account_id', '=', account.id)
         ])
         if project_ids:
             raise Warning(_("Please delete the linked Project first!"))
         analytic_line_ids = self.env['account.analytic.line'].search([
             ('account_id', '=', account.id)
         ])
         if analytic_line_ids:
             raise Warning(
                 _("Please delete the linked Analytic Line(s) first!"))
         return super(AccountAnalyticAccount, account).unlink()
Esempio n. 15
0
 def confirm(self):
     self.ensure_one()
     point_of_sale_id = self._context.get('active_id', False)
     if not point_of_sale_id:
         raise Warning(_('No Point Of sale as active_id on context'))
     point_of_sale = self.env['sii.point_of_sale'].browse(point_of_sale_id)
     return point_of_sale.get_pysiiws_currency_rate(self.currency_id)
Esempio n. 16
0
 def set_qty_state_confirm(self,
                           purchase_order_id=False,
                           purchase_agreement_id=False):
     indent_line_obj = self.env['purchase.indent.line']
     indent_history_ids = []
     if purchase_order_id:
         indent_history_ids = self.env['purchase.indent.history'].search([
             ('order_id', '=', purchase_order_id.id),
             ('state', '=', 'Cancelled')
         ])
     elif purchase_agreement_id:
         indent_history_ids = self.env['purchase.indent.history'].search([
             ('purchase_requisition_id', '=', purchase_agreement_id.id),
             ('state', '=', 'Cancelled')
         ])
     for history_id in indent_history_ids:
         indent_line_id = indent_line_obj.sudo().search([
             ('product_id', '=', history_id.product_id.id),
             ('purchase_indent_id', '=', history_id.purchase_indent_id.id)
         ])
         if indent_line_id.requisition_qty + history_id.requisition_qty > \
                 indent_line_id.product_qty:
             remaining_qty = \
                 indent_line_id.product_qty - indent_line_id.requisition_qty
             raise Warning(
                 _("Requisition Quantity of ' %s ' is more than \
             Remaining Quantity (%s)!") %
                 (history_id.product_id.name,
                  formatLang(self.env, remaining_qty, digits=2)))
         requisition_qty = \
             indent_line_id.requisition_qty + history_id.requisition_qty
         indent_line_id.write({'requisition_qty': requisition_qty})
         history_id.purchase_indent_id.check_state()
         history_id.date = datetime.now()
Esempio n. 17
0
 def unlink(self):
     for record in self:
         if record.purchase_indent_ids:
             raise Warning(
                 _("You can not delete agreement which have \
             reference of Purchase Indent!"))
     return super(PurchaseRequisition, self).unlink()
Esempio n. 18
0
 def unlink(self):
     for record in self:
         if record.purchase_indent_ids:
             raise Warning(
                 _("You can not delete Purchase order which \
             have reference of Purchase Indent!"))
     return super(PurchaseOrder, self).unlink()
Esempio n. 19
0
 def copy(self):
     self.ensure_one()
     if self.purchase_indent_ids:
         raise Warning(
             _("You can not copy Purchase order which have \
         reference of Purchase Indent!"))
     return super(PurchaseOrder, self).copy()
Esempio n. 20
0
 def _get_eu_res_country_group(self):
     eu_group = self.env.ref("base.europe", raise_if_not_found=False)
     if not eu_group:
         raise Warning(
             _('The Europe country group cannot be found. '
               'Please update the base module.'))
     return eu_group
Esempio n. 21
0
    def action_confirm(self):
        """ Generate purchase Order based on Inter company Rules"""
        company_obj = self.env['res.company']
        purchase_order_obj = self.env['purchase.order']
        purchase_line_obj = self.env['purchase.order.line']

        res = super(SaleOrder, self).action_confirm()
        for record in self:
            if not record.company_id:
                continue
            company = company_obj.get_company_from_partner(record.partner_id)
            if company and company.inter_rules_so_from_po and (
                    not record.order_auto_generated):
                ict_uid = company.user_id.id
                # this method check Access Rights
                purchase_order_obj.check_access_right(purchase_order_obj,
                                                      ict_uid, company)
                if self.currency_id.id != company.partner_id. \
                        property_product_pricelist.currency_id.id:
                    raise Warning(
                        _('Currency mis-match! The pricelist '
                          'currency should be same for PO and SO. '
                          'You cannot create PO from SO if the '
                          'pricelist currency is not same.'))

                purchase_vals = record._prepare_purchase_order(company)
                purchase_id = purchase_order_obj.sudo().create(purchase_vals)
                for line in record.order_line:
                    line_vals = line._prepare_order_line_data(
                        purchase_id, company)
                    purchase_line_obj.sudo().create(line_vals)

                if company.inter_rule_auto_validation:
                    purchase_id.sudo().button_confirm()
        return res
 def to_print(recs):
     valid_input = re.match('^\s*\[?\s*((\d+)(\s*,\s*\d+)*)\s*\]?\s*$',
                                                         recs[0].object_ids)
     valid_input = valid_input and valid_input.group(1) or False
     if not valid_input:
         raise Warning(
             _("Input single record ID or number of comma separated IDs!"))
     print_ids = eval("[%s]" % valid_input, {})
     rep_obj = recs.env['ir.actions.report']
     report = rep_obj.browse(recs.env.context['active_id'])[0]
     ctx = dict(recs.env.context)
     ctx.update({'active_id': print_ids[0],
                 'active_ids': print_ids,
                 'active_model': report.model,
                })
     data = {
             'model': report.model,
             'ids': print_ids,
             'id': print_ids[0],
             'report_type': 'aeroo',
             }
     res =  {
             'type': 'ir.actions.report',
             'report_name': report.report_name,
             'report_type': report.report_type,
             'datas': data,
             'context': ctx,
             'target': 'current',
             }
     _logger.exception('AEROO by_action======================= %s' % (res,))
     return res
Esempio n. 23
0
File: sii.py Progetto: sc4you/perpul
 def _check_product_types(self):
     for r in self:
         if r.product_types:
             types = set(r.product_types.split(','))
             if not types.issubset(['adjust', 'consu', 'service']):
                 raise Warning(
                     _('You provided an invalid list of product types.\
                 Must been separated by commas'))
Esempio n. 24
0
 def button_cancel(self):
     res = super(PurchaseOrder, self).button_cancel()
     if self.order_line.filtered(
             lambda l: l.blanket_po_line):
         raise Warning(
             _('Sorry, You can not cancel blanket line based PO.'))
     self.write({'state': 'cancel'})
     return res
Esempio n. 25
0
 def unlink(self):
     for indent_id in self:
         if indent_id.state not in ['draft', 'cancel']:
             raise Warning(
                 _("Invalid Action!\n You cannot delete a \
             Purchase Indent which is not in 'Draft' or 'Cancel' State!"))
         indent_id.indent_line.unlink()
     return super(PurchaseIndent, self).unlink()
Esempio n. 26
0
 def action_cancel(self):
     group_id = self.sudo().env.ref('purchase.group_purchase_manager')
     if self._uid != self.create_uid.id \
             and self._uid not in group_id.users.ids:
         raise Warning(
             _("Can't cancel purchase indent which is \
         requested by %s!") % (self.create_uid.name))
     self.state = 'cancel'
Esempio n. 27
0
 def check_duplicate_coupon_code(self):
     check_coupon_id = self.search([
         ('coupon_code', '=', self.coupon_code),
         ('id', '!=', self.id),
         ('pricelist_id', '=', self.pricelist_id.id)])
     if check_coupon_id:
         raise Warning(_("Coupon code (%s) already exists!") % (
             self.coupon_code))
Esempio n. 28
0
    def test_sftp_connection(self, context=None):
        self.ensure_one()

        # Check if there is a success or fail and write messages
        messageTitle = ""
        messageContent = ""
        error = ""
        has_failed = False

        for rec in self:
            db_list = self.get_db_list(rec.host, rec.port)
            pathToWriteTo = rec.sftp_path
            ipHost = rec.sftp_host
            portHost = rec.sftp_port
            usernameLogin = rec.sftp_user
            passwordLogin = rec.sftp_password

            # Connect with external server over SFTP, so we know sure that everything works.
            try:
                s = paramiko.SSHClient()
                s.set_missing_host_key_policy(paramiko.AutoAddPolicy())
                s.connect(ipHost, 22, usernameLogin, passwordLogin, timeout=10)
                sftp = s.open_sftp()
                messageTitle = _(
                    "Connection Test Succeeded!\nEverything seems properly set up for FTP back-ups!"
                )
            except Exception as e:
                _logger.critical(
                    'There was a problem connecting to the remote ftp: ' +
                    str(e))
                error += str(e)
                has_failed = True
                messageTitle = _("Connection Test Failed!")
                if len(rec.sftp_host) < 8:
                    messageContent += "\nYour IP address seems to be too short.\n"
                messageContent += _("Here is what we got instead:\n")
            finally:
                if s:
                    s.close()

        if has_failed:
            raise Warning(messageTitle + '\n\n' + messageContent +
                          "%s" % str(error))
        else:
            raise Warning(messageTitle + '\n\n' + messageContent)
Esempio n. 29
0
 def copy(self, default=None):
     self.ensure_one()
     default = dict(default or {})
     if self.purchase_indent_ids:
         raise Warning(
             _("You can not copy Purchase Agreement which \
         have reference of Purchase Indent!"))
     default.update(name=_("%s (copy)") % (self.name or ''))
     return super(PurchaseRequisition, self).copy(default)
Esempio n. 30
0
def pre_init_check(cr):
    from flectra.service import common
    from flectra.exceptions import Warning
    version_info = common.exp_version()
    server_serie = version_info.get('server_serie')
    if server_serie != '11.0':
        raise Warning(
            'Module support Perpul series 11.0 found {}.'.format(server_serie))
    return True