Adapted to 3.4

This commit is contained in:
Guillem Barba 2015-01-22 17:54:51 +01:00
parent 1abc5affce
commit 715ad57ee9
4 changed files with 14 additions and 34 deletions

View File

@ -1 +1,2 @@
Version 3.4.0 - 2015-01-22
* Initial release

17
sale.py
View File

@ -111,16 +111,14 @@ class SaleLine:
Not(Eval('context', {}).get('groups', []).contains(
Id('farm', 'group_farm')))),
'readonly': ~Eval('_parent_sale', {}),
}, depends=['type'],
on_change=['_parent_sale.sale_date', 'type', 'animal',
'animal_location', 'animal_quantity'])
}, depends=['type'])
animal_type = fields.Function(fields.Selection([
(None, ''),
('male', 'Male'),
('female', 'Female'),
('individual', 'Individual'),
('group', 'Group'),
], 'Animal Type', on_change_with=['type', 'animal']),
], 'Animal Type'),
'on_change_with_animal_type')
animal_location = fields.Many2One('stock.location', 'Animal Location',
domain=[
@ -129,9 +127,7 @@ class SaleLine:
'invisible': ~Bool(Eval('animal_type')),
'required': Bool(Eval('animal_type')),
'readonly': Eval('animal_type', '') != 'group',
}, depends=['animal_type'],
on_change=['_parent_sale.sale_date', 'animal', 'animal_location',
'animal_quantity'])
}, depends=['animal_type'])
animal_quantity = fields.Integer('Animal Quantity', states={
'invisible': Eval('animal_type', '') != 'group',
'required': Eval('animal_type', '') == 'group',
@ -143,8 +139,8 @@ class SaleLine:
def __setup__(cls):
super(SaleLine, cls).__setup__()
if hasattr(cls, 'analytic_accounts'):
cls.animal.on_change.append('analytic_accounts')
cls.animal_location.on_change.append('analytic_accounts')
cls.animal.on_change.add('analytic_accounts')
cls.animal_location.on_change.add('analytic_accounts')
@classmethod
def get_animal_models(cls):
@ -157,6 +153,7 @@ class SaleLine:
])
return [('', '')] + [(m.model, m.name) for m in models]
@fields.depends('type', 'animal', '_parent_sale.sale_date')
def on_change_animal(self):
Animal = Pool().get('farm.animal')
@ -196,6 +193,7 @@ class SaleLine:
res['analytic_account_%s' % account.root.id] = account.id
return res
@fields.depends('type', 'animal')
def on_change_with_animal_type(self, name=None):
Animal = Pool().get('farm.animal')
if not self.type or not self.animal or self.animal.id < 0:
@ -204,6 +202,7 @@ class SaleLine:
return self.animal.type
return 'group'
@fields.depends('animal', 'animal_location', '_parent_sale.sale_date')
def on_change_animal_location(self):
if not self.animal or not self.animal_location:
return {

View File

@ -1,18 +1,11 @@
#!/usr/bin/env python
# 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))
import unittest
import doctest
import unittest
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 TestCase(unittest.TestCase):
@ -36,23 +29,10 @@ class TestCase(unittest.TestCase):
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(TestCase))
suite.addTests(doctest.DocFileSuite('scenario_sale_farm.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())

View File

@ -1,5 +1,5 @@
[tryton]
version=3.0.0
version=3.4.0
depends:
farm
sale