akretion/odoo-shopinvader

View on GitHub
product_stock_state/models/product_template.py

Summary

Maintainability
B
5 hrs
Test Coverage
Similar blocks of code found in 2 locations. Consider refactoring.
# -*- coding: utf-8 -*-
Similar blocks of code found in 2 locations. Consider refactoring.
# Copyright 2017-Today GRAP (http://www.grap.coop).
Similar blocks of code found in 2 locations. Consider refactoring.
# Copyright 2018 ACSONE SA/NV
Similar blocks of code found in 2 locations. Consider refactoring.
# Copyright 2018 Akretion (http://www.akretion.com).
Similar blocks of code found in 2 locations. Consider refactoring.
# @author Sylvain LE GAL <https://twitter.com/legalsylvain>
Similar blocks of code found in 2 locations. Consider refactoring.
# @author Sébastien BEAU <sebastien.beau@akretion.com>
Similar blocks of code found in 2 locations. Consider refactoring.
# @author Laurent Mignon <laurent.mignon@acsone.com>
Similar blocks of code found in 2 locations. Consider refactoring.
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
Similar blocks of code found in 2 locations. Consider refactoring.
 
Similar blocks of code found in 2 locations. Consider refactoring.
from odoo import api, fields, models
Similar blocks of code found in 2 locations. Consider refactoring.
 
Similar blocks of code found in 2 locations. Consider refactoring.
 
Similar blocks of code found in 2 locations. Consider refactoring.
class ProductTemplate(models.Model):
Similar blocks of code found in 2 locations. Consider refactoring.
_inherit = "product.template"
Similar blocks of code found in 2 locations. Consider refactoring.
 
Similar blocks of code found in 2 locations. Consider refactoring.
stock_state_threshold = fields.Float(
Similar blocks of code found in 2 locations. Consider refactoring.
compute="_compute_stock_state_threshold",
Similar blocks of code found in 2 locations. Consider refactoring.
store=True,
Similar blocks of code found in 2 locations. Consider refactoring.
help="Define custom value under wich the stock state will pass from"
Similar blocks of code found in 2 locations. Consider refactoring.
" 'In Stock' to 'In Limited Stock' State. If not set, Odoo will"
Similar blocks of code found in 2 locations. Consider refactoring.
" use the value defined in the product category. If"
Similar blocks of code found in 2 locations. Consider refactoring.
" no value is defined in product category, it will use the value"
Similar blocks of code found in 2 locations. Consider refactoring.
" defined for the company",
Similar blocks of code found in 2 locations. Consider refactoring.
)
Similar blocks of code found in 2 locations. Consider refactoring.
 
Similar blocks of code found in 2 locations. Consider refactoring.
manual_stock_state_threshold = fields.Float()
Similar blocks of code found in 2 locations. Consider refactoring.
 
Similar blocks of code found in 2 locations. Consider refactoring.
@api.multi
Similar blocks of code found in 2 locations. Consider refactoring.
@api.depends(
Similar blocks of code found in 2 locations. Consider refactoring.
"categ_id.stock_state_threshold", "manual_stock_state_threshold"
Similar blocks of code found in 2 locations. Consider refactoring.
)
Similar blocks of code found in 2 locations. Consider refactoring.
def _compute_stock_state_threshold(self):
Similar blocks of code found in 2 locations. Consider refactoring.
for rec in self:
Similar blocks of code found in 2 locations. Consider refactoring.
rec.stock_state_threshold = (
Similar blocks of code found in 2 locations. Consider refactoring.
rec.manual_stock_state_threshold
Similar blocks of code found in 2 locations. Consider refactoring.
or rec.categ_id.stock_state_threshold
Similar blocks of code found in 2 locations. Consider refactoring.
)