Migrate to version 3.4

This commit is contained in:
Sergi Almacellas Abellana 2014-11-05 17:17:48 +01:00
parent 0a58a352ba
commit 6a86ba5cac
3 changed files with 17 additions and 37 deletions

View File

@ -1,9 +1,14 @@
Version 3.4.0 - 2014-11-03
* Add compatibility (as extra dependency) with sale_discount
* Improve sale line margin computation unifying getter and on_change_with and
calling on_change_with_amount
Version 3.2.0 - 2014-05-22
Version 3.0.0 - 2013-10-25
Version 2.8.0 - 2013-04-26
Version 2.6.0 - 2012-10-16
* Active Record
* Simplify module information with python configuration

View File

@ -5,8 +5,8 @@ from decimal import Decimal
from trytond.model import fields
from trytond.pyson import Eval
from trytond.pool import Pool, PoolMeta
from trytond.config import CONFIG
DIGITS = int(CONFIG.get('unit_price_digits', 4))
from trytond.config import config
DIGITS = int(config.get('digits', 'unit_price_digits', 4))
__all__ = ['Sale', 'SaleLine']
__metaclass__ = PoolMeta
@ -86,6 +86,8 @@ class SaleLine:
Return the margin of each sale lines
'''
Currency = Pool().get('currency.currency')
if not self.sale or not self.sale.currency:
return Decimal('0.0')
currency = self.sale.currency
if self.type == 'line':
cost = Decimal(str(self.quantity)) * (self.cost_price or

View File

@ -1,61 +1,34 @@
#!/usr/bin/env python
#This file is part sale_margin module for Tryton.
#The COPYRIGHT file at the top level of this repository contains
#the full copyright notices and license terms.
import sys
import os
DIR = os.path.abspath(os.path.normpath(os.path.join(__file__,
'..', '..', '..', '..', '..', 'trytond')))
if os.path.isdir(DIR):
sys.path.insert(0, os.path.dirname(DIR))
# This file is part sale_margin module for Tryton.
# The COPYRIGHT file at the top level of this repository contains
# the full copyright notices and license terms.
import unittest
import doctest
import trytond.tests.test_tryton
from trytond.tests.test_tryton import test_view, test_depends
from trytond.backend.sqlite.database import Database as SQLiteDatabase
from trytond.tests.test_tryton import doctest_setup, doctest_teardown
class SaleMarginTestCase(unittest.TestCase):
'''
Test Sale Margin module.
'''
'Test Sale Margin module'
def setUp(self):
trytond.tests.test_tryton.install_module('sale_margin')
def test0005views(self):
'''
Test views.
'''
'Test views'
test_view('sale_margin')
def test0006depends(self):
'''
Test depends.
'''
'Test depends'
test_depends()
def doctest_dropdb(test):
database = SQLiteDatabase().connect()
cursor = database.cursor(autocommit=True)
try:
database.drop(cursor, ':memory:')
cursor.commit()
finally:
cursor.close()
def suite():
suite = trytond.tests.test_tryton.suite()
suite.addTests(unittest.TestLoader().loadTestsFromTestCase(
SaleMarginTestCase))
suite.addTests(doctest.DocFileSuite('scenario_sale_margin.rst',
setUp=doctest_dropdb, tearDown=doctest_dropdb, encoding='utf-8',
setUp=doctest_setup, tearDown=doctest_teardown, encoding='utf-8',
optionflags=doctest.REPORT_ONLY_FIRST_FAILURE))
return suite
if __name__ == '__main__':
unittest.TextTestRunner(verbosity=2).run(suite())