Removed billing from tasks

the new system is much more better

bzr revid: fp@tinyerp.com-20080904163238-twksm9h4sktf39z2
This commit is contained in:
Fabien Pinckaers 2008-09-04 18:32:38 +02:00
parent 98e61f2125
commit 07b1f0b9da
5 changed files with 3 additions and 208 deletions

View File

@ -63,9 +63,9 @@ class mrp_production_workcenter_line(osv.osv):
_columns = {
'state': fields.selection([('draft','Draft'),('confirm', 'Confirm'),('cancel','Canceled'),('done','Done')],'Status', readonly=True),
# 'date_start': fields.datetime('Start Date'),
# 'date_finnished': fields.datetime('End Date'),
# 'delay': fields.function(_calc_delay, method=True, string='Delay', help="This is delay between operation start and stop in this workcenter"),
'date_start': fields.datetime('Start Date'),
'date_finnished': fields.datetime('End Date'),
'delay': fields.function(_calc_delay, method=True, string='Delay', help="This is delay between operation start and stop in this workcenter"),
'delay': fields.float('delay', required=True),

View File

@ -121,17 +121,8 @@ class project(osv.osv):
'progress_rate': fields.function(_progress_rate, method=True, string='Progress', type='float'),
'date_start': fields.date('Project started on'),
'date_end': fields.date('Project should end on'),
'tariff': fields.float('Sales price'),
'mode': fields.selection([
('', ''),
('project', 'By Task'),
('hour', 'By Hour'),
('effective', 'By Effective Hour')
], 'Price setting mode'),
'partner_id': fields.many2one('res.partner', 'Customer'),
'contact_id': fields.many2one('res.partner.address', 'Contact'),
'pricelist_id': fields.many2one('product.pricelist', 'Pricelist'),
'tax_ids': fields.many2many('account.tax', 'project_account_tax_rel', 'project_id','tax_id', 'Applicable taxes'),
'warn_customer': fields.boolean('Warn customer'),
'warn_header': fields.text('Mail header'),
'warn_footer': fields.text('Mail footer'),
@ -250,8 +241,6 @@ class task(osv.osv):
'effective_hours': fields.function(_hours_effect, method=True, string='Eff. Hours'),
'progress_rate': fields.function(_progress_rate, method=True, string='Progress', type='float'),
'progress': fields.integer('Progress (0-100)'),
'billable': fields.boolean('To be invoiced'),
'invoice_id': fields.many2one('account.invoice','Generated Invoice'),
'user_id': fields.many2one('res.users', 'Assigned to'),
'partner_id': fields.many2one('res.partner', 'Customer'),
'work_ids': fields.one2many('project.task.work', 'task_id', 'Work done'),

View File

@ -38,8 +38,6 @@
<field name="category_id" select="2"/>
<field name="pricelist_id"/>
<field name="warn_customer"/>
<field name="mode"/>
<field name="tariff"/>
<separator colspan="4" string="Mail texts"/>
<field name="warn_header"/>
<field name="warn_footer"/>
@ -92,11 +90,9 @@
</page>
<page string="Others">
<separator colspan="4" string="Notes"/>
<field colspan="4" name="invoice_id" readonly="True"/>
<field colspan="4" name="notes" nolabel="1"/>
<newline/>
<field name="type"/>
<field name="billable" select="1"/>
<field name="start_sequence"/>
<field colspan="4" name="child_ids" nolabel="1">
<tree string="Delegated tasks">
@ -326,9 +322,6 @@
<field name="active" select="2"/>
<field name="start_sequence"/>
<field name="partner_id" select="2"/>
<newline/>
<field name="invoice_id"/>
<field name="billable" select="2"/>
<separator colspan="4" string="Notes"/>
<field colspan="4" name="notes" nolabel="1"/>
</page>
@ -379,26 +372,6 @@
</record>
<menuitem action="action_view_task" id="menu_action_view_task" parent="project.menu_main"/>
<record id="action_view_task2" model="ir.actions.act_window">
<field name="name">Unbilled closed tasks</field>
<field name="res_model">project.task</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="domain">[('state','=','done'), ('billable','=',True), ('invoice_id','=',False)]</field>
</record>
<menuitem groups="base.group_extended" id="menu_action_billable" name="Billable Tasks" parent="project.menu_action_view_task"/>
<menuitem action="action_view_task2" id="menu_action_view_task2" parent="project.menu_action_billable"/>
<record id="action_view_task3" model="ir.actions.act_window">
<field name="name">Unbilled open tasks</field>
<field name="res_model">project.task</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="domain">[('state','=','open'), ('billable','=',True), ('invoice_id','=',False)]</field>
</record>
<menuitem action="action_view_task3" id="menu_action_view_task3" parent="project.menu_action_billable"/>
<record id="action_view_task4" model="ir.actions.act_window">
<field name="name">My Tasks</field>
<field name="res_model">project.task</field>

View File

@ -28,10 +28,8 @@
#
##############################################################################
import billing
import close_task
import task_delegate
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -1,165 +0,0 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# Copyright (c) 2004-2008 TINY SPRL. (http://tiny.be) All Rights Reserved.
#
# $Id$
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
import wizard
import ir
from mx.DateTime import now
import pooler
import netsvc
bill_form = """<?xml version="1.0" ?>
<form string="Billing wizard">
<field name="journal_id"/>
<field name="sale_account_id"/>
<newline/>
<field name="task_total"/>
<field name="task_invoice"/>
<field name="invoice_num"/>
<field name="total"/>
</form>"""
bill_fields = {
'journal_id':{'string':'Journal', 'type':'many2one', 'relation':'account.journal', 'required': 'True'},
'sale_account_id':{'string':'Income account', 'type':'many2one', 'relation':'account.account', 'required': 'True'},
'invoice_num' : {'string':'Generated invoices', 'type': 'integer', 'readonly': 'True'},
'task_total' : {'string':'Number of tasks', 'type': 'integer', 'readonly': 'True'},
'task_invoice' : {'string':'Tasks to invoice', 'type': 'integer', 'readonly': 'True'},
'total' : {'string':'Total Price', 'type': 'float', 'readonly': 'True'},
}
ack_form = """<?xml version="1.0" ?>
<form string="Billing wizard">
<separator string="The orders were successfully generated" />
</form>"""
ack_fields = {}
def _compute_orders(self, cr, uid, data, context):
tasks = pooler.get_pool(cr.dbname).get('project.task').browse(cr, uid, data['ids'])
projects = {}
tot = 0.0
task_tot = 0
task_inv = 0
for task in tasks:
project = task.project_id
if not task.invoice_id and task.billable:
if project.mode == 'project':
tot += project.tariff
elif project.mode == 'effective':
tot += project.tariff * task.effective_hours
elif project.mode == 'hour':
tot += project.tariff * task.planned_hours
task_inv += 1
projects[project.id] = projects.get(project.id, []) + [task.id]
task_tot += 1
res = {'invoice_num': len(projects), 'total': tot, 'task_total': task_tot, 'task_invoice':task_inv}
return res
def _do_orders(self, cr, uid, data, context):
tasks = pooler.get_pool(cr.dbname).get('project.task').browse(cr, uid, data['ids'])
invoiceline = pooler.get_pool(cr.dbname).get('account.invoice.line')
customers = {}
for task in filter(lambda t: t.billable and not t.invoice_id, tasks):
if not task.project_id.id in customers:
partner = task.partner_id or task.project_id.partner_id
if not partner.id:
raise wizard.except_wizard(_('Error !'), _('No partner defined for the task or project.'))
if not task.project_id.pricelist_id.id:
raise wizard.except_wizard(_('Error !'), _('No pricelist defined in the project definition.'))
adr = pooler.get_pool(cr.dbname).get('res.partner').address_get(cr, uid, [partner.id], ['default','invoice','shipping'])
a = partner.property_account_receivable.id
if partner.property_payment_term:
pay_term = partner.property_payment_term.id
else:
pay_term = False
oid = pooler.get_pool(cr.dbname).get('account.invoice').create(cr, uid, {
'name': task.project_id.name,
'origin': 'Task:'+str(task.id),
'state': 'draft',
'partner_id': partner.id,
'address_contact_id': adr['default'],
'address_invoice_id': adr['invoice'],
'account_id': a,
'type': 'out_invoice',
'currency_id': task.project_id.pricelist_id.currency_id.id,
'payment_term': pay_term,
'journal_id': data['form']['journal_id'],
})
customers[task.project_id.id] = oid
else:
oid = customers[task.project_id.id]
if task.project_id.mode == 'project':
qty = 1
elif task.project_id.mode == 'effective':
qty = task.effective_hours
else:
qty = task.planned_hours
invoiceline.create(cr, uid, {
'invoice_id': oid,
'name': task.name,
'account_id': data['form']['sale_account_id'],
'price_unit': task.project_id.tariff,
'quantity': qty,
'invoice_line_tax_id': [(6,0, [t.id for t in task.project_id.tax_ids])],
'account_analytic_id': task.project_id.category_id.id,
})
#pooler.get_pool(cr.dbname).get('project.task').write(cr, uid, [task.id], {'invoice_id':oid})
return {
'domain': "[('id','in', ["+','.join(map(str,customers.values()))+"])]",
'name': 'Invoices',
'view_type': 'form',
'view_mode': 'tree,form',
'res_model': 'account.invoice',
'view_id': False,
'context': "{'type':'out_invoice'}",
'type': 'ir.actions.act_window'
}
class wiz_bill(wizard.interface):
states = {
'init':{
'actions': [_compute_orders],
'result': {'type':'form', 'arch':bill_form, 'fields':bill_fields, 'state':[('end', 'Cancel'), ('bill', 'Ok')] },
},
'bill':{
'actions': [],
'result': {'type':'action', 'action':_do_orders, 'state':'end' },
},
}
wiz_bill('project.wiz_bill')
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: