diff --git a/__init__.py b/__init__.py
index 919ccce..533e843 100644
--- a/__init__.py
+++ b/__init__.py
@@ -11,6 +11,7 @@ def register():
product_limit.ShipmentOutReturn,
product_limit.Location,
product_limit.PrintProductLimitNoteParam,
+ product_limit.Configuration,
module='stock_location_product_limit', type_='model')
Pool.register(
product_limit.PrintProductLimitNote,
diff --git a/locale/es.po b/locale/es.po
index 9965481..1c2cb1f 100644
--- a/locale/es.po
+++ b/locale/es.po
@@ -224,4 +224,12 @@ msgstr "Disponible"
msgctxt "report:stock.shipment.out.return.restocking_list:"
msgid "Limit"
-msgstr "Límite"
\ No newline at end of file
+msgstr "Límite"
+
+msgctxt "field:stock.configuration,show_limit:"
+msgid "Show product limits"
+msgstr "Mostrar límites producto"
+
+msgctxt "help:stock.configuration,show_limit:"
+msgid "If checked a summary of product limits is shown in shipment reports."
+msgstr "Mostrará un resumen de límites de producto en los informes de albarán."
\ No newline at end of file
diff --git a/product_limit.py b/product_limit.py
index 830c1a5..8b28a2a 100644
--- a/product_limit.py
+++ b/product_limit.py
@@ -12,7 +12,8 @@ from trytond.wizard import Wizard, StateTransition, StateView, Button
__all__ = ['ProductLimit', 'ShipmentOut', 'ShipmentOutReturn', 'Location',
'ProductLimitNote', 'PrintProductLimitNote',
- 'PrintProductLimitNoteParam', 'DeliveryNote', 'RestockingList']
+ 'PrintProductLimitNoteParam', 'DeliveryNote', 'RestockingList',
+ 'Configuration']
class ProductLimit(ModelSQL, ModelView):
@@ -339,9 +340,17 @@ class DeliveryNote:
@classmethod
def get_context(cls, records, data):
+ Conf = Pool().get('stock.configuration')
+
report_context = super(DeliveryNote, cls).get_context(records, data)
- report_context['product_limits'] = {
- r.id: r.product_limits_by_location() for r in records}
+
+ show_limit = Conf(1).show_limit
+ report_context['product_limits'] = {}
+ for r in records:
+ values = []
+ if show_limit:
+ values = r.product_limits_by_location()
+ report_context['product_limits'][r.id] = values
return report_context
@@ -351,7 +360,28 @@ class RestockingList:
@classmethod
def get_context(cls, records, data):
+ Conf = Pool().get('stock.configuration')
+
report_context = super(RestockingList, cls).get_context(records, data)
- report_context['product_limits'] = {
- r.id: r.product_limits_by_location() for r in records}
+
+ show_limit = Conf(1).show_limit
+ report_context['product_limits'] = {}
+ for r in records:
+ values = []
+ if show_limit:
+ values = r.product_limits_by_location()
+ report_context['product_limits'][r.id] = values
return report_context
+
+
+class Configuration:
+ __name__ = 'stock.configuration'
+ __metaclass__ = PoolMeta
+
+ show_limit = fields.Boolean('Show product limits', help=(
+ 'If checked a summary of product limits is shown in shipment reports.')
+ )
+
+ @staticmethod
+ def default_show_limit():
+ return True
diff --git a/product_limit.xml b/product_limit.xml
index befe802..0e72625 100644
--- a/product_limit.xml
+++ b/product_limit.xml
@@ -84,6 +84,13 @@ this repository contains the full copyright notices and license terms. -->
form
product_limit_print_params_form
+
+
+
+ stock.configuration
+
+ configuration_form
+
diff --git a/tests/scenario_stock_shipment_out.rst b/tests/scenario_stock_shipment_out.rst
index 74919e0..2021eab 100644
--- a/tests/scenario_stock_shipment_out.rst
+++ b/tests/scenario_stock_shipment_out.rst
@@ -139,6 +139,11 @@ Testing the reports::
u'odt'
>>> name
u'Delivery Note'
+ >>> conf = Model.get('stock.configuration')(1)
+ >>> conf.show_limit = False
+ >>> conf.save()
+ >>> delivery_note = Report('stock.shipment.out.delivery_note')
+ >>> ext, _, _, name = delivery_note.execute([shipment_out], {})
Testing note print wizard::