diff --git a/addons/account/account.py b/addons/account/account.py index 9cc6023375e..58c4cf447ef 100644 --- a/addons/account/account.py +++ b/addons/account/account.py @@ -1680,7 +1680,7 @@ class account_move_reconcile(osv.osv): elif reconcile.line_partial_ids: first_partner = reconcile.line_partial_ids[0].partner_id.id move_lines = reconcile.line_partial_ids - if any([line.partner_id.id != first_partner for line in move_lines]): + if any([(line.account_id.type in ('receivable', 'payable') and line.partner_id.id != first_partner) for line in move_lines]): return False return True diff --git a/addons/account_report_company/account_report_company.py b/addons/account_report_company/account_report_company.py index 0c102fcc4e1..eacee60e13c 100644 --- a/addons/account_report_company/account_report_company.py +++ b/addons/account_report_company/account_report_company.py @@ -30,7 +30,7 @@ class res_partner(osv.Model): _display_name_store_triggers = { 'res.partner': (lambda self,cr,uid,ids,context=None: self.search(cr, uid, [('id','child_of',ids)]), - ['parent_id', 'is_company'], 10) + ['parent_id', 'is_company', 'name'], 10) } # indirection to avoid passing a copy of the overridable method when declaring the function field diff --git a/addons/account_voucher/account_voucher.py b/addons/account_voucher/account_voucher.py index dd8bb157067..9e0e7e5b167 100644 --- a/addons/account_voucher/account_voucher.py +++ b/addons/account_voucher/account_voucher.py @@ -1167,8 +1167,13 @@ class account_voucher(osv.osv): amount_currency = sign * (line.amount) elif line.move_line_id.currency_id.id == voucher_brw.payment_rate_currency_id.id: # if the rate is specified on the voucher, we must use it - voucher_rate = currency_obj.browse(cr, uid, voucher_currency, context=ctx).rate - amount_currency = (move_line['debit'] - move_line['credit']) * voucher_brw.payment_rate * voucher_rate + payment_rate = voucher_brw.payment_rate + if voucher_currency != company_currency: + #if the voucher currency is not the company currency, we need to consider the rate of the line's currency + voucher_rate = currency_obj.browse(cr, uid, voucher_currency, context=ctx).rate + payment_rate = voucher_rate * payment_rate + amount_currency = (move_line['debit'] - move_line['credit']) * payment_rate + else: # otherwise we use the rates of the system (giving the voucher date in the context) amount_currency = currency_obj.compute(cr, uid, company_currency, line.move_line_id.currency_id.id, move_line['debit']-move_line['credit'], context=ctx) diff --git a/addons/hr_timesheet/hr_timesheet.py b/addons/hr_timesheet/hr_timesheet.py index 6a538e5d09c..461507f9e41 100644 --- a/addons/hr_timesheet/hr_timesheet.py +++ b/addons/hr_timesheet/hr_timesheet.py @@ -37,8 +37,8 @@ class hr_employee(osv.osv): def _getAnalyticJournal(self, cr, uid, context=None): md = self.pool.get('ir.model.data') try: - result = md.get_object_reference(cr, uid, 'hr_timesheet', 'analytic_journal') - return result[1] + dummy, res_id = md.check_object_reference(cr, uid, 'hr_timesheet', 'analytic_journal') + return res_id except ValueError: pass return False @@ -46,8 +46,8 @@ class hr_employee(osv.osv): def _getEmployeeProduct(self, cr, uid, context=None): md = self.pool.get('ir.model.data') try: - result = md.get_object_reference(cr, uid, 'product', 'product_product_consultant') - return result[1] + dummy, res_id = md.check_object_reference(cr, uid, 'product', 'product_product_consultant') + return res_id except ValueError: pass return False diff --git a/addons/hr_timesheet_invoice/__openerp__.py b/addons/hr_timesheet_invoice/__openerp__.py index 888902e1484..d15dd3b0e3b 100644 --- a/addons/hr_timesheet_invoice/__openerp__.py +++ b/addons/hr_timesheet_invoice/__openerp__.py @@ -46,6 +46,7 @@ reports.""", 'report/hr_timesheet_invoice_report_view.xml', 'wizard/hr_timesheet_analytic_profit_view.xml', 'wizard/hr_timesheet_invoice_create_view.xml', + 'wizard/hr_timesheet_invoice_create_final_view.xml', ], 'demo': ['hr_timesheet_invoice_demo.xml'], 'test': ['test/test_hr_timesheet_invoice.yml', diff --git a/addons/hr_timesheet_invoice/wizard/__init__.py b/addons/hr_timesheet_invoice/wizard/__init__.py index 092ea8bbd7b..b718be1acbb 100644 --- a/addons/hr_timesheet_invoice/wizard/__init__.py +++ b/addons/hr_timesheet_invoice/wizard/__init__.py @@ -21,6 +21,7 @@ import hr_timesheet_invoice_create import hr_timesheet_analytic_profit +import hr_timesheet_final_invoice_create # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/hr_timesheet_invoice/wizard/hr_timesheet_final_invoice_create.py b/addons/hr_timesheet_invoice/wizard/hr_timesheet_final_invoice_create.py new file mode 100644 index 00000000000..1977d6cccc5 --- /dev/null +++ b/addons/hr_timesheet_invoice/wizard/hr_timesheet_final_invoice_create.py @@ -0,0 +1,63 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2004-2010 Tiny SPRL (). +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## + +import time + +from openerp.osv import fields, osv +from openerp.tools.translate import _ + +# +# Create an final invoice based on selected timesheet lines +# + +# +# TODO: check unit of measure !!! +# +class final_invoice_create(osv.osv_memory): + _name = 'hr.timesheet.invoice.create.final' + _description = 'Create invoice from timesheet final' + _columns = { + 'date': fields.boolean('Date', help='Display date in the history of works'), + 'time': fields.boolean('Time Spent', help='Display time in the history of works'), + 'name': fields.boolean('Log of Activity', help='Display detail of work in the invoice line.'), + 'price': fields.boolean('Cost', help='Display cost of the item you reinvoice'), + 'product': fields.many2one('product.product', 'Product', help='The product that will be used to invoice the remaining amount'), + } + + def do_create(self, cr, uid, ids, context=None): + data = self.read(cr, uid, ids, [], context=context)[0] + # hack for fixing small issue (context should not propagate implicitly between actions) + if 'default_type' in context: + del context['default_type'] + ids = self.pool.get('account.analytic.line').search(cr, uid, [('invoice_id','=',False),('to_invoice','<>', False), ('account_id', 'in', context['active_ids'])], context=context) + invs = self.pool.get('account.analytic.line').invoice_cost_create(cr, uid, ids, data, context=context) + mod_obj = self.pool.get('ir.model.data') + act_obj = self.pool.get('ir.actions.act_window') + mod_ids = mod_obj.search(cr, uid, [('name', '=', 'action_invoice_tree1')], context=context)[0] + res_id = mod_obj.read(cr, uid, mod_ids, ['res_id'], context=context)['res_id'] + act_win = act_obj.read(cr, uid, res_id, [], context=context) + act_win['domain'] = [('id','in',invs),('type','=','out_invoice')] + act_win['name'] = _('Invoices') + return act_win + +final_invoice_create() + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/hr_timesheet_invoice/wizard/hr_timesheet_invoice_create_final_view.xml b/addons/hr_timesheet_invoice/wizard/hr_timesheet_invoice_create_final_view.xml new file mode 100644 index 00000000000..d1c95212139 --- /dev/null +++ b/addons/hr_timesheet_invoice/wizard/hr_timesheet_invoice_create_final_view.xml @@ -0,0 +1,52 @@ + + + + + Create Invoice + ir.actions.act_window + hr.timesheet.invoice.create.final + form + form + new + + + + + + Invoice + client_action_multi + + action + account.analytic.account + + + + + hr.timesheet.invoice.create.final.form + hr.timesheet.invoice.create.final + +
+

Do you want to show details of each activity to your customer?

+ + + + + + + + + + + + +
+
+
+
+
+ +
+
diff --git a/addons/note/note.py b/addons/note/note.py index 2d95b15107a..eb9a6397d18 100644 --- a/addons/note/note.py +++ b/addons/note/note.py @@ -141,12 +141,19 @@ class note_note(osv.osv): #note without user's stage nb_notes_ws = self.search(cr,uid, domain+[('stage_ids', 'not in', current_stage_ids)], context=context, count=True) if nb_notes_ws: - result += [{ #notes for unknown stage and if stage_ids is not empty - '__context': {'group_by': groupby[1:]}, - '__domain': domain + [('stage_ids', 'not in', current_stage_ids)], - 'stage_id': (0, 'Unknown'), - 'stage_id_count':nb_notes_ws - }] + # add note to the first column if it's the first stage + dom_not_in = ('stage_ids', 'not in', current_stage_ids) + if result and result[0]['stage_id'][0] == current_stage_ids[0]: + dom_in = result[0]['__domain'].pop() + result[0]['__domain'] = domain + ['|', dom_in, dom_not_in] + else: + # add the first stage column + result = [{ + '__context': {'group_by': groupby[1:]}, + '__domain': domain + [dom_not_in], + 'stage_id': (current_stage_ids[0], stage_name[current_stage_ids[0]]), + 'stage_id_count':nb_notes_ws + }] + result else: # if stage_ids is empty @@ -156,7 +163,7 @@ class note_note(osv.osv): result = [{ #notes for unknown stage '__context': {'group_by': groupby[1:]}, '__domain': domain, - 'stage_id': (0, 'Unknown'), + 'stage_id': False, 'stage_id_count':nb_notes_ws }] else: @@ -187,9 +194,12 @@ class res_users(osv.Model): model_id = data_obj.get_object_reference(cr, uid, 'base', 'group_user') #Employee Group group_id = model_id and model_id[1] or False if group_id in [x.id for x in user.groups_id]: - for note_xml_id in ['note_stage_01','note_stage_02','note_stage_03','note_stage_04']: - data_id = data_obj._get_id(cr, uid, 'note', note_xml_id) + for note_xml_id in ['note_stage_00','note_stage_01','note_stage_02','note_stage_03','note_stage_04']: + try: + data_id = data_obj._get_id(cr, uid, 'note', note_xml_id) + except ValueError: + continue stage_id = data_obj.browse(cr, uid, data_id, context=context).res_id note_obj.copy(cr, uid, stage_id, default = { 'user_id': user_id}, context=context) - return user_id \ No newline at end of file + return user_id diff --git a/addons/note/note_data.xml b/addons/note/note_data.xml index 592292788b3..376b8e9053f 100644 --- a/addons/note/note_data.xml +++ b/addons/note/note_data.xml @@ -2,6 +2,12 @@ + + New + + + + Today 1