ingadhoc/odoo-argentina

View on GitHub
l10n_ar_invoice/models/invoice.py

Summary

Maintainability
F
4 days
Test Coverage

File invoice.py has 764 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# -*- coding: utf-8 -*-
##############################################################################
# For copyright and license notices, see __openerp__.py file in module root
# directory
##############################################################################
Severity: Major
Found in l10n_ar_invoice/models/invoice.py - About 1 day to fix

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

        def check_argentinian_invoice_taxes(self):
            """
            We make theis function to be used as a constraint but also to be called
            from other models like vat citi
            """
    Severity: Minor
    Found in l10n_ar_invoice/models/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

    account_invoice has 22 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class account_invoice(models.Model):
        _inherit = "account.invoice"
        _order = "afip_document_number desc, number desc, id desc"
    
        state_id = fields.Many2one(
    Severity: Minor
    Found in l10n_ar_invoice/models/invoice.py - About 2 hrs to fix

      Function _get_available_journal_document_class has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
      Open

          def _get_available_journal_document_class(self):
              invoice_type = self.type
              document_class_ids = []
              document_class_id = False
      
      
      Severity: Minor
      Found in l10n_ar_invoice/models/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 action_number has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
      Open

          def action_number(self):
              """
              A partir de este metodo no debería haber errores porque el modulo de
              factura electronica ya habria pedido el cae. Lo ideal sería hacer todo
              esto antes que se pida el cae pero tampoco se pueden volver a atras los
      Severity: Minor
      Found in l10n_ar_invoice/models/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 _get_invoice_number has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

          def _get_invoice_number(self):
              """ Funcion que calcula numero de punto de venta y numero de factura
              a partir del document number. Es utilizado principalmente por el modulo
              de vat ledger citi
              """
      Severity: Minor
      Found in l10n_ar_invoice/models/invoice.py - About 1 hr 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 _get_concept has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

          def _get_concept(self):
              afip_concept = False
              if self.point_of_sale_type in ['online', 'electronic']:
                  # exportaciones
                  product_types = set(
      Severity: Minor
      Found in l10n_ar_invoice/models/invoice.py - About 1 hr 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 get_valid_document_letters has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def get_valid_document_letters(
                  self, cr, uid, partner_id, operation_type='sale',
                  company_id=False, context=None):
              if context is None:
                  context = {}
      Severity: Minor
      Found in l10n_ar_invoice/models/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 get_valid_document_letters has 6 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def get_valid_document_letters(
      Severity: Minor
      Found in l10n_ar_invoice/models/invoice.py - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                                if not obj_inv.journal_document_class_id.sequence_id:
                                    raise Warning(
                                        _('Error!. Please define sequence on the journal related documents to this invoice.'))
                                afip_document_number = obj_sequence.next_by_id(
        Severity: Major
        Found in l10n_ar_invoice/models/invoice.py - About 45 mins to fix

          Function check_invoice_type_document_type has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

              def check_invoice_type_document_type(self):
                  for rec in self:
                      document_type = rec.document_type
                      invoice_type = rec.type
                      if not document_type:
          Severity: Minor
          Found in l10n_ar_invoice/models/invoice.py - About 25 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

              @api.one
              @api.depends('afip_document_number', 'number')
              def _get_document_number(self):
                  if self.afip_document_number and self.afip_document_class_id:
                      document_number = (
          Severity: Major
          Found in l10n_ar_invoice/models/invoice.py and 1 other location - About 2 hrs to fix
          l10n_ar_invoice/models/account.py on lines 201..216

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

          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

                  vat_exempt_amount = sum(vat_taxes.filtered(
                      lambda r: r.tax_code_id.afip_code == 2).mapped('base'))
          Severity: Minor
          Found in l10n_ar_invoice/models/invoice.py and 1 other location - About 55 mins to fix
          l10n_ar_invoice/models/invoice.py on lines 392..393

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

          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

                  vat_untaxed = sum(vat_taxes.filtered(
                      lambda r: r.tax_code_id.afip_code == 1).mapped('base'))
          Severity: Minor
          Found in l10n_ar_invoice/models/invoice.py and 1 other location - About 55 mins to fix
          l10n_ar_invoice/models/invoice.py on lines 389..390

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

          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