Add parameter price_decimal and price_digits

issue4438
review6791002
This commit is contained in:
Cédric Krier committed 2015-01-06 23:27:38 +01:00
1 parent 56daf61733
commit efc52c89b4
3 files changed
+24 -6

No files matched your search

+3
View File
@@ -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)
+12
View File
@@ -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.
..
+9 -6
View File
@@ -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):