Trust-Code/odoo-brasil

View on GitHub
br_account/models/account_invoice.py

Summary

Maintainability
F
4 days
Test Coverage

File account_invoice.py has 394 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# -*- coding: utf-8 -*-
# © 2009 Renato Lima - Akretion
# © 2016 Danimar Ribeiro, Trustcode
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

Severity: Minor
Found in br_account/models/account_invoice.py - About 5 hrs to fix

    Function invoice_line_move_line_get has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
    Open

        def invoice_line_move_line_get(self):
            res = super(AccountInvoice, self).invoice_line_move_line_get()
    
            contador = 0
    
    
    Severity: Minor
    Found in br_account/models/account_invoice.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 _compute_amount has 42 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def _compute_amount(self):
            super(AccountInvoice, self)._compute_amount()
            lines = self.invoice_line_ids
            self.total_tax = sum(l.price_tax for l in lines)
            self.icms_base = sum(l.icms_base_calculo for l in lines)
    Severity: Minor
    Found in br_account/models/account_invoice.py - About 1 hr to fix

      Function get_taxes_values has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def get_taxes_values(self):
              tax_grouped = {}
              for line in self.invoice_line_ids:
                  other_taxes = line.invoice_line_tax_ids.filtered(
                      lambda x: not x.domain)
      Severity: Minor
      Found in br_account/models/account_invoice.py - About 45 mins 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 _prepare_refund has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def _prepare_refund(self, invoice, date_invoice=None, date=None,
      Severity: Minor
      Found in br_account/models/account_invoice.py - About 35 mins to fix

        Function _compute_amount has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            def _compute_amount(self):
                super(AccountInvoice, self)._compute_amount()
                lines = self.invoice_line_ids
                self.total_tax = sum(l.price_tax for l in lines)
                self.icms_base = sum(l.icms_base_calculo for l in lines)
        Severity: Minor
        Found in br_account/models/account_invoice.py - About 35 mins 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 tax_line_move_line_get has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            def tax_line_move_line_get(self):
                res = super(AccountInvoice, self).tax_line_move_line_get()
        
                done_taxes = []
                for tax_line in sorted(self.tax_line_ids, key=lambda x: -x.sequence):
        Severity: Minor
        Found in br_account/models/account_invoice.py - About 35 mins 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

                    line.invoice_line_tax_ids = other_taxes | line.tax_icms_id | \
                        line.tax_ipi_id | line.tax_pis_id | line.tax_cofins_id | \
                        line.tax_issqn_id | line.tax_ii_id | line.tax_icms_st_id | \
                        line.tax_simples_id | line.tax_csll_id | line.tax_irrf_id | \
                        line.tax_inss_id
        Severity: Major
        Found in br_account/models/account_invoice.py and 1 other location - About 5 hrs to fix
        br_account/models/account_invoice_line.py on lines 569..573

        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 89.

        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

            @api.one
            @api.depends('move_id.line_ids')
            def _compute_receivables(self):
                receivable_lines = []
                for line in self.move_id.line_ids:
        Severity: Major
        Found in br_account/models/account_invoice.py and 1 other location - About 5 hrs to fix
        br_account/models/account_invoice.py on lines 108..116

        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 88.

        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

            @api.one
            @api.depends('move_id.line_ids')
            def _compute_payables(self):
                payable_lines = []
                for line in self.move_id.line_ids:
        Severity: Major
        Found in br_account/models/account_invoice.py and 1 other location - About 5 hrs to fix
        br_account/models/account_invoice.py on lines 98..106

        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 88.

        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 6 locations. Consider refactoring.
        Open

                self.cofins_retention = sum(
                    abs(l.cofins_valor) if l.cofins_valor < 0 else 0.0 for l in lines)
        Severity: Major
        Found in br_account/models/account_invoice.py and 5 other locations - About 1 hr to fix
        br_account/models/account_invoice.py on lines 68..69
        br_account/models/account_invoice.py on lines 70..71
        br_account/models/account_invoice.py on lines 74..75
        br_account/models/account_invoice.py on lines 76..77
        br_account/models/account_invoice.py on lines 78..79

        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 39.

        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 6 locations. Consider refactoring.
        Open

                self.csll_retention = sum(
                    abs(l.csll_valor) if l.csll_valor < 0 else 0 for l in lines)
        Severity: Major
        Found in br_account/models/account_invoice.py and 5 other locations - About 1 hr to fix
        br_account/models/account_invoice.py on lines 68..69
        br_account/models/account_invoice.py on lines 70..71
        br_account/models/account_invoice.py on lines 72..73
        br_account/models/account_invoice.py on lines 76..77
        br_account/models/account_invoice.py on lines 78..79

        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 39.

        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 6 locations. Consider refactoring.
        Open

                self.pis_retention = sum(
                    abs(l.pis_valor) if l.pis_valor < 0 else 0.0 for l in lines)
        Severity: Major
        Found in br_account/models/account_invoice.py and 5 other locations - About 1 hr to fix
        br_account/models/account_invoice.py on lines 68..69
        br_account/models/account_invoice.py on lines 72..73
        br_account/models/account_invoice.py on lines 74..75
        br_account/models/account_invoice.py on lines 76..77
        br_account/models/account_invoice.py on lines 78..79

        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 39.

        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 6 locations. Consider refactoring.
        Open

                self.irrf_retention = sum(
                    abs(l.irrf_valor) if l.irrf_valor < 0 else 0.0 for l in lines)
        Severity: Major
        Found in br_account/models/account_invoice.py and 5 other locations - About 1 hr to fix
        br_account/models/account_invoice.py on lines 68..69
        br_account/models/account_invoice.py on lines 70..71
        br_account/models/account_invoice.py on lines 72..73
        br_account/models/account_invoice.py on lines 74..75
        br_account/models/account_invoice.py on lines 78..79

        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 39.

        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 6 locations. Consider refactoring.
        Open

                self.issqn_retention = sum(
                    abs(l.issqn_valor) if l.issqn_valor < 0 else 0.0 for l in lines)
        Severity: Major
        Found in br_account/models/account_invoice.py and 5 other locations - About 1 hr to fix
        br_account/models/account_invoice.py on lines 70..71
        br_account/models/account_invoice.py on lines 72..73
        br_account/models/account_invoice.py on lines 74..75
        br_account/models/account_invoice.py on lines 76..77
        br_account/models/account_invoice.py on lines 78..79

        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 39.

        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 6 locations. Consider refactoring.
        Open

                self.inss_retention = sum(
                    abs(l.inss_valor) if l.inss_valor < 0 else 0.0 for l in lines)
        Severity: Major
        Found in br_account/models/account_invoice.py and 5 other locations - About 1 hr to fix
        br_account/models/account_invoice.py on lines 68..69
        br_account/models/account_invoice.py on lines 70..71
        br_account/models/account_invoice.py on lines 72..73
        br_account/models/account_invoice.py on lines 74..75
        br_account/models/account_invoice.py on lines 76..77

        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 39.

        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

            vendor_serie = fields.Char(
                u'Série NF Entrada', size=12, readonly=True,
                states={'draft': [('readonly', False)]},
        Severity: Minor
        Found in br_account/models/account_invoice.py and 1 other location - About 35 mins to fix
        br_account/models/account_invoice.py on lines 143..145

        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 33.

        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

            vendor_number = fields.Char(
                u'Número NF Entrada', size=18, readonly=True,
                states={'draft': [('readonly', False)]},
        Severity: Minor
        Found in br_account/models/account_invoice.py and 1 other location - About 35 mins to fix
        br_account/models/account_invoice.py on lines 147..149

        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 33.

        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 7 locations. Consider refactoring.
        Open

                    price_unit = line.price_unit * (1 - (line.discount or 0.0) / 100.0)
        Severity: Major
        Found in br_account/models/account_invoice.py and 6 other locations - About 30 mins to fix
        br_account/models/account_invoice.py on lines 337..338
        br_account/models/account_invoice_line.py on lines 68..68
        br_point_sale/models/pos_order.py on lines 216..216
        br_point_sale/models/pos_order.py on lines 287..287
        br_purchase/models/purchase.py on lines 79..79
        br_sale/models/sale.py on lines 84..84

        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 32.

        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 7 locations. Consider refactoring.
        Open

                    price = line.price_unit * (1 - (
                        line.discount or 0.0) / 100.0)
        Severity: Major
        Found in br_account/models/account_invoice.py and 6 other locations - About 30 mins to fix
        br_account/models/account_invoice.py on lines 390..390
        br_account/models/account_invoice_line.py on lines 68..68
        br_point_sale/models/pos_order.py on lines 216..216
        br_point_sale/models/pos_order.py on lines 287..287
        br_purchase/models/purchase.py on lines 79..79
        br_sale/models/sale.py on lines 84..84

        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 32.

        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

        There are no issues that match your filters.

        Category
        Status