Kirti Savalia(OpenERP) has proposed merging
lp:~openerp-dev/openobject-addons/trunk-temporal-db-intermediate-branch-rpa-ksa-yml-ksa
into
lp:~openerp-dev/openobject-addons/trunk-temporal-db-intermediate-branch-rpa-ksa.
Requested reviews:
Rucha (Open ERP) (rpa-openerp)
For more details, see:
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-temporal-db-intermediate-branch-rpa-ksa-yml-ksa/+merge/65932
YML File For Base Temporal
--
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-temporal-db-intermediate-branch-rpa-ksa-yml-ksa/+merge/65932
Your team OpenERP R&D Team is subscribed to branch
lp:~openerp-dev/openobject-addons/trunk-temporal-db-intermediate-branch-rpa-ksa.
=== modified file 'base_temporal/__openerp__.py'
--- base_temporal/__openerp__.py 2011-06-21 06:58:52 +0000
+++ base_temporal/__openerp__.py 2011-06-27 05:18:29 +0000
@@ -40,7 +40,7 @@
'base_temporal_test_view.xml'
,'security/ir.model.access.csv'
],
- 'test': [],
+ 'test': ['test/base_temporal_test.yml'],
'installable': True,
'active': False,
}
=== added directory 'base_temporal/test'
=== added file 'base_temporal/test/base_temporal_test.yml'
--- base_temporal/test/base_temporal_test.yml 1970-01-01 00:00:00 +0000
+++ base_temporal/test/base_temporal_test.yml 2011-06-27 05:18:29 +0000
@@ -0,0 +1,161 @@
+-
+ In order to test base_temporal module in OpenERP, I create a base_temporal.test called "My Contract".
+-
+ !record {model: base.temporal.test, id: base_temporal_my_contract}:
+ name: My Contract
+ temporal_date_from: !eval time.strftime('%Y-%m-%d %H:%M:%S')
+-
+ I create a base_temporal.test called "My Contract" created two days ago.
+-
+ !python {model: base.temporal.test}: |
+ from datetime import datetime, timedelta
+ date_from = datetime.today() - timedelta(days=2)
+ self.write(cr, uid, [(ref("base_temporal_my_contract"))], {'temporal_date_from': date_from})
+-
+ I update the contract to "My Yesterday's Contract" at the date of yesterday.
+-
+ !python {model: base.temporal.test}: |
+ from datetime import datetime, timedelta
+ date_from = datetime.today() - timedelta(days=1)
+ ctx={}
+ vals={}
+ ctx.update({'model':'base.temporal.test', 'active_ids':[ref('base_temporal_my_contract')], 'temporal_mode': True})
+ if context.get('temporal_mode', True):
+ record = self.browse(cr, uid, ref("base_temporal_my_contract"), context=context)
+ vals.update({'temporal_date_from': date_from, 'name': 'My Yesterday Contract'})
+ self.shallow_copy(cr, uid, record.id, {}, context)
+ self.write(cr, uid, [(ref("base_temporal_my_contract"))],vals, context=ctx)
+-
+ I update the contract to "Future Contract" at the date of tomorrow.
+-
+ !python {model: base.temporal.test}: |
+ from datetime import datetime, timedelta
+ date_from = datetime.today() + timedelta(days=1)
+ ctx={}
+ vals={}
+ ctx.update({'model': 'base.temporal.test','active_ids':[ref('base_temporal_my_contract')], 'temporal_mode': True})
+ if context.get('temporal_mode', True):
+ record = self.browse(cr, uid, ref("base_temporal_my_contract"), context=context)
+ vals.update({'temporal_date_from': date_from, 'name':'Future Contract'})
+ self.shallow_copy(cr, uid, record.id, {}, context)
+ self.write(cr, uid, [(ref("base_temporal_my_contract"))],vals, context=ctx)
+-
+ I update the contract to "Current Contract" at the date of today.
+-
+ !python {model: base.temporal.test}: |
+ from datetime import datetime, timedelta
+ date_from = datetime.today()
+ from_date = date_from.isoformat().split('.')[0].replace('T',' ')
+ ctx={}
+ vals={}
+ ctx.update({'model':'base.temporal.test','active_ids':[ref('base_temporal_my_contract')], 'temporal_mode': True})
+ if context.get('temporal_mode', True):
+ record = self.browse(cr, uid, ref("base_temporal_my_contract"), context=context)
+ vals.update({'temporal_date_from': from_date, 'name':'Current Contract'})
+ self.shallow_copy(cr, uid, record.id, {}, context)
+ self.write(cr, uid, [(ref("base_temporal_my_contract"))], vals, context=ctx)
+-
+ I check that I have 4 versions of the "My Contract".
+-
+ !python {model: base.temporal.test}: |
+ from tools.translate import _
+ record = self.browse(cr, uid, ref("base_temporal_my_contract"))
+ version_ids = self.search(cr, uid, ['|',('temporal_parent_id','=',record.id),('id','=',record.id)])
+ assert version_ids, _('Not Found 4 versions of the My Contract')
+-
+ I create a new contract called "Contract 2" at the date of today.
+-
+ !record {model: base.temporal.test, id: base_temporal_contract2}:
+ name: Contract 2
+ temporal_date_from: !eval time.strftime('%Y-%m-%d %H:%M:%S')
+-
+ I check that I have 1 version the new contract called "Contract 2".
+-
+ !python {model: base.temporal.test}: |
+ from tools.translate import _
+ record = self.browse(cr, uid, ref("base_temporal_contract2"))
+ version_ids = self.search(cr, uid, ['|',('temporal_parent_id','=',record.id),('id','=',record.id)])
+ assert version_ids, _('Not Found 1 versions of the Contract2')
+-
+ I check that when I read the name of the first contract at the date of yesterday, I see "My Yesterday's Contract"
+-
+ !python {model: base.temporal.test}: |
+ from datetime import datetime, timedelta
+ from tools.translate import _
+ record = self.browse(cr, uid, ref("base_temporal_my_contract"))
+ temp_date = (datetime.strptime(record.temporal_date_from,"%Y-%m-%d %H:%M:%S")-timedelta(days=1)).strftime('%Y-%m-%d %H:%M:%S')
+ context.update({'temporal_date':temp_date})
+ yesterday_ids = self.read(cr, uid, record.id, ['name'], context=context)
+ assert yesterday_ids, _('Not Found My Yesterday Contract')
+-
+ I check that when I read the name of the first contract at the date of in one month, I see "Future Contract".
+-
+ !python {model: base.temporal.test}: |
+ from datetime import datetime, timedelta
+ from tools.translate import _
+ record = self.browse(cr, uid, ref("base_temporal_my_contract"))
+ temp_date = (datetime.strptime(record.temporal_date_from,"%Y-%m-%d %H:%M:%S")+timedelta(days=1)).strftime('%Y-%m-%d %H:%M:%S')
+ context.update({'temporal_date':temp_date})
+ future_ids = self.read(cr, uid, record.id, ['name'], context=context)
+ assert future_ids, _('Not Found Future Contract')
+-
+ I check that when I read the name of the first contract at the date of in one month, I see "Current Contract".
+-
+ !python {model: base.temporal.test}: |
+ from datetime import datetime, timedelta
+ from tools.translate import _
+ record = self.browse(cr, uid, ref("base_temporal_my_contract"))
+ temp_date = (datetime.strptime(record.temporal_date_from,"%Y-%m-%d %H:%M:%S")).strftime('%Y-%m-%d %H:%M:%S')
+ ids = self.search(cr, uid, [('temporal_date_from','=',temp_date),('id','=',record.id)])
+ context.update({'temporal_date':temp_date})
+ current_ids = self.read(cr, uid, ids, ['name'], context=context)
+ assert current_ids, _('Not Found Current Contract')
+-
+ I create a new contract called "Contract 3" with two lines on this contract "Line 3.1" at the date of today.
+-
+ !record {model: base.temporal.test, id: base_temporal_contract3}:
+ name: Contract 3
+ temporal_date_from: !eval time.strftime('%Y-%m-%d %H:%M:%S')
+ line_ids:
+ - name: Line 3.1
+-
+ I create a new contract called "Contract 3" with two lines on this contract "Line 3.2" at the date of today.
+-
+ !record {model: base.temporal.test, id: base_temporal_contract3}:
+ name: Contract 3
+ temporal_date_from: !eval time.strftime('%Y-%m-%d %H:%M:%S')
+ line_ids:
+ - name: Line 3.2
+-
+ I update "Contract 3" at the date of tomorrow and change name to "Contract 3 Bis" and first line name to "Line 3.2 Bis".
+-
+ !python {model: base.temporal.test}: |
+ from datetime import datetime, timedelta
+ record = self.browse(cr, uid, ref("base_temporal_contract3"))
+ temp_date = (datetime.strptime(record.temporal_date_from,"%Y-%m-%d %H:%M:%S")+timedelta(days=1)).strftime('%Y-%m-%d %H:%M:%S')
+ contract_ids = self.search(cr, uid, [('temporal_parent_id','=',record.id),('temporal_date_from','=',record.temporal_date_from)])
+ self.write(cr, uid, contract_ids, {'name': 'Contract 3 Bis', 'temporal_date_from': temp_date})
+-
+ I read "contract 3" at the date of today and check name "Contract 3" and lines "Line 3.1, Line 3.2" .
+-
+ !python {model: base.temporal.test}: |
+ from tools.translate import _
+ from datetime import datetime, timedelta
+ record = self.browse(cr, uid, ref("base_temporal_contract3"))
+ temp_date = (datetime.strptime(record.temporal_date_from,"%Y-%m-%d %H:%M:%S")).strftime('%Y-%m-%d %H:%M:%S')
+ context.update({'temporal_date':temp_date})
+ contract_ids = self.read(cr, uid, record.id, ['name'], context=context)
+ assert contract_ids, _('Not Found Contract 3')
+-
+ I read "Contract 3" at the date of tomorrow and check name "Contract 3 Bis" and lines "Line 3.1, Line 3.2 Bis" .
+-
+ !python {model: base.temporal.test}: |
+ from tools.translate import _
+ from datetime import datetime, timedelta
+ date_from = datetime.today()+timedelta(days=1)
+ from_date = date_from.isoformat().split('.')[0].replace('T',' ')
+ record = self.browse(cr, uid, ref("base_temporal_contract3"))
+ context.update({'temporal_date':from_date})
+ contract_ids = self.read(cr, uid, record.id, ['name'], context=context)
+ assert contract_ids, _('Not Found Contract 3 Bis')
+
_______________________________________________
Mailing list: https://launchpad.net/~openerp-dev-gtk
Post to : [email protected]
Unsubscribe : https://launchpad.net/~openerp-dev-gtk
More help : https://help.launchpad.net/ListHelp