From 44963c74f51a9691e8cc046817cc99c29fb37758 Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Sat, 11 Sep 2010 16:43:26 +0530 Subject: [PATCH 1/6] [FIX] signature of overloads to the project)_task methods bzr revid: xmo@openerp.com-20100911111326-ymk1csobvakjavvv --- addons/project_mailgate/project_mailgate.py | 20 ++++++++++---------- addons/project_mrp/project_mrp.py | 20 +++++++++----------- 2 files changed, 19 insertions(+), 21 deletions(-) diff --git a/addons/project_mailgate/project_mailgate.py b/addons/project_mailgate/project_mailgate.py index d402374b5ea..9b6b7d77f7b 100644 --- a/addons/project_mailgate/project_mailgate.py +++ b/addons/project_mailgate/project_mailgate.py @@ -120,34 +120,34 @@ class project_tasks(osv.osv): message_id=message_id, attach=attach, \ context=context) - def do_draft(self, cr, uid, ids, *args): - res = super(project_tasks, self).do_draft(cr, uid, ids, *args) + def do_draft(self, cr, uid, ids, *args, **kwargs): + res = super(project_tasks, self).do_draft(cr, uid, ids, *args, **kwargs) tasks = self.browse(cr, uid, ids) self._history(cr, uid, tasks, _('Draft')) return res - def do_open(self, cr, uid, ids, *args): - res = super(project_tasks, self).do_open(cr, uid, ids, *args) + def do_open(self, cr, uid, ids, *args, **kwargs): + res = super(project_tasks, self).do_open(cr, uid, ids, *args, **kwargs) tasks = self.browse(cr, uid, ids) self._history(cr, uid, tasks, _('Open')) return res - def do_pending(self, cr, uid, ids, *args): - res = super(project_tasks, self).do_pending(cr, uid, ids, *args) + def do_pending(self, cr, uid, ids, *args, **kwargs): + res = super(project_tasks, self).do_pending(cr, uid, ids, *args, **kwargs) tasks = self.browse(cr, uid, ids) self._history(cr, uid, tasks, _('Pending')) return res - def do_close(self, cr, uid, ids, *args): - res = super(project_tasks, self).do_close(cr, uid, ids, *args) + def do_close(self, cr, uid, ids, *args, **kwargs): + res = super(project_tasks, self).do_close(cr, uid, ids, *args, **kwargs) tasks = self.browse(cr, uid, ids) for task in tasks: if task.state == 'done': self._history(cr, uid, tasks, _('Done')) return res - def do_cancel(self, cr, uid, ids, *args): - res = super(project_tasks, self).do_cancel(cr, uid, ids, *args) + def do_cancel(self, cr, uid, ids, *args, **kwargs): + res = super(project_tasks, self).do_cancel(cr, uid, ids, *args, **kwargs) tasks = self.browse(cr, uid, ids) self._history(cr, uid, tasks, _('Cancel')) return res diff --git a/addons/project_mrp/project_mrp.py b/addons/project_mrp/project_mrp.py index 4e99ee0b281..5f3eb4616be 100644 --- a/addons/project_mrp/project_mrp.py +++ b/addons/project_mrp/project_mrp.py @@ -29,22 +29,20 @@ class project_task(osv.osv): 'procurement_id': fields.many2one('procurement.order', 'Procurement', ondelete='set null') } - def do_close(self, cr, uid, ids, *args): - res = super(project_task, self).do_close(cr, uid, ids, *args) - tasks = self.browse(cr, uid, ids) - for task in tasks: + def _validate_subflows(self, cr, uid, ids): + for task in self.browse(cr, uid, ids): if task.procurement_id: wf_service = netsvc.LocalService("workflow") wf_service.trg_validate(uid, 'procurement.order', task.procurement_id.id, 'subflow.done', cr) + + def do_close(self, cr, uid, ids, *args, **kwargs): + res = super(project_task, self).do_close(cr, uid, ids, *args, **kwargs) + self._validate_subflows(cr, uid, ids) return res - def do_cancel(self, cr, uid, ids, *args): - res = super(project_task, self).do_cancel(cr, uid, ids, *args) - tasks = self.browse(cr, uid, ids) - for task in tasks: - if task.procurement_id: - wf_service = netsvc.LocalService("workflow") - wf_service.trg_validate(uid, 'procurement.order', task.procurement_id.id, 'subflow.cancel', cr) + def do_cancel(self, cr, uid, ids, *args, **kwargs): + res = super(project_task, self).do_cancel(cr, uid, ids, *args, **kwargs) + self._validate_subflows(cr, uid, ids) return True project_task() From 8431b705979fc73639ac04c602e8d647c8a49973 Mon Sep 17 00:00:00 2001 From: "Harry (OpenERP)" Date: Sat, 11 Sep 2010 17:14:42 +0530 Subject: [PATCH 2/6] [FIX] caldav: fix bzr revid: hmo@tinyerp.com-20100911114442-egfc63paqr93rdpc --- addons/caldav/calendar.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/addons/caldav/calendar.py b/addons/caldav/calendar.py index 9a4e948cbe1..01c35880fbb 100644 --- a/addons/caldav/calendar.py +++ b/addons/caldav/calendar.py @@ -186,6 +186,8 @@ def map_data(cr, uid, obj, context=None): if field_type == 'selection': if not map_val: continue + if type(map_val) == list and len(map_val): #TOFIX: why need to check this + map_val = map_val[0] mapping = obj.__attribute__[map_dict].get('mapping', False) if mapping: map_val = mapping.get(map_val.lower(), False) From 2f97ff0188321fd555c6e4a6861035e6ec184062 Mon Sep 17 00:00:00 2001 From: Fabien Pinckaers Date: Sun, 12 Sep 2010 14:08:59 +0200 Subject: [PATCH 3/6] [IMP] Adding test reports in YML files, to generate sample of reports bzr revid: fp@tinyerp.com-20100912120859-s0qjlxt1wqx76lbr --- addons/sale/__openerp__.py | 25 +++++++++++++------------ addons/sale/test/sale_order_print.yml | 8 ++++++++ 2 files changed, 21 insertions(+), 12 deletions(-) create mode 100644 addons/sale/test/sale_order_print.yml diff --git a/addons/sale/__openerp__.py b/addons/sale/__openerp__.py index ceab22fd98a..2bcb2f2d88f 100644 --- a/addons/sale/__openerp__.py +++ b/addons/sale/__openerp__.py @@ -69,19 +69,20 @@ ], 'demo_xml': ['sale_demo.xml'], 'test': [ - 'test/data_test.yml', - 'test/manual_order_policy.yml', - 'test/prepaid_order_policy.yml', - 'test/picking_order_policy.yml', - 'test/postpaid_order_policy.yml', - 'test/advance_invoice.yml', - 'test/so_make_line_invoice.yml', - 'test/sale_procurement.yml', - 'test/invoice_on_ordered_qty.yml', - 'test/invoice_on_shipped_qty.yml', - ], + 'test/data_test.yml', + 'test/manual_order_policy.yml', + 'test/prepaid_order_policy.yml', + 'test/picking_order_policy.yml', + 'test/postpaid_order_policy.yml', + 'test/advance_invoice.yml', + 'test/so_make_line_invoice.yml', + 'test/sale_procurement.yml', + 'test/invoice_on_ordered_qty.yml', + 'test/invoice_on_shipped_qty.yml', + 'test/sale_order_print.yml', + ], 'installable': True, 'active': False, 'certificate': '0058103601429', } -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/sale/test/sale_order_print.yml b/addons/sale/test/sale_order_print.yml new file mode 100644 index 00000000000..def94d8c27e --- /dev/null +++ b/addons/sale/test/sale_order_print.yml @@ -0,0 +1,8 @@ +- + In order to test the PDF reports defined on a sale order, we will print a sale order +- + !python {model: sale.order}: | + import netsvc, tools, os + (data, format) = netsvc.LocalService('report.sale.order').create(cr, uid, [ref('sale.order'),ref('sale.order2')], {}, {}) + if tools.config['test_report_directory']: + file(os.path.join(tools.config['test_report_directory'], 'sale-sale_order.'+format), 'wb+').write(data) From 27a92be325b80657f32aeb4065042bc9c68ac013 Mon Sep 17 00:00:00 2001 From: Olivier Dony Date: Mon, 13 Sep 2010 02:43:29 +0200 Subject: [PATCH 4/6] [IMP] marketing_campaign: added group_by day for improved cross-analysis bzr revid: odo@openerp.com-20100913004329-0fleqqugzyn5bxua --- .../report/campaign_analysis.py | 15 ++++++++++----- .../report/campaign_analysis_view.xml | 7 ++++--- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/addons/marketing_campaign/report/campaign_analysis.py b/addons/marketing_campaign/report/campaign_analysis.py index aa0e0e01a22..066423c546c 100644 --- a/addons/marketing_campaign/report/campaign_analysis.py +++ b/addons/marketing_campaign/report/campaign_analysis.py @@ -44,11 +44,12 @@ class campaign_analysis(osv.osv): _columns = { 'res_id' : fields.integer('Resource', readonly=True), 'year': fields.char('Year', size=4, readonly=True), - 'month':fields.selection([('01','January'), ('02','February'), - ('03','March'), ('04','April'),('05','May'), ('06','June'), - ('07','July'), ('08','August'), ('09','September'), - ('10','October'), ('11','November'), ('12','December')], - 'Month', readonly=True), + 'month': fields.selection([('01','January'), ('02','February'), + ('03','March'), ('04','April'),('05','May'), ('06','June'), + ('07','July'), ('08','August'), ('09','September'), + ('10','October'), ('11','November'), ('12','December')], + 'Month', readonly=True), + 'day': fields.char('Day', size=10, readonly=True), 'date': fields.date('Date', readonly=True), 'campaign_id': fields.many2one('marketing.campaign', 'Campaign', readonly=True), @@ -63,6 +64,9 @@ class campaign_analysis(osv.osv): type="float" ), 'revenue': fields.float('Revenue',digits=(16,2),readonly=True), 'count' : fields.integer('# of Actions', readonly=True), + 'state': fields.selection([('todo', 'To Do'), + ('exception', 'Exception'), ('done', 'Done'), + ('cancelled', 'Cancelled')], 'State', readonly=True), } def init(self, cr): tools.drop_view_if_exists(cr, 'campaign_analysis') @@ -73,6 +77,7 @@ class campaign_analysis(osv.osv): min(wi.res_id) as res_id, to_char(wi.date::date, 'YYYY') as year, to_char(wi.date::date, 'MM') as month, + to_char(wi.date::date, 'YYYY-MM-DD') as day, wi.date::date as date, s.campaign_id as campaign_id, wi.activity_id as activity_id, diff --git a/addons/marketing_campaign/report/campaign_analysis_view.xml b/addons/marketing_campaign/report/campaign_analysis_view.xml index d88be86d01e..aa994fcfc48 100644 --- a/addons/marketing_campaign/report/campaign_analysis_view.xml +++ b/addons/marketing_campaign/report/campaign_analysis_view.xml @@ -9,6 +9,7 @@ + @@ -28,7 +29,7 @@ campaign.analysis search - + - + @@ -75,7 +76,7 @@ - Campaigns + Campaign Analysis campaign.analysis form tree From 33cb2c8c9a87e68ab9da02a95372af5ac63ea399 Mon Sep 17 00:00:00 2001 From: Olivier Dony Date: Mon, 13 Sep 2010 02:43:37 +0200 Subject: [PATCH 5/6] [IMP] marketing_campaign: another round of reviewing/improvements: - better form/search views - improved labels - added next sync on segments - added domain to prevent cross-campaign transitions on activities - ... bzr revid: odo@openerp.com-20100913004337-0cvl8qd0qaj3fomc --- .../marketing_campaign/marketing_campaign.py | 35 ++--- .../marketing_campaign_data.xml | 8 +- .../marketing_campaign_view.xml | 123 ++++++++++-------- 3 files changed, 89 insertions(+), 77 deletions(-) diff --git a/addons/marketing_campaign/marketing_campaign.py b/addons/marketing_campaign/marketing_campaign.py index c9383b53b15..4fd4fda5253 100644 --- a/addons/marketing_campaign/marketing_campaign.py +++ b/addons/marketing_campaign/marketing_campaign.py @@ -135,12 +135,12 @@ Normal - the campaign runs normally and automatically sends all emails and repor if activity.type != 'email': continue if not activity.email_template_id.from_account: - raise osv.except_osv(_("Error"), _("The campaign cannot be started: an email account is missing in the email activity '%s'")%activity.name) + raise osv.except_osv(_("Error"), _("The campaign cannot be started: the email account is missing in email activity '%s'")%activity.name) if activity.email_template_id.from_account.state != 'approved': - raise osv.except_osv(_("Error"), _("The campaign cannot be started: the email account is not approved in the email activity '%s'")%activity.name) + raise osv.except_osv(_("Error"), _("The campaign cannot be started: the email account is not approved in email activity '%s'")%activity.name) if not has_start and not has_signal_without_from: - raise osv.except_osv(_("Error"), _("The campaign hasn't any starting activity nor any activity with a signal and no previous activity.")) + raise osv.except_osv(_("Error"), _("The campaign cannot be started: it doesn't have any starting activity (or any activity with a signal and no previous activity)")) return self.write(cr, uid, ids, {'state': 'running'}) @@ -213,27 +213,31 @@ class marketing_campaign_segment(osv.osv): _name = "marketing.campaign.segment" _description = "Campaign Segment" + def _get_next_sync(self, cr, uid, ids, fn, args, context=None): + # next auto sync date is same for all segments + sync_job = self.pool.get('ir.model.data').get_object(cr, uid, 'marketing_campaign', 'ir_cron_marketing_campaign_every_day', context=context) + next_sync = sync_job and sync_job.nextcall or False + return dict.fromkeys(ids, next_sync) + _columns = { 'name': fields.char('Name', size=64,required=True), - 'campaign_id': fields.many2one('marketing.campaign', 'Campaign', - required=True, select=1, ondelete="cascade"), - 'object_id': fields.related('campaign_id','object_id', - type='many2one', relation='ir.model', - string='Object'), - 'ir_filter_id': fields.many2one('ir.filters', 'Filter', help="Filter to select the matching resource records that belong to this segment. New filters can be created and saved using the advanced search on the list view of the Resource"), + 'campaign_id': fields.many2one('marketing.campaign', 'Campaign', required=True, select=1, ondelete="cascade"), + 'object_id': fields.related('campaign_id','object_id', type='many2one', relation='ir.model', string='Resource'), + 'ir_filter_id': fields.many2one('ir.filters', 'Filter', help="Filter to select the matching resource records that belong to this segment. New filters can be created and saved using the advanced search on the list view of the Resource. If no filter is set, all records are selected without filtering. The synchronization mode may also add a criterion to the filter."), 'sync_last_date': fields.datetime('Last Synchronization', help="Date on which this segment was synchronized last time (automatically or manually)"), - 'sync_mode': fields.selection([('create_date', 'If record created after last sync'), - ('write_date', 'If record modified after last sync (no duplicates)'), + 'sync_mode': fields.selection([('create_date', 'Only records created after last sync'), + ('write_date', 'Only records modified after last sync (no duplicates)'), ('all', 'All records (no duplicates)')], - 'Workitem creation mode', - help="Determines how new campaign workitems are created for resource records matching this segment. This is used when segments are synchronized manually, or automatically via the scheduled job."), + 'Synchronization mode', + help="Determines an additional criterion to add to the filter when selecting new records to inject in the campaign."), 'state': fields.selection([('draft', 'Draft'), ('running', 'Running'), ('done', 'Done'), ('cancelled', 'Cancelled')], 'State',), - 'date_run': fields.datetime('Launching Date', help="Initial start date of this segment."), + 'date_run': fields.datetime('Launch Date', help="Initial start date of this segment."), 'date_done': fields.datetime('End Date', help="Date this segment was last closed or cancelled."), + 'date_next_sync': fields.function(_get_next_sync, method=True, string='Next Synchronization', type='datetime', help="Next time the synchronization job is scheduled to run automatically"), } _defaults = { @@ -264,7 +268,6 @@ class marketing_campaign_segment(osv.osv): if model_name: mod_name = model_name[0]['model'] res['domain'] = {'ir_filter_id': [('model_id', '=', mod_name)]} - res['context'] = {'default_model_id': model_name[0]['model']} else: res['value'] = {'ir_filter_id': False} return res @@ -594,7 +597,7 @@ class marketing_campaign_workitem(osv.osv): 'campaign_id': fields.related('activity_id', 'campaign_id', type='many2one', relation='marketing.campaign', string='Campaign', readonly=True, store=True), 'object_id': fields.related('activity_id', 'campaign_id', 'object_id', - type='many2one', relation='ir.model', string='Resource', select=1, readonly=True), + type='many2one', relation='ir.model', string='Resource', select=1, readonly=True, store=True), 'res_id': fields.integer('Resource ID', select=1, readonly=True), 'res_name': fields.function(_res_name_get, method=True, string='Resource Name', fnct_search=_resource_search, type="char", size=64), 'date': fields.datetime('Execution Date', help='If date is not set, this workitem has to be run manually', readonly=True), diff --git a/addons/marketing_campaign/marketing_campaign_data.xml b/addons/marketing_campaign/marketing_campaign_data.xml index 42ed4d12118..4f337b1d60e 100644 --- a/addons/marketing_campaign/marketing_campaign_data.xml +++ b/addons/marketing_campaign/marketing_campaign_data.xml @@ -5,7 +5,7 @@ - Check Marketing Campaign Activities + Marketing Campaign: Campaign workitems processing 1 hours -1 @@ -14,9 +14,9 @@ - + - Check Segment + Marketing Campaign: Segment Sync 1 days -1 @@ -25,6 +25,6 @@ - + diff --git a/addons/marketing_campaign/marketing_campaign_view.xml b/addons/marketing_campaign/marketing_campaign_view.xml index cbcb7fe1b76..7d1c8d3d2bf 100644 --- a/addons/marketing_campaign/marketing_campaign_view.xml +++ b/addons/marketing_campaign/marketing_campaign_view.xml @@ -32,14 +32,14 @@ - +