[MERGE]Merged with 7.0

bzr revid: dhr@tinyerp.com-20130424045245-ei1zkkddlwxgxzp6
This commit is contained in:
Dharti Ratani (Open ERP) 2013-04-24 10:22:45 +05:30
commit 4181fe91c3
10 changed files with 156 additions and 18 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -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:

View File

@ -0,0 +1,63 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
# 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 <http://www.gnu.org/licenses/>.
#
##############################################################################
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:

View File

@ -0,0 +1,52 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="action_hr_timesheet_invoice_create_final" model="ir.actions.act_window">
<field name="name">Create Invoice</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">hr.timesheet.invoice.create.final</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="target">new</field>
<field name="multi" eval="1"/>
</record>
<record model="ir.values" id="hr_timesheet_invoice_create_final_values">
<field name="model_id" ref="model_account_analytic_account" />
<field name="name">Invoice</field>
<field name="key2">client_action_multi</field>
<field name="value" eval="'ir.actions.act_window,' + str(ref('action_hr_timesheet_invoice_create_final'))" />
<field name="key">action</field>
<field name="model">account.analytic.account</field>
</record>
<record id="view_hr_timesheet_invoice_create_final" model="ir.ui.view">
<field name="name">hr.timesheet.invoice.create.final.form</field>
<field name="model">hr.timesheet.invoice.create.final</field>
<field name="arch" type="xml">
<form string="Invoice contract" version="7.0">
<p>Do you want to show details of each activity to your customer?</p>
<group>
<group>
<field name="date"/>
<field name="time"/>
</group><group>
<field name="name"/>
<field name="price"/>
</group>
</group>
<group string="Force to use a special product" groups="base.group_no_one">
<field name="product"/>
</group>
<footer>
<button name="do_create" string="Create Invoice" type="object" class="oe_highlight"/>
or
<button string="Cancel" class="oe_link" special="cancel" />
</footer>
</form>
</field>
</record>
</data>
</openerp>

View File

@ -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
return user_id

View File

@ -2,6 +2,12 @@
<openerp>
<data>
<record model="note.stage" id="note_stage_00">
<field name="name">New</field>
<field name="sequence" eval="0"/>
<field name="user_id" eval="ref('base.user_root')"/>
</record>
<record model="note.stage" id="note_stage_01">
<field name="name">Today</field>
<field name="sequence">1</field>