[tryton-debian-vcs] tryton-modules-product-price-list branch debian updated. debian/3.4.1-1-3-gb210507
Mathias Behrle
tryton-debian-vcs at alioth.debian.org
Thu Apr 23 16:05:06 UTC 2015
The following commit has been merged in the debian branch:
https://alioth.debian.org/plugins/scmgit/cgi-bin/gitweb.cgi/?p=tryton/tryton-modules-product-price-list.git;a=commitdiff;h=debian/3.4.1-1-3-gb210507
commit b21050716a98d667040bdeec06ca424e5ac362d0
Author: Mathias Behrle <mathiasb at m9s.biz>
Date: Thu Apr 23 17:41:35 2015 +0200
Updating Depends.
diff --git a/debian/control b/debian/control
index f4248b0..f385203 100644
--- a/debian/control
+++ b/debian/control
@@ -18,6 +18,8 @@ Package: tryton-modules-product-price-list
Architecture: all
Depends:
python-pkg-resources,
+ python-simpleeval,
+ python-sql,
tryton-modules-company (>= ${version:major}),
tryton-modules-party (>= ${version:major}),
tryton-modules-product (>= ${version:major}),
commit 71c25707fc79e9665069d68c8b0d75e52c4d1d2f
Author: Mathias Behrle <mathiasb at m9s.biz>
Date: Thu Apr 23 17:00:02 2015 +0200
Merging upstream version 3.6.0.
diff --git a/CHANGELOG b/CHANGELOG
index f712fa9..fed4690 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,5 +1,8 @@
-Version 3.4.1 - 2015-02-22
+Version 3.6.0 - 2015-04-20
* Bug fixes (see mercurial logs for details)
+* Add support for PyPy
+* Add tax included option
+* Replace safe_eval by simpleeval
Version 3.4.0 - 2014-10-20
* Bug fixes (see mercurial logs for details)
diff --git a/INSTALL b/INSTALL
index e53d450..f0810af 100644
--- a/INSTALL
+++ b/INSTALL
@@ -5,9 +5,10 @@ Prerequisites
-------------
* Python 2.7 or later (http://www.python.org/)
+ * simpleeval (https://github.com/danthedeckie/simpleeval)
+ * python-sql 0.4 or later (http://code.google.com/p/python-sql/)
* trytond (http://www.tryton.org/)
* trytond_product (http://www.tryton.org/)
- * trytond_party (http://www.tryton.org/)
* trytond_company (http://www.tryton.org/)
Installation
diff --git a/PKG-INFO b/PKG-INFO
index 04ee2d9..fe88413 100644
--- a/PKG-INFO
+++ b/PKG-INFO
@@ -1,12 +1,12 @@
Metadata-Version: 1.1
Name: trytond_product_price_list
-Version: 3.4.1
+Version: 3.6.0
Summary: Tryton module with price list
Home-page: http://www.tryton.org/
Author: Tryton
Author-email: issue_tracker at tryton.org
License: GPL-3
-Download-URL: http://downloads.tryton.org/3.4/
+Download-URL: http://downloads.tryton.org/3.6/
Description: trytond_product_price_list
==========================
@@ -64,4 +64,6 @@ Classifier: Natural Language :: Slovenian
Classifier: Natural Language :: Spanish
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 2.7
+Classifier: Programming Language :: Python :: Implementation :: CPython
+Classifier: Programming Language :: Python :: Implementation :: PyPy
Classifier: Topic :: Office/Business
diff --git a/__init__.py b/__init__.py
index 598261a..87d2165 100644
--- a/__init__.py
+++ b/__init__.py
@@ -1,5 +1,5 @@
-#This file is part of Tryton. The COPYRIGHT file at the top level of
-#this repository contains the full copyright notices and license terms.
+# 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.pool import Pool
from .price_list import *
diff --git a/locale/bg_BG.po b/locale/bg_BG.po
index 9a5bfec..fc13860 100644
--- a/locale/bg_BG.po
+++ b/locale/bg_BG.po
@@ -3,7 +3,9 @@ msgid ""
msgstr "Content-Type: text/plain; charset=utf-8\n"
msgctxt "error:product.price_list.line:"
-msgid "Invalid formula \"%(formula)s\" in price list line \"%(line)s\"."
+msgid ""
+"Invalid formula \"%(formula)s\" in price list line \"%(line)s\" with "
+"exception \"%(exception)s\"."
msgstr ""
msgctxt "field:product.price_list,company:"
@@ -34,6 +36,10 @@ msgctxt "field:product.price_list,rec_name:"
msgid "Name"
msgstr "Име"
+msgctxt "field:product.price_list,tax_included:"
+msgid "Tax Included"
+msgstr ""
+
msgctxt "field:product.price_list,write_date:"
msgid "Write Date"
msgstr "Променено на"
diff --git a/locale/ca_ES.po b/locale/ca_ES.po
index fe78fbc..36713ed 100644
--- a/locale/ca_ES.po
+++ b/locale/ca_ES.po
@@ -3,8 +3,12 @@ msgid ""
msgstr "Content-Type: text/plain; charset=utf-8\n"
msgctxt "error:product.price_list.line:"
-msgid "Invalid formula \"%(formula)s\" in price list line \"%(line)s\"."
-msgstr "Formula \"%(formula)s\" a línia de tarifa \"%(line)s\" incorrecta."
+msgid ""
+"Invalid formula \"%(formula)s\" in price list line \"%(line)s\" with "
+"exception \"%(exception)s\"."
+msgstr ""
+"La fórmula \"%(formula)s\" a la línia de tarifa \"%(line)s\" no és correcte "
+"generant l'excepció \"%(exception)s\"."
msgctxt "field:product.price_list,company:"
msgid "Company"
@@ -34,6 +38,10 @@ msgctxt "field:product.price_list,rec_name:"
msgid "Name"
msgstr "Nom"
+msgctxt "field:product.price_list,tax_included:"
+msgid "Tax Included"
+msgstr "Impost inclòs"
+
msgctxt "field:product.price_list,write_date:"
msgid "Write Date"
msgstr "Data modificació"
diff --git a/locale/cs_CZ.po b/locale/cs_CZ.po
index 96113f8..f8f4506 100644
--- a/locale/cs_CZ.po
+++ b/locale/cs_CZ.po
@@ -3,7 +3,9 @@ msgid ""
msgstr "Content-Type: text/plain; charset=utf-8\n"
msgctxt "error:product.price_list.line:"
-msgid "Invalid formula \"%(formula)s\" in price list line \"%(line)s\"."
+msgid ""
+"Invalid formula \"%(formula)s\" in price list line \"%(line)s\" with "
+"exception \"%(exception)s\"."
msgstr ""
msgctxt "field:product.price_list,company:"
@@ -34,6 +36,10 @@ msgctxt "field:product.price_list,rec_name:"
msgid "Name"
msgstr ""
+msgctxt "field:product.price_list,tax_included:"
+msgid "Tax Included"
+msgstr ""
+
msgctxt "field:product.price_list,write_date:"
msgid "Write Date"
msgstr ""
diff --git a/locale/de_DE.po b/locale/de_DE.po
index 5a598c9..36bc4fc 100644
--- a/locale/de_DE.po
+++ b/locale/de_DE.po
@@ -3,8 +3,12 @@ msgid ""
msgstr "Content-Type: text/plain; charset=utf-8\n"
msgctxt "error:product.price_list.line:"
-msgid "Invalid formula \"%(formula)s\" in price list line \"%(line)s\"."
-msgstr "Ungültige Formel \"%(formula)s\" in Preislistenzeile \"%(line)s\"."
+msgid ""
+"Invalid formula \"%(formula)s\" in price list line \"%(line)s\" with "
+"exception \"%(exception)s\"."
+msgstr ""
+"Ungültige Formel \"%(formula)s\" in Preislistenzeile \"%(line)s\" mit "
+"Fehlermeldung \"%(exception)s\""
msgctxt "field:product.price_list,company:"
msgid "Company"
@@ -34,6 +38,10 @@ msgctxt "field:product.price_list,rec_name:"
msgid "Name"
msgstr "Name"
+msgctxt "field:product.price_list,tax_included:"
+msgid "Tax Included"
+msgstr "Steuer Inklusive"
+
msgctxt "field:product.price_list,write_date:"
msgid "Write Date"
msgstr "Zuletzt geändert"
diff --git a/locale/es_AR.po b/locale/es_AR.po
index bef1285..e8d2bd7 100644
--- a/locale/es_AR.po
+++ b/locale/es_AR.po
@@ -3,9 +3,12 @@ msgid ""
msgstr "Content-Type: text/plain; charset=utf-8\n"
msgctxt "error:product.price_list.line:"
-msgid "Invalid formula \"%(formula)s\" in price list line \"%(line)s\"."
+msgid ""
+"Invalid formula \"%(formula)s\" in price list line \"%(line)s\" with "
+"exception \"%(exception)s\"."
msgstr ""
-"Fórmula «%(formula)s» en línea de precio de lista «%(line)s» no es correcta."
+"Fórmula «%(formula)s» incorrecta en línea de precio de lista «%(line)s» con "
+"excepción «%(exception)s»."
msgctxt "field:product.price_list,company:"
msgid "Company"
@@ -35,6 +38,10 @@ msgctxt "field:product.price_list,rec_name:"
msgid "Name"
msgstr "Nombre"
+msgctxt "field:product.price_list,tax_included:"
+msgid "Tax Included"
+msgstr "Impuesto incluido"
+
msgctxt "field:product.price_list,write_date:"
msgid "Write Date"
msgstr "Fecha modificación"
@@ -81,7 +88,7 @@ msgstr "Secuencia"
msgctxt "field:product.price_list.line,unit_digits:"
msgid "Unit Digits"
-msgstr "Dígitos de unidad"
+msgstr "Decimales de unidad"
msgctxt "field:product.price_list.line,write_date:"
msgid "Write Date"
diff --git a/locale/es_CO.po b/locale/es_CO.po
index 5de9bc8..3424fbf 100644
--- a/locale/es_CO.po
+++ b/locale/es_CO.po
@@ -3,8 +3,12 @@ msgid ""
msgstr "Content-Type: text/plain; charset=utf-8\n"
msgctxt "error:product.price_list.line:"
-msgid "Invalid formula \"%(formula)s\" in price list line \"%(line)s\"."
-msgstr "Fómula inválida \"%(formula)s\" en línea de lista de precios \"%(line)s\"."
+msgid ""
+"Invalid formula \"%(formula)s\" in price list line \"%(line)s\" with "
+"exception \"%(exception)s\"."
+msgstr ""
+"Frmula inválida \"%s(formula)s\" en línea de lista de precio \"%(line)s\" "
+"con excepción \"%(exception)s\""
msgctxt "field:product.price_list,company:"
msgid "Company"
@@ -34,6 +38,10 @@ msgctxt "field:product.price_list,rec_name:"
msgid "Name"
msgstr "Nombre"
+msgctxt "field:product.price_list,tax_included:"
+msgid "Tax Included"
+msgstr "Impuesto Incluido"
+
msgctxt "field:product.price_list,write_date:"
msgid "Write Date"
msgstr "Fecha de Modificación"
diff --git a/locale/es_EC.po b/locale/es_EC.po
index b90bf19..bed0ff4 100644
--- a/locale/es_EC.po
+++ b/locale/es_EC.po
@@ -3,10 +3,12 @@ msgid ""
msgstr "Content-Type: text/plain; charset=utf-8\n"
msgctxt "error:product.price_list.line:"
-msgid "Invalid formula \"%(formula)s\" in price list line \"%(line)s\"."
+msgid ""
+"Invalid formula \"%(formula)s\" in price list line \"%(line)s\" with "
+"exception \"%(exception)s\"."
msgstr ""
-"La fórmula \"%(formula)s\" en la línea de lista de precios \"%(line)s\" no "
-"es válida."
+"La fórmula \"%(formula)s\" en la línea de lista de precios \"%(line)s\" con "
+"excepción \"%(exception)s\" no es válida."
msgctxt "field:product.price_list,company:"
msgid "Company"
@@ -14,11 +16,11 @@ msgstr "Empresa"
msgctxt "field:product.price_list,create_date:"
msgid "Create Date"
-msgstr "Fecha de Creación"
+msgstr "Fecha de creación"
msgctxt "field:product.price_list,create_uid:"
msgid "Create User"
-msgstr "Creado por Usuario"
+msgstr "Creado por usuario"
msgctxt "field:product.price_list,id:"
msgid "ID"
@@ -36,21 +38,25 @@ msgctxt "field:product.price_list,rec_name:"
msgid "Name"
msgstr "Nombre"
+msgctxt "field:product.price_list,tax_included:"
+msgid "Tax Included"
+msgstr "Impuesto incluido"
+
msgctxt "field:product.price_list,write_date:"
msgid "Write Date"
-msgstr "Fecha de Modificación"
+msgstr "Fecha de modificación"
msgctxt "field:product.price_list,write_uid:"
msgid "Write User"
-msgstr "Modificado por Usuario"
+msgstr "Modificado por usuario"
msgctxt "field:product.price_list.line,create_date:"
msgid "Create Date"
-msgstr "Fecha de Creación"
+msgstr "Fecha de creación"
msgctxt "field:product.price_list.line,create_uid:"
msgid "Create User"
-msgstr "Creado por Usuario"
+msgstr "Creado por usuario"
msgctxt "field:product.price_list.line,formula:"
msgid "Formula"
@@ -62,7 +68,7 @@ msgstr "ID"
msgctxt "field:product.price_list.line,price_list:"
msgid "Price List"
-msgstr "Lista de Precios"
+msgstr "Lista de precios"
msgctxt "field:product.price_list.line,product:"
msgid "Product"
@@ -82,15 +88,15 @@ msgstr "Secuencia"
msgctxt "field:product.price_list.line,unit_digits:"
msgid "Unit Digits"
-msgstr "Decimales de Unidad"
+msgstr "Decimales de unidad"
msgctxt "field:product.price_list.line,write_date:"
msgid "Write Date"
-msgstr "Fecha de Modificación"
+msgstr "Fecha de modificación"
msgctxt "field:product.price_list.line,write_uid:"
msgid "Write User"
-msgstr "Modificado por Usuario"
+msgstr "Modificado por usuario"
msgctxt "help:product.price_list.line,formula:"
msgid ""
@@ -98,40 +104,40 @@ msgid ""
"- unit_price: the original unit_price"
msgstr ""
"Expresión de Python que se evaluará con:\n"
-"- unit_price: El precio unitario original"
+"- unit_price: el precio unitario original"
msgctxt "model:ir.action,name:act_price_list_form"
msgid "Price Lists"
-msgstr "Listas de Precios"
+msgstr "Listas de precios"
msgctxt "model:ir.ui.menu,name:menu_price_list"
msgid "Price Lists"
-msgstr "Listas de Precios"
+msgstr "Listas de precios"
msgctxt "model:product.price_list,name:"
msgid "Price List"
-msgstr "Lista de Precios"
+msgstr "Lista de precios"
msgctxt "model:product.price_list.line,name:"
msgid "Price List Line"
-msgstr "Línea de Lista de Precios"
+msgstr "Línea de lista de precios"
msgctxt "view:party.party:"
msgid "Price List"
-msgstr "Lista de Precios"
+msgstr "Lista de precios"
msgctxt "view:product.price_list.line:"
msgid "Price List Line"
-msgstr "Línea de Lista de Precios"
+msgstr "Línea de lista de precios"
msgctxt "view:product.price_list.line:"
msgid "Price List Lines"
-msgstr "Líneas de Lista de Precios"
+msgstr "Líneas de lista de precios"
msgctxt "view:product.price_list:"
msgid "Price List"
-msgstr "Lista de Precios"
+msgstr "Lista de precios"
msgctxt "view:product.price_list:"
msgid "Price Lists"
-msgstr "Listas de Precios"
+msgstr "Listas de precios"
diff --git a/locale/es_ES.po b/locale/es_ES.po
index 8e94c01..36b4284 100644
--- a/locale/es_ES.po
+++ b/locale/es_ES.po
@@ -3,8 +3,12 @@ msgid ""
msgstr "Content-Type: text/plain; charset=utf-8\n"
msgctxt "error:product.price_list.line:"
-msgid "Invalid formula \"%(formula)s\" in price list line \"%(line)s\"."
-msgstr "Formula \"%(formula)s\" en línea de tarifa \"%(line)s\" no es correcta."
+msgid ""
+"Invalid formula \"%(formula)s\" in price list line \"%(line)s\" with "
+"exception \"%(exception)s\"."
+msgstr ""
+"La fórmula \"%(formula)s\" en la línea de tarifa \"%(line)s\" no es correcta"
+" generando la excepción \"%(exception)s\"."
msgctxt "field:product.price_list,company:"
msgid "Company"
@@ -34,6 +38,10 @@ msgctxt "field:product.price_list,rec_name:"
msgid "Name"
msgstr "Nombre"
+msgctxt "field:product.price_list,tax_included:"
+msgid "Tax Included"
+msgstr "Impuestos incluidos"
+
msgctxt "field:product.price_list,write_date:"
msgid "Write Date"
msgstr "Fecha modificación"
diff --git a/locale/fr_FR.po b/locale/fr_FR.po
index 1a97232..4821c45 100644
--- a/locale/fr_FR.po
+++ b/locale/fr_FR.po
@@ -3,10 +3,12 @@ msgid ""
msgstr "Content-Type: text/plain; charset=utf-8\n"
msgctxt "error:product.price_list.line:"
-msgid "Invalid formula \"%(formula)s\" in price list line \"%(line)s\"."
+msgid ""
+"Invalid formula \"%(formula)s\" in price list line \"%(line)s\" with "
+"exception \"%(exception)s\"."
msgstr ""
-"La formule « %(formula)s » de la ligne de liste de prix « %(line)s » est "
-"invalide."
+"Formule invalide « %(formula)s » sur la ligne de la liste de prix « %(line)s"
+" » avec l'exception « %(exception)s »."
msgctxt "field:product.price_list,company:"
msgid "Company"
@@ -36,6 +38,10 @@ msgctxt "field:product.price_list,rec_name:"
msgid "Name"
msgstr "Nom"
+msgctxt "field:product.price_list,tax_included:"
+msgid "Tax Included"
+msgstr "Taxe incluse"
+
msgctxt "field:product.price_list,write_date:"
msgid "Write Date"
msgstr "Date de mise à jour"
diff --git a/locale/nl_NL.po b/locale/nl_NL.po
index 9af3e50..742acb0 100644
--- a/locale/nl_NL.po
+++ b/locale/nl_NL.po
@@ -3,7 +3,9 @@ msgid ""
msgstr "Content-Type: text/plain; charset=utf-8\n"
msgctxt "error:product.price_list.line:"
-msgid "Invalid formula \"%(formula)s\" in price list line \"%(line)s\"."
+msgid ""
+"Invalid formula \"%(formula)s\" in price list line \"%(line)s\" with "
+"exception \"%(exception)s\"."
msgstr ""
#, fuzzy
@@ -38,6 +40,10 @@ msgctxt "field:product.price_list,rec_name:"
msgid "Name"
msgstr "Naam bijlage"
+msgctxt "field:product.price_list,tax_included:"
+msgid "Tax Included"
+msgstr ""
+
msgctxt "field:product.price_list,write_date:"
msgid "Write Date"
msgstr ""
diff --git a/locale/ru_RU.po b/locale/ru_RU.po
index ea19633..d724dc8 100644
--- a/locale/ru_RU.po
+++ b/locale/ru_RU.po
@@ -3,7 +3,9 @@ msgid ""
msgstr "Content-Type: text/plain; charset=utf-8\n"
msgctxt "error:product.price_list.line:"
-msgid "Invalid formula \"%(formula)s\" in price list line \"%(line)s\"."
+msgid ""
+"Invalid formula \"%(formula)s\" in price list line \"%(line)s\" with "
+"exception \"%(exception)s\"."
msgstr ""
#, fuzzy
@@ -41,6 +43,10 @@ msgctxt "field:product.price_list,rec_name:"
msgid "Name"
msgstr "Наименование"
+msgctxt "field:product.price_list,tax_included:"
+msgid "Tax Included"
+msgstr ""
+
#, fuzzy
msgctxt "field:product.price_list,write_date:"
msgid "Write Date"
diff --git a/locale/sl_SI.po b/locale/sl_SI.po
index 6355f3b..f54fd19 100644
--- a/locale/sl_SI.po
+++ b/locale/sl_SI.po
@@ -3,8 +3,12 @@ msgid ""
msgstr "Content-Type: text/plain; charset=utf-8\n"
msgctxt "error:product.price_list.line:"
-msgid "Invalid formula \"%(formula)s\" in price list line \"%(line)s\"."
-msgstr "Neveljavna formula \"%(formula)s\" v postavki cenika \"%(line)s\"."
+msgid ""
+"Invalid formula \"%(formula)s\" in price list line \"%(line)s\" with "
+"exception \"%(exception)s\"."
+msgstr ""
+"Neveljavna formula \"%(formula)s\" v postavki cenika \"%(line)s\" z napako "
+"\"%(exception)s\"."
msgctxt "field:product.price_list,company:"
msgid "Company"
@@ -34,6 +38,10 @@ msgctxt "field:product.price_list,rec_name:"
msgid "Name"
msgstr "Ime"
+msgctxt "field:product.price_list,tax_included:"
+msgid "Tax Included"
+msgstr "Davek vključen"
+
msgctxt "field:product.price_list,write_date:"
msgid "Write Date"
msgstr "Zapisano"
diff --git a/price_list.py b/price_list.py
index 36df54a..184f14f 100644
--- a/price_list.py
+++ b/price_list.py
@@ -1,10 +1,12 @@
-#This file is part of Tryton. The COPYRIGHT file at the top level of
-#this repository contains the full copyright notices and license terms.
+# 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 decimal import Decimal
-import tokenize
-from StringIO import StringIO
+
+from sql import Null
+from simpleeval import simple_eval
+
from trytond.model import ModelView, ModelSQL, MatchMixin, fields
-from trytond.tools import safe_eval
+from trytond.tools import decistmt
from trytond.pyson import If, Eval
from trytond.transaction import Transaction
from trytond.pool import Pool
@@ -13,37 +15,6 @@ from trytond import backend
__all__ = ['PriceList', 'PriceListLine']
-# code snippet taken from http://docs.python.org/library/tokenize.html
-def decistmt(s):
- """Substitute Decimals for floats in a string of statements.
-
- >>> from decimal import Decimal
- >>> s = 'print +21.3e-5*-.1234/81.7'
- >>> decistmt(s)
- "print +Decimal ('21.3e-5')*-Decimal ('.1234')/Decimal ('81.7')"
-
- >>> exec(s)
- -3.21716034272e-007
- >>> exec(decistmt(s))
- -3.217160342717258261933904529E-7
- """
- result = []
- # tokenize the string
- g = tokenize.generate_tokens(StringIO(s).readline)
- for toknum, tokval, _, _, _ in g:
- # replace NUMBER tokens
- if toknum == tokenize.NUMBER and '.' in tokval:
- result.extend([
- (tokenize.NAME, 'Decimal'),
- (tokenize.OP, '('),
- (tokenize.STRING, repr(tokval)),
- (tokenize.OP, ')')
- ])
- else:
- result.append((toknum, tokval))
- return tokenize.untokenize(result)
-
-
class PriceList(ModelSQL, ModelView):
'Price List'
__name__ = 'product.price_list'
@@ -54,42 +25,27 @@ class PriceList(ModelSQL, ModelView):
('id', If(Eval('context', {}).contains('company'), '=', '!='),
Eval('context', {}).get('company', -1)),
])
+ tax_included = fields.Boolean('Tax Included')
lines = fields.One2Many('product.price_list.line', 'price_list', 'Lines')
@staticmethod
def default_company():
return Transaction().context.get('company')
- def _get_context_price_list_line(self, party, product, unit_price,
- quantity, uom):
- '''
- Get price list context for unit price
-
- :param party: the BrowseRecord of the party.party
- :param product: the BrowseRecord of the product.product
- :param unit_price: a Decimal for the default unit price in the
- company's currency and default uom of the product
- :param quantity: the quantity of product
- :param uom: the BrowseRecord of the product.uom
- :return: a dictionary
- '''
+ @staticmethod
+ def default_tax_included():
+ return False
+
+ def get_context_formula(self, party, product, unit_price, quantity, uom):
return {
- 'unit_price': unit_price,
- }
+ 'names': {
+ 'unit_price': unit_price,
+ },
+ }
def compute(self, party, product, unit_price, quantity, uom,
pattern=None):
- '''
- Compute price based on price list of party
-
- :param unit_price: a Decimal for the default unit price in the
- company's currency and default uom of the product
- :param quantity: the quantity of product
- :param uom: a instance of the product.uom
- :param pattern: a dictionary with price list field as key
- and match value as value
- :return: the computed unit price
- '''
+ 'Compute price based on price list of party'
Uom = Pool().get('product.uom')
@@ -101,12 +57,11 @@ class PriceList(ModelSQL, ModelView):
pattern['quantity'] = Uom.compute_qty(uom, quantity,
product.default_uom, round=False) if product else quantity
+ context = self.get_context_formula(
+ party, product, unit_price, quantity, uom)
for line in self.lines:
if line.match(pattern):
- with Transaction().set_context(
- self._get_context_price_list_line(party, product,
- unit_price, quantity, uom)):
- return line.get_unit_price()
+ return line.get_unit_price(**context)
return unit_price
@@ -133,7 +88,7 @@ class PriceListLine(ModelSQL, ModelView, MatchMixin):
cls._order.insert(0, ('sequence', 'ASC'))
cls._error_messages.update({
'invalid_formula': ('Invalid formula "%(formula)s" in price '
- 'list line "%(line)s".'),
+ 'list line "%(line)s" with exception "%(exception)s".'),
})
@classmethod
@@ -150,7 +105,7 @@ class PriceListLine(ModelSQL, ModelView, MatchMixin):
@staticmethod
def order_sequence(tables):
table, _ = tables[None]
- return [table.sequence == None, table.sequence]
+ return [table.sequence == Null, table.sequence]
@staticmethod
def default_formula():
@@ -172,23 +127,18 @@ class PriceListLine(ModelSQL, ModelView, MatchMixin):
'''
Check formula
'''
- pool = Pool()
- PriceList = pool.get('product.price_list')
- context = PriceList()._get_context_price_list_line(None, None,
- Decimal('0.0'), 0, None)
-
- with Transaction().set_context(**context):
- try:
- if not isinstance(self.get_unit_price(), Decimal):
- self.raise_user_error('invalid_formula', {
- 'formula': self.formula,
- 'line': self.rec_name,
- })
- except Exception:
- self.raise_user_error('invalid_formula', {
- 'formula': self.formula,
- 'line': self.rec_name,
- })
+ context = self.price_list.get_context_formula(
+ None, None, Decimal('0'), 0, None)
+
+ try:
+ if not isinstance(self.get_unit_price(**context), Decimal):
+ raise ValueError
+ except Exception, exception:
+ self.raise_user_error('invalid_formula', {
+ 'formula': self.formula,
+ 'line': self.rec_name,
+ 'exception': exception,
+ })
def match(self, pattern):
if 'quantity' in pattern:
@@ -197,10 +147,7 @@ class PriceListLine(ModelSQL, ModelView, MatchMixin):
return False
return super(PriceListLine, self).match(pattern)
- def get_unit_price(self):
- '''
- Return unit price (as Decimal)
- '''
- context = Transaction().context.copy()
- context['Decimal'] = Decimal
- return safe_eval(decistmt(self.formula), context)
+ def get_unit_price(self, **context):
+ 'Return unit price (as Decimal)'
+ context.setdefault('functions', {})['Decimal'] = Decimal
+ return simple_eval(decistmt(self.formula), **context)
diff --git a/price_list.xml b/price_list.xml
index 88b3a00..b84fc9d 100644
--- a/price_list.xml
+++ b/price_list.xml
@@ -19,7 +19,8 @@ this repository contains the full copyright notices and license terms. -->
<record model="ir.action.act_window" id="act_price_list_form">
<field name="name">Price Lists</field>
<field name="res_model">product.price_list</field>
- <field name="domain">[('company', '=', Eval('company'))]</field>
+ <field name="domain"
+ eval="[('company', '=', Eval('company'))]" pyson="1"/>
</record>
<record model="ir.action.act_window.view" id="act_price_list_form_view1">
<field name="sequence" eval="10"/>
@@ -56,7 +57,9 @@ this repository contains the full copyright notices and license terms. -->
<field name="global_p" eval="True"/>
</record>
<record model="ir.rule" id="rule_product_list1">
- <field name="domain">[('company', '=', user.company.id if user.company else None)]</field>
+ <field name="domain"
+ eval="[('company', '=', Eval('user', {}).get('company', None))]"
+ pyson="1"/>
<field name="rule_group" ref="rule_group_product_list"/>
</record>
diff --git a/setup.py b/setup.py
index c6d0c97..18f0ce6 100644
--- a/setup.py
+++ b/setup.py
@@ -1,6 +1,6 @@
#!/usr/bin/env python
-#This file is part of Tryton. The COPYRIGHT file at the top level of
-#this repository contains the full copyright notices and license terms.
+# 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 setuptools import setup
import re
@@ -41,7 +41,7 @@ if minor_version % 2:
'hg+http://hg.tryton.org/modules/%s#egg=%s-%s' % (
name[8:], name, version))
-requires = []
+requires = ['simpleeval', 'python-sql >= 0.4']
for dep in info.get('depends', []):
if not re.match(r'(ir|res|webdav)(\W|$)', dep):
requires.append(get_require_version('trytond_%s' % dep))
@@ -85,6 +85,8 @@ setup(name=name,
'Natural Language :: Spanish',
'Operating System :: OS Independent',
'Programming Language :: Python :: 2.7',
+ 'Programming Language :: Python :: Implementation :: CPython',
+ 'Programming Language :: Python :: Implementation :: PyPy',
'Topic :: Office/Business',
],
license='GPL-3',
diff --git a/tests/__init__.py b/tests/__init__.py
index 761c2f5..d4fff33 100644
--- a/tests/__init__.py
+++ b/tests/__init__.py
@@ -1,5 +1,5 @@
-#This file is part of Tryton. The COPYRIGHT file at the top level of
-#this repository contains the full copyright notices and license terms.
+# 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 .test_product_price_list import suite
diff --git a/tests/test_product_price_list.py b/tests/test_product_price_list.py
index abb5c8e..5ab71f8 100644
--- a/tests/test_product_price_list.py
+++ b/tests/test_product_price_list.py
@@ -1,23 +1,13 @@
-#This file is part of Tryton. The COPYRIGHT file at the top level of
-#this repository contains the full copyright notices and license terms.
+# This file is part of Tryton. The COPYRIGHT file at the top level of
+# this repository contains the full copyright notices and license terms.
import unittest
import trytond.tests.test_tryton
-from trytond.tests.test_tryton import test_view, test_depends
+from trytond.tests.test_tryton import ModuleTestCase
-class ProductPriceListTestCase(unittest.TestCase):
+class ProductPriceListTestCase(ModuleTestCase):
'Test ProductPriceList module'
-
- def setUp(self):
- trytond.tests.test_tryton.install_module('product_price_list')
-
- def test0005views(self):
- 'Test views'
- test_view('product_price_list')
-
- def test0006depends(self):
- 'Test depends'
- test_depends()
+ module = 'product_price_list'
def suite():
diff --git a/tryton.cfg b/tryton.cfg
index f0fe400..2e941e7 100644
--- a/tryton.cfg
+++ b/tryton.cfg
@@ -1,5 +1,5 @@
[tryton]
-version=3.4.1
+version=3.6.0
depends:
company
ir
diff --git a/trytond_product_price_list.egg-info/PKG-INFO b/trytond_product_price_list.egg-info/PKG-INFO
index 61e9174..bc13153 100644
--- a/trytond_product_price_list.egg-info/PKG-INFO
+++ b/trytond_product_price_list.egg-info/PKG-INFO
@@ -1,12 +1,12 @@
Metadata-Version: 1.1
Name: trytond-product-price-list
-Version: 3.4.1
+Version: 3.6.0
Summary: Tryton module with price list
Home-page: http://www.tryton.org/
Author: Tryton
Author-email: issue_tracker at tryton.org
License: GPL-3
-Download-URL: http://downloads.tryton.org/3.4/
+Download-URL: http://downloads.tryton.org/3.6/
Description: trytond_product_price_list
==========================
@@ -64,4 +64,6 @@ Classifier: Natural Language :: Slovenian
Classifier: Natural Language :: Spanish
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 2.7
+Classifier: Programming Language :: Python :: Implementation :: CPython
+Classifier: Programming Language :: Python :: Implementation :: PyPy
Classifier: Topic :: Office/Business
diff --git a/trytond_product_price_list.egg-info/requires.txt b/trytond_product_price_list.egg-info/requires.txt
index a29faeb..49d1daa 100644
--- a/trytond_product_price_list.egg-info/requires.txt
+++ b/trytond_product_price_list.egg-info/requires.txt
@@ -1,3 +1,5 @@
-trytond_company >= 3.4, < 3.5
-trytond_product >= 3.4, < 3.5
-trytond >= 3.4, < 3.5
\ No newline at end of file
+simpleeval
+python-sql >= 0.4
+trytond_company >= 3.6, < 3.7
+trytond_product >= 3.6, < 3.7
+trytond >= 3.6, < 3.7
\ No newline at end of file
diff --git a/view/price_list_form.xml b/view/price_list_form.xml
index 403dc0a..d398f92 100644
--- a/view/price_list_form.xml
+++ b/view/price_list_form.xml
@@ -6,6 +6,12 @@ this repository contains the full copyright notices and license terms. -->
<field name="name"/>
<label name="company"/>
<field name="company"/>
- <field name="lines" colspan="4"
- view_ids="product_price_list.price_list_line_view_tree_sequence"/>
+ <label name="tax_included"/>
+ <field name="tax_included"/>
+ <notebook colspan="4">
+ <page name="lines">
+ <field name="lines" colspan="4"
+ view_ids="product_price_list.price_list_line_view_tree_sequence"/>
+ </page>
+ </notebook>
</form>
diff --git a/view/price_list_tree.xml b/view/price_list_tree.xml
index 9cab295..1c08836 100644
--- a/view/price_list_tree.xml
+++ b/view/price_list_tree.xml
@@ -3,4 +3,5 @@
this repository contains the full copyright notices and license terms. -->
<tree string="Price Lists">
<field name="name"/>
+ <field name="tax_included"/>
</tree>
--
tryton-modules-product-price-list
More information about the tryton-debian-vcs
mailing list