From cd4a62996a72ab9997b912c12deda6a5dd0a5226 Mon Sep 17 00:00:00 2001 From: Thibault Date: Thu, 23 Aug 2012 17:32:03 +0200 Subject: [PATCH 1/8] [REF] mail_alias: moved _auto_init code from res_users and hr_recruitment to mail_alias, using a kewl call to migrate_to_alias. bzr revid: odo@openerp.com-20120823153203-8tm3lbqah6vwd7co --- addons/hr_recruitment/hr_recruitment.py | 44 +++----------------- addons/mail/mail_alias.py | 55 +++++++++++++++++++++++++ addons/mail/res_users.py | 36 +--------------- 3 files changed, 63 insertions(+), 72 deletions(-) diff --git a/addons/hr_recruitment/hr_recruitment.py b/addons/hr_recruitment/hr_recruitment.py index 81a7ae6129e..6b4839b7b2b 100644 --- a/addons/hr_recruitment/hr_recruitment.py +++ b/addons/hr_recruitment/hr_recruitment.py @@ -19,18 +19,13 @@ # ############################################################################## -import logging import time -from datetime import datetime - import tools -from osv import fields, osv -from openerp.modules.registry import RegistryManager -from openerp import SUPERUSER_ID -from base_status.base_stage import base_stage -from tools.translate import _ -_logger = logging.getLogger(__name__) +from base_status.base_stage import base_stage +from datetime import datetime +from osv import fields, osv +from tools.translate import _ AVAILABLE_STATES = [ ('draft', 'New'), @@ -522,35 +517,8 @@ class hr_job(osv.osv): def _auto_init(self, cr, context=None): """Installation hook to create aliases for all jobs and avoid constraint errors.""" - - # disable the unique alias_id not null constraint, to avoid spurious warning during - # super.auto_init. We'll reinstall it afterwards. - self._columns['alias_id'].required = False - - super(hr_job,self)._auto_init(cr, context=context) - - registry = RegistryManager.get(cr.dbname) - mail_alias = registry.get('mail.alias') - hr_jobs = registry.get('hr.job') - jobs_no_alias = hr_jobs.search(cr, SUPERUSER_ID, [('alias_id', '=', False)]) - # Use read() not browse(), to avoid prefetching uninitialized inherited fields - for job_data in hr_jobs.read(cr, SUPERUSER_ID, jobs_no_alias, ['name']): - alias_id = mail_alias.create_unique_alias(cr, SUPERUSER_ID, {'alias_name': 'job+'+job_data['name'], - 'alias_defaults': {'job_id': job_data['id']}}, - model_name='hr.applicant') - hr_jobs.write(cr, SUPERUSER_ID, job_data['id'], {'alias_id': alias_id}) - _logger.info('Mail alias created for hr.job %s (uid %s)', job_data['name'], job_data['id']) - - # Finally attempt to reinstate the missing constraint - try: - cr.execute('ALTER TABLE hr_job ALTER COLUMN alias_id SET NOT NULL') - except Exception: - _logger.warning("Table '%s': unable to set a NOT NULL constraint on column '%s' !\n"\ - "If you want to have it, you should update the records and execute manually:\n"\ - "ALTER TABLE %s ALTER COLUMN %s SET NOT NULL", - self._table, 'alias_id', self._table, 'alias_id') - - self._columns['alias_id'].required = True + self.pool.get('mail.alias').migrate_to_alias(cr, self._name, self._table, super(hr_job,self)._auto_init, + self._columns['alias_id'], 'name', alias_prefix='job+', alias_defaults={'job_id': 'id'}, context=context) def create(self, cr, uid, vals, context=None): mail_alias = self.pool.get('mail.alias') diff --git a/addons/mail/mail_alias.py b/addons/mail/mail_alias.py index 82b20f39480..4ed9c5dc2ab 100644 --- a/addons/mail/mail_alias.py +++ b/addons/mail/mail_alias.py @@ -19,11 +19,16 @@ # ############################################################################## +import logging import re import unicodedata from openerp.osv import fields, osv from openerp.tools import ustr +from openerp.modules.registry import RegistryManager +from openerp import SUPERUSER_ID + +_logger = logging.getLogger(__name__) # Inspired by http://stackoverflow.com/questions/517923 def remove_accents(input_str): @@ -129,6 +134,56 @@ class mail_alias(osv.Model): sequence = (sequence + 1) if sequence else 2 return new_name + def migrate_to_alias(self, cr, child_model_name, child_table_name, child_model_auto_init_fct, + alias_id_column, alias_column, alias_prefix = '', alias_force_thread_id = '', alias_defaults = {}, context=None): + """ Installation hook to create aliases for all users and avoid constraint errors. + + :param child_model_name: model name of the child class (i.e. res.users) + :param child_table_name: table name of the child class (i.e. res_users) + :param child_model_auto_init_fct: pointer to the _auto_init function + (i.e. super(res_users,self)._auto_init(cr, context=context)) + :param alias_id_column: alias_id column (i.e. self._columns['alias_id']) + :param alias_column: column used for the unique name (i.e. 'login') + :param alias_prefix: prefix for the unique name (i.e. 'jobs' + ...) + :param alias_force_thread_id': name of the column for force_thread_id; + if empty string, not taken into account + :param alias_defaults: dict, keys = mail.alias columns, values = child + model column name used for default values (i.e. {'job_id': 'id'}) + """ + + # disable the unique alias_id not null constraint, to avoid spurious warning during + # super.auto_init. We'll reinstall it afterwards. + alias_id_column.required = False + + # call _auto_init + child_model_auto_init_fct(cr, context=context) + + registry = RegistryManager.get(cr.dbname) + mail_alias = registry.get('mail.alias') + child_class_model = registry.get(child_model_name) + no_alias_ids = child_class_model.search(cr, SUPERUSER_ID, [('alias_id', '=', False)]) + # Use read() not browse(), to avoid prefetching uninitialized inherited fields + for obj_data in child_class_model.read(cr, SUPERUSER_ID, no_alias_ids, [alias_column]): + alias_vals = {'alias_name': '%s%s' % (alias_prefix, obj_data[alias_column]) } + if alias_force_thread_id: + alias_vals['alias_force_thread_id'] = obj_data[alias_force_thread_id] + alias_vals['alias_defaults'] = dict( (k, obj_data[v]) for k, v in alias_defaults.iteritems()) + alias_id = mail_alias.create_unique_alias(cr, SUPERUSER_ID, alias_vals, model_name=child_model_name) + child_class_model.write(cr, SUPERUSER_ID, obj_data['id'], {'alias_id': alias_id}) + _logger.info('Mail alias created for %s %s (uid %s)', child_model_name, obj_data[alias_column], obj_data['id']) + + # Finally attempt to reinstate the missing constraint + try: + cr.execute('ALTER TABLE %s ALTER COLUMN alias_id SET NOT NULL' % (child_table_name)) + except Exception: + _logger.warning("Table '%s': unable to set a NOT NULL constraint on column '%s' !\n"\ + "If you want to have it, you should update the records and execute manually:\n"\ + "ALTER TABLE %s ALTER COLUMN %s SET NOT NULL", + child_table_name, 'alias_id', child_table_name, 'alias_id') + + # set back the unique alias_id constraint + alias_id_column.required = True + def create_unique_alias(self, cr, uid, vals, model_name=None, context=None): """Creates an email.alias record according to the values provided in ``vals``, with 2 alterations: the ``alias_name`` value may be suffixed in order to diff --git a/addons/mail/res_users.py b/addons/mail/res_users.py index f985ac4f88d..829ba739dd4 100644 --- a/addons/mail/res_users.py +++ b/addons/mail/res_users.py @@ -19,15 +19,10 @@ # ############################################################################## -import logging - from osv import osv, fields -from openerp.modules.registry import RegistryManager from openerp import SUPERUSER_ID from tools.translate import _ -_logger = logging.getLogger(__name__) - class res_users(osv.Model): """ Update of res.users class - add a preference about sending emails about notifications @@ -69,35 +64,8 @@ class res_users(osv.Model): def _auto_init(self, cr, context=None): """Installation hook to create aliases for all users and avoid constraint errors.""" - - # disable the unique alias_id not null constraint, to avoid spurious warning during - # super.auto_init. We'll reinstall it afterwards. - self._columns['alias_id'].required = False - - super(res_users,self)._auto_init(cr, context=context) - - registry = RegistryManager.get(cr.dbname) - mail_alias = registry.get('mail.alias') - res_users_model = registry.get('res.users') - users_no_alias = res_users_model.search(cr, SUPERUSER_ID, [('alias_id', '=', False)]) - # Use read() not browse(), to avoid prefetching uninitialized inherited fields - for user_data in res_users_model.read(cr, SUPERUSER_ID, users_no_alias, ['login']): - alias_id = mail_alias.create_unique_alias(cr, SUPERUSER_ID, {'alias_name': user_data['login'], - 'alias_force_id': user_data['id']}, - model_name=self._name) - res_users_model.write(cr, SUPERUSER_ID, user_data['id'], {'alias_id': alias_id}) - _logger.info('Mail alias created for user %s (uid %s)', user_data['login'], user_data['id']) - - # Finally attempt to reinstate the missing constraint - try: - cr.execute('ALTER TABLE res_users ALTER COLUMN alias_id SET NOT NULL') - except Exception: - _logger.warning("Table '%s': unable to set a NOT NULL constraint on column '%s' !\n"\ - "If you want to have it, you should update the records and execute manually:\n"\ - "ALTER TABLE %s ALTER COLUMN %s SET NOT NULL", - self._table, 'alias_id', self._table, 'alias_id') - - self._columns['alias_id'].required = True + self.pool.get('mail.alias').migrate_to_alias(cr, self._name, self._table, super(res_users,self)._auto_init, + self._columns['alias_id'], 'login', alias_force_thread_id='id', context=context) def create(self, cr, uid, data, context=None): # create default alias same as the login From 7423196143231f210f59aecef3311f83d84d6c3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Fri, 24 Aug 2012 16:39:44 +0200 Subject: [PATCH 2/8] [REVIEW] Updated some variable names to try to be more explicit. bzr revid: tde@openerp.com-20120824143944-cjm0zwfaldbfztq1 --- addons/mail/mail_alias.py | 16 ++++++++-------- addons/mail/res_users.py | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/addons/mail/mail_alias.py b/addons/mail/mail_alias.py index 4ed9c5dc2ab..70280e64a5d 100644 --- a/addons/mail/mail_alias.py +++ b/addons/mail/mail_alias.py @@ -135,7 +135,7 @@ class mail_alias(osv.Model): return new_name def migrate_to_alias(self, cr, child_model_name, child_table_name, child_model_auto_init_fct, - alias_id_column, alias_column, alias_prefix = '', alias_force_thread_id = '', alias_defaults = {}, context=None): + alias_id_column, alias_key, alias_prefix = '', alias_force_key = '', alias_defaults = {}, context=None): """ Installation hook to create aliases for all users and avoid constraint errors. :param child_model_name: model name of the child class (i.e. res.users) @@ -143,9 +143,9 @@ class mail_alias(osv.Model): :param child_model_auto_init_fct: pointer to the _auto_init function (i.e. super(res_users,self)._auto_init(cr, context=context)) :param alias_id_column: alias_id column (i.e. self._columns['alias_id']) - :param alias_column: column used for the unique name (i.e. 'login') + :param alias_key: name of the column used for the unique name (i.e. 'login') :param alias_prefix: prefix for the unique name (i.e. 'jobs' + ...) - :param alias_force_thread_id': name of the column for force_thread_id; + :param alias_force_key': name of the column for force_thread_id; if empty string, not taken into account :param alias_defaults: dict, keys = mail.alias columns, values = child model column name used for default values (i.e. {'job_id': 'id'}) @@ -163,14 +163,14 @@ class mail_alias(osv.Model): child_class_model = registry.get(child_model_name) no_alias_ids = child_class_model.search(cr, SUPERUSER_ID, [('alias_id', '=', False)]) # Use read() not browse(), to avoid prefetching uninitialized inherited fields - for obj_data in child_class_model.read(cr, SUPERUSER_ID, no_alias_ids, [alias_column]): - alias_vals = {'alias_name': '%s%s' % (alias_prefix, obj_data[alias_column]) } - if alias_force_thread_id: - alias_vals['alias_force_thread_id'] = obj_data[alias_force_thread_id] + for obj_data in child_class_model.read(cr, SUPERUSER_ID, no_alias_ids, [alias_key]): + alias_vals = {'alias_name': '%s%s' % (alias_prefix, obj_data[alias_key]) } + if alias_force_key: + alias_vals['alias_force_thread_id'] = obj_data[alias_force_key] alias_vals['alias_defaults'] = dict( (k, obj_data[v]) for k, v in alias_defaults.iteritems()) alias_id = mail_alias.create_unique_alias(cr, SUPERUSER_ID, alias_vals, model_name=child_model_name) child_class_model.write(cr, SUPERUSER_ID, obj_data['id'], {'alias_id': alias_id}) - _logger.info('Mail alias created for %s %s (uid %s)', child_model_name, obj_data[alias_column], obj_data['id']) + _logger.info('Mail alias created for %s %s (uid %s)', child_model_name, obj_data[alias_key], obj_data['id']) # Finally attempt to reinstate the missing constraint try: diff --git a/addons/mail/res_users.py b/addons/mail/res_users.py index 829ba739dd4..d9c77cb83f4 100644 --- a/addons/mail/res_users.py +++ b/addons/mail/res_users.py @@ -65,7 +65,7 @@ class res_users(osv.Model): def _auto_init(self, cr, context=None): """Installation hook to create aliases for all users and avoid constraint errors.""" self.pool.get('mail.alias').migrate_to_alias(cr, self._name, self._table, super(res_users,self)._auto_init, - self._columns['alias_id'], 'login', alias_force_thread_id='id', context=context) + self._columns['alias_id'], 'login', alias_force_key='id', context=context) def create(self, cr, uid, data, context=None): # create default alias same as the login From 49b3c7b7535e181dd0d447096c0469b6d526dfac Mon Sep 17 00:00:00 2001 From: niv-openerp Date: Fri, 24 Aug 2012 18:54:49 +0200 Subject: [PATCH 3/8] [IMP] made the loading messages translatable bzr revid: nicolas.vanhoren@openerp.com-20120824165449-mfb4ftxnq3vd0p84 --- addons/web/static/src/js/coresetup.js | 156 +++++++++++++------------- 1 file changed, 80 insertions(+), 76 deletions(-) diff --git a/addons/web/static/src/js/coresetup.js b/addons/web/static/src/js/coresetup.js index a34a7dadd30..af6442bd747 100644 --- a/addons/web/static/src/js/coresetup.js +++ b/addons/web/static/src/js/coresetup.js @@ -520,82 +520,6 @@ $.async_when = function() { return old_async_when.apply(this, arguments); }; -/** Setup blockui */ -if ($.blockUI) { - $.blockUI.defaults.baseZ = 1100; - $.blockUI.defaults.message = '
'; - $.blockUI.defaults.css.border = '0'; - $.blockUI.defaults.css["background-color"] = ''; -} - -var messages_by_seconds = [ - [0, "Loading..."], - [30, "Still Loading..."], - [60, "Still Loading...
Please be patient."], - [120, "Hey, guess what?
It's still loading."], - [300, "You may not believe it,
but the application is actually loading..."], -]; - -instance.web.Throbber = instance.web.Widget.extend({ - template: "Throbber", - start: function() { - var opts = { - lines: 13, // The number of lines to draw - length: 7, // The length of each line - width: 4, // The line thickness - radius: 10, // The radius of the inner circle - rotate: 0, // The rotation offset - color: '#FFF', // #rgb or #rrggbb - speed: 1, // Rounds per second - trail: 60, // Afterglow percentage - shadow: false, // Whether to render a shadow - hwaccel: false, // Whether to use hardware acceleration - className: 'spinner', // The CSS class to assign to the spinner - zIndex: 2e9, // The z-index (defaults to 2000000000) - top: 'auto', // Top position relative to parent in px - left: 'auto' // Left position relative to parent in px - }; - this.spin = new Spinner(opts).spin(this.$element[0]); - this.start_time = new Date().getTime(); - this.act_message(); - }, - act_message: function() { - var self = this; - setTimeout(function() { - if (self.isDestroyed()) - return; - var seconds = (new Date().getTime() - self.start_time) / 1000; - var mes; - _.each(messages_by_seconds, function(el) { - if (seconds >= el[0]) - mes = el[1]; - }); - self.$(".oe_throbber_message").html(mes); - self.act_message(); - }, 1000); - }, - destroy: function() { - if (this.spin) - this.spin.stop(); - this._super(); - }, -}); -instance.web.Throbber.throbbers = []; - -instance.web.blockUI = function() { - var tmp = $.blockUI.apply($, arguments); - var throbber = new instance.web.Throbber(); - instance.web.Throbber.throbbers.push(throbber); - throbber.appendTo($(".oe_blockui_spin_container")); - return tmp; -} -instance.web.unblockUI = function() { - _.each(instance.web.Throbber.throbbers, function(el) { - el.destroy(); - }); - return $.unblockUI.apply($, arguments); -} - /** Setup default session */ instance.session = new instance.web.Session(); @@ -679,6 +603,86 @@ instance.session.on('module_loaded', this, function () { $.timeago.settings.translator = instance.web._t; }); +/** Setup blockui */ +if ($.blockUI) { + $.blockUI.defaults.baseZ = 1100; + $.blockUI.defaults.message = '
'; + $.blockUI.defaults.css.border = '0'; + $.blockUI.defaults.css["background-color"] = ''; +} + +var messages_by_seconds = function() { + return [ + [0, _t("Loading...")], + [30, _t("Still loading...")], + [60, _t("Still loading...
Please be patient.")], + [120, _t("Don't leave yet,
it's still loading...")], + [300, _t("You may not believe it,
but the application is actually loading...")], + [600, _t("You know, sometimes,
OpenERP can be a little bit slow,
because it's loading...")], + [3600, _t("Maybe you should consider pressing F5...")], + ]; +}; + +instance.web.Throbber = instance.web.Widget.extend({ + template: "Throbber", + start: function() { + var opts = { + lines: 13, // The number of lines to draw + length: 7, // The length of each line + width: 4, // The line thickness + radius: 10, // The radius of the inner circle + rotate: 0, // The rotation offset + color: '#FFF', // #rgb or #rrggbb + speed: 1, // Rounds per second + trail: 60, // Afterglow percentage + shadow: false, // Whether to render a shadow + hwaccel: false, // Whether to use hardware acceleration + className: 'spinner', // The CSS class to assign to the spinner + zIndex: 2e9, // The z-index (defaults to 2000000000) + top: 'auto', // Top position relative to parent in px + left: 'auto' // Left position relative to parent in px + }; + this.spin = new Spinner(opts).spin(this.$element[0]); + this.start_time = new Date().getTime(); + this.act_message(); + }, + act_message: function() { + var self = this; + setTimeout(function() { + if (self.isDestroyed()) + return; + var seconds = (new Date().getTime() - self.start_time) / 1000; + var mes; + _.each(messages_by_seconds(), function(el) { + if (seconds >= el[0]) + mes = el[1]; + }); + self.$(".oe_throbber_message").html(mes); + self.act_message(); + }, 1000); + }, + destroy: function() { + if (this.spin) + this.spin.stop(); + this._super(); + }, +}); +instance.web.Throbber.throbbers = []; + +instance.web.blockUI = function() { + var tmp = $.blockUI.apply($, arguments); + var throbber = new instance.web.Throbber(); + instance.web.Throbber.throbbers.push(throbber); + throbber.appendTo($(".oe_blockui_spin_container")); + return tmp; +} +instance.web.unblockUI = function() { + _.each(instance.web.Throbber.throbbers, function(el) { + el.destroy(); + }); + return $.unblockUI.apply($, arguments); +} + /** * Registry for all the client actions key: tag value: widget */ From 0068c09358226c78b2e779749818bb38855bf640 Mon Sep 17 00:00:00 2001 From: niv-openerp Date: Fri, 24 Aug 2012 19:01:11 +0200 Subject: [PATCH 4/8] [IMP] web_linkedin: put the wizard into the sales wizard bzr revid: nicolas.vanhoren@openerp.com-20120824170111-j64d4l8xc6403a2m --- addons/web_linkedin/__openerp__.py | 2 +- addons/web_linkedin/web_linkedin.py | 3 +- addons/web_linkedin/web_linkedin_view.xml | 64 +++++++++-------------- 3 files changed, 27 insertions(+), 42 deletions(-) diff --git a/addons/web_linkedin/__openerp__.py b/addons/web_linkedin/__openerp__.py index 0e9503ac579..6ce78cfca47 100644 --- a/addons/web_linkedin/__openerp__.py +++ b/addons/web_linkedin/__openerp__.py @@ -10,7 +10,7 @@ OpenERP Web LinkedIn module. This module provides the Integration of the LinkedIn with OpenERP. """, 'data': ['web_linkedin_view.xml'], - 'depends' : ['base'], + 'depends' : ['crm'], 'js': ['static/src/js/*.js'], 'css': ['static/src/css/*.css'], 'qweb': ['static/src/xml/*.xml'], diff --git a/addons/web_linkedin/web_linkedin.py b/addons/web_linkedin/web_linkedin.py index c398ad17f3b..ea94329f8b1 100644 --- a/addons/web_linkedin/web_linkedin.py +++ b/addons/web_linkedin/web_linkedin.py @@ -39,8 +39,7 @@ class Binary(openerpweb.Controller): return base64.b64encode(bfile.read()) class web_linkedin_settings(osv.osv_memory): - _name = 'web_linkedin.settings' - _inherit = 'res.config.settings' + _inherit = 'sale.config.settings' _columns = { 'api_key': fields.char(string="API Key", size=50), 'server_domain': fields.char(size=100), diff --git a/addons/web_linkedin/web_linkedin_view.xml b/addons/web_linkedin/web_linkedin_view.xml index 463bfd49d21..8b4fa617bf3 100644 --- a/addons/web_linkedin/web_linkedin_view.xml +++ b/addons/web_linkedin/web_linkedin_view.xml @@ -15,48 +15,34 @@ linkedin_settings - web_linkedin.settings + sale.config.settings + -
-
-
-

- To use the LinkedIn module with this database, an API Key is required. Please follow this procedure: -

-
    -
  • Go to this URL: - https://www.linkedin.com/secure/developer. -
  • -
  • Log into LinkedIn.
  • -
  • Add a new application and fill the form: -
      -
    • JavaScript API Domain:
    • -
    • The programming tool is Javascript
    • -
    -
  • -
  • Copy the API key down here:
  • -
- - - -
+
+
+

+ To use the LinkedIn module with this database, an API Key is required. Please follow this procedure: +

+
    +
  • Go to this URL: + https://www.linkedin.com/secure/developer. +
  • +
  • Log into LinkedIn.
  • +
  • Add a new application and fill the form: +
      +
    • JavaScript API Domain:
    • +
    • The programming tool is Javascript
    • +
    +
  • +
  • Copy the API key down here:
  • +
+ + + +
+
- - - Configure Linkedin - ir.actions.act_window - web_linkedin.settings - form - inline - - - - From 9780532da1247b0d528f6a42a4ba9b25892f6fea Mon Sep 17 00:00:00 2001 From: niv-openerp Date: Fri, 24 Aug 2012 19:26:22 +0200 Subject: [PATCH 5/8] [IMP] changed the way create from m2o works, added option create_name_field bzr revid: nicolas.vanhoren@openerp.com-20120824172622-evcz7011wlagep4z --- addons/web/static/src/js/view_form.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index b8c9acfef49..ac61a988693 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -2641,7 +2641,7 @@ instance.web.form.CompletionFieldMixin = { } // create... values.push({label: _t("   Create and Edit..."), action: function() { - self._search_create_popup("form", undefined, {}); + self._search_create_popup("form", undefined, self._create_context(search_val)); }}); return values; @@ -2653,7 +2653,7 @@ instance.web.form.CompletionFieldMixin = { _quick_create: function(name) { var self = this; var slow_create = function () { - self._search_create_popup("form", undefined, {"default_name": name}); + self._search_create_popup("form", undefined, self._create_context(name)); }; if (self.options.quick_create === undefined || self.options.quick_create) { new instance.web.DataSet(this, this.field.relation, self.build_context()) @@ -2690,6 +2690,13 @@ instance.web.form.CompletionFieldMixin = { * To implement. */ add_id: function(id) {}, + _create_context: function(name) { + var tmp = {}; + var field = (this.options || {}).create_name_field; + if (field) + tmp["default_" + field] = name; + return tmp; + }, }; instance.web.form.FieldMany2One = instance.web.form.AbstractField.extend(instance.web.form.CompletionFieldMixin, instance.web.form.ReinitializeFieldMixin, { From 9818cf073f11364fd1846b43ed34b0a93eb224f5 Mon Sep 17 00:00:00 2001 From: niv-openerp Date: Fri, 24 Aug 2012 19:27:29 +0200 Subject: [PATCH 6/8] [IMP] crm: added create_name_field on partner_id in leads bzr revid: nicolas.vanhoren@openerp.com-20120824172729-4botx8doui5iw1er --- addons/crm/crm_lead_view.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/crm/crm_lead_view.xml b/addons/crm/crm_lead_view.xml index f2c923844ec..6a715893a17 100644 --- a/addons/crm/crm_lead_view.xml +++ b/addons/crm/crm_lead_view.xml @@ -155,7 +155,7 @@ + on_change="on_change_partner(partner_id)" options='{"create_name_field": "name"}'/>