diff --git a/CHANGELOG b/CHANGELOG
index abd6758d8b..44122866aa 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,3 +1,5 @@
+* Add default invoice grouping method
+
Version 4.4.0 - 2017-05-01
* Bug fixes (see mercurial logs for details)
@@ -21,4 +23,4 @@ Version 3.2.0 - 2014-04-21
* Bug fixes (see mercurial logs for details)
Version 3.0.0 - 2013-10-21
-* Initial release
\ No newline at end of file
+* Initial release
diff --git a/__init__.py b/__init__.py
index 9b84e4cf5b..1684a0349f 100644
--- a/__init__.py
+++ b/__init__.py
@@ -4,6 +4,7 @@
from trytond.pool import Pool
from .party import *
from .sale import *
+from . import configuration
def register():
@@ -11,4 +12,6 @@ def register():
Sale,
Party,
PartySaleInvoiceGroupingMethod,
+ configuration.Configuration,
+ configuration.ConfigurationSaleMethod,
module='sale_invoice_grouping', type_='model')
diff --git a/configuration.py b/configuration.py
new file mode 100644
index 0000000000..db859dd5ea
--- /dev/null
+++ b/configuration.py
@@ -0,0 +1,57 @@
+# This file is part of Tryton. The COPYRIGHT file at the top level of
+# this repository contains the full copyright notices and license terms.
+from trytond.model import fields
+from trytond.pool import Pool, PoolMeta
+
+__all__ = ['Configuration', 'ConfigurationSaleMethod']
+
+
+sale_invoice_grouping_method = fields.Selection(
+ 'get_sale_invoice_grouping_methods', "Sale Invoice Grouping Method",
+ help="The default invoice grouping method for new customers.")
+
+
+@classmethod
+def get_sale_invoice_grouping_methods(cls):
+ pool = Pool()
+ Party = pool.get('party.party')
+ field_name = 'sale_invoice_grouping_method'
+ return Party.fields_get([field_name])[field_name]['selection']
+
+
+class Configuration:
+ __metaclass__ = PoolMeta
+ __name__ = 'sale.configuration'
+
+ sale_invoice_grouping_method = fields.MultiValue(
+ sale_invoice_grouping_method)
+ get_sale_invoice_grouping_methods = get_sale_invoice_grouping_methods
+
+ @classmethod
+ def multivalue_model(cls, field):
+ pool = Pool()
+ if field == 'sale_invoice_grouping_method':
+ return pool.get('sale.configuration.sale_method')
+ return super(Configuration, cls).multivalue_model(field)
+
+ @classmethod
+ def get_sale_invoice_grouping_methods(cls):
+ pool = Pool()
+ Party = pool.get('party.party')
+ field_name = 'sale_invoice_grouping_method'
+ return Party.fields_get([field_name])[field_name]['selection']
+
+
+class ConfigurationSaleMethod():
+ __metaclass__ = PoolMeta
+ __name__ = 'sale.configuration.sale_method'
+
+ sale_invoice_grouping_method = sale_invoice_grouping_method
+ get_sale_invoice_grouping_methods = get_sale_invoice_grouping_methods
+
+ @classmethod
+ def get_sale_invoice_grouping_methods(cls):
+ pool = Pool()
+ Party = pool.get('party.party')
+ field_name = 'sale_invoice_grouping_method'
+ return Party.fields_get([field_name])[field_name]['selection']
diff --git a/configuration.xml b/configuration.xml
new file mode 100644
index 0000000000..1be072a305
--- /dev/null
+++ b/configuration.xml
@@ -0,0 +1,12 @@
+
+
+
+
+
+ sale.configuration
+
+ configuration_form
+
+
+
diff --git a/party.py b/party.py
index e9187f3ab2..aeee9f3e1e 100644
--- a/party.py
+++ b/party.py
@@ -21,6 +21,13 @@ class Party:
'party.party.sale_invoice_grouping_method', 'party',
"Sale Invoice Grouping Methods")
+ @classmethod
+ def default_sale_invoice_grouping_method(cls, **pattern):
+ pool = Pool()
+ Configuration = pool.get('sale.configuration')
+ return Configuration(1).get_multivalue(
+ 'sale_invoice_grouping_method', **pattern)
+
class PartySaleInvoiceGroupingMethod(ModelSQL, ValueMixin):
"Party Sale Invoice Grouping Method"
diff --git a/tryton.cfg b/tryton.cfg
index 2ebebc6afc..7e58f687b9 100644
--- a/tryton.cfg
+++ b/tryton.cfg
@@ -8,3 +8,4 @@ depends:
sale
xml:
party.xml
+ configuration.xml
diff --git a/view/configuration_form.xml b/view/configuration_form.xml
new file mode 100644
index 0000000000..f15f4ddc66
--- /dev/null
+++ b/view/configuration_form.xml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
+