[REV] revert revision 9056 that was deleting a whole wizard. The patch is good but not applicable as it in the v7
bzr revid: qdp-launchpad@openerp.com-20130423144948-unekni1ztjwv71fb
This commit is contained in:
parent
5af43030d3
commit
e13dc082e5
|
@ -206,14 +206,17 @@ class account_analytic_account(osv.osv):
|
||||||
return res
|
return res
|
||||||
|
|
||||||
if child_ids:
|
if child_ids:
|
||||||
#Search all invoice lines not in cancelled state that refer to this analytic account
|
cr.execute("SELECT account_analytic_line.account_id, COALESCE(SUM(amount), 0.0) \
|
||||||
inv_line_obj = self.pool.get("account.invoice.line")
|
FROM account_analytic_line \
|
||||||
inv_lines = inv_line_obj.search(cr, uid, ['&', ('account_analytic_id', 'in', child_ids), ('invoice_id.state', '!=', 'cancel')], context=context)
|
JOIN account_analytic_journal \
|
||||||
for line in inv_line_obj.browse(cr, uid, inv_lines, context=context):
|
ON account_analytic_line.journal_id = account_analytic_journal.id \
|
||||||
res[line.account_analytic_id.id] += line.price_subtotal
|
WHERE account_analytic_line.account_id IN %s \
|
||||||
|
AND account_analytic_journal.type = 'sale' \
|
||||||
|
GROUP BY account_analytic_line.account_id", (child_ids,))
|
||||||
|
for account_id, sum in cr.fetchall():
|
||||||
|
res[account_id] = round(sum,2)
|
||||||
for acc in self.browse(cr, uid, res.keys(), context=context):
|
for acc in self.browse(cr, uid, res.keys(), context=context):
|
||||||
res[acc.id] = res[acc.id] - (acc.timesheet_ca_invoiced or 0.0)
|
res[acc.id] = res[acc.id] - (acc.timesheet_ca_invoiced or 0.0)
|
||||||
|
|
||||||
res_final = res
|
res_final = res
|
||||||
return res_final
|
return res_final
|
||||||
|
|
||||||
|
@ -540,23 +543,6 @@ class account_analytic_account(osv.osv):
|
||||||
pass
|
pass
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
def hr_to_invoice_timesheets(self, cr, uid, ids, context=None):
|
|
||||||
domain = [('invoice_id','=',False),('to_invoice','!=',False), ('journal_id.type', '=', 'general'), ('account_id', 'in', ids)]
|
|
||||||
names = [record.name for record in self.browse(cr, uid, ids, context=context)]
|
|
||||||
name = _('Timesheets to Invoice of %s') % ','.join(names)
|
|
||||||
return {
|
|
||||||
'type': 'ir.actions.act_window',
|
|
||||||
'name': name,
|
|
||||||
'view_type': 'form',
|
|
||||||
'view_mode': 'tree,form',
|
|
||||||
'domain' : domain,
|
|
||||||
'res_model': 'account.analytic.line',
|
|
||||||
'nodestroy': True,
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class account_analytic_account_summary_user(osv.osv):
|
class account_analytic_account_summary_user(osv.osv):
|
||||||
_name = "account_analytic_analysis.summary.user"
|
_name = "account_analytic_analysis.summary.user"
|
||||||
_description = "Hours Summary by User"
|
_description = "Hours Summary by User"
|
||||||
|
|
|
@ -98,8 +98,8 @@
|
||||||
<field class="oe_inline" name="ca_to_invoice" attrs="{'invisible': [('invoice_on_timesheets','=',False)]}"/>
|
<field class="oe_inline" name="ca_to_invoice" attrs="{'invisible': [('invoice_on_timesheets','=',False)]}"/>
|
||||||
</td><td class="oe_timesheet_action" attrs="{'invisible': ['|',('invoice_on_timesheets','=',False),('type','=','template')]}">
|
</td><td class="oe_timesheet_action" attrs="{'invisible': ['|',('invoice_on_timesheets','=',False),('type','=','template')]}">
|
||||||
<span attrs="{'invisible': [('ca_to_invoice','=',0.0)]}" class="oe_grey">
|
<span attrs="{'invisible': [('ca_to_invoice','=',0.0)]}" class="oe_grey">
|
||||||
<button name="hr_to_invoice_timesheets"
|
<button name="%(hr_timesheet_invoice.action_hr_timesheet_invoice_create_final)d"
|
||||||
type="object"
|
type="action"
|
||||||
class="oe_link"
|
class="oe_link"
|
||||||
string="⇒ Invoice"/>
|
string="⇒ Invoice"/>
|
||||||
or view
|
or view
|
||||||
|
|
|
@ -46,6 +46,7 @@ reports.""",
|
||||||
'report/hr_timesheet_invoice_report_view.xml',
|
'report/hr_timesheet_invoice_report_view.xml',
|
||||||
'wizard/hr_timesheet_analytic_profit_view.xml',
|
'wizard/hr_timesheet_analytic_profit_view.xml',
|
||||||
'wizard/hr_timesheet_invoice_create_view.xml',
|
'wizard/hr_timesheet_invoice_create_view.xml',
|
||||||
|
'wizard/hr_timesheet_invoice_create_final_view.xml',
|
||||||
],
|
],
|
||||||
'demo': ['hr_timesheet_invoice_demo.xml'],
|
'demo': ['hr_timesheet_invoice_demo.xml'],
|
||||||
'test': ['test/test_hr_timesheet_invoice.yml',
|
'test': ['test/test_hr_timesheet_invoice.yml',
|
||||||
|
|
|
@ -103,3 +103,18 @@
|
||||||
assert aline.invoice_id == invoice_id, "Invoice doesn't match the one at analytic line"
|
assert aline.invoice_id == invoice_id, "Invoice doesn't match the one at analytic line"
|
||||||
assert invoice_id.amount_untaxed == 187.5, "Invoice amount mismatch: %s" % invoice_id.amount_untaxed
|
assert invoice_id.amount_untaxed == 187.5, "Invoice amount mismatch: %s" % invoice_id.amount_untaxed
|
||||||
assert invoice_id.amount_tax == 50, "Invoice tax mismatch: %s" % invoice_id.amount_tax
|
assert invoice_id.amount_tax == 50, "Invoice tax mismatch: %s" % invoice_id.amount_tax
|
||||||
|
-
|
||||||
|
I create final invoice for this analytic account.
|
||||||
|
-
|
||||||
|
!record {model: hr.timesheet.invoice.create.final, id: hr_timesheet_invoice_create_final_0}:
|
||||||
|
date: 1
|
||||||
|
name: 1
|
||||||
|
price: 1
|
||||||
|
time: 1
|
||||||
|
-
|
||||||
|
I click on "Create Invoice" button to create Invoice and validate the invoice.
|
||||||
|
-
|
||||||
|
!python {model: hr.timesheet.invoice.create.final}: |
|
||||||
|
import netsvc
|
||||||
|
wkf_service = netsvc.LocalService("workflow")
|
||||||
|
res = self.do_create(cr, uid, [ref("hr_timesheet_invoice_create_final_0")], {"active_ids": [ref("account.analytic_agrolait")]})
|
||||||
|
|
|
@ -102,3 +102,18 @@
|
||||||
assert aline.invoice_id == invoice_id, "Invoice doesn't match the one at analytic line"
|
assert aline.invoice_id == invoice_id, "Invoice doesn't match the one at analytic line"
|
||||||
assert invoice_id.amount_untaxed == 187.5, "Invoice amount mismatch: %s" % invoice_id.amount_untaxed
|
assert invoice_id.amount_untaxed == 187.5, "Invoice amount mismatch: %s" % invoice_id.amount_untaxed
|
||||||
assert invoice_id.amount_tax == 40, "Invoice tax mismatch: %s" % invoice_id.amount_tax
|
assert invoice_id.amount_tax == 40, "Invoice tax mismatch: %s" % invoice_id.amount_tax
|
||||||
|
-
|
||||||
|
I create final invoice for this analytic account.
|
||||||
|
-
|
||||||
|
!record {model: hr.timesheet.invoice.create.final, id: hr_timesheet_invoice_create_final_0}:
|
||||||
|
date: 1
|
||||||
|
name: 1
|
||||||
|
price: 1
|
||||||
|
time: 1
|
||||||
|
-
|
||||||
|
I click on "Create Invoice" button to create Invoice and validate the invoice.
|
||||||
|
-
|
||||||
|
!python {model: hr.timesheet.invoice.create.final}: |
|
||||||
|
import netsvc
|
||||||
|
wkf_service = netsvc.LocalService("workflow")
|
||||||
|
res = self.do_create(cr, uid, [ref("hr_timesheet_invoice_create_final_0")], {"active_ids": [ref("account.analytic_agrolait")]})
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
|
|
||||||
import hr_timesheet_invoice_create
|
import hr_timesheet_invoice_create
|
||||||
import hr_timesheet_analytic_profit
|
import hr_timesheet_analytic_profit
|
||||||
|
import hr_timesheet_final_invoice_create
|
||||||
|
|
||||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||||
|
|
||||||
|
|
|
@ -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:
|
|
@ -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>
|
Loading…
Reference in New Issue