Merged from 5.0 : April 8 8PM IST
bzr revid: jvo@tinyerp.com-20090408135303-7tmposga83ivk96b bzr revid: jvo@tinyerp.com-20090408143915-7w9cxn7qthqdch46
This commit is contained in:
@@ -48,6 +48,21 @@ class account_analytic_line(osv.osv):
|
||||
'date': lambda *a: time.strftime('%Y-%m-%d'),
|
||||
}
|
||||
_order = 'date'
|
||||
|
||||
|
||||
def search(self, cr, uid, args, offset=0, limit=None, order=None, context=None):
|
||||
if context is None:
|
||||
context = {}
|
||||
|
||||
if context.get('from_date',False):
|
||||
args.append(['date', '>=',context['from_date']])
|
||||
|
||||
if context.get('to_date',False):
|
||||
args.append(['date','<=',context['to_date']])
|
||||
|
||||
return super(account_analytic_line, self).search(cr, uid, args, offset, limit,
|
||||
order, context=context)
|
||||
|
||||
def _check_company(self, cr, uid, ids):
|
||||
lines = self.browse(cr, uid, ids)
|
||||
for l in lines:
|
||||
|
||||
@@ -121,7 +121,7 @@
|
||||
<field name="amount_untaxed" sum="Untaxed amount"/>
|
||||
<field name="amount_total" sum="Total amount"/>
|
||||
<field name="currency_id"/>
|
||||
<field name="date_invoice"/>
|
||||
<field name="date_invoice" select="1"/>
|
||||
<field name="date_due" select="1"/>
|
||||
<field name="residual"/>
|
||||
<field name="state"/>
|
||||
|
||||
@@ -290,30 +290,15 @@ class account_invoice(osv.osv):
|
||||
}
|
||||
|
||||
def unlink(self, cr, uid, ids, context=None):
|
||||
for inv in self.browse(cr, uid, ids, context):
|
||||
print inv.name, inv.amount_total
|
||||
for line in inv.invoice_line:
|
||||
print line.price_subtotal
|
||||
# invoices = self.read(cr, uid, ids, ['state'])
|
||||
# unlink_ids = []
|
||||
# for t in invoices:
|
||||
# if t['state'] in ('draft', 'cancel'):
|
||||
# unlink_ids.append(t['id'])
|
||||
# else:
|
||||
# raise osv.except_osv(_('Invalid action !'), _('Cannot delete invoice(s) that are already opened or paid !'))
|
||||
# osv.osv.unlink(self, cr, uid, unlink_ids, context=context)
|
||||
# return True
|
||||
|
||||
#def unlink(self, cr, uid, ids, context=None):
|
||||
# invoices = self.read(cr, uid, ids, ['state'])
|
||||
# unlink_ids = []
|
||||
# for t in invoices:
|
||||
# if t['state'] in ('draft', 'cancel'):
|
||||
# unlink_ids.append(t['id'])
|
||||
# else:
|
||||
# raise osv.except_osv(_('Invalid action !'), _('Cannot delete invoice(s) that are already opened or paid !'))
|
||||
# osv.osv.unlink(self, cr, uid, unlink_ids, context=context)
|
||||
# return True
|
||||
invoices = self.read(cr, uid, ids, ['state'])
|
||||
unlink_ids = []
|
||||
for t in invoices:
|
||||
if t['state'] in ('draft', 'cancel'):
|
||||
unlink_ids.append(t['id'])
|
||||
else:
|
||||
raise osv.except_osv(_('Invalid action !'), _('Cannot delete invoice(s) that are already opened or paid !'))
|
||||
osv.osv.unlink(self, cr, uid, unlink_ids, context=context)
|
||||
return True
|
||||
|
||||
# def get_invoice_address(self, cr, uid, ids):
|
||||
# res = self.pool.get('res.partner').address_get(cr, uid, [part], ['invoice'])
|
||||
|
||||
@@ -36,8 +36,15 @@ class account_analytic_account(osv.osv):
|
||||
|
||||
def _credit_calc(self, cr, uid, ids, name, arg, context={}):
|
||||
acc_set = ",".join(map(str, ids))
|
||||
cr.execute("SELECT a.id, COALESCE(SUM(l.amount),0) FROM account_analytic_account a LEFT JOIN account_analytic_line l ON (a.id=l.account_id) WHERE l.amount<0 and a.id IN (%s) GROUP BY a.id" % acc_set)
|
||||
r= dict(cr.fetchall())
|
||||
|
||||
where_date = ''
|
||||
if context.get('from_date',False):
|
||||
where_date += " AND l.date >= '" + context['from_date'] + "'"
|
||||
if context.get('to_date',False):
|
||||
where_date += " AND l.date <= '" + context['to_date'] + "'"
|
||||
|
||||
cr.execute("SELECT a.id, COALESCE(SUM(l.amount),0) FROM account_analytic_account a LEFT JOIN account_analytic_line l ON (a.id=l.account_id %s) WHERE l.amount<0 and a.id IN (%s) GROUP BY a.id" % (where_date,acc_set))
|
||||
r = dict(cr.fetchall())
|
||||
for i in ids:
|
||||
r.setdefault(i,0.0)
|
||||
return r
|
||||
@@ -45,18 +52,30 @@ class account_analytic_account(osv.osv):
|
||||
def _debit_calc(self, cr, uid, ids, name, arg, context={}):
|
||||
|
||||
acc_set = ",".join(map(str, ids))
|
||||
cr.execute("SELECT a.id, COALESCE(SUM(l.amount),0) FROM account_analytic_account a LEFT JOIN account_analytic_line l ON (a.id=l.account_id) WHERE l.amount>0 and a.id IN (%s) GROUP BY a.id" % acc_set)
|
||||
|
||||
where_date = ''
|
||||
if context.get('from_date',False):
|
||||
where_date += " AND l.date >= '" + context['from_date'] + "'"
|
||||
if context.get('to_date',False):
|
||||
where_date += " AND l.date <= '" + context['to_date'] + "'"
|
||||
|
||||
cr.execute("SELECT a.id, COALESCE(SUM(l.amount),0) FROM account_analytic_account a LEFT JOIN account_analytic_line l ON (a.id=l.account_id %s) WHERE l.amount>0 and a.id IN (%s) GROUP BY a.id" % (where_date,acc_set))
|
||||
r= dict(cr.fetchall())
|
||||
for i in ids:
|
||||
r.setdefault(i,0.0)
|
||||
return r
|
||||
|
||||
|
||||
|
||||
def _balance_calc(self, cr, uid, ids, name, arg, context={}):
|
||||
ids2 = self.search(cr, uid, [('parent_id', 'child_of', ids)])
|
||||
acc_set = ",".join(map(str, ids2))
|
||||
cr.execute("SELECT a.id, COALESCE(SUM(l.amount),0) FROM account_analytic_account a LEFT JOIN account_analytic_line l ON (a.id=l.account_id) WHERE a.id IN (%s) GROUP BY a.id" % acc_set)
|
||||
|
||||
where_date = ''
|
||||
if context.get('from_date',False):
|
||||
where_date += " AND l.date >= '" + context['from_date'] + "'"
|
||||
if context.get('to_date',False):
|
||||
where_date += " AND l.date <= '" + context['to_date'] + "'"
|
||||
|
||||
cr.execute("SELECT a.id, COALESCE(SUM(l.amount),0) FROM account_analytic_account a LEFT JOIN account_analytic_line l ON (a.id=l.account_id %s) WHERE a.id IN (%s) GROUP BY a.id" % (where_date,acc_set))
|
||||
res = {}
|
||||
for account_id, sum in cr.fetchall():
|
||||
res[account_id] = sum
|
||||
@@ -86,9 +105,16 @@ class account_analytic_account(osv.osv):
|
||||
#XXX must convert into one uom
|
||||
ids2 = self.search(cr, uid, [('parent_id', 'child_of', ids)])
|
||||
acc_set = ",".join(map(str, ids2))
|
||||
|
||||
where_date = ''
|
||||
if context.get('from_date',False):
|
||||
where_date += " AND l.date >= '" + context['from_date'] + "'"
|
||||
if context.get('to_date',False):
|
||||
where_date += " AND l.date <= '" + context['to_date'] + "'"
|
||||
|
||||
cr.execute('SELECT a.id, COALESCE(SUM(l.unit_amount), 0) \
|
||||
FROM account_analytic_account a \
|
||||
LEFT JOIN account_analytic_line l ON (a.id = l.account_id) \
|
||||
LEFT JOIN account_analytic_line l ON (a.id = l.account_id ' + where_date + ') \
|
||||
WHERE a.id IN ('+acc_set+') GROUP BY a.id')
|
||||
res = {}
|
||||
for account_id, sum in cr.fetchall():
|
||||
@@ -168,7 +194,7 @@ class account_analytic_account(osv.osv):
|
||||
|
||||
_order = 'parent_id desc,code'
|
||||
_constraints = [
|
||||
(check_recursion, 'Error! You can not create recursive account.', ['parent_id'])
|
||||
(check_recursion, 'Error! You can not create recursive analytic accounts.', ['parent_id'])
|
||||
]
|
||||
|
||||
def create(self, cr, uid, vals, context=None):
|
||||
|
||||
@@ -94,8 +94,11 @@
|
||||
action="action_account_analytic_account_tree2"
|
||||
id="account_analytic_def_chart"
|
||||
parent="account_analytic_def_account"/>
|
||||
<menuitem action="action_account_analytic_account_tree2" id="account_analytic_chart" parent="account.menu_finance_charts"/>
|
||||
|
||||
<!-- <menuitem action="action_account_analytic_account_tree2" id="account_analytic_chart" parent="account.menu_finance_charts"/>-->
|
||||
|
||||
<wizard id="wizard_analytic_account_chart" menu="False" model="account.analytic.account" name="account.analytic.account.chart" string="Analytic Chart of Accounts"/>
|
||||
<menuitem icon="STOCK_INDENT" action="wizard_analytic_account_chart" id="menu_action_analytic_account_tree2" parent="account.menu_finance_charts" type="wizard"/>
|
||||
|
||||
<record id="analytic_account_form" model="ir.actions.act_window">
|
||||
<field name="name">New Analytic Account</field>
|
||||
<field name="res_model">account.analytic.account</field>
|
||||
|
||||
@@ -27,6 +27,7 @@ import wizard_account_analytic_cost_ledger_report
|
||||
import wizard_account_analytic_cost_ledger_for_journal_report
|
||||
import wizard_account_analytic_analytic_check
|
||||
import wizard_account_analytic_line
|
||||
import wizard_analytic_account_chart
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
||||
|
||||
@@ -26,15 +26,15 @@ import time
|
||||
from tools.translate import _
|
||||
|
||||
def _action_open_window(self, cr, uid, data, context):
|
||||
domain=[]
|
||||
from_date= data['form']['from_date']
|
||||
to_date=data['form']['to_date']
|
||||
domain = []
|
||||
from_date = data['form']['from_date']
|
||||
to_date = data['form']['to_date']
|
||||
if from_date and to_date:
|
||||
domain=[('date','>=',from_date),('date','<=',to_date)]
|
||||
domain = [('date','>=',from_date),('date','<=',to_date)]
|
||||
elif from_date:
|
||||
domain=[('date','>=',from_date)]
|
||||
domain = [('date','>=',from_date)]
|
||||
elif to_date:
|
||||
domain=[('date','<=',to_date)]
|
||||
domain = [('date','<=',to_date)]
|
||||
return {
|
||||
'name': _('Analytic Entries'),
|
||||
'view_type': 'form',
|
||||
|
||||
@@ -0,0 +1,79 @@
|
||||
# -*- encoding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). All Rights Reserved
|
||||
# $Id$
|
||||
#
|
||||
# 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 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 General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
import wizard
|
||||
import pooler
|
||||
|
||||
class wizard_analytic_account_chart(wizard.interface):
|
||||
_account_chart_arch = '''<?xml version="1.0"?>
|
||||
<form string="Analytic Account Charts">
|
||||
<separator string="Select the Period for Analysis" colspan="4"/>
|
||||
<field name="from_date"/>
|
||||
<newline/>
|
||||
<field name="to_date"/>
|
||||
<newline/>
|
||||
<label string="(Keep empty to open the current situation)" align="0.0" colspan="3"/>
|
||||
</form>'''
|
||||
|
||||
_account_chart_fields = {
|
||||
'from_date': {
|
||||
'string': 'From',
|
||||
'type': 'date',
|
||||
},
|
||||
'to_date': {
|
||||
'string': 'To',
|
||||
'type': 'date',
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
def _analytic_account_chart_open_window(self, cr, uid, data, context):
|
||||
mod_obj = pooler.get_pool(cr.dbname).get('ir.model.data')
|
||||
act_obj = pooler.get_pool(cr.dbname).get('ir.actions.act_window')
|
||||
|
||||
result = mod_obj._get_id(cr, uid, 'account', 'action_account_analytic_account_tree2')
|
||||
id = mod_obj.read(cr, uid, [result], ['res_id'])[0]['res_id']
|
||||
result = act_obj.read(cr, uid, [id], context=context)[0]
|
||||
|
||||
result_context = {}
|
||||
if data['form']['from_date']:
|
||||
result_context.update({'from_date' : data['form']['from_date']})
|
||||
if data['form']['to_date']:
|
||||
result_context.update({'to_date' : data['form']['to_date']})
|
||||
|
||||
result['context'] = str(result_context)
|
||||
return result
|
||||
|
||||
states = {
|
||||
'init': {
|
||||
'actions': [],
|
||||
'result': {'type': 'form', 'arch':_account_chart_arch, 'fields':_account_chart_fields, 'state': [('end', 'Cancel'), ('open', 'Open Charts')]}
|
||||
},
|
||||
'open': {
|
||||
'actions': [],
|
||||
'result': {'type': 'action', 'action':_analytic_account_chart_open_window, 'state':'end'}
|
||||
}
|
||||
}
|
||||
wizard_analytic_account_chart('account.analytic.account.chart')
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
<field name="name">account.analytic.account.form</field>
|
||||
<field name="model">account.analytic.account</field>
|
||||
<field name="type">form</field>
|
||||
<field name="inherit_id" ref="account.view_account_analytic_account_form"/>
|
||||
<field name="inherit_id" ref="hr_timesheet_invoice.account_analytic_account_form_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//field[@name='to_invoice']" position="after">
|
||||
<!--<field name="to_invoice" string="Default Invoicing Percentage"/>-->
|
||||
|
||||
+6
-3
@@ -510,7 +510,7 @@ class crm_case(osv.osv):
|
||||
return True
|
||||
|
||||
def format_body(self, body):
|
||||
return tools.ustr((body or '').encode('ascii', 'replace'))
|
||||
return (body or u'').encode('utf8', 'replace')
|
||||
|
||||
def format_mail(self, case, body):
|
||||
data = {
|
||||
@@ -526,7 +526,7 @@ class crm_case(osv.osv):
|
||||
'partner': (case.partner_id and case.partner_id.name) or '/',
|
||||
'partner_email': (case.partner_address_id and case.partner_address_id.email) or '/',
|
||||
}
|
||||
return self.format_body(body) % data
|
||||
return self.format_body(body % data)
|
||||
|
||||
def email_send(self, cr, uid, case, emails, body, context={}):
|
||||
body = self.format_mail(case, body)
|
||||
@@ -534,7 +534,10 @@ class crm_case(osv.osv):
|
||||
emailfrom = case.user_id.address_id.email
|
||||
else:
|
||||
emailfrom = case.section_id.reply_to
|
||||
tools.email_send(emailfrom, emails, '['+str(case.id)+'] '+case.name, body, reply_to=case.section_id.reply_to, tinycrm=str(case.id))
|
||||
name = '[%d] %s' % (case.id, case.name.encode('utf8'))
|
||||
reply_to = case.section_id.reply_to or False
|
||||
if reply_to: reply_to = reply_to.encode('utf8')
|
||||
tools.email_send(emailfrom, emails, name, body, reply_to=reply_to, tinycrm=str(case.id))
|
||||
return True
|
||||
def __log(self, cr, uid, cases, keyword, context={}):
|
||||
if not self.pool.get('res.partner.event.type').check(cr, uid, 'crm_case_'+keyword):
|
||||
|
||||
@@ -137,7 +137,7 @@ class sale_order_line(osv.osv):
|
||||
def product_id_change(self, cr, uid, ids, pricelist, product, qty=0,
|
||||
uom=False, qty_uos=0, uos=False, name='', partner_id=False,
|
||||
lang=False, update_tax=True, date_order=False, packaging=False,
|
||||
fiscal_position=False):
|
||||
fiscal_position=False, flag=False):
|
||||
warning = {}
|
||||
if not product:
|
||||
return {'value': {'th_weight' : 0, 'product_packaging': False,
|
||||
@@ -152,7 +152,7 @@ class sale_order_line(osv.osv):
|
||||
message= product_info.sale_line_warn_msg
|
||||
result = super(sale_order_line, self).product_id_change( cr, uid, ids, pricelist, product, qty,
|
||||
uom, qty_uos, uos, name, partner_id,
|
||||
lang, update_tax, date_order, packaging, fiscal_position)
|
||||
lang, update_tax, date_order, packaging, fiscal_position, flag)
|
||||
if title and message:
|
||||
warning['title']=title[0]
|
||||
warning['message']=message
|
||||
|
||||
Reference in New Issue
Block a user