diff --git a/CHANGELOG b/CHANGELOG index a806b4fb0e..3ec990a110 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,4 @@ +* Add configuration option to store invoice report cache in filestore * Manage readonly state on Invoice Line and Tax Line * Rename account.invoice.payment_term.line.relativedelta into account.invoice.payment_term.line.delta diff --git a/doc/index.rst b/doc/index.rst index 36d55fb61f..6d10cd4065 100644 --- a/doc/index.rst +++ b/doc/index.rst @@ -123,4 +123,16 @@ computed terms base on an amount and a date. .. note:: The last line of payment term must be a remainder. +Configuration +************* + +The account_invoice module uses the section `account_invoice` to retrieve some +parameters: + +- `filestore`: a boolean value to store invoice report cache in the FileStore. + The default value is `False`. + +- `store_prefix`: the prefix to use with the FileStore. The default value is + `None`. + .. _`python-dateutil library`: http://labix.org/python-dateutil#head-72c4689ec5608067d118b9143cef6bdffb6dad4e diff --git a/invoice.py b/invoice.py index 8215581ec1..df0126c715 100644 --- a/invoice.py +++ b/invoice.py @@ -21,6 +21,7 @@ from trytond.tools import reduce_ids, grouped_slice from trytond.transaction import Transaction from trytond.pool import Pool from trytond.rpc import RPC +from trytond.config import config from trytond.modules.account.tax import TaxableMixin from trytond.modules.product import price_digits @@ -55,6 +56,13 @@ STATES = [ ('cancel', 'Canceled'), ] +if config.getboolean('account_invoice', 'filestore', default=False): + file_id = 'invoice_report_cache_id' + store_prefix = config.get('account_invoice', 'store_prefix', default=None) +else: + file_id = None + store_prefix = None + class Invoice(Workflow, ModelSQL, ModelView, TaxableMixin): 'Invoice' @@ -169,7 +177,9 @@ class Invoice(Workflow, ModelSQL, ModelView, TaxableMixin): amount_to_pay = fields.Function(fields.Numeric('Amount to Pay', digits=(16, Eval('currency_digits', 2)), depends=['currency_digits']), 'get_amount_to_pay') - invoice_report_cache = fields.Binary('Invoice Report', readonly=True) + invoice_report_cache = fields.Binary('Invoice Report', readonly=True, + file_id=file_id, store_prefix=store_prefix) + invoice_report_cache_id = fields.Char('Invoice Report ID', readonly=True) invoice_report_format = fields.Char('Invoice Report Format', readonly=True) @classmethod