diff --git a/addons/hr_evaluation/hr_evaluation.py b/addons/hr_evaluation/hr_evaluation.py index 1a945650666..be87543c0e0 100644 --- a/addons/hr_evaluation/hr_evaluation.py +++ b/addons/hr_evaluation/hr_evaluation.py @@ -138,6 +138,7 @@ class hr_evaluation(osv.Model): _name = "hr_evaluation.evaluation" _inherit = ['mail.thread'] _description = "Employee Appraisal" + _rec_name = "employee_id" _columns = { 'date': fields.date("Appraisal Deadline", required=True, select=True), 'employee_id': fields.many2one('hr.employee', "Employee", required=True), diff --git a/addons/l10n_it/data/account.tax.template.csv b/addons/l10n_it/data/account.tax.template.csv index 67daee0eeef..4015d2621cf 100644 --- a/addons/l10n_it/data/account.tax.template.csv +++ b/addons/l10n_it/data/account.tax.template.csv @@ -8,7 +8,7 @@ id,description,chart_template_id:id,name,sequence,amount,parent_id:id,child_depe 10v,10v,l10n_it_chart_template_generic,Iva al 10% (debito),5,0.1,,False,percent,2601,2601,sale,template_impcode_riscossa_10,template_ivacode_riscossa_10,template_impcode_riscossa_10,template_ivacode_riscossa_10,-1,-1,False,1,1 10a,10a,l10n_it_chart_template_generic,Iva al 10% (credito),6,0.1,,False,percent,1601,1601,purchase,template_impcode_pagata_10,template_ivacode_pagata_10,template_impcode_pagata_10,template_ivacode_pagata_10,1,1,False,-1,-1 10AO,10AO,l10n_it_chart_template_generic,Iva al 10% indetraibile,7,0.1,,True,percent,,,purchase,template_impcode_pagata_10ind,,template_impcode_pagata_10ind,,1,1,False,-1,-1 -10AOb,10AOb,l10n_it_chart_template_generic,Iva al 10% indetraibile (D),200,0,10AO,False,balance,1601,1601,purchase,,template_ivacode_pagata_10,,template_ivacode_pagata_10,1,1,False,-1,-1 +10AOb,10AOb,l10n_it_chart_template_generic,Iva al 10% indetraibile (D),200,0,10AO,False,balance,1601,1601,purchase,,template_ivacode_pagata_10ind,,template_ivacode_pagata_10ind,1,1,False,-1,-1 10AOa,10AOa,l10n_it_chart_template_generic,Iva al 10% indetraibile (I),100,1,10AO,False,percent,,,purchase,,template_ivacode_pagata_10ind,,template_ivacode_pagata_10ind,1,1,False,-1,-1 12v,12v,l10n_it_chart_template_generic,Iva 12% (debito),8,0.12,,False,percent,2601,2601,sale,template_impcode_riscossa_12,template_ivacode_riscossa_12,template_impcode_riscossa_12,template_ivacode_riscossa_12,-1,-1,False,1,1 12a,12a,l10n_it_chart_template_generic,Iva 12% (credito),9,0.12,,False,percent,1601,1601,purchase,template_impcode_pagata_12,template_ivacode_pagata_12,template_impcode_pagata_12,template_ivacode_pagata_12,1,1,False,-1,-1 diff --git a/addons/resource/tests/common.py b/addons/resource/tests/common.py index 74b91abde2e..a82bf70b708 100644 --- a/addons/resource/tests/common.py +++ b/addons/resource/tests/common.py @@ -29,8 +29,9 @@ class TestResourceCommon(common.TransactionCase): def setUp(self): super(TestResourceCommon, self).setUp() cr, uid = self.cr, self.uid - if not hasattr(self, 'context'): - self.context = {} + self.context = context = dict(tz='UTC') + + self.registry('res.users').write(cr, uid, uid, {'tz': 'UTC'}, context=context) # Usefull models self.resource_resource = self.registry('resource.resource') @@ -56,7 +57,7 @@ class TestResourceCommon(common.TransactionCase): self.calendar_id = self.resource_calendar.create( cr, uid, { 'name': 'TestCalendar', - } + }, context=context ) self.att1_id = self.resource_attendance.create( cr, uid, { @@ -65,7 +66,7 @@ class TestResourceCommon(common.TransactionCase): 'hour_from': 8, 'hour_to': 16, 'calendar_id': self.calendar_id, - } + }, context=context ) self.att2_id = self.resource_attendance.create( cr, uid, { @@ -74,7 +75,7 @@ class TestResourceCommon(common.TransactionCase): 'hour_from': 8, 'hour_to': 13, 'calendar_id': self.calendar_id, - } + }, context=context ) self.att3_id = self.resource_attendance.create( cr, uid, { @@ -83,7 +84,7 @@ class TestResourceCommon(common.TransactionCase): 'hour_from': 16, 'hour_to': 23, 'calendar_id': self.calendar_id, - } + }, context=context ) self.resource1_id = self.resource_resource.create( cr, uid, { @@ -91,7 +92,7 @@ class TestResourceCommon(common.TransactionCase): 'resource_type': 'user', 'time_efficiency': 150.0, 'calendar_id': self.calendar_id, - } + }, context=context ) self.leave1_id = self.resource_leaves.create( cr, uid, { @@ -99,7 +100,7 @@ class TestResourceCommon(common.TransactionCase): 'calendar_id': self.calendar_id, 'date_from': self.leave1_start, 'date_to': self.leave1_end, - } + }, context=context ) self.leave2_id = self.resource_leaves.create( cr, uid, { @@ -108,7 +109,7 @@ class TestResourceCommon(common.TransactionCase): 'resource_id': self.resource1_id, 'date_from': self.leave2_start, 'date_to': self.leave2_end, - } + }, context=context ) self.leave3_id = self.resource_leaves.create( cr, uid, { @@ -117,7 +118,7 @@ class TestResourceCommon(common.TransactionCase): 'resource_id': self.resource1_id, 'date_from': self.leave3_start, 'date_to': self.leave3_end, - } + }, context=context ) # Some browse data - self.calendar = self.resource_calendar.browse(cr, uid, self.calendar_id) + self.calendar = self.resource_calendar.browse(cr, uid, self.calendar_id, context=context) diff --git a/addons/resource/tests/test_resource.py b/addons/resource/tests/test_resource.py index a26fd55caf2..064a54868f2 100644 --- a/addons/resource/tests/test_resource.py +++ b/addons/resource/tests/test_resource.py @@ -151,16 +151,17 @@ class TestResource(TestResourceCommon): def test_20_calendar_working_intervals(self): """ Testing working intervals computing method of resource.calendar """ cr, uid = self.cr, self.uid + context = self.context _format = '%Y-%m-%d %H:%M:%S' # Test: day0 without leaves: 1 interval - intervals = self.resource_calendar.get_working_intervals_of_day(cr, uid, self.calendar_id, start_dt=self.date1, context={'tz': 'UTC'}) + intervals = self.resource_calendar.get_working_intervals_of_day(cr, uid, self.calendar_id, start_dt=self.date1, context=context) self.assertEqual(len(intervals), 1, 'resource_calendar: wrong working intervals') self.assertEqual(intervals[0][0], datetime.strptime('2013-02-12 09:08:07', _format), 'resource_calendar: wrong working intervals') self.assertEqual(intervals[0][1], datetime.strptime('2013-02-12 16:00:00', _format), 'resource_calendar: wrong working intervals') # Test: day3 without leaves: 2 interval - intervals = self.resource_calendar.get_working_intervals_of_day(cr, uid, self.calendar_id, start_dt=self.date2, context={'tz': 'UTC'}) + intervals = self.resource_calendar.get_working_intervals_of_day(cr, uid, self.calendar_id, start_dt=self.date2, context=context) self.assertEqual(len(intervals), 2, 'resource_calendar: wrong working intervals') self.assertEqual(intervals[0][0], datetime.strptime('2013-02-15 10:11:12', _format), 'resource_calendar: wrong working intervals') self.assertEqual(intervals[0][1], datetime.strptime('2013-02-15 13:00:00', _format), 'resource_calendar: wrong working intervals') @@ -168,7 +169,7 @@ class TestResource(TestResourceCommon): self.assertEqual(intervals[1][1], datetime.strptime('2013-02-15 23:00:00', _format), 'resource_calendar: wrong working intervals') # Test: day0 with leaves outside range: 1 interval - intervals = self.resource_calendar.get_working_intervals_of_day(cr, uid, self.calendar_id, start_dt=self.date1.replace(hour=0), compute_leaves=True, context={'tz': 'UTC'}) + intervals = self.resource_calendar.get_working_intervals_of_day(cr, uid, self.calendar_id, start_dt=self.date1.replace(hour=0), compute_leaves=True, context=context) self.assertEqual(len(intervals), 1, 'resource_calendar: wrong working intervals') self.assertEqual(intervals[0][0], datetime.strptime('2013-02-12 08:00:00', _format), 'resource_calendar: wrong working intervals') self.assertEqual(intervals[0][1], datetime.strptime('2013-02-12 16:00:00', _format), 'resource_calendar: wrong working intervals') @@ -177,7 +178,7 @@ class TestResource(TestResourceCommon): intervals = self.resource_calendar.get_working_intervals_of_day(cr, uid, self.calendar_id, start_dt=self.date1.replace(hour=8) + relativedelta(days=7), end_dt=self.date1.replace(hour=15, minute=45, second=30) + relativedelta(days=7), - compute_leaves=True, context={'tz': 'UTC'}) + compute_leaves=True, context=context) self.assertEqual(len(intervals), 2, 'resource_calendar: wrong working intervals') self.assertEqual(intervals[0][0], datetime.strptime('2013-02-19 08:08:07', _format), 'resource_calendar: wrong working intervals') self.assertEqual(intervals[0][1], datetime.strptime('2013-02-19 09:00:00', _format), 'resource_calendar: wrong working intervals') @@ -187,21 +188,22 @@ class TestResource(TestResourceCommon): def test_30_calendar_working_days(self): """ Testing calendar hours computation on a working day """ cr, uid = self.cr, self.uid + context = self.context _format = '%Y-%m-%d %H:%M:%S' # Test: day1, beginning at 10:30 -> work from 10:30 (arrival) until 16:00 - intervals = self.resource_calendar.get_working_intervals_of_day(cr, uid, self.calendar_id, start_dt=self.date1.replace(hour=10, minute=30, second=0), context={'tz': 'UTC'}) + intervals = self.resource_calendar.get_working_intervals_of_day(cr, uid, self.calendar_id, start_dt=self.date1.replace(hour=10, minute=30, second=0), context=context) self.assertEqual(len(intervals), 1, 'resource_calendar: wrong working interval / day computing') self.assertEqual(intervals[0][0], datetime.strptime('2013-02-12 10:30:00', _format), 'resource_calendar: wrong working interval / day computing') self.assertEqual(intervals[0][1], datetime.strptime('2013-02-12 16:00:00', _format), 'resource_calendar: wrong working interval / day computing') # Test: hour computation for same interval, should give 5.5 - wh = self.resource_calendar.get_working_hours_of_date(cr, uid, self.calendar_id, start_dt=self.date1.replace(hour=10, minute=30, second=0), context={'tz': 'UTC'}) + wh = self.resource_calendar.get_working_hours_of_date(cr, uid, self.calendar_id, start_dt=self.date1.replace(hour=10, minute=30, second=0), context=context) self.assertEqual(wh, 5.5, 'resource_calendar: wrong working interval / day time computing') # Test: day1+7 on leave, without leave computation intervals = self.resource_calendar.get_working_intervals_of_day( cr, uid, self.calendar_id, - start_dt=self.date1.replace(hour=7, minute=0, second=0) + relativedelta(days=7), context={'tz': 'UTC'} + start_dt=self.date1.replace(hour=7, minute=0, second=0) + relativedelta(days=7), context=context ) # Result: day1 (08->16) self.assertEqual(len(intervals), 1, 'resource_calendar: wrong working interval/day computing') @@ -212,7 +214,7 @@ class TestResource(TestResourceCommon): intervals = self.resource_calendar.get_working_intervals_of_day( cr, uid, self.calendar_id, start_dt=self.date1.replace(hour=7, minute=0, second=0) + relativedelta(days=7), - compute_leaves=True, context={'tz': 'UTC'} + compute_leaves=True, context=context ) # Result: day1 (08->09 + 12->16) self.assertEqual(len(intervals), 2, 'resource_calendar: wrong working interval/day computing') @@ -225,7 +227,7 @@ class TestResource(TestResourceCommon): intervals = self.resource_calendar.get_working_intervals_of_day( cr, uid, self.calendar_id, start_dt=self.date1.replace(hour=7, minute=0, second=0) + relativedelta(days=14), - compute_leaves=True, context={'tz': 'UTC'} + compute_leaves=True, context=context ) # Result: day1 (08->16) self.assertEqual(len(intervals), 1, 'resource_calendar: wrong working interval/day computing') @@ -237,7 +239,7 @@ class TestResource(TestResourceCommon): cr, uid, self.calendar_id, start_dt=self.date1.replace(hour=7, minute=0, second=0) + relativedelta(days=14), compute_leaves=True, - resource_id=self.resource1_id, context={'tz': 'UTC'} + resource_id=self.resource1_id, context=context ) # Result: nothing, because on leave self.assertEqual(len(intervals), 0, 'resource_calendar: wrong working interval/day computing') @@ -245,6 +247,7 @@ class TestResource(TestResourceCommon): def test_40_calendar_hours_scheduling(self): """ Testing calendar hours scheduling """ cr, uid = self.cr, self.uid + context = self.context _format = '%Y-%m-%d %H:%M:%S' # -------------------------------------------------- @@ -269,7 +272,7 @@ class TestResource(TestResourceCommon): # (datetime.datetime(2013, 2, 8, 16, 0), datetime.datetime(2013, 2, 8, 23, 0)) # (datetime.datetime(2013, 2, 12, 8, 0), datetime.datetime(2013, 2, 12, 9, 0)) - res = self.resource_calendar.schedule_hours(cr, uid, self.calendar_id, -40, day_dt=self.date1.replace(minute=0, second=0), context={'tz': 'UTC'}) + res = self.resource_calendar.schedule_hours(cr, uid, self.calendar_id, -40, day_dt=self.date1.replace(minute=0, second=0), context=context) # current day, limited at 09:00 because of day_dt specified -> 1 hour self.assertEqual(res[-1][0], datetime.strptime('2013-02-12 08:00:00', _format), 'resource_calendar: wrong hours scheduling') self.assertEqual(res[-1][1], datetime.strptime('2013-02-12 09:00:00', _format), 'resource_calendar: wrong hours scheduling') @@ -308,7 +311,7 @@ class TestResource(TestResourceCommon): res = self.resource_calendar.schedule_hours( cr, uid, self.calendar_id, 40, - day_dt=self.date1.replace(minute=0, second=0), context={'tz': 'UTC'} + day_dt=self.date1.replace(minute=0, second=0), context=context ) self.assertEqual(res[0][0], datetime.strptime('2013-02-12 09:00:00', _format), 'resource_calendar: wrong hours scheduling') self.assertEqual(res[0][1], datetime.strptime('2013-02-12 16:00:00', _format), 'resource_calendar: wrong hours scheduling') @@ -342,8 +345,7 @@ class TestResource(TestResourceCommon): cr, uid, self.calendar_id, 40, day_dt=self.date1.replace(minute=0, second=0), compute_leaves=True, - resource_id=self.resource1_id, - context={'tz': 'UTC'} + resource_id=self.resource1_id, context=context ) self.assertEqual(res[0][0], datetime.strptime('2013-02-12 09:00:00', _format), 'resource_calendar: wrong hours scheduling') self.assertEqual(res[0][1], datetime.strptime('2013-02-12 16:00:00', _format), 'resource_calendar: wrong hours scheduling') @@ -378,7 +380,7 @@ class TestResource(TestResourceCommon): cr, uid, self.calendar_id, self.date1.replace(hour=6, minute=0), self.date2.replace(hour=23, minute=0) + relativedelta(days=7), - resource_id=self.resource1_id, exclude_leaves=True, context={'tz': 'UTC'}) + resource_id=self.resource1_id, exclude_leaves=True, context=context) self.assertEqual(res, 40.0, 'resource_calendar: wrong _interval_hours_get compatibility computation') # new API: resource without leaves @@ -387,7 +389,7 @@ class TestResource(TestResourceCommon): cr, uid, self.calendar_id, self.date1.replace(hour=6, minute=0), self.date2.replace(hour=23, minute=0) + relativedelta(days=7), - compute_leaves=False, resource_id=self.resource1_id, context={'tz': 'UTC'}) + compute_leaves=False, resource_id=self.resource1_id, context=context) self.assertEqual(res, 40.0, 'resource_calendar: wrong get_working_hours computation') # old API: resource and leaves @@ -396,7 +398,7 @@ class TestResource(TestResourceCommon): cr, uid, self.calendar_id, self.date1.replace(hour=6, minute=0), self.date2.replace(hour=23, minute=0) + relativedelta(days=7), - resource_id=self.resource1_id, exclude_leaves=False, context={'tz': 'UTC'}) + resource_id=self.resource1_id, exclude_leaves=False, context=context) self.assertEqual(res, 33.0, 'resource_calendar: wrong _interval_hours_get compatibility computation') # new API: resource and leaves @@ -405,7 +407,7 @@ class TestResource(TestResourceCommon): cr, uid, self.calendar_id, self.date1.replace(hour=6, minute=0), self.date2.replace(hour=23, minute=0) + relativedelta(days=7), - compute_leaves=True, resource_id=self.resource1_id, context={'tz': 'UTC'}) + compute_leaves=True, resource_id=self.resource1_id, context=context) self.assertEqual(res, 33.0, 'resource_calendar: wrong get_working_hours computation') # -------------------------------------------------- @@ -418,7 +420,7 @@ class TestResource(TestResourceCommon): self.date1.replace(hour=6, minute=0), self.date2.replace(hour=23, minute=0), compute_leaves=True, resource_id=self.resource1_id, - default_interval=(8, 16), context={'tz': 'UTC'}) + default_interval=(8, 16), context=context) self.assertEqual(res, 32.0, 'resource_calendar: wrong get_working_hours computation') def test_50_calendar_schedule_days(self): diff --git a/addons/stock_landed_costs/stock_landed_costs.py b/addons/stock_landed_costs/stock_landed_costs.py index c3c67d4ac4e..598ddf7f368 100644 --- a/addons/stock_landed_costs/stock_landed_costs.py +++ b/addons/stock_landed_costs/stock_landed_costs.py @@ -24,6 +24,7 @@ import openerp.addons.decimal_precision as dp from openerp.tools import float_compare, float_round from openerp.tools.translate import _ import product +from openerp import SUPERUSER_ID from openerp.exceptions import UserError @@ -214,8 +215,7 @@ class stock_landed_cost(osv.osv): else: quant_dict[quant.id] += diff for key, value in quant_dict.items(): - print value - quant_obj.write(cr, uid, key, {'cost': value}, context=context) + quant_obj.write(cr, SUPERUSER_ID, key, {'cost': value}, context=context) qty_out = 0 for quant in line.move_id.quant_ids: if quant.location_id.usage != 'internal': diff --git a/doc/cla/corporate/bizzappdev.md b/doc/cla/corporate/bizzappdev.md new file mode 100644 index 00000000000..466a086fb67 --- /dev/null +++ b/doc/cla/corporate/bizzappdev.md @@ -0,0 +1,16 @@ +India, 2015-09-19 + +BizzAppDev agrees to the terms of the Odoo Corporate Contributor License +Agreement v1.0. + +I declare that I am authorized and able to make this agreement and sign this +declaration. + +Signed, + +Ruchir Shukla ruchir@bizzappdev.com https://github.com/bizzappdev + +List of contributors: + +Ruchir Shukla ruchir@bizzappdev.com https://github.com/bizzappdev + diff --git a/openerp/addons/base/ir/ir_ui_view.py b/openerp/addons/base/ir/ir_ui_view.py index 4724206a5f4..da14b2ef65f 100644 --- a/openerp/addons/base/ir/ir_ui_view.py +++ b/openerp/addons/base/ir/ir_ui_view.py @@ -1216,6 +1216,7 @@ class view(osv.osv): LEFT JOIN ir_model_data md ON (md.model = 'ir.ui.view' AND md.res_id = v.id) WHERE md.module IS NULL AND v.model = %s + AND v.active = true GROUP BY coalesce(v.inherit_id, v.id) """, (model,)) diff --git a/openerp/tests/common.py b/openerp/tests/common.py index c71e430fb00..6095ae03540 100644 --- a/openerp/tests/common.py +++ b/openerp/tests/common.py @@ -144,12 +144,13 @@ class TransactionCase(BaseCase): #: :class:`~openerp.api.Environment` for the current test case self.env = api.Environment(self.cr, self.uid, {}) - def tearDown(self): - # rollback and close the cursor, and reset the environments + @self.addCleanup + def reset(): + # rollback and close the cursor, and reset the environments self.registry.clear_caches() - self.env.reset() - self.cr.rollback() - self.cr.close() + self.env.reset() + self.cr.rollback() + self.cr.close() def patch_order(self, model, order): m_e = self.env[model]