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 * Add compatibility (as extra dependency) with sale_discount
* Improve sale line margin computation unifying getter and on_change_with and * Improve sale line margin computation unifying getter and on_change_with and
calling on_change_with_amount calling on_change_with_amount
Version 3.2.0 - 2014-05-22 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 Version 2.6.0 - 2012-10-16
* Active Record * Active Record
* Simplify module information with python configuration * Simplify module information with python configuration

View File

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

View File

@ -1,61 +1,34 @@
#!/usr/bin/env python #!/usr/bin/env python
#This file is part sale_margin module for Tryton. # This file is part sale_margin module for Tryton.
#The COPYRIGHT file at the top level of this repository contains # The COPYRIGHT file at the top level of this repository contains
#the full copyright notices and license terms. # 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))
import unittest import unittest
import doctest import doctest
import trytond.tests.test_tryton import trytond.tests.test_tryton
from trytond.tests.test_tryton import test_view, test_depends 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): class SaleMarginTestCase(unittest.TestCase):
''' 'Test Sale Margin module'
Test Sale Margin module.
'''
def setUp(self): def setUp(self):
trytond.tests.test_tryton.install_module('sale_margin') trytond.tests.test_tryton.install_module('sale_margin')
def test0005views(self): def test0005views(self):
''' 'Test views'
Test views.
'''
test_view('sale_margin') test_view('sale_margin')
def test0006depends(self): def test0006depends(self):
''' 'Test depends'
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(): def suite():
suite = trytond.tests.test_tryton.suite() suite = trytond.tests.test_tryton.suite()
suite.addTests(unittest.TestLoader().loadTestsFromTestCase( suite.addTests(unittest.TestLoader().loadTestsFromTestCase(
SaleMarginTestCase)) SaleMarginTestCase))
suite.addTests(doctest.DocFileSuite('scenario_sale_margin.rst', 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)) optionflags=doctest.REPORT_ONLY_FIRST_FAILURE))
return suite return suite
if __name__ == '__main__':
unittest.TextTestRunner(verbosity=2).run(suite())