From 7be91c10088e835ecc333bcdc7973734ea0041ed Mon Sep 17 00:00:00 2001 From: "ksa (Open ERP)" Date: Tue, 22 Mar 2011 14:21:52 +0530 Subject: [PATCH 001/148] [FIX]:problem with create_date in base synchro lp bug: https://launchpad.net/bugs/725073 fixed bzr revid: ksa@tinyerp.co.in-20110322085152-xmq5lgh93351l7xh --- addons/base_synchro/wizard/base_synchro.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/addons/base_synchro/wizard/base_synchro.py b/addons/base_synchro/wizard/base_synchro.py index 0535ca8054d..1a593684b59 100644 --- a/addons/base_synchro/wizard/base_synchro.py +++ b/addons/base_synchro/wizard/base_synchro.py @@ -103,6 +103,11 @@ class base_synchro(osv.osv_memory): if object.model_id.model=='crm.case.history': fields = ['email','description','log_id'] value = pool_src.get(object.model_id.model).read(cr, uid, [id], fields)[0] + if 'create_date' in value: + del value['create_date'] + for key ,val in value.iteritems(): + if type(val)==tuple: + value.update({key:val[0]}) value = self.data_transform(cr, uid, pool_src, pool_dest, object.model_id.model, value, action, context=context) id2 = self.get_id(cr, uid, object.id, id, action, context) # From 6d10583973d371fff93a10896d43af832bc9826f Mon Sep 17 00:00:00 2001 From: "ARA (OpenERP)" Date: Thu, 24 Mar 2011 14:14:17 +0530 Subject: [PATCH 002/148] [FIX] Account: Account chart wizard does not check if generated account code for bank journal exsits lp bug: https://launchpad.net/bugs/684119 fixed bzr revid: ara@tinyerp.com-20110324084417-9rqbu46o4v97x2ey --- addons/account/account.py | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/addons/account/account.py b/addons/account/account.py index 2bdb62b44c0..8947afc8fe4 100644 --- a/addons/account/account.py +++ b/addons/account/account.py @@ -2921,15 +2921,27 @@ class wizard_multi_charts_accounts(osv.osv_memory): ref_acc_bank = obj_multi.chart_template_id.bank_account_view_id current_num = 1 + valid = True for line in obj_multi.bank_accounts_id: #create the account_account for this bank journal tmp = line.acc_name dig = obj_multi.code_digits if ref_acc_bank.code: - try: - new_code = str(int(ref_acc_bank.code.ljust(dig,'0')) + current_num) - except: - new_code = str(ref_acc_bank.code.ljust(dig-len(str(current_num)),'0')) + str(current_num) + while valid: + try: + new_code = str(int(ref_acc_bank.code.ljust(dig, '0')) + current_num) + ids = obj_acc.search(cr, uid,[('code', '=', new_code)]) + if not ids: + valid = False + else: + current_num += 1 + except: + new_code = str(ref_acc_bank.code.ljust(dig-len(str(current_num)), '0')) + str(current_num) + ids = obj_acc.search(cr, uid,[('code', '=', new_code)]) + if not ids: + valid = False + else: + current_num += 1 vals = { 'name': tmp, 'currency_id': line.currency_id and line.currency_id.id or False, @@ -2962,6 +2974,7 @@ class wizard_multi_charts_accounts(osv.osv_memory): vals_journal['default_debit_account_id'] = acc_cash_id obj_journal.create(cr, uid, vals_journal) current_num += 1 + valid = True #create the properties property_obj = self.pool.get('ir.property') From 0de7622c037ee2aa18dea205847703624761343d Mon Sep 17 00:00:00 2001 From: "ARA (OpenERP)" Date: Thu, 24 Mar 2011 14:16:53 +0530 Subject: [PATCH 003/148] [FIX] Account: Account chart wizard does not check if generated account code for bank journal exsits bzr revid: ara@tinyerp.com-20110324084653-ysbw98hvxcynrgqt --- addons/account/account.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/account/account.py b/addons/account/account.py index 8947afc8fe4..def72ec08d3 100644 --- a/addons/account/account.py +++ b/addons/account/account.py @@ -2930,14 +2930,14 @@ class wizard_multi_charts_accounts(osv.osv_memory): while valid: try: new_code = str(int(ref_acc_bank.code.ljust(dig, '0')) + current_num) - ids = obj_acc.search(cr, uid,[('code', '=', new_code)]) + ids = obj_acc.search(cr, uid, [('code', '=', new_code)]) if not ids: valid = False else: current_num += 1 except: new_code = str(ref_acc_bank.code.ljust(dig-len(str(current_num)), '0')) + str(current_num) - ids = obj_acc.search(cr, uid,[('code', '=', new_code)]) + ids = obj_acc.search(cr, uid, [('code', '=', new_code)]) if not ids: valid = False else: From 82565f571b748ac285754e1eb1a633b9bcd00c51 Mon Sep 17 00:00:00 2001 From: "ARA (OpenERP)" Date: Fri, 25 Mar 2011 15:19:39 +0530 Subject: [PATCH 004/148] [FIX] Account: payment term line need at least 5 to 6 digits precision lp bug: https://launchpad.net/bugs/740596 fixed bzr revid: ara@tinyerp.com-20110325094939-k30q24tu5okj7mcm --- addons/account/account.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/account/account.py b/addons/account/account.py index 2bdb62b44c0..1dab0d077af 100644 --- a/addons/account/account.py +++ b/addons/account/account.py @@ -102,7 +102,7 @@ class account_payment_term_line(osv.osv): ('fixed', 'Fixed Amount')], 'Valuation', required=True, help="""Select here the kind of valuation related to this payment term line. Note that you should have your last line with the type 'Balance' to ensure that the whole amount will be threated."""), - 'value_amount': fields.float('Value Amount', help="For Value percent enter % ratio between 0-1."), + 'value_amount': fields.float('Value Amount', digits=(16, 6), help="For Value percent enter % ratio between 0-1."), 'days': fields.integer('Number of Days', required=True, help="Number of days to add before computation of the day of month." \ "If Date=15/01, Number of Days=22, Day of Month=-1, then the due date is 28/02."), 'days2': fields.integer('Day of the Month', required=True, help="Day of the month, set -1 for the last day of the current month. If it's positive, it gives the day of the next month. Set 0 for net days (otherwise it's based on the beginning of the month)."), From 10fbcafa0366bff92d3a77f966408cb9c5e84a6a Mon Sep 17 00:00:00 2001 From: "ARA (OpenERP)" Date: Wed, 30 Mar 2011 11:48:09 +0530 Subject: [PATCH 005/148] [FIX] Account:Account chart wizard does not check if generated account code for bank journal exsits bzr revid: ara@tinyerp.com-20110330061809-3b28ug6dz37tq23v --- addons/account/account.py | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/addons/account/account.py b/addons/account/account.py index def72ec08d3..e25ec7fa08c 100644 --- a/addons/account/account.py +++ b/addons/account/account.py @@ -2930,18 +2930,13 @@ class wizard_multi_charts_accounts(osv.osv_memory): while valid: try: new_code = str(int(ref_acc_bank.code.ljust(dig, '0')) + current_num) - ids = obj_acc.search(cr, uid, [('code', '=', new_code)]) - if not ids: - valid = False - else: - current_num += 1 except: new_code = str(ref_acc_bank.code.ljust(dig-len(str(current_num)), '0')) + str(current_num) - ids = obj_acc.search(cr, uid, [('code', '=', new_code)]) - if not ids: - valid = False - else: - current_num += 1 + ids = obj_acc.search(cr, uid, [('code', '=', new_code)]) + if not ids: + valid = False + else: + current_num += 1 vals = { 'name': tmp, 'currency_id': line.currency_id and line.currency_id.id or False, From 53cad5a3bf55108a443d726a2637f3bc3e9823a6 Mon Sep 17 00:00:00 2001 From: "ron@tinyerp.com" <> Date: Thu, 31 Mar 2011 16:52:06 +0530 Subject: [PATCH 006/148] [FIX]sale: wrong price calculation when changing UoM and pricelist based on other pricelist lp bug: https://launchpad.net/bugs/742100 fixed bzr revid: ron@tinyerp.com-20110331112206-5ww6yrqyc3y88yzw --- addons/product/pricelist.py | 1 + addons/sale/sale.py | 2 ++ 2 files changed, 3 insertions(+) diff --git a/addons/product/pricelist.py b/addons/product/pricelist.py index 2271dbc86a6..4e7caff0e96 100644 --- a/addons/product/pricelist.py +++ b/addons/product/pricelist.py @@ -234,6 +234,7 @@ class product_pricelist(osv.osv): [res['base_pricelist_id']], product_id, qty, context=context)[res['base_pricelist_id']] ptype_src = self.browse(cr, uid, res['base_pricelist_id']).currency_id.id + uom_price_already_computed = True price = currency_obj.compute(cr, uid, ptype_src, res['currency_id'], price_tmp, round=False) elif res['base'] == -2: # this section could be improved by moving the queries outside the loop: diff --git a/addons/sale/sale.py b/addons/sale/sale.py index f80d610eb03..ac80f65e5d9 100644 --- a/addons/sale/sale.py +++ b/addons/sale/sale.py @@ -1111,6 +1111,8 @@ class sale_order_line(osv.osv): result['product_uos_qty'] = qty result['th_weight'] = q * product_obj.weight # Round the quantity up + if not uom: + uom =product_obj.uom_id and product_obj.uom_id.id if not uom2: uom2 = product_obj.uom_id if (product_obj.type=='product') and (product_obj.virtual_available * uom2.factor < qty * product_obj.uom_id.factor) \ From 79ca9ad384686e9fd70ec9f97fdf356bb5f5e5b1 Mon Sep 17 00:00:00 2001 From: "ron@tinyerp.com" <> Date: Fri, 1 Apr 2011 15:19:10 +0530 Subject: [PATCH 007/148] [IMP]product: wrong price calculation when changing UoM and pricelist based on other pricelist bzr revid: ron@tinyerp.com-20110401094910-stho2qg6pcgdtrve --- addons/product/product.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/product/product.py b/addons/product/product.py index bab6b5f5cc1..a56f13e73fa 100644 --- a/addons/product/product.py +++ b/addons/product/product.py @@ -593,7 +593,7 @@ class product_product(osv.osv): res[product.id] = (res[product.id] * (product.price_margin or 1.0)) + \ product.price_extra if 'uom' in context: - uom = product.uos_id or product.uom_id + uom = product.uom_id or product.uos_id res[product.id] = product_uom_obj._compute_price(cr, uid, uom.id, res[product.id], context['uom']) # Convert from price_type currency to asked one From 4bc1c69250829f82ace458aeedca7b44a15c3ff0 Mon Sep 17 00:00:00 2001 From: "ron@tinyerp.com" <> Date: Mon, 4 Apr 2011 15:31:41 +0530 Subject: [PATCH 008/148] [REF]sale:refectoring code wrong price calculation when changing UoM and pricelist based on other pricelist bzr revid: ron@tinyerp.com-20110404100141-2i3og2pxcxf3n1sg --- addons/sale/sale.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/addons/sale/sale.py b/addons/sale/sale.py index ac80f65e5d9..919358f500a 100644 --- a/addons/sale/sale.py +++ b/addons/sale/sale.py @@ -1111,8 +1111,6 @@ class sale_order_line(osv.osv): result['product_uos_qty'] = qty result['th_weight'] = q * product_obj.weight # Round the quantity up - if not uom: - uom =product_obj.uom_id and product_obj.uom_id.id if not uom2: uom2 = product_obj.uom_id if (product_obj.type=='product') and (product_obj.virtual_available * uom2.factor < qty * product_obj.uom_id.factor) \ @@ -1135,7 +1133,7 @@ class sale_order_line(osv.osv): else: price = self.pool.get('product.pricelist').price_get(cr, uid, [pricelist], product, qty or 1.0, partner_id, { - 'uom': uom, + 'uom': uom or result.get('product_uom'), 'date': date_order, })[pricelist] if price is False: From 3b31cb43692cfd1a7ef1c57dff8d4fc1928c1990 Mon Sep 17 00:00:00 2001 From: "Ujjvala Collins (OpenERP)" Date: Thu, 14 Apr 2011 11:03:11 +0530 Subject: [PATCH 009/148] [FIX] project: If a project is deleted its related analytic account should also be deleted. lp bug: https://launchpad.net/bugs/758699 fixed bzr revid: uco@tinyerp.com-20110414053311-ucmrf4vkl3ogl872 --- addons/project/project.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/addons/project/project.py b/addons/project/project.py index 134364d8b1a..9473918bf95 100644 --- a/addons/project/project.py +++ b/addons/project/project.py @@ -118,9 +118,11 @@ class project(osv.osv): return result.keys() def unlink(self, cr, uid, ids, *args, **kwargs): + analytic_obj = self.pool.get('account.analytic.account') for proj in self.browse(cr, uid, ids): if proj.tasks: raise osv.except_osv(_('Operation Not Permitted !'), _('You can not delete a project with tasks. I suggest you to deactivate it.')) + analytic_obj.unlink(cr, uid, [proj.analytic_account_id.id]) return super(project, self).unlink(cr, uid, ids, *args, **kwargs) _columns = { From 96d2e9b535773c30b29f3c498170a28a833f2c00 Mon Sep 17 00:00:00 2001 From: cpa-openerp Date: Fri, 15 Apr 2011 15:02:53 +0530 Subject: [PATCH 010/148] [FIX] Dataset is used to read records (read_ids method). bzr revid: cpa@tinyerp.com-20110415093253-qx78tf0001u1cg4d --- addons/base_gantt/__openerp__.py | 4 +- addons/base_gantt/controllers/main.py | 176 +-------- .../lib/dhtmlxGantt/sources/dhtmlxgantt.js | 4 +- addons/base_gantt/static/src/js/gantt.js | 366 +++++++++++------- .../base_gantt/static/src/xml/base_gantt.xml | 5 +- 5 files changed, 231 insertions(+), 324 deletions(-) diff --git a/addons/base_gantt/__openerp__.py b/addons/base_gantt/__openerp__.py index 55cec2c0863..c23f352a4f7 100644 --- a/addons/base_gantt/__openerp__.py +++ b/addons/base_gantt/__openerp__.py @@ -3,8 +3,8 @@ "version": "2.0", "depends": ['base'], "js": [ - 'static/lib/dhtmlxGantt/codebase/dhtmlxcommon.js', - 'static/lib/dhtmlxGantt/codebase/dhtmlxgantt.js', + 'static/lib/dhtmlxGantt/sources/dhtmlxcommon.js', + 'static/lib/dhtmlxGantt/sources/dhtmlxgantt.js', 'static/src/js/gantt.js' ], "css": ['static/lib/dhtmlxGantt/codebase/dhtmlxgantt.css'], diff --git a/addons/base_gantt/controllers/main.py b/addons/base_gantt/controllers/main.py index 7edb4d28763..a2e52c0cb32 100644 --- a/addons/base_gantt/controllers/main.py +++ b/addons/base_gantt/controllers/main.py @@ -1,184 +1,24 @@ -import glob, os -from xml.etree import ElementTree -import math -import simplejson import openerpweb -import time -import datetime -from base.controllers.main import Xml2Json - +from base.controllers.main import View -COLOR_PALETTE = ['#f57900', '#cc0000', '#d400a8', '#75507b', '#3465a4', '#73d216', '#c17d11', '#edd400', - '#fcaf3e', '#ef2929', '#ff00c9', '#ad7fa8', '#729fcf', '#8ae234', '#e9b96e', '#fce94f', - '#ff8e00', '#ff0000', '#b0008c', '#9000ff', '#0078ff', '#00ff00', '#e6ff00', '#ffff00', - '#905000', '#9b0000', '#840067', '#510090', '#0000c9', '#009b00', '#9abe00', '#ffc900', ] - -_colorline = ['#%02x%02x%02x' % (25 + ((r + 10) % 11) * 23, 5 + ((g + 1) % 11) * 20, 25 + ((b + 4) % 11) * 23) for r in range(11) for g in range(11) for b in range(11) ] - -def choice_colors(n): - if n > len(COLOR_PALETTE): - return _colorline[0:-1:len(_colorline) / (n + 1)] - elif n: - return COLOR_PALETTE[:n] - return [] - -class GanttView(openerpweb.Controller): +class GanttView(View): _cp_path = "/base_gantt/ganttview" - date_start = None - date_delay = None - date_stop = None - color_field = None - - day_length = 8 - fields = {} - events = [] - calendar_fields = {} - ids = [] model = '' domain = [] context = {} - event_res = [] - colors = {} - color_values = [] @openerpweb.jsonrequest def load(self, req, model, view_id): - m = req.session.model(model) - r = m.fields_view_get(view_id, 'gantt') - r["arch"] = Xml2Json.convert_to_structure(r["arch"]) - return {'fields_view':r} - - @openerpweb.jsonrequest - def get_events(self, req, **kw): - - self.model = kw['model'] - self.fields = kw['fields'] - self.day_length = kw['day_length'] - self.calendar_fields = kw['calendar_fields'] - self.color_field = kw.get('color_field') or self.color_field or None - self.fields[self.color_field] = "" - self.colors = kw.get('colors') or {} - self.text = self.calendar_fields['text']['name'] + fields_view = self.fields_view_get(req, model, view_id, 'gantt') + return {'fields_view':fields_view} - self.date_start = self.calendar_fields['date_start']['name'] - self.fields[self.date_start] = "" - - if self.calendar_fields.get('date_stop'): - self.date_stop = self.calendar_fields['date_stop']['name'] - self.fields[self.date_stop] = "" - if self.calendar_fields.get('date_delay'): - self.date_delay = self.calendar_fields['date_delay']['name'] - self.fields[self.date_delay] = "" - if self.calendar_fields.get('parent'): - self.parent = self.calendar_fields['parent']['name'] - self.fields[self.parent] = "" - - model = req.session.model(self.model) - event_ids = model.search([]) - - return self.create_event(event_ids, model) - - def create_event(self, event_ids, model): - - self.events = model.read(event_ids, self.fields.keys()) - result = [] - for evt in self.events: - - event_res = {} - key = evt[self.color_field] - name = key - value = key - if isinstance(key, list): # M2O, XMLRPC returns List instead of Tuple - name = key[0] - value = key[-1] - evt[self.color_field] = key = key[-1] - if isinstance(key, tuple): # M2O - value, name = key - - self.colors[key] = (name, value, None) - - st_date = evt.get(self.date_start) - if st_date: - self.set_format(st_date) - if self.date_delay: - duration = evt.get(self.date_delay) - else: - en_date = evt.get(self.date_stop) - - duration = (time.mktime(time.strptime(en_date, self.format))-\ - time.mktime(time.strptime(st_date, self.format)))/ (60 * 60) - - if duration > self.day_length : - d = math.floor(duration / 24) - h = duration % 24 - duration = d * self.day_length + h - - event_res = {} - event_res['start_date'] = st_date - event_res['duration'] = duration - event_res['text'] = evt.get(self.text) - event_res['id'] = evt['id'] - event_res['parent'] = evt.get(self.parent) - result.append(event_res) - - colors = choice_colors(len(self.colors)) - for i, (key, value) in enumerate(self.colors.items()): - self.colors[key] = [value[0], value[1], colors[i]] - - return {'result': result,'sidebar': self.colors} - - def set_format(self, st_date): - if len(st_date) == 10 : - self.format = "%Y-%m-%d" - else : - self.format = "%Y-%m-%d %H:%M:%S" - return - - def check_format(self, date): - if self.format == "%Y-%m-%d %H:%M:%S": - date = date + " 00:00:00" - return date - - @openerpweb.jsonrequest - def on_event_resize(self, req, **kw): - if self.date_delay: - key = self.date_delay - value = kw['duration'] - else: - key = self.date_stop - value = self.check_format(kw['end_date']) - try: - model = req.session.model(self.model) - res = model.write(kw['id'], {key : value}) - except Exception, e: - print "eeeeeeeeeeeeeeeeeeeeeeeeeee",e - return True - - @openerpweb.jsonrequest - def on_event_drag(self, req, **kw): - start_date = self.check_format(kw['start_date']) - if self.date_delay: - key = self.date_delay - value = kw['duration'] - else: - key = self.date_stop - value = self.check_format(kw['end_date']) - try: - model = req.session.model(self.model) - res = model.write(kw['id'], {self.date_start : start_date, key : value}) - except Exception, e: - print "eeeeeeeeeeeeeeeeeeeeeeeeeee",e - return True - @openerpweb.jsonrequest def reload_gantt(self, req, **kw): model = req.session.model(kw['model']) - if (kw['domain']): - domain = (kw['color_field'],'in', kw['domain']) - event_ids = model.search([domain]) - else: - event_ids = model.search([]) - return self.create_event(event_ids, model) + domain = kw['domain'] + + event_ids = model.search(domain) + return event_ids \ No newline at end of file diff --git a/addons/base_gantt/static/lib/dhtmlxGantt/sources/dhtmlxgantt.js b/addons/base_gantt/static/lib/dhtmlxGantt/sources/dhtmlxgantt.js index 52b9b562e96..7efcd730293 100644 --- a/addons/base_gantt/static/lib/dhtmlxGantt/sources/dhtmlxgantt.js +++ b/addons/base_gantt/static/lib/dhtmlxGantt/sources/dhtmlxgantt.js @@ -348,7 +348,7 @@ GanttProject.prototype.create = function() * @type: public * @topic: 0 */ -function GanttChart() +function GanttChart(day_length) { this.Error = new GanttError(); this.dhtmlXMLSenderObject = new dhtmlXMLSenderObject(this); @@ -356,7 +356,7 @@ function GanttChart() //settings this.heightTaskItem = 12; this.dayInPixels = 24; - this.hoursInDay = 8; + this.hoursInDay = day_length; this._showTreePanel = true; this._showTooltip = true; this.isShowDescTask = false; diff --git a/addons/base_gantt/static/src/js/gantt.js b/addons/base_gantt/static/src/js/gantt.js index f8391f2744b..f23da0c580d 100644 --- a/addons/base_gantt/static/src/js/gantt.js +++ b/addons/base_gantt/static/src/js/gantt.js @@ -7,7 +7,8 @@ QWeb.add_template('/base_gantt/static/src/xml/base_gantt.xml'); openerp.base.views.add('gantt', 'openerp.base_gantt.GanttView'); openerp.base_gantt.GanttView = openerp.base.Controller.extend({ - init: function(view_manager, session, element_id, dataset, view_id) { +init: function(view_manager, session, element_id, dataset, view_id) { + this._super(session, element_id); this.view_manager = view_manager; this.dataset = dataset; @@ -16,82 +17,224 @@ openerp.base_gantt.GanttView = openerp.base.Controller.extend({ this.fields_views = {}; this.widgets = {}; this.widgets_counter = 0; - this.fields = {}; - this.datarecord = {}; - this.calendar_fields = {}; - }, - do_show: function () { - // TODO: re-trigger search - this.$element.show(); - }, - do_hide: function () { - this.$element.hide(); + this.fields = this.dataset.fields ? this.dataset.fields: {}; + this.ids = this.dataset.ids; + this.name = ""; + this.date_start = ""; + this.date_delay = ""; + this.date_stop = ""; + this.color_field = ""; + this.day_lenth = 8; + this.colors = []; + this.color_values = []; + this.calendar_fields = {}; + this.info_fields = []; + this.domain = this.dataset._domain ? this.dataset._domain: []; + this.context = {}; + }, + start: function() { + this.rpc("/base_gantt/ganttview/load", {"model": this.model, "view_id": this.view_id}, this.on_loaded); + }, + on_loaded: function(data) { + + var self = this; this.fields_view = data.fields_view; - var self = this; this.name = this.fields_view.name || this.fields_view.arch.attrs.string; this.view_id = this.fields_view.view_id; this.date_start = this.fields_view.arch.attrs.date_start; this.date_delay = this.fields_view.arch.attrs.date_delay; this.date_stop = this.fields_view.arch.attrs.date_stop; - this.color_field = this.fields_view.arch.attrs.color; + this.color_field = this.fields_view.arch.attrs.color; this.day_length = this.fields_view.arch.attrs.day_length || 8; this.colors = this.fields_view.arch.attrs.colors; - this.fields = this.fields_view.fields; this.text = this.fields_view.arch.children[0].children[0].attrs.name; this.parent = this.fields_view.arch.children[0].attrs.link; - - this.calendar_fields['parent'] = {'name': this.parent}; - this.calendar_fields['date_start'] = {'name': this.date_start}; - this.calendar_fields['text'] = {'name': this.text}; - if(this.date_delay) - this.calendar_fields['date_delay'] = {'name': this.date_delay}; - if(this.date_stop) - this.calendar_fields['date_stop'] = {'name': this.date_stop}; - - this.calendar_fields['day_length'] = this.day_length; - this.rpc('/base_gantt/ganttview/get_events', - {'model': this.model, - 'fields': this.fields, - 'color_field': this.color_field, - 'day_length': this.day_length, - 'calendar_fields': this.calendar_fields, - 'colors': this.colors, - 'info_fields': this.info_fields - }, - function(res) { - self.create_gantt(); - self.load_event(res); - }) + + this.format = "%Y-%m-%d"; + this.time = "00:00:00"; + + self.create_gantt(); + self.get_events(self.ids); + this.$element.html(QWeb.render("GanttView", {"view": this, "fields_view": this.fields_view})); }, + + create_gantt: function() { + + ganttChartControl = new GanttChart(this.day_length); + ganttChartControl.setImagePath("/base_gantt/static/lib/dhtmlxGantt/codebase/imgs/"); + ganttChartControl.setEditable(true); + ganttChartControl.showTreePanel(true); + ganttChartControl.showContextMenu(true); + ganttChartControl.showDescTask(true,'d,s-f'); + ganttChartControl.showDescProject(true,'n,d'); + + }, + + get_events: function(event_ids) { + + var self = this; + this.dataset.read_ids(event_ids, {}, function(result) { + self.load_event(result); + }); + + }, + + load_event: function(events) { + + var self = this; + var result = events; + var project_id = new Array(); + var project = new Array(); + var sidebar = {} + var j = -1; + + for (i in result) { + + if (result[i][this.date_start] != false){ + var parent_id = result[i][this.parent][0]; + var parent_name = result[i][this.parent][1]; + + if (jQuery.inArray(parent_id, project_id) == -1){ + if (parent_id == undefined){ + parent_name = ""; + } + j = j + 1; + project[j] = new GanttProjectInfo(parent_id, parent_name, new Date(2011, 1, 1)); + project_id[j] = parent_id; + } + + var id = result[i]['id']; + var text = result[i][this.text]; + + var start_date = this.convert_date_format(result[i][this.date_start]); + + if (this.date_stop != undefined){ + if (result[i][this.date_stop] != false){ + var stop_date = this.convert_date_format(result[i][this.date_stop]); + var duration= self.hours_between(start_date, stop_date); + } + else{ + var duration = 0; + } + } + else{ + var duration = result[i][this.date_delay]; + } + if (duration == false) + duration = 0 + + var task = new GanttTaskInfo(id, text, start_date, duration, 100, ""); + + k = project_id.indexOf(parent_id); + project[k].addTask(task); + } + } + + for (i in project_id){ + ganttChartControl.addProject(project[i]); + } + + ganttChartControl.create("GanttDiv"); + ganttChartControl.attachEvent("onTaskEndResize", function(task) {self.on_task_end_resize(task);}) + ganttChartControl.attachEvent("onTaskEndDrag", function(task) {self.on_task_end_drag(task);}) + + }, + + hours_between: function(date1, date2) { + + var ONE_DAY = 1000 * 60 * 60 * 24 + var date1_ms = date1.getTime() + var date2_ms = date2.getTime() + var difference_ms = Math.abs(date1_ms - date2_ms) + + d = Math.round(difference_ms / ONE_DAY) + h = Math.round(difference_ms % ONE_DAY) + + return (d * this.day_length) + h; + + }, + + on_task_end_resize : function(task) { + + var event_id = task.getId(); + var data = {}; + + if (this.date_stop != undefined){ + data[this.date_stop] = this.reverse_convert_date_format(task.getFinishDate()); + }else{ + data[this.date_delay] = task.getDuration(); + } + this.dataset.write(event_id, data, function(result) {}); + + }, + + on_task_end_drag : function(task) { + + var event_id = task.getId(); + var data = {}; + + data[this.date_start] = this.reverse_convert_date_format(task.getEST()); + + if (this.date_stop != undefined){ + data[this.date_stop] = this.reverse_convert_date_format(task.getFinishDate()); + }else{ + data[this.date_delay] = task.getDuration(); + } + + this.dataset.write(event_id, data, function(result) {}); + + }, + + do_show: function () { + + this.$element.show(); + + }, + + do_hide: function () { + + this.$element.hide(); + + }, + convert_date_format: function(date) { - date=date+""; - if(typeof (date)!="string"||date.length===0){ + var self = this; + + if (date.length == 19){ + self.format = "%Y-%m-%d %H:%M:%S"; + self.time = date.split(' ')[1]; + } + + date = date+""; + if(typeof (date) != "string" || date.length === 0){ return null; } var iso=date.split("-"); - if(iso.length===0){ + if(iso.length === 0){ return null; } var day = iso[2]; + var iso_hours = day.split(' '); if (iso_hours.length > 1) { day = iso_hours[0]; - var iso_date_hours = iso_hours[1].split(':') + var iso_date_hours = iso_hours[1].split(':'); var new_date = new Date(iso[0], iso[1] - 1, day); new_date.setHours(iso_date_hours[0]); new_date.setMinutes(iso_date_hours[1]); new_date.setSeconds(iso_date_hours[2]); + } else { var new_date = new Date(iso[0], iso[1] - 1, day); @@ -100,125 +243,52 @@ openerp.base_gantt.GanttView = openerp.base.Controller.extend({ new_date.setMonth(iso[1]-1); new_date.setDate(day); return new_date; + }, - create_gantt: function() { - ganttChartControl = new GanttChart(); - ganttChartControl.setImagePath("/base_gantt/static/lib/dhtmlxGantt/codebase/imgs/"); - ganttChartControl.setEditable(true); - ganttChartControl.showTreePanel(true); - ganttChartControl.showContextMenu(true); - ganttChartControl.showDescTask(true,'d,s-f'); - ganttChartControl.showDescProject(true,'n,d'); - }, - load_event: function(res) { - var self = this - var result = res.result; - var sidebar = res.sidebar; - var project_id = new Array(); - var project = new Array(); - var j = -1; - var self = this; - for (i in result) { - - var parent_id = result[i]['parent'][0]; - var parent_name = result[i]['parent'][1]; - - if (jQuery.inArray(parent_id, project_id) == -1){ - if (parent_id == undefined){ - parent_name = ""; - } - j = j + 1; - project[j] = new GanttProjectInfo(parent_id, parent_name, new Date(2011, 1, 1)); - project_id[j] = parent_id; - } - - var id = result[i]['id']; - var text = result[i]['text']; - var start_date = this.convert_date_format(result[i]['start_date']); - var duration = result[i]['duration']; - - var task = new GanttTaskInfo(id, text, start_date, duration, 100, ""); - - k = project_id.indexOf(parent_id); - project[k].addTask(task); + reverse_convert_date_format: function(date) { + var self = this; - } - for (i in project_id){ - ganttChartControl.addProject(project[i]); - } - ganttChartControl.create("GanttDiv"); - ganttChartControl.attachEvent("onTaskEndResize", function(task) {self.on_task_end_resize(task);}) - ganttChartControl.attachEvent("onTaskEndDrag", function(task) {self.on_task_end_drag(task);}) + if (self.format == "%Y-%m-%d %H:%M:%S") + { + return date.getFullYear()+'-'+(date.getMonth()+1)+'-'+date.getDate()+' '+self.time; + } + else + { + return date.getFullYear()+"-"+(date.getMonth()+1)+"-"+date.getDate(); + } - //Create Sidebar - if (jQuery('#cal-sidebar-option').length == 0){ - jQuery('#gantt-sidebar').append( - jQuery('',{'width':'100%','cellspacing': 0, 'cellpadding': 0, 'id':'cal-sidebar-option'}) - ) - for(s in sidebar) { - jQuery('#cal-sidebar-option').append( - jQuery('').append( - jQuery('
').append( - jQuery('
') - .append( - jQuery('', - { - 'type': 'checkbox', - 'id':sidebar[s][0], - 'value':sidebar[s][0] - }).bind('click',function(){ - self.reload_gantt(self.color_field,self.model) - }), - sidebar[s][1] - ) - .css('background-color',sidebar[s][sidebar[s].length-1]) - ) - ) - ) - } - } }, - reload_gantt: function(color_field, model) { - var domain = []; - var self = this; - jQuery('input[type=checkbox]:checked','#cal-sidebar-option').each(function() { - domain.push(parseInt(jQuery(this).attr('id'))) - }); + + reload_gantt: function(domain) { + + var self = this; + this.rpc('/base_gantt/ganttview/reload_gantt',{ - 'domain':domain, - 'color_field':color_field, - 'model': model - },function(res) { + 'domain': domain, + 'model': self.model + },function(event_ids) { ganttChartControl.clearAll(); jQuery("#GanttDiv").children().remove(); - self.load_event(res); + self.get_events(event_ids); }); - }, - reverse_convert_date_format: function(date) { - return date.getFullYear()+"-"+(date.getMonth()+1)+"-"+date.getDate(); + }, - on_task_end_resize : function(task) { - this.rpc('/base_gantt/ganttview/on_event_resize', - {'id' : task.getId(), - 'end_date' : this.reverse_convert_date_format(task.getFinishDate()), - 'duration' : task.getDuration() - }, - function(result) { - }) - }, - on_task_end_drag : function(task) { - this.rpc('/base_gantt/ganttview/on_event_drag', - {'id' : task.getId(), - 'start_date' : this.reverse_convert_date_format(task.getEST()), - 'end_date' : this.reverse_convert_date_format(task.getFinishDate()), - 'duration' : task.getDuration() - }, - function(result) { - }) + do_search: function (domains, contexts, groupbys) { + var self = this; + return this.rpc('/base/session/eval_domain_and_context', { + domains: domains, + contexts: contexts, + group_by_seq: groupbys + }, function (results) { + + self.dataset.context = results.context; + self.dataset.domain = results.domain; + return self.reload_gantt(self.dataset.domain); + }); } - + }); // here you may tweak globals object, if any, and play with on_* or do_* callbacks on them diff --git a/addons/base_gantt/static/src/xml/base_gantt.xml b/addons/base_gantt/static/src/xml/base_gantt.xml index 72c14ceb16c..c85abf0cad8 100644 --- a/addons/base_gantt/static/src/xml/base_gantt.xml +++ b/addons/base_gantt/static/src/xml/base_gantt.xml @@ -3,12 +3,9 @@

- -
+
-
-
From 26e21b097e151c1d93aea77049ca5eab2758728a Mon Sep 17 00:00:00 2001 From: "Quentin (OpenERP)" Date: Tue, 19 Apr 2011 17:34:59 +0200 Subject: [PATCH 011/148] [FIX] account: fix error on initial balance if we don't give any criteria lp bug: https://launchpad.net/bugs/744789 fixed bzr revid: qdp-launchpad@openerp.com-20110419153459-fpd1zitw5ud3lzct --- addons/account/account_move_line.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/addons/account/account_move_line.py b/addons/account/account_move_line.py index 83a67df9178..e541a8f7490 100644 --- a/addons/account/account_move_line.py +++ b/addons/account/account_move_line.py @@ -93,6 +93,10 @@ class account_move_line(osv.osv): else: query = obj+".state <> 'draft' AND "+obj+".period_id IN (SELECT id FROM account_period WHERE fiscalyear_id IN (%s)) %s %s" % (fiscalyear_clause, where_move_state, where_move_lines_by_date) + if initial_bal and not context.get('periods', False) and not where_move_lines_by_date: + #we didn't pass any filter in the context, and the initial balance can't be computed using only the fiscalyear otherwise entries will be summed twice + #so we have to invalidate this query + query += " AND 1=2" if context.get('journal_ids', False): query += ' AND '+obj+'.journal_id IN (%s)' % ','.join(map(str, context['journal_ids'])) From b2a3d521faf426e6affcea10d1dee3f707065a90 Mon Sep 17 00:00:00 2001 From: "ARA (OpenERP)" Date: Wed, 27 Apr 2011 12:33:18 +0530 Subject: [PATCH 012/148] [FIX] account: payment term line need at least 5 to 6 digits precision bzr revid: ara@tinyerp.com-20110427070318-nq5757mhtqbay99o --- addons/account/account.py | 2 +- addons/account/data/account_data2.xml | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/addons/account/account.py b/addons/account/account.py index 1dab0d077af..fec7f39d86e 100644 --- a/addons/account/account.py +++ b/addons/account/account.py @@ -102,7 +102,7 @@ class account_payment_term_line(osv.osv): ('fixed', 'Fixed Amount')], 'Valuation', required=True, help="""Select here the kind of valuation related to this payment term line. Note that you should have your last line with the type 'Balance' to ensure that the whole amount will be threated."""), - 'value_amount': fields.float('Value Amount', digits=(16, 6), help="For Value percent enter % ratio between 0-1."), + 'value_amount': fields.float('Value Amount', digits_compute=dp.get_precision('Payment Term'), help="For Value percent enter % ratio between 0-1."), 'days': fields.integer('Number of Days', required=True, help="Number of days to add before computation of the day of month." \ "If Date=15/01, Number of Days=22, Day of Month=-1, then the due date is 28/02."), 'days2': fields.integer('Day of the Month', required=True, help="Day of the month, set -1 for the last day of the current month. If it's positive, it gives the day of the next month. Set 0 for net days (otherwise it's based on the beginning of the month)."), diff --git a/addons/account/data/account_data2.xml b/addons/account/data/account_data2.xml index 4f482b496af..4a44c726960 100644 --- a/addons/account/data/account_data2.xml +++ b/addons/account/data/account_data2.xml @@ -21,7 +21,10 @@ - + + Payment Term + 6 + From 5060d7111c0c08abd77b69c19a3777f0e3088abf Mon Sep 17 00:00:00 2001 From: "sma (Tiny)" Date: Wed, 27 Apr 2011 17:50:51 +0530 Subject: [PATCH 013/148] [IMP] Implement many2one initiall work. bzr revid: sma@tinyerp.com-20110427122051-h80fka7fqjz0fcpz --- addons/base/controllers/main.py | 6 +++ addons/base/static/src/base.html | 1 + addons/base/static/src/css/base.css | 59 +++++++++++++++++++++++++++++ addons/base/static/src/js/base.js | 1 + addons/base/static/src/js/data.js | 10 +++++ addons/base/static/src/js/form.js | 16 ++++++++ addons/base/static/src/xml/base.xml | 5 ++- addons/base/static/test/test.html | 1 + 8 files changed, 98 insertions(+), 1 deletion(-) diff --git a/addons/base/controllers/main.py b/addons/base/controllers/main.py index 8faca685300..a1560936213 100644 --- a/addons/base/controllers/main.py +++ b/addons/base/controllers/main.py @@ -420,6 +420,12 @@ class DataSet(openerpweb.Controller): r = m.default_get(fields, context) return {'result': r} + @openerpweb.jsonrequest + def name_search(self, req, model, search_str, domain=[], context={}): + m = req.session.model(model) + r = m.name_search(search_str, domain, 'ilike', context) + return {'result': r} + class View(openerpweb.Controller): def fields_view_get(self, request, model, view_id, view_type, transform=True, toolbar=False, submenu=False): diff --git a/addons/base/static/src/base.html b/addons/base/static/src/base.html index 83fbfcecefc..8d18b2f14ca 100644 --- a/addons/base/static/src/base.html +++ b/addons/base/static/src/base.html @@ -23,6 +23,7 @@ + diff --git a/addons/base/static/src/css/base.css b/addons/base/static/src/css/base.css index 1bd004b53f6..dc16c772785 100644 --- a/addons/base/static/src/css/base.css +++ b/addons/base/static/src/css/base.css @@ -779,3 +779,62 @@ body.openerp { background: url(http://placekitten.com/g/212/100) repeat; } +/* Many2one Autosearch */ + +.openerp .combo_img { + position: absolute; + margin-left: -19px; + margin-top: 3px; +} + +.openerp .autoTextResults { + position: absolute; + z-index: 1000; + background-color: #fff; + border: 1px solid #333; + display: none; + padding: 0 2px 0 2px; + min-width: 132px; + border-radius: 3px; + -moz-border-radius: 3px; + -webkit-border-radius: 3px; + color: #1F1F1F; + overflow: auto; +} + +.openerp table.autoTextTable { + border: none; + font-family: arial, sans-serif; + font-size: 13px; + font-style: normal; + font-variant: normal; + font-weight: normal; + width: 100%; +} + +.openerp table.autoTextTable tr.autoTextNormalRow td { +} + +.openerp table.autoTextTable tr.autoTextSelectedRow td { + background-color: DarkGray; + color: #1F1F1F; + cursor: pointer; +} + +.openerp table.autoTextTable ul{ + list-style-image:none; + list-style-type:none; +} + +.openerp table.autoTextTable td a.autoTextHighlight { + font-weight: bold; + text-decoration: none; + color: #FFF; +} + +.openerp table.autoTextTable td.autoTextHidden { + display: none; +} + +/* ------------- End autocomplete ------- */ + diff --git a/addons/base/static/src/js/base.js b/addons/base/static/src/js/base.js index 504f5ca744d..615b2c8e889 100644 --- a/addons/base/static/src/js/base.js +++ b/addons/base/static/src/js/base.js @@ -125,6 +125,7 @@ openerp.base = function(instance) { openerp.base.views(instance); openerp.base.search(instance); openerp.base.list(instance); + openerp.base.m2o(instance); openerp.base.form(instance); }; diff --git a/addons/base/static/src/js/data.js b/addons/base/static/src/js/data.js index a29f320b79c..79482f33430 100644 --- a/addons/base/static/src/js/data.js +++ b/addons/base/static/src/js/data.js @@ -118,6 +118,16 @@ openerp.base.DataSet = openerp.base.Controller.extend( /** @lends openerp.base. ids: ids, args: args }, callback); + + }, + name_search: function (search_str, callback) { + search_str = search_str || ''; + return this.rpc('/base/dataset/name_search', { + model: this.model, + search_str: search_str, + domain: this.domain || [], + context: this.context + }, callback); }, exec_workflow: function (id, signal, callback) { return this.rpc('/base/dataset/exec_workflow', { diff --git a/addons/base/static/src/js/form.js b/addons/base/static/src/js/form.js index 84d7fe0babd..9a5e092b142 100644 --- a/addons/base/static/src/js/form.js +++ b/addons/base/static/src/js/form.js @@ -824,10 +824,24 @@ openerp.base.form.FieldSelection = openerp.base.form.Field.extend({ } }); +openerp.base.form.FieldMany2OneDatasSet = openerp.base.DataSetStatic.extend({ + start: function() { + }, + write: function (id, data, callback) { + this._super(id, data, callback); + }, +}); + openerp.base.form.FieldMany2One = openerp.base.form.Field.extend({ init: function(view, node) { this._super(view, node); this.template = "FieldMany2One"; + this.is_field_m2o = true; + }, + start: function() { + this.$element = $('#' + this.element_id); + this.dataset = new openerp.base.form.FieldMany2OneDatasSet(this.session, this.field.relation); + new openerp.base.m2o(this.$element, this.field.relation, this.dataset) }, set_value: function(value) { this._super.apply(this, arguments); @@ -837,6 +851,8 @@ openerp.base.form.FieldMany2One = openerp.base.form.Field.extend({ this.value = value[0]; } this.$element.find('input').val(show_value); + // Need to replace this `text` with original `id` after discuss with xmo + this.$element.find('input').attr('text', this.value); } }); diff --git a/addons/base/static/src/xml/base.xml b/addons/base/static/src/xml/base.xml index b49ef2c7d6a..c59229511a9 100644 --- a/addons/base/static/src/xml/base.xml +++ b/addons/base/static/src/xml/base.xml @@ -257,7 +257,7 @@
+ +
diff --git a/addons/base/static/test/test.html b/addons/base/static/test/test.html index 5fcf4f4c594..b71e8231bd7 100644 --- a/addons/base/static/test/test.html +++ b/addons/base/static/test/test.html @@ -21,6 +21,7 @@ + - - - - - - - - -
-
    -
- -
-
    -
-
-
- - -
-
-

Choose dashboard layout

-
    -
-
-
\ No newline at end of file diff --git a/addons/base_dashboard/static/src/js/dashboard.js b/addons/base_dashboard/static/src/js/dashboard.js index 34d09f80e62..5ee83f6216f 100644 --- a/addons/base_dashboard/static/src/js/dashboard.js +++ b/addons/base_dashboard/static/src/js/dashboard.js @@ -10,34 +10,108 @@ openerp.base.form.Board = openerp.base.form.Widget.extend({ }, start: function() { this._super.apply(this, arguments); - this.$element.html(QWeb.render(this.template)); - }, - - render: function() { - var self = this; - jQuery('body').append( - jQuery('
', {'id': 'dashboard_template'}).load('/base_dashboard/static/src/dashboard_template.html',self.on_loaded).hide() - ) - }, - - on_loaded: function() { + + this.$element.html(QWeb.render(this.template)); + var $dashboard = this.$element.find('#dashboard'); var children = this.node.children; - var board = jQuery('#dashboard').dashboard({ - layoutClass:'layout' - }); - board.init(); - for(var ch = 0; ch < children.length; ch++) { - var ch_widgets = children[ch].children; - for(var chld = 0; chld < ch_widgets.length; chld++) { - var widget_type = ch_widgets[chld].tag; - var child_index = widget_type == 'action' ? chld : ch; - var widget = new (openerp.base.form.widgets.get_object(widget_type)) (this.view, ch_widgets[chld], board, child_index); - widget.start(); + + for(var ch=0; ch < children.length; ch++) { + var node = children[ch]; + + var widget; + if(node.tag.indexOf('child') >= 0) { + widget = new (openerp.base.form.widgets.get_object('child')) (this.view, node, $dashboard); + } else { + //Vpaned + widget = new (openerp.base.form.widgets.get_object(node.tag)) (this.view, node, $dashboard); } + + widget.start(); + } - } + + jQuery('.column').css('width', 100/children.length+'%'); + }, + +// render: function() { +// var self = this; +// var children = this.node.children; +// console.log('test>>>',this.$element) +//// jQuery('body').append( +//// jQuery('
', {'id': 'dashboard_template'}).load('/base_dashboard/static/src/dashboard_template.html',self.on_loaded).hide() +//// ) +// }, + +// on_loaded: function() { +// var children = this.node.children; +// var board = jQuery('#dashboard').dashboard({ +// layoutClass:'layout' +// }); +// board.init(); +// for(var ch = 0; ch < children.length; ch++) { +// var ch_widgets = children[ch].children; +// for(var chld = 0; chld < ch_widgets.length; chld++) { +// var widget_type = ch_widgets[chld].tag; +// var child_index = widget_type == 'action' ? chld : ch; +// var widget = new (openerp.base.form.widgets.get_object(widget_type)) (this.view, ch_widgets[chld], board, child_index); +// widget.start(); +// } +// } +// } }); + +openerp.base.form.Dashbar = openerp.base.form.Widget.extend({ + init: function(view, node, dashboard) { + this._super(view, node, dashboard); + this.dashboard = dashboard; + }, + start: function() { + var $dashboard = this.dashboard; + var children = this.node.children; + $dashboard.append( + jQuery('
',{ + 'class': 'column', + 'id': this.node.tag + }) + ) + for(var chld=0; chld < children.length;chld++) { + var child = children[chld]; + $dashboard.find('#'+this.node.tag).append( + jQuery('
',{ + 'class': 'portlet' + } + ).append( + jQuery('
',{ + 'class': 'portlet-header' + }).html(child.attrs.string), + jQuery('
',{ + 'class': 'portlet-content' + }).html('test') + ) + ) + } + + $( ".column" ).sortable({ + connectWith: ".column" + }); + + $( ".portlet" ).addClass( "ui-widget ui-widget-content ui-helper-clearfix ui-corner-all" ) + .find( ".portlet-header" ) + .addClass( "ui-widget-header ui-corner-all" ) + .prepend( "") + .end() + .find( ".portlet-content" ); + + $( ".portlet-header .ui-icon" ).click(function() { + $( this ).toggleClass( "ui-icon-minusthick" ).toggleClass( "ui-icon-plusthick" ); + $( this ).parents( ".portlet:first" ).find( ".portlet-content" ).toggle(); + }); + + $( ".column" ).disableSelection(); + }, +}) + openerp.base.form.Action = openerp.base.form.Widget.extend({ init: function(view, node, board, child_index) { this._super(view, node, board, child_index); @@ -99,6 +173,7 @@ openerp.base.form.Vpaned = openerp.base.form.Widget.extend({ }) openerp.base.form.widgets.add('hpaned', 'openerp.base.form.Board'); +openerp.base.form.widgets.add('child', 'openerp.base.form.Dashbar'); openerp.base.form.widgets.add('vpaned', 'openerp.base.form.Vpaned'); openerp.base.form.widgets.add('action', 'openerp.base.form.Action'); } \ No newline at end of file diff --git a/addons/base_dashboard/static/src/xml/base_dashboard.xml b/addons/base_dashboard/static/src/xml/base_dashboard.xml index efe0a92c4dc..c019ee307b1 100644 --- a/addons/base_dashboard/static/src/xml/base_dashboard.xml +++ b/addons/base_dashboard/static/src/xml/base_dashboard.xml @@ -1,12 +1,15 @@ \ No newline at end of file From e9c0ce5ea215f43281f471fbd9e4657fc0983fbd Mon Sep 17 00:00:00 2001 From: "vda (OpenERP)" Date: Wed, 11 May 2011 14:12:55 +0530 Subject: [PATCH 046/148] [ADD] Forget css. bzr revid: vda@tinyerp.com-20110511084255-il7ha4s40ghv04oy --- .../static/src/css/dashboard.css | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 addons/base_dashboard/static/src/css/dashboard.css diff --git a/addons/base_dashboard/static/src/css/dashboard.css b/addons/base_dashboard/static/src/css/dashboard.css new file mode 100644 index 00000000000..c0b6a2e1395 --- /dev/null +++ b/addons/base_dashboard/static/src/css/dashboard.css @@ -0,0 +1,32 @@ +.column { + float: left; + padding-bottom: 100px; +} + +.portlet { + margin: 0 1em 1em 0; +} + +.portlet-header { + margin: 0.3em; + padding-bottom: 4px; + padding-left: 0.2em; +} + +.portlet-header .ui-icon { + float: right; +} + +.portlet-content { + padding: 0.4em; +} + +.ui-sortable-placeholder { + border: 1px dotted black; + visibility: visible !important; + height: 50px !important; +} + +.ui-sortable-placeholder * { + visibility: hidden; +} \ No newline at end of file From 7664ee4650ec7f6902a0d27845b0978a2a2a3b0a Mon Sep 17 00:00:00 2001 From: "vda (OpenERP)" Date: Wed, 11 May 2011 14:43:42 +0530 Subject: [PATCH 047/148] [FIX] Code cleanup. bzr revid: vda@tinyerp.com-20110511091342-y76kpbhtg40opvzn --- .../base_dashboard/static/src/js/dashboard.js | 69 +++++-------------- 1 file changed, 18 insertions(+), 51 deletions(-) diff --git a/addons/base_dashboard/static/src/js/dashboard.js b/addons/base_dashboard/static/src/js/dashboard.js index 5ee83f6216f..47393efca92 100644 --- a/addons/base_dashboard/static/src/js/dashboard.js +++ b/addons/base_dashboard/static/src/js/dashboard.js @@ -32,32 +32,6 @@ openerp.base.form.Board = openerp.base.form.Widget.extend({ jQuery('.column').css('width', 100/children.length+'%'); }, - -// render: function() { -// var self = this; -// var children = this.node.children; -// console.log('test>>>',this.$element) -//// jQuery('body').append( -//// jQuery('
', {'id': 'dashboard_template'}).load('/base_dashboard/static/src/dashboard_template.html',self.on_loaded).hide() -//// ) -// }, - -// on_loaded: function() { -// var children = this.node.children; -// var board = jQuery('#dashboard').dashboard({ -// layoutClass:'layout' -// }); -// board.init(); -// for(var ch = 0; ch < children.length; ch++) { -// var ch_widgets = children[ch].children; -// for(var chld = 0; chld < ch_widgets.length; chld++) { -// var widget_type = ch_widgets[chld].tag; -// var child_index = widget_type == 'action' ? chld : ch; -// var widget = new (openerp.base.form.widgets.get_object(widget_type)) (this.view, ch_widgets[chld], board, child_index); -// widget.start(); -// } -// } -// } }); @@ -77,17 +51,25 @@ openerp.base.form.Dashbar = openerp.base.form.Widget.extend({ ) for(var chld=0; chld < children.length;chld++) { var child = children[chld]; + var widget = new (openerp.base.form.widgets.get_object(child.tag)) (this.view, child); + widget.start() $dashboard.find('#'+this.node.tag).append( jQuery('
',{ - 'class': 'portlet' + 'class': 'portlet', + 'id': child.attrs.name } ).append( jQuery('
',{ 'class': 'portlet-header' - }).html(child.attrs.string), + }).html(child.attrs.string).append( + jQuery('',{ + 'class': 'ui-icon ui-icon-minusthick' + }) + ), jQuery('
',{ - 'class': 'portlet-content' - }).html('test') + 'class': 'portlet-content', + 'id': child.attrs.name+'-portlet-content' + }) ) ) } @@ -99,7 +81,6 @@ openerp.base.form.Dashbar = openerp.base.form.Widget.extend({ $( ".portlet" ).addClass( "ui-widget ui-widget-content ui-helper-clearfix ui-corner-all" ) .find( ".portlet-header" ) .addClass( "ui-widget-header ui-corner-all" ) - .prepend( "") .end() .find( ".portlet-content" ); @@ -113,10 +94,8 @@ openerp.base.form.Dashbar = openerp.base.form.Widget.extend({ }) openerp.base.form.Action = openerp.base.form.Widget.extend({ - init: function(view, node, board, child_index) { - this._super(view, node, board, child_index); - this.board = board; - this.child_index = child_index; + init: function(view, node) { + this._super(view, node); }, start: function() { this._super.apply(this, arguments); @@ -128,26 +107,14 @@ openerp.base.form.Action = openerp.base.form.Widget.extend({ on_load_action: function(result) { var action = result.action; - - action.search_view = false; + action.search_view = action.search_view_id = false; action.no_sidebar = true; - action.search_view_id = false; var node_attrs = this.node.attrs; - var get_column = ['first', 'second', 'third']; - var board_element = this.board.element.find('[id=column-'+get_column[this.child_index]+']'); - - this.board.addWidget({ - 'id': node_attrs.name, - 'title': node_attrs.string, - }, board_element); - - var content_id = node_attrs.name+'-widgetcontent'; - this.board.getWidget(node_attrs.name).element.find('.widgetcontent').attr('id',content_id) - - action_manager = new openerp.base.ActionManager(this.session, content_id); + var content_id = jQuery('#'+node_attrs.name).find('.portlet-content').attr('id') + var action_manager = new openerp.base.ActionManager(this.session, content_id); action_manager.start(); - this.board.getWidget(node_attrs.name).url = action_manager.do_action(action); + action_manager.do_action(action); } }) From 1ab09878032a644cca80a1e8403ecdf33e460139 Mon Sep 17 00:00:00 2001 From: Jacques-Etienne Baudoux Date: Wed, 11 May 2011 18:07:07 +0200 Subject: [PATCH 048/148] [IMP] logging of rpc calls and cron jobs lp bug: https://launchpad.net/bugs/781190 fixed bzr revid: jba@openerp.com-20110511160707-lsf87msknw7rngus --- openerp/addons/base/ir/ir_cron.py | 9 ++++++++- openerp/netsvc.py | 20 +++++++++++--------- 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/openerp/addons/base/ir/ir_cron.py b/openerp/addons/base/ir/ir_cron.py index 2ab8819792a..aac021b0497 100644 --- a/openerp/addons/base/ir/ir_cron.py +++ b/openerp/addons/base/ir/ir_cron.py @@ -20,6 +20,10 @@ ############################################################################## import time +import sys +import traceback +import logging +from pprint import pformat from datetime import datetime from dateutil.relativedelta import relativedelta import netsvc @@ -91,10 +95,13 @@ class ir_cron(osv.osv, netsvc.Agent): if m and hasattr(m, func): f = getattr(m, func) try: + depth=(None if self._logger.isEnabledFor(logging.DEBUG_RPC_ANSWER) else 1) + netsvc.log('cron', (cr.dbname,uid,'*',model,func)+tuple(args), channel=logging.DEBUG, depth=(None if self._logger.isEnabledFor(logging.DEBUG_RPC_ANSWER) else 1), fn='object.execute') f(cr, uid, *args) except Exception, e: cr.rollback() - self._logger.exception("Job call of self.pool.get('%s').%s(cr, uid, *%r) failed" % (model, func, args)) + logger=logging.getLogger('cron') + logger.exception("Job call of self.pool.get('%s').%s(cr, uid, *%r) failed" % (model, func, args)) def _poolJobs(self, db_name, check=False): diff --git a/openerp/netsvc.py b/openerp/netsvc.py index 1b8d54e3c8e..f06f96f7285 100644 --- a/openerp/netsvc.py +++ b/openerp/netsvc.py @@ -393,19 +393,21 @@ def replace_request_password(args): args[2] = '*' return args -class OpenERPDispatcher: - def log(self, title, msg, channel=logging.DEBUG_RPC, depth=None): - logger = logging.getLogger(title) - if logger.isEnabledFor(channel): - for line in pformat(msg, depth=depth).split('\n'): - logger.log(channel, line) +def log(title, msg, channel=logging.DEBUG_RPC, depth=None, fn=""): + logger = logging.getLogger(title) + if logger.isEnabledFor(channel): + indent=0 + for line in (fn+pformat(msg, depth=depth)).split('\n'): + logger.log(channel, ' '*indent+line) + indent=len(fn) +class OpenERPDispatcher: + def log(self, title, msg, channel=logging.DEBUG_RPC, depth=None, fn=""): + log(title, msg, channel=channel, depth=depth, fn=fn) def dispatch(self, service_name, method, params): try: logger = logging.getLogger('result') - self.log('service', service_name) - self.log('method', method) - self.log('params', replace_request_password(params), depth=(None if logger.isEnabledFor(logging.DEBUG_RPC_ANSWER) else 1)) + self.log('service', tuple(replace_request_password(params)), depth=(None if logger.isEnabledFor(logging.DEBUG_RPC_ANSWER) else 1), fn='%s.%s'%(service_name,method)) auth = getattr(self, 'auth_provider', None) result = ExportService.getService(service_name).dispatch(method, auth, params) self.log('result', result, channel=logging.DEBUG_RPC_ANSWER) From 1a7fd90a1f4ffcca9fad34e3e9df52b493ac27fc Mon Sep 17 00:00:00 2001 From: "sma (Tiny)" Date: Thu, 12 May 2011 15:07:28 +0530 Subject: [PATCH 049/148] [IMP] Improve many2one with jQuery widget. bzr revid: sma@tinyerp.com-20110512093728-nlxp59p5qbl79q2k --- addons/base/static/src/js/m2o.js | 431 +++++-------------------------- 1 file changed, 68 insertions(+), 363 deletions(-) diff --git a/addons/base/static/src/js/m2o.js b/addons/base/static/src/js/m2o.js index 094c7b0d837..23bdeb0e5e3 100644 --- a/addons/base/static/src/js/m2o.js +++ b/addons/base/static/src/js/m2o.js @@ -1,376 +1,81 @@ -openerp.base.m2o = function(openerp) { +openerp.base.m2o = function(openerp){ -openerp.base.m2o = openerp.base.Controller.extend({ - init: function(view_manager, element_id, model, dataset, session) { - this._super(element_id, model, dataset, session); + openerp.base.m2o = openerp.base.Controller.extend({ + init: function(view_manager, element_id, model, dataset, session){ + this._super(element_id, model, dataset, session); - this.view_manager = view_manager - this.session = session; - this.element = element_id.find('input'); - this.relation = model; - this.dataset = dataset; - this.name = this.element.attr('name'); - this.selectedResultRow = 0; - this.selectedResult = false; - this.numResultRows = 0; - this.completeDelay = 500; - this.specialKeyPressed = false; - this.lastKey = null; - this.delayedRequest = null; - this.lastTextResult = this.element.val(); - this.lastSearch = null; + this.view_manager = view_manager + this.session = session; + this.element = element_id.find('input'); + this.dataset = dataset; + var cache = {}; + var lastXhr; + this.relation = model; + this.result_ids = [] + var self = this - this.select_img = jQuery('#'+ this.element.attr('name') + '_select'); - if(this.select_img) - jQuery(this.select_img).click(jQuery.proxy(this, 'select')); + this.element.autocomplete({ + source: function(request, response){ + var search_val = request.term; + if (search_val in cache) { + response(cache[search_val]); + return; + } + //pass request to server + lastXhr = self.dataset.name_search(search_val, function(obj, status, xhr){ + var result = obj.result + var values = []; - this.element.bind({ - keydown: jQuery.proxy(this, 'on_keydown'), - keypress: jQuery.proxy(this, 'on_keypress'), - keyup: jQuery.proxy(this, 'on_keyup') - }); - }, + if (!result.length) { + values.push({'value': 'Create...', id: 'create'}) + } - get_matched : function() { - if(!this.relation) { - return; - } - var self = this; - this.dataset.name_search(this.element.val(), function(response) { - var res = response.result[0]; - self.element.val(res[1]); - self.element.attr('text', res[0]); - }); - }, + $.each(result, function(i, val){ + values.push({ + value: val[1], + id: val[0] + }); + self.result_ids.push(result[i][0]) + }); - callSearchRequest: function() { - this.delayedRequest = null - this.lastSearch = this.element.val(); - var s = this.element.val(); - var val = s.lastIndexOf(',') >= 0 ? s.substring(s.lastIndexOf(',') + 1).replace(/^\s+|\s+$/g, "") : s.replace(/^\s+|\s+$/g, ""); - var self = this; - this.dataset.name_search(val, function(obj){ - self.displayResults(obj); - }); - return true; - }, + if (values.length > 10) { + values = values.slice(0, 10); + values.push({'value': 'More...', id: 'more'}) + } + //process response + cache[search_val] = values; + response(values); + }); + return; + }, - select : function(evt) { - // Set the width of combo-box as per input box - jQuery('div#autoCompleteResults_' + this.name).width(this.element.width()); + select: function(event, ui){ + if (ui.item.id == 'more') { + self.dataset.ids = self.result_ids; + self.dataset.count = self.dataset.ids.length; + self.dataset.domain = [] + var pop = new openerp.base.form.Many2XSelectPopup(null, self.session); + pop.select_element(self.relation, self.dataset); + self.element.val('') + return; + } - if (jQuery('div#autoCompleteResults_'+this.name).is(':visible')){ - this.select_img.attr('src', '/base/static/src/img/icons/index1.jpeg'); - jQuery('div#autoCompleteResults_'+this.name).hide(); - return false; - } else { - this.select_img.attr('src', '/base/static/src/img/icons/index2.jpeg'); - } - return this.callSearchRequest(); - }, - - displayResults : function(obj) { - var self = this; - var result = obj.result; - var data = [] - this.result_ids = [] - if (result.length > 10) { - for (var i in result){ - this.result_ids.push(result[i][0]) - } - data = result; - result = data.slice(0, 10); - } - - this.numResultRows = result.length; - this.selectedResultRow = 0; - - var $fancyTable = jQuery('', { - "class": "autoTextTable", - "name": "autoCompleteTable" + self.name, - "id": "autoCompleteTable" + self.name}); - var rowName = "autoComplete" + self.name + "_"; - var $resultsTable = jQuery('').appendTo($fancyTable); - jQuery.each(result, function (i, currentObject) { - - jQuery('', { - "class": "autoTextNormalRow", - "name": rowName + i, - "id": rowName + i, - }).append(jQuery('', { - "class": "autoTextNormalRow", - "id": rowName + this.numResultRows++ - }).append(jQuery('', { - "class": "autoTextNormalRow", - "id": rowName + this.numResultRows++ - }).append(jQuery('
', { - 'data-id':currentObject[0], - 'class': 'm2o_coplition' - }).append(jQuery('', { - 'style':'text-transform:none; white-space: nowrap', - 'title': currentObject[1], - 'text': currentObject[1] - }))).appendTo($resultsTable); - }); - - if (!result.length) { - jQuery('
', {'id':'create','class': 'm2o_coplition' - }).append(jQuery('', { - 'style': 'text-transform:none; white-space: nowrap', - 'title': 'Create', - 'text': 'Create...'}))).appendTo($resultsTable); - } - - if (data.length) { - jQuery('
', {'id': 'more','class': 'm2o_coplition' - }).append(jQuery('', { - 'style': 'text-transform:none; white-space: nowrap', - 'title': 'More', - 'text': 'More...'}))).appendTo($resultsTable); - } - // Swap out the old results with the newly created table - var $resultsHolder = jQuery("#autoCompleteResults_" + self.name); - if($resultsTable.children().length) { - $resultsHolder.empty().append($fancyTable); - this.updateSelectedResult(); - $resultsHolder.show(); - } - return true; - }, - - on_keypress: function(evt) { - if (evt.which == 9 || evt.ctrlKey) { - return true; - } - }, - - on_keyup: function(evt) { - if(this.specialKeyPressed || (this.element.val() == this.lastSearch)) return false; - - if (evt.which == 40) { - if (!this.element.val().length) { - if (this.delayedRequest) { - clearInterval(this.delayedRequest); - this.clearResults(); - return false; - } - } - if (this.delayedRequest) - clearInterval(this.delayedRequest); - - this.delayedRequest = setTimeout(function(thisObj){ - thisObj.callSearchRequest() - }, this.completeDelay, this); - } - return true; - - }, - - on_keydown : function(evt) { - - var key = evt.which; - this.lastKey = evt.which; - this.specialKeyPressed = false; - if(this.numResultRows > 0) { - switch (evt.which) { - // Enter Key - // Single Click - case 13: - case 1: - var $selectedRow = jQuery("#autoComplete" + this.name + "_" + this.selectedResultRow); - this.dataset.ids = this.result_ids; - this.dataset.domain = []; - this.dataset.count = this.dataset.ids.length; - if ($selectedRow.find('td').attr('id') == 'more') { + if (ui.item.id == 'create') { var element_id = _.uniqueId("act_window_dialog"); var dialog = jQuery('
', - {'id': element_id - }).dialog({title: 'test', - modal: true, - minWidth: 800, - buttons: { - Cancel: function() { - $(this).dialog("close"); - } - } - }); - var event_list = new openerp.base.ListView(this.view_manager, this.session, element_id, this.dataset, false); - event_list.start(); - event_list.do_reload(); + {'id': element_id + }).dialog({ + modal: true, + minWidth: 800 + }); + var event_form = new openerp.base.FormView(self.view_manager, self.session, element_id, self.dataset, false); + event_form.start(); + self.element.val('') + return; } - - if ($selectedRow.find('td').attr('id') == 'create') { - this.PseudoDialogue(); - break; - } - - this.setCompletionText($selectedRow, true); - this.clearResults(); - break; - - // Escape Key - case 27: - this.clearResults(); - break; - - // Up Key - case 38: - if(this.selectedResultRow > 0) this.selectedResultRow--; - this.updateSelectedResult(); - break; - - // Down Key - case 40: - if(this.selectedResultRow < this.numResultRows - (this.selectedResultRow == null ? 0 : 1)) { - if (this.selectedResultRow == null) - this.selectedResultRow = 0; - else - this.selectedResultRow++; - } - this.selectedResult = true; - this.updateSelectedResult(); - break; - - default: - break; - } - if(evt.which == 13 || evt.which == 27 || evt.which == 38 || evt.which == 40)// - this.specialKeyPressed = true; - - } - - if((evt.which == 8 || evt.which == 46)) { - var value = this.element.val(); - if (value.indexOf('[') > 0) { - this.element.val(this.lastSearch) - evt.stopPropagation(); - evt.preventDefault(); - } - else if (value.length == 1) { - this.clearResults(); - } - } - return !this.specialKeyPressed; - }, - - updateSelectedResult: function() { - // Set classes to show currently selected row - for(var i = 0; i < this.numResultRows; i++) { - var rowName = '#autoComplete' + this.name + '_' - var $selectedRow = jQuery('#autoComplete' + this.name + '_' + i) - if(this.selectedResultRow == i) { - $selectedRow.addClass("autoTextSelectedRow"); - $selectedRow.removeClass("autoTextNormalRow") ; - if (this.selectedResult) { - this.setCompletionText($selectedRow); + self.element.attr('m2o_id', ui.item.id); } - } else { - $selectedRow.removeClass("autoTextSelectedRow"); - $selectedRow.addClass("autoTextNormalRow") ; - } + }); } - }, - - setCompletionText: function ($selectedRow, flag) { - var $cell = $selectedRow.find('td'); - var autoCompleteText = $cell.find('span').text(); - if ($cell.attr('id') == 'more') { - this.element.val(''); - return; - } - - if ($cell.attr('id') == 'create' || !autoCompleteText) - return - - autoCompleteText = flag ? autoCompleteText : this.lastSearch + '[' + autoCompleteText.substring(this.lastSearch.length) + ']' - - this.element.val(autoCompleteText); - this.element.attr('m2o_id', $cell.attr('data-id')); - this.lastTextResult = autoCompleteText; - }, - - clearResults: function() { - // Hide all the results - jQuery("#autoCompleteResults_" + this.name).hide(); - // Clear out our result tracking - this.selectedResultRow = 0; - this.numResultRows = 0; - this.lastSearch = null; - }, - - PseudoDialogue: function(){ - var parent_element = jQuery("#autoCompleteResults_" + this.name); - var $DiaTable = jQuery('', { - "name": "create_m2o" + this.name, - "id": "create_m2o" + this.name}); - var $tbl = jQuery('').appendTo($DiaTable); - var onClick = jQuery.proxy(this, 'getOnclick'); - - jQuery('').append( - jQuery('', {'class':'create_m2o'}).append( - jQuery('
').append( - jQuery('', { - 'style':'text-transform:none; white-space: nowrap', - 'title': 'Name', - 'text': 'Name :'}).after( - jQuery('', { - 'id': 'm2o_' + this.name, - 'type': 'text', - 'val':this.element.val()})))).after( - jQuery('
').append( - jQuery('',{ - 'id':'create', - 'text':'Create', - 'href':'javascript: void(0)', - 'click': onClick, - 'class':'a_m2o'}, 'EDIT')).append( - jQuery('',{ - 'id':'edit', - 'href':'javascript: void(0)', - 'click':onClick, - 'text':'Edit', - 'class':'a_m2o'})).append( - jQuery('',{ - 'id':'close', - 'text':'Close', - 'href':'javascript: void(0)', - 'click':onClick, - 'class':'a_m2o'})))).appendTo($tbl); - - parent_element.empty().append($DiaTable); - parent_element.show(); - }, - - getOnclick : function(evt) { - if(evt.currentTarget.id == 'create') { - var self = this - this.dataset.create({'name': this.element.val()}, - function(r){}, function(r){self.on_edit(r)}); - } - - if(evt.currentTarget.id == 'edit') { - this.on_edit(); - } - - jQuery("#autoCompleteResults_" + this.name).empty(); - this.clearResults(); - }, - - on_edit: function(r) { - var element_id = _.uniqueId("act_window_dialog"); - var dialog = jQuery('
', - {'id': element_id - }).dialog({title: 'test', - modal: true, - minWidth: 800, - buttons: { - Cancel: function() { - $(this).dialog("close"); - } - } - }); - var event_form = new openerp.base.FormView(this.view_manager, this.session, element_id, this.dataset, false); - event_form.start(); - }, - }) -} + }); +} \ No newline at end of file From 7141cf73276ad6ff15701189d1057dd8a296453d Mon Sep 17 00:00:00 2001 From: "sma (Tiny)" Date: Thu, 12 May 2011 15:09:08 +0530 Subject: [PATCH 050/148] [REM] Remove unnecessary css. bzr revid: sma@tinyerp.com-20110512093908-63477h8xmlhj4t7b --- addons/base/static/src/css/base.css | 78 ----------------------------- 1 file changed, 78 deletions(-) diff --git a/addons/base/static/src/css/base.css b/addons/base/static/src/css/base.css index 64e2e78fb8b..92a0c415e1e 100644 --- a/addons/base/static/src/css/base.css +++ b/addons/base/static/src/css/base.css @@ -775,88 +775,10 @@ body.openerp { } /* Many2one Autosearch */ - .openerp .combo_img { position: absolute; margin-left: -19px; margin-top: 3px; } - -.openerp .autoTextResults { - position: absolute; - z-index: 1000; - background-color: #fff; - border: 1px solid #333; - display: none; - padding: 0 2px 0 2px; - min-width: 132px; - border-radius: 3px; - -moz-border-radius: 3px; - -webkit-border-radius: 3px; - color: #1F1F1F; - overflow: auto; -} - -.openerp table.autoTextTable { - border: none; - font-family: arial, sans-serif; - font-size: 13px; - font-style: normal; - font-variant: normal; - font-weight: normal; - width: 100%; -} - -.openerp table.autoTextTable tr.autoTextNormalRow td { -} - -.openerp table.autoTextTable tr.autoTextSelectedRow td { - background-color: DarkGray; - color: #1F1F1F; - cursor: pointer; -} - -.openerp table.autoTextTable ul{ - list-style-image:none; - list-style-type:none; -} - -.openerp table.autoTextTable td a.autoTextHighlight { - font-weight: bold; - text-decoration: none; - color: #FFF; -} - -.openerp table.autoTextTable td.autoTextHidden { - display: none; -} - -.create_m2o { - background-color: #4C4C4C; - height: 1.5em; - left: 0; - overflow: hidden; - padding-bottom: 0.05em; - padding-top: 0.05em; - top: 0; -} - -.a_m2o { - background-color: white; - border: 0.05em solid gray; - cursor: pointer; - font-family: arial; - font-size: 0.8em; - font-style: italic; - font-weight: bold; - margin: 10px; - margin-left: 10px; - margin-right: 10px; - padding-left: 10px; - padding-right: 10px; - padding-top: 0.1em; - text-decoration: none; - width: 4em; -} /* ------------- End autocomplete ------- */ From 1e4bbe7bd6a18df651a90b14a554c5aebbc80d29 Mon Sep 17 00:00:00 2001 From: "sma (Tiny)" Date: Thu, 12 May 2011 19:15:24 +0530 Subject: [PATCH 051/148] [IMP] Improve button click. bzr revid: sma@tinyerp.com-20110512134524-d9wkls6cv6iqykzs --- addons/base/static/src/js/m2o.js | 62 ++++++++++++++++++++++++-------- 1 file changed, 48 insertions(+), 14 deletions(-) diff --git a/addons/base/static/src/js/m2o.js b/addons/base/static/src/js/m2o.js index 23bdeb0e5e3..02fe536db89 100644 --- a/addons/base/static/src/js/m2o.js +++ b/addons/base/static/src/js/m2o.js @@ -14,7 +14,7 @@ openerp.base.m2o = function(openerp){ this.result_ids = [] var self = this - this.element.autocomplete({ + var $input = this.element.autocomplete({ source: function(request, response){ var search_val = request.term; if (search_val in cache) { @@ -50,32 +50,66 @@ openerp.base.m2o = function(openerp){ }, select: function(event, ui){ + if (ui.item.id == 'more') { self.dataset.ids = self.result_ids; self.dataset.count = self.dataset.ids.length; self.dataset.domain = [] + self.element.val('') var pop = new openerp.base.form.Many2XSelectPopup(null, self.session); pop.select_element(self.relation, self.dataset); - self.element.val('') return; } if (ui.item.id == 'create') { - var element_id = _.uniqueId("act_window_dialog"); - var dialog = jQuery('
', - {'id': element_id - }).dialog({ - modal: true, - minWidth: 800 - }); - var event_form = new openerp.base.FormView(self.view_manager, self.session, element_id, self.dataset, false); - event_form.start(); - self.element.val('') - return; + + var val = self.element.val() + self.dataset.create({'name': self.element.val()}, + function(r){}, function(r){ + var element_id = _.uniqueId("act_window_dialog"); + var dialog = jQuery('
', + {'id': element_id + }).dialog({ + modal: true, + minWidth: 800 + }); + self.element.val('') + var event_form = new openerp.base.FormView(self.view_manager, self.session, element_id, self.dataset, false); + event_form.start(); + return true; + }); + console.log(id_2.result,'56576777878787878',val, self.element.data( "autocomplete" ).term) + console.log(this) + $( this ).val( "" ); + self.element.val(self.element.data( "autocomplete" ).term); } self.element.attr('m2o_id', ui.item.id); - } + }, + minLength: 0 }); + + $("
 
") + .attr("tabIndex", -1) + .attr("title", "Show All Items") + .insertAfter($input) + .button({ + icons: { + primary: "ui-icon-triangle-1-s" + }, + text: false + }) + .removeClass("ui-corner-all") + .addClass("ui-corner-right ui-button-icon") + .click(function() { + // close if already visible + if ($input.autocomplete("widget").is(":visible")) { + $input.autocomplete( "close" ); + return; + } + $(this).blur(); + $input.autocomplete("search", "" ); + $input.focus(); + }); } }); } \ No newline at end of file From 14eaf4afb9a0226738518cb3f3031698aef18252 Mon Sep 17 00:00:00 2001 From: "sma (Tiny)" Date: Thu, 12 May 2011 19:16:26 +0530 Subject: [PATCH 052/148] [IMP] Remove static image. bzr revid: sma@tinyerp.com-20110512134626-bb3t3c1rhz020xno --- addons/base/static/src/xml/base.xml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/addons/base/static/src/xml/base.xml b/addons/base/static/src/xml/base.xml index 9e1646ace08..dd0b071a0ef 100644 --- a/addons/base/static/src/xml/base.xml +++ b/addons/base/static/src/xml/base.xml @@ -347,8 +347,7 @@ t-att-class="'field_' + widget.type" t-att-type="widget.type" style="width: 100%;"/> - -
+
From d352848b48d0342b60de0e69e5b3a219590e1745 Mon Sep 17 00:00:00 2001 From: "sma (Tiny)" Date: Thu, 12 May 2011 19:17:05 +0530 Subject: [PATCH 053/148] [IMP] Add combo image. bzr revid: sma@tinyerp.com-20110512134705-aldge5yx7bi9i8vz --- addons/base/static/src/css/base.css | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/addons/base/static/src/css/base.css b/addons/base/static/src/css/base.css index 92a0c415e1e..44e20d00d68 100644 --- a/addons/base/static/src/css/base.css +++ b/addons/base/static/src/css/base.css @@ -775,10 +775,11 @@ body.openerp { } /* Many2one Autosearch */ -.openerp .combo_img { - position: absolute; - margin-left: -19px; - margin-top: 3px; +.openerp .ui_combo { + height: 20px; + margin-right: 1px; + top: 4px; + width: 22px; } /* ------------- End autocomplete ------- */ From 50194d321eaed52d993b6e7e42fddfde6bdd3905 Mon Sep 17 00:00:00 2001 From: Fabien Meghazi Date: Thu, 12 May 2011 16:32:22 +0200 Subject: [PATCH 054/148] [ADD] Added float_time form widget bzr revid: fme@openerp.com-20110512143222-2gc42sludahd7c6i --- addons/base/static/src/js/form.js | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/addons/base/static/src/js/form.js b/addons/base/static/src/js/form.js index b4e9e0cbc33..589ebaf692a 100644 --- a/addons/base/static/src/js/form.js +++ b/addons/base/static/src/js/form.js @@ -150,7 +150,7 @@ openerp.base.FormView = openerp.base.View.extend( /** @lends openerp.base.FormV args.push(value == null ? false : value); } else { args.push(false); - this.log("warning : on_change can't find field " + field, onchange); + self.log("warning : on_change can't find field " + field, onchange); } }); var ajax = { @@ -718,6 +718,28 @@ openerp.base.form.FieldDate = openerp.base.form.FieldDatetime.extend({ format: openerp.base.parse_date }); +openerp.base.form.FieldFloatTime = openerp.base.form.FieldChar.extend({ + init: function(view, node) { + this._super(view, node); + this.validation_regex = /^\d+:\d+$/; + }, + set_value: function(value) { + value = value || 0; + this._super.apply(this, [value]); + var show_value = _.sprintf("%02d:%02d", Math.floor(value), Math.round((value % 1) * 60)); + this.$element.find('input').val(show_value); + }, + validate: function() { + if (typeof(this.value) == "string") { + this._super.apply(this, arguments); + if (!this.invalid) { + var time = this.value.split(':'); + this.value = parseInt(time[0], 10) + parseInt(time[1], 10) / 60; + } + } + } +}); + openerp.base.form.FieldText = openerp.base.form.Field.extend({ init: function(view, node) { this._super(view, node); @@ -1005,7 +1027,7 @@ openerp.base.form.widgets = new openerp.base.Registry({ 'float' : 'openerp.base.form.FieldFloat', 'integer': 'openerp.base.form.FieldFloat', 'progressbar': 'openerp.base.form.FieldProgressBar', - 'float_time': 'openerp.base.form.FieldFloat' + 'float_time': 'openerp.base.form.FieldFloatTime' }); }; From 6b09377f4f83fe9fd2eebcf99f44f53336a52bca Mon Sep 17 00:00:00 2001 From: Fabien Meghazi Date: Thu, 12 May 2011 16:38:35 +0200 Subject: [PATCH 055/148] [FIX] fixed dates.js bzr revid: fme@openerp.com-20110512143835-16l5c3ajj36l4nrn --- addons/base/static/src/js/dates.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/addons/base/static/src/js/dates.js b/addons/base/static/src/js/dates.js index a243130aab2..8daea39773f 100644 --- a/addons/base/static/src/js/dates.js +++ b/addons/base/static/src/js/dates.js @@ -96,7 +96,7 @@ var fts = function(str, size) { * @returns {String} A string representing a datetime. */ openerp.base.format_datetime = function(obj) { - if(! str) { + if (!obj) { return false; } return fts(obj.getUTCFullYear(),4) + "-" + fts(obj.getUTCMonth() + 1,2) + "-" @@ -112,7 +112,7 @@ openerp.base.format_datetime = function(obj) { * @returns {String} A string representing a date. */ openerp.base.format_date = function(obj) { - if(! str) { + if (!obj) { return false; } return fts(obj.getFullYear(),4) + "-" + fts(obj.getMonth() + 1,2) + "-" @@ -127,11 +127,11 @@ openerp.base.format_date = function(obj) { * @returns {String} A string representing a time. */ openerp.base.format_time = function(obj) { - if(! str) { + if (!obj) { return false; } return fts(obj.getHours(),2) + ":" + fts(obj.getMinutes(),2) + ":" + fts(obj.getSeconds(),2); }; -}; \ No newline at end of file +}; From 270566ad5361ac07a547afe6577f0234be133047 Mon Sep 17 00:00:00 2001 From: Fabien Meghazi Date: Thu, 12 May 2011 16:43:55 +0200 Subject: [PATCH 056/148] [FIX] Fixed form dates parsing & formatting bzr revid: fme@openerp.com-20110512144355-1ollzrcf722lwwh7 --- addons/base/static/src/js/form.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/addons/base/static/src/js/form.js b/addons/base/static/src/js/form.js index 589ebaf692a..5a9580ba0d6 100644 --- a/addons/base/static/src/js/form.js +++ b/addons/base/static/src/js/form.js @@ -697,17 +697,21 @@ openerp.base.form.FieldDatetime = openerp.base.form.Field.extend({ if (value == null || value == false) { this.$element.find('input').val(''); } else { - this.value = this.format(value); + this.value = this.parse(value); this.$element.find('input')[this.jqueryui_object]('setDate', this.value); } }, set_value_from_ui: function() { this.value = this.$element.find('input')[this.jqueryui_object]('getDate') || false; + if (this.value) { + this.value = this.format(this.value); + } }, validate: function() { this.invalid = this.required && this.value === false; }, - format: openerp.base.parse_datetime + parse: openerp.base.parse_datetime, + format: openerp.base.format_datetime }); openerp.base.form.FieldDate = openerp.base.form.FieldDatetime.extend({ @@ -715,7 +719,8 @@ openerp.base.form.FieldDate = openerp.base.form.FieldDatetime.extend({ this._super(view, node); this.jqueryui_object = 'datepicker'; }, - format: openerp.base.parse_date + parse: openerp.base.parse_date, + format: openerp.base.format_date }); openerp.base.form.FieldFloatTime = openerp.base.form.FieldChar.extend({ From 55e1c6e7f46b5a3d50f360f5515db311da5ca058 Mon Sep 17 00:00:00 2001 From: Fabien Meghazi Date: Thu, 12 May 2011 16:48:35 +0200 Subject: [PATCH 057/148] [FIX] Fixed some litteral arguments in on_changes bzr revid: fme@openerp.com-20110512144835-ygbu7nfxjz7hp160 --- addons/base/static/src/js/form.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/addons/base/static/src/js/form.js b/addons/base/static/src/js/form.js index 5a9580ba0d6..e4c2b2d465e 100644 --- a/addons/base/static/src/js/form.js +++ b/addons/base/static/src/js/form.js @@ -143,9 +143,16 @@ openerp.base.FormView = openerp.base.View.extend( /** @lends openerp.base.FormV var call = onchange.match(/^\s?(.*?)\((.*?)\)\s?$/); if (call) { var method = call[1], args = []; + var argument_replacement = { + 'False' : false, + 'True' : true, + 'None' : null + } _.each(call[2].split(','), function(a) { var field = _.trim(a); - if (self.fields[field]) { + if (field in argument_replacement) { + args.push(argument_replacement[field]); + } else if (self.fields[field]) { var value = self.fields[field].value; args.push(value == null ? false : value); } else { From d9fa808fcf52220b62fd1b9f6d5ec9277898a4b4 Mon Sep 17 00:00:00 2001 From: Fabien Meghazi Date: Thu, 12 May 2011 17:22:48 +0200 Subject: [PATCH 058/148] [ADD] Added non editable image field widget bzr revid: fme@openerp.com-20110512152248-53z3r716040mvb9t --- addons/base/static/src/js/form.js | 14 +++++++++++++- addons/base/static/src/xml/base.xml | 9 +++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/addons/base/static/src/js/form.js b/addons/base/static/src/js/form.js index e4c2b2d465e..20c2012c8e3 100644 --- a/addons/base/static/src/js/form.js +++ b/addons/base/static/src/js/form.js @@ -1013,6 +1013,17 @@ openerp.base.form.FieldReference = openerp.base.form.Field.extend({ } }); +openerp.base.form.FieldImage = openerp.base.form.Field.extend({ + init: function(view, node) { + this._super(view, node); + this.template = "FieldImage"; + }, + set_value: function(value) { + this._super.apply(this, arguments); + this.$element.find('img').show().attr('src', 'data:image/png;base64,' + this.value); + } +}); + /** * Registry of form widgets, called by :js:`openerp.base.FormView` */ @@ -1039,7 +1050,8 @@ openerp.base.form.widgets = new openerp.base.Registry({ 'float' : 'openerp.base.form.FieldFloat', 'integer': 'openerp.base.form.FieldFloat', 'progressbar': 'openerp.base.form.FieldProgressBar', - 'float_time': 'openerp.base.form.FieldFloatTime' + 'float_time': 'openerp.base.form.FieldFloatTime', + 'image': 'openerp.base.form.FieldImage' }); }; diff --git a/addons/base/static/src/xml/base.xml b/addons/base/static/src/xml/base.xml index 6a597396f56..713dee55036 100644 --- a/addons/base/static/src/xml/base.xml +++ b/addons/base/static/src/xml/base.xml @@ -360,6 +360,15 @@
+ + +