[MERGE] Merged with main branch

bzr revid: pso@tinyerp.com-20120823130751-55j9naym9rab8492
bzr revid: pso@tinyerp.com-20120827053644-mzy2bj3fppc3ij4e
This commit is contained in:
pso (OpenERP) 2012-08-27 11:06:44 +05:30
commit f06f0da395
47 changed files with 359 additions and 322 deletions

View File

@ -582,6 +582,8 @@ class account_account(osv.osv):
def name_get(self, cr, uid, ids, context=None):
if not ids:
return []
if isinstance(ids, (int, long)):
ids = [ids]
reads = self.read(cr, uid, ids, ['name', 'code'], context=context)
res = []
for record in reads:

View File

@ -1,6 +1,6 @@
<?xml version="1.0" ?>
<openerp>
<data noupdate="1">
<data>
<!-- FIELD LIST -->
@ -76,7 +76,7 @@
</field>
</record>
<!-- ACTION -->
<!-- ACTION -->
<record model="ir.actions.act_window" id="action_ir_model_fields_anonymize_wizard">
<field name="name">Anonymize Database</field>
@ -163,4 +163,3 @@
</data>
</openerp>

View File

@ -26,10 +26,10 @@ openerp.auth_anonymous = function(instance) {
start: function() {
var self = this;
this._super.apply(this, arguments);
this.$element.find('.oe_topbar_anonymous_login').click(function() {
this.$el.find('.oe_topbar_anonymous_login').click(function() {
var p = self.getParent();
var am = p.action_manager;
p.$element.find('.oe_leftbar').hide();
p.$el.find('.oe_leftbar').hide();
am.do_action({
type:'ir.actions.client',
tag:'login',

View File

@ -4,7 +4,7 @@ openerp.auth_oauth = function(instance) {
instance.web.Login = instance.web.Login.extend({
start: function(parent, params) {
var d = this._super.apply(this, arguments);
this.$element.on('click', 'a.zocial', this.on_oauth_sign_in);
this.$el.on('click', 'a.zocial', this.on_oauth_sign_in);
this.oauth_providers = [];
if(this.params.oauth_error === 1) {
this.do_warn("Sign up error.","Sign up is not allowed on this database.");

View File

@ -8,7 +8,7 @@ instance.web.Login = instance.web.Login.extend({
this._super.apply(this, arguments);
var self = this;
this._default_error_message = this.$element.find('.oe_login_error_message').text();
this._default_error_message = this.$el.find('.oe_login_error_message').text();
this.$openid_selected_button = $();
this.$openid_selected_input = $();
@ -32,7 +32,7 @@ instance.web.Login = instance.web.Login.extend({
this.do_openid_select('a[data-url=""]', 'login,password', true);
}
this.$element.find('a[data-url]').click(function (event) {
this.$el.find('a[data-url]').click(function (event) {
event.preventDefault();
var selected_oidh = $(this).attr('href').substr(1);
if (selected_oidh != self.$openid_selected_provider) {
@ -48,10 +48,10 @@ instance.web.Login = instance.web.Login.extend({
var self = this;
self.$openid_selected_button.add(self.$openid_selected_input).removeClass('selected');
self.$openid_selected_button = self.$element.find(button).addClass('selected');
self.$openid_selected_button = self.$el.find(button).addClass('selected');
var input = _(provider.split(',')).map(function(p) { return 'li[data-provider="'+p+'"]'; }).join(',');
self.$openid_selected_input = self.$element.find(input).addClass('selected');
self.$openid_selected_input = self.$el.find(input).addClass('selected');
self.$openid_selected_input.find('input:first').focus();
self.$openid_selected_provider = (self.$openid_selected_button.attr('href') || '').substr(1);
@ -61,7 +61,7 @@ instance.web.Login = instance.web.Login.extend({
}
if (!noautosubmit && self.$openid_selected_input.length == 0) {
self.$element.find('form').submit();
self.$el.find('form').submit();
}
},
@ -96,7 +96,7 @@ instance.web.Login = instance.web.Login.extend({
localStorage.setItem('openid-login', id);
}
var db = this.$element.find("form [name=db]").val();
var db = this.$el.find("form [name=db]").val();
var openid_url = dataurl.replace('{id}', id);
this.do_openid_login(db, openid_url);
@ -129,12 +129,12 @@ instance.web.Login = instance.web.Login.extend({
do_warn: function(title, msg) {
//console.warn(title, msg);
this.$element.find('.oe_login_error_message').text(msg).show();
this.$el.find('.oe_login_error_message').text(msg).show();
this._super(title, msg);
},
reset_error_message: function() {
this.$element.find('.oe_login_error_message').text(this._default_error_message);
this.$el.find('.oe_login_error_message').text(this._default_error_message);
}
});

View File

@ -2,7 +2,7 @@ openerp.auth_reset_password = function(instance) {
var _t = instance.web._t;
instance.web.Login.include({
start: function() {
var $e = this.$element;
var $e = this.$el;
$e.find('a.oe_login_switch').click(function() {
$e.find('ul.oe_login_switch').toggle();
var $m = $e.find('form input[name=is_reset_pw]');
@ -15,7 +15,7 @@ openerp.auth_reset_password = function(instance) {
ev.preventDefault();
}
var $e = this.$element;
var $e = this.$el;
var db = $e.find("form [name=db]").val();
if (!db) {
this.do_warn(_t("Login"), _t("No database selected !"));

View File

@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data noupdate="1">
<data>
<record id="view_base_report_sxw" model="ir.ui.view">
<field name="name">Base Report sxw</field>
<field name="model">base.report.sxw</field>
@ -17,7 +18,7 @@
</footer>
</form>
</field>
</record>
</record>
<record id="action_view_base_report_sxw" model="ir.actions.act_window">
<field name="name">Base Report sxw</field>
@ -43,7 +44,8 @@
<label colspan="4" string="This is the template of your requested report.&#10;Save it as a .SXW file and open it with OpenOffice.&#10;Don't forget to install the OpenERP SA OpenOffice package to modify it.&#10;Once it is modified, re-upload it in OpenERP using this wizard." align="0.0"/>
</form>
</field>
</record>
</record>
<record id="view_base_report_file_rml" model="ir.ui.view">
<field name="name">Base Report File sxw</field>
<field name="model">base.report.rml.save</field>
@ -55,6 +57,5 @@
</field>
</record>
</data>
</openerp>

View File

@ -7,13 +7,13 @@ openerp.base_setup = function(openerp) {
if (this.dataset.model === 'res.partner') {
/* Set names for partner categories */
var category_ids = [];
this.$element.find('.oe_kanban_partner_categories span').each(function() {
this.$el.find('.oe_kanban_partner_categories span').each(function() {
category_ids.push($(this).data('category_id'));
});
var dataset = new openerp.web.DataSetSearch(this, 'res.partner.category', self.session.context);
dataset.name_get(_.uniq(category_ids)).then(function(result) {
_.each(result, function(value) {
self.$element
self.$el
.find('.oe_kanban_partner_categories span[data-category_id=' + value[0] + ']')
.html(value[1]);
});

View File

@ -50,6 +50,13 @@
content: "+";
margin-left: 4px;
}
.openerp .oe_dashboard .oe_action .oe_header .oe_header_text {
visibility: hidden;
cursor: text;
}
.openerp .oe_dashboard .oe_action .oe_header span {
cursor: pointer;
}
.openerp .oe_dashboard .oe_action .oe_header_empty {
padding-top: 0;
padding-bottom: 2px;

View File

@ -49,6 +49,11 @@
.oe_maximize:after
content: "+"
margin-left: 4px
.oe_header_text
visibility: hidden
cursor: text
span
cursor: pointer
.oe_header_empty
padding-top: 0
padding-bottom: 2px

View File

@ -18,18 +18,21 @@ instance.web.form.DashBoard = instance.web.form.FormWidget.extend({
var self = this;
this._super.apply(this, arguments);
this.$element.find('.oe_dashboard_column').sortable({
this.$el.find('.oe_dashboard_column').sortable({
connectWith: '.oe_dashboard_column',
handle: '.oe_header',
scroll: false
}).disableSelection().bind('sortstop', self.do_save_dashboard);
}).bind('sortstop', self.do_save_dashboard);
// Events
this.$element.find('.oe_dashboard_link_reset').click(this.on_reset);
this.$element.find('.oe_dashboard_link_change_layout').click(this.on_change_layout);
this.$element.delegate('.oe_dashboard_column .oe_fold', 'click', this.on_fold_action);
this.$element.delegate('.oe_dashboard_column .oe_close', 'click', this.on_close_action);
this.$el.find('.oe_dashboard_link_reset').click(this.on_reset);
this.$el.find('.oe_dashboard_link_change_layout').click(this.on_change_layout);
this.$el.find('h2.oe_header span.oe_header_txt').click(function(ev){
if(ev.target === ev.currentTarget)
self.on_header_string($(ev.target).parent());
});
this.$el.delegate('.oe_dashboard_column .oe_fold', 'click', this.on_fold_action);
this.$el.delegate('.oe_dashboard_column .oe_close', 'click', this.on_close_action);
// Init actions
_.each(this.node.children, function(column, column_index) {
@ -46,6 +49,30 @@ instance.web.form.DashBoard = instance.web.form.FormWidget.extend({
});
});
},
on_header_string:function(h2){
var self = this;
var span = h2.find('span:first').hide();
var input = h2.find('.oe_header_text').css('visibility','visible');
var attr = h2.closest(".oe_action").data('action_attrs');
var change_string = function(new_name){
attr['string'] = new_name;
span.text(new_name).show();
input.css('visibility','hidden');
self.do_save_dashboard();
}
input.unbind()
.val(span.text())
.change(function(event){
change_string($(this).val());
})
.keyup(function(event){
if(event.keyCode == 27){
//esc key to cancel changes
input.css('visibility','hidden');
span.show();
}
});
},
on_reset: function() {
this.rpc('/web/view/undo_custom', {
view_id: this.view.fields_view.view_id,
@ -55,7 +82,7 @@ instance.web.form.DashBoard = instance.web.form.FormWidget.extend({
on_change_layout: function() {
var self = this;
var qdict = {
current_layout : this.$element.find('.oe_dashboard').attr('data-layout')
current_layout : this.$el.find('.oe_dashboard').attr('data-layout')
};
var $dialog = instance.web.dialog($('<div>'), {
modal: true,
@ -70,7 +97,7 @@ instance.web.form.DashBoard = instance.web.form.FormWidget.extend({
});
},
do_change_layout: function(new_layout) {
var $dashboard = this.$element.find('.oe_dashboard');
var $dashboard = this.$el.find('.oe_dashboard');
var current_layout = $dashboard.attr('data-layout');
if (current_layout != new_layout) {
var clayout = current_layout.split('-').length,
@ -114,10 +141,10 @@ instance.web.form.DashBoard = instance.web.form.FormWidget.extend({
var self = this;
var board = {
form_title : this.view.fields_view.arch.attrs.string,
style : this.$element.find('.oe_dashboard').attr('data-layout'),
style : this.$el.find('.oe_dashboard').attr('data-layout'),
columns : []
};
this.$element.find('.oe_dashboard_column').each(function() {
this.$el.find('.oe_dashboard_column').each(function() {
var actions = [];
$(this).find('.oe_action').each(function() {
var action_id = $(this).attr('data-id'),
@ -139,7 +166,7 @@ instance.web.form.DashBoard = instance.web.form.FormWidget.extend({
view_id: this.view.fields_view.view_id,
arch: arch
}, function() {
self.$element.find('.oe_dashboard_link_reset').show();
self.$el.find('.oe_dashboard_link_reset').show();
});
},
on_load_action: function(result, index, action_attrs) {
@ -245,11 +272,11 @@ instance.web.form.DashBoard = instance.web.form.FormWidget.extend({
});
}
var rendered = QWeb.render(this.form_template, this);
this.$element.html(rendered);
this.$el.html(rendered);
},
no_result: function() {
if (this.view.options.action.help) {
this.$element.append(
this.$el.append(
$('<div class="oe_view_nocontent">')
.append($('<div>').html(this.view.options.action.help || " "))
);
@ -296,7 +323,7 @@ instance.board.AddToDashboard = instance.web.search.Input.extend({
_in_drawer: true,
start: function () {
var self = this;
this.$element
this.$el
.on('click', 'h4', this.proxy('show_option'))
.on('submit', 'form', function (e) {
e.preventDefault();
@ -333,7 +360,7 @@ instance.board.AddToDashboard = instance.web.search.Input.extend({
var self = this;
var getParent = this.getParent();
var view_parent = this.getParent().getParent();
if (! view_parent.action || ! this.$element.find("select").val()) {
if (! view_parent.action || ! this.$el.find("select").val()) {
this.do_warn("Can't find dashboard action");
return;
}
@ -343,24 +370,24 @@ instance.board.AddToDashboard = instance.web.search.Input.extend({
_.each(data.contexts, context.add, context);
_.each(data.domains, domain.add, domain);
this.rpc('/board/add_to_dashboard', {
menu_id: this.$element.find("select").val(),
menu_id: this.$el.find("select").val(),
action_id: view_parent.action.id,
context_to_save: context,
domain: domain,
view_mode: view_parent.active_view,
name: this.$element.find("input").val()
name: this.$el.find("input").val()
}, function(r) {
if (r === false) {
self.do_warn("Could not add filter to dashboard");
} else {
self.$element.toggleClass('oe_opened');
self.$el.toggleClass('oe_opened');
self.do_notify("Filter added to dashboard", '');
}
});
},
show_option:function(){
this.$element.toggleClass('oe_opened');
if (! this.$element.hasClass('oe_opened'))
this.$el.toggleClass('oe_opened');
if (! this.$el.hasClass('oe_opened'))
return;
this.$("input").val(this.getParent().fields_view.name || "" );
}

View File

@ -23,13 +23,15 @@
<t t-name="DashBoard.action">
<div t-att-data-id="action.attrs.name" class="oe_action">
<h2 t-attf-class="oe_header #{action.attrs.string ? '' : 'oe_header_empty'}">
<t t-esc="action.attrs.string"/>
<span class="oe_header_txt"> <t t-esc="action.attrs.string"/> </span>
<input class = "oe_header_text" type="text"/>
<t t-if="!action.attrs.string">&amp;nbsp;</t>
<button t-if="action.attrs.creatable and action.attrs.creatable !== 'false'" class="oe_button oe_button_create">Create</button>
<span class='oe_icon oe_close'></span>
<span class='oe_icon oe_minimize oe_fold' t-if="!action.attrs.fold"></span>
<span class='oe_icon oe_maximize oe_fold' t-if="action.attrs.fold"></span>
</h2>
<div t-attf-id="#{view.element_id}_action_#{column_index}_#{action_index}" class="oe_content" t-att-style="action.attrs.fold ? 'display: none' : null"></div>
</div>
</t>

View File

@ -291,6 +291,7 @@ class crm_lead(base_stage, osv.osv):
def on_change_partner(self, cr, uid, ids, partner_id, context=None):
result = {}
values = {}
if partner_id:
partner = self.pool.get('res.partner').browse(cr, uid, partner_id, context=context)
values = {

View File

@ -155,7 +155,7 @@
<group>
<field name="partner_name" string="Company Name"/>
<field name="partner_id" string="Customer"
on_change="on_change_partner(partner_id)" />
on_change="on_change_partner(partner_id)" options='{"create_name_field": "name"}'/>
<label for="street" string="Address"/>
<div>
<field name="street" placeholder="Street..."/>

View File

@ -11,7 +11,7 @@ openerp.document_page = function (openerp) {
}
} else {
var wiki_value = wiky.process(show_value || '');
this.$element.html(wiki_value);
this.$el.html(wiki_value);
}
},
});

View File

@ -28,14 +28,14 @@ openerp.edi.EdiView = openerp.web.Widget.extend({
if (openerp.web.qweb.templates[template_content]) {
this.content = openerp.web.qweb.render(template_content, param);
}
this.$element.html(openerp.web.qweb.render("EdiView", param));
this.$element.find('button.oe_edi_action_print').bind('click', this.do_print);
this.$element.find('button#oe_edi_import_existing').bind('click', this.do_import_existing);
this.$element.find('button#oe_edi_import_create').bind('click', this.do_import_create);
this.$element.find('button#oe_edi_download').bind('click', this.do_download);
this.$element.find('.oe_edi_import_choice, .oe_edi_import_choice_label').bind('click', this.toggle_choice('import'));
this.$element.find('.oe_edi_pay_choice, .oe_edi_pay_choice_label').bind('click', this.toggle_choice('pay'));
this.$element.find('#oe_edi_download_show_code').bind('click', this.show_code);
this.$el.html(openerp.web.qweb.render("EdiView", param));
this.$el.find('button.oe_edi_action_print').bind('click', this.do_print);
this.$el.find('button#oe_edi_import_existing').bind('click', this.do_import_existing);
this.$el.find('button#oe_edi_import_create').bind('click', this.do_import_create);
this.$el.find('button#oe_edi_download').bind('click', this.do_download);
this.$el.find('.oe_edi_import_choice, .oe_edi_import_choice_label').bind('click', this.toggle_choice('import'));
this.$el.find('.oe_edi_pay_choice, .oe_edi_pay_choice_label').bind('click', this.toggle_choice('pay'));
this.$el.find('#oe_edi_download_show_code').bind('click', this.show_code);
},
on_document_failed: function(response) {
var self = this;
@ -85,7 +85,7 @@ openerp.edi.EdiView = openerp.web.Widget.extend({
},
do_import_existing: function(e) {
var url_download = this.get_download_url();
var $edi_text_server_input = this.$element.find('#oe_edi_txt_server_url');
var $edi_text_server_input = this.$el.find('#oe_edi_txt_server_url');
var server_url = $edi_text_server_input.val();
$edi_text_server_input.removeClass('invalid');
if (!server_url) {
@ -138,14 +138,14 @@ openerp.edi.EdiImport = openerp.web.Widget.extend({
show_login: function() {
this.destroy_content();
this.login = new openerp.web.Login(this);
this.login.appendTo(this.$element);
this.login.appendTo(this.$el);
},
destroy_content: function() {
_.each(_.clone(this.getChildren()), function(el) {
el.destroy();
});
this.$element.children().remove();
this.$el.children().remove();
},
do_import: function() {

File diff suppressed because one or more lines are too long

View File

@ -59,7 +59,7 @@ openerp.event = function(instance, mod) {
address = _.str.sprintf('%(street)s, %(zip)s %(city)s', value);
}
// TODO repalce by widget_option selector self.options.selector
var el = self.view.$element.find(".oe_google_map")[0];
var el = self.view.$el.find(".oe_google_map")[0];
self.map.render_map(address,el);
});
},

View File

@ -267,16 +267,16 @@
<field name="arch" type="xml">
<form string="Interview Appraisal" version="7.0">
<header>
<button string="Send Request" name="survey_req_waiting_answer" states="draft" type="object" icon="gtk-yes" class="oe_highlight"/>
<button string="Done" name="survey_req_done" states="waiting_answer" type="object" icon="gtk-jump-to"/>
<button string="Cancel" name="survey_req_cancel" states="draft,waiting_answer" type="object" icon="gtk-cancel"/>
<button name="%(survey.action_view_survey_question_message)d" string="Answer Survey" type="action" states="waiting_answer,cancel" icon="gtk-execute" context="{'survey_id': survey_id, 'response_id': [response], 'response_no':0, 'active' : response,'request' : True, 'object' : 'hr.evaluation.interview', 'cur_id' : active_id}" attrs="{'readonly':[('survey_id','=',False)]}" class="oe_highlight"/>
<button name="action_print_survey" string="Print Survey" type="object" states="draft" icon="gtk-print" context="{'survey_id': survey_id, 'response_id': [response], 'response_no':0}" attrs="{'readonly':[('survey_id','=',False)]}" class="oe_highlight"/>
<button string="Send Request" name="survey_req_waiting_answer" states="draft" type="object" icon="gtk-yes" class="oe_highlight"/>
<button name="%(survey.action_view_survey_question_message)d" string="Answer Survey" type="action" states="waiting_answer" context="{'survey_id': survey_id, 'response_id': [response], 'response_no':0, 'active' : response,'request' : True, 'object' : 'hr.evaluation.interview', 'cur_id' : active_id}" attrs="{'readonly':[('survey_id','=',False)]}"/>
<button string="Done" name="survey_req_done" states="waiting_answer" type="object" icon="gtk-jump-to"/>
<field name="state" widget="statusbar" statusbar_visible="waiting_answer,done"/>
</header>
<sheet>
<div class="oe_right oe_button_box" name="button_box">
<button string="Send Reminder Email" name="%(mail.action_email_compose_message_wizard)d" icon="terp-mail-message-new" type="action" states="waiting_answer" class="oe_link"/>
<button string="Send Reminder Email" name="%(mail.action_email_compose_message_wizard)d" icon="terp-mail-message-new" type="action" states="waiting_answer"/>
</div>
<group>
<group col="3" colspan="1">

View File

@ -108,7 +108,7 @@ class hr_payslip(osv.osv):
'journal_id': slip.journal_id.id,
'period_id': period_id,
}
for line in slip.line_ids:
for line in slip.details_by_salary_rule_category:
amt = slip.credit_note and -line.total or line.total
partner_id = line.salary_rule_id.register_id.partner_id and line.salary_rule_id.register_id.partner_id.id or default_partner_id
debit_account_id = line.salary_rule_id.account_debit.id

View File

@ -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')

View File

@ -10,7 +10,7 @@ openerp.hr_recruitment = function(openerp) {
var categ_ids = [];
// Collect categories ids
self.$element.find('span[data-categ_id]').each(function() {
self.$el.find('span[data-categ_id]').each(function() {
categ_ids.push($(this).data('categ_id'));
});
@ -19,7 +19,7 @@ openerp.hr_recruitment = function(openerp) {
dataset.read_slice(['id', 'name']).then(function(result) {
_.each(result, function(v, k) {
// Set the proper value in the DOM and display the element
self.$element.find('span[data-categ_id=' + v.id + ']').text(v.name);
self.$el.find('span[data-categ_id=' + v.id + ']').text(v.name);
});
});
},

View File

@ -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_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)
: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_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_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'})
"""
# 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_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_key], 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

View File

@ -296,7 +296,7 @@ class mail_thread(osv.Model):
self.message_create_notify_by_email(cr, uid, vals, user_to_push_ids, context=context)
return msg_id
def message_get_user_ids_to_notify(self, cr, uid, thread_ids, new_msg_vals, context=None):
# get body
body = new_msg_vals.get('body_html', '') if new_msg_vals.get('content_subtype') == 'html' else new_msg_vals.get('body_text', '')
@ -1139,7 +1139,7 @@ class mail_thread(osv.Model):
""" When creating a new message, set as unread if uid is not the
object responsible. """
for obj in self.browse(cr, uid, ids, context=context):
if obj.message_state and self._columns.get('user_id') and (not obj.user_id or obj.user_id.id != uid):
if obj.message_state and ('user_id' in obj._columns.keys()) and (not obj.user_id or obj.user_id.id != uid) :
self.message_mark_as_unread(cr, uid, [obj.id], context=context)
def message_check_and_set_unread(self, cr, uid, ids, context=None):

View File

@ -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_key='id', context=context)
def create(self, cr, uid, data, context=None):
# create default alias same as the login

View File

@ -57,7 +57,7 @@ openerp.mail = function(session) {
/* generic chatter events binding */
bind_events: function(widget) {
// event: click on an internal link to a document: model, login
widget.$element.delegate('a.oe_mail_internal_link', 'click', function (event) {
widget.$el.delegate('a.oe_mail_internal_link', 'click', function (event) {
event.preventDefault();
// lazy implementation: fetch data and try to redirect
if (! event.srcElement.dataset.resModel) return false;
@ -344,8 +344,8 @@ openerp.mail = function(session) {
// customize display: add avatar, clean previous content
var user_avatar = mail.ChatterUtils.get_image(this.session.prefix,
this.session.session_id, 'res.users', 'image_small', this.session.uid);
this.$element.find('img.oe_mail_icon').attr('src', user_avatar);
this.$element.find('div.oe_mail_msg_content').empty();
this.$el.find('img.oe_mail_icon').attr('src', user_avatar);
this.$el.find('div.oe_mail_msg_content').empty();
// create a context for the default_get of the compose form
var widget_context = {
'active_model': this.params.res_model,
@ -378,7 +378,7 @@ openerp.mail = function(session) {
disable_autofocus: true,
});
// add the form, bind events, activate the form
var msg_node = this.$element.find('div.oe_mail_msg_content');
var msg_node = this.$el.find('div.oe_mail_msg_content');
return $.when(this.form_view.appendTo(msg_node)).pipe(function() {
self.bind_events();
self.form_view.do_show();
@ -396,31 +396,31 @@ openerp.mail = function(session) {
* in the function. */
bind_events: function() {
var self = this;
this.$element.find('button.oe_form_button').click(function (event) {
this.$el.find('button.oe_form_button').click(function (event) {
event.preventDefault();
});
// event: click on 'Send an Email' link that toggles the form for
// sending an email (partner_ids)
this.$element.find('a.oe_mail_compose_message_email').click(function (event) {
this.$el.find('a.oe_mail_compose_message_email').click(function (event) {
event.preventDefault();
self.toggle_email_mode();
});
// event: click on 'Formatting' icon-link that toggles the advanced
// formatting options for writing a message (subject, body_html)
this.$element.find('a.oe_mail_compose_message_formatting').click(function (event) {
this.$el.find('a.oe_mail_compose_message_formatting').click(function (event) {
event.preventDefault();
self.toggle_formatting_mode();
});
// event: click on 'Attachment' icon-link that opens the dialog to
// add an attachment.
this.$element.find('a.oe_mail_compose_message_attachment').click(function (event) {
this.$el.find('a.oe_mail_compose_message_attachment').click(function (event) {
event.preventDefault();
// not yet implemented
self.set_body_value('attachment', 'attachment');
});
// event: click on 'Checklist' icon-link that toggles the options
// for adding checklist.
this.$element.find('a.oe_mail_compose_message_checklist').click(function (event) {
this.$el.find('a.oe_mail_compose_message_checklist').click(function (event) {
event.preventDefault();
// not yet implemented
self.set_body_value('checklist', 'checklist');
@ -440,9 +440,9 @@ openerp.mail = function(session) {
// update context of datasetsearch
this.ds_compose.context.formatting = this.formatting;
// toggle display
this.$element.find('span.oe_mail_compose_message_subject').toggleClass('oe_mail_compose_message_invisible');
this.$element.find('div.oe_mail_compose_message_body_text').toggleClass('oe_mail_compose_message_invisible');
this.$element.find('div.oe_mail_compose_message_body_html').toggleClass('oe_mail_compose_message_invisible');
this.$el.find('span.oe_mail_compose_message_subject').toggleClass('oe_mail_compose_message_invisible');
this.$el.find('div.oe_mail_compose_message_body_text').toggleClass('oe_mail_compose_message_invisible');
this.$el.find('div.oe_mail_compose_message_body_html').toggleClass('oe_mail_compose_message_invisible');
},
/**
@ -460,14 +460,14 @@ openerp.mail = function(session) {
// update 'Post' button -> 'Send'
// update 'Send an Email' link -> 'Post a comment'
if (this.email_mode) {
this.$element.find('button.oe_mail_compose_message_button_send').html('<span>Send</span>');
this.$element.find('a.oe_mail_compose_message_email').html('Comment');
this.$el.find('button.oe_mail_compose_message_button_send').html('<span>Send</span>');
this.$el.find('a.oe_mail_compose_message_email').html('Comment');
} else {
this.$element.find('button.oe_mail_compose_message_button_send').html('<span>Post</span>');
this.$element.find('a.oe_mail_compose_message_email').html('Send an Email');
this.$el.find('button.oe_mail_compose_message_button_send').html('<span>Post</span>');
this.$el.find('a.oe_mail_compose_message_email').html('Send an Email');
}
// toggle display
this.$element.find('div.oe_mail_compose_message_partner_ids').toggleClass('oe_mail_compose_message_invisible');
this.$el.find('div.oe_mail_compose_message_partner_ids').toggleClass('oe_mail_compose_message_invisible');
},
/**
@ -581,14 +581,14 @@ openerp.mail = function(session) {
'res_id': this.params.res_id, 'mode': mode || 'comment', 'msg_id': msg_id,
'email_mode': email_mode || false, 'formatting': formatting || false,
'context': context || false } );
var composition_node = this.$element.find('div.oe_mail_thread_action');
var composition_node = this.$el.find('div.oe_mail_thread_action');
composition_node.empty();
var compose_done = this.compose_message_widget.appendTo(composition_node);
return compose_done;
},
do_customize_display: function() {
if (this.display.show_post_comment) { this.$element.find('div.oe_mail_thread_action').eq(0).show(); }
if (this.display.show_post_comment) { this.$el.find('div.oe_mail_thread_action').eq(0).show(); }
},
/**
@ -599,29 +599,29 @@ openerp.mail = function(session) {
// generic events from Chatter Mixin
mail.ChatterUtils.bind_events(this);
// event: click on 'more' at bottom of thread
this.$element.find('button.oe_mail_button_more').click(function () {
this.$el.find('button.oe_mail_button_more').click(function () {
self.do_more();
});
// event: writing in basic textarea of composition form (quick reply)
this.$element.find('textarea.oe_mail_compose_textarea').keyup(function (event) {
this.$el.find('textarea.oe_mail_compose_textarea').keyup(function (event) {
var charCode = (event.which) ? event.which : window.event.keyCode;
if (event.shiftKey && charCode == 13) { this.value = this.value+"\n"; }
else if (charCode == 13) { return self.do_comment(); }
});
// event: click on 'Reply' in msg
this.$element.find('div.oe_mail_thread_display').delegate('a.oe_mail_msg_reply', 'click', function (event) {
this.$el.find('div.oe_mail_thread_display').delegate('a.oe_mail_msg_reply', 'click', function (event) {
var act_dom = $(this).parents('div.oe_mail_thread_display').find('div.oe_mail_thread_action:first');
act_dom.toggle();
event.preventDefault();
});
// event: click on 'attachment(s)' in msg
this.$element.delegate('a.oe_mail_msg_view_attachments', 'click', function (event) {
this.$el.delegate('a.oe_mail_msg_view_attachments', 'click', function (event) {
var act_dom = $(this).parent().parent().parent().find('.oe_mail_msg_attachments');
act_dom.toggle();
event.preventDefault();
});
// event: click on 'Delete' in msg side menu
this.$element.find('div.oe_mail_thread_display').delegate('a.oe_mail_msg_delete', 'click', function (event) {
this.$el.find('div.oe_mail_thread_display').delegate('a.oe_mail_msg_delete', 'click', function (event) {
if (! confirm(_t("Do you really want to delete this message?"))) { return false; }
var msg_id = event.srcElement.dataset.id;
if (! msg_id) return false;
@ -634,7 +634,7 @@ openerp.mail = function(session) {
return call_defer;
});
// event: click on 'Hide' in msg side menu
this.$element.find('div.oe_mail_thread_display').delegate('a.oe_mail_msg_hide', 'click', function (event) {
this.$el.find('div.oe_mail_thread_display').delegate('a.oe_mail_msg_hide', 'click', function (event) {
if (! confirm(_t("Do you really want to hide this thread ?"))) { return false; }
var msg_id = event.srcElement.dataset.id;
if (! msg_id) return false;
@ -647,7 +647,7 @@ openerp.mail = function(session) {
return call_defer;
});
// event: click on "Reply" in msg side menu (email style)
this.$element.find('div.oe_mail_thread_display').delegate('a.oe_mail_msg_reply_by_email', 'click', function (event) {
this.$el.find('div.oe_mail_thread_display').delegate('a.oe_mail_msg_reply_by_email', 'click', function (event) {
var msg_id = event.srcElement.dataset.msg_id;
var email_mode = (event.srcElement.dataset.type == 'email');
var formatting = (event.srcElement.dataset.formatting == 'html');
@ -665,7 +665,7 @@ openerp.mail = function(session) {
var self = this;
this.params.offset = 0;
this.comments_structure = {'root_ids': [], 'new_root_ids': [], 'msgs': {}, 'tree_struct': {}, 'model_to_root_ids': {}};
this.$element.find('div.oe_mail_thread_display').empty();
this.$el.find('div.oe_mail_thread_display').empty();
var domain = this.get_fetch_domain(this.comments_structure);
return this.fetch_comments(this.params.limit, this.params.offset, domain).then();
},
@ -680,8 +680,8 @@ openerp.mail = function(session) {
else { self.display.show_more = true; }
self.display_comments(records);
// TODO: move to customize display
if (self.display.show_more == true) self.$element.find('div.oe_mail_thread_more:last').show();
else self.$element.find('div.oe_mail_thread_more:last').hide();
if (self.display.show_more == true) self.$el.find('div.oe_mail_thread_more:last').show();
else self.$el.find('div.oe_mail_thread_more:last').hide();
});
return defer;
@ -725,8 +725,8 @@ openerp.mail = function(session) {
self.thread = new mail.Thread(self, {'res_model': self.params.res_model, 'res_id': self.params.res_id, 'uid': self.params.uid,
'records': sub_msgs, 'thread_level': (self.params.thread_level-1), 'parent_id': record.id,
'is_wall': self.params.is_wall});
self.$element.find('li.oe_mail_thread_msg:last').append('<div class="oe_mail_thread_subthread"/>');
self.thread.appendTo(self.$element.find('div.oe_mail_thread_subthread:last'));
self.$el.find('li.oe_mail_thread_msg:last').append('<div class="oe_mail_thread_subthread"/>');
self.thread.appendTo(self.$el.find('div.oe_mail_thread_subthread:last'));
}
else if (self.params.thread_level == 0) {
self.display_comment(record);
@ -758,8 +758,8 @@ openerp.mail = function(session) {
// render
var rendered = session.web.qweb.render('mail.thread.message', {'record': record, 'thread': this, 'params': this.params, 'display': this.display});
// expand feature
$(rendered).appendTo(this.$element.children('div.oe_mail_thread_display:first'));
this.$element.find('div.oe_mail_msg_record_body').expander({
$(rendered).appendTo(this.$el.children('div.oe_mail_thread_display:first'));
this.$el.find('div.oe_mail_msg_record_body').expander({
slicePoint: this.params.msg_more_limit,
expandText: 'read more',
userCollapseText: '[^]',
@ -771,11 +771,11 @@ openerp.mail = function(session) {
display_current_user: function () {
var avatar = mail.ChatterUtils.get_image(this.session.prefix, this.session.session_id, 'res.users', 'image_small', this.params.uid);
return this.$element.find('img.oe_mail_icon').attr('src', avatar);
return this.$el.find('img.oe_mail_icon').attr('src', avatar);
},
do_comment: function () {
var comment_node = this.$element.find('textarea');
var comment_node = this.$el.find('textarea');
var body_text = comment_node.val();
comment_node.val('');
return this.ds.call('message_append_note', [[this.params.res_id], '', body_text, this.params.parent_id, 'comment', 'plain']).then(
@ -851,17 +851,17 @@ openerp.mail = function(session) {
this.view.on("change:actual_mode", this, this._check_visibility);
this._check_visibility();
mail.ChatterUtils.bind_events(this);
this.$element.find('button.oe_mail_button_followers').click(function () { self.do_toggle_followers(); });
this.$el.find('button.oe_mail_button_followers').click(function () { self.do_toggle_followers(); });
if (! this.params.see_subscribers_options) {
this.$element.find('button.oe_mail_button_followers').hide(); }
this.$element.find('button.oe_mail_button_follow').click(function () { self.do_follow(); });
this.$element.find('button.oe_mail_button_unfollow').click(function () { self.do_unfollow(); })
this.$el.find('button.oe_mail_button_followers').hide(); }
this.$el.find('button.oe_mail_button_follow').click(function () { self.do_follow(); });
this.$el.find('button.oe_mail_button_unfollow').click(function () { self.do_unfollow(); })
.mouseover(function () { $(this).html('Unfollow').removeClass('oe_mail_button_mouseout').addClass('oe_mail_button_mouseover'); })
.mouseleave(function () { $(this).html('Following').removeClass('oe_mail_button_mouseover').addClass('oe_mail_button_mouseout'); });
},
_check_visibility: function() {
this.$element.toggle(this.view.get("actual_mode") !== "create");
this.$el.toggle(this.view.get("actual_mode") !== "create");
},
destroy: function () {
@ -872,15 +872,15 @@ openerp.mail = function(session) {
this._super.apply(this, arguments);
if (! this.view.datarecord.id ||
session.web.BufferedDataSet.virtual_id_regex.test(this.view.datarecord.id)) {
this.$element.find('.oe_mail_thread').hide();
this.$el.find('.oe_mail_thread').hide();
return;
}
// create and render Thread widget
this.$element.find('div.oe_mail_recthread_main').empty();
this.$el.find('div.oe_mail_recthread_main').empty();
if (this.thread) this.thread.destroy();
this.thread = new mail.Thread(this, {'res_model': this.view.model, 'res_id': this.view.datarecord.id, 'uid': this.session.uid,
'thread_level': this.params.thread_level, 'show_post_comment': true, 'limit': 15});
var thread_done = this.thread.appendTo(this.$element.find('div.oe_mail_recthread_main'));
var thread_done = this.thread.appendTo(this.$el.find('div.oe_mail_recthread_main'));
return thread_done;
},
});
@ -965,7 +965,7 @@ openerp.mail = function(session) {
this.compose_message_widget = new mail.ComposeMessage(this, {
'extended_mode': false, 'uid': this.session.uid, 'res_model': this.params.res_model,
'res_id': this.params.res_id, 'mode': mode || 'comment', 'msg_id': msg_id });
var composition_node = this.$element.find('div.oe_mail_wall_action');
var composition_node = this.$el.find('div.oe_mail_wall_action');
composition_node.empty();
var compose_done = this.compose_message_widget.appendTo(composition_node);
return compose_done;
@ -975,7 +975,7 @@ openerp.mail = function(session) {
add_event_handlers: function () {
var self = this;
// display more threads
this.$element.find('button.oe_mail_wall_button_more').click(function () { return self.do_more(); });
this.$el.find('button.oe_mail_wall_button_more').click(function () { return self.do_more(); });
},
/**
@ -987,7 +987,7 @@ openerp.mail = function(session) {
load_search_view: function (view_id, defaults, hidden) {
var self = this;
this.searchview = new session.web.SearchView(this, this.ds_msg, view_id || false, defaults || {}, hidden || false);
var search_view_loaded = this.searchview.appendTo(this.$element.find('.oe_view_manager_view_search'));
var search_view_loaded = this.searchview.appendTo(this.$el.find('.oe_view_manager_view_search'));
return $.when(search_view_loaded).then(function () {
self.searchview.on_search.add(self.do_searchview_search);
});
@ -1016,7 +1016,7 @@ openerp.mail = function(session) {
},
display_current_user: function () {
//return this.$element.find('img.oe_mail_msg_image').attr('src', this.thread_get_avatar('res.users', 'avatar', this.session.uid));
//return this.$el.find('img.oe_mail_msg_image').attr('src', this.thread_get_avatar('res.users', 'avatar', this.session.uid));
},
/**
@ -1031,7 +1031,7 @@ openerp.mail = function(session) {
this.search['context'] = _.extend(this.params.context, this.search_results.context);
this.display_show_more = true;
this.comments_structure = {'root_ids': [], 'new_root_ids': [], 'msgs': {}, 'tree_struct': {}, 'model_to_root_ids': {}};
this.$element.find('ul.oe_mail_wall_threads').empty();
this.$el.find('ul.oe_mail_wall_threads').empty();
return this.fetch_comments(this.params.limit, 0);
},
@ -1064,13 +1064,13 @@ openerp.mail = function(session) {
var model_name = self.comments_structure.msgs[root_id]['model'];
var res_id = self.comments_structure.msgs[root_id]['res_id'];
var render_res = session.web.qweb.render('mail.wall_thread_container', {});
$('<li class="oe_mail_wall_thread">').html(render_res).appendTo(self.$element.find('ul.oe_mail_wall_threads'));
$('<li class="oe_mail_wall_thread">').html(render_res).appendTo(self.$el.find('ul.oe_mail_wall_threads'));
var thread = new mail.Thread(self, {
'res_model': model_name, 'res_id': res_id, 'uid': self.session.uid, 'records': records,
'parent_id': false, 'thread_level': self.params.thread_level, 'show_hide': true, 'is_wall': true}
);
self.thread_list.push(thread);
return thread.appendTo(self.$element.find('li.oe_mail_wall_thread:last'));
return thread.appendTo(self.$el.find('li.oe_mail_wall_thread:last'));
});
// update TODO
this.comments_structure['root_ids'] = _.union(this.comments_structure['root_ids'], this.comments_structure['new_root_ids']);
@ -1097,8 +1097,8 @@ openerp.mail = function(session) {
/** Display update: show more button */
do_update_show_more: function (new_value) {
if (new_value != undefined) this.display_show_more = new_value;
if (this.display_show_more) this.$element.find('div.oe_mail_wall_more:last').show();
else this.$element.find('div.oe_mail_wall_more:last').hide();
if (this.display_show_more) this.$el.find('div.oe_mail_wall_more:last').show();
else this.$el.find('div.oe_mail_wall_more:last').hide();
},
/** Action: Shows more discussions */

View File

@ -40,20 +40,20 @@ openerp_mail_followers = function(session, mail) {
// any other method to know if the view is in create mode anymore
this.view.on("change:actual_mode", this, this._check_visibility);
this._check_visibility();
this.$element.find('button.oe_mail_button_followers').click(function () { self.do_toggle_followers(); });
this.$el.find('button.oe_mail_button_followers').click(function () { self.do_toggle_followers(); });
if (! this.params.display_control) {
this.$element.find('button.oe_mail_button_followers').hide(); }
this.$element.find('button.oe_mail_button_follow').click(function () { self.do_follow(); })
this.$el.find('button.oe_mail_button_followers').hide(); }
this.$el.find('button.oe_mail_button_follow').click(function () { self.do_follow(); })
.mouseover(function () { $(this).html('Follow').removeClass('oe_mail_button_mouseout').addClass('oe_mail_button_mouseover'); })
.mouseleave(function () { $(this).html('Not following').removeClass('oe_mail_button_mouseover').addClass('oe_mail_button_mouseout'); });
this.$element.find('button.oe_mail_button_unfollow').click(function () { self.do_unfollow(); })
this.$el.find('button.oe_mail_button_unfollow').click(function () { self.do_unfollow(); })
.mouseover(function () { $(this).html('Unfollow').removeClass('oe_mail_button_mouseout').addClass('oe_mail_button_mouseover'); })
.mouseleave(function () { $(this).html('Following').removeClass('oe_mail_button_mouseover').addClass('oe_mail_button_mouseout'); });
this.reinit();
},
_check_visibility: function() {
this.$element.toggle(this.view.get("actual_mode") !== "create");
this.$el.toggle(this.view.get("actual_mode") !== "create");
},
destroy: function () {
@ -64,16 +64,16 @@ openerp_mail_followers = function(session, mail) {
this.params.display_followers = true;
this.params.display_control = this.node.attrs.display_control || false;
this.params.display_actions = this.node.attrs.display_actions || false;
this.$element.find('button.oe_mail_button_followers').html('Hide followers')
this.$element.find('button.oe_mail_button_follow').hide();
this.$element.find('button.oe_mail_button_unfollow').hide();
this.$el.find('button.oe_mail_button_followers').html('Hide followers')
this.$el.find('button.oe_mail_button_follow').hide();
this.$el.find('button.oe_mail_button_unfollow').hide();
},
set_value: function(value_) {
this.reinit();
if (! this.view.datarecord.id ||
session.web.BufferedDataSet.virtual_id_regex.test(this.view.datarecord.id)) {
this.$element.find('div.oe_mail_recthread_aside').hide();
this.$el.find('div.oe_mail_recthread_aside').hide();
return;
}
return this.fetch_subscribers(value_);
@ -89,19 +89,19 @@ openerp_mail_followers = function(session, mail) {
display_subscribers: function (records) {
var self = this;
this.is_subscriber = false;
var user_list = this.$element.find('ul.oe_mail_followers_display').empty();
this.$element.find('div.oe_mail_recthread_followers h4').html(this.params.title + ' (' + records.length + ')');
var user_list = this.$el.find('ul.oe_mail_followers_display').empty();
this.$el.find('div.oe_mail_recthread_followers h4').html(this.params.title + ' (' + records.length + ')');
_(records).each(function (record) {
if (record.id == self.session.uid) { self.is_subscriber = true; }
record.avatar_url = mail.ChatterUtils.get_image(self.session.prefix, self.session.session_id, 'res.users', 'image_small', record.id);
$(session.web.qweb.render('mail.followers.partner', {'record': record})).appendTo(user_list);
});
if (this.is_subscriber) {
this.$element.find('button.oe_mail_button_follow').hide();
this.$element.find('button.oe_mail_button_unfollow').show(); }
this.$el.find('button.oe_mail_button_follow').hide();
this.$el.find('button.oe_mail_button_unfollow').show(); }
else {
this.$element.find('button.oe_mail_button_follow').show();
this.$element.find('button.oe_mail_button_unfollow').hide(); }
this.$el.find('button.oe_mail_button_follow').show();
this.$el.find('button.oe_mail_button_unfollow').hide(); }
},
do_follow: function () {
@ -114,9 +114,9 @@ openerp_mail_followers = function(session, mail) {
do_toggle_followers: function () {
this.params.see_subscribers = ! this.params.see_subscribers;
if (this.params.see_subscribers) { this.$element.find('button.oe_mail_button_followers').html('Hide followers'); }
else { this.$element.find('button.oe_mail_button_followers').html('Show followers'); }
this.$element.find('div.oe_mail_recthread_followers').toggle();
if (this.params.see_subscribers) { this.$el.find('button.oe_mail_button_followers').html('Hide followers'); }
else { this.$el.find('button.oe_mail_button_followers').html('Show followers'); }
this.$el.find('div.oe_mail_recthread_followers').toggle();
},
});
};

View File

@ -5,8 +5,8 @@ instance.web.form.FieldPad = instance.web.form.AbstractField.extend(instance.web
initialize_content: function() {
var self = this;
this.$textarea = undefined;
this.$element.find('div.oe_etherpad_head').click(function(ev) {
self.$element.toggleClass('oe_etherpad_fullscreen').toggleClass('oe_etherpad_normal');
this.$el.find('div.oe_etherpad_head').click(function(ev) {
self.$el.toggleClass('oe_etherpad_fullscreen').toggleClass('oe_etherpad_normal');
});
},
set_value: function(value_) {
@ -21,12 +21,12 @@ instance.web.form.FieldPad = instance.web.form.AbstractField.extend(instance.web
if (!this.get("effective_readonly")) {
var pad_username = this.session.username;
var code = '<iframe width="100%" height="100%" frameborder="0" src="'+url+'?showChat=false&userName='+pad_username+'"></iframe>';
this.$element.find('div.oe_etherpad_default').html(code);
this.$el.find('div.oe_etherpad_default').html(code);
} else {
$.get(url+'/export/html').success(function(data) {
self.$element.html('<div class="etherpad_readonly">'+data+'</div>');
self.$el.html('<div class="etherpad_readonly">'+data+'</div>');
}).error(function() {
self.$element.text('Unable to load pad');
self.$el.text('Unable to load pad');
});
}
}

View File

@ -877,13 +877,17 @@
<form string="Point of Sale Session" version="7.0">
<header>
<button name="open" type="workflow" string="Validate &amp; Open Session" states="opening_control" class="oe_highlight"/>
<button name="cashbox_control" type="workflow" string="End of Session" states="opened"
class="oe_highlight"/>
<button name="cashbox_control" type="workflow" string="End of Session"
attrs="{'invisible' : [('has_closing_control', '=', False),('state', '=', 'opened')]}"
class="oe_highlight" />
<button name="close" type="workflow" string="Validate Closing &amp; Post Entries"
attrs="{'invisible' : [('has_closing_control', '=', True),('state', '=', 'opened')]}"
class="oe_highlight" />
<button name="close" type="workflow" string="Validate Closing &amp; Post Entries" states="closing_control"
class="oe_highlight"/>
class="oe_highlight" />
<button name="open_frontend_cb" type="object" string="Continue Selling" states="opened"/>
<div class="oe_right">
<field name="state" widget="statusbar" statusbar_visible="opening_control,opened,closing_control,closed" nolabel="1"/>
<field name="state" widget="statusbar" statusbar_visible="opening_control,opened,closing_control,closed" nolabel="1" />
</div>
</header>
<sheet>
@ -895,16 +899,16 @@
Session:
<field name="name" attrs="{'invisible': [('name','=','/')]}" class="oe_inline"/>
</h1>
<field name="has_opening_control" invisible="1" />
<field name="has_closing_control" invisible="1" />
<group>
<field name="has_opening_control" invisible="1" />
<field name="has_closing_control" invisible="1" />
<group>
<field name="user_id"/>
<field name="config_id" attrs="{'invisible' : [('config_id', '&lt;&gt;', False)]}"/>
</group>
<group>
<field name="start_at" attrs="{'invisible' : [('state', '=', 'opening_control')]}"/>
<field name="stop_at" attrs="{'invisible' : [('state', '&lt;&gt;', 'closed')]}"/>
<field name="stop_at" attrs="{'invisible' : [('state', '!=', 'closed')]}"/>
</group>
<newline/>

View File

@ -225,13 +225,13 @@ function openerp_pos_screens(instance, module){ //module is instance.point_of_sa
// with add_action_button()
show_action_bar: function(){
this.pos_widget.action_bar.show();
this.$element.css({'bottom':'105px'});
this.$el.css({'bottom':'105px'});
},
// hides the action bar. The actionbar is automatically hidden when it is empty
hide_action_bar: function(){
this.pos_widget.action_bar.hide();
this.$element.css({'bottom':'0px'});
this.$el.css({'bottom':'0px'});
},
// adds a new button to the action bar. The button definition takes three parameters, all optional :
@ -250,8 +250,8 @@ function openerp_pos_screens(instance, module){ //module is instance.point_of_sa
var self = this;
this.hidden = false;
if(this.$element){
this.$element.show();
if(this.$el){
this.$el.show();
}
if(this.pos_widget.action_bar.get_button_count() > 0){
@ -311,8 +311,8 @@ function openerp_pos_screens(instance, module){ //module is instance.point_of_sa
// POS initialization.
hide: function(){
this.hidden = true;
if(this.$element){
this.$element.hide();
if(this.$el){
this.$el.hide();
}
},
@ -323,8 +323,8 @@ function openerp_pos_screens(instance, module){ //module is instance.point_of_sa
renderElement: function(){
this._super();
if(this.hidden){
if(this.$element){
this.$element.hide();
if(this.$el){
this.$el.hide();
}
}
},
@ -332,13 +332,13 @@ function openerp_pos_screens(instance, module){ //module is instance.point_of_sa
module.PopUpWidget = module.PosBaseWidget.extend({
show: function(){
if(this.$element){
this.$element.show();
if(this.$el){
this.$el.show();
}
},
hide: function(){
if(this.$element){
this.$element.hide();
if(this.$el){
this.$el.hide();
}
},
});
@ -350,7 +350,7 @@ function openerp_pos_screens(instance, module){ //module is instance.point_of_sa
this.pos.proxy.help_needed();
var self = this;
this.$element.find('.button').off('click').click(function(){
this.$el.find('.button').off('click').click(function(){
self.pos_widget.screen_selector.close_popup();
self.pos.proxy.help_canceled();
});
@ -700,7 +700,7 @@ function openerp_pos_screens(instance, module){ //module is instance.point_of_sa
},
refresh: function() {
this.currentOrder = this.pos.get('selectedOrder');
$('.pos-receipt-container', this.$element).html(QWeb.render('PosTicket',{widget:this}));
$('.pos-receipt-container', this.$el).html(QWeb.render('PosTicket',{widget:this}));
},
});

View File

@ -35,10 +35,10 @@ function openerp_pos_basewidget(instance, module){ //module is instance.point_of
},
show: function(){
this.$element.show();
this.$el.show();
},
hide: function(){
this.$element.hide();
this.$el.hide();
},
});

View File

@ -63,12 +63,12 @@ function openerp_pos_scrollbar(instance, module){ //module is instance.point_of_
this.update_scroller_dimensions(false);
this.update_button_status();
this.auto_hide(false);
this.$element.bind('mousewheel',function(event,delta){
this.$el.bind('mousewheel',function(event,delta){
self.scroll(delta*self.wheel_step);
return false;
});
this.$element.bind('click',function(event){
var vpos = event.pageY - self.$element.offset().top;
this.$el.bind('click',function(event){
var vpos = event.pageY - self.$el.offset().top;
var spos = self.scroller_dimensions();
if(vpos > spos.bar_pos && vpos < spos.pos){
self.page_up();
@ -106,9 +106,9 @@ function openerp_pos_scrollbar(instance, module){ //module is instance.point_of_
// shows the scrollbar. if animated is true, it will do it in an animated fashion
show: function(animated){ //FIXME: animated show and hide don't work ... ?
if(animated){
this.$element.show().animate({'width':'48px'}, 500, 'swing');
this.$el.show().animate({'width':'48px'}, 500, 'swing');
}else{
this.$element.show().css('width','48px');
this.$el.show().css('width','48px');
}
this.on_show(this);
},
@ -117,9 +117,9 @@ function openerp_pos_scrollbar(instance, module){ //module is instance.point_of_
hide: function(animated){
var self = this;
if(animated){
this.$element.animate({'width':'0px'}, 500, 'swing', function(){ self.$element.hide();});
this.$el.animate({'width':'0px'}, 500, 'swing', function(){ self.$el.hide();});
}else{
this.$element.hide().css('width','0px');
this.$el.hide().css('width','0px');
}
this.on_hide(this);
},
@ -136,7 +136,7 @@ function openerp_pos_scrollbar(instance, module){ //module is instance.point_of_
var button_up_height = this.$('.up-button')[0].offsetHeight || 48;
var button_down_height = this.$('.down-button')[0].offsetHeight || 48;
var bar_height = this.$element[0].offsetHeight || 96;
var bar_height = this.$el[0].offsetHeight || 96;
var scrollbar_height = bar_height - button_up_height - button_down_height;
scroller_pos = scroller_pos * scrollbar_height + button_up_height;
@ -205,7 +205,7 @@ function openerp_pos_scrollbar(instance, module){ //module is instance.point_of_
if(this.target_selector){
return this.target_widget.$(this.target_selector);
}else{
return this.target_widget.$element;
return this.target_widget.$el;
}
}else if(this.target_selector){
return $(this.target_selector);

View File

@ -61,10 +61,10 @@ function openerp_pos_widgets(instance, module){ //module is instance.point_of_sa
start: function() {
this.state.bind('change:mode', this.changedMode, this);
this.changedMode();
this.$element.find('button#numpad-backspace').click(_.bind(this.clickDeleteLastChar, this));
this.$element.find('button#numpad-minus').click(_.bind(this.clickSwitchSign, this));
this.$element.find('button.number-char').click(_.bind(this.clickAppendNewChar, this));
this.$element.find('button.mode-button').click(_.bind(this.clickChangeMode, this));
this.$el.find('button#numpad-backspace').click(_.bind(this.clickDeleteLastChar, this));
this.$el.find('button#numpad-minus').click(_.bind(this.clickSwitchSign, this));
this.$el.find('button.number-char').click(_.bind(this.clickAppendNewChar, this));
this.$el.find('button.mode-button').click(_.bind(this.clickChangeMode, this));
},
clickDeleteLastChar: function() {
return this.state.deleteLastChar();
@ -84,7 +84,7 @@ function openerp_pos_widgets(instance, module){ //module is instance.point_of_sa
changedMode: function() {
var mode = this.state.get('mode');
$('.selected-mode').removeClass('selected-mode');
$(_.str.sprintf('.mode-button[data-mode="%s"]', mode), this.$element).addClass('selected-mode');
$(_.str.sprintf('.mode-button[data-mode="%s"]', mode), this.$el).addClass('selected-mode');
},
});
@ -102,7 +102,7 @@ function openerp_pos_widgets(instance, module){ //module is instance.point_of_sa
pos_widget : self.pos_widget,
cashRegister: cashRegister,
});
button.appendTo(self.$element);
button.appendTo(self.$el);
});
}
});
@ -117,7 +117,7 @@ function openerp_pos_widgets(instance, module){ //module is instance.point_of_sa
var self = this;
this._super();
this.$element.click(function(){
this.$el.click(function(){
if (self.pos.get('selectedOrder').get('screen') === 'receipt'){ //TODO Why ?
console.warn('TODO should not get there...?');
return;
@ -146,9 +146,9 @@ function openerp_pos_widgets(instance, module){ //module is instance.point_of_sa
},
renderElement: function() {
this._super();
this.$element.click(_.bind(this.click_handler, this));
this.$el.click(_.bind(this.click_handler, this));
if(this.model.is_selected()){
this.$element.addClass('selected');
this.$el.addClass('selected');
}
},
refresh: function(){
@ -291,7 +291,7 @@ function openerp_pos_widgets(instance, module){ //module is instance.point_of_sa
this._super();
this.$('img').replaceWith(this.pos_widget.image_cache.get_image(this.get_image_url()));
var self = this;
$("a", this.$element).click(function(e){
$("a", this.$el).click(function(e){
if(self.click_product_action){
self.click_product_action(self.model);
}
@ -355,7 +355,7 @@ function openerp_pos_widgets(instance, module){ //module is instance.point_of_sa
},
setButtonSelected: function() {
$('.selected-order').removeClass('selected-order');
this.$element.addClass('selected-order');
this.$el.addClass('selected-order');
},
closeOrder: function(event) {
this.order.destroy();
@ -378,7 +378,7 @@ function openerp_pos_widgets(instance, module){ //module is instance.point_of_sa
renderElement: function(){
this._super();
if(this.click_action){
this.$element.click(_.bind(this.click_action, this));
this.$el.click(_.bind(this.click_action, this));
}
},
});
@ -421,10 +421,10 @@ function openerp_pos_widgets(instance, module){ //module is instance.point_of_sa
return button;
},
show:function(){
this.$element.show();
this.$el.show();
},
hide:function(){
this.$element.hide();
this.$el.hide();
},
});
@ -644,11 +644,11 @@ function openerp_pos_widgets(instance, module){ //module is instance.point_of_sa
var self = this;
this._super();
if(this.action){
this.$element.click(function(){ self.action(); });
this.$el.click(function(){ self.action(); });
}
},
show: function(){ this.$element.show(); },
hide: function(){ this.$element.hide(); },
show: function(){ this.$el.show(); },
hide: function(){ this.$el.hide(); },
});

View File

@ -499,7 +499,7 @@ class product_product(osv.osv):
main_supplier = self._get_main_product_supplier(cr, uid, product, context=context)
result[product.id] = {
'seller_info_id': main_supplier and main_supplier.id or False,
'seller_delay': main_supplier and main_supplier.delay or 1,
'seller_delay': main_supplier.delay if main_supplier else 1,
'seller_qty': main_supplier and main_supplier.qty or 0.0,
'seller_id': main_supplier and main_supplier.name.id or False
}

View File

@ -10,7 +10,7 @@ openerp.project = function(openerp) {
var members_ids = [];
// Collect members ids
self.$element.find('img[data-member_id]').each(function() {
self.$el.find('img[data-member_id]').each(function() {
members_ids.push($(this).data('member_id'));
});
@ -19,7 +19,7 @@ openerp.project = function(openerp) {
dataset.read_slice(['id', 'name']).then(function(result) {
_.each(result, function(v, k) {
// Set the proper value in the DOM
self.$element.find('img[data-member_id=' + v.id + ']').attr('title', v.name).tipsy({
self.$el.find('img[data-member_id=' + v.id + ']').attr('title', v.name).tipsy({
offset: 10
});
});
@ -35,7 +35,7 @@ openerp.project = function(openerp) {
var categ_ids = [];
// Collect categories ids
self.$element.find('span[data-categ_id]').each(function() {
self.$el.find('span[data-categ_id]').each(function() {
categ_ids.push($(this).data('categ_id'));
});
@ -44,7 +44,7 @@ openerp.project = function(openerp) {
dataset.read_slice(['id', 'name']).then(function(result) {
_.each(result, function(v, k) {
// Set the proper value in the DOM and display the element
self.$element.find('span[data-categ_id=' + v.id + ']').text(v.name);
self.$el.find('span[data-categ_id=' + v.id + ']').text(v.name);
});
});
},

View File

@ -580,8 +580,9 @@ class account_analytic_account(osv.osv):
return res
def _trigger_project_creation(self, cr, uid, vals, context=None):
if context is None: context = {}
res = super(account_analytic_account, self)._trigger_project_creation(cr, uid, vals, context=context)
return res or vals.get('use_issues')
return res or (vals.get('use_issues') and not 'project_creation_in_progress' in context)
account_analytic_account()

View File

@ -78,7 +78,7 @@ class purchase_report(osv.osv):
to_char(s.date_order, 'YYYY-MM-DD') as day,
s.state,
s.date_approve,
date_trunc('day',s.minimum_planned_date) as expected_date,
s.minimum_planned_date as expected_date,
s.dest_address_id,
s.pricelist_id,
s.validator,
@ -117,7 +117,7 @@ class purchase_report(osv.osv):
s.date_approve,
l.date_planned,
l.product_uom,
date_trunc('day',s.minimum_planned_date),
s.minimum_planned_date,
s.pricelist_id,
s.validator,
s.dest_address_id,
@ -129,7 +129,7 @@ class purchase_report(osv.osv):
to_char(s.date_order, 'YYYY-MM-DD'),
s.state,
s.warehouse_id,
u.uom_type,
u.uom_type,
u.category_id,
t.uom_id,
u.id,

View File

@ -22,6 +22,9 @@
attrs="{'invisible': [('advance_payment_method', '!=', 'percentage')]}"/>
</div>
</group>
<div>
<b><label string="After clicking 'Show Lines to Invoice' button, select lines to invoice and make invoice from the 'More' button." attrs="{'invisible': [('advance_payment_method', '!=', 'lines')]}"/></b>
</div>
<footer>
<button name="create_invoices" string="Create Invoice" type="object"
class="oe_highlight"

View File

@ -89,7 +89,7 @@ openerp.share = function(session) {
start: function() {
start_res = this._super.apply(this, arguments);
if (has_action_id) {
this.$element.find('button.oe_share_invite').show();
this.$el.find('button.oe_share_invite').show();
}
return start_res;
}
@ -100,7 +100,7 @@ openerp.share = function(session) {
var self = this;
this.check_if_action_is_defined();
has_share(function() {
self.$element.delegate('button.oe_share_invite', 'click', self.on_click_share_invite);
self.$el.delegate('button.oe_share_invite', 'click', self.on_click_share_invite);
});
return this._super.apply(this, arguments);
},

View File

@ -153,7 +153,8 @@ class report_stock_inventory(osv.osv):
'date': fields.datetime('Date', readonly=True),
'year': fields.char('Year', size=4, readonly=True),
'month':fields.selection([('01','January'), ('02','February'), ('03','March'), ('04','April'),
('05','May'), ('06','June'), ('07','July'), ('08','August'), ('09','September')]),
('05','May'), ('06','June'), ('07','July'), ('08','August'), ('09','September'),
('10','October'), ('11','November'), ('12','December')], 'Month', readonly=True),
'partner_id':fields.many2one('res.partner', 'Partner', readonly=True),
'product_id':fields.many2one('product.product', 'Product', readonly=True),
'product_categ_id':fields.many2one('product.category', 'Product Category', readonly=True),
@ -173,6 +174,8 @@ class report_stock_inventory(osv.osv):
CREATE OR REPLACE view report_stock_inventory AS (
(SELECT
min(m.id) as id, m.date as date,
to_char(m.date, 'YYYY') as year,
to_char(m.date, 'MM') as month,
m.partner_id as partner_id, m.location_id as location_id,
m.product_id as product_id, pt.categ_id as product_categ_id, l.usage as location_type,
m.company_id,
@ -191,10 +194,12 @@ CREATE OR REPLACE view report_stock_inventory AS (
LEFT JOIN stock_location l ON (m.location_id=l.id)
GROUP BY
m.id, m.product_id, m.product_uom, pt.categ_id, m.partner_id, m.location_id, m.location_dest_id,
m.prodlot_id, m.date, m.state, l.usage, m.company_id, pt.uom_id
m.prodlot_id, m.date, m.state, l.usage, m.company_id, pt.uom_id, to_char(m.date, 'YYYY'), to_char(m.date, 'MM')
) UNION ALL (
SELECT
-m.id as id, m.date as date,
to_char(m.date, 'YYYY') as year,
to_char(m.date, 'MM') as month,
m.partner_id as partner_id, m.location_dest_id as location_id,
m.product_id as product_id, pt.categ_id as product_categ_id, l.usage as location_type,
m.company_id,
@ -212,7 +217,7 @@ CREATE OR REPLACE view report_stock_inventory AS (
LEFT JOIN stock_location l ON (m.location_dest_id=l.id)
GROUP BY
m.id, m.product_id, m.product_uom, pt.categ_id, m.partner_id, m.location_id, m.location_dest_id,
m.prodlot_id, m.date, m.state, l.usage, m.company_id, pt.uom_id
m.prodlot_id, m.date, m.state, l.usage, m.company_id, pt.uom_id, to_char(m.date, 'YYYY'), to_char(m.date, 'MM')
)
);
""")

View File

@ -163,8 +163,10 @@
<filter name="group_lot" string="Lot" icon="terp-accessories-archiver" context="{'group_by':'prodlot_id'}"/>
<filter name="group_company" string="Company" groups="base.group_multi_company" icon="terp-go-home" context="{'group_by':'company_id'}"/>
<filter name="group_location" string="Location" icon="terp-go-home" context="{'group_by':'location_id'}"/>
<filter string="Date" icon="terp-go-month" context="{'group_by':'date'}"/>
<filter string="Status" icon="terp-stock_effects-object-colorize" context="{'group_by':'state'}"/>
<filter string="Date" icon="terp-go-today" context="{'group_by':'date'}"/>
<filter string="Month" icon="terp-go-month" context="{'group_by':'month'}"/>
<filter string="Year" icon="terp-go-year" context="{'group_by':'year'}"/>
</group>
</search>
</field>

View File

@ -2087,11 +2087,12 @@ class stock_move(osv.osv):
done.append(move.id)
pickings[move.picking_id.id] = 1
r = res.pop(0)
cr.execute('update stock_move set location_id=%s, product_qty=%s where id=%s', (r[1], r[0], move.id))
product_uos_qty = self.pool.get('stock.move').onchange_quantity(cr, uid, ids, move.product_id.id, r[0], move.product_id.uom_id.id, move.product_id.uos_id.id)['value']['product_uos_qty']
cr.execute('update stock_move set location_id=%s, product_qty=%s, product_uos_qty=%s where id=%s', (r[1], r[0],product_uos_qty, move.id))
while res:
r = res.pop(0)
move_id = self.copy(cr, uid, move.id, {'product_qty': r[0], 'location_id': r[1]})
move_id = self.copy(cr, uid, move.id, {'product_uos_qty': product_uos_qty, 'product_qty': r[0], 'location_id': r[1]})
done.append(move_id)
if done:
count += len(done)

View File

@ -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'],

View File

@ -233,8 +233,8 @@ openerp.web_linkedin = function(instance) {
$row.appendTo($elem);
}
pc.appendTo($row);
pc.$element.css("display", "table-cell");
pc.$element.css("width", "20%");
pc.$el.css("display", "table-cell");
pc.$el.css("width", "20%");
pc.on("selected", self, function(data) {
self.trigger("selected", data);
self.destroy();
@ -255,7 +255,7 @@ openerp.web_linkedin = function(instance) {
},
start: function() {
var self = this;
this.$element.click(function() {
this.$el.click(function() {
self.trigger("selected", self.data);
});
if (this.data.__type === "company") {

View File

@ -39,15 +39,16 @@ 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),
}
def get_default_linkedin(self, cr, uid, fields, context=None):
key = self.pool.get("ir.config_parameter").get_param(cr, uid, "web.linkedin.apikey") or ""
return {'api_key': key}
dom = self.pool.get('ir.config_parameter').get_param(cr, uid, 'web.base.url')
return {'api_key': key, 'server_domain': dom,}
def set_linkedin(self, cr, uid, ids, context=None):
key = self.browse(cr, uid, ids[0], context)["api_key"] or ""

View File

@ -15,15 +15,11 @@
<record id="view_linkedin_config_settings" model="ir.ui.view">
<field name="name">linkedin_settings</field>
<field name="model">web_linkedin.settings</field>
<field name="model">sale.config.settings</field>
<field name="inherit_id" ref="base_setup.view_sale_config_settings"/>
<field name="arch" type="xml">
<form string="Configure Linkedin" version="7.0" class="oe_form_configuration">
<header>
<button string="Apply" type="object" name="execute" class="oe_highlight"/>
or
<button string="Cancel" type="object" name="cancel" class="oe_link"/>
</header>
<div>
<div name="linkedin" position="inside">
<form string="Configure Linkedin" version="7.0" class="oe_form_configuration">
<p>
To use the LinkedIn module with this database, an API Key is required. Please follow this procedure:
</p>
@ -34,31 +30,19 @@
<li>Log into LinkedIn.</li>
<li>Add a new application and fill the form:
<ul>
<li>JavaScript API Domain: the domain of the url used to log into this database (example: http://localhost:8069)</li>
<li>JavaScript API Domain: <field name="server_domain" readonly="1" style="width:0"/></li>
<li>The programming tool is Javascript</li>
</ul>
</li>
<li>Copy the API key down here:</li>
</ul>
</div>
<group>
<field name="api_key"/>
</group>
</form>
<group>
<field name="api_key"/>
</group>
</form>
</div>
</field>
</record>
<record id="action_linkedin_config_settings" model="ir.actions.act_window">
<field name="name">Configure Linkedin</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">web_linkedin.settings</field>
<field name="view_mode">form</field>
<field name="target">inline</field>
</record>
<menuitem id="menu_linkedin_config_settings" name="Linkedin" parent="base.menu_config"
sequence="10" action="action_linkedin_config_settings"/>
</data>
</openerp>

View File

@ -39,13 +39,13 @@ instance.web_shortcuts.Shortcuts = instance.web.Widget.extend({
var self = this;
this._super();
this.trigger('load');
this.$element.on('click', '.oe_systray_shortcuts_items a', function() {
this.$el.on('click', '.oe_systray_shortcuts_items a', function() {
self.trigger('click', $(this));
});
},
load: function() {
var self = this;
this.$element.find('.oe_systray_shortcuts_items').empty();
this.$el.find('.oe_systray_shortcuts_items').empty();
return this.rpc('/web/shortcuts/list', {}, function(shortcuts) {
_.each(shortcuts, function(sc) {
self.trigger('display', sc);
@ -64,13 +64,13 @@ instance.web_shortcuts.Shortcuts = instance.web.Widget.extend({
},
display: function(sc) {
var self = this;
this.$element.find('.oe_systray_shortcuts_items').append();
this.$el.find('.oe_systray_shortcuts_items').append();
var $sc = $(QWeb.render('Systray.Shortcuts.Item', {'shortcut': sc}));
$sc.appendTo(self.$element.find('.oe_systray_shortcuts_items'));
$sc.appendTo(self.$el.find('.oe_systray_shortcuts_items'));
},
remove: function (menu_id) {
var menu_id = this.session.active_id;
var $shortcut = this.$element.find('.oe_systray_shortcuts_items li a[data-id=' + menu_id + ']');
var $shortcut = this.$el.find('.oe_systray_shortcuts_items li a[data-id=' + menu_id + ']');
var shortcut_id = $shortcut.data('shortcut-id');
$shortcut.remove();
this.dataset.unlink([shortcut_id]);
@ -85,10 +85,10 @@ instance.web_shortcuts.Shortcuts = instance.web.Widget.extend({
instance.webclient.user_menu.on_action({action_id: ir_menu_data.action[0][2].id});
}
});
this.$element.find('.oe_systray_shortcuts').trigger('mouseout');
this.$el.find('.oe_systray_shortcuts').trigger('mouseout');
},
has: function(menu_id) {
return !!this.$element.find('a[data-id=' + menu_id + ']').length;
return !!this.$el.find('a[data-id=' + menu_id + ']').length;
}
});
@ -101,7 +101,7 @@ instance.web.UserMenu.include({
self.shortcuts.trigger('load');
} else {
self.shortcuts = new instance.web_shortcuts.Shortcuts(self);
self.shortcuts.appendTo(instance.webclient.$element.find('.oe_systray'));
self.shortcuts.appendTo(instance.webclient.$el.find('.oe_systray'));
}
});
},
@ -119,7 +119,7 @@ instance.web.ViewManagerAction.include({
var shortcuts_menu = instance.webclient.user_menu.shortcuts;
var grandparent = this.getParent() && this.getParent().getParent();
// display shortcuts if on the first view for the action
var $shortcut_toggle = this.$element.find('.oe_shortcuts_toggle');
var $shortcut_toggle = this.$el.find('.oe_shortcuts_toggle');
if (!this.action.name ||
!(view.view_type === this.views_src[0].view_type
&& view.view_id === this.views_src[0].view_id)) {