osbzr/gooderp_addons

View on GitHub
warehouse/models/inventory.py

Summary

Maintainability
D
1 day
Test Coverage

File inventory.py has 408 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# -*- coding: utf-8 -*-

from odoo.osv import osv
# from odoo.osv import fields
from utils import create_name, safe_division
Severity: Minor
Found in warehouse/models/inventory.py - About 5 hrs to fix

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

        def generate_inventory(self):
            for inventory in self:
                if self.state in ['done', 'confirmed']:
                    raise UserError(u'请不要重复点击生成盘点单据按钮')
                out_line, in_line = [], []
    Severity: Minor
    Found in warehouse/models/inventory.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 check_done has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

        def check_done(self):
            for inventory in self:
                if inventory.state == 'confirmed' and \
                    (not inventory.out_id or inventory.out_id.state == 'done') and \
                        (not inventory.in_id or inventory.in_id.state == 'done'):
    Severity: Minor
    Found in warehouse/models/inventory.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_line_detail has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

        def get_line_detail(self):
            for inventory in self:
                sql_text = '''
                    SELECT wh.id as warehouse_id,
                           goods.id as goods_id,
    Severity: Minor
    Found in warehouse/models/inventory.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 onchange_qty has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

        def onchange_qty(self):
            self.ensure_one()
    
            if self.goods_id and self.goods_id.using_batch:
                if self.goods_id.force_batch_one and self.difference_qty:
    Severity: Minor
    Found in warehouse/models/inventory.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 delete_confirmed_wh has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

        def delete_confirmed_wh(self):
            for inventory in self:
                if inventory.state == 'confirmed':
                    if (inventory.out_id and inventory.out_id.state == 'done') \
                            or (inventory.in_id and inventory.in_id.state == 'done'):
    Severity: Minor
    Found in warehouse/models/inventory.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_difference_qty has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def _get_difference_qty(self):
            for line in self:
                line.difference_qty = line.inventory_qty - line.real_qty
                line.difference_uos_qty = line.inventory_uos_qty - line.real_uos_qty
    
    
    Severity: Minor
    Found in warehouse/models/inventory.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 (103 > 79 characters)
    Open

                if float_is_zero(line.difference_qty, 2) and not float_is_zero(line.difference_uos_qty, 2):
    Severity: Minor
    Found in warehouse/models/inventory.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

        warehouse_id = fields.Many2one('warehouse', u'仓库', required=True, default=_get_default_warehouse,
    Severity: Minor
    Found in warehouse/models/inventory.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

                    (not inventory.out_id or inventory.out_id.state != 'done') and \
    Severity: Minor
    Found in warehouse/models/inventory.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

                line.difference_uos_qty = line.inventory_uos_qty - line.real_uos_qty
    Severity: Minor
    Found in warehouse/models/inventory.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 (90 > 79 characters)
    Open

        warehouse_id = fields.Many2one('warehouse', u'仓库', required=True, ondelete='restrict',
    Severity: Minor
    Found in warehouse/models/inventory.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 (82 > 79 characters)
    Open

        goods_id = fields.Many2one('goods', u'商品', required=True, ondelete='restrict',
    Severity: Minor
    Found in warehouse/models/inventory.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 (82 > 79 characters)
    Open

        @api.depends('inventory_qty', 'real_qty', 'inventory_uos_qty', 'real_uos_qty')
    Severity: Minor
    Found in warehouse/models/inventory.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 (81 > 79 characters)
    Open

                            or (inventory.in_id and inventory.in_id.state == 'done'):
    Severity: Minor
    Found in warehouse/models/inventory.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 (90 > 79 characters)
    Open

                if not float_is_zero(line.difference_qty, 2) and line.difference_uos_qty == 0:
    Severity: Minor
    Found in warehouse/models/inventory.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 (88 > 79 characters)
    Open

                    line.difference_uos_qty = line.difference_qty / line.goods_id.conversion
    Severity: Minor
    Found in warehouse/models/inventory.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

                    (not inventory.out_id or inventory.out_id.state == 'done') and \
    Severity: Minor
    Found in warehouse/models/inventory.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 (88 > 79 characters)
    Open

                    line.difference_qty = line.difference_uos_qty * line.goods_id.conversion
    Severity: Minor
    Found in warehouse/models/inventory.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

                line.difference_uos_qty = line.inventory_uos_qty - line.real_uos_qty
    Severity: Minor
    Found in warehouse/models/inventory.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