diff --git a/addons/account/account.py b/addons/account/account.py index b4a14684a27..b6dd4bfb11b 100644 --- a/addons/account/account.py +++ b/addons/account/account.py @@ -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, diff --git a/addons/account/account_bank_statement.py b/addons/account/account_bank_statement.py index 0f6aca2f917..56c4ddba96e 100644 --- a/addons/account/account_bank_statement.py +++ b/addons/account/account_bank_statement.py @@ -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 = { diff --git a/addons/account/account_invoice_view.xml b/addons/account/account_invoice_view.xml index 5b06a40acb1..6d14f25427c 100644 --- a/addons/account/account_invoice_view.xml +++ b/addons/account/account_invoice_view.xml @@ -221,6 +221,8 @@ + + @@ -306,6 +308,8 @@ + + diff --git a/addons/account/invoice.py b/addons/account/invoice.py index b3c5316b68f..be9b4f63246 100644 --- a/addons/account/invoice.py +++ b/addons/account/invoice.py @@ -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) diff --git a/addons/account/project/report/analytic_balance.py b/addons/account/project/report/analytic_balance.py index 341424984df..0c7b0cda761 100644 --- a/addons/account/project/report/analytic_balance.py +++ b/addons/account/project/report/analytic_balance.py @@ -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', diff --git a/addons/account/project/report/analytic_balance.rml b/addons/account/project/report/analytic_balance.rml index 1e420418a4e..a9b39e49cc5 100644 --- a/addons/account/project/report/analytic_balance.rml +++ b/addons/account/project/report/analytic_balance.rml @@ -45,7 +45,7 @@ - + @@ -130,45 +130,45 @@ - [[ formatLang(sum_debit(objects,data['form']['date1'],data['form']['date2'])) ]] + [[ formatLang(sum_all(get_objects(data['form']['empty_acc']),data['form']['date1'],data['form']['date2'],'debit')) ]] - [[ formatLang(sum_credit(objects,data['form']['date1'],data['form']['date2'])) ]] + [[ formatLang(sum_all(get_objects(data['form']['empty_acc']),data['form']['date1'],data['form']['date2'],'credit')) ]] - [[ formatLang(sum_balance(objects,data['form']['date1'],data['form']['date2'])) ]] + [[ formatLang(sum_balance(get_objects(data['form']['empty_acc']),data['form']['date1'],data['form']['date2'])) ]] - [[ formatLang(sum_quantity(objects,data['form']['date1'],data['form']['date2'])) ]] + [[ formatLang(sum_all(get_objects(data['form']['empty_acc']),data['form']['date1'],data['form']['date2'],'quantity')) ]]
- [[ repeatIn(objects,'o') ]] + [[ repeatIn(get_objects(data['form']['empty_acc']),'o') ]] - [[ o.code ]] + [[ o['code'] ]] - [[ o.complete_name ]] + [[ o['complete_name'] ]] - [[ formatLang(move_sum_debit(o.id,data['form']['date1'],data['form']['date2'])) ]] + [[ formatLang(move_sum(o['id'],data['form']['date1'],data['form']['date2'], 'debit')) ]] - [[ formatLang(move_sum_credit(o.id,data['form']['date1'],data['form']['date2'])) ]] + [[ formatLang(move_sum(o['id'],data['form']['date1'],data['form']['date2'], 'credit')) ]] - [[ formatLang(move_sum_balance(o.id,data['form']['date1'],data['form']['date2'])) ]] + [[ formatLang(move_sum_balance(o['id'],data['form']['date1'],data['form']['date2'])) ]] - [[ formatLang(move_sum_quantity(o.id,data['form']['date1'],data['form']['date2'])) ]] + [[ formatLang(move_sum(o['id'],data['form']['date1'],data['form']['date2'], 'quantity')) ]] - [[ repeatIn(lines_g(o.id,data['form']['date1'],data['form']['date2']),'move_g') ]] + [[ repeatIn(lines_g(o['id'],data['form']['date1'],data['form']['date2']),'move_g') ]] [[ move_g['code'] ]] diff --git a/addons/account/project/wizard/wizard_account_analytic_balance_report.py b/addons/account/project/wizard/wizard_account_analytic_balance_report.py index bb487517354..57c9353ceeb 100644 --- a/addons/account/project/wizard/wizard_account_analytic_balance_report.py +++ b/addons/account/project/wizard/wizard_account_analytic_balance_report.py @@ -24,14 +24,16 @@ import time import wizard dates_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.'}, } diff --git a/addons/account/report/account_balance.py b/addons/account/report/account_balance.py index 6f34e9d092f..ebf12dd9b08 100644 --- a/addons/account/report/account_balance.py +++ b/addons/account/report/account_balance.py @@ -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] diff --git a/addons/account/report/general_ledger.py b/addons/account/report/general_ledger.py index ce42653cc58..534b4d52e67 100644 --- a/addons/account/report/general_ledger.py +++ b/addons/account/report/general_ledger.py @@ -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 diff --git a/addons/account/report/general_ledger_landscape.py b/addons/account/report/general_ledger_landscape.py index ef355526de3..c63c4281173 100644 --- a/addons/account/report/general_ledger_landscape.py +++ b/addons/account/report/general_ledger_landscape.py @@ -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] diff --git a/addons/account/report/invoice.rml b/addons/account/report/invoice.rml index b2a65b73f33..902a9db3e06 100644 --- a/addons/account/report/invoice.rml +++ b/addons/account/report/invoice.rml @@ -366,7 +366,7 @@ [[ t.name ]] [[ formatLang(t.base) ]] - [[ t.tax_code_id.notprintable and removeParentNode('blockTable') or '' ]][[ formatLang(t.amount) ]] + [[ (t.tax_code_id and t.tax_code_id.notprintable) and removeParentNode('blockTable') or '' ]][[ formatLang(t.amount) ]]
diff --git a/addons/account/report/overdue.py b/addons/account/report/overdue.py index dca2f6aeff6..76ebbe7efa4 100644 --- a/addons/account/report/overdue.py +++ b/addons/account/report/overdue.py @@ -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 diff --git a/addons/account/wizard/wizard_account_balance_report.py b/addons/account/wizard/wizard_account_balance_report.py index d8282ad440f..b7ff7c00922 100644 --- a/addons/account/wizard/wizard_account_balance_report.py +++ b/addons/account/wizard/wizard_account_balance_report.py @@ -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): diff --git a/addons/account/wizard/wizard_general_ledger_report.py b/addons/account/wizard/wizard_general_ledger_report.py index 82940bd3a16..b6b998e3bbd 100644 --- a/addons/account/wizard/wizard_general_ledger_report.py +++ b/addons/account/wizard/wizard_general_ledger_report.py @@ -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 = { diff --git a/addons/account_balance/report/account_balance.py b/addons/account_balance/report/account_balance.py index 0f0e92d9ad1..4fe498ac147 100644 --- a/addons/account_balance/report/account_balance.py +++ b/addons/account_balance/report/account_balance.py @@ -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): diff --git a/addons/account_balance/report/account_balance_landscape.py b/addons/account_balance/report/account_balance_landscape.py index 2638a628990..372fdf2c441 100644 --- a/addons/account_balance/report/account_balance_landscape.py +++ b/addons/account_balance/report/account_balance_landscape.py @@ -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): diff --git a/addons/account_balance/wizard/wizard_account_balance_report.py b/addons/account_balance/wizard/wizard_account_balance_report.py index 0f3280cb553..327b6190383 100644 --- a/addons/account_balance/wizard/wizard_account_balance_report.py +++ b/addons/account_balance/wizard/wizard_account_balance_report.py @@ -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))]) diff --git a/addons/hr_holidays/report/holidays_summary_report.py b/addons/hr_holidays/report/holidays_summary_report.py index 589f97f2631..a7be0e2b51c 100644 --- a/addons/hr_holidays/report/holidays_summary_report.py +++ b/addons/hr_holidays/report/holidays_summary_report.py @@ -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 += ['' % (x, som1.replace(day=x).strftime('%a'),cell+x) for x in range(1, lengthmonth(year,i+month)+1)] i=i+1 diff --git a/addons/hr_timesheet_invoice/wizard/hr_timesheet_invoice_create.py b/addons/hr_timesheet_invoice/wizard/hr_timesheet_invoice_create.py index 45205b03d2d..2b769cd1eae 100644 --- a/addons/hr_timesheet_invoice/wizard/hr_timesheet_invoice_create.py +++ b/addons/hr_timesheet_invoice/wizard/hr_timesheet_invoice_create.py @@ -184,7 +184,7 @@ class invoice_create(wizard.interface): _create_form = """ -
+ diff --git a/addons/hr_timesheet_sheet/hr_timesheet_sheet.py b/addons/hr_timesheet_sheet/hr_timesheet_sheet.py index 9d8bdb1ba64..3fbf615ad18 100644 --- a/addons/hr_timesheet_sheet/hr_timesheet_sheet.py +++ b/addons/hr_timesheet_sheet/hr_timesheet_sheet.py @@ -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 diff --git a/addons/l10n_ch/partner.py b/addons/l10n_ch/partner.py index 5f3584563be..4dc9656826c 100755 --- a/addons/l10n_ch/partner.py +++ b/addons/l10n_ch/partner.py @@ -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 diff --git a/addons/project/project.py b/addons/project/project.py index 72a7958e921..aaf16082792 100644 --- a/addons/project/project.py +++ b/addons/project/project.py @@ -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): diff --git a/addons/project_gtd/project_gtd_demo.xml b/addons/project_gtd/project_gtd_demo.xml index 08a9d3cc2f2..ca59a1211fd 100644 --- a/addons/project_gtd/project_gtd_demo.xml +++ b/addons/project_gtd/project_gtd_demo.xml @@ -71,6 +71,39 @@ + + + 38.0 + 38.0 + + + + + + Specific adaptation to MRP + + + + 40 + 32.0 + 32.0 + + + + + In house training + + + 50 + 24.0 + 24.0 + + + + + Validation + latest modifications. + + diff --git a/addons/project_gtd/project_gtd_view.xml b/addons/project_gtd/project_gtd_view.xml index f093c49efcb..13a3f1080bc 100644 --- a/addons/project_gtd/project_gtd_view.xml +++ b/addons/project_gtd/project_gtd_view.xml @@ -115,9 +115,9 @@ - Inbox Tasks + My Inbox project.task - [('user_id','=',uid),('timebox_id','=',False),('state','in',('open','draft'))] + [('user_id','=',uid),('state','in',('open','draft'))] {'gtd_sort':True} @@ -129,6 +129,7 @@ project.gtd.timebox.treelist project.gtd.timebox tree + child_ids 50 @@ -137,18 +138,17 @@ - My Timeboxes project.gtd.timebox - [('user_id','=',uid)] + [('user_id','=',uid),('parent_id','=',False)] tree {'record_id':False} @@ -170,7 +170,7 @@ + + TimeBox + ir.actions.act_window + project.task + form + tree,form + [('timebox_id','child_of',[active_id])] + {'timebox_id':active_id} + + + + + Tasks by Timebox + + + diff --git a/addons/project_gtd/wizard/project_gtd_daily.py b/addons/project_gtd/wizard/project_gtd_daily.py index 81f6731262a..3ead091e06b 100644 --- a/addons/project_gtd/wizard/project_gtd_daily.py +++ b/addons/project_gtd/wizard/project_gtd_daily.py @@ -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', diff --git a/addons/sale/sale.py b/addons/sale/sale.py index 8afb332bc7d..1492143a7d0 100644 --- a/addons/sale/sale.py +++ b/addons/sale/sale.py @@ -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) diff --git a/addons/stock/stock.py b/addons/stock/stock.py index 2a372d4eeed..039dfdd99fd 100644 --- a/addons/stock/stock.py +++ b/addons/stock/stock.py @@ -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)