diff --git a/addons/account/account.py b/addons/account/account.py index bb24aec1748..1a44e480e03 100644 --- a/addons/account/account.py +++ b/addons/account/account.py @@ -1027,6 +1027,9 @@ class account_period(osv.osv): def action_draft(self, cr, uid, ids, *args): mode = 'draft' + for period in self.browse(cr, uid, ids): + if period.fiscalyear_id.state == 'done': + raise osv.except_osv(_('Warning !'), _('You can not re-open a period which belongs to closed fiscal year')) cr.execute('update account_journal_period set state=%s where period_id in %s', (mode, tuple(ids),)) cr.execute('update account_period set state=%s where id in %s', (mode, tuple(ids),)) return True diff --git a/addons/account/account_move_line.py b/addons/account/account_move_line.py index 36d211c11d2..082d654c5a2 100644 --- a/addons/account/account_move_line.py +++ b/addons/account/account_move_line.py @@ -742,7 +742,7 @@ class account_move_line(osv.osv): def list_partners_to_reconcile(self, cr, uid, context=None): cr.execute( """SELECT partner_id FROM ( - SELECT l.partner_id, p.last_reconciliation_date, SUM(l.debit) AS debit, SUM(l.credit) AS credit, MAX(l.date) AS max_date + SELECT l.partner_id, p.last_reconciliation_date, SUM(l.debit) AS debit, SUM(l.credit) AS credit, MAX(l.create_date) AS max_date FROM account_move_line l RIGHT JOIN account_account a ON (a.id = l.account_id) RIGHT JOIN res_partner p ON (l.partner_id = p.id) @@ -753,9 +753,14 @@ class account_move_line(osv.osv): ) AS s WHERE debit > 0 AND credit > 0 AND (last_reconciliation_date IS NULL OR max_date > last_reconciliation_date) ORDER BY last_reconciliation_date""") - ids = cr.fetchall() - ids = len(ids) and [x[0] for x in ids] or [] - return self.pool.get('res.partner').name_get(cr, uid, ids, context=context) + ids = [x[0] for x in cr.fetchall()] + if not ids: + return [] + + # To apply the ir_rules + partner_obj = self.pool.get('res.partner') + ids = partner_obj.search(cr, uid, [('id', 'in', ids)], context=context) + return partner_obj.name_get(cr, uid, ids, context=context) def reconcile_partial(self, cr, uid, ids, type='auto', context=None, writeoff_acc_id=False, writeoff_period_id=False, writeoff_journal_id=False): move_rec_obj = self.pool.get('account.move.reconcile') diff --git a/addons/account/report/account_invoice_report.py b/addons/account/report/account_invoice_report.py index af6ae1eede7..31725a46b46 100644 --- a/addons/account/report/account_invoice_report.py +++ b/addons/account/report/account_invoice_report.py @@ -210,8 +210,8 @@ class account_invoice_report(osv.osv): cr.id IN (SELECT id FROM res_currency_rate cr2 WHERE (cr2.currency_id = sub.currency_id) - AND ((sub.date IS NOT NULL AND cr.name <= sub.date) - OR (sub.date IS NULL AND cr.name <= NOW())) + AND ((sub.date IS NOT NULL AND cr2.name <= sub.date) + OR (sub.date IS NULL AND cr2.name <= NOW())) ORDER BY name DESC LIMIT 1) )""" % ( self._table, diff --git a/addons/account/report/account_print_invoice.rml b/addons/account/report/account_print_invoice.rml index 4ffa7a33f9d..9268c94d4c7 100644 --- a/addons/account/report/account_print_invoice.rml +++ b/addons/account/report/account_print_invoice.rml @@ -168,7 +168,7 @@ Tel. : [[ (o.partner_id.phone) or removeParentNode('para') ]] Fax : [[ (o.partner_id.fax) or removeParentNode('para') ]] - VAT : [[ (o.partner_id.vat) or removeParentNode('para') ]] + TIN : [[ (o.partner_id.vat) or removeParentNode('para') ]] diff --git a/addons/account/wizard/account_invoice_refund.py b/addons/account/wizard/account_invoice_refund.py index df4ad3494d2..ba48dd34fe2 100644 --- a/addons/account/wizard/account_invoice_refund.py +++ b/addons/account/wizard/account_invoice_refund.py @@ -181,9 +181,9 @@ class account_invoice_refund(osv.osv_memory): invoice = invoice[0] del invoice['id'] invoice_lines = inv_line_obj.browse(cr, uid, invoice['invoice_line'], context=context) - invoice_lines = inv_obj._refund_cleanup_lines(cr, uid, invoice_lines) + invoice_lines = inv_obj._refund_cleanup_lines(cr, uid, invoice_lines, context=context) tax_lines = inv_tax_obj.browse(cr, uid, invoice['tax_line'], context=context) - tax_lines = inv_obj._refund_cleanup_lines(cr, uid, tax_lines) + tax_lines = inv_obj._refund_cleanup_lines(cr, uid, tax_lines, context=context) invoice.update({ 'type': inv.type, 'date_invoice': date, diff --git a/addons/account_analytic_analysis/account_analytic_analysis.py b/addons/account_analytic_analysis/account_analytic_analysis.py index 0a56c80766b..33ab3be209c 100644 --- a/addons/account_analytic_analysis/account_analytic_analysis.py +++ b/addons/account_analytic_analysis/account_analytic_analysis.py @@ -352,11 +352,10 @@ class account_analytic_account(osv.osv): res[account.id] = 0.0 sale_ids = sale_obj.search(cr, uid, [('project_id','=', account.id), ('state', '=', 'manual')], context=context) for sale in sale_obj.browse(cr, uid, sale_ids, context=context): - if not sale.invoiced: - res[account.id] += sale.amount_untaxed - for invoice in sale.invoice_ids: - if invoice.state not in ('draft', 'cancel'): - res[account.id] -= invoice.amount_untaxed + res[account.id] += sale.amount_untaxed + for invoice in sale.invoice_ids: + if invoice.state != 'cancel': + res[account.id] -= invoice.amount_untaxed return res def _timesheet_ca_invoiced_calc(self, cr, uid, ids, name, arg, context=None): diff --git a/addons/auth_oauth/static/src/js/auth_oauth.js b/addons/auth_oauth/static/src/js/auth_oauth.js index 7ee83bd99e9..131ae5c1c42 100644 --- a/addons/auth_oauth/static/src/js/auth_oauth.js +++ b/addons/auth_oauth/static/src/js/auth_oauth.js @@ -5,6 +5,7 @@ openerp.auth_oauth = function(instance) { start: function(parent, params) { var self = this; var d = this._super.apply(this, arguments); + this.$el.hide(); this.$el.on('click', 'a.zocial', this.on_oauth_sign_in); this.oauth_providers = []; if(this.params.oauth_error === 1) { @@ -24,6 +25,8 @@ openerp.auth_oauth = function(instance) { var db = this.$("form [name=db]").val(); if (db) { this.rpc("/auth_oauth/list_providers", { dbname: db }).done(this.on_oauth_loaded); + } else { + this.$el.show(); } }, on_oauth_loaded: function(result) { @@ -32,6 +35,7 @@ openerp.auth_oauth = function(instance) { if (this.oauth_providers.length === 1 && params.type === 'signup') { this.do_oauth_sign_in(this.oauth_providers[0]); } else { + this.$el.show(); this.$('.oe_oauth_provider_login_button').remove(); var buttons = QWeb.render("auth_oauth.Login.button",{"widget":this}); this.$(".oe_login_pane form ul").after(buttons); @@ -57,7 +61,7 @@ openerp.auth_oauth = function(instance) { state: JSON.stringify(state), }; var url = provider.auth_endpoint + '?' + $.param(params); - window.location = url; + instance.web.redirect(url); }, _oauth_state: function(provider) { // return the state object sent back with the redirected uri diff --git a/addons/board/static/src/js/dashboard.js b/addons/board/static/src/js/dashboard.js index bd9625a4fa8..3489b686e1b 100644 --- a/addons/board/static/src/js/dashboard.js +++ b/addons/board/static/src/js/dashboard.js @@ -419,8 +419,10 @@ instance.board.AddToDashboard = instance.web.search.Input.extend({ instance.web.SearchView.include({ add_common_inputs: function() { this._super(); - (new instance.board.AddToDashboard(this)); - + var vm = this.getParent().getParent(); + if (vm.inner_action && vm.inner_action.views) { + (new instance.board.AddToDashboard(this)); + } } }); diff --git a/addons/crm/__openerp__.py b/addons/crm/__openerp__.py index 0dd075d48e6..64bad21ede1 100644 --- a/addons/crm/__openerp__.py +++ b/addons/crm/__openerp__.py @@ -103,16 +103,16 @@ Dashboard for CRM will include: 'crm_action_rule_demo.xml', ], 'test': [ - 'test/process/communication_with_customer.yml', - 'test/process/lead2opportunity2win.yml', - 'test/process/lead2opportunity_assign_salesmen.yml', - 'test/process/merge_opportunity.yml', - 'test/process/cancel_lead.yml', - 'test/process/segmentation.yml', - 'test/process/phonecalls.yml', - 'test/ui/crm_demo.yml', - 'test/ui/duplicate_lead.yml', - 'test/ui/delete_lead.yml', + 'test/crm_lead_message.yml', + 'test/lead2opportunity2win.yml', + 'test/lead2opportunity_assign_salesmen.yml', + 'test/crm_lead_merge.yml', + 'test/crm_lead_cancel.yml', + 'test/segmentation.yml', + 'test/phonecalls.yml', + 'test/crm_lead_onchange.yml', + 'test/crm_lead_copy.yml', + 'test/crm_lead_unlink.yml', ], 'installable': True, 'application': True, diff --git a/addons/crm/crm_lead.py b/addons/crm/crm_lead.py index 56990f0e8f9..3f676329765 100644 --- a/addons/crm/crm_lead.py +++ b/addons/crm/crm_lead.py @@ -22,6 +22,7 @@ from openerp.addons.base_status.base_stage import base_stage import crm from datetime import datetime +from operator import itemgetter from openerp.osv import fields, osv import time from openerp import tools @@ -628,12 +629,13 @@ class crm_lead(base_stage, format_address, osv.osv): opportunities = self.browse(cr, uid, ids, context=context) sequenced_opps = [] for opportunity in opportunities: + sequence = -1 if opportunity.stage_id and opportunity.stage_id.state != 'cancel': - sequenced_opps.append((opportunity.stage_id.sequence, opportunity)) - else: - sequenced_opps.append((-1, opportunity)) - sequenced_opps.sort(key=lambda tup: tup[0], reverse=True) - opportunities = [opportunity for sequence, opportunity in sequenced_opps] + sequence = opportunity.stage_id.sequence + sequenced_opps.append(((int(sequence != -1 and opportunity.type == 'opportunity'), sequence, -opportunity.id), opportunity)) + + sequenced_opps.sort(reverse=True) + opportunities = map(itemgetter(1), sequenced_opps) ids = [opportunity.id for opportunity in opportunities] highest = opportunities[0] opportunities_rest = opportunities[1:] @@ -652,11 +654,10 @@ class crm_lead(base_stage, format_address, osv.osv): opportunities.extend(opportunities_rest) self._merge_notify(cr, uid, highest, opportunities, context=context) # Check if the stage is in the stages of the sales team. If not, assign the stage with the lowest sequence - if merged_data.get('type') == 'opportunity' and merged_data.get('section_id'): - section_stages = self.pool.get('crm.case.section').read(cr, uid, merged_data['section_id'], ['stage_ids'], context=context) - if merged_data.get('stage_id') not in section_stages['stage_ids']: - stages_sequences = self.pool.get('crm.case.stage').search(cr, uid, [('id','in',section_stages['stage_ids'])], order='sequence', limit=1, context=context) - merged_data['stage_id'] = stages_sequences and stages_sequences[0] or False + if merged_data.get('section_id'): + section_stage_ids = self.pool.get('crm.case.stage').search(cr, uid, [('section_ids', 'in', merged_data['section_id']), ('type', '=', merged_data.get('type'))], order='sequence', context=context) + if merged_data.get('stage_id') not in section_stage_ids: + merged_data['stage_id'] = section_stage_ids and section_stage_ids[0] or False # Write merged data into first opportunity self.write(cr, uid, [highest.id], merged_data, context=context) # Delete tail opportunities diff --git a/addons/crm/crm_lead_data.xml b/addons/crm/crm_lead_data.xml index 8ee352f25c0..e410cbe3d85 100644 --- a/addons/crm/crm_lead_data.xml +++ b/addons/crm/crm_lead_data.xml @@ -7,68 +7,68 @@ New draft - - + + both Opportunity open - - + + lead - - Qualification - - open - - - opportunity - - - Proposition - - open - - - opportunity - - - Negotiation - - open - - - opportunity - - - Won - - done - - - - opportunity - Dead cancel - - + + lead + + Qualification + + open + + + opportunity + + + Proposition + + open + + + opportunity + + + Negotiation + + open + + + opportunity + + + Won + + done + + + + opportunity + Lost cancel - - + + opportunity diff --git a/addons/crm/crm_lead_view.xml b/addons/crm/crm_lead_view.xml index df28d240a0c..894df92b70f 100644 --- a/addons/crm/crm_lead_view.xml +++ b/addons/crm/crm_lead_view.xml @@ -100,6 +100,7 @@