Commit 4e55e3a0 authored by Jérome Perrin's avatar Jérome Perrin

PaySheetModel.getCell should get values on all specialised models, it was just

using the first one.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@19775 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 76459b28
...@@ -77,8 +77,11 @@ class PaySheetModel(TradeCondition, XMLMatrix): ...@@ -77,8 +77,11 @@ class PaySheetModel(TradeCondition, XMLMatrix):
cell = XMLMatrix.getCell(self, *kw, **kwd) cell = XMLMatrix.getCell(self, *kw, **kwd)
# if cell not found, look on the inherited models # if cell not found, look on the inherited models
if cell is None and self.getSpecialiseValue() is not None: if cell is None:
cell = self.getSpecialiseValue().getCell(*kw, **kwd) for specialised_model in self.getSpecialiseValueList():
cell = specialised_model.getCell(*kw, **kwd)
if cell is not None:
return cell
return cell return cell
......
...@@ -355,15 +355,11 @@ class TestPayrollMixin(ERP5TypeTestCase): ...@@ -355,15 +355,11 @@ class TestPayrollMixin(ERP5TypeTestCase):
''' '''
slice = model.newCell(slice, portal_type='Pay Sheet Model Slice', slice = model.newCell(slice, portal_type='Pay Sheet Model Slice',
base_id=base_id) base_id=base_id)
if slice is not None: slice.setQuantityRangeMax(max_value)
slice.setQuantityRangeMax(max_value) slice.setQuantityRangeMin(min_value)
slice.setQuantityRangeMin(min_value) get_transaction().commit()
self.tic()
get_transaction().commit() return slice
slice.reindexObject()
self.tic()
return slice
return None
def addAllSlices(self, model): def addAllSlices(self, model):
''' '''
...@@ -1071,6 +1067,12 @@ class TestPayroll(TestPayrollMixin): ...@@ -1071,6 +1067,12 @@ class TestPayroll(TestPayrollMixin):
model_company.edit(variation_settings_category_list= model_company.edit(variation_settings_category_list=
self.variation_settings_category_list) self.variation_settings_category_list)
model_company_alt = self.paysheet_model_module.newContent(
id='model_company_alt',
portal_type='Pay Sheet Model')
model_company_alt.edit(variation_settings_category_list=
self.variation_settings_category_list)
model_country = self.paysheet_model_module.newContent(id='model_country', model_country = self.paysheet_model_module.newContent(id='model_country',
portal_type='Pay Sheet Model') portal_type='Pay Sheet Model')
model_country.edit(variation_settings_category_list= model_country.edit(variation_settings_category_list=
...@@ -1084,7 +1086,9 @@ class TestPayroll(TestPayrollMixin): ...@@ -1084,7 +1086,9 @@ class TestPayroll(TestPayrollMixin):
model_company.updateCellRange(base_id='cell') model_company.updateCellRange(base_id='cell')
self.addSlice(model_company, 'salary_range/%s' % \ self.addSlice(model_company, 'salary_range/%s' % \
self.france_settings_slice_b, 2, 3) self.france_settings_slice_b, 2, 3)
self.addSlice(model_company, 'salary_range/%s' % \
model_company_alt.updateCellRange(base_id='cell')
self.addSlice(model_company_alt, 'salary_range/%s' % \
self.france_settings_forfait, 20, 30) self.france_settings_forfait, 20, 30)
model_country.updateCellRange(base_id='cell') model_country.updateCellRange(base_id='cell')
...@@ -1092,7 +1096,7 @@ class TestPayroll(TestPayrollMixin): ...@@ -1092,7 +1096,7 @@ class TestPayroll(TestPayrollMixin):
self.france_settings_slice_c, 4, 5) self.france_settings_slice_c, 4, 5)
# inherite from each other # inherite from each other
model_employee.setSpecialiseValue(model_company) model_employee.setSpecialiseValueList((model_company, model_company_alt))
model_company.setSpecialiseValue(model_country) model_company.setSpecialiseValue(model_country)
...@@ -1123,8 +1127,8 @@ class TestPayroll(TestPayrollMixin): ...@@ -1123,8 +1127,8 @@ class TestPayroll(TestPayrollMixin):
self.assertEqual(cell_c.getQuantityRangeMin(), 4) self.assertEqual(cell_c.getQuantityRangeMin(), 4)
self.assertEqual(cell_c.getQuantityRangeMax(), 5) self.assertEqual(cell_c.getQuantityRangeMax(), 5)
# check model_company could access just it's own cell and this of the country # check model_company and model_company_alt could access just it's own cell
# model # and this of the country model
cell_a = model_company.getCell('salary_range/%s' % \ cell_a = model_company.getCell('salary_range/%s' % \
self.france_settings_slice_a) self.france_settings_slice_a)
self.assertEqual(cell_a, None) self.assertEqual(cell_a, None)
...@@ -1135,7 +1139,7 @@ class TestPayroll(TestPayrollMixin): ...@@ -1135,7 +1139,7 @@ class TestPayroll(TestPayrollMixin):
self.assertEqual(cell_b.getQuantityRangeMin(), 2) self.assertEqual(cell_b.getQuantityRangeMin(), 2)
self.assertEqual(cell_b.getQuantityRangeMax(), 3) self.assertEqual(cell_b.getQuantityRangeMax(), 3)
cell_forfait = model_company.getCell('salary_range/%s' % \ cell_forfait = model_company_alt.getCell('salary_range/%s' % \
self.france_settings_forfait) self.france_settings_forfait)
self.assertNotEqual(cell_forfait, None) self.assertNotEqual(cell_forfait, None)
self.assertEqual(cell_forfait.getQuantityRangeMin(), 20) self.assertEqual(cell_forfait.getQuantityRangeMin(), 20)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment