From efc52c89b449c170d79448409b7b98f3b71c82fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Tue, 6 Jan 2015 23:27:38 +0100 Subject: [PATCH] Add parameter price_decimal and price_digits issue4438 review6791002 --- CHANGELOG | 3 +++ doc/index.rst | 12 ++++++++++++ product.py | 15 +++++++++------ 3 files changed, 24 insertions(+), 6 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 3fcdd6ae2e..ea2c6a92c3 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,6 @@ +* Add price_digits +* Add parameter price_decimal + Version 3.4.0 - 2014-10-20 * Bug fixes (see mercurial logs for details) diff --git a/doc/index.rst b/doc/index.rst index 2e9ab39720..7e62a9ffcf 100644 --- a/doc/index.rst +++ b/doc/index.rst @@ -61,3 +61,15 @@ The Product Template model contains the following fields: The Product model extend the Product Template with two fields: Code and Description. + +Configuration +************* + +The product module uses the section `product` to retrieve some parameters: + +- `price_decimal`: defines the number of decimal with which the unit prices are + stored. The default value is `4`. + +.. warning:: + It can not be lowered once a database is created. +.. diff --git a/product.py b/product.py index 1252e05a5a..991af06822 100644 --- a/product.py +++ b/product.py @@ -6,8 +6,9 @@ from trytond.transaction import Transaction from trytond.pool import Pool from trytond import backend from trytond.const import OPERATORS +from trytond.config import config -__all__ = ['Template', 'Product'] +__all__ = ['Template', 'Product', 'price_digits'] STATES = { 'readonly': ~Eval('active', True), @@ -19,6 +20,8 @@ TYPES = [ ('service', 'Service'), ] +price_digits = (16, config.getint('product', 'price_decimal', 4)) + class Template(ModelSQL, ModelView): "Product Template" @@ -36,9 +39,9 @@ class Template(ModelSQL, ModelView): category = fields.Many2One('product.category', 'Category', states=STATES, depends=DEPENDS) list_price = fields.Property(fields.Numeric('List Price', states=STATES, - digits=(16, 4), depends=DEPENDS, required=True)) - cost_price = fields.Property(fields.Numeric('Cost Price', - states=STATES, digits=(16, 4), depends=DEPENDS, required=True)) + digits=price_digits, depends=DEPENDS, required=True)) + cost_price = fields.Property(fields.Numeric('Cost Price', states=STATES, + digits=price_digits, depends=DEPENDS, required=True)) cost_price_method = fields.Property(fields.Selection([ ("fixed", "Fixed"), ("average", "Average") @@ -143,9 +146,9 @@ class Product(ModelSQL, ModelView): type = fields.Function(fields.Selection(TYPES, 'Type'), 'on_change_with_type', searcher='search_type') list_price_uom = fields.Function(fields.Numeric('List Price', - digits=(16, 4)), 'get_price_uom') + digits=price_digits), 'get_price_uom') cost_price_uom = fields.Function(fields.Numeric('Cost Price', - digits=(16, 4)), 'get_price_uom') + digits=price_digits), 'get_price_uom') @classmethod def order_rec_name(cls, tables):