From 721b855e34a998fa454434e82aeae2f49da16d9f Mon Sep 17 00:00:00 2001 From: Jigar Amin - OpenERP Date: Mon, 21 Nov 2011 18:57:35 +0530 Subject: [PATCH 02/63] [IMP] updated openerp descriptor for the adding test case bzr revid: jam@tinyerp.com-20111121132735-lw9gfa02gu5p5y6a --- addons/resource/__openerp__.py | 1 + 1 file changed, 1 insertion(+) diff --git a/addons/resource/__openerp__.py b/addons/resource/__openerp__.py index f1e020215a6..92091221d85 100644 --- a/addons/resource/__openerp__.py +++ b/addons/resource/__openerp__.py @@ -45,6 +45,7 @@ It also manages the leaves of every resource. ], 'demo_xml': ['resource_demo.xml' ], + 'test': [],#TODO: Add Resource test cases 'installable': True, 'active': False, 'certificate': '00746371192190459469', From f33ac6c84a3e77c098337b104da91b39c33d586e Mon Sep 17 00:00:00 2001 From: Jigar Amin - OpenERP Date: Tue, 22 Nov 2011 12:34:40 +0530 Subject: [PATCH 05/63] [ADD] Added Demo data for the on change bzr revid: jam@tinyerp.com-20111122070440-2o9sbpud5zxe0eek --- addons/resource/__openerp__.py | 2 +- addons/resource/resource_demo.xml | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/addons/resource/__openerp__.py b/addons/resource/__openerp__.py index 92091221d85..f6cdb178e83 100644 --- a/addons/resource/__openerp__.py +++ b/addons/resource/__openerp__.py @@ -45,7 +45,7 @@ It also manages the leaves of every resource. ], 'demo_xml': ['resource_demo.xml' ], - 'test': [],#TODO: Add Resource test cases + 'test': ['test/on_chnage_resource.yml'],#TODO: Add Resource test cases 'installable': True, 'active': False, 'certificate': '00746371192190459469', diff --git a/addons/resource/resource_demo.xml b/addons/resource/resource_demo.xml index 2d1b6622e07..989a029f93f 100644 --- a/addons/resource/resource_demo.xml +++ b/addons/resource/resource_demo.xml @@ -79,5 +79,30 @@ + + + + Demo Resource + + + user + + + + Morning 2 Hours On Leave + + + + + + + + Half Day Seak Leave + + + + + + From aaf8819e97452f6ea1938bae34e7aeccbee50ae9 Mon Sep 17 00:00:00 2001 From: Jigar Amin - OpenERP Date: Tue, 22 Nov 2011 12:35:56 +0530 Subject: [PATCH 06/63] [ADD] Added the On Change Resource YAML for the Resource Leave bzr revid: jam@tinyerp.com-20111122070556-hxp192kapzurhk5b --- addons/resource/test/on_chnage_resource.yml | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 addons/resource/test/on_chnage_resource.yml diff --git a/addons/resource/test/on_chnage_resource.yml b/addons/resource/test/on_chnage_resource.yml new file mode 100644 index 00000000000..429e9328939 --- /dev/null +++ b/addons/resource/test/on_chnage_resource.yml @@ -0,0 +1,6 @@ +- + I changing the Working Calendarof 'Demo Resource' +- + !record {model: resource.calendar.leaves, id: resource_calendar_leaves_demoleave1}: + calendar_id: resource.timesheet_group1 + resource_id: resource.resource_resource_demorsource From 545889f2bb05178975384e090f70dc8818f647e4 Mon Sep 17 00:00:00 2001 From: Jigar Amin - OpenERP Date: Tue, 22 Nov 2011 12:37:08 +0530 Subject: [PATCH 07/63] [FIX] yaml typo bzr revid: jam@tinyerp.com-20111122070708-qwixijixoght6qvn --- addons/resource/test/on_chnage_resource.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/resource/test/on_chnage_resource.yml b/addons/resource/test/on_chnage_resource.yml index 429e9328939..ade15fb1ade 100644 --- a/addons/resource/test/on_chnage_resource.yml +++ b/addons/resource/test/on_chnage_resource.yml @@ -1,5 +1,5 @@ - - I changing the Working Calendarof 'Demo Resource' + I changing the Resource of the Leave of 'Demo Resource'. - !record {model: resource.calendar.leaves, id: resource_calendar_leaves_demoleave1}: calendar_id: resource.timesheet_group1 From becbd5b33d0a20708adc78130a5e3f9a4f74c4e7 Mon Sep 17 00:00:00 2001 From: Jigar Amin - OpenERP Date: Tue, 22 Nov 2011 17:15:27 +0530 Subject: [PATCH 08/63] [IMP] Added yaml udner test section bzr revid: jam@tinyerp.com-20111122114527-1e9uqmt80b6g4ldw --- addons/resource/__openerp__.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/addons/resource/__openerp__.py b/addons/resource/__openerp__.py index f6cdb178e83..77ce9da3c2c 100644 --- a/addons/resource/__openerp__.py +++ b/addons/resource/__openerp__.py @@ -45,7 +45,10 @@ It also manages the leaves of every resource. ], 'demo_xml': ['resource_demo.xml' ], - 'test': ['test/on_chnage_resource.yml'],#TODO: Add Resource test cases + 'test': [ + 'test/on_chnage_resource.yml', + 'test/test_resource.yml', + ], 'installable': True, 'active': False, 'certificate': '00746371192190459469', From 221973ba63797cf08e1eb572fec708173a919327 Mon Sep 17 00:00:00 2001 From: Jigar Amin - OpenERP Date: Tue, 22 Nov 2011 17:16:28 +0530 Subject: [PATCH 09/63] [ADD] Added the yaml for the resource fucntion validation bzr revid: jam@tinyerp.com-20111122114628-zgaq98cjy17pndf8 --- addons/resource/test/test_resource.yml | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 addons/resource/test/test_resource.yml diff --git a/addons/resource/test/test_resource.yml b/addons/resource/test/test_resource.yml new file mode 100644 index 00000000000..c1eb392c8b6 --- /dev/null +++ b/addons/resource/test/test_resource.yml @@ -0,0 +1,23 @@ +- + I generate resource detail for the User "Demo" +- + !python {model: resource.resource}: | + res = self.generate_resources(cr, uid, [ref('base.user_demo')], ref('timesheet_group1')) + assert res, "Resource is not generated." + for resource in res.values(): + assert resource.get('efficiency') == 0.8, "Wrong resource has been Generated" + assert resource.get('vacation'), 'No vaction calculated' + +- + I compute vecation for the reource "Demo Resource" +- + !python {model: resource.resource}: | + res= self.compute_vacation(cr, uid, ref('timesheet_group1'), ref('resource_resource_demorsource')) + assert res, "No vacation generated for the resource 'Demo Resource'." + +- + I compute the working calendar for the resource 'Demo Resource'. +- + !python {model: resource.resource}: | + res= self.compute_working_calendar(cr, uid, ref('timesheet_group1')) + assert res, "No working calendar generated for the resource 'Demo Resource'." From 46348ccf3150a8b68d03f1f7147e936996d22659 Mon Sep 17 00:00:00 2001 From: Jigar Amin - OpenERP Date: Tue, 29 Nov 2011 10:08:49 +0530 Subject: [PATCH 10/63] [RM/ADD] rearragned the yaml and refcetored the yamls bzr revid: jam@tinyerp.com-20111129043849-i0k4udno1x2jklz1 --- addons/resource/__openerp__.py | 2 +- .../test/{ => process}/test_resource.yml | 18 ++++++++++-------- .../test/{ => ui}/on_chnage_resource.yml | 2 +- 3 files changed, 12 insertions(+), 10 deletions(-) rename addons/resource/test/{ => process}/test_resource.yml (74%) rename addons/resource/test/{ => ui}/on_chnage_resource.yml (65%) diff --git a/addons/resource/__openerp__.py b/addons/resource/__openerp__.py index 77ce9da3c2c..10626110324 100644 --- a/addons/resource/__openerp__.py +++ b/addons/resource/__openerp__.py @@ -46,8 +46,8 @@ It also manages the leaves of every resource. 'demo_xml': ['resource_demo.xml' ], 'test': [ - 'test/on_chnage_resource.yml', 'test/test_resource.yml', + 'test/on_chnage_resource.yml', ], 'installable': True, 'active': False, diff --git a/addons/resource/test/test_resource.yml b/addons/resource/test/process/test_resource.yml similarity index 74% rename from addons/resource/test/test_resource.yml rename to addons/resource/test/process/test_resource.yml index c1eb392c8b6..df9fd9e2708 100644 --- a/addons/resource/test/test_resource.yml +++ b/addons/resource/test/process/test_resource.yml @@ -1,5 +1,7 @@ +- | + In Order to Test resource : I use the 'Demo resource' from Demo Record, with 38 Hours / week and 9 Hours / Day working calendar scheduled. - - I generate resource detail for the User "Demo" + First, I generate resource detail for the User "Demo" - !python {model: resource.resource}: | res = self.generate_resources(cr, uid, [ref('base.user_demo')], ref('timesheet_group1')) @@ -8,16 +10,16 @@ assert resource.get('efficiency') == 0.8, "Wrong resource has been Generated" assert resource.get('vacation'), 'No vaction calculated' -- - I compute vecation for the reource "Demo Resource" -- - !python {model: resource.resource}: | - res= self.compute_vacation(cr, uid, ref('timesheet_group1'), ref('resource_resource_demorsource')) - assert res, "No vacation generated for the resource 'Demo Resource'." - - I compute the working calendar for the resource 'Demo Resource'. - !python {model: resource.resource}: | res= self.compute_working_calendar(cr, uid, ref('timesheet_group1')) assert res, "No working calendar generated for the resource 'Demo Resource'." + +- + I compute vacation for the resource "Demo Resource" based on his Resource Leave Request(s). +- + !python {model: resource.resource}: | + res= self.compute_vacation(cr, uid, ref('timesheet_group1'), ref('resource_resource_demorsource')) + assert res, "No vacation generated for the resource 'Demo Resource'." diff --git a/addons/resource/test/on_chnage_resource.yml b/addons/resource/test/ui/on_chnage_resource.yml similarity index 65% rename from addons/resource/test/on_chnage_resource.yml rename to addons/resource/test/ui/on_chnage_resource.yml index ade15fb1ade..821b3efa5e4 100644 --- a/addons/resource/test/on_chnage_resource.yml +++ b/addons/resource/test/ui/on_chnage_resource.yml @@ -1,5 +1,5 @@ - - I changing the Resource of the Leave of 'Demo Resource'. + I create resource calendar leave record to call event resource onchange event for "Demo Resource". - !record {model: resource.calendar.leaves, id: resource_calendar_leaves_demoleave1}: calendar_id: resource.timesheet_group1 From a3e243fee4f72c70885633963cbf7cd4634501e1 Mon Sep 17 00:00:00 2001 From: Jigar Amin - OpenERP Date: Tue, 29 Nov 2011 10:10:37 +0530 Subject: [PATCH 11/63] [FIX] Refectored the test case file reference bzr revid: jam@tinyerp.com-20111129044037-px01nteee4b9opid --- addons/resource/__openerp__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/resource/__openerp__.py b/addons/resource/__openerp__.py index 10626110324..3fc4b4b7cfc 100644 --- a/addons/resource/__openerp__.py +++ b/addons/resource/__openerp__.py @@ -46,8 +46,8 @@ It also manages the leaves of every resource. 'demo_xml': ['resource_demo.xml' ], 'test': [ - 'test/test_resource.yml', - 'test/on_chnage_resource.yml', + 'test/process/test_resource.yml', + 'test/ui/on_chnage_resource.yml', ], 'installable': True, 'active': False, From 6f9262a9f6e663789af80f4e4e645310016d77c9 Mon Sep 17 00:00:00 2001 From: Jigar Amin - OpenERP Date: Tue, 29 Nov 2011 10:24:32 +0530 Subject: [PATCH 12/63] [ADD] Added test case to check resource duplicate bzr revid: jam@tinyerp.com-20111129045432-3asz2skngzh8mh3t --- addons/resource/__openerp__.py | 3 ++- addons/resource/test/ui/duplicate_resource.yml | 6 ++++++ .../ui/{on_chnage_resource.yml => on_change_resource.yml} | 0 3 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 addons/resource/test/ui/duplicate_resource.yml rename addons/resource/test/ui/{on_chnage_resource.yml => on_change_resource.yml} (100%) diff --git a/addons/resource/__openerp__.py b/addons/resource/__openerp__.py index 3fc4b4b7cfc..3d08b81494b 100644 --- a/addons/resource/__openerp__.py +++ b/addons/resource/__openerp__.py @@ -47,7 +47,8 @@ It also manages the leaves of every resource. ], 'test': [ 'test/process/test_resource.yml', - 'test/ui/on_chnage_resource.yml', + 'test/ui/on_change_resource.yml', + 'test/ui/duplicate_resource.yml', ], 'installable': True, 'active': False, diff --git a/addons/resource/test/ui/duplicate_resource.yml b/addons/resource/test/ui/duplicate_resource.yml new file mode 100644 index 00000000000..45f1f5aa28e --- /dev/null +++ b/addons/resource/test/ui/duplicate_resource.yml @@ -0,0 +1,6 @@ +- + I duplicate the resource "Demo resource" +- + !python {model: resource.resource}: | + copied_id = self.copy(cr, uid, ref("resource_resource_demorsource")) + assert copied_id, "Unablr to Duplicate Reousrce" diff --git a/addons/resource/test/ui/on_chnage_resource.yml b/addons/resource/test/ui/on_change_resource.yml similarity index 100% rename from addons/resource/test/ui/on_chnage_resource.yml rename to addons/resource/test/ui/on_change_resource.yml From f0ddecdb8fc2d11f3a751095d69360e090d7558f Mon Sep 17 00:00:00 2001 From: Jigar Amin - OpenERP Date: Tue, 29 Nov 2011 10:25:59 +0530 Subject: [PATCH 13/63] [FIX] Removed the fuction def prototype of check_availability in resource_resource bzr revid: jam@tinyerp.com-20111129045559-31vm4mzvmvkwnak5 --- addons/resource/resource.py | 7 ------- 1 file changed, 7 deletions(-) diff --git a/addons/resource/resource.py b/addons/resource/resource.py index bd62c449d2b..59844da4c36 100644 --- a/addons/resource/resource.py +++ b/addons/resource/resource.py @@ -366,13 +366,6 @@ class resource_resource(osv.osv): wktime_cal.append((non_working[:-1], time_range)) return wktime_cal - #TODO: Write optimized alogrothem for resource availability. : Method Yet not implemented - def check_availability(self, cr, uid, ids, start, end, context=None): - if context == None: - contex = {} - allocation = {} - return allocation - resource_resource() class resource_calendar_leaves(osv.osv): From d75cd905a7a41a26943e3a6a841e0eb81c15f2ef Mon Sep 17 00:00:00 2001 From: Jigar Amin - OpenERP Date: Tue, 29 Nov 2011 10:27:36 +0530 Subject: [PATCH 14/63] [RM] rmoved the Unused import stmt bzr revid: jam@tinyerp.com-20111129045736-0ev604ced41napfq --- addons/resource/resource.py | 1 - 1 file changed, 1 deletion(-) diff --git a/addons/resource/resource.py b/addons/resource/resource.py index 59844da4c36..9229d7293eb 100644 --- a/addons/resource/resource.py +++ b/addons/resource/resource.py @@ -22,7 +22,6 @@ from datetime import datetime, timedelta import math from faces import * -from new import classobj from osv import fields, osv from tools.translate import _ From 630271cbbbb3c5735f953e8f2facf1c91f1baa07 Mon Sep 17 00:00:00 2001 From: Jigar Amin - OpenERP Date: Tue, 29 Nov 2011 11:06:02 +0530 Subject: [PATCH 15/63] [ADD] Added test case to check the resource calandar fucntion bzr revid: jam@tinyerp.com-20111129053602-nf19mwtk8ya19ahi --- addons/resource/__openerp__.py | 1 + .../test/process/test_resource_calendar.yml | 29 +++++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 addons/resource/test/process/test_resource_calendar.yml diff --git a/addons/resource/__openerp__.py b/addons/resource/__openerp__.py index 3d08b81494b..e27d9be8fe6 100644 --- a/addons/resource/__openerp__.py +++ b/addons/resource/__openerp__.py @@ -47,6 +47,7 @@ It also manages the leaves of every resource. ], 'test': [ 'test/process/test_resource.yml', + 'test/process/test_resource_calendar.yml', 'test/ui/on_change_resource.yml', 'test/ui/duplicate_resource.yml', ], diff --git a/addons/resource/test/process/test_resource_calendar.yml b/addons/resource/test/process/test_resource_calendar.yml new file mode 100644 index 00000000000..04f54c746eb --- /dev/null +++ b/addons/resource/test/process/test_resource_calendar.yml @@ -0,0 +1,29 @@ +- | + In order to test resource calendar, I use the Demo record '38 Hours/Week'. +- + I check the working hour on day for resoruce 'Demo Resource' using calendar '38 Hours/Week' . +- + !python {model: resource.calendar}: | + from datetime import datetime + dt = datetime.now() + calendar = self.browse(cr, uid, ref('timesheet_group1')) + result = self.working_hours_on_day(cr, uid, calendar, dt, context) + assert result, "No Working Our on Day for Resource has been Generated." +- + I Check the Resource 6.0 Hours Working Internal Timeming Based on Resource Calendar. +- + !python {model: resource.calendar}: | + from datetime import datetime + dt = datetime.now() + result = self.interval_get(cr, uid, ref('timesheet_group1'), dt, 6.0) + assert result, 'No Working Internal Timeming Generated' + +- + I check total number of working hours on resource in between three dates based on resource working calendar. +- + !python {model: resource.calendar}: | + from datetime import datetime, timedelta + dt_from = datetime.now() + dt_to = dt_from + timedelta(days=3) + hours = self.interval_hours_get(cr, uid, ref('timesheet_group1'), dt_from, dt_to) + assert hours, 'No Working Hours Generated' From 477becd62aa2485a4353cbcb7a41e327621d3af6 Mon Sep 17 00:00:00 2001 From: Jigar Amin - OpenERP Date: Tue, 29 Nov 2011 11:24:53 +0530 Subject: [PATCH 16/63] [IMP] Added the test case to calculate resource working schedule bzr revid: jam@tinyerp.com-20111129055453-zh6akbwvm7vniivr --- .../resource/test/process/test_resource_calendar.yml | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/addons/resource/test/process/test_resource_calendar.yml b/addons/resource/test/process/test_resource_calendar.yml index 04f54c746eb..04310d72f26 100644 --- a/addons/resource/test/process/test_resource_calendar.yml +++ b/addons/resource/test/process/test_resource_calendar.yml @@ -1,7 +1,7 @@ - | In order to test resource calendar, I use the Demo record '38 Hours/Week'. - - I check the working hour on day for resoruce 'Demo Resource' using calendar '38 Hours/Week' . + I check the working hour on day for resource 'Demo Resource' using calendar '38 Hours/Week' . - !python {model: resource.calendar}: | from datetime import datetime @@ -27,3 +27,11 @@ dt_to = dt_from + timedelta(days=3) hours = self.interval_hours_get(cr, uid, ref('timesheet_group1'), dt_from, dt_to) assert hours, 'No Working Hours Generated' +- + I check resource working schedule based on resource calendar for 30 Hours. +- + !python {model: resource.calendar}: | + from datetime import datetime, timedelta + dt_from = datetime.now() + hours = self.interval_min_get(cr, uid, ref('timesheet_group1'), dt_from, 30.0, resource=ref('resource_resource_demorsource')) + assert hours, 'No Working Schedule Generated.' From e726b6ee40153f5201d4815089285709a93130a8 Mon Sep 17 00:00:00 2001 From: Jigar Amin - OpenERP Date: Tue, 29 Nov 2011 12:00:28 +0530 Subject: [PATCH 17/63] [IMP/FIX] YAMl typos and missing docstring for the reosurce calendar def bzr revid: jam@tinyerp.com-20111129063028-0k7zkk1hrr1jd0vp --- addons/resource/resource.py | 52 ++++++++++++++++++- .../test/process/test_resource_calendar.yml | 4 +- 2 files changed, 52 insertions(+), 4 deletions(-) diff --git a/addons/resource/resource.py b/addons/resource/resource.py index 9229d7293eb..edb900bf2fc 100644 --- a/addons/resource/resource.py +++ b/addons/resource/resource.py @@ -43,9 +43,12 @@ class resource_calendar(osv.osv): } def working_hours_on_day(self, cr, uid, resource_calendar_id, day, context=None): - """ + """Calculates the Working Total Hours based on Resource Calendar and + given working day (datetime object). + @param resource_calendar_id: resource.calendar browse record @param day: datetime object + @return: returns the working hours (as float) men should work on the given day if is in the attendance_ids of the resource_calendar_id (i.e if that day is a working day), returns 0.0 otherwise """ res = 0.0 @@ -55,9 +58,16 @@ class resource_calendar(osv.osv): return res def _get_leaves(self, cr, uid, id, resource): + """Private Method to Calculate resource Leaves days + + @param id: resource calendar id + @param resource: resource id for which leaves will ew calculated + + @return : returns the list of dates, where resource on leave in + resource.calendar.leaves object (e.g.['%Y-%m-%d', '%Y-%m-%d']) + """ resource_cal_leaves = self.pool.get('resource.calendar.leaves') dt_leave = [] - resource_leave_ids = resource_cal_leaves.search(cr, uid, [('calendar_id','=',id), '|', ('resource_id','=',False), ('resource_id','=',resource)]) #res_leaves = resource_cal_leaves.read(cr, uid, resource_leave_ids, ['date_from', 'date_to']) res_leaves = resource_cal_leaves.browse(cr, uid, resource_leave_ids) @@ -72,6 +82,21 @@ class resource_calendar(osv.osv): return dt_leave def interval_min_get(self, cr, uid, id, dt_from, hours, resource=False): + """ + Calculates the working Schedule from supplied from date to till hours + will be satisfied based or resource calendar id. If resource is also + given then it will consider the resource leave also and than will + calculates resource working schedule + + @param dt_from: datetime object, start of working scheduled + @param hours: float, total number working hours needed scheduled from + start date + @param resource : Optional Resource id, if supplied than resource leaves + will also taken into consideration for calculating working + schedule. + @return : List datetime object of working schedule based on supplies + params + """ if not id: td = int(hours)*3 return [(dt_from - timedelta(hours=td), dt_from)] @@ -161,10 +186,32 @@ class resource_calendar(osv.osv): return results def interval_get(self, cr, uid, id, dt_from, hours, resource=False, byday=True): + """Calculates Resource Working Internal Timing Based on Resource Calendar. + + @param dt_from: start resource schedule calculation. + @param hours : total number of working hours to be scheduled. + @param resource: optional resource id, If supplied it will take care of + resource leave while scheduling. + @param byday: boolean flag bit enforce day wise scheduling + + @return : list of scheduled working timing based on resource calendar. + """ res = self.interval_get_multi(cr, uid, [(dt_from.strftime('%Y-%m-%d %H:%M:%S'), hours, id)], resource, byday)[(dt_from.strftime('%Y-%m-%d %H:%M:%S'), hours, id)] return res def interval_hours_get(self, cr, uid, id, dt_from, dt_to, resource=False): + """ Calculates the Total Working hours based on given start_date to + end_date, If resource id is supplied that it will consider the source + leaves also in calculating the hours. + + @param dt_from : date start to calculate hours + @param dt_end : date end to calculate hours + @param resource: optional resource id, If given resource leave will be + considered. + + @return : Total number of working hours based dt_from and dt_end and + resource if supplied. + """ if not id: return 0.0 dt_leave = self._get_leaves(cr, uid, id, resource) @@ -289,6 +336,7 @@ class resource_resource(osv.osv): def compute_vacation(self, cr, uid, calendar_id, resource_id=False, resource_calendar=False, context=None): """ Compute the vacation from the working calendar of the resource. + @param calendar_id : working calendar of the project @param resource_id : resource working on phase/task @param resource_calendar : working calendar of the resource diff --git a/addons/resource/test/process/test_resource_calendar.yml b/addons/resource/test/process/test_resource_calendar.yml index 04310d72f26..7c117e74128 100644 --- a/addons/resource/test/process/test_resource_calendar.yml +++ b/addons/resource/test/process/test_resource_calendar.yml @@ -10,12 +10,12 @@ result = self.working_hours_on_day(cr, uid, calendar, dt, context) assert result, "No Working Our on Day for Resource has been Generated." - - I Check the Resource 6.0 Hours Working Internal Timeming Based on Resource Calendar. + I Check the Resource 6.0 Hours Working Internal Timing Based on Resource Calendar. - !python {model: resource.calendar}: | from datetime import datetime dt = datetime.now() - result = self.interval_get(cr, uid, ref('timesheet_group1'), dt, 6.0) + result = self.interval_get(cr, uid, ref('timesheet_group1'), dt, 6.0, ref('resource_resource_demorsource')) assert result, 'No Working Internal Timeming Generated' - From e5bc35d12f9743a16852e4627a455b0ccba9f45a Mon Sep 17 00:00:00 2001 From: Jigar Amin - OpenERP Date: Mon, 5 Dec 2011 14:18:38 +0530 Subject: [PATCH 18/63] [MOV] moved yaml file bzr revid: jam@tinyerp.com-20111205084838-urtohfj8zb2puv51 --- .../test/{process/test_resource_calendar.yml => resource.yml} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename addons/resource/test/{process/test_resource_calendar.yml => resource.yml} (100%) diff --git a/addons/resource/test/process/test_resource_calendar.yml b/addons/resource/test/resource.yml similarity index 100% rename from addons/resource/test/process/test_resource_calendar.yml rename to addons/resource/test/resource.yml From 85770076fb58eb998f480db9536d020328219371 Mon Sep 17 00:00:00 2001 From: Jigar Amin - OpenERP Date: Mon, 5 Dec 2011 14:59:20 +0530 Subject: [PATCH 19/63] [ADD/RM] Removed useless file, added the demo resource record bzr revid: jam@tinyerp.com-20111205092920-ephr4ictr36fgvmd --- addons/resource/__openerp__.py | 5 +-- addons/resource/resource_demo.xml | 41 ++++++++++++++----- .../resource/test/process/test_resource.yml | 25 ----------- addons/resource/test/resource.yml | 13 ++++-- .../resource/test/ui/duplicate_resource.yml | 6 --- .../resource/test/ui/on_change_resource.yml | 6 --- 6 files changed, 40 insertions(+), 56 deletions(-) delete mode 100644 addons/resource/test/process/test_resource.yml delete mode 100644 addons/resource/test/ui/duplicate_resource.yml delete mode 100644 addons/resource/test/ui/on_change_resource.yml diff --git a/addons/resource/__openerp__.py b/addons/resource/__openerp__.py index e27d9be8fe6..4e522470f18 100644 --- a/addons/resource/__openerp__.py +++ b/addons/resource/__openerp__.py @@ -46,10 +46,7 @@ It also manages the leaves of every resource. 'demo_xml': ['resource_demo.xml' ], 'test': [ - 'test/process/test_resource.yml', - 'test/process/test_resource_calendar.yml', - 'test/ui/on_change_resource.yml', - 'test/ui/duplicate_resource.yml', + 'test/resource.yml', ], 'installable': True, 'active': False, diff --git a/addons/resource/resource_demo.xml b/addons/resource/resource_demo.xml index 989a029f93f..6a3c186a44c 100644 --- a/addons/resource/resource_demo.xml +++ b/addons/resource/resource_demo.xml @@ -88,21 +88,40 @@ user - - Morning 2 Hours On Leave - + + + + Analyst + + + user + + + + + + Designer + + + user + + + + + + Developer + + + user + + + + 2 Hours On Leave + - - Half Day Seak Leave - - - - - - diff --git a/addons/resource/test/process/test_resource.yml b/addons/resource/test/process/test_resource.yml deleted file mode 100644 index df9fd9e2708..00000000000 --- a/addons/resource/test/process/test_resource.yml +++ /dev/null @@ -1,25 +0,0 @@ -- | - In Order to Test resource : I use the 'Demo resource' from Demo Record, with 38 Hours / week and 9 Hours / Day working calendar scheduled. -- - First, I generate resource detail for the User "Demo" -- - !python {model: resource.resource}: | - res = self.generate_resources(cr, uid, [ref('base.user_demo')], ref('timesheet_group1')) - assert res, "Resource is not generated." - for resource in res.values(): - assert resource.get('efficiency') == 0.8, "Wrong resource has been Generated" - assert resource.get('vacation'), 'No vaction calculated' - -- - I compute the working calendar for the resource 'Demo Resource'. -- - !python {model: resource.resource}: | - res= self.compute_working_calendar(cr, uid, ref('timesheet_group1')) - assert res, "No working calendar generated for the resource 'Demo Resource'." - -- - I compute vacation for the resource "Demo Resource" based on his Resource Leave Request(s). -- - !python {model: resource.resource}: | - res= self.compute_vacation(cr, uid, ref('timesheet_group1'), ref('resource_resource_demorsource')) - assert res, "No vacation generated for the resource 'Demo Resource'." diff --git a/addons/resource/test/resource.yml b/addons/resource/test/resource.yml index 7c117e74128..1fc2e1b19b9 100644 --- a/addons/resource/test/resource.yml +++ b/addons/resource/test/resource.yml @@ -1,5 +1,10 @@ -- | - In order to test resource calendar, I use the Demo record '38 Hours/Week'. +- + In order to test resource calendar. + I assign workig calendar '38 Hours/Week' to human resource. +- + !python {model: resource.resource}: | + self.write(cr, uid, [ref('resource_analyst'), ref('resource_designer'), ref('resource_developer')], {'calendar_id' : ref('timesheet_group1')}) + - I check the working hour on day for resource 'Demo Resource' using calendar '38 Hours/Week' . - @@ -15,7 +20,7 @@ !python {model: resource.calendar}: | from datetime import datetime dt = datetime.now() - result = self.interval_get(cr, uid, ref('timesheet_group1'), dt, 6.0, ref('resource_resource_demorsource')) + result = self.interval_get(cr, uid, ref('timesheet_group1'), dt, 6.0, ref('resource_analyst')) assert result, 'No Working Internal Timeming Generated' - @@ -33,5 +38,5 @@ !python {model: resource.calendar}: | from datetime import datetime, timedelta dt_from = datetime.now() - hours = self.interval_min_get(cr, uid, ref('timesheet_group1'), dt_from, 30.0, resource=ref('resource_resource_demorsource')) + hours = self.interval_min_get(cr, uid, ref('timesheet_group1'), dt_from, 30.0, resource=ref('resource_analyst')) assert hours, 'No Working Schedule Generated.' diff --git a/addons/resource/test/ui/duplicate_resource.yml b/addons/resource/test/ui/duplicate_resource.yml deleted file mode 100644 index 45f1f5aa28e..00000000000 --- a/addons/resource/test/ui/duplicate_resource.yml +++ /dev/null @@ -1,6 +0,0 @@ -- - I duplicate the resource "Demo resource" -- - !python {model: resource.resource}: | - copied_id = self.copy(cr, uid, ref("resource_resource_demorsource")) - assert copied_id, "Unablr to Duplicate Reousrce" diff --git a/addons/resource/test/ui/on_change_resource.yml b/addons/resource/test/ui/on_change_resource.yml deleted file mode 100644 index 821b3efa5e4..00000000000 --- a/addons/resource/test/ui/on_change_resource.yml +++ /dev/null @@ -1,6 +0,0 @@ -- - I create resource calendar leave record to call event resource onchange event for "Demo Resource". -- - !record {model: resource.calendar.leaves, id: resource_calendar_leaves_demoleave1}: - calendar_id: resource.timesheet_group1 - resource_id: resource.resource_resource_demorsource From 9b384b626a0e31624d522401af5cd4513434cd0a Mon Sep 17 00:00:00 2001 From: "Kirti Savalia (OpenERP)" Date: Mon, 5 Dec 2011 16:59:30 +0530 Subject: [PATCH 20/63] [FIX]:MRP report for product price requires currency symbol lp bug: https://launchpad.net/bugs/898478 fixed bzr revid: ksa@tinyerp.com-20111205112930-txhakrami8z4rgth --- addons/mrp/report/price.py | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/addons/mrp/report/price.py b/addons/mrp/report/price.py index c072b821196..5ca53a2d95c 100644 --- a/addons/mrp/report/price.py +++ b/addons/mrp/report/price.py @@ -62,7 +62,7 @@ class report_custom(report_rml): 'uom': prod.uom_po_id.id, 'date': time.strftime('%Y-%m-%d'), })[pricelist.id] - main_sp_price = """"""+rml_obj.formatLang(price)+' '+ company_currency.symbol+"""\r\n""" + main_sp_price = """"""+rml_obj.formatLang(price)+' '+ (company_currency.symbol or company_currency.name)+"""\r\n""" sum += prod_qtty*price std_price = product_uom_pool._compute_price(cr, uid, prod.uom_id.id, prod.standard_price, to_uom_id=product_uom.id) main_strd_price = str(std_price) + '\r\n' @@ -75,11 +75,11 @@ class report_custom(report_rml): 'uom': prod.uom_po_id.id, 'date': time.strftime('%Y-%m-%d'), })[pricelist.id] - sellers_price += """"""+rml_obj.formatLang(price) +' '+ company_currency.symbol +"""\r\n""" + sellers_price += """"""+rml_obj.formatLang(price) +' '+ (company_currency.symbol or company_currency.name) +"""\r\n""" xml += """ """+ prod_name +""" """+ main_sp_name + sellers + """ """+ rml_obj.formatLang(prod_qtty) +' '+ product_uom_name +""" - """+ rml_obj.formatLang(float(main_strd_price)) +' '+ company_currency.symbol +""" + """+ rml_obj.formatLang(float(main_strd_price)) +' '+ (company_currency.symbol or company_currency.name) +""" """ + main_sp_price + sellers_price + """'""" xml += '' @@ -93,9 +93,9 @@ class report_custom(report_rml): xml = '' xml += "" + to_xml(workcenter.name) + '' xml += "" - xml += """"""+rml_obj.formatLang(cost_cycle)+' '+ company_currency.symbol + """""" - xml += """"""+rml_obj.formatLang(cost_hour)+' '+ company_currency.symbol + """""" - xml += """"""+rml_obj.formatLang(cost_hour + cost_cycle)+' '+ company_currency.symbol + """""" + xml += """"""+rml_obj.formatLang(cost_cycle)+' '+ (company_currency.symbol or company_currency.name) + """""" + xml += """"""+rml_obj.formatLang(cost_hour)+' '+ (company_currency.symbol or company_currency.name) + """""" + xml += """"""+rml_obj.formatLang(cost_hour + cost_cycle)+' '+ (company_currency.symbol or company_currency.name) + """""" xml += '' return xml, total @@ -159,8 +159,8 @@ class report_custom(report_rml): """ + _('Total Cost of %s %s') % (str(number), product_uom_name) + """: - """+ rml_obj.formatLang(total_strd, digits=purchase_price_digits) +' '+ company_currency.symbol + """ - """+ rml_obj.formatLang(total, digits=purchase_price_digits) +' '+ company_currency.symbol + """ + """+ rml_obj.formatLang(total_strd, digits=purchase_price_digits) +' '+ (company_currency.symbol or company_currency.name) + """ + """+ rml_obj.formatLang(total, digits=purchase_price_digits) +' '+ (company_currency.symbol or company_currency.name) + """ '""" else: bom = bom_pool.browse(cr, uid, bom_id, context=context) @@ -186,7 +186,7 @@ class report_custom(report_rml): """ + _('Components Cost of %s %s') % (str(number), product_uom_name) + """: - """+ rml_obj.formatLang(total_strd, digits=purchase_price_digits) +' '+ company_currency.symbol + """ + """+ rml_obj.formatLang(total_strd, digits=purchase_price_digits) +' '+ (company_currency.symbol or company_currency.name) + """ '""" @@ -204,13 +204,13 @@ class report_custom(report_rml): - """+ rml_obj.formatLang(total2, digits=purchase_price_digits) +' '+ company_currency.symbol +""" + """+ rml_obj.formatLang(total2, digits=purchase_price_digits) +' '+ (company_currency.symbol or company_currency.name) +""" '""" xml += """ """ + _('Total Cost of %s %s') % (str(number), product_uom_name) + """: - """+ rml_obj.formatLang(total_strd+total2, digits=purchase_price_digits) +' '+ company_currency.symbol + """ + """+ rml_obj.formatLang(total_strd+total2, digits=purchase_price_digits) +' '+ (company_currency.symbol or company_currency.name) + """ '""" From 6e5e699b6ebed8802b9c6b9b1d6772b856edd99e Mon Sep 17 00:00:00 2001 From: Jigar Amin - OpenERP Date: Mon, 5 Dec 2011 17:22:18 +0530 Subject: [PATCH 21/63] [IMP] imporved test case scenario bzr revid: jam@tinyerp.com-20111205115218-95ol3r8mw3uxdi5u --- addons/resource/resource_demo.xml | 42 ++++++++-------- addons/resource/test/resource.yml | 80 +++++++++++++++++++------------ 2 files changed, 70 insertions(+), 52 deletions(-) diff --git a/addons/resource/resource_demo.xml b/addons/resource/resource_demo.xml index 6a3c186a44c..acd96cd992b 100644 --- a/addons/resource/resource_demo.xml +++ b/addons/resource/resource_demo.xml @@ -5,73 +5,73 @@ - 38 Hours/Week + 45 Hours/Week - + Monday morning 0 08 12 - + Monday evening 0 13 18 - + Tuesday morning 1 08 12 - + Tuesday evening 1 13 18 - + Wednesday morning 2 08 12 - + Wednesday evening 2 13 18 - + Thursday morning 3 08 12 - + Thursday evening 13 18 3 - + Friday morning 4 08 12 - + Friday evening 4 13 @@ -79,15 +79,6 @@ - - - - Demo Resource - - - user - - @@ -98,7 +89,7 @@ - + Designer @@ -107,7 +98,7 @@ - + Developer @@ -122,6 +113,13 @@ + + + Dummy Resource Leave + + + + diff --git a/addons/resource/test/resource.yml b/addons/resource/test/resource.yml index 1fc2e1b19b9..42468681e69 100644 --- a/addons/resource/test/resource.yml +++ b/addons/resource/test/resource.yml @@ -1,42 +1,62 @@ - - In order to test resource calendar. - I assign workig calendar '38 Hours/Week' to human resource. + In order to test resource. +- + I assign workig calendar '45 Hours/Week' to human resource. - !python {model: resource.resource}: | - self.write(cr, uid, [ref('resource_analyst'), ref('resource_designer'), ref('resource_developer')], {'calendar_id' : ref('timesheet_group1')}) + self.write(cr, uid, [ref('resource_analyst'), ref('resource_designer'), ref('resource_developer')], {'calendar_id' : ref('timesheet_group1'), 'resource_type': 'user'}) - - I check the working hour on day for resource 'Demo Resource' using calendar '38 Hours/Week' . + I had Project of OpenERP Integration of 50 Hours with three human resource assigned on it. I have started project from this week start. +- + First, I generate the resource detail and check the resource Efficiency assigned. +- + !python {model: resource.resource}: | + resources = self.generate_resources(cr, uid, [ref('base.user_root'),ref('base.user_demo')], ref('timesheet_group1'), context) + for resource in resources.values(): + print resource + assert resource.get('efficiency', 0.0) == 1.0, 'Invalid resource generated.' +- + I check per day work hour availability of the Resource based on Working Calendar Assigned to each resource, for first day of the week. +- + !python {model: resource.resource}: | + calendar_pool = self.pool.get('resource.calendar') + resources = self.browse(cr, uid, [ref('resource_analyst'), ref('resource_designer'), ref('resource_developer')], context) + from datetime import datetime, timedelta + now = datetime.now() + dt = now - timedelta(days=now.weekday()) + for resource in resources: + result = calendar_pool.working_hours_on_day(cr, uid, resource.calendar_id, dt, context) + assert result == 9.0, 'Wrong calculation of day work hour availability of the Resource.' +- + Now, resource "Developer" drafted leave on Thursday in this week. +- + !python {model: resource.calendar.leaves}: | + from datetime import datetime,timedelta + now = datetime.now() + dt = (now - timedelta(days=now.weekday()) ) + timedelta(days=3) + self.write(cr, uid, [ref('resource_dummyleave')], {'resource_id': ref('resource_developer'), 'calendar_id': ref('timesheet_group1'), 'date_from': dt.strftime("%Y-%m-%d 09:00:00"), 'date_to': dt.strftime("%Y-%m-%d 18:00:00")}) + +- + I check Actual working hours on resource 'Developer' from this week - !python {model: resource.calendar}: | - from datetime import datetime - dt = datetime.now() - calendar = self.browse(cr, uid, ref('timesheet_group1')) - result = self.working_hours_on_day(cr, uid, calendar, dt, context) - assert result, "No Working Our on Day for Resource has been Generated." -- - I Check the Resource 6.0 Hours Working Internal Timing Based on Resource Calendar. -- - !python {model: resource.calendar}: | - from datetime import datetime - dt = datetime.now() - result = self.interval_get(cr, uid, ref('timesheet_group1'), dt, 6.0, ref('resource_analyst')) - assert result, 'No Working Internal Timeming Generated' + from datetime import datetime, timedelta + now = datetime.now() + dt_from = now - timedelta(days=now.weekday()) + dt_to = dt_from+ timedelta(days=6) + hours = self.interval_hours_get(cr, uid, ref('timesheet_group1'), dt_from, dt_to, resource=ref('resource_developer')) + assert hours > 27 , 'Invalid Total Week working hour calculated' + - - I check total number of working hours on resource in between three dates based on resource working calendar. + Project Analysis work is of 20 hours which will start from Week startso i will calculate working schedule for resource Analyst for the same. - !python {model: resource.calendar}: | + from datetime import datetime, timedelta - dt_from = datetime.now() - dt_to = dt_from + timedelta(days=3) - hours = self.interval_hours_get(cr, uid, ref('timesheet_group1'), dt_from, dt_to) - assert hours, 'No Working Hours Generated' -- - I check resource working schedule based on resource calendar for 30 Hours. -- - !python {model: resource.calendar}: | - from datetime import datetime, timedelta - dt_from = datetime.now() - hours = self.interval_min_get(cr, uid, ref('timesheet_group1'), dt_from, 30.0, resource=ref('resource_analyst')) - assert hours, 'No Working Schedule Generated.' + now = datetime.now() + work_intreval = self.interval_min_get(cr, uid, ref('timesheet_group1'), now, 20.0, resource=ref('resource_designer')) + assert len(work_intreval) >= 5, 'Wrong Schedule Calculated' + + From cd99a7eeb698c4671a2c1071a19c728ff5e87e02 Mon Sep 17 00:00:00 2001 From: Jigar Amin - OpenERP Date: Mon, 5 Dec 2011 17:26:37 +0530 Subject: [PATCH 22/63] [ADD/FIX] Duplicate reosurce yaml and added the references for the same bzr revid: jam@tinyerp.com-20111205115637-473yq421xc5w6ag2 --- addons/resource/__openerp__.py | 1 + addons/resource/test/duplicate_resource.yml | 6 ++++++ addons/resource/test/resource.yml | 2 -- 3 files changed, 7 insertions(+), 2 deletions(-) create mode 100644 addons/resource/test/duplicate_resource.yml diff --git a/addons/resource/__openerp__.py b/addons/resource/__openerp__.py index 4e522470f18..c95cb6d29b5 100644 --- a/addons/resource/__openerp__.py +++ b/addons/resource/__openerp__.py @@ -47,6 +47,7 @@ It also manages the leaves of every resource. ], 'test': [ 'test/resource.yml', + 'test/duplicate_resource.yml', ], 'installable': True, 'active': False, diff --git a/addons/resource/test/duplicate_resource.yml b/addons/resource/test/duplicate_resource.yml new file mode 100644 index 00000000000..5869530e2f4 --- /dev/null +++ b/addons/resource/test/duplicate_resource.yml @@ -0,0 +1,6 @@ +- + I duplicate the resource "Analyst" +- + !python {model: resource.resource}: | + copied_id = self.copy(cr, uid, ref("resource_analyst")) + assert copied_id, "Unable to Duplicate Resource" diff --git a/addons/resource/test/resource.yml b/addons/resource/test/resource.yml index 42468681e69..df4e84e58b1 100644 --- a/addons/resource/test/resource.yml +++ b/addons/resource/test/resource.yml @@ -47,8 +47,6 @@ dt_to = dt_from+ timedelta(days=6) hours = self.interval_hours_get(cr, uid, ref('timesheet_group1'), dt_from, dt_to, resource=ref('resource_developer')) assert hours > 27 , 'Invalid Total Week working hour calculated' - - - Project Analysis work is of 20 hours which will start from Week startso i will calculate working schedule for resource Analyst for the same. - From bbe95e2694fade1a3fc1e6fd1c0fafc4f2c765c9 Mon Sep 17 00:00:00 2001 From: Jigar Amin - OpenERP Date: Mon, 5 Dec 2011 17:32:10 +0530 Subject: [PATCH 23/63] [FIX] removed print stme bzr revid: jam@tinyerp.com-20111205120210-vqnxzmxk38pc2l07 --- addons/resource/test/resource.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/addons/resource/test/resource.yml b/addons/resource/test/resource.yml index df4e84e58b1..4c9a47ed6e5 100644 --- a/addons/resource/test/resource.yml +++ b/addons/resource/test/resource.yml @@ -14,7 +14,6 @@ !python {model: resource.resource}: | resources = self.generate_resources(cr, uid, [ref('base.user_root'),ref('base.user_demo')], ref('timesheet_group1'), context) for resource in resources.values(): - print resource assert resource.get('efficiency', 0.0) == 1.0, 'Invalid resource generated.' - I check per day work hour availability of the Resource based on Working Calendar Assigned to each resource, for first day of the week. From 2d8a2e5f6c357ca6aebeec04710075eb04f2f2df Mon Sep 17 00:00:00 2001 From: "Kirti Savalia (OpenERP)" Date: Wed, 7 Dec 2011 12:32:10 +0530 Subject: [PATCH 24/63] [IMP]:store the value in variable bzr revid: ksa@tinyerp.com-20111207070210-adb7ur2i1jxdd9vb --- addons/mrp/report/price.py | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/addons/mrp/report/price.py b/addons/mrp/report/price.py index 5ca53a2d95c..fc32eeeed9e 100644 --- a/addons/mrp/report/price.py +++ b/addons/mrp/report/price.py @@ -41,6 +41,7 @@ class report_custom(report_rml): rml_obj=report_sxw.rml_parse(cr, uid, product_pool._name,context) rml_obj.localcontext.update({'lang':context.get('lang',False)}) company_currency = user_pool.browse(cr, uid, uid).company_id.currency_id + company_currency_symbol = company_currency.symbol or company_currency.name def process_bom(bom, currency_id, factor=1): xml = '' sum = 0 @@ -62,7 +63,7 @@ class report_custom(report_rml): 'uom': prod.uom_po_id.id, 'date': time.strftime('%Y-%m-%d'), })[pricelist.id] - main_sp_price = """"""+rml_obj.formatLang(price)+' '+ (company_currency.symbol or company_currency.name)+"""\r\n""" + main_sp_price = """"""+rml_obj.formatLang(price)+' '+ (company_currency_symbol)+"""\r\n""" sum += prod_qtty*price std_price = product_uom_pool._compute_price(cr, uid, prod.uom_id.id, prod.standard_price, to_uom_id=product_uom.id) main_strd_price = str(std_price) + '\r\n' @@ -75,11 +76,11 @@ class report_custom(report_rml): 'uom': prod.uom_po_id.id, 'date': time.strftime('%Y-%m-%d'), })[pricelist.id] - sellers_price += """"""+rml_obj.formatLang(price) +' '+ (company_currency.symbol or company_currency.name) +"""\r\n""" + sellers_price += """"""+rml_obj.formatLang(price) +' '+ (company_currency_symbol) +"""\r\n""" xml += """ """+ prod_name +""" """+ main_sp_name + sellers + """ """+ rml_obj.formatLang(prod_qtty) +' '+ product_uom_name +""" - """+ rml_obj.formatLang(float(main_strd_price)) +' '+ (company_currency.symbol or company_currency.name) +""" + """+ rml_obj.formatLang(float(main_strd_price)) +' '+ (company_currency_symbol) +""" """ + main_sp_price + sellers_price + """'""" xml += '' @@ -93,9 +94,9 @@ class report_custom(report_rml): xml = '' xml += "" + to_xml(workcenter.name) + '' xml += "" - xml += """"""+rml_obj.formatLang(cost_cycle)+' '+ (company_currency.symbol or company_currency.name) + """""" - xml += """"""+rml_obj.formatLang(cost_hour)+' '+ (company_currency.symbol or company_currency.name) + """""" - xml += """"""+rml_obj.formatLang(cost_hour + cost_cycle)+' '+ (company_currency.symbol or company_currency.name) + """""" + xml += """"""+rml_obj.formatLang(cost_cycle)+' '+ (company_currency_symbol) + """""" + xml += """"""+rml_obj.formatLang(cost_hour)+' '+ (company_currency_symbol) + """""" + xml += """"""+rml_obj.formatLang(cost_hour + cost_cycle)+' '+ (company_currency_symbol) + """""" xml += '' return xml, total @@ -159,8 +160,8 @@ class report_custom(report_rml): """ + _('Total Cost of %s %s') % (str(number), product_uom_name) + """: - """+ rml_obj.formatLang(total_strd, digits=purchase_price_digits) +' '+ (company_currency.symbol or company_currency.name) + """ - """+ rml_obj.formatLang(total, digits=purchase_price_digits) +' '+ (company_currency.symbol or company_currency.name) + """ + """+ rml_obj.formatLang(total_strd, digits=purchase_price_digits) +' '+ (company_currency_symbol) + """ + """+ rml_obj.formatLang(total, digits=purchase_price_digits) +' '+ (company_currency_symbol) + """ '""" else: bom = bom_pool.browse(cr, uid, bom_id, context=context) @@ -186,7 +187,7 @@ class report_custom(report_rml): """ + _('Components Cost of %s %s') % (str(number), product_uom_name) + """: - """+ rml_obj.formatLang(total_strd, digits=purchase_price_digits) +' '+ (company_currency.symbol or company_currency.name) + """ + """+ rml_obj.formatLang(total_strd, digits=purchase_price_digits) +' '+ (company_currency_symbol) + """ '""" @@ -204,13 +205,13 @@ class report_custom(report_rml): - """+ rml_obj.formatLang(total2, digits=purchase_price_digits) +' '+ (company_currency.symbol or company_currency.name) +""" + """+ rml_obj.formatLang(total2, digits=purchase_price_digits) +' '+ (company_currency_symbol) +""" '""" xml += """ """ + _('Total Cost of %s %s') % (str(number), product_uom_name) + """: - """+ rml_obj.formatLang(total_strd+total2, digits=purchase_price_digits) +' '+ (company_currency.symbol or company_currency.name) + """ + """+ rml_obj.formatLang(total_strd+total2, digits=purchase_price_digits) +' '+ (company_currency_symbol) + """ '""" From c26ed4d7066e1dd7db4a577a694e2f5b8c4990e3 Mon Sep 17 00:00:00 2001 From: Jigar Amin - OpenERP Date: Mon, 19 Dec 2011 10:45:17 +0530 Subject: [PATCH 25/63] [FiX] typo bzr revid: jam@tinyerp.com-20111219051517-y8t1t4lvjohl2a7c --- addons/resource/test/resource.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/resource/test/resource.yml b/addons/resource/test/resource.yml index 4c9a47ed6e5..5b7fa108101 100644 --- a/addons/resource/test/resource.yml +++ b/addons/resource/test/resource.yml @@ -1,7 +1,7 @@ - In order to test resource. - - I assign workig calendar '45 Hours/Week' to human resource. + I assign working calendar '45 Hours/Week' to human resource. - !python {model: resource.resource}: | self.write(cr, uid, [ref('resource_analyst'), ref('resource_designer'), ref('resource_developer')], {'calendar_id' : ref('timesheet_group1'), 'resource_type': 'user'}) @@ -47,7 +47,7 @@ hours = self.interval_hours_get(cr, uid, ref('timesheet_group1'), dt_from, dt_to, resource=ref('resource_developer')) assert hours > 27 , 'Invalid Total Week working hour calculated' - - Project Analysis work is of 20 hours which will start from Week startso i will calculate working schedule for resource Analyst for the same. + Project Analysis work is of 20 hours which will start from Week start so i will calculate working schedule for resource Analyst for the same. - !python {model: resource.calendar}: | From 81a9188d898e1fa33750e754a05e71568e108807 Mon Sep 17 00:00:00 2001 From: "Jagdish Panchal (Open ERP)" Date: Tue, 20 Dec 2011 11:42:01 +0530 Subject: [PATCH 26/63] [FIX] sale: Give accees right to model_account_invoice_report lp bug: https://launchpad.net/bugs/904805 fixed bzr revid: jap@tinyerp.com-20111220061201-qyje32kc34cjr4jb --- addons/sale/security/ir.model.access.csv | 1 + addons/sale_crm/security/ir.model.access.csv | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/addons/sale/security/ir.model.access.csv b/addons/sale/security/ir.model.access.csv index 25d063d49e9..2e08a025971 100644 --- a/addons/sale/security/ir.model.access.csv +++ b/addons/sale/security/ir.model.access.csv @@ -58,3 +58,4 @@ access_product_pricelist_type_sale_manager,product.pricelist.type salemanager,pr access_product_pricelist_sale_manager,product.pricelist salemanager,product.model_product_pricelist,base.group_sale_manager,1,1,1,1 access_product_group_res_partner_sale_manager,res_partner group_sale_manager,base.model_res_partner,base.group_sale_manager,1,1,1,0 access_product_pricelist_version_sale_manager,product.pricelist.version sale_manager,product.model_product_pricelist_version,base.group_sale_manager,1,1,1,1 +access_account_invoice_report_salesman,account.invoice.report salesman,account.model_account_invoice_report,base.group_sale_salesman,1,0,0,0 \ No newline at end of file diff --git a/addons/sale_crm/security/ir.model.access.csv b/addons/sale_crm/security/ir.model.access.csv index d4e6eede351..75317a244ad 100644 --- a/addons/sale_crm/security/ir.model.access.csv +++ b/addons/sale_crm/security/ir.model.access.csv @@ -1,2 +1,2 @@ id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink -access_account_invoice_report_salesman,account.invoice.report salesman,account.model_account_invoice_report,base.group_sale_salesman,1,0,0,0 + From 688aaff712172f20fed0cad13cb33422b9951bd6 Mon Sep 17 00:00:00 2001 From: Benoit Guillot Date: Tue, 20 Dec 2011 10:41:10 +0100 Subject: [PATCH 27/63] [REF] refactor date_planned bzr revid: benoit.guillot@akretion.com.br-20111220094110-bay12ed4v850h0q6 --- addons/sale/sale.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/addons/sale/sale.py b/addons/sale/sale.py index e2487d7c1cf..e56aa7d0968 100644 --- a/addons/sale/sale.py +++ b/addons/sale/sale.py @@ -771,6 +771,11 @@ class sale_order(osv.osv): self.pool.get('procurement.order').write(cr, uid, [proc_id], {'product_qty': mov.product_qty, 'product_uos_qty': mov.product_uos_qty}) return True + def _get_date_planned(self, cr, uid, order, line, start_date, *args): + date_planned = datetime.strptime(start_date, DEFAULT_SERVER_DATE_FORMAT) + relativedelta(days=line.delay or 0.0) + date_planned = (date_planned - timedelta(days=order.company_id.security_lead)).strftime(DEFAULT_SERVER_DATETIME_FORMAT) + return date_planned + def _create_pickings_and_procurements(self, cr, uid, order, order_lines, picking_id=False, *args): """Create the required procurements to supply sale order lines, also connecting the procurements to appropriate stock moves in order to bring the goods to the @@ -799,8 +804,7 @@ class sale_order(osv.osv): if line.state == 'done': continue - date_planned = datetime.strptime(order.date_order, DEFAULT_SERVER_DATE_FORMAT) + relativedelta(days=line.delay or 0.0) - date_planned = (date_planned - timedelta(days=order.company_id.security_lead)).strftime(DEFAULT_SERVER_DATETIME_FORMAT) + date_planned = self._get_date_planned(cr, uid, order, line, order.date_order, *args) if line.product_id: if line.product_id.product_tmpl_id.type in ('product', 'consu'): From 810315fec1fce935e7c8c5b0b5dcbd237310a687 Mon Sep 17 00:00:00 2001 From: "Jagdish Panchal (Open ERP)" Date: Tue, 20 Dec 2011 15:11:29 +0530 Subject: [PATCH 28/63] [FIX] point_of_sale: remove the domain from pos catagory field in product form lp bug: https://launchpad.net/bugs/906726 fixed bzr revid: jap@tinyerp.com-20111220094129-ws1y1pgtbn2io74i --- addons/point_of_sale/point_of_sale.py | 1 - 1 file changed, 1 deletion(-) diff --git a/addons/point_of_sale/point_of_sale.py b/addons/point_of_sale/point_of_sale.py index bff7892b74c..1eb9a0865f7 100644 --- a/addons/point_of_sale/point_of_sale.py +++ b/addons/point_of_sale/point_of_sale.py @@ -737,7 +737,6 @@ class product_product(osv.osv): 'expense_pdt': fields.boolean('PoS Cash Output', help="This is a product you can use to take cash from a statement for the point of sale backend, exemple: money lost, transfer to bank, etc."), 'img': fields.binary('Product Image, must be 50x50', help="Use an image size of 50x50."), 'pos_categ_id': fields.many2one('pos.category','PoS Category', - domain="[('type','=','normal')]", help="If you want to sell this product through the point of sale, select the category it belongs to.") } product_product() From 7d0bc5e163e359badeca8f13a31098db1b44fc97 Mon Sep 17 00:00:00 2001 From: "Kunal Chavda (OpenERP)" Date: Tue, 20 Dec 2011 15:12:04 +0530 Subject: [PATCH 29/63] [FIX]Fixed code for showing pie chart. lp bug: https://launchpad.net/bugs/906783 fixed bzr revid: kch@tinyerp.com-20111220094204-4qihd3jnxyeggkl4 --- addons/web_graph/static/src/js/graph.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/web_graph/static/src/js/graph.js b/addons/web_graph/static/src/js/graph.js index 59f56328ffa..e63eec884cd 100644 --- a/addons/web_graph/static/src/js/graph.js +++ b/addons/web_graph/static/src/js/graph.js @@ -173,7 +173,7 @@ openerp.web_graph.GraphView = openerp.web.View.extend({ graph_data = _(graph_data).sortBy(function (point) { return point[self.abscissa] + '[[--]]' + point[self.group_field]; }); - if (this.chart == 'bar' || 'line' || 'area') { + if (_.include(['bar','line','area'],this.chart)) { return this.schedule_bar_line_area(graph_data); } else if (this.chart == "pie") { return this.schedule_pie(graph_data); From c27f0a956d0999a774a799594d3828f11e2eceb3 Mon Sep 17 00:00:00 2001 From: "Sanjay Gohel (Open ERP)" Date: Tue, 20 Dec 2011 15:23:08 +0530 Subject: [PATCH 30/63] [FIX]Audittrail:give rights to admin/config and admin/access rights read,write and create auditrules bzr revid: sgo@tinyerp.com-20111220095308-f26huvkwwzfnfr2f --- addons/audittrail/security/ir.model.access.csv | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/addons/audittrail/security/ir.model.access.csv b/addons/audittrail/security/ir.model.access.csv index 25bba6a00b1..1d2198fd661 100644 --- a/addons/audittrail/security/ir.model.access.csv +++ b/addons/audittrail/security/ir.model.access.csv @@ -1,4 +1,5 @@ id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink -access_audittrail_rule_all_users,audittrail rule all,model_audittrail_rule,base.group_user,1,0,0,0 +access_audittrail_rule_all_users,audittrail rule all,model_audittrail_rule,base.group_system,1,1,1,0 +access_audittrail_rule_all_access,audittrail rule all,model_audittrail_rule,base.group_erp_manager,1,1,1,0 access_audittrail_log_all_users,audittrail log all,model_audittrail_log,base.group_user,1,0,1,0 access_audittrail_log_line_all_users,audittrail log line all,model_audittrail_log_line,base.group_user,1,0,1,0 From 19a9a1d595b47b5f5444de5b0cca21702293fe9a Mon Sep 17 00:00:00 2001 From: Fabien Pinckaers Date: Tue, 20 Dec 2011 11:23:33 +0100 Subject: [PATCH 31/63] [IMP] useability seach opportunity bzr revid: fp@tinyerp.com-20111220102333-dv8v47wkgf4v0laf --- openerp/addons/base/res/res_partner.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/openerp/addons/base/res/res_partner.py b/openerp/addons/base/res/res_partner.py index 69d7cbc577b..9cc39fda018 100644 --- a/openerp/addons/base/res/res_partner.py +++ b/openerp/addons/base/res/res_partner.py @@ -141,6 +141,8 @@ class res_partner(osv.osv): 'company_id': fields.many2one('res.company', 'Company', select=1), 'color': fields.integer('Color Index'), } + def name_create(self, cr, uid, name, context=None): + raise osv.except_osv(_('Warning'), _("Quick create is desactivated for partners!")) def _default_category(self, cr, uid, context=None): if context is None: @@ -314,6 +316,8 @@ class res_partner_address(osv.osv): 'active': lambda *a: 1, 'company_id': lambda s,cr,uid,c: s.pool.get('res.company')._company_default_get(cr, uid, 'res.partner.address', context=c), } + def name_create(self, cr, uid, name, context=None): + raise osv.except_osv(_('Warning'), _("Quick create is desactivated for addresses and contacts!")) def name_get(self, cr, user, ids, context=None): if context is None: From a26f4b1de7a2c663c71f943ab16c1528a78a0bea Mon Sep 17 00:00:00 2001 From: Fabien Meghazi Date: Tue, 20 Dec 2011 11:43:27 +0100 Subject: [PATCH 32/63] [FIX] Fix sidebar attachment deletion bzr revid: fme@openerp.com-20111220104327-1zif2g20625mtcdc --- addons/web/static/src/js/view_form.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index d77042446e3..5c503160e34 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -647,7 +647,7 @@ openerp.web.form.SidebarAttachments = openerp.web.Widget.extend({ on_attachment_delete: function(e) { var self = this, $e = $(e.currentTarget); var name = _.str.trim($e.parent().find('a.oe-sidebar-attachments-link').text()); - if (confirm(_.sprintf(_t("Do you really want to delete the attachment %s?"), name))) { + if (confirm(_.str.sprintf(_t("Do you really want to delete the attachment %s?"), name))) { this.rpc('/web/dataset/unlink', { model: 'ir.attachment', ids: [parseInt($e.attr('data-id'))] From 3daf6b30b941c5b53e36c98996baf587a06e6c62 Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Tue, 20 Dec 2011 12:47:32 +0100 Subject: [PATCH 33/63] [FIX] jsonP-requests issue for real bzr revid: xmo@openerp.com-20111220114732-gekgwwb0ry0sdqil --- addons/web/common/http.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/addons/web/common/http.py b/addons/web/common/http.py index 900090071c8..ad23dbc0c89 100644 --- a/addons/web/common/http.py +++ b/addons/web/common/http.py @@ -355,8 +355,10 @@ def session_context(request, storage_path, session_cookie='sessionid'): if stored and isinstance(v, session.OpenERPSession): v.contexts_store.update(stored.contexts_store) v.domains_store.update(stored.domains_store) - jsonp = getattr(v, 'jsonp_requests', {}) - jsonp.update(stored.jsonp_requests) + if not hasattr(v, 'jsonp_requests'): + v.jsonp_requests = {} + v.jsonp_requests.update(getattr( + stored, 'jsonp_requests', {})) # add missing keys for k, v in in_store.iteritems(): From 8ba259b3f68ef8e834d0f1dc8019589bf5b1eab2 Mon Sep 17 00:00:00 2001 From: Fabien Meghazi Date: Tue, 20 Dec 2011 12:55:00 +0100 Subject: [PATCH 34/63] [IMP] Improved buttons bzr revid: fme@openerp.com-20111220115500-aulwnoj6ciks8jxm --- addons/web/static/src/css/base.css | 36 ++++----- addons/web/static/src/xml/base.xml | 79 ++++++++++--------- .../static/src/css/dashboard.css | 1 + .../static/src/xml/web_dashboard.xml | 6 +- .../static/src/xml/base_diagram.xml | 2 +- addons/web_gantt/static/src/xml/web_gantt.xml | 8 +- .../web_kanban/static/src/xml/web_kanban.xml | 2 +- .../static/src/xml/web_process.xml | 6 +- 8 files changed, 71 insertions(+), 69 deletions(-) diff --git a/addons/web/static/src/css/base.css b/addons/web/static/src/css/base.css index 04ce2fa3ed2..80ac570ea1f 100644 --- a/addons/web/static/src/css/base.css +++ b/addons/web/static/src/css/base.css @@ -1210,7 +1210,9 @@ label.error { color: #1f1f1f; } -.openerp input[type="text"].field_email, .openerp input[type="text"].field_url { +.openerp input[type="text"].field_binary, +.openerp input[type="text"].field_email, +.openerp input[type="text"].field_url { border-right:none; -webkit-border-top-right-radius: 0px; -webkit-border-bottom-right-radius: 0px; @@ -1219,7 +1221,7 @@ label.error { border-top-right-radius: 0px; border-bottom-right-radius: 0px; } -.openerp .mail_button, .openerp .url_button { +.openerp .oe_button.oe_field_button { -webkit-border-top-left-radius: 0px; -webkit-border-bottom-left-radius: 0px; -moz-border-radius-topleft: 0px; @@ -1227,10 +1229,12 @@ label.error { border-top-left-radius: 0px; border-bottom-left-radius: 0px; margin-right:-1px; + height: 22px; } -.openerp .mail_button img, .openerp .url_button img { - vertical-align:top; +.openerp .oe_form_field_email button img, +.openerp .oe_form_field_url button img { + vertical-align: top; } /* vertically recentering filter management select tag */ .openerp select.oe_search-view-filters-management { @@ -1255,7 +1259,7 @@ label.error { .openerp .oe_forms input.field_datetime { min-width: 11em; } -.openerp .oe_forms .oe_button { +.openerp .oe_forms .oe_form_button .oe_button { color: #4c4c4c; white-space: nowrap; min-width: 100%; @@ -2015,9 +2019,9 @@ ul.oe-arrow-list li.oe-arrow-list-selected .oe-arrow-list-after { } /* Buttons */ -.openerp a.button:link, -.openerp a.button:visited, -.openerp button { +.openerp .oe_button:link, +.openerp .oe_button:visited, +.openerp .oe_button { display: inline-block; border: 1px solid #ababab; color: #404040; @@ -2048,8 +2052,7 @@ ul.oe-arrow-list li.oe-arrow-list-selected .oe-arrow-list-after { outline: none; } -.openerp a.button:hover, -.openerp button:hover { +.openerp .oe_button:hover { -o-background-size: 100% 100%; -moz-background-size: 100% 100%; -webkit-background-size: auto auto !important; @@ -2063,8 +2066,7 @@ ul.oe-arrow-list li.oe-arrow-list-selected .oe-arrow-list-after { cursor: pointer; } -.openerp a.button:focus, -.openerp button:focus { +.openerp .oe_button:focus { border: 1px solid #80bfff; -o-background-size: 100% 100%; -moz-background-size: 100% 100%; @@ -2082,10 +2084,8 @@ ul.oe-arrow-list li.oe-arrow-list-selected .oe-arrow-list-after { box-shadow: 0 0 3px #80bfff, 0 1px 1px rgba(255, 255, 255, 0.8) inset; } -.openerp a.button:active, -.openerp a.button.active, -.openerp button:active, -.openerp button.active { +.openerp .oe_button:active, +.openerp .oe_button.active { background: #e3e3e3; background: -moz-linear-gradient(top, #e3e3e3, #f6f6f6) #1b468f; background: -webkit-gradient(linear, left top, left bottom, from(#e3e3e3), to(#f6f6f6)) #1b468f; @@ -2096,8 +2096,8 @@ ul.oe-arrow-list li.oe-arrow-list-selected .oe-arrow-list-after { box-shadow: none, 0 0 0 transparent; } -.openerp a.button.disabled, -.openerp button:disabled { +.openerp .oe_button.disabled, +.openerp .oe_button:disabled { background: #efefef !important; border: 1px solid #d1d1d1 !important; font-size: 12px; diff --git a/addons/web/static/src/xml/base.xml b/addons/web/static/src/xml/base.xml index e425d701a5b..260a8e20308 100644 --- a/addons/web/static/src/xml/base.xml +++ b/addons/web/static/src/xml/base.xml @@ -119,7 +119,7 @@ equalTo="input[name=create_admin_pwd]"/> - + @@ -149,7 +149,7 @@ - + @@ -181,7 +181,7 @@ - + @@ -210,7 +210,7 @@ - + @@ -241,7 +241,7 @@ equalTo="input[name=new_pwd]" minlength="1"/> - + @@ -289,8 +289,8 @@ - - + + @@ -575,11 +575,11 @@ @@ -930,7 +930,7 @@ @@ -1044,7 +1044,7 @@ method="post" enctype="multipart/form-data" action="/web/binary/upload"> - @@ -1052,7 +1052,7 @@ @@ -1087,7 +1087,7 @@ method="post" enctype="multipart/form-data" action="/web/binary/upload"> - @@ -1096,13 +1096,13 @@ - + @@ -1623,7 +1624,7 @@ - + @@ -1644,7 +1645,7 @@ minlength="1"/> - +
- - @@ -692,8 +692,8 @@
- - + +
@@ -709,10 +709,10 @@ - - - - + + + + @@ -724,7 +724,7 @@ - @@ -916,7 +916,7 @@
- - - - - @@ -1160,8 +1160,8 @@
- - + +
@@ -1401,18 +1401,18 @@
- - + + - + - - + + - +
@@ -1420,8 +1420,8 @@
- - + + + + +
diff --git a/addons/web_dashboard/static/src/css/dashboard.css b/addons/web_dashboard/static/src/css/dashboard.css index 1ac30e905ad..ea8d26c2ad2 100644 --- a/addons/web_dashboard/static/src/css/dashboard.css +++ b/addons/web_dashboard/static/src/css/dashboard.css @@ -42,6 +42,7 @@ .openerp .oe_dashboard_button_create { margin-left: 4px; padding: 0 4px 0 4px; + height: 16px !important; } .openerp a.oe-dashboard-action-rename { diff --git a/addons/web_dashboard/static/src/xml/web_dashboard.xml b/addons/web_dashboard/static/src/xml/web_dashboard.xml index 5f98df612d5..e40d056b314 100644 --- a/addons/web_dashboard/static/src/xml/web_dashboard.xml +++ b/addons/web_dashboard/static/src/xml/web_dashboard.xml @@ -1,11 +1,11 @@