[IMP] pre-commit: first run on whole repo
This commit is contained in:
@@ -2,44 +2,66 @@
|
||||
# @author: Alexis de Lattre <alexis.delattre@akretion.com>
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
|
||||
|
||||
from odoo import api, fields, models, _
|
||||
from odoo import _, fields, models
|
||||
from odoo.tools import float_compare, float_is_zero
|
||||
|
||||
|
||||
class StockInventory(models.Model):
|
||||
_inherit = 'stock.inventory'
|
||||
_inherit = "stock.inventory"
|
||||
|
||||
prefill_counted_quantity = fields.Selection(
|
||||
readonly=True, states={'draft': [('readonly', False)]})
|
||||
readonly=True, states={"draft": [("readonly", False)]}
|
||||
)
|
||||
|
||||
|
||||
class StockInventoryLine(models.Model):
|
||||
_inherit = 'stock.inventory.line'
|
||||
_inherit = "stock.inventory.line"
|
||||
|
||||
product_barcode = fields.Char(related='product_id.barcode', string="Product Barcode")
|
||||
product_barcode = fields.Char(
|
||||
related="product_id.barcode", string="Product Barcode"
|
||||
)
|
||||
difference_qty = fields.Float(search="_search_difference_qty_usability")
|
||||
|
||||
def _search_difference_qty_usability(self, operator, value):
|
||||
# Inspired by the method _search_difference_qty() from the
|
||||
# official stock module
|
||||
# So a part of this code is copyright Odoo SA under LGPL licence
|
||||
if not self.env.context.get('default_inventory_id'):
|
||||
raise NotImplementedError(_('Unsupported search on %s outside of an Inventory Adjustment', 'difference_qty'))
|
||||
lines = self.search([('inventory_id', '=', self.env.context.get('default_inventory_id'))])
|
||||
if not self.env.context.get("default_inventory_id"):
|
||||
raise NotImplementedError(
|
||||
_(
|
||||
"Unsupported search on %s outside of an Inventory Adjustment",
|
||||
"difference_qty",
|
||||
)
|
||||
)
|
||||
lines = self.search(
|
||||
[("inventory_id", "=", self.env.context.get("default_inventory_id"))]
|
||||
)
|
||||
line_ids = []
|
||||
for line in lines:
|
||||
if operator == '=':
|
||||
if operator == "=":
|
||||
if float_is_zero(line.difference_qty, line.product_id.uom_id.rounding):
|
||||
line_ids.append(line.id)
|
||||
elif operator == '!=':
|
||||
if not float_is_zero(line.difference_qty, line.product_id.uom_id.rounding):
|
||||
elif operator == "!=":
|
||||
if not float_is_zero(
|
||||
line.difference_qty, line.product_id.uom_id.rounding
|
||||
):
|
||||
line_ids.append(line.id)
|
||||
elif operator == '>':
|
||||
if float_compare(line.difference_qty, 0, line.product_id.uom_id.rounding) > 0:
|
||||
elif operator == ">":
|
||||
if (
|
||||
float_compare(
|
||||
line.difference_qty, 0, line.product_id.uom_id.rounding
|
||||
)
|
||||
> 0
|
||||
):
|
||||
line_ids.append(line.id)
|
||||
elif operator == '<':
|
||||
if float_compare(line.difference_qty, 0, line.product_id.uom_id.rounding) < 0:
|
||||
elif operator == "<":
|
||||
if (
|
||||
float_compare(
|
||||
line.difference_qty, 0, line.product_id.uom_id.rounding
|
||||
)
|
||||
< 0
|
||||
):
|
||||
line_ids.append(line.id)
|
||||
else:
|
||||
raise NotImplementedError()
|
||||
return [('id', 'in', line_ids)]
|
||||
return [("id", "in", line_ids)]
|
||||
|
||||
Reference in New Issue
Block a user