changeset 917784ba894d in modules/sale_price_list:default
details: 
https://hg.tryton.org/modules/sale_price_list?cmd=changeset;node=917784ba894d
description:
        Add unit per price list

        We add a selection field on price list to define how to get the unit.
        But also we remove the digits constraint on the quantity as it is 
compared
        against an non-rounded value.

        issue8442
        review255621002
diffstat:

 CHANGELOG   |   2 ++
 __init__.py |   5 +++--
 product.py  |  17 +++++++++++++++--
 3 files changed, 20 insertions(+), 4 deletions(-)

diffs (62 lines):

diff -r 62188ddedc39 -r 917784ba894d CHANGELOG
--- a/CHANGELOG Mon May 06 15:12:06 2019 +0200
+++ b/CHANGELOG Mon Jul 08 18:43:25 2019 +0200
@@ -1,3 +1,5 @@
+* Add product sale unit to price list
+
 Version 5.2.0 - 2019-05-06
 * Bug fixes (see mercurial logs for details)
 
diff -r 62188ddedc39 -r 917784ba894d __init__.py
--- a/__init__.py       Mon May 06 15:12:06 2019 +0200
+++ b/__init__.py       Mon Jul 08 18:43:25 2019 +0200
@@ -4,7 +4,7 @@
 from trytond.pool import Pool
 from .party import *
 from .sale import *
-from .product import *
+from . import product
 from . import configuration
 
 
@@ -14,7 +14,8 @@
         PartySalePriceList,
         Sale,
         SaleLine,
-        Product,
+        product.Product,
+        product.PriceList,
         configuration.Configuration,
         configuration.ConfigurationSalePriceList,
         module='sale_price_list', type_='model')
diff -r 62188ddedc39 -r 917784ba894d product.py
--- a/product.py        Mon May 06 15:12:06 2019 +0200
+++ b/product.py        Mon Jul 08 18:43:25 2019 +0200
@@ -3,8 +3,6 @@
 from trytond.transaction import Transaction
 from trytond.pool import Pool, PoolMeta
 
-__all__ = ['Product']
-
 
 class Product(metaclass=PoolMeta):
     __name__ = 'product.product'
@@ -42,3 +40,18 @@
                     price = Tax.reverse_compute(price, taxes)
                 prices[product.id] = price
         return prices
+
+
+class PriceList(metaclass=PoolMeta):
+    __name__ = 'product.price_list'
+
+    @classmethod
+    def __setup__(cls):
+        super().__setup__()
+        cls.unit.selection.append(('product_sale', "Product Sale"))
+
+    def get_uom(self, product):
+        uom = super().get_uom(product)
+        if self.unit == 'product_sale' and self.product.sale_uom:
+            uom = self.product.sale_uom
+        return uom

Reply via email to