mirror of
https://github.com/OCA/stock-logistics-warehouse.git
synced 2025-01-21 14:27:28 +02:00
s_packaging_calculator: ease override of packaging name
This commit is contained in:
committed by
nguyen hoang hiep
parent
4f156d449e
commit
7b7cacc7f6
@@ -80,7 +80,9 @@ class Product(models.Model):
|
||||
the display name of the packaging.
|
||||
"""
|
||||
custom_filter = self.env.context.get("_packaging_filter", lambda x: x)
|
||||
name_getter = self.env.context.get("_packaging_name_getter", lambda x: x.name)
|
||||
name_getter = self.env.context.get(
|
||||
"_packaging_name_getter", self._packaging_name_getter
|
||||
)
|
||||
packagings = sorted(
|
||||
[
|
||||
Packaging(x.id, name_getter(x), x.qty, x.barcode, False)
|
||||
@@ -100,6 +102,9 @@ class Product(models.Model):
|
||||
)
|
||||
return packagings
|
||||
|
||||
def _packaging_name_getter(self, packaging):
|
||||
return packaging.name
|
||||
|
||||
def _product_qty_by_packaging(self, pkg_by_qty, qty, with_contained=False):
|
||||
"""Produce a list of dictionaries of packaging info."""
|
||||
# TODO: refactor to handle fractional quantities (eg: 0.5 Kg)
|
||||
|
||||
Reference in New Issue
Block a user