Remove computed unit digits fields for stock quantity
The unit field can be used directly as digits.
This commit is contained in:
@@ -101,8 +101,6 @@ class Template(
|
||||
fields.Many2One('product.uom.category', 'Default UOM Category'),
|
||||
'on_change_with_default_uom_category',
|
||||
searcher='search_default_uom_category')
|
||||
default_uom_digits = fields.Function(fields.Integer("Default Unit Digits"),
|
||||
'on_change_with_default_uom_digits')
|
||||
categories = fields.Many2Many(
|
||||
'product.template-product.category', 'template', 'category',
|
||||
"Categories",
|
||||
@@ -233,11 +231,6 @@ class Template(
|
||||
def search_default_uom_category(cls, name, clause):
|
||||
return [('default_uom.category' + clause[0][len(name):], *clause[1:])]
|
||||
|
||||
@fields.depends('default_uom')
|
||||
def on_change_with_default_uom_digits(self, name=None):
|
||||
if self.default_uom:
|
||||
return self.default_uom.digits
|
||||
|
||||
@classmethod
|
||||
def _new_code(cls):
|
||||
pool = Pool()
|
||||
|
||||
@@ -71,10 +71,8 @@ class PurchaseRequest(ModelSQL, ModelView):
|
||||
supply_date = fields.Date('Expected Supply Date', readonly=True)
|
||||
default_uom = fields.Function(fields.Many2One(
|
||||
'product.uom', "Default UOM"), 'on_change_with_default_uom')
|
||||
default_uom_digits = fields.Function(fields.Integer('Default UOM Digits'),
|
||||
'on_change_with_default_uom_digits')
|
||||
stock_level = fields.Float('Stock at Supply Date', readonly=True,
|
||||
digits=(16, Eval('default_uom_digits', 2)))
|
||||
stock_level = fields.Float(
|
||||
"Stock at Supply Date", readonly=True, digits='default_uom')
|
||||
warehouse = fields.Many2One(
|
||||
'stock.location', "Warehouse",
|
||||
states={
|
||||
@@ -245,12 +243,6 @@ class PurchaseRequest(ModelSQL, ModelView):
|
||||
def on_change_with_default_uom(self, name=None):
|
||||
return self.product.default_uom if self.product else None
|
||||
|
||||
@fields.depends('product')
|
||||
def on_change_with_default_uom_digits(self, name=None):
|
||||
if self.product:
|
||||
return self.product.default_uom.digits
|
||||
return 2
|
||||
|
||||
@fields.depends('description')
|
||||
def on_change_with_summary(self, name=None):
|
||||
return firstline(self.description or '')
|
||||
|
||||
@@ -686,18 +686,14 @@ class ProductsByLocations(DeactivableMixin, ModelSQL, ModelView):
|
||||
|
||||
product = fields.Many2One('product.product', "Product")
|
||||
quantity = fields.Function(
|
||||
fields.Float(
|
||||
"Quantity", digits=(16, Eval('default_uom_digits', 2))),
|
||||
fields.Float("Quantity", digits='default_uom'),
|
||||
'get_product', searcher='search_product')
|
||||
forecast_quantity = fields.Function(
|
||||
fields.Float(
|
||||
"Forecast Quantity", digits=(16, Eval('default_uom_digits', 2))),
|
||||
fields.Float("Forecast Quantity", digits='default_uom'),
|
||||
'get_product', searcher='search_product')
|
||||
default_uom = fields.Function(
|
||||
fields.Many2One('product.uom', "Default UOM"),
|
||||
'get_product', searcher='search_product')
|
||||
default_uom_digits = fields.Function(
|
||||
fields.Integer("Default UOM Digits"), 'get_product')
|
||||
cost_value = fields.Function(
|
||||
fields.Numeric("Cost Value"), 'get_product')
|
||||
consumable = fields.Function(
|
||||
|
||||
@@ -147,14 +147,20 @@ def check_no_stock_if_inactive(func):
|
||||
|
||||
class Template(metaclass=PoolMeta):
|
||||
__name__ = "product.template"
|
||||
quantity = fields.Function(fields.Float('Quantity',
|
||||
help="The amount of stock in the location."),
|
||||
quantity = fields.Function(
|
||||
fields.Float(
|
||||
"Quantity", digits='default_uom',
|
||||
help="The amount of stock in the location."),
|
||||
'sum_product')
|
||||
forecast_quantity = fields.Function(fields.Float('Forecast Quantity',
|
||||
help="The amount of stock expected to be in the location."),
|
||||
forecast_quantity = fields.Function(
|
||||
fields.Float(
|
||||
"Forecast Quantity", digits='default_uom',
|
||||
help="The amount of stock expected to be in the location."),
|
||||
'sum_product')
|
||||
cost_value = fields.Function(fields.Numeric('Cost Value',
|
||||
help="The value of the stock in the location."),
|
||||
cost_value = fields.Function(
|
||||
fields.Numeric(
|
||||
"Cost Value", digits=price_digits,
|
||||
help="The value of the stock in the location."),
|
||||
'sum_product')
|
||||
|
||||
def sum_product(self, name):
|
||||
@@ -191,11 +197,11 @@ class Template(metaclass=PoolMeta):
|
||||
class Product(StockMixin, object, metaclass=PoolMeta):
|
||||
__name__ = "product.product"
|
||||
quantity = fields.Function(fields.Float(
|
||||
"Quantity", digits=(16, Eval('default_uom_digits', 2)),
|
||||
"Quantity", digits='default_uom',
|
||||
help="The amount of stock in the location."),
|
||||
'get_quantity', searcher='search_quantity')
|
||||
forecast_quantity = fields.Function(fields.Float(
|
||||
"Forecast Quantity", digits=(16, Eval('default_uom_digits', 2)),
|
||||
"Forecast Quantity", digits='default_uom',
|
||||
help="The amount of stock expected to be in the location."),
|
||||
'get_quantity', searcher='search_quantity')
|
||||
cost_value = fields.Function(fields.Numeric(
|
||||
|
||||
@@ -78,15 +78,15 @@ class Lot(DeactivableMixin, ModelSQL, ModelView, LotMixin, StockMixin):
|
||||
__name__ = 'stock.lot'
|
||||
_rec_name = 'number'
|
||||
|
||||
quantity = fields.Function(fields.Float('Quantity'), 'get_quantity',
|
||||
searcher='search_quantity')
|
||||
forecast_quantity = fields.Function(fields.Float('Forecast Quantity'),
|
||||
quantity = fields.Function(
|
||||
fields.Float("Quantity", digits='default_uom'),
|
||||
'get_quantity', searcher='search_quantity')
|
||||
forecast_quantity = fields.Function(
|
||||
fields.Float("Forecast Quantity", digits='default_uom'),
|
||||
'get_quantity', searcher='search_quantity')
|
||||
default_uom = fields.Function(
|
||||
fields.Many2One('product.uom', "Default UOM"),
|
||||
'on_change_with_default_uom')
|
||||
default_uom_digits = fields.Function(fields.Integer("Default Unit Digits"),
|
||||
'on_change_with_default_uom_digits')
|
||||
|
||||
@classmethod
|
||||
def __setup__(cls):
|
||||
@@ -125,11 +125,6 @@ class Lot(DeactivableMixin, ModelSQL, ModelView, LotMixin, StockMixin):
|
||||
def on_change_with_default_uom(self, name=None):
|
||||
return self.product.default_uom if self.product else None
|
||||
|
||||
@fields.depends('product')
|
||||
def on_change_with_default_uom_digits(self, name=None):
|
||||
if self.product:
|
||||
return self.product.default_uom.digits
|
||||
|
||||
@classmethod
|
||||
def copy(cls, lots, default=None):
|
||||
default = default.copy() if default else {}
|
||||
@@ -305,18 +300,14 @@ class LotsByLocations(ModelSQL, ModelView):
|
||||
lot = fields.Many2One('stock.lot', "Lot")
|
||||
product = fields.Many2One('product.product', "Product")
|
||||
quantity = fields.Function(
|
||||
fields.Float(
|
||||
"Quantity", digits=(16, Eval('default_uom_digits', 2))),
|
||||
fields.Float("Quantity", digits='default_uom'),
|
||||
'get_lot', searcher='search_lot')
|
||||
forecast_quantity = fields.Function(
|
||||
fields.Float(
|
||||
"Forecast Quantity", digits=(16, Eval('default_uom_digits', 2))),
|
||||
fields.Float("Forecast Quantity", digits='default_uom'),
|
||||
'get_lot', searcher='search_lot')
|
||||
default_uom = fields.Function(
|
||||
fields.Many2One('product.uom', "Default UOM"),
|
||||
'get_lot', searcher='search_lot')
|
||||
default_uom_digits = fields.Function(
|
||||
fields.Integer("Default UOM Digits"), 'get_lot')
|
||||
|
||||
@classmethod
|
||||
def __setup__(cls):
|
||||
|
||||
Reference in New Issue
Block a user