bzr revid: chs@tinyerp.com-20090913213730-myosgkcltrmb66rq
This commit is contained in:
Christophe Simonis
2009-09-13 23:37:30 +02:00
27 changed files with 322 additions and 134 deletions
+1 -1
View File
@@ -1308,7 +1308,7 @@ class account_tax(osv.osv):
# we compute the amount for the current tax object and append it to the result
data = {'id':tax.id,
'name':tax.name,
'name':tax.description and tax.description + " - " + tax.name or tax.name,
'account_collected_id':tax.account_collected_id.id,
'account_paid_id':tax.account_paid_id.id,
'base_code_id': tax.base_code_id.id,
+16 -1
View File
@@ -213,6 +213,11 @@ class account_bank_statement(osv.osv):
amount = res_currency_obj.compute(cr, uid, st.currency.id,
company_currency_id, move.amount, context=context,
account=acc_cur)
if st.currency.id <> company_currency_id:
amount_cur = res_currency_obj.compute(cr, uid, company_currency_id,
st.currency.id, amount, context=context,
account=acc_cur)
val['amount_currency'] = -amount_cur
if move.account_id and move.account_id.currency_id and move.account_id.currency_id.id <> company_currency_id:
val['currency_id'] = move.account_id.currency_id.id
@@ -430,7 +435,17 @@ class account_bank_statement_reconcile(osv.osv):
def name_get(self, cursor, user, ids, context=None):
res= []
for o in self.browse(cursor, user, ids, context=context):
res.append((o.id, '[%.2f]' % (o.total_entry - o.total_new,)))
result = 0.0
res_currency = ''
for line in o.line_ids:
if line.amount_currency and line.currency_id:
result += line.amount_currency
res_currency = line.currency_id.code
else:
result += line.debit - line.credit
if res_currency:
res_currency = ' ' + res_currency
res.append((o.id, '[%.2f'% (result - o.total_new,) + res_currency + ']' ))
return res
_columns = {
+4
View File
@@ -221,6 +221,8 @@
<field name="journal_id"/>
<field name="debit"/>
<field name="credit"/>
<field name="amount_currency"/>
<field name="currency_id"/>
</tree>
</field>
</page>
@@ -306,6 +308,8 @@
<field name="journal_id" groups="base.group_user"/>
<field name="debit"/>
<field name="credit"/>
<field name="amount_currency"/>
<field name="currency_id"/>
</tree>
</field>
</page>
+9 -5
View File
@@ -107,8 +107,11 @@ class account_invoice(osv.osv):
paid_amt = 0.0
to_pay = inv.amount_total
for lines in inv.move_lines:
paid_amt = paid_amt - lines.credit + lines.debit
res[inv.id] = to_pay - abs(paid_amt)
if lines.amount_currency and lines.currency_id:
paid_amt += lines.amount_currency
else:
paid_amt += lines.credit + lines.debit
res[inv.id] = round(to_pay - abs(paid_amt),int(config['price_accuracy']))
return res
def _get_lines(self, cr, uid, ids, name, arg, context=None):
@@ -426,8 +429,9 @@ class account_invoice(osv.osv):
ait_obj = self.pool.get('account.invoice.tax')
for id in ids:
cr.execute("DELETE FROM account_invoice_tax WHERE invoice_id=%s", (id,))
partner = self.browse(cr, uid, id).partner_id
context.update({'lang': partner.lang})
partner = self.browse(cr, uid, id,context=context).partner_id
if partner.lang:
context.update({'lang': partner.lang})
for taxe in ait_obj.compute(cr, uid, id, context=context).values():
ait_obj.create(cr, uid, taxe)
# Update the stored value (fields.function), so we write to trigger recompute
@@ -892,7 +896,7 @@ class account_invoice(osv.osv):
if l.account_id.id==src_account_id:
line_ids.append(l.id)
total += (l.debit or 0.0) - (l.credit or 0.0)
if (not total) or writeoff_acc_id:
if (not round(total,int(config['price_accuracy']))) or writeoff_acc_id:
self.pool.get('account.move.line').reconcile(cr, uid, line_ids, 'manual', writeoff_acc_id, writeoff_period_id, writeoff_journal_id, context)
else:
self.pool.get('account.move.line').reconcile_partial(cr, uid, line_ids, 'manual', context)
+169 -81
View File
@@ -30,17 +30,50 @@ class account_analytic_balance(report_sxw.rml_parse):
super(account_analytic_balance, self).__init__(cr, uid, name, context)
self.localcontext.update( {
'time': time,
'get_objects': self._get_objects,
'lines_g': self._lines_g,
'move_sum_debit': self._move_sum_debit,
'move_sum_credit': self._move_sum_credit,
'sum_debit': self._sum_debit,
'sum_credit': self._sum_credit,
'move_sum': self._move_sum,
# 'move_sum_debit': self._move_sum_debit,
# 'move_sum_credit': self._move_sum_credit,
'sum_all': self._sum_all,
# 'sum_debit': self._sum_debit,
# 'sum_credit': self._sum_credit,
'sum_balance': self._sum_balance,
'sum_quantity': self._sum_quantity,
# 'sum_quantity': self._sum_quantity,
'move_sum_balance': self._move_sum_balance,
'move_sum_quantity': self._move_sum_quantity,
# 'move_sum_quantity': self._move_sum_quantity,
})
self.acc_ids = []
self.read_data = []
self.empty_acc = False
self.acc_data_dict = {}# maintains a relation with an account with its successors.
self.acc_sum_list = []# maintains a list of all ids
def get_children(self, ids):
ids2 = []
read_data = self.pool.get('account.analytic.account').read(self.cr, self.uid, ids,['child_ids','code','complete_name','balance'])
for data in read_data:
if (data['id'] not in self.acc_ids):
inculde_empty = True
if (not self.empty_acc) and data['balance'] == 0.00:
inculde_empty = False
if inculde_empty:
self.acc_ids.append(data['id'])
self.read_data.append(data)
if data['child_ids']:
res = self.get_children(data['child_ids'])
return True
def _get_objects(self, empty_acc):
if self.read_data:
return self.read_data
self.empty_acc = empty_acc
self.read_data = []
self.get_children(self.ids)
return self.read_data
def _lines_g(self, account_id, date1, date2):
account_analytic_obj = self.pool.get('account.analytic.account')
ids = account_analytic_obj.search(self.cr, self.uid,
@@ -68,93 +101,148 @@ class account_analytic_balance(report_sxw.rml_parse):
r['credit'] = 0.0
return res
def _move_sum_debit(self, account_id, date1, date2):
account_analytic_obj = self.pool.get('account.analytic.account')
ids = account_analytic_obj.search(self.cr, self.uid,
[('parent_id', 'child_of', [account_id])])
self.cr.execute("SELECT sum(amount) \
FROM account_analytic_line \
WHERE account_id in ("+ ','.join(map(str, ids)) +") \
AND date>=%s AND date<=%s AND amount>0",
(date1, date2))
return self.cr.fetchone()[0] or 0.0
def _move_sum_credit(self, account_id, date1, date2):
account_analytic_obj = self.pool.get('account.analytic.account')
ids = account_analytic_obj.search(self.cr, self.uid,
[('parent_id', 'child_of', [account_id])])
self.cr.execute("SELECT -sum(amount) \
FROM account_analytic_line \
WHERE account_id in ("+ ','.join(map(str, ids)) +") \
AND date>=%s AND date<=%s AND amount<0",
(date1, date2))
return self.cr.fetchone()[0] or 0.0
def _move_sum_balance(self, account_id, date1, date2):
debit = self._move_sum_debit(account_id, date1, date2)
credit = self._move_sum_credit(account_id, date1, date2)
return (debit-credit)
def _move_sum_quantity(self, account_id, date1, date2):
account_analytic_obj = self.pool.get('account.analytic.account')
ids = account_analytic_obj.search(self.cr, self.uid,
[('parent_id', 'child_of', [account_id])])
self.cr.execute("SELECT sum(unit_amount) \
FROM account_analytic_line \
def _move_sum(self, account_id, date1, date2, option):
if account_id not in self.acc_data_dict:
account_analytic_obj = self.pool.get('account.analytic.account')
ids = account_analytic_obj.search(self.cr, self.uid,[('parent_id', 'child_of', [account_id])])
self.acc_data_dict[account_id] = ids
else:
ids = self.acc_data_dict[account_id]
if option == "credit" :
self.cr.execute("SELECT -sum(amount) FROM account_analytic_line \
WHERE account_id in ("+ ','.join(map(str, ids)) +") \
AND date>=%s AND date<=%s AND amount<0",
(date1, date2))
elif option == "debit" :
self.cr.execute("SELECT sum(amount) FROM account_analytic_line \
WHERE account_id in ("+ ','.join(map(str, ids)) +") \
AND date>=%s AND date<=%s AND amount>0",
(date1, date2))
elif option == "quantity" :
self.cr.execute("SELECT sum(unit_amount) FROM account_analytic_line \
WHERE account_id in ("+ ','.join(map(str, ids)) +") \
AND date>=%s AND date<=%s",
(date1, date2))
return self.cr.fetchone()[0] or 0.0
def _sum_debit(self, accounts, date1, date2):
ids = map(lambda x: x.id, accounts)
if not len(ids):
return 0.0
account_analytic_obj = self.pool.get('account.analytic.account')
ids2 = account_analytic_obj.search(self.cr, self.uid,
[('parent_id', 'child_of', ids)])
self.cr.execute("SELECT sum(amount) \
FROM account_analytic_line \
WHERE account_id IN ("+','.join(map(str, ids2))+") \
AND date>=%s AND date<=%s AND amount>0",
(date1, date2))
return self.cr.fetchone()[0] or 0.0
def _sum_credit(self, accounts, date1, date2):
ids = map(lambda x: x.id, accounts)
# def _move_sum_debit(self, account_id, date1, date2):
# account_analytic_obj = self.pool.get('account.analytic.account')
# ids = account_analytic_obj.search(self.cr, self.uid,
# [('parent_id', 'child_of', [account_id])])
# self.cr.execute("SELECT sum(amount) \
# FROM account_analytic_line \
# WHERE account_id in ("+ ','.join(map(str, ids)) +") \
# AND date>=%s AND date<=%s AND amount>0",
# (date1, date2))
# return self.cr.fetchone()[0] or 0.0
#
# def _move_sum_credit(self, account_id, date1, date2):
# account_analytic_obj = self.pool.get('account.analytic.account')
# ids = account_analytic_obj.search(self.cr, self.uid,
# [('parent_id', 'child_of', [account_id])])
# self.cr.execute("SELECT -sum(amount) \
# FROM account_analytic_line \
# WHERE account_id in ("+ ','.join(map(str, ids)) +") \
# AND date>=%s AND date<=%s AND amount<0",
# (date1, date2))
# return self.cr.fetchone()[0] or 0.0
#
def _move_sum_balance(self, account_id, date1, date2):
debit = self._move_sum(account_id, date1, date2, 'debit')
credit = self._move_sum(account_id, date1, date2, 'credit')
return (debit-credit)
# def _move_sum_quantity(self, account_id, date1, date2):
# account_analytic_obj = self.pool.get('account.analytic.account')
# ids = account_analytic_obj.search(self.cr, self.uid,
# [('parent_id', 'child_of', [account_id])])
# self.cr.execute("SELECT sum(unit_amount) \
# FROM account_analytic_line \
# WHERE account_id in ("+ ','.join(map(str, ids)) +") \
# AND date>=%s AND date<=%s",
# (date1, date2))
# return self.cr.fetchone()[0] or 0.0
def _sum_all(self, accounts, date1, date2, option):
ids = map(lambda x: x['id'], accounts)
if not len(ids):
return 0.0
ids = map(lambda x: x.id, accounts)
account_analytic_obj = self.pool.get('account.analytic.account')
ids2 = account_analytic_obj.search(self.cr, self.uid,
[('parent_id', 'child_of', ids)])
self.cr.execute("SELECT -sum(amount) \
FROM account_analytic_line \
WHERE account_id IN ("+','.join(map(str, ids2))+") \
AND date>=%s AND date<=%s AND amount<0",
(date1, date2))
if not self.acc_sum_list:
account_analytic_obj = self.pool.get('account.analytic.account')
ids2 = account_analytic_obj.search(self.cr, self.uid,[('parent_id', 'child_of', ids)])
self.acc_sum_list = ids2
else:
ids2 = self.acc_sum_list
if option == "debit" :
self.cr.execute("SELECT sum(amount) FROM account_analytic_line \
WHERE account_id IN ("+','.join(map(str, ids2))+") \
AND date>=%s AND date<=%s AND amount>0",
(date1, date2))
elif option == "credit" :
self.cr.execute("SELECT -sum(amount) FROM account_analytic_line \
WHERE account_id IN ("+','.join(map(str, ids2))+") \
AND date>=%s AND date<=%s AND amount<0",
(date1, date2))
elif option == "quantity" :
self.cr.execute("SELECT sum(unit_amount) FROM account_analytic_line \
WHERE account_id IN ("+','.join(map(str, ids2))+") \
AND date>=%s AND date<=%s",
(date1, date2))
return self.cr.fetchone()[0] or 0.0
# def _sum_debit(self, accounts, date1, date2):
# ids = map(lambda x: x['id'], accounts)
# if not len(ids):
# return 0.0
# account_analytic_obj = self.pool.get('account.analytic.account')
# ids2 = account_analytic_obj.search(self.cr, self.uid,
# [('parent_id', 'child_of', ids)])
# self.cr.execute("SELECT sum(amount) \
# FROM account_analytic_line \
# WHERE account_id IN ("+','.join(map(str, ids2))+") \
# AND date>=%s AND date<=%s AND amount>0",
# (date1, date2))
# return self.cr.fetchone()[0] or 0.0
#
# def _sum_credit(self, accounts, date1, date2):
# ids = map(lambda x: x['id'], accounts)
# if not len(ids):
# return 0.0
# ids = map(lambda x: x['id'], accounts)
# account_analytic_obj = self.pool.get('account.analytic.account')
# ids2 = account_analytic_obj.search(self.cr, self.uid,
# [('parent_id', 'child_of', ids)])
# self.cr.execute("SELECT -sum(amount) \
# FROM account_analytic_line \
# WHERE account_id IN ("+','.join(map(str, ids2))+") \
# AND date>=%s AND date<=%s AND amount<0",
# (date1, date2))
# return self.cr.fetchone()[0] or 0.0
def _sum_balance(self, accounts, date1, date2):
debit = self._sum_debit(accounts, date1, date2) or 0.0
credit = self._sum_credit(accounts, date1, date2) or 0.0
debit = self._sum_all(accounts, date1, date2, 'debit') or 0.0
credit = self._sum_all(accounts, date1, date2, 'credit') or 0.0
return (debit-credit)
def _sum_quantity(self, accounts, date1, date2):
ids = map(lambda x: x.id, accounts)
if not len(ids):
return 0.0
account_analytic_obj = self.pool.get('account.analytic.account')
ids2 = account_analytic_obj.search(self.cr, self.uid,
[('parent_id', 'child_of', ids)])
self.cr.execute("SELECT sum(unit_amount) \
FROM account_analytic_line \
WHERE account_id IN ("+','.join(map(str, ids2))+") \
AND date>=%s AND date<=%s",
(date1, date2))
return self.cr.fetchone()[0] or 0.0
# def _sum_quantity(self, accounts, date1, date2):
# ids = map(lambda x: x['id'], accounts)
# if not len(ids):
# return 0.0
# account_analytic_obj = self.pool.get('account.analytic.account')
# ids2 = account_analytic_obj.search(self.cr, self.uid,
# [('parent_id', 'child_of', ids)])
# self.cr.execute("SELECT sum(unit_amount) \
# FROM account_analytic_line \
# WHERE account_id IN ("+','.join(map(str, ids2))+") \
# AND date>=%s AND date<=%s",
# (date1, date2))
# return self.cr.fetchone()[0] or 0.0
report_sxw.report_sxw('report.account.analytic.account.balance',
'account.analytic.account', 'addons/account/project/report/analytic_balance.rml',
@@ -45,7 +45,7 @@
<blockValign value="TOP"/>
<lineStyle kind="LINEBELOW" colorName="#000000" start="0,0" stop="-1,0"/>
<lineStyle kind="LINEBELOW" colorName="#000000" start="0,1" stop="-1,1"/>
<lineStyle kind="LINEBELOW" colorName="#777777" start="0,2" stop="1,2"/>
<lineStyle kind="LINEBELOW" colorName="#b3b3b3" start="0,2" stop="1,2"/>
<lineStyle kind="LINEBELOW" colorName="#e6e6e6" start="0,3" stop="-1,-1"/>
</blockTableStyle>
<blockTableStyle id="Table2">
@@ -130,45 +130,45 @@
</td>
<td></td>
<td>
<para style="terp_tblheader_General_Right"><u>[[ formatLang(sum_debit(objects,data['form']['date1'],data['form']['date2'])) ]]</u></para>
<para style="terp_tblheader_General_Right"><u>[[ formatLang(sum_all(get_objects(data['form']['empty_acc']),data['form']['date1'],data['form']['date2'],'debit')) ]]</u></para>
</td>
<td>
<para style="terp_tblheader_General_Right"><u>[[ formatLang(sum_credit(objects,data['form']['date1'],data['form']['date2'])) ]]</u></para>
<para style="terp_tblheader_General_Right"><u>[[ formatLang(sum_all(get_objects(data['form']['empty_acc']),data['form']['date1'],data['form']['date2'],'credit')) ]]</u></para>
</td>
<td>
<para style="terp_tblheader_General_Right"><u>[[ formatLang(sum_balance(objects,data['form']['date1'],data['form']['date2'])) ]]</u></para>
<para style="terp_tblheader_General_Right"><u>[[ formatLang(sum_balance(get_objects(data['form']['empty_acc']),data['form']['date1'],data['form']['date2'])) ]]</u></para>
</td>
<td>
<para style="terp_tblheader_General_Right"><u>[[ formatLang(sum_quantity(objects,data['form']['date1'],data['form']['date2'])) ]]</u></para>
<para style="terp_tblheader_General_Right"><u>[[ formatLang(sum_all(get_objects(data['form']['empty_acc']),data['form']['date1'],data['form']['date2'],'quantity')) ]]</u></para>
</td>
</tr>
</blockTable>
<section>
<para style="terp_default_8">[[ repeatIn(objects,'o') ]]</para>
<para style="terp_default_8">[[ repeatIn(get_objects(data['form']['empty_acc']),'o') ]]</para>
<blockTable colWidths="57.0,280.0,50.0,50.0,50.0,50.0" style="tbl_data">
<tr>
<td>
<para style="terp_default_8_bold">[[ o.code ]]</para>
<para style="terp_default_8_bold">[[ o['code'] ]]</para>
</td>
<td>
<para style="terp_default_8_bold">[[ o.complete_name ]]</para>
<para style="terp_default_8_bold">[[ o['complete_name'] ]]</para>
</td>
<td>
<para style="terp_default_8_right_bold"><u>[[ formatLang(move_sum_debit(o.id,data['form']['date1'],data['form']['date2'])) ]]</u></para>
<para style="terp_default_8_right_bold"><u>[[ formatLang(move_sum(o['id'],data['form']['date1'],data['form']['date2'], 'debit')) ]]</u></para>
</td>
<td>
<para style="terp_default_8_right_bold"><u>[[ formatLang(move_sum_credit(o.id,data['form']['date1'],data['form']['date2'])) ]]</u></para>
<para style="terp_default_8_right_bold"><u>[[ formatLang(move_sum(o['id'],data['form']['date1'],data['form']['date2'], 'credit')) ]]</u></para>
</td>
<td>
<para style="terp_default_8_right_bold"><u>[[ formatLang(move_sum_balance(o.id,data['form']['date1'],data['form']['date2'])) ]]</u></para>
<para style="terp_default_8_right_bold"><u>[[ formatLang(move_sum_balance(o['id'],data['form']['date1'],data['form']['date2'])) ]]</u></para>
</td>
<td>
<para style="terp_default_8_right_bold"><u>[[ formatLang(move_sum_quantity(o.id,data['form']['date1'],data['form']['date2'])) ]]</u></para>
<para style="terp_default_8_right_bold"><u>[[ formatLang(move_sum(o['id'],data['form']['date1'],data['form']['date2'], 'quantity')) ]]</u></para>
</td>
</tr>
<tr>
<td>
<para style="terp_default_8">[[ repeatIn(lines_g(o.id,data['form']['date1'],data['form']['date2']),'move_g') ]]</para>
<para style="terp_default_8">[[ repeatIn(lines_g(o['id'],data['form']['date1'],data['form']['date2']),'move_g') ]]</para>
<para style="terp_default_8">[[ move_g['code'] ]]</para>
</td>
<td>
@@ -24,14 +24,16 @@ import time
import wizard
dates_form = '''<?xml version="1.0"?>
<form string="Select period">
<form string="Select Period">
<field name="date1"/>
<field name="date2"/>
<field name="empty_acc"/>
</form>'''
dates_fields = {
'date1': {'string':'Start of period', 'type':'date', 'required':True, 'default': lambda *a: time.strftime('%Y-01-01')},
'date2': {'string':'End of period', 'type':'date', 'required':True, 'default': lambda *a: time.strftime('%Y-%m-%d')},
'date1': {'string':'Start of Period', 'type':'date', 'required':True, 'default': lambda *a: time.strftime('%Y-01-01')},
'date2': {'string':'End of Period', 'type':'date', 'required':True, 'default': lambda *a: time.strftime('%Y-%m-%d')},
'empty_acc': {'string':'Empty Accounts ? ', 'type':'boolean', 'help':'Check if you want to display Accounts with 0 balance too.'},
}
+1
View File
@@ -93,6 +93,7 @@ class account_balance(report_sxw.rml_parse):
res={}
result_acc=[]
ctx = self.context.copy()
ctx['state'] = form['context'].get('state','all')
ctx['fiscalyear'] = form['fiscalyear']
if form['state']=='byperiod' :
ctx['periods'] = form['periods'][0][2]
+1 -1
View File
@@ -188,6 +188,7 @@ class general_ledger(rml_parse.rml_parse):
## We will make the test for period or date
## We will now make the test
#
ctx['state'] = form['context'].get('state','all')
if form.has_key('fiscalyear'):
ctx['fiscalyear'] = form['fiscalyear']
ctx['periods'] = form['periods'][0][2]
@@ -195,7 +196,6 @@ class general_ledger(rml_parse.rml_parse):
ctx['date_from'] = form['date_from']
ctx['date_to'] = form['date_to']
##
#
self.query = self.pool.get('account.move.line')._query_get(self.cr, self.uid, context=ctx)
if account and account.child_consol_ids: # add ids of consolidated childs also of selected account
@@ -188,6 +188,7 @@ class general_ledger_landscape(rml_parse.rml_parse):
## We will make the test for period or date
## We will now make the test
#
ctx['state'] = form['context'].get('state','all')
if form.has_key('fiscalyear'):
ctx['fiscalyear'] = form['fiscalyear']
ctx['periods'] = form['periods'][0][2]
+1 -1
View File
@@ -366,7 +366,7 @@
<tr>
<td><para style="terp_default_Centre_8">[[ t.name ]] </para></td>
<td><para style="terp_default_Right_8">[[ formatLang(t.base) ]]</para></td>
<td><para style="terp_default_Right_8">[[ t.tax_code_id.notprintable and removeParentNode('blockTable') or '' ]][[ formatLang(t.amount) ]]</para></td>
<td><para style="terp_default_Right_8">[[ (t.tax_code_id and t.tax_code_id.notprintable) and removeParentNode('blockTable') or '' ]][[ formatLang(t.amount) ]]</para></td>
</tr>
</blockTable>
</td>
+3 -3
View File
@@ -29,14 +29,14 @@ import pooler
class Overdue(report_sxw.rml_parse):
def __init__(self, cr, uid, name, context):
super(Overdue, self).__init__(cr, uid, name, context)
super(Overdue, self).__init__(cr, uid, name, context=context)
self.localcontext.update( {
'time' : time,
'adr_get' : self._adr_get,
'getLines' : self._lines_get,
'tel_get' : self._tel_get,
})
self.context = context
def _adr_get(self, partner, type):
res = []
res_partner = pooler.get_pool(self.cr.dbname).get('res.partner')
@@ -51,7 +51,7 @@ class Overdue(report_sxw.rml_parse):
'country_id' : False,
}
if adr_id:
result = res_partner_address.read(self.cr, self.uid, [adr_id])
result = res_partner_address.read(self.cr, self.uid, [adr_id],context=self.context.copy())
result[0]['country_id'] = result[0]['country_id'] and result[0]['country_id'][1] or False
return result
@@ -79,7 +79,7 @@ account_fields = {
}
class wizard_report(wizard.interface):
def _get_defaults(self, cr, uid, data, context):
def _get_defaults(self, cr, uid, data, context={}):
user = pooler.get_pool(cr.dbname).get('res.users').browse(cr, uid, uid, context=context)
if user.company_id:
company_id = user.company_id.id
@@ -91,7 +91,8 @@ class wizard_report(wizard.interface):
data['form']['fiscalyear'] = fiscalyear_obj.find(cr, uid)
# data['form']['periods'] = periods_obj.search(cr, uid, [('fiscalyear_id','=',data['form']['fiscalyear'])])
# data['form']['fiscalyear'] = False
data['form']['display_account']='bal_all'
data['form']['display_account'] = 'bal_all'
data['form']['context'] = context
return data['form']
def _check_state(self, cr, uid, data, context):
@@ -130,7 +130,7 @@ def _check_state(self, cr, uid, data, context):
class wizard_report(wizard.interface):
def _get_defaults(self, cr, uid, data, context):
def _get_defaults(self, cr, uid, data, context={}):
user = pooler.get_pool(cr.dbname).get('res.users').browse(cr, uid, uid, context=context)
if user.company_id:
company_id = user.company_id.id
@@ -147,6 +147,7 @@ class wizard_report(wizard.interface):
data['form']['landscape']=True
data['form']['fiscalyear'] = False
data['form']['amount_currency'] = True
data['form']['context'] = context
return data['form']
states = {
@@ -401,7 +401,8 @@ class account_balance(report_sxw.rml_parse):
ctx['fiscalyear'] = id
ctx['periods'] = form['periods'][0][2]
ctx['period_manner']=form['period_manner']
ctx['period_manner'] = form['period_manner']
ctx['state'] = form['context'].get('state','all')
tmp = self.pool.get('account.account').browse(self.cr, self.uid, ids, ctx.copy())
if len(tmp):
@@ -458,7 +459,7 @@ class account_balance(report_sxw.rml_parse):
ctx['fiscalyear'] = id
ctx['periods'] = form['periods'][0][2]
ctx['period_manner']=form['period_manner']
ctx['state'] = form['context'].get('state','all')
tmp1 = self.pool.get('account.account').browse(self.cr, self.uid, ids,ctx.copy())
if len(tmp1):
@@ -402,7 +402,8 @@ class account_balance_landscape(rml_parse.rml_parse):
ctx['fiscalyear'] = id
ctx['periods'] = form['periods'][0][2]
ctx['period_manner']=form['period_manner']
ctx['period_manner'] = form['period_manner']
ctx['state'] = form['context'].get('state','all')
tmp = self.pool.get('account.account').browse(self.cr, self.uid, ids, ctx.copy())
if len(tmp):
@@ -461,7 +462,7 @@ class account_balance_landscape(rml_parse.rml_parse):
ctx['fiscalyear'] = id
ctx['periods'] = form['periods'][0][2]
ctx['period_manner']=form['period_manner']
ctx['state'] = form['context'].get('state','all')
tmp1 = self.pool.get('account.account').browse(self.cr, self.uid, ids,ctx.copy())
if len(tmp1):
@@ -133,7 +133,8 @@ def _check(self, cr, uid, data, context):
class wizard_report(wizard.interface):
def _get_defaults(self, cr, uid, data, context):
def _get_defaults(self, cr, uid, data, context={}):
data['form']['context'] = context
fiscalyear_obj = pooler.get_pool(cr.dbname).get('account.fiscalyear')
data['form']['fiscalyear']=[fiscalyear_obj.find(cr, uid)]
# p_ids=pooler.get_pool(cr.dbname).get('account.period').search(cr,uid,[('fiscalyear_id','=',fiscalyear_obj.find(cr, uid))])
@@ -130,7 +130,7 @@ class report_custom(report_rml):
while day_diff1>0:
if month+i<=12:
if day_diff1>30:
if day_diff1 > lengthmonth(year,i+month): # Not on 30 else you have problems when entering 01-01-2009 for example
som1=datetime.date(year,month+i,1)
date_xml += ['<dayy number="%d" name="%s" cell="%d"/>' % (x, som1.replace(day=x).strftime('%a'),cell+x) for x in range(1, lengthmonth(year,i+month)+1)]
i=i+1
@@ -184,7 +184,7 @@ class invoice_create(wizard.interface):
_create_form = """<?xml version="1.0"?>
<form title="Invoice on analytic entries">
<form string="Invoice on analytic entries">
<notebook>
<page string="Invoicing Data">
<separator string="Do you want to show details of work in invoice ?" colspan="4"/>
@@ -576,7 +576,7 @@ class hr_timesheet_sheet_sheet_day(osv.osv):
sheet_id,
total_timesheet,
total_attendance,
(total_attendance - total_timesheet) AS total_difference
round(cast((total_attendance - total_timesheet) as Numeric),2) AS total_difference
FROM
((
SELECT
+1 -1
View File
@@ -69,7 +69,7 @@ class res_partner_bank(osv.osv):
if address['type'] == 'default':
return address.get(field,False)
elif not address['type']:
value = address[field]
value = address.get(field,False)
else :
value = False
return value
+4 -3
View File
@@ -280,7 +280,7 @@ class task(osv.osv):
'planned_hours': fields.float('Planned Hours', required=True, help='Estimated time to do the task, usually set by the project manager when the task is in draft state.'),
'effective_hours': fields.function(_hours_get, method=True, string='Hours Spent', multi='hours', store=True, help="Computed using the sum of the task work done."),
'remaining_hours': fields.float('Remaining Hours', digits=(16,2), help="Total remaining time, can be re-estimated periodically by the assignee of the task."),
'remaining_hours': fields.float('Remaining Hours', digits=(16,4), help="Total remaining time, can be re-estimated periodically by the assignee of the task."),
'total_hours': fields.function(_hours_get, method=True, string='Total Hours', multi='hours', store=True, help="Computed as: Time Spent + Remaining Time."),
'progress': fields.function(_hours_get, method=True, string='Progress (%)', multi='hours', store=True, help="Computed as: Time Spent / Total Time."),
'delay_hours': fields.function(_hours_get, method=True, string='Delay Hours', multi='hours', store=True, help="Computed as: Total Time - Estimated Time. It gives the difference of the time estimated by the project manager and the real time to close the task."),
@@ -433,8 +433,9 @@ class project_work(osv.osv):
def write(self, cr, uid, ids,vals,context={}):
if 'hours' in vals and (not vals['hours']):
vals['hours'] = 0.00
for work in self.browse(cr, uid, ids, context):
cr.execute('update project_task set remaining_hours=remaining_hours - %s + (%s) where id=%s', (vals.get('hours',0.0), work.hours, work.task_id.id))
if 'hours' in vals:
for work in self.browse(cr, uid, ids, context):
cr.execute('update project_task set remaining_hours=remaining_hours - %s + (%s) where id=%s', (vals.get('hours',0.0), work.hours, work.task_id.id))
return super(project_work,self).write(cr, uid, ids, vals, context)
def unlink(self, cr, uid, ids, *args, **kwargs):
+33
View File
@@ -71,6 +71,39 @@
<field name="col_deadline" eval="True"/>
<field name="col_effective_hours" eval="True"/>
</record>
<record id="project.project_task_116" model="project.task">
<field name="planned_hours">38.0</field>
<field name="remaining_hours">38.0</field>
<field name="timebox_id" ref="timebox_daily"/>
<field name="context_id" ref="context_office"/>
<field name="type" ref="project.project_tt_feature"/>
<field name="user_id" ref="base.user_root"/>
<field name="project_id" ref="project.project_project_22"/>
<field name="name">Specific adaptation to MRP</field>
</record>
<record id="project.project_task_201" model="project.task">
<field name="sequence">40</field>
<field name="planned_hours">32.0</field>
<field name="remaining_hours">32.0</field>
<field name="timebox_id" ref="timebox_monthly"/>
<field name="context_id" ref="context_home"/>
<field name="user_id" ref="base.user_root"/>
<field name="project_id" ref="project.project_project_23"/>
<field name="name">In house training</field>
</record>
<record id="project.project_task_202" model="project.task">
<field name="sequence">50</field>
<field name="planned_hours">24.0</field>
<field name="remaining_hours">24.0</field>
<field name="timebox_id" ref="timebox_weekly"/>
<field name="context_id" ref="context_office"/>
<field name="user_id" ref="base.user_root"/>
<field name="project_id" ref="project.project_project_22"/>
<field name="name">Validation + latest modifications.</field>
</record>
</data>
</openerp>
+22 -6
View File
@@ -115,9 +115,9 @@
</field>
</record>
<record model="ir.actions.act_window" id="open_gtd_task_inbox">
<field name="name">Inbox Tasks</field>
<field name="name">My Inbox</field>
<field name="res_model">project.task</field>
<field name="domain">[('user_id','=',uid),('timebox_id','=',False),('state','in',('open','draft'))]</field>
<field name="domain">[('user_id','=',uid),('state','in',('open','draft'))]</field>
<field name="context">{'gtd_sort':True}</field>
<field name="view_id" ref="task_inbox_view"/>
</record>
@@ -129,6 +129,7 @@
<field name="name">project.gtd.timebox.treelist</field>
<field name="model">project.gtd.timebox</field>
<field name="type">tree</field>
<field name="field_parent">child_ids</field>
<field name="priority">50</field>
<field name="arch" type="xml">
<tree string="Timeboxes">
@@ -137,18 +138,17 @@
</field>
</record>
<record model="ir.actions.act_window" id="open_gtd_timebox_all">
<field name="name">My Timeboxes</field>
<field name="res_model">project.gtd.timebox</field>
<field name="domain">[('user_id','=',uid)]</field>
<field name="domain">[('user_id','=',uid),('parent_id','=',False)]</field>
<field name="view_type">tree</field>
<field name="view_id" ref="view_gtd_timebox_treelist"/>
<field name="context">{'record_id':False}</field>
</record>
<menuitem
name="All My Timeboxes"
name="My Timeboxes"
id="menu_open_time_allinbox"
parent="menu_open_time"
action="open_gtd_timebox_all"/>
@@ -170,7 +170,7 @@
</record>
<act_window name="My Inbox"
domain="[('user_id', '=', uid),('timebox_id','=',False),('state','in',('draft','open'))]"
domain="[('user_id', '=', uid),('state','in',('draft','open'))]"
res_model="project.task"
src_model="project.gtd.timebox"
view_type="form"
@@ -207,7 +207,23 @@
view_mode="tree,form"
id="act_timebox_tasks"/>
<record id="project_normal_action_tree" model="ir.actions.act_window">
<field name="name">TimeBox</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">project.task</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="domain">[('timebox_id','child_of',[active_id])]</field>
<field name="context">{'timebox_id':active_id}</field>
</record>
<record id="ir_project_category_open" model="ir.values">
<field eval="'tree_but_open'" name="key2"/>
<field eval="'project.gtd.timebox'" name="model"/>
<field name="name">Tasks by Timebox</field>
<field eval="'ir.actions.act_window,%d'%project_normal_action_tree" name="value"/>
<field eval="True" name="object"/>
</record>
</data>
</openerp>
@@ -42,7 +42,7 @@ class wiz_timebox_open(wizard.interface):
domain = "[('user_id', '=', uid)]"
value = {
'domain': domain,
'name': 'Timebox',
'name': 'My Daily Timebox',
'view_type': 'form',
'view_mode': view_type,
'res_model': 'project.gtd.timebox',
+16 -3
View File
@@ -492,7 +492,7 @@ class sale_order(osv.osv):
if line.procurement_id:
res.append(line.procurement_id.id)
return res
# if mode == 'finished':
# returns True if all lines are done, False otherwise
# if mode == 'canceled':
@@ -504,9 +504,22 @@ class sale_order(osv.osv):
notcanceled = False
write_done_ids = []
write_cancel_ids = []
stock_move_obj = self.pool.get('stock.move')
for order in self.browse(cr, uid, ids, context={}):
for line in order.order_line:
if (not line.procurement_id) or (line.procurement_id.state=='done'):
#check for pending deliveries
pending_deliveries = False
for line in order.order_line:
move_ids = stock_move_obj.search(cr, uid, [('sale_line_id','=', line.id)])
for move in stock_move_obj.browse( cr, uid, move_ids ):
#if one of the related order lines is in state draft, auto or confirmed
#this order line is not yet delivered
if move.state in ('draft', 'auto', 'confirmed'):
pending_deliveries = True
if ((not line.procurement_id) or (line.procurement_id.state=='done')) and not pending_deliveries:
finished = True
if line.state != 'done':
write_done_ids.append(line.id)
+5
View File
@@ -1135,6 +1135,11 @@ class stock_move(osv.osv):
if move.state in ('confirmed', 'waiting'):
res = self.pool.get('stock.location')._product_reserve(cr, uid, [move.location_id.id], move.product_id.id, move.product_qty, {'uom': move.product_uom.id})
if res:
#_product_available_test depends on the next status for correct functioning
#the test does not work correctly if the same product occurs multiple times
#in the same order. This is e.g. the case when using the button 'split in two' of
#the stock outgoing form
self.write(cr, uid, move.id, {'state':'assigned'})
done.append(move.id)
pickings[move.picking_id.id] = 1
r = res.pop(0)