osbzr/gooderp_addons

View on GitHub
warehouse/models/goods.py

Summary

Maintainability
C
7 hrs
Test Coverage

Function get_matching_records has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
Open

    def get_matching_records(self, warehouse, qty, uos_qty=0, attribute=None,
                             ignore_stock=False, ignore=None, move_line=False):
        """
        获取匹配记录,不考虑批号
        :param ignore_stock: 当参数指定为True的时候,此时忽略库存警告
Severity: Minor
Found in warehouse/models/goods.py - About 4 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_matching_records has 7 arguments (exceeds 4 allowed). Consider refactoring.
Open

    def get_matching_records(self, warehouse, qty, uos_qty=0, attribute=None,
Severity: Major
Found in warehouse/models/goods.py - About 50 mins to fix

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

        def _get_cost(self, warehouse=None, ignore=None):
            # 如果没有历史的剩余数量,计算最后一条move的成本
            # 存在一种情况,计算一条line的成本的时候,先done掉该line,之后在通过该函数
            # 查询成本,此时百分百搜到当前的line,所以添加ignore参数来忽略掉指定的line
            self.ensure_one()
    Severity: Minor
    Found in warehouse/models/goods.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_suggested_cost_by_warehouse has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def get_suggested_cost_by_warehouse(
    Severity: Minor
    Found in warehouse/models/goods.py - About 35 mins to fix

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

          def get_suggested_cost_by_warehouse(
                  self, warehouse, qty, lot_id=None, attribute=None, ignore_move=None):
              # 存在一种情况,计算一条line的成本的时候,先done掉该line,之后在通过该函数
              # 查询成本,此时百分百搜到当前的line,所以添加ignore参数来忽略掉指定的line
              if lot_id:
      Severity: Minor
      Found in warehouse/models/goods.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

      Line too long (81 > 79 characters)
      Open

                  self, warehouse, qty, lot_id=None, attribute=None, ignore_move=None):
      Severity: Minor
      Found in warehouse/models/goods.py by pep8

      Limit all lines to a maximum of 79 characters.

      There are still many devices around that are limited to 80 character
      lines; plus, limiting windows to 80 characters makes it possible to
      have several windows side-by-side.  The default wrapping on such
      devices looks ugly.  Therefore, please limit all lines to a maximum
      of 79 characters. For flowing long blocks of text (docstrings or
      comments), limiting the length to 72 characters is recommended.
      
      Reports error E501.

      Line too long (85 > 79 characters)
      Open

              if qty > lot_id.qty_remaining and not self.env.context.get('wh_in_line_ids'):
      Severity: Minor
      Found in warehouse/models/goods.py by pep8

      Limit all lines to a maximum of 79 characters.

      There are still many devices around that are limited to 80 character
      lines; plus, limiting windows to 80 characters makes it possible to
      have several windows side-by-side.  The default wrapping on such
      devices looks ugly.  Therefore, please limit all lines to a maximum
      of 79 characters. For flowing long blocks of text (docstrings or
      comments), limiting the length to 72 characters is recommended.
      
      Reports error E501.

      Line too long (86 > 79 characters)
      Open

                             sum(line.qty_remaining * (line.cost / line.goods_qty)) as cost,
      Severity: Minor
      Found in warehouse/models/goods.py by pep8

      Limit all lines to a maximum of 79 characters.

      There are still many devices around that are limited to 80 character
      lines; plus, limiting windows to 80 characters makes it possible to
      have several windows side-by-side.  The default wrapping on such
      devices looks ugly.  Therefore, please limit all lines to a maximum
      of 79 characters. For flowing long blocks of text (docstrings or
      comments), limiting the length to 72 characters is recommended.
      
      Reports error E501.

      Line too long (80 > 79 characters)
      Open

              self.current_qty = sum(line.get('qty') for line in self.get_stock_qty())
      Severity: Minor
      Found in warehouse/models/goods.py by pep8

      Limit all lines to a maximum of 79 characters.

      There are still many devices around that are limited to 80 character
      lines; plus, limiting windows to 80 characters makes it possible to
      have several windows side-by-side.  The default wrapping on such
      devices looks ugly.  Therefore, please limit all lines to a maximum
      of 79 characters. For flowing long blocks of text (docstrings or
      comments), limiting the length to 72 characters is recommended.
      
      Reports error E501.

      Line too long (91 > 79 characters)
      Open

                                               'qty': matching_qty, 'uos_qty': matching_uos_qty})
      Severity: Minor
      Found in warehouse/models/goods.py by pep8

      Limit all lines to a maximum of 79 characters.

      There are still many devices around that are limited to 80 character
      lines; plus, limiting windows to 80 characters makes it possible to
      have several windows side-by-side.  The default wrapping on such
      devices looks ugly.  Therefore, please limit all lines to a maximum
      of 79 characters. For flowing long blocks of text (docstrings or
      comments), limiting the length to 72 characters is recommended.
      
      Reports error E501.

      Line too long (101 > 79 characters)
      Open

                      if not ignore_stock and qty_to_go > 0 and not self.env.context.get('wh_in_line_ids'):
      Severity: Minor
      Found in warehouse/models/goods.py by pep8

      Limit all lines to a maximum of 79 characters.

      There are still many devices around that are limited to 80 character
      lines; plus, limiting windows to 80 characters makes it possible to
      have several windows side-by-side.  The default wrapping on such
      devices looks ugly.  Therefore, please limit all lines to a maximum
      of 79 characters. For flowing long blocks of text (docstrings or
      comments), limiting the length to 72 characters is recommended.
      
      Reports error E501.

      Line too long (85 > 79 characters)
      Open

                  qty_to_go, uos_qty_to_go, cost = qty, uos_qty, 0    # 分别为待出库商品的数量、辅助数量和成本
      Severity: Minor
      Found in warehouse/models/goods.py by pep8

      Limit all lines to a maximum of 79 characters.

      There are still many devices around that are limited to 80 character
      lines; plus, limiting windows to 80 characters makes it possible to
      have several windows side-by-side.  The default wrapping on such
      devices looks ugly.  Therefore, please limit all lines to a maximum
      of 79 characters. For flowing long blocks of text (docstrings or
      comments), limiting the length to 72 characters is recommended.
      
      Reports error E501.

      Line too long (104 > 79 characters)
      Open

                      matching_records.append({'line_in_id': line.id, 'expiration_date': line.expiration_date,
      Severity: Minor
      Found in warehouse/models/goods.py by pep8

      Limit all lines to a maximum of 79 characters.

      There are still many devices around that are limited to 80 character
      lines; plus, limiting windows to 80 characters makes it possible to
      have several windows side-by-side.  The default wrapping on such
      devices looks ugly.  Therefore, please limit all lines to a maximum
      of 79 characters. For flowing long blocks of text (docstrings or
      comments), limiting the length to 72 characters is recommended.
      
      Reports error E501.

      Line too long (83 > 79 characters)
      Open

                          domain = [('id', 'in', self.env.context.get('wh_in_line_ids')),
      Severity: Minor
      Found in warehouse/models/goods.py by pep8

      Limit all lines to a maximum of 79 characters.

      There are still many devices around that are limited to 80 character
      lines; plus, limiting windows to 80 characters makes it possible to
      have several windows side-by-side.  The default wrapping on such
      devices looks ugly.  Therefore, please limit all lines to a maximum
      of 79 characters. For flowing long blocks of text (docstrings or
      comments), limiting the length to 72 characters is recommended.
      
      Reports error E501.

      Line too long (92 > 79 characters)
      Open

                  if not self.env.context.get('location') and move_line and move_line.location_id:
      Severity: Minor
      Found in warehouse/models/goods.py by pep8

      Limit all lines to a maximum of 79 characters.

      There are still many devices around that are limited to 80 character
      lines; plus, limiting windows to 80 characters makes it possible to
      have several windows side-by-side.  The default wrapping on such
      devices looks ugly.  Therefore, please limit all lines to a maximum
      of 79 characters. For flowing long blocks of text (docstrings or
      comments), limiting the length to 72 characters is recommended.
      
      Reports error E501.

      Line too long (83 > 79 characters)
      Open

          def get_matching_records_by_lot(self, lot_id, qty, uos_qty=0, suggested=False):
      Severity: Minor
      Found in warehouse/models/goods.py by pep8

      Limit all lines to a maximum of 79 characters.

      There are still many devices around that are limited to 80 character
      lines; plus, limiting windows to 80 characters makes it possible to
      have several windows side-by-side.  The default wrapping on such
      devices looks ugly.  Therefore, please limit all lines to a maximum
      of 79 characters. For flowing long blocks of text (docstrings or
      comments), limiting the length to 72 characters is recommended.
      
      Reports error E501.

      Line too long (124 > 79 characters)
      Open

                              matching_records.append({'line_in_id': line_in_id.id, 'expiration_date': line_in_id.expiration_date,
      Severity: Minor
      Found in warehouse/models/goods.py by pep8

      Limit all lines to a maximum of 79 characters.

      There are still many devices around that are limited to 80 character
      lines; plus, limiting windows to 80 characters makes it possible to
      have several windows side-by-side.  The default wrapping on such
      devices looks ugly.  Therefore, please limit all lines to a maximum
      of 79 characters. For flowing long blocks of text (docstrings or
      comments), limiting the length to 72 characters is recommended.
      
      Reports error E501.

      Line too long (93 > 79 characters)
      Open

                                                       'qty': qty_to_go, 'uos_qty': uos_qty_to_go})
      Severity: Minor
      Found in warehouse/models/goods.py by pep8

      Limit all lines to a maximum of 79 characters.

      There are still many devices around that are limited to 80 character
      lines; plus, limiting windows to 80 characters makes it possible to
      have several windows side-by-side.  The default wrapping on such
      devices looks ugly.  Therefore, please limit all lines to a maximum
      of 79 characters. For flowing long blocks of text (docstrings or
      comments), limiting the length to 72 characters is recommended.
      
      Reports error E501.

      Line too long (105 > 79 characters)
      Open

          current_qty = fields.Float(u'当前数量', compute='compute_stock_qty', digits=dp.get_precision('Quantity'))
      Severity: Minor
      Found in warehouse/models/goods.py by pep8

      Limit all lines to a maximum of 79 characters.

      There are still many devices around that are limited to 80 character
      lines; plus, limiting windows to 80 characters makes it possible to
      have several windows side-by-side.  The default wrapping on such
      devices looks ugly.  Therefore, please limit all lines to a maximum
      of 79 characters. For flowing long blocks of text (docstrings or
      comments), limiting the length to 72 characters is recommended.
      
      Reports error E501.

      Line too long (91 > 79 characters)
      Open

                      warehouse, qty, attribute=attribute, ignore_stock=True, ignore=ignore_move)
      Severity: Minor
      Found in warehouse/models/goods.py by pep8

      Limit all lines to a maximum of 79 characters.

      There are still many devices around that are limited to 80 character
      lines; plus, limiting windows to 80 characters makes it possible to
      have several windows side-by-side.  The default wrapping on such
      devices looks ugly.  Therefore, please limit all lines to a maximum
      of 79 characters. For flowing long blocks of text (docstrings or
      comments), limiting the length to 72 characters is recommended.
      
      Reports error E501.

      Line too long (106 > 79 characters)
      Open

                  if (vals.get('uom_id') or vals.get('uos_id') or vals.get('conversion')) and goods.current_qty:
      Severity: Minor
      Found in warehouse/models/goods.py by pep8

      Limit all lines to a maximum of 79 characters.

      There are still many devices around that are limited to 80 character
      lines; plus, limiting windows to 80 characters makes it possible to
      have several windows side-by-side.  The default wrapping on such
      devices looks ugly.  Therefore, please limit all lines to a maximum
      of 79 characters. For flowing long blocks of text (docstrings or
      comments), limiting the length to 72 characters is recommended.
      
      Reports error E501.

      There are no issues that match your filters.

      Category
      Status