Trust-Code/odoo-brasil

View on GitHub

Showing 421 of 421 total issues

Similar blocks of code found in 4 locations. Consider refactoring.
Open

        if self.boleto_type == u'9':
            if self.bank_account_id.bank_id.bic != '756':
                vals['warning'] = {
                    'title': u'Ação Bloqueada!',
                    'message': u'Este boleto não combina com a conta bancária!'
Severity: Major
Found in br_boleto/models/payment_mode.py and 3 other locations - About 2 hrs to fix
br_boleto/models/payment_mode.py on lines 71..79
br_boleto/models/payment_mode.py on lines 89..96
br_boleto/models/payment_mode.py on lines 115..122

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 59.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 4 locations. Consider refactoring.
Open

        if self.boleto_type == u'10':
            if self.bank_account_id.bank_id.bic != '0851':
                vals['warning'] = {
                    'title': u'Ação Bloqueada!',
                    'message': u'Este boleto não combina com a conta bancária!'
Severity: Major
Found in br_boleto/models/payment_mode.py and 3 other locations - About 2 hrs to fix
br_boleto/models/payment_mode.py on lines 71..79
br_boleto/models/payment_mode.py on lines 89..96
br_boleto/models/payment_mode.py on lines 106..113

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 59.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 4 locations. Consider refactoring.
Open

        if self.boleto_type == u'1':
            if self.bank_account_id.bank_id.bic != '001':
                vals['warning'] = {
                    'title': u'Ação Bloqueada!',
                    'message': u'Este boleto não combina com a conta bancária!'
Severity: Major
Found in br_boleto/models/payment_mode.py and 3 other locations - About 2 hrs to fix
br_boleto/models/payment_mode.py on lines 89..96
br_boleto/models/payment_mode.py on lines 106..113
br_boleto/models/payment_mode.py on lines 115..122

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 59.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Identical blocks of code found in 2 locations. Consider refactoring.
Open

            if not bank_account.acc_number_dig or\
               not bank_account.bra_number or\
               not bank_account.bra_number_dig:
                bank_account_vals = {
                    'acc_number_dig': vals.get('acc_number_dig'),
Severity: Major
Found in br_account_payment/models/account_journal.py and 1 other location - About 2 hrs to fix
br_account_payment/models/account_journal.py on lines 42..50

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 59.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

File sale.py has 279 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# -*- coding: utf-8 -*-
# © 2009  Renato Lima - Akretion
# © 2012  Raphaël Valyi - Akretion
# © 2016 Danimar Ribeiro, Trustcode
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
Severity: Minor
Found in br_sale/models/sale.py - About 2 hrs to fix

    AccountInvoiceLine has 24 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class AccountInvoiceLine(models.Model):
        _inherit = 'account.invoice.line'
    
        @api.model
        def _default_company_fiscal_type(self):
    Severity: Minor
    Found in br_account/models/account_invoice_line.py - About 2 hrs to fix

      Consider simplifying this complex logical expression.
      Open

              if self.model == '009':
                  tz = pytz.timezone(self.env.user.partner_id.tz) or pytz.utc
                  dt_emissao = datetime.strptime(self.data_emissao, DTFT)
                  dt_emissao = pytz.utc.localize(dt_emissao).astimezone(tz)
                  dt_emissao = dt_emissao.strftime('%d/%m/%Y')
      Severity: Critical
      Found in br_nfse/models/nfse_susesu.py - About 2 hrs to fix

        Function _compute_amount_line_all has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
        Open

            def _compute_amount_line_all(self):
                super(PosOrderLine, self)._compute_amount_line_all()
                for line in self:
                    currency = line.order_id.pricelist_id.currency_id
                    values = line.order_id.fiscal_position_id.map_tax_extra_values(
        Severity: Minor
        Found in br_point_sale/models/pos_order.py - About 2 hrs to fix

        Cognitive Complexity

        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

        A method's cognitive complexity is based on a few simple rules:

        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
        • Code is considered more complex for each "break in the linear flow of the code"
        • Code is considered more complex when "flow breaking structures are nested"

        Further reading

        Function br_boleto_onchange_boleto_type has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
        Open

            def br_boleto_onchange_boleto_type(self):
                vals = {}
        
                if self.boleto_type not in IMPLEMENTADOS:
                    vals['warning'] = {
        Severity: Minor
        Found in br_boleto/models/payment_mode.py - About 2 hrs to fix

        Cognitive Complexity

        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

        A method's cognitive complexity is based on a few simple rules:

        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
        • Code is considered more complex for each "break in the linear flow of the code"
        • Code is considered more complex when "flow breaking structures are nested"

        Further reading

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

            boleto_especie = fields.Selection([
                ('01', u'DUPLICATA MERCANTIL'),
                ('02', u'NOTA PROMISSÓRIA'),
                ('03', u'NOTA DE SEGURO'),
                ('04', u'MENSALIDADE ESCOLAR'),
        Severity: Major
        Found in br_boleto/models/payment_mode.py and 1 other location - About 2 hrs to fix
        br_account/models/cst.py on lines 44..58

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 57.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

        CST_IPI = [
            ('00', u'00 - Entrada com Recuperação de Crédito'),
            ('01', u'01 - Entrada Tributável com Alíquota Zero'),
            ('02', u'02 - Entrada Isenta'),
            ('03', u'03 - Entrada Não-Tributada'),
        Severity: Major
        Found in br_account/models/cst.py and 1 other location - About 2 hrs to fix
        br_boleto/models/payment_mode.py on lines 33..47

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 57.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        File nfse_imperial.py has 274 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        # -*- coding: utf-8 -*-
        # © 2017 Danimar Ribeiro <danimaribeiro@gmail.com>, Trustcode
        # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
        
        import re
        Severity: Minor
        Found in br_nfse/models/nfse_imperial.py - About 2 hrs to fix

          Function _prepare_invoice_line has 64 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              def _prepare_invoice_line(self, qty):
                  res = super(SaleOrderLine, self)._prepare_invoice_line(qty)
          
                  res['valor_desconto'] = self.valor_desconto
                  res['valor_bruto'] = self.valor_bruto
          Severity: Major
          Found in br_sale/models/sale.py - About 2 hrs to fix

            Identical blocks of code found in 4 locations. Consider refactoring.
            Open

                @api.multi
                def name_get(self):
                    result = []
                    for rec in self:
                        result.append((rec.id, "%s - %s" % (rec.code, rec.name or '')))
            Severity: Major
            Found in br_account/models/br_account.py and 3 other locations - About 2 hrs to fix
            br_account/models/br_account.py on lines 87..92
            br_account/models/br_account.py on lines 167..172
            br_account/models/product_fiscal_classification.py on lines 62..67

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 56.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Identical blocks of code found in 2 locations. Consider refactoring.
            Open

                    if self.total_edocs == 1:
                        edoc = self.env['invoice.eletronic'].search(
                            [('numero_controle', '=', self.numero_controle)], limit=1)
                        dummy, act_id = self.env['ir.model.data'].get_object_reference(
                            'br_account_einvoice', 'action_sped_base_eletronic_doc')
            Severity: Major
            Found in br_point_sale/models/pos_order.py and 1 other location - About 2 hrs to fix
            br_account_einvoice/models/account_invoice.py on lines 55..72

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 56.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Identical blocks of code found in 4 locations. Consider refactoring.
            Open

                @api.multi
                def name_get(self):
                    result = []
                    for rec in self:
                        result.append((rec.id, "%s - %s" % (rec.code, rec.name or '')))
            Severity: Major
            Found in br_account/models/br_account.py and 3 other locations - About 2 hrs to fix
            br_account/models/br_account.py on lines 50..55
            br_account/models/br_account.py on lines 167..172
            br_account/models/product_fiscal_classification.py on lines 62..67

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 56.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Identical blocks of code found in 4 locations. Consider refactoring.
            Open

                @api.multi
                def name_get(self):
                    result = []
                    for rec in self:
                        result.append((rec.id, "%s - %s" % (rec.code, rec.name or '')))
            Severity: Major
            Found in br_account/models/product_fiscal_classification.py and 3 other locations - About 2 hrs to fix
            br_account/models/br_account.py on lines 50..55
            br_account/models/br_account.py on lines 87..92
            br_account/models/br_account.py on lines 167..172

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 56.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Identical blocks of code found in 2 locations. Consider refactoring.
            Open

                    if self.total_edocs == 1:
                        dummy, act_id = self.env['ir.model.data'].get_object_reference(
                            'br_account_einvoice', 'action_sped_base_eletronic_doc')
                        dummy, view_id = self.env['ir.model.data'].get_object_reference(
                            'br_account_einvoice', 'br_account_invoice_eletronic_form')
            Severity: Major
            Found in br_account_einvoice/models/account_invoice.py and 1 other location - About 2 hrs to fix
            br_point_sale/models/pos_order.py on lines 189..207

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 56.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Identical blocks of code found in 4 locations. Consider refactoring.
            Open

                @api.multi
                def name_get(self):
                    result = []
                    for rec in self:
                        result.append((rec.id, "%s - %s" % (rec.code, rec.name or '')))
            Severity: Major
            Found in br_account/models/br_account.py and 3 other locations - About 2 hrs to fix
            br_account/models/br_account.py on lines 50..55
            br_account/models/br_account.py on lines 87..92
            br_account/models/product_fiscal_classification.py on lines 62..67

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 56.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

                        elif not self.is_company and len(val) == 11:
                            cnpj_cpf = "%s.%s.%s-%s"\
                                % (val[0:3], val[3:6], val[6:9], val[9:11])
                            self.cnpj_cpf = cnpj_cpf
            Severity: Major
            Found in br_base/models/res_partner.py and 1 other location - About 2 hrs to fix
            br_crm/models/crm_lead.py on lines 90..93

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 56.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Severity
            Category
            Status
            Source
            Language