From 685489a172033e4a53a2ff76854646f777f48e9d Mon Sep 17 00:00:00 2001 From: vth Date: Mon, 11 Oct 2010 11:21:53 +0530 Subject: [PATCH 01/26] [REF] account bzr revid: vth@tinyerp.com-20101011055153-h8hygvtjqkxc8004 --- addons/account/account.py | 2 +- addons/account/account_move_line.py | 14 +++++----- addons/account/invoice.py | 26 +++++++++---------- addons/account/partner.py | 6 ++--- addons/account/project/report/cost_ledger.py | 4 +-- .../project/report/quantity_cost_ledger.py | 2 +- addons/account/report/account_balance.py | 2 +- .../report/account_balance_landscape.py | 4 +-- .../account/report/account_central_journal.py | 2 +- .../account/report/account_entries_report.py | 2 +- .../account/report/account_general_ledger.py | 6 ++--- addons/account/report/account_journal.py | 8 +++--- .../account/report/account_partner_balance.py | 6 ++--- .../account/report/account_print_overdue.py | 16 ++++++------ addons/account/report/rml_parse.py | 8 +++--- addons/account/sequence.py | 4 +-- .../account/wizard/account_change_currency.py | 4 +-- .../wizard/account_fiscalyear_close.py | 4 +-- addons/account/wizard/account_move_journal.py | 2 +- addons/project/project.py | 10 +++---- 20 files changed, 66 insertions(+), 66 deletions(-) diff --git a/addons/account/account.py b/addons/account/account.py index 9176a2eec64..8ff9d35086e 100644 --- a/addons/account/account.py +++ b/addons/account/account.py @@ -2722,7 +2722,7 @@ class wizard_multi_charts_accounts(osv.osv_memory): # Bank Journals data_id = obj_data.search(cr, uid, [('model','=','account.journal.view'), ('name','=','account_journal_bank_view')]) - data = obj_pool.browse(cr, uid, data_id[0]) + data = obj_data.browse(cr, uid, data_id[0]) view_id_cash = data.res_id data_id = obj_data.search(cr, uid, [('model','=','account.journal.view'), ('name','=','account_journal_bank_view_multi')]) diff --git a/addons/account/account_move_line.py b/addons/account/account_move_line.py index ba6f4110ec1..d9b78795998 100644 --- a/addons/account/account_move_line.py +++ b/addons/account/account_move_line.py @@ -349,7 +349,7 @@ class account_move_line(osv.osv): return res def name_get(self, cr, uid, ids, context={}): - if not len(ids): + if not ids: return [] result = [] for line in self.browse(cr, uid, ids, context): @@ -363,18 +363,18 @@ class account_move_line(osv.osv): if context is None: context = {} - if not len(args): + if not args: return [] where = ' and '.join(map(lambda x: '(abs(sum(debit-credit))'+x[1]+str(x[2])+')',args)) cursor.execute('select id, sum(debit-credit) from account_move_line \ group by id, debit, credit having '+where) res = cursor.fetchall() - if not len(res): + if not res: return [('id', '=', '0')] return [('id', 'in', [x[0] for x in res])] def _invoice_search(self, cursor, user, obj, name, args, context): - if not len(args): + if not args: return [] invoice_obj = self.pool.get('account.invoice') @@ -407,7 +407,7 @@ class account_move_line(osv.osv): qu2 += x[2] else: qu1.append(' (False)') - if len(qu1): + if qu1: qu1 = ' AND' + ' AND'.join(qu1) else: qu1 = '' @@ -415,7 +415,7 @@ class account_move_line(osv.osv): 'FROM account_move_line l, account_invoice i ' \ 'WHERE l.move_id = i.move_id ' + qu1, qu2) res = cursor.fetchall() - if not len(res): + if not res: return [('id', '=', '0')] return [('id', 'in', [x[0] for x in res])] @@ -989,7 +989,7 @@ class account_move_line(osv.osv): part_rec_ids = [rec['reconcile_partial_id'][0] for rec in part_recs] unlink_ids += rec_ids unlink_ids += part_rec_ids - if len(unlink_ids): + if unlink_ids: obj_move_rec.unlink(cr, uid, unlink_ids) return True diff --git a/addons/account/invoice.py b/addons/account/invoice.py index 79978c0bbaf..36b1c38d5f3 100644 --- a/addons/account/invoice.py +++ b/addons/account/invoice.py @@ -302,7 +302,7 @@ class account_invoice(osv.osv): }, help="The Journal Entry of the invoice have been totally reconciled with one or several Journal Entries of payment."), 'partner_bank_id': fields.many2one('res.partner.bank', 'Bank Account', help='Bank Account Number, Company bank account if Invoice is customer or supplier refund, otherwise Partner bank account number.', readonly=True, states={'draft':[('readonly',False)]}), - 'move_lines':fields.function(_get_lines , method=True, type='many2many', relation='account.move.line', string='Entry Lines'), + 'move_lines':fields.function(_get_lines, method=True, type='many2many', relation='account.move.line', string='Entry Lines'), 'residual': fields.function(_amount_residual, method=True, digits_compute=dp.get_precision('Account'), string='Residual', store={ 'account.invoice': (lambda self, cr, uid, ids, c={}: ids, ['invoice_line'], 50), @@ -585,7 +585,7 @@ class account_invoice(osv.osv): else: val['currency_id'] = company.currency_id.id - return {'value' : val, 'domain': dom } + return {'value': val, 'domain': dom } # go from canceled state to draft state def action_cancel_draft(self, cr, uid, ids, *args): @@ -898,7 +898,7 @@ class account_invoice(osv.osv): 'name': name, 'price': total, 'account_id': acc_id, - 'date_maturity' : inv.date_due or False, + 'date_maturity': inv.date_due or False, 'amount_currency': diff_currency_p \ and total_currency or False, 'currency_id': diff_currency_p \ @@ -909,7 +909,7 @@ class account_invoice(osv.osv): date = inv.date_invoice or time.strftime('%Y-%m-%d') part = inv.partner_id.id - line = map(lambda x:(0,0,self.line_get_convert(cr, uid, x, part, date, context={})) ,iml) + line = map(lambda x:(0,0,self.line_get_convert(cr, uid, x, part, date, context={})),iml) line = self.group_lines(cr, uid, iml, line, inv) @@ -932,7 +932,7 @@ class account_invoice(osv.osv): period_id = inv.period_id and inv.period_id.id or False if not period_id: period_ids = self.pool.get('account.period').search(cr, uid, [('date_start','<=',inv.date_invoice or time.strftime('%Y-%m-%d')),('date_stop','>=',inv.date_invoice or time.strftime('%Y-%m-%d'))]) - if len(period_ids): + if period_ids: period_id = period_ids[0] if period_id: move['period_id'] = period_id @@ -1018,7 +1018,7 @@ class account_invoice(osv.osv): account_move_obj.unlink(cr, uid, [i['move_id'][0]]) if i['payment_ids']: account_move_line_obj = self.pool.get('account.move.line') - pay_ids = account_move_line_obj.browse(cr, uid , i['payment_ids']) + pay_ids = account_move_line_obj.browse(cr, uid, i['payment_ids']) for move_line in pay_ids: if move_line.reconcile_partial_id and move_line.reconcile_partial_id.line_partial_ids: raise osv.except_osv(_('Error !'), _('You cannot cancel the Invoice which is Partially Paid! You need to unreconcile concerned payment entries!')) @@ -1043,7 +1043,7 @@ class account_invoice(osv.osv): return True def name_get(self, cr, uid, ids, context=None): - if not len(ids): + if not ids: return [] types = { 'out_invoice': 'CI: ', @@ -1103,7 +1103,7 @@ class account_invoice(osv.osv): else: refund_journal_ids = self.pool.get('account.journal').search(cr, uid, [('type','=','sale_refund')]) - if not date : + if not date: date = time.strftime('%Y-%m-%d') invoice.update({ 'type': type_dict[invoice['type']], @@ -1114,11 +1114,11 @@ class account_invoice(osv.osv): 'tax_line': tax_lines, 'journal_id': refund_journal_ids }) - if period_id : + if period_id: invoice.update({ 'period_id': period_id, }) - if description : + if description: invoice.update({ 'name': description, }) @@ -1406,7 +1406,7 @@ class account_invoice_line(osv.osv): result['uos_id'] = res.uom_id.id or uom or False if result['uos_id']: res2 = res.uom_id.category_id.id - if res2 : + if res2: domain = {'uos_id':[('category_id','=',res2 )]} result['categ_id'] = res.categ_id.id @@ -1537,8 +1537,8 @@ class account_invoice_tax(osv.osv): 'tax_code_id': fields.many2one('account.tax.code', 'Tax Code', help="The tax basis of the tax declaration."), 'tax_amount': fields.float('Tax Code Amount', digits_compute=dp.get_precision('Account')), 'company_id': fields.related('account_id', 'company_id', type='many2one', relation='res.company', string='Company', store=True), - 'factor_base' : fields.function(_count_factor, method=True, string='Multipication factor for Base code', type='float', multi="all"), - 'factor_tax' : fields.function(_count_factor, method=True, string='Multipication factor Tax code', type='float', multi="all") + 'factor_base': fields.function(_count_factor, method=True, string='Multipication factor for Base code', type='float', multi="all"), + 'factor_tax': fields.function(_count_factor, method=True, string='Multipication factor Tax code', type='float', multi="all") } def base_change(self, cr, uid, ids, base, currency_id=False, company_id=False, date_invoice=False): diff --git a/addons/account/partner.py b/addons/account/partner.py index 536976d1e39..61f722bc462 100644 --- a/addons/account/partner.py +++ b/addons/account/partner.py @@ -52,7 +52,7 @@ class account_fiscal_position(osv.osv): return result def map_account(self, cr, uid, fposition_id, account_id, context={}): - if not fposition_id : + if not fposition_id: return account_id for pos in fposition_id.account_ids: if pos.account_src_id.id == account_id: @@ -116,7 +116,7 @@ class res_partner(osv.osv): return res def _asset_difference_search(self, cr, uid, obj, name, type, args, context=None): - if not len(args): + if not args: return [] having_values = tuple(map(itemgetter(2), args)) where = ' AND '.join( @@ -133,7 +133,7 @@ class res_partner(osv.osv): 'GROUP BY partner_id HAVING '+where), (type,) + having_values) res = cr.fetchall() - if not len(res): + if not res: return [('id','=','0')] return [('id','in',map(itemgetter(0), res))] diff --git a/addons/account/project/report/cost_ledger.py b/addons/account/project/report/cost_ledger.py index c711eeb2b30..225a85d2ee1 100644 --- a/addons/account/project/report/cost_ledger.py +++ b/addons/account/project/report/cost_ledger.py @@ -91,14 +91,14 @@ class account_analytic_cost_ledger(report_sxw.rml_parse): def _sum_debit(self, accounts, date1, date2): ids = map(lambda x: x.id, accounts) - if not len(ids): + if not ids: return 0.0 self.cr.execute("SELECT sum(amount) FROM account_analytic_line WHERE account_id IN %s AND date>=%s AND date<=%s AND amount>0", (tuple(ids), 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): + if not ids: return 0.0 self.cr.execute("SELECT -sum(amount) FROM account_analytic_line WHERE account_id IN %s AND date>=%s AND date<=%s AND amount<0", (tuple(ids),date1, date2,)) return self.cr.fetchone()[0] or 0.0 diff --git a/addons/account/project/report/quantity_cost_ledger.py b/addons/account/project/report/quantity_cost_ledger.py index c593d05566e..4d874fe50ee 100644 --- a/addons/account/project/report/quantity_cost_ledger.py +++ b/addons/account/project/report/quantity_cost_ledger.py @@ -102,7 +102,7 @@ class account_analytic_quantity_cost_ledger(report_sxw.rml_parse): def _sum_quantity(self, accounts, date1, date2, journals): ids = map(lambda x: x.id, accounts) - if not len(ids): + if not ids: return 0.0 if not journals: self.cr.execute("SELECT sum(unit_amount) \ diff --git a/addons/account/report/account_balance.py b/addons/account/report/account_balance.py index 236433819c5..5a6c7700b9d 100644 --- a/addons/account/report/account_balance.py +++ b/addons/account/report/account_balance.py @@ -86,7 +86,7 @@ class account_balance(report_sxw.rml_parse, common_report_header): self.sum_debit += account_rec['debit'] self.sum_credit += account_rec['credit'] if disp_acc == 'bal_movement': - if res['credit'] > 0 or res['debit'] > 0 or res['balance'] > 0 : + if res['credit'] > 0 or res['debit'] > 0 or res['balance'] > 0: self.result_acc.append(res) elif disp_acc == 'bal_solde': if res['balance'] != 0: diff --git a/addons/account/report/account_balance_landscape.py b/addons/account/report/account_balance_landscape.py index 04f7cc8ec7f..6ec7ec7c10e 100644 --- a/addons/account/report/account_balance_landscape.py +++ b/addons/account/report/account_balance_landscape.py @@ -139,7 +139,7 @@ class account_balance_landscape(rml_parse.rml_parse): ctx['state'] = form['context'].get('state','all') tmp = self.pool.get('account.account').browse(self.cr, self.uid, ids, ctx.copy()) - if len(tmp): + if tmp: accounts.append(tmp) merged_accounts=zip(*accounts) @@ -198,7 +198,7 @@ class account_balance_landscape(rml_parse.rml_parse): ctx['state'] = form['context'].get('state','all') tmp1 = self.pool.get('account.account').browse(self.cr, self.uid, ids, ctx.copy()) - if len(tmp1): + if tmp1: accounts.append(tmp1) if level==1: #if parent is called,done is not empty when called again. diff --git a/addons/account/report/account_central_journal.py b/addons/account/report/account_central_journal.py index bf5164253cc..d3693ecb152 100644 --- a/addons/account/report/account_central_journal.py +++ b/addons/account/report/account_central_journal.py @@ -71,7 +71,7 @@ class journal_print(report_sxw.rml_parse, common_report_header): move_state = ['draft','posted'] if self.target_move == 'posted': move_state = ['posted'] - self.cr.execute('SELECT a.currency_id ,a.code, a.name, c.code AS currency_code,l.currency_id ,l.amount_currency ,SUM(debit) AS debit, SUM(credit) AS credit \ + self.cr.execute('SELECT a.currency_id ,a.code, a.name, c.code AS currency_code, l.currency_id, l.amount_currency, SUM(debit) AS debit, SUM(credit) AS credit \ from account_move_line l \ LEFT JOIN account_move am ON (l.move_id=am.id) \ LEFT JOIN account_account a ON (l.account_id=a.id) \ diff --git a/addons/account/report/account_entries_report.py b/addons/account/report/account_entries_report.py index ae0b3e47b04..942ca8c4fb8 100644 --- a/addons/account/report/account_entries_report.py +++ b/addons/account/report/account_entries_report.py @@ -55,7 +55,7 @@ class account_entries_report(osv.osv): 'move_line_state': fields.selection([('draft','Unbalanced'), ('valid','Valid')], 'State of Move Line', readonly=True), 'reconcile_id': fields.many2one('account.move.reconcile', readonly=True), 'partner_id': fields.many2one('res.partner','Partner', readonly=True), - 'analytic_account_id' : fields.many2one('account.analytic.account', 'Analytic Account', readonly=True), + 'analytic_account_id': fields.many2one('account.analytic.account', 'Analytic Account', readonly=True), 'quantity': fields.float('Products Quantity', digits=(16,2), readonly=True), 'user_type': fields.many2one('account.account.type', 'Account Type', readonly=True), 'type': fields.selection([ diff --git a/addons/account/report/account_general_ledger.py b/addons/account/report/account_general_ledger.py index f3ec97a592e..b0e3d7a85d9 100644 --- a/addons/account/report/account_general_ledger.py +++ b/addons/account/report/account_general_ledger.py @@ -117,15 +117,15 @@ class general_ledger(rml_parse.rml_parse, common_report_header): sold_account = self._sum_balance_account(child_account) self.sold_accounts[child_account.id] = sold_account if self.display_account == 'bal_movement': - if child_account.type != 'view' and num_entry <> 0 : + if child_account.type != 'view' and num_entry <> 0: res.append(child_account) elif self.display_account == 'bal_solde': - if child_account.type != 'view' and num_entry <> 0 : + if child_account.type != 'view' and num_entry <> 0: if ( sold_account <> 0.0): res.append(child_account) else: res.append(child_account) - if not len(res): + if not res: return [account] return res diff --git a/addons/account/report/account_journal.py b/addons/account/report/account_journal.py index 4f6ad99792d..ab7b6211064 100644 --- a/addons/account/report/account_journal.py +++ b/addons/account/report/account_journal.py @@ -84,7 +84,7 @@ class journal_print(report_sxw.rml_parse, common_report_header): if self.target_move == 'posted': move_state = ['posted'] - self.cr.execute('SELECT SUM(debit) FROM account_move_line l , account_move am ' + self.cr.execute('SELECT SUM(debit) FROM account_move_line l, account_move am ' 'WHERE l.move_id=am.id AND am.state IN %s AND l.period_id IN %s AND l.journal_id IN %s ' + self.query_get_clause + ' ', (tuple(move_state), tuple(period_id), tuple(journal_id))) return self.cr.fetchone()[0] or 0.0 @@ -121,7 +121,7 @@ class journal_print(report_sxw.rml_parse, common_report_header): if self.target_move == 'posted': move_state = ['posted'] - self.cr.execute('SELECT l.id FROM account_move_line l, account_move am WHERE l.move_id=am.id AND am.state IN %s AND l.period_id=%s AND l.journal_id IN %s ' + self.query_get_clause + ' ORDER BY l.'+ self.sort_selection + '' ,(tuple(move_state), period_id, tuple(journal_id) )) + self.cr.execute('SELECT l.id FROM account_move_line l, account_move am WHERE l.move_id=am.id AND am.state IN %s AND l.period_id=%s AND l.journal_id IN %s ' + self.query_get_clause + ' ORDER BY l.'+ self.sort_selection + '',(tuple(move_state), period_id, tuple(journal_id) )) ids = map(lambda x: x[0], self.cr.fetchall()) return obj_mline.browse(self.cr, self.uid, ids) @@ -138,12 +138,12 @@ class journal_print(report_sxw.rml_parse, common_report_header): def _get_fiscalyear(self, data): if data['model'] == 'account.journal.period': return self.pool.get('account.journal.period').browse(self.cr, self.uid, data['id']).fiscalyear_id.name - return super(journal_print ,self)._get_fiscalyear(data) + return super(journal_print, self)._get_fiscalyear(data) def _get_account(self, data): if data['model'] == 'account.journal.period': return self.pool.get('account.journal.period').browse(self.cr, self.uid, data['id']).company_id.name - return super(journal_print ,self)._get_account(data) + return super(journal_print, self)._get_account(data) def _display_currency(self, data): if data['model'] == 'account.journal.period': diff --git a/addons/account/report/account_partner_balance.py b/addons/account/report/account_partner_balance.py index 06baa4639eb..c17de597e1c 100644 --- a/addons/account/report/account_partner_balance.py +++ b/addons/account/report/account_partner_balance.py @@ -83,7 +83,7 @@ class partner_balance(report_sxw.rml_parse, common_report_header): full_account = [] result_tmp = 0.0 self.cr.execute( - "SELECT p.ref,l.account_id,ac.name AS account_name,ac.code AS code ,p.name, sum(debit) AS debit, sum(credit) AS credit, " \ + "SELECT p.ref,l.account_id,ac.name AS account_name,ac.code AS code,p.name, sum(debit) AS debit, sum(credit) AS credit, " \ "CASE WHEN sum(debit) > sum(credit) " \ "THEN sum(debit) - sum(credit) " \ "ELSE 0 " \ @@ -254,7 +254,7 @@ class partner_balance(report_sxw.rml_parse, common_report_header): "JOIN account_move am ON (am.id = l.move_id)" \ "WHERE l.account_id IN %s" \ "AND am.state IN %s" \ - "AND " + self.query + "" , + "AND " + self.query + "", (tuple(self.account_ids), tuple(move_state))) temp_res = float(self.cr.fetchone()[0] or 0.0) return temp_res @@ -273,7 +273,7 @@ class partner_balance(report_sxw.rml_parse, common_report_header): "JOIN account_move am ON (am.id = l.move_id)" \ "WHERE l.account_id IN %s" \ "AND am.state IN %s" \ - "AND " + self.query + "" , + "AND " + self.query + "", (tuple(self.account_ids), tuple(move_state))) temp_res = float(self.cr.fetchone()[0] or 0.0) return temp_res diff --git a/addons/account/report/account_print_overdue.py b/addons/account/report/account_print_overdue.py index c59dd56a02f..3e1f0b54de1 100644 --- a/addons/account/report/account_print_overdue.py +++ b/addons/account/report/account_print_overdue.py @@ -30,11 +30,11 @@ class Overdue(report_sxw.rml_parse): def __init__(self, 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, - 'message' : self._message, + 'time': time, + 'adr_get': self._adr_get, + 'getLines': self._lines_get, + 'tel_get': self._tel_get, + 'message': self._message, }) self.context = context def _adr_get(self, partner, type): @@ -47,10 +47,10 @@ class Overdue(report_sxw.rml_parse): 'name': False, 'street': False, 'street2': False, - 'city' : False, - 'zip' : False, + 'city': False, + 'zip': False, 'state_id':False, - 'country_id' : False, + 'country_id': False, } if adr_id: result = res_partner_address.read(self.cr, self.uid, [adr_id], context=self.context.copy()) diff --git a/addons/account/report/rml_parse.py b/addons/account/report/rml_parse.py index 0c7018ae290..1d3cc629cfa 100644 --- a/addons/account/report/rml_parse.py +++ b/addons/account/report/rml_parse.py @@ -34,17 +34,17 @@ class rml_parse(report_sxw.rml_parse): self.localcontext.update({ 'comma_me': self.comma_me, 'format_date': self._get_and_change_date_format_for_swiss, - 'strip_name' : self._strip_name, - 'explode_name' : self._explode_name, + 'strip_name': self._strip_name, + 'explode_name': self._explode_name, }) def comma_me(self,amount): #print "#" + str(amount) + "#" if not amount: amount = 0.0 - if type(amount) is float : + if type(amount) is float: amount = str('%.2f'%amount) - else : + else: amount = str(amount) if (amount == '0'): return ' ' diff --git a/addons/account/sequence.py b/addons/account/sequence.py index b75e7f3e34e..52c1f5df8c4 100644 --- a/addons/account/sequence.py +++ b/addons/account/sequence.py @@ -43,13 +43,13 @@ ir_sequence_fiscalyear() class ir_sequence(osv.osv): _inherit = 'ir.sequence' _columns = { - 'fiscal_ids' : fields.one2many('account.sequence.fiscalyear', + 'fiscal_ids': fields.one2many('account.sequence.fiscalyear', 'sequence_main_id', 'Sequences') } def get_id(self, cr, uid, sequence_id, test='id', context=None): if context is None: context = {} - cr.execute('select id from ir_sequence where ' + cr.execute('select id from ir_sequence where ' + test + '=%s and active=%s', (sequence_id, True,)) res = cr.dictfetchone() if res: diff --git a/addons/account/wizard/account_change_currency.py b/addons/account/wizard/account_change_currency.py index 9355691369e..ebc11e1dabf 100644 --- a/addons/account/wizard/account_change_currency.py +++ b/addons/account/wizard/account_change_currency.py @@ -71,8 +71,8 @@ class account_change_currency(osv.osv_memory): if old_rate <= 0: raise osv.except_osv(_('Error'), _('Current currency is not confirured properly !')) new_price = (line.price_unit / old_rate ) * rate - obj_inv_line.write(cr, uid, [line.id], {'price_unit' : new_price}) - obj_inv.write(cr, uid, [invoice.id], {'currency_id' : new_currency}, context=context) + obj_inv_line.write(cr, uid, [line.id], {'price_unit': new_price}) + obj_inv.write(cr, uid, [invoice.id], {'currency_id': new_currency}, context=context) return {} account_change_currency() diff --git a/addons/account/wizard/account_fiscalyear_close.py b/addons/account/wizard/account_fiscalyear_close.py index d6d3b67c10e..e3d115ae30a 100644 --- a/addons/account/wizard/account_fiscalyear_close.py +++ b/addons/account/wizard/account_fiscalyear_close.py @@ -65,9 +65,9 @@ class account_fiscalyear_close(osv.osv_memory): context = {} fy_id = data[0]['fy_id'] - cr.execute("SELECT id FROM account_period WHERE date_stop < (SELECT date_start FROM account_fiscalyear WHERE id = %s)" , (str(data[0]['fy2_id']),)) + cr.execute("SELECT id FROM account_period WHERE date_stop < (SELECT date_start FROM account_fiscalyear WHERE id = %s)", (str(data[0]['fy2_id']),)) fy_period_set = ','.join(map(lambda id: str(id[0]), cr.fetchall())) - cr.execute("SELECT id FROM account_period WHERE date_start > (SELECT date_stop FROM account_fiscalyear WHERE id = %s)" , (str(fy_id),)) + cr.execute("SELECT id FROM account_period WHERE date_start > (SELECT date_stop FROM account_fiscalyear WHERE id = %s)", (str(fy_id),)) fy2_period_set = ','.join(map(lambda id: str(id[0]), cr.fetchall())) period = obj_acc_period.browse(cr, uid, data[0]['period_id'], context=context) diff --git a/addons/account/wizard/account_move_journal.py b/addons/account/wizard/account_move_journal.py index c03176a0536..fc0953b93fa 100644 --- a/addons/account/wizard/account_move_journal.py +++ b/addons/account/wizard/account_move_journal.py @@ -33,7 +33,7 @@ class account_move_journal(osv.osv_memory): """ ids = self.pool.get('account.period').find(cr, uid, context=context) period_id = False - if len(ids): + if ids: period_id = ids[0] return period_id diff --git a/addons/project/project.py b/addons/project/project.py index 27bbb2f8c7f..c0f9be5394e 100644 --- a/addons/project/project.py +++ b/addons/project/project.py @@ -315,7 +315,7 @@ class project(osv.osv): if child_ids: self.setActive(cr, uid, child_ids, value, context=None) return True - + project() class users(osv.osv): @@ -418,7 +418,7 @@ class task(osv.osv): 'active': fields.function(_is_template, method=True, store=True, string='Not a Template Task', type='boolean', help="This field is computed automatically and have the same behavior than the boolean 'active' field: if the task is linked to a template or unactivated project, it will be hidden unless specifically asked."), 'name': fields.char('Task Summary', size=128, required=True), 'description': fields.text('Description'), - 'priority' : fields.selection([('4','Very Low'), ('3','Low'), ('2','Medium'), ('1','Urgent'), ('0','Very urgent')], 'Priority'), + 'priority': fields.selection([('4','Very Low'), ('3','Low'), ('2','Medium'), ('1','Urgent'), ('0','Very urgent')], 'Priority'), 'sequence': fields.integer('Sequence', help="Gives the sequence order when displaying a list of tasks."), 'type_id': fields.many2one('project.task.type', 'Stage',), 'state': fields.selection([('draft', 'Draft'),('open', 'In Progress'),('pending', 'Pending'), ('cancelled', 'Cancelled'), ('done', 'Done')], 'State', readonly=True, required=True, @@ -526,7 +526,7 @@ class task(osv.osv): if not project_id: return False task = self.browse(cr, uid, project_id, context=context) project = task.project_id - res = self.do_close(cr, uid, [project_id], context=context) + res = self.do_close(cr, uid, [project_id], context=context) if project.warn_manager or project.warn_customer: return { 'name': _('Send Email after close task'), @@ -537,7 +537,7 @@ class task(osv.osv): 'target': 'new', 'nodestroy': True, 'context': {'active_id': task.id} - } + } return res def do_close(self, cr, uid, ids, context=None): @@ -678,7 +678,7 @@ class task(osv.osv): if types: if not typeid: self.write(cr, uid, task.id, {'type_id': types[0]}) - elif typeid and typeid in types and types.index(typeid) != len(types)-1 : + elif typeid and typeid in types and types.index(typeid) != len(types)-1: index = types.index(typeid) self.write(cr, uid, task.id, {'type_id': types[index+1]}) return True From d10e1e83afdc3ca4300dd23c6b482337cce7d932 Mon Sep 17 00:00:00 2001 From: "ARA (OpenERP)" Date: Mon, 11 Oct 2010 11:33:40 +0530 Subject: [PATCH 02/26] [REF] cleaning code of account bzr revid: ara@tinyerp.com-20101011060340-v55iqbqk378atwnq --- addons/account/account_analytic_line.py | 14 ++++++------ addons/account/account_cash_statement.py | 2 +- .../report/account_aged_partner_balance.py | 22 +++++++++---------- .../report/account_analytic_entries_report.py | 2 +- .../account/report/account_central_journal.py | 7 +++--- .../wizard/account_automatic_reconcile.py | 2 +- .../account/wizard/account_invoice_refund.py | 22 +++++++++---------- .../wizard/account_move_line_select.py | 4 ++-- addons/account/wizard/account_reconcile.py | 8 +++---- addons/account/wizard/account_unreconcile.py | 2 +- 10 files changed, 43 insertions(+), 42 deletions(-) diff --git a/addons/account/account_analytic_line.py b/addons/account/account_analytic_line.py index bb13f1a5776..de4948f0bd1 100644 --- a/addons/account/account_analytic_line.py +++ b/addons/account/account_analytic_line.py @@ -31,12 +31,12 @@ class account_analytic_line(osv.osv): _inherit = 'account.analytic.line' _description = 'Analytic Line' _columns = { - 'product_uom_id' : fields.many2one('product.uom', 'UoM'), - 'product_id' : fields.many2one('product.product', 'Product'), - 'general_account_id' : fields.many2one('account.account', 'General Account', required=True, ondelete='cascade'), - 'move_id' : fields.many2one('account.move.line', 'Move Line', ondelete='cascade', select=True), - 'journal_id' : fields.many2one('account.analytic.journal', 'Analytic Journal', required=True, ondelete='cascade', select=True), - 'code' : fields.char('Code', size=8), + 'product_uom_id': fields.many2one('product.uom', 'UoM'), + 'product_id': fields.many2one('product.product', 'Product'), + 'general_account_id': fields.many2one('account.account', 'General Account', required=True, ondelete='cascade'), + 'move_id': fields.many2one('account.move.line', 'Move Line', ondelete='cascade', select=True), + 'journal_id': fields.many2one('account.analytic.journal', 'Analytic Journal', required=True, ondelete='cascade', select=True), + 'code': fields.char('Code', size=8), 'ref': fields.char('Ref.', size=64), 'currency_id': fields.related('move_id', 'currency_id', type='many2one', relation='res.currency', string='Account currency', store=True, help="The related account currency if not equal to the company one.", readonly=True), 'amount_currency': fields.related('move_id', 'amount_currency', type='float', string='Amount currency', store=True, help="The amount expressed in the related account currency if not equal to the company one.", readonly=True), @@ -88,7 +88,7 @@ class account_analytic_line(osv.osv): company_id = j_id.company_id.id result = 0.0 is_purchase = False - + if j_id.type <> 'sale': a = prod.product_tmpl_id.property_account_expense.id if not a: diff --git a/addons/account/account_cash_statement.py b/addons/account/account_cash_statement.py index 86690b204b9..445072605ed 100644 --- a/addons/account/account_cash_statement.py +++ b/addons/account/account_cash_statement.py @@ -229,7 +229,7 @@ class account_cash_statement(osv.osv): 'balance_end_cash': fields.function(_balance_end_cash, method=True, store=True, string='Balance', help="Closing balance based on cashBox"), 'starting_details_ids': fields.one2many('account.cashbox.line', 'starting_id', string='Opening Cashbox'), 'ending_details_ids': fields.one2many('account.cashbox.line', 'ending_id', string='Closing Cashbox'), - 'name': fields.char('Name', size=64, required=True, states={'draft': [('readonly', False)]}, readonly=True, help='if you give the Name other then / , its created Accounting Entries Move will be with same name as statement name. This allows the statement entries to have the same references than the statement itself'), + 'name': fields.char('Name', size=64, required=True, states={'draft': [('readonly', False)]}, readonly=True, help='if you give the Name other then /, its created Accounting Entries Move will be with same name as statement name. This allows the statement entries to have the same references than the statement itself'), 'user_id':fields.many2one('res.users', 'Responsible', required=False), } _defaults = { diff --git a/addons/account/report/account_aged_partner_balance.py b/addons/account/report/account_aged_partner_balance.py index 5a1b8ac868b..b15fab65c63 100644 --- a/addons/account/report/account_aged_partner_balance.py +++ b/addons/account/report/account_aged_partner_balance.py @@ -71,7 +71,7 @@ class aged_trial_report(rml_parse.rml_parse, common_report_header): OR (reconcile_id IN (SELECT recon.id FROM account_move_reconcile AS recon WHERE recon.create_date > %s )))\ AND (l.partner_id=res_partner.id)\ AND ' + self.query + ' \ - ORDER BY res_partner.name' , (self.date_from,)) + ORDER BY res_partner.name', (self.date_from,)) partners = self.cr.dictfetchall() ## mise a 0 du total for i in range(7): @@ -95,7 +95,7 @@ class aged_trial_report(rml_parse.rml_parse, common_report_header): OR (l.reconcile_id IN (SELECT recon.id FROM account_move_reconcile AS recon WHERE recon.create_date > %s )))\ AND ' + self.query + '\ AND account_account.active\ - GROUP BY partner_id ' , (tuple(move_state), tuple(self.ACCOUNT_TYPE), tuple(partner_ids), self.date_from)) + GROUP BY partner_id ', (tuple(move_state), tuple(self.ACCOUNT_TYPE), tuple(partner_ids), self.date_from)) t = self.cr.fetchall() for i in t: totals[i[0]] = i[1] @@ -130,7 +130,7 @@ class aged_trial_report(rml_parse.rml_parse, common_report_header): OR (l.reconcile_id IN (SELECT recon.id FROM account_move_reconcile AS recon WHERE recon.create_date > %s )))\ AND '+ self.query + '\ AND account_account.active\ - GROUP BY l.partner_id' , (tuple(move_state), tuple(self.ACCOUNT_TYPE), self.date_from, tuple(partner_ids), self.date_from)) + GROUP BY l.partner_id', (tuple(move_state), tuple(self.ACCOUNT_TYPE), self.date_from, tuple(partner_ids), self.date_from)) t = self.cr.fetchall() for i in t: future_past[i[0]] = i[1] @@ -139,7 +139,7 @@ class aged_trial_report(rml_parse.rml_parse, common_report_header): # Each history will contain : history[1] = {'': } history = [] for i in range(5): - args_list = (tuple(move_state), tuple(self.ACCOUNT_TYPE), tuple(partner_ids) ,self.date_from,) + args_list = (tuple(move_state), tuple(self.ACCOUNT_TYPE), tuple(partner_ids),self.date_from,) dates_query = '(COALESCE(l.date_maturity,l.date)' if form[str(i)]['start'] and form[str(i)]['stop']: dates_query += ' BETWEEN %s AND %s)' @@ -152,7 +152,7 @@ class aged_trial_report(rml_parse.rml_parse, common_report_header): args_list += (form[str(i)]['stop'],) self.cr.execute('SELECT l.partner_id, SUM(l.debit-l.credit)\ - FROM account_move_line AS l, account_account , account_move am \ + FROM account_move_line AS l, account_account, account_move am \ WHERE (l.account_id = account_account.id) AND (l.move_id=am.id)\ AND (am.state IN %s)\ AND (account_account.type IN %s)\ @@ -162,7 +162,7 @@ class aged_trial_report(rml_parse.rml_parse, common_report_header): AND '+ self.query + '\ AND account_account.active\ AND ' + dates_query + '\ - GROUP BY l.partner_id' , args_list) + GROUP BY l.partner_id', args_list) t = self.cr.fetchall() d = {} for i in t: @@ -227,7 +227,7 @@ class aged_trial_report(rml_parse.rml_parse, common_report_header): self.total_account.append(0) totals = {} self.cr.execute('SELECT SUM(l.debit-l.credit) \ - FROM account_move_line AS l, account_account , account_move am \ + FROM account_move_line AS l, account_account, account_move am \ WHERE (l.account_id = account_account.id) AND (l.move_id=am.id)\ AND (am.state IN %s)\ AND (l.partner_id IS NULL)\ @@ -235,7 +235,7 @@ class aged_trial_report(rml_parse.rml_parse, common_report_header): AND ((l.reconcile_id IS NULL) \ OR (l.reconcile_id IN (SELECT recon.id FROM account_move_reconcile AS recon WHERE recon.create_date > %s )))\ AND ' + self.query + '\ - AND account_account.active ' ,(tuple(move_state), tuple(self.ACCOUNT_TYPE), self.date_from)) + AND account_account.active ',(tuple(move_state), tuple(self.ACCOUNT_TYPE), self.date_from)) t = self.cr.fetchall() for i in t: totals['Unknown Partner'] = i[0] @@ -266,7 +266,7 @@ class aged_trial_report(rml_parse.rml_parse, common_report_header): AND ((l.reconcile_id IS NULL)\ OR (l.reconcile_id IN (SELECT recon.id FROM account_move_reconcile AS recon WHERE recon.create_date > %s )))\ AND '+ self.query + '\ - AND account_account.active ' , (tuple(move_state), tuple(self.ACCOUNT_TYPE), self.date_from, self.date_from)) + AND account_account.active ', (tuple(move_state), tuple(self.ACCOUNT_TYPE), self.date_from, self.date_from)) t = self.cr.fetchall() for i in t: future_past['Unknown Partner'] = i[0] @@ -286,7 +286,7 @@ class aged_trial_report(rml_parse.rml_parse, common_report_header): args_list += (form[str(i)]['stop'],) self.cr.execute('SELECT SUM(l.debit-l.credit)\ - FROM account_move_line AS l, account_account , account_move am \ + FROM account_move_line AS l, account_account, account_move am \ WHERE (l.account_id = account_account.id) AND (l.move_id=am.id)\ AND (am.state IN %s)\ AND (account_account.type IN %s)\ @@ -296,7 +296,7 @@ class aged_trial_report(rml_parse.rml_parse, common_report_header): AND '+ self.query + '\ AND account_account.active\ AND ' + dates_query + '\ - GROUP BY l.partner_id' , args_list) + GROUP BY l.partner_id', args_list) t = self.cr.fetchall() d = {} for i in t: diff --git a/addons/account/report/account_analytic_entries_report.py b/addons/account/report/account_analytic_entries_report.py index aa0c5b3ba99..a53e19721dd 100644 --- a/addons/account/report/account_analytic_entries_report.py +++ b/addons/account/report/account_analytic_entries_report.py @@ -33,7 +33,7 @@ class analytic_entries_report(osv.osv): 'month':fields.selection([('01','January'), ('02','February'), ('03','March'), ('04','April'), ('05','May'), ('06','June'), ('07','July'), ('08','August'), ('09','September'), ('10','October'), ('11','November'), ('12','December')], 'Month',readonly=True), - 'user_id' : fields.many2one('res.users', 'User',readonly=True), + 'user_id': fields.many2one('res.users', 'User',readonly=True), 'name': fields.char('Description', size=64, readonly=True), 'partner_id': fields.many2one('res.partner', 'Partner'), 'company_id': fields.many2one('res.company', 'Company', required=True), diff --git a/addons/account/report/account_central_journal.py b/addons/account/report/account_central_journal.py index d3693ecb152..35f1e666c6f 100644 --- a/addons/account/report/account_central_journal.py +++ b/addons/account/report/account_central_journal.py @@ -71,11 +71,12 @@ class journal_print(report_sxw.rml_parse, common_report_header): move_state = ['draft','posted'] if self.target_move == 'posted': move_state = ['posted'] + self.cr.execute('SELECT a.currency_id ,a.code, a.name, c.code AS currency_code, l.currency_id, l.amount_currency, SUM(debit) AS debit, SUM(credit) AS credit \ from account_move_line l \ LEFT JOIN account_move am ON (l.move_id=am.id) \ LEFT JOIN account_account a ON (l.account_id=a.id) \ - LEFT JOIN res_currency c on (l.currency_id=c.id) WHERE am.state IN %s AND l.period_id=%s AND l.journal_id=%s '+self.query_get_clause+' GROUP BY a.id, a.code, a.name,l.amount_currency,c.code , a.currency_id,l.currency_id', (tuple(move_state), period_id, journal_id)) + LEFT JOIN res_currency c on (l.currency_id=c.id) WHERE am.state IN %s AND l.period_id=%s AND l.journal_id=%s '+self.query_get_clause+' GROUP BY a.id, a.code, a.name,l.amount_currency,c.code, a.currency_id,l.currency_id', (tuple(move_state), period_id, journal_id)) return self.cr.dictfetchall() def _set_get_account_currency_code(self, account_id): @@ -91,12 +92,12 @@ class journal_print(report_sxw.rml_parse, common_report_header): def _get_account(self, data): if data['model'] == 'account.journal.period': return self.pool.get('account.journal.period').browse(self.cr, self.uid, data['id']).company_id.name - return super(journal_print ,self)._get_account(data) + return super(journal_print,self)._get_account(data) def _get_fiscalyear(self, data): if data['model'] == 'account.journal.period': return self.pool.get('account.journal.period').browse(self.cr, self.uid, data['id']).fiscalyear_id.name - return super(journal_print ,self)._get_fiscalyear(data) + return super(journal_print,self)._get_fiscalyear(data) def _display_currency(self, data): if data['model'] == 'account.journal.period': diff --git a/addons/account/wizard/account_automatic_reconcile.py b/addons/account/wizard/account_automatic_reconcile.py index 6a1afc45bcf..5939437ce1d 100644 --- a/addons/account/wizard/account_automatic_reconcile.py +++ b/addons/account/wizard/account_automatic_reconcile.py @@ -170,7 +170,7 @@ class account_automatic_reconcile(osv.osv_memory): "AND reconcile_id IS NULL", (account_id, partner_id)) line_ids = [id for (id,) in cr.fetchall()] - if len(line_ids): + if line_ids: reconciled += len(line_ids) if allow_write_off: move_line_obj.reconcile(cr, uid, line_ids, 'auto', form['writeoff_acc_id'], form['period_id'], form['journal_id'], context) diff --git a/addons/account/wizard/account_invoice_refund.py b/addons/account/wizard/account_invoice_refund.py index c7e75f205f8..29d67859ca5 100644 --- a/addons/account/wizard/account_invoice_refund.py +++ b/addons/account/wizard/account_invoice_refund.py @@ -100,7 +100,7 @@ class account_invoice_refund(osv.osv_memory): raise osv.except_osv(_('Error !'), _('Can not %s draft/proforma/cancel invoice.') % (mode)) if inv.reconciled and mode in ('cancel', 'modify'): raise osv.except_osv(_('Error !'), _('Can not %s invoice which is already reconciled, invoice should be unreconciled first. You can only Refund this invoice') % (mode)) - if form['period'] : + if form['period']: period = form['period'] else: period = inv.period_id and inv.period_id.id or False @@ -108,9 +108,9 @@ class account_invoice_refund(osv.osv_memory): if not journal_id: journal_id = inv.journal_id.id - if form['date'] : + if form['date']: date = form['date'] - if not form['period'] : + if not form['period']: cr.execute("select name from ir_model_fields \ where model = 'account.period' \ and name = 'company_id'") @@ -128,7 +128,7 @@ class account_invoice_refund(osv.osv_memory): period = res[0] else: date = inv.date_invoice - if form['description'] : + if form['description']: description = form['description'] else: description = inv.name @@ -147,18 +147,18 @@ class account_invoice_refund(osv.osv_memory): if mode in ('cancel', 'modify'): movelines = inv.move_id.line_id to_reconcile_ids = {} - for line in movelines : - if line.account_id.id == inv.account_id.id : + for line in movelines: + if line.account_id.id == inv.account_id.id: to_reconcile_ids[line.account_id.id] = [line.id] - if type(line.reconcile_id) != osv.orm.browse_null : + if type(line.reconcile_id) != osv.orm.browse_null: reconcile_obj.unlink(cr, uid, line.reconcile_id.id) wf_service.trg_validate(uid, 'account.invoice', \ refund.id, 'invoice_open', cr) refund = inv_obj.browse(cr, uid, refund_id[0], context=context) - for tmpline in refund.move_id.line_id : - if tmpline.account_id.id == inv.account_id.id : + for tmpline in refund.move_id.line_id: + if tmpline.account_id.id == inv.account_id.id: to_reconcile_ids[tmpline.account_id.id].append(tmpline.id) - for account in to_reconcile_ids : + for account in to_reconcile_ids: account_m_line_obj.reconcile(cr, uid, to_reconcile_ids[account], writeoff_period_id=period, writeoff_journal_id = inv.journal_id.id, @@ -214,7 +214,7 @@ class account_invoice_refund(osv.osv_memory): return result def invoice_refund(self, cr, uid, ids, context=None): - data_refund = self.read(cr, uid, ids, [] ,context=context)[0]['filter_refund'] + data_refund = self.read(cr, uid, ids, [],context=context)[0]['filter_refund'] return self.compute_refund(cr, uid, ids, data_refund, context=context) account_invoice_refund() diff --git a/addons/account/wizard/account_move_line_select.py b/addons/account/wizard/account_move_line_select.py index 546bb08c754..86345703f6f 100644 --- a/addons/account/wizard/account_move_line_select.py +++ b/addons/account/wizard/account_move_line_select.py @@ -46,7 +46,7 @@ class account_move_line_select(osv.osv_memory): fiscalyears = fiscalyear_obj.browse(cr, uid, fiscalyear_ids) period_ids = [] - if fiscalyears : + if fiscalyears: for fiscalyear in fiscalyears: for period in fiscalyear.period_ids: period_ids.append(period.id) @@ -56,7 +56,7 @@ class account_move_line_select(osv.osv_memory): id = mod_obj.read(cr, uid, [result], ['res_id'])[0]['res_id'] result = act_obj.read(cr, uid, [id])[0] result['context'] = { - 'fiscalyear': False , + 'fiscalyear': False, 'account_id': context['active_id'], 'active_id': context['active_id'], } diff --git a/addons/account/wizard/account_reconcile.py b/addons/account/wizard/account_reconcile.py index c1d9854d014..13fea538532 100644 --- a/addons/account/wizard/account_reconcile.py +++ b/addons/account/wizard/account_reconcile.py @@ -83,7 +83,7 @@ class account_move_line_reconcile(osv.osv_memory): data = self.read(cr, uid, ids, context=context) date = time.strftime('%Y-%m-%d') ids = self.pool.get('account.period').find(cr, uid, dt=date, context=context) - if len(ids): + if ids: period_id = ids[0] #stop the reconciliation process by partner (manual reconciliation) only if there is nothing more to reconcile for this partner if 'active_ids' in context and context['active_ids']: @@ -93,10 +93,10 @@ class account_move_line_reconcile(osv.osv_memory): credit_ml_ids = account_move_line_obj.search(cr, uid, [('partner_id', '=', partner_id), ('account_id.reconcile', '=', True), ('reconcile_id', '=', False), ('credit', '>', 0)], context=context) for ml_id in context['active_ids']: if ml_id in debit_ml_ids: - debit_ml_ids.remove(ml_id) + debit_ml_ids.remove(ml_id) if ml_id in credit_ml_ids: credit_ml_ids.remove(ml_id) - if not (len(debit_ml_ids) and len(credit_ml_ids)): + if not debit_ml_ids and credit_ml_ids: context.update({'stop_reconcile': True}) account_move_line_obj.reconcile(cr, uid, context['active_ids'], 'manual', account_id, period_id, journal_id, context=context) @@ -161,7 +161,7 @@ class account_move_line_reconcile_writeoff(osv.osv_memory): date = context['date_p'] ids = self.pool.get('account.period').find(cr, uid, dt=date, context=context) - if len(ids): + if ids: period_id = ids[0] context.update({'stop_reconcile': True}) diff --git a/addons/account/wizard/account_unreconcile.py b/addons/account/wizard/account_unreconcile.py index 1e647742f4a..2a77cd8fb66 100644 --- a/addons/account/wizard/account_unreconcile.py +++ b/addons/account/wizard/account_unreconcile.py @@ -44,7 +44,7 @@ class account_unreconcile_reconcile(osv.osv_memory): rec_ids = context['active_ids'] if context is None: context = {} - if len(rec_ids): + if rec_ids: obj_move_reconcile.unlink(cr, uid, rec_ids) return {} From 301ff85dca7949d718278f962ffdd9bec835fdfb Mon Sep 17 00:00:00 2001 From: "psi (Open ERP)" Date: Mon, 11 Oct 2010 11:37:52 +0530 Subject: [PATCH 03/26] [IMP] event: code cleaning bzr revid: psi@tinyerp.co.in-20101011060752-wycy59vnqnb11k2s --- addons/event/event.py | 62 ++++++++-------- .../event/report/report_event_registration.py | 70 +++++++++---------- .../wizard/event_confirm_registration.py | 6 +- addons/event/wizard/event_make_invoice.py | 7 +- .../wizard/partner_event_registration.py | 23 +++--- 5 files changed, 87 insertions(+), 81 deletions(-) diff --git a/addons/event/event.py b/addons/event/event.py index fc01ae8bdfc..e2d51474689 100644 --- a/addons/event/event.py +++ b/addons/event/event.py @@ -90,10 +90,10 @@ class event_event(crm.crm_case, osv.osv): #send reminder that will confirm the event for all the people that were already confirmed reg_ids = register_pool.search(cr, uid, [ ('event_id', '=', event.id), - ('state', 'not in', ['draft', 'cancel'])]) + ('state', 'not in', ['draft', 'cancel'])], context=context) register_pool.mail_user_confirm(cr, uid, reg_ids) - return self.write(cr, uid, ids, {'state': 'confirm'}) + return self.write(cr, uid, ids, {'state': 'confirm'}, context=context) def button_confirm(self, cr, uid, ids, context=None): """This Function Confirm Event. @@ -116,7 +116,7 @@ class event_event(crm.crm_case, osv.osv): unconfirmed_ids.append(event.id) if unconfirmed_ids: view_id = data_pool._get_id(cr, uid, 'event', 'view_event_confirm') - view_data = data_pool.browse(cr, uid, view_id) + view_data = data_pool.browse(cr, uid, view_id, context=context) view_id = view_data.res_id context['event_ids'] = unconfirmed_ids return { @@ -143,7 +143,7 @@ class event_event(crm.crm_case, osv.osv): """ register_pool = self.pool.get('event.registration') res = {} - for event in self.browse(cr, uid, ids, context): + for event in self.browse(cr, uid, ids, context=context): res[event.id] = {} for field in fields: res[event.id][field] = False @@ -155,11 +155,11 @@ class event_event(crm.crm_case, osv.osv): reg_ids = register_pool.search(cr, uid, [ ('event_id', '=', event.id), - ('state', 'in', state)]) + ('state', 'in', state)], context=context) number = 0.0 if reg_ids: - cr.execute('select sum(nb_register) from event_registration where id IN %s', (tuple(reg_ids),)) + cr.execute('SELECT SUM(nb_register) FROM event_registration WHERE id IN %s', (tuple(reg_ids),)) number = cr.fetchone() if 'register_current' in fields: res[event.id]['register_current'] = number and number[0] @@ -194,8 +194,8 @@ class event_event(crm.crm_case, osv.osv): register_values['description'] = vals['mail_confirm'] if register_values: - reg_ids = register_pool.search(cr, uid, [('event_id', '=', event.id)]) - register_pool.write(cr, uid, reg_ids, register_values) + reg_ids = register_pool.search(cr, uid, [('event_id', '=', event.id)], context=context) + register_pool.write(cr, uid, reg_ids, register_values, context=context) return res _columns = { @@ -231,7 +231,7 @@ class event_event(crm.crm_case, osv.osv): 'pricelist_id': fields.many2one('product.pricelist', 'Pricelist', readonly=True, states={'draft': [('readonly', False)]}, help="Pricelist version for current event."), 'unit_price': fields.related('product_id', 'list_price', type='float', string='Registration Cost', readonly=True, states={'draft':[('readonly',False)]}, help="This will be the default price used as registration cost when invoicing this event. Note that you can specify for each registration a specific amount if you want to", digits_compute=dp.get_precision('Sale Price')), 'main_speaker_id': fields.many2one('res.partner','Main Speaker', readonly=False, states={'done': [('readonly', True)]}, help="Speaker who are giving speech on event."), - 'speaker_ids':fields.many2many('res.partner', 'event_speaker_rel', 'speaker_id', 'partner_id', 'Other Speakers', readonly=False, states={'done': [('readonly', True)]}), + 'speaker_ids': fields.many2many('res.partner', 'event_speaker_rel', 'speaker_id', 'partner_id', 'Other Speakers', readonly=False, states={'done': [('readonly', True)]}), 'address_id': fields.many2one('res.partner.address','Location Address', readonly=False, states={'done': [('readonly', True)]}), 'speaker_confirmed': fields.boolean('Speaker Confirmed', readonly=False, states={'done': [('readonly', True)]}), 'country_id': fields.related('address_id', 'country_id', @@ -239,7 +239,6 @@ class event_event(crm.crm_case, osv.osv): 'language': fields.char('Language',size=64, readonly=False, states={'done': [('readonly', True)]}), 'note': fields.text('Description', readonly=False, states={'done': [('readonly', True)]}), 'company_id': fields.many2one('res.company', 'Company', required=False, change_default=True, readonly=False, states={'done': [('readonly', True)]}), - } _defaults = { @@ -256,7 +255,7 @@ class event_event(crm.crm_case, osv.osv): level = 100 while len(ids): - cr.execute('select distinct parent_id from event_event where id IN %s', (tuple(ids),)) + cr.execute('SELECT DISTINCT parent_id FROM event_event WHERE id IN %s', (tuple(ids),)) ids = filter(None, map(lambda x: x[0], cr.fetchall())) if not level: return False @@ -359,7 +358,7 @@ class event_registration(osv.osv): val_invoice = inv_pool.onchange_partner_id(cr, uid, [], 'out_invoice', reg.partner_invoice_id.id, False, False) val_invoice['value'].update({'partner_id': reg.partner_invoice_id.id}) - inv_lines_pool.product_id_change(cr, uid, [], reg.event_id.product_id.id, uom =False, partner_id=reg.partner_invoice_id.id, fposition_id=reg.partner_invoice_id.property_account_position.id) + inv_lines_pool.product_id_change(cr, uid, [], reg.event_id.product_id.id, uom=False, partner_id=reg.partner_invoice_id.id, fposition_id=reg.partner_invoice_id.property_account_position.id) val_invoice['value'].update({ 'origin': reg.event_product, @@ -368,7 +367,7 @@ class event_registration(osv.osv): 'comment': "", 'date_invoice': context.get('date_inv', False) }) - inv_id = inv_pool.create(cr, uid, val_invoice['value']) + inv_id = inv_pool.create(cr, uid, val_invoice['value'], context=context) inv_pool.button_compute(cr, uid, [inv_id]) self.history(cr, uid, [reg], _('Invoiced')) return inv_id @@ -469,12 +468,12 @@ class event_registration(osv.osv): for registration in self.browse(cr, uid, ids, context=context): total_confirmed = registration.event_id.register_current + registration.nb_register if total_confirmed <= registration.event_id.register_max or registration.event_id.register_max == 0: - self.do_open(cr, uid, [registration.id], context) + self.do_open(cr, uid, [registration.id], context=context) else: unconfirmed_ids.append(registration.id) if unconfirmed_ids: view_id = data_pool._get_id(cr, uid, 'event', 'view_event_confirm_registration') - view_data = data_pool.browse(cr, uid, view_id) + view_data = data_pool.browse(cr, uid, view_id, context=context) view_id = view_data.res_id context['registration_ids'] = unconfirmed_ids return { @@ -502,10 +501,10 @@ class event_registration(osv.osv): if registration.tobe_invoiced and not registration.invoice_id: unclosed_ids.append(registration.id) else: - self.do_close(cr, uid, [registration.id]) + self.do_close(cr, uid, [registration.id], context=context) if unclosed_ids: view_id = data_pool._get_id(cr, uid, 'event', 'view_event_make_invoice') - view_data = data_pool.browse(cr, uid, view_id) + view_data = data_pool.browse(cr, uid, view_id, context=context) view_id = view_data.res_id context['active_ids'] = unclosed_ids return { @@ -561,10 +560,10 @@ class event_registration(osv.osv): body = regestration.event_id.mail_confirm if subject or body: tools.email_send(src, email_to, subject, body, email_cc = email_cc, openobject_id = regestration.id) - self.history(cr, uid, [regestration], subject, history=True, \ - email=email_to, details=body, \ - subject=subject, email_from=src, \ - email_cc=', '.join(email_cc)) + self.history(cr, uid, [regestration], subject, history = True, \ + email = email_to, details = body, \ + subject = subject, email_from = src, \ + email_cc = ', '.join(email_cc)) return True @@ -620,12 +619,17 @@ class event_registration(osv.osv): res_obj = self.pool.get('res.partner') data_event = event_obj.browse(cr, uid, event_id) - res = {'value': {'unit_price': False, 'event_product': False, 'user_id': False, - 'date': data_event.date_begin, 'date_deadline': data_event.date_end, 'description': data_event.note, 'name': data_event.name, - 'section_id': data_event.section_id and data_event.section_id.id or False, + res = {'value': {'unit_price': False, + 'event_product': False, + 'user_id': False, + 'date': data_event.date_begin, + 'date_deadline': data_event.date_end, + 'description': data_event.note, + 'name': data_event.name, + 'section_id': data_event.section_id and data_event.section_id.id or False, }} if data_event.user_id.id: - res['value'].update({'user_id':data_event.user_id.id}) + res['value'].update({'user_id': data_event.user_id.id}) if data_event.product_id: pricelist_id = data_event.pricelist_id and data_event.pricelist_id.id or False if partner_invoice_id: @@ -653,7 +657,7 @@ class event_registration(osv.osv): data['contact_id'], data['partner_invoice_id'], data['email_from'] = (False, False, False) if not part: return {'value': data} - data['partner_invoice_id']=part + data['partner_invoice_id'] = part # this calls onchange_partner_invoice_id d = self.onchange_partner_invoice_id(cr, uid, ids, event_id, part) # this updates the dictionary @@ -677,8 +681,8 @@ class event_registration(osv.osv): @param event_id: Event ID @param partner_invoice_id: Partner Invoice ID """ - data={} - context={} + data = {} + context = {} event_obj = self.pool.get('event.event') prod_obj = self.pool.get('product.product') res_obj = self.pool.get('res.partner') @@ -686,7 +690,7 @@ class event_registration(osv.osv): data['unit_price']=False if not event_id: return {'value': data} - data_event = event_obj.browse(cr, uid, event_id) + data_event = event_obj.browse(cr, uid, event_id, context=context) if data_event.product_id: data['event_product'] = data_event.product_id.name pricelist_id = data_event.pricelist_id and data_event.pricelist_id.id or False diff --git a/addons/event/report/report_event_registration.py b/addons/event/report/report_event_registration.py index f74b7d31567..1aa0af9ee2b 100644 --- a/addons/event/report/report_event_registration.py +++ b/addons/event/report/report_event_registration.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- ############################################################################## -# +# # OpenERP, Open Source Management Solution # Copyright (C) 2004-2010 Tiny SPRL (). # @@ -15,7 +15,7 @@ # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . +# along with this program. If not, see . # ############################################################################## @@ -23,7 +23,7 @@ from osv import fields, osv import tools class report_event_registration(osv.osv): - + _name = "report.event.registration" _description = "Events on registrations and Events on type" _auto = False @@ -31,19 +31,19 @@ class report_event_registration(osv.osv): _columns = { 'date': fields.date('Date', readonly=True), 'year': fields.char('Year', size=4, readonly=True), - 'month':fields.selection([('01','January'), ('02','February'), ('03','March'), ('04','April'), + 'month': fields.selection([('01','January'), ('02','February'), ('03','March'), ('04','April'), ('05','May'), ('06','June'), ('07','July'), ('08','August'), ('09','September'), ('10','October'), ('11','November'), ('12','December')], 'Month',readonly=True), - 'day': fields.char('Day', size=128, readonly=True), - 'event_id': fields.many2one('event.event', 'Event Related', required=True), - 'draft_state': fields.integer(' # No of draft Registration.', size=20), - 'confirm_state': fields.integer(' # No of Confirm Registration', size=20), - 'register_max': fields.integer('Maximum Registrations'), - 'nbevent': fields.integer('Number Of Events'), + 'day': fields.char('Day', size=128, readonly=True), + 'event_id': fields.many2one('event.event', 'Event Related', required=True), + 'draft_state': fields.integer(' # No of draft Registration.', size=20), + 'confirm_state': fields.integer(' # No of Confirm Registration', size=20), + 'register_max': fields.integer('Maximum Registrations'), + 'nbevent': fields.integer('Number Of Events'), 'type': fields.many2one('event.type', 'Event Type'), 'state': fields.selection([('draft', 'Draft'), ('confirm', 'Confirmed'), ('done', 'Done'), ('cancel', 'Cancelled')], 'State', readonly=True, required=True), - 'user_id':fields.many2one('res.users', 'Responsible', readonly=True), - 'speaker_id':fields.many2one('res.partner', 'Speaker', readonly=True), + 'user_id': fields.many2one('res.users', 'Responsible', readonly=True), + 'speaker_id': fields.many2one('res.partner', 'Speaker', readonly=True), } _order = 'date desc' def init(self, cr): @@ -53,32 +53,32 @@ class report_event_registration(osv.osv): """ tools.drop_view_if_exists(cr, 'report_event_registration') cr.execute(""" - create or replace view report_event_registration as ( - select - e.id as id, - c.event_id as event_id, - e.date_begin as date, - e.user_id as user_id, - e.main_speaker_id as speaker_id, - to_char(e.date_begin, 'YYYY') as year, - to_char(e.date_begin, 'MM') as month, - to_char(e.date_begin, 'YYYY-MM-DD') as day, - count(t.id) as nbevent, - t.id as type, - (SELECT sum(c.nb_register) FROM event_registration c WHERE c.event_id=e.id and t.id=e.type and state in ('draft')) as draft_state, - (SELECT sum(c.nb_register) FROM event_registration c WHERE c.event_id=e.id and t.id=e.type and state in ('open')) as confirm_state, - e.register_max as register_max, - e.state as state - from + CREATE OR REPLACE view report_event_registration AS ( + SELECT + e.id AS id, + c.event_id AS event_id, + e.date_begin AS date, + e.user_id AS user_id, + e.main_speaker_id AS speaker_id, + to_char(e.date_begin, 'YYYY') AS year, + to_char(e.date_begin, 'MM') AS month, + to_char(e.date_begin, 'YYYY-MM-DD') AS day, + count(t.id) AS nbevent, + t.id AS type, + (SELECT SUM(c.nb_register) FROM event_registration c WHERE c.event_id=e.id AND t.id=e.type AND state IN ('draft')) AS draft_state, + (SELECT SUM(c.nb_register) FROM event_registration c WHERE c.event_id=e.id AND t.id=e.type AND state IN ('open')) AS confirm_state, + e.register_max AS register_max, + e.state AS state + FROM event_event e - inner join - event_registration c on (e.id=c.event_id) - inner join - event_type t on (e.type=t.id) - group by + INNER JOIN + event_registration c ON (e.id=c.event_id) + INNER JOIN + event_type t ON (e.type=t.id) + GROUP BY to_char(e.date_begin, 'YYYY'), to_char(e.date_begin, 'MM'), - t.id, e.id, e.date_begin,e.main_speaker_id, + t.id, e.id, e.date_begin, e.main_speaker_id, e.register_max, e.type, e.state, c.event_id, e.user_id, to_char(e.date_begin, 'YYYY-MM-DD') )""") diff --git a/addons/event/wizard/event_confirm_registration.py b/addons/event/wizard/event_confirm_registration.py index 92f94474cb8..7b6cd7ee3f3 100644 --- a/addons/event/wizard/event_confirm_registration.py +++ b/addons/event/wizard/event_confirm_registration.py @@ -40,6 +40,8 @@ class event_confirm_registration(osv.osv_memory): """ This function gets default values """ + if context is None: + context = {} registration_pool = self.pool.get('event.registration') registration_ids = context.get('registration_ids', []) res = super(event_confirm_registration, self).default_get(cr, uid, fields, context=context) @@ -56,7 +58,9 @@ class event_confirm_registration(osv.osv_memory): res.update({'msg': msg}) return res - def confirm(self, cr, uid, ids, context): + def confirm(self, cr, uid, ids, context=None): + if context is None: + context = {} registration_pool = self.pool.get('event.registration') registration_ids = context.get('registration_ids', []) registration_pool.do_open(cr, uid, registration_ids, context=context) diff --git a/addons/event/wizard/event_make_invoice.py b/addons/event/wizard/event_make_invoice.py index 12ad2cf0d68..f22db18a78a 100644 --- a/addons/event/wizard/event_make_invoice.py +++ b/addons/event/wizard/event_make_invoice.py @@ -18,6 +18,7 @@ # along with this program. If not, see . # ############################################################################## + from osv import fields, osv from tools.translate import _ @@ -29,7 +30,7 @@ class event_make_invoice(osv.osv_memory): _description = "Event Make Invoice" _columns = { 'grouped': fields.boolean('Group the invoices'), - 'invoice_date':fields.date('Invoice Date'), + 'invoice_date': fields.date('Invoice Date'), } def view_init(self, cr, uid, fields, context=None): @@ -61,7 +62,7 @@ class event_make_invoice(osv.osv_memory): _("Registration doesn't have any partner to invoice.")) def default_get(self, cr, uid, fields_list, context=None): - return super(event_make_invoice, self).default_get(cr, uid, fields_list, context) + return super(event_make_invoice, self).default_get(cr, uid, fields_list, context=context) def make_invoice(self, cr, uid, ids, context=None): reg_obj = self.pool.get('event.registration') @@ -70,7 +71,7 @@ class event_make_invoice(osv.osv_memory): if context is None: context = {} - for data in self.browse(cr, uid, ids): + for data in self.browse(cr, uid, ids, context=context): res = reg_obj.action_invoice_create(cr, uid, context.get(('active_ids'),[]), data.grouped, date_inv = data.invoice_date) form_id = mod_obj._get_id(cr, uid, 'account', 'invoice_form') diff --git a/addons/event/wizard/partner_event_registration.py b/addons/event/wizard/partner_event_registration.py index 00f106ab8ae..33ed6e60cdb 100644 --- a/addons/event/wizard/partner_event_registration.py +++ b/addons/event/wizard/partner_event_registration.py @@ -19,7 +19,6 @@ # ############################################################################## -import wizard import netsvc import tools from osv import fields, osv @@ -53,7 +52,6 @@ class partner_event_registration(osv.osv_memory): value = {} res_obj = self.pool.get('res.partner') job_obj = self.pool.get('res.partner.job') - event_obj = self.pool.get('event.event') reg_obj = self.pool.get('event.registration') mod_obj = self.pool.get('ir.model.data') @@ -62,9 +60,9 @@ class partner_event_registration(osv.osv_memory): contact_id = False email = False if addr.has_key('default'): - job_ids = job_obj.search(cr, uid, [('address_id', '=', addr['default'])]) + job_ids = job_obj.search(cr, uid, [('address_id', '=', addr['default'])], context=context) if job_ids: - contact = job_obj.browse(cr, uid, job_ids[0]) + contact = job_obj.browse(cr, uid, job_ids[0], context=context) if contact: contact_id = contact.contact_id.id email = contact.email @@ -72,14 +70,13 @@ class partner_event_registration(osv.osv_memory): result = mod_obj._get_id(cr, uid, 'event', 'view_registration_search') res = mod_obj.read(cr, uid, result, ['res_id']) - data_obj = self.pool.get('ir.model.data') # Select the view - id2 = data_obj._get_id(cr, uid, 'event', 'view_event_registration_form') - id3 = data_obj._get_id(cr, uid, 'event', 'view_event_registration_tree') + id2 = mod_obj._get_id(cr, uid, 'event', 'view_event_registration_form') + id3 = mod_obj._get_id(cr, uid, 'event', 'view_event_registration_tree') if id2: - id2 = data_obj.browse(cr, uid, id2, context=context).res_id + id2 = mod_obj.browse(cr, uid, id2, context=context).res_id if id3: - id3 = data_obj.browse(cr, uid, id3, context=context).res_id + id3 = mod_obj.browse(cr, uid, id3, context=context).res_id for current in self.browse(cr, uid, ids, context=context): for partner in res_obj.browse(cr, uid, record_ids, context=context): @@ -105,7 +102,7 @@ class partner_event_registration(osv.osv_memory): 'views': [(id2, 'form'), (id3, 'tree'), (False, 'calendar'), (False, 'graph')], 'type': 'ir.actions.act_window', 'search_view_id': res['res_id'] - } + } return value def name_get(self, cr, uid, ids, context=None): @@ -118,7 +115,7 @@ class partner_event_registration(osv.osv_memory): res = [] if not ids: return res - reads = self.read(cr, uid, ids, ['event_type', 'event_id'], context) + reads = self.read(cr, uid, ids, ['event_type', 'event_id'], context=context) for record in reads: event_id = record['event_id'][1] if record['event_type']: @@ -135,13 +132,13 @@ class partner_event_registration(osv.osv_memory): context = {} partner_id = context.get('active_id', False) if event_id: - event = event_obj.browse(cr, uid, event_id) + event = event_obj.browse(cr, uid, event_id, context=context) pricelist_id = event.pricelist_id and event.pricelist_id.id or False if partner_id: partner = partner_obj.browse(cr, uid, partner_id, context=context) pricelist_id = pricelist_id or partner.property_product_pricelist.id unit_price = product_obj._product_price(cr, uid, [event.product_id.id], False, False, {'pricelist': pricelist_id})[event.product_id.id] - + res['value'] = { 'event_type': event.type and event.type.id or False, 'start_date': event.date_begin, From 9bf62c39d7dc92de7b3c8288774721de8047dadb Mon Sep 17 00:00:00 2001 From: vra Date: Mon, 11 Oct 2010 11:40:58 +0530 Subject: [PATCH 04/26] [FIX][IMP]hr_payroll : Fixed and improved the employee detail and year report. bzr revid: vra@tinyerp.com-20101011061058-djvd4zijs2b9s2rn --- .../report/report_employees_detail.py | 17 +++-- .../report/report_employees_detail.rml | 75 +++++++++---------- .../hr_payroll/report/report_year_report.rml | 60 +++++++-------- .../hr_payroll/report/report_year_salary.py | 16 ++-- 4 files changed, 86 insertions(+), 82 deletions(-) diff --git a/addons/hr_payroll/report/report_employees_detail.py b/addons/hr_payroll/report/report_employees_detail.py index f3ecb56aa0b..fe4b0537896 100644 --- a/addons/hr_payroll/report/report_employees_detail.py +++ b/addons/hr_payroll/report/report_employees_detail.py @@ -48,10 +48,14 @@ class employees_salary_report(rml_parse.rml_parse): m = datetime.date(cy, cm, 1).strftime('%b') mnth_name.append(m) self.mnths.append(str(cm)+'-'+str(cy)) + if cm == 12: cm = 0 cy = ly cm = cm +1 + for c in range(0,(12-no_months)): + mnth_name.append('None') + self.mnths.append('None') return [mnth_name] def get_employee(self,form): @@ -134,11 +138,14 @@ class employees_salary_report(rml_parse.rml_parse): category_name = self.pool.get('hr.allounce.deduction.categoty').read(self.cr, self.uid, [category],['name','type'])[0] result.append(category_name['name']) for mnth in self.mnths: - if len(mnth) != 7: - mnth = '0' + str(mnth) - query = "select id from hr_payslip where employee_id = "+str(emp_id)+" and to_char(date,'mm-yyyy') like '%"+mnth+"%' and state = 'done' " - self.cr.execute(query) - payslip_id = self.cr.dictfetchone() + if mnth <> 'None': + if len(mnth) != 7: + mnth = '0' + str(mnth) + query = "select id from hr_payslip where employee_id = "+str(emp_id)+" and to_char(date,'mm-yyyy') like '%"+mnth+"%' and state = 'done' " + self.cr.execute(query) + payslip_id = self.cr.dictfetchone() + else: + payslip_id = False if payslip_id: payslip_obj = self.pool.get('hr.payslip').browse(self.cr, self.uid, payslip_id['id']) if not category: diff --git a/addons/hr_payroll/report/report_employees_detail.rml b/addons/hr_payroll/report/report_employees_detail.rml index e1bd6c3b3c8..b4e577e1f22 100644 --- a/addons/hr_payroll/report/report_employees_detail.rml +++ b/addons/hr_payroll/report/report_employees_detail.rml @@ -184,6 +184,20 @@ + + + + + + + + + + + + + + @@ -329,46 +343,46 @@
[[ repeatIn(get_periods(data['form']),'m') ]] [[ get_employee_detail(o) ]] - + Title - [[ m[0] ]] + [[ m[0] != 'None' and m[0] or '' ]] - [[ m[1] ]] + [[ m[1] != 'None' and m[1] or '' ]] - [[ m[2] ]] + [[ m[2] != 'None' and m[2] or '' ]] - [[ m[3] ]] + [[ m[3] != 'None' and m[3] or '' ]] - [[ m[4] ]] + [[ m[4] != 'None' and m[4] or '' ]] - [[ m[5] ]] + [[ m[5] != 'None' and m[5] or '' ]] - [[ m[6] ]] + [[ m[6] != 'None' and m[6] or '' ]] - [[ m[7] ]] + [[ m[7] != 'None' and m[7] or '' ]] - [[ m[8] ]] + [[ m[8] != 'None' and m[8] or '' ]] - [[ m[9] ]] + [[ m[9] != 'None' and m[9] or '' ]] - [[ m[10] ]] + [[ m[10] != 'None' and m[10] or '' ]] - [[ m[11] ]] + [[ m[11] != 'None' and m[11] or '' ]] Total @@ -379,9 +393,6 @@
- - - @@ -390,8 +401,8 @@
- [[ repeatIn(get_allow(),'e1') ]] - + [[ repeatIn(get_allow(),'e1') ]] + [[ e1[0] ]] @@ -437,9 +448,6 @@ - - -
@@ -449,8 +457,8 @@
- [[ repeatIn(get_deduct(),'e2') ]] - + [[ repeatIn(get_deduct(),'e2') ]] + [[ e2[0] ]] @@ -496,9 +504,6 @@ - - -
@@ -508,8 +513,8 @@
- [[ repeatIn(get_other(),'e3') ]] - + [[ repeatIn(get_other(),'e3') ]] + [[ e3[0] ]] @@ -555,18 +560,9 @@ - - -
- - -
- - - - + [[ get_monthly_total()[0] ]] @@ -616,9 +612,6 @@
- - - diff --git a/addons/hr_payroll/report/report_year_report.rml b/addons/hr_payroll/report/report_year_report.rml index 052af6f4701..527491552aa 100755 --- a/addons/hr_payroll/report/report_year_report.rml +++ b/addons/hr_payroll/report/report_year_report.rml @@ -63,11 +63,24 @@ + + + + + + + + + + + + + + - @@ -133,58 +146,55 @@
- [[ repeatIn(get_periods(data['form']),'m') ]] + [[ repeatIn(get_periods(data['form']),'m') ]] Name - [[ m[0] ]] + [[ m[0] != 'None' and m[0] or '' ]] - [[ m[1] ]] + [[ m[1] != 'None' and m[1] or '' ]] - [[ m[2] ]] + [[ m[2] != 'None' and m[2] or '' ]] - [[ m[3] ]] + [[ m[3] != 'None' and m[3] or '' ]] - [[ m[4] ]] + [[ m[4] != 'None' and m[4] or '' ]] - [[ m[5] ]] + [[ m[5] != 'None' and m[5] or '' ]] - [[ m[6] ]] + [[ m[6] != 'None' and m[6] or '' ]] - [[ m[7] ]] + [[ m[7] != 'None' and m[7] or '' ]] - [[ m[8] ]] + [[ m[8] != 'None' and m[8] or '' ]] - [[ m[9] ]] + [[ m[9] != 'None' and m[9] or '' ]] - [[ m[10] ]] + [[ m[10] != 'None' and m[10] or '' ]] - [[ m[11] ]] + [[ m[11] != 'None' and m[11] or '' ]] Total - - -
- [[ repeatIn(get_employee(data['form']),'e') ]] + [[ repeatIn(get_employee(data['form']),'e') ]] @@ -231,19 +241,10 @@ - - -
- - -
- - -
- [[ repeatIn(get_months_tol(),'t') ]] + [[ repeatIn(get_months_tol(),'t') ]] @@ -294,8 +295,5 @@
- - - diff --git a/addons/hr_payroll/report/report_year_salary.py b/addons/hr_payroll/report/report_year_salary.py index b23effbeccb..6c830b80941 100755 --- a/addons/hr_payroll/report/report_year_salary.py +++ b/addons/hr_payroll/report/report_year_salary.py @@ -43,6 +43,9 @@ class year_salary_report(rml_parse.rml_parse): cm = 0 cy = ly cm = cm +1 + for c in range(0,(12-no_months)): + mnth_name.append('None') + self.mnths.append('None') return [mnth_name] def get_employee(self,form): @@ -58,11 +61,14 @@ class year_salary_report(rml_parse.rml_parse): ls1.append(emp_id.name) tol = 0.0 for mnth in self.mnths: - if len(mnth) != 7: - mnth = '0' + str(mnth) - query = "select net from hr_payslip where employee_id = "+str(emp_id.id)+" and to_char(date,'mm-yyyy') like '%"+mnth+"%' and state = 'done' " - self.cr.execute(query) - sal = self.cr.fetchall() + if mnth <> 'None': + if len(mnth) != 7: + mnth = '0' + str(mnth) + query = "select net from hr_payslip where employee_id = "+str(emp_id.id)+" and to_char(date,'mm-yyyy') like '%"+mnth+"%' and state = 'done' " + self.cr.execute(query) + sal = self.cr.fetchall() + else: + sal = [(0.0,)] try: ls1.append(sal[0][0]) except: From 15380c03ffe091d71ba4f00da41d87d61829386f Mon Sep 17 00:00:00 2001 From: Mustufa Rangwala Date: Mon, 11 Oct 2010 12:50:26 +0530 Subject: [PATCH 05/26] [REF] bzr revid: mra@mra-laptop-20101011072026-4m0ehsw20j7stywj --- addons/account/account_bank_statement.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/addons/account/account_bank_statement.py b/addons/account/account_bank_statement.py index a7b6b66d2c1..0b240663943 100644 --- a/addons/account/account_bank_statement.py +++ b/addons/account/account_bank_statement.py @@ -21,9 +21,7 @@ import time -import netsvc from osv import fields, osv -from tools.misc import currency from tools.translate import _ import decimal_precision as dp From ae663dc16c6689f52271e880e7d7946cb61a9097 Mon Sep 17 00:00:00 2001 From: Mustufa Rangwala Date: Mon, 11 Oct 2010 13:04:19 +0530 Subject: [PATCH 06/26] [IMP] account_voucher: Cleaning bzr revid: mra@mra-laptop-20101011073419-hp26wqaylubtqay2 --- addons/account_voucher/account_voucher.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/addons/account_voucher/account_voucher.py b/addons/account_voucher/account_voucher.py index 912a7864862..a69b0a0ce11 100644 --- a/addons/account_voucher/account_voucher.py +++ b/addons/account_voucher/account_voucher.py @@ -29,8 +29,9 @@ from tools.translate import _ class account_move_line(osv.osv): _inherit = 'account.move.line' + def _unreconciled(self, cr, uid, ids, prop, unknow_none, context): - res={} + res = {} for line in self.browse(cr, uid, ids, context=context): res[line.id] = line.debit - line.credit if line.reconcile_partial_id: @@ -43,9 +44,11 @@ class account_move_line(osv.osv): _columns = { 'amount_unreconciled': fields.function(_unreconciled, method=True, string='Unreconciled Amount'), } + account_move_line() class account_voucher(osv.osv): + def _get_type(self, cr, uid, ids, context={}): return context.get('type', False) @@ -92,7 +95,7 @@ class account_voucher(osv.osv): journal_id = context.get('journal_id', False) if journal_id: journal = journal_pool.browse(cr, uid, journal_id) - currency_id = journal.company_id.currency_id.id +# currency_id = journal.company_id.currency_id.id if journal.currency: return journal.currency.id return False @@ -114,7 +117,7 @@ class account_voucher(osv.osv): def fields_view_get(self, cr, uid, view_id=None, view_type=False, context=None, toolbar=False, submenu=False): if not view_id and context.get('invoice_type',False): mod_obj = self.pool.get('ir.model.data') - if context.get('invoice_type') in ('out_invoice','out_refund'): + if context.get('invoice_type') in ('out_invoice', 'out_refund'): result = mod_obj._get_id(cr, uid, 'account_voucher', 'view_vendor_receipt_form') else: result = mod_obj._get_id(cr, uid, 'account_voucher', 'view_vendor_payment_form') From ca6308e217a7c5a7dd08552d481f60a673095644 Mon Sep 17 00:00:00 2001 From: mtr Date: Mon, 11 Oct 2010 13:46:40 +0530 Subject: [PATCH 07/26] [IMP] membership:-security improvements for the 'partner_manager' user bzr revid: mtr@mtr-20101011081640-qxh628totfv3fwt0 --- addons/membership/membership_view.xml | 3 ++- addons/membership/report/report_membership_view.xml | 3 ++- addons/membership/security/ir.model.access.csv | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/addons/membership/membership_view.xml b/addons/membership/membership_view.xml index ad9c3bcf772..afa1ee9bebe 100644 --- a/addons/membership/membership_view.xml +++ b/addons/membership/membership_view.xml @@ -140,7 +140,8 @@ parent="menu_membership" id="menu_membership_products" action="action_membership_products" - sequence="1"/> + sequence="1" + groups="base.group_partner_manager"/> diff --git a/addons/membership/report/report_membership_view.xml b/addons/membership/report/report_membership_view.xml index abe8b44bcba..291efee4834 100644 --- a/addons/membership/report/report_membership_view.xml +++ b/addons/membership/report/report_membership_view.xml @@ -116,7 +116,8 @@ + id="menu_report_membership" + groups="base.group_partner_manager"/> diff --git a/addons/membership/security/ir.model.access.csv b/addons/membership/security/ir.model.access.csv index 6cf3eb755c2..f3d91646c44 100644 --- a/addons/membership/security/ir.model.access.csv +++ b/addons/membership/security/ir.model.access.csv @@ -1,4 +1,4 @@ "id","name","model_id:id","group_id:id","perm_read","perm_write","perm_create","perm_unlink" -"access_membership_membership_line_partner_manager","membership.membership_line partner_manager","model_membership_membership_line","base.group_partner_manager",1,0,0,0 +"access_membership_membership_line_partner_manager","membership.membership_line partner_manager","model_membership_membership_line","base.group_partner_manager",1,1,1,1 "access_membership_membership_line","membership.membership_line","model_membership_membership_line",,1,0,0,0 "access_report_membership","report.membership","model_report_membership","base.group_partner_manager",1,0,0,0 From a0ac32cec0cb5f548226fa734efe76520c23349d Mon Sep 17 00:00:00 2001 From: Mustufa Rangwala Date: Mon, 11 Oct 2010 14:16:22 +0530 Subject: [PATCH 08/26] [REF] account: menu string name updated for cash register to cash registers bzr revid: mra@mra-laptop-20101011084622-l0intwt9fslh4b2r --- addons/account/account_view.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/account/account_view.xml b/addons/account/account_view.xml index e7e1c055c32..dd1011b1c33 100644 --- a/addons/account/account_view.xml +++ b/addons/account/account_view.xml @@ -2578,7 +2578,7 @@ - Cash Register + Cash Registers ir.actions.act_window account.bank.statement form From cc49a86ab373b61b427704bb88ba348b8ac71b0c Mon Sep 17 00:00:00 2001 From: vra Date: Mon, 11 Oct 2010 14:28:23 +0530 Subject: [PATCH 09/26] [IMP] account_budget: improved the budget reports rml and sxw. bzr revid: vra@tinyerp.com-20101011085823-0zgt1j9ip72zd8vv --- .../report/analytic_account_budget_report.rml | 10 +++++----- addons/account_budget/report/budget_report.rml | 17 +++++------------ .../report/crossovered_budget_report.rml | 8 ++++---- 3 files changed, 14 insertions(+), 21 deletions(-) diff --git a/addons/account_budget/report/analytic_account_budget_report.rml b/addons/account_budget/report/analytic_account_budget_report.rml index ea800685470..10b54482ae7 100644 --- a/addons/account_budget/report/analytic_account_budget_report.rml +++ b/addons/account_budget/report/analytic_account_budget_report.rml @@ -128,16 +128,16 @@ Description - Theoretical Amount + Theoretical Amt - Planned Amount + Planned Amt - Practical Amount + Practical Amt - Perc(%) + Perc(%) @@ -166,7 +166,7 @@ - [[ repeatIn(funct_total(data['form']),'b') ]] Total([[ company.currency_id.code ]]) : + [[ repeatIn(funct_total(data['form']),'b') ]] Total: [[ formatLang(b['tot_theo']) ]] [[ company.currency_id.symbol ]] diff --git a/addons/account_budget/report/budget_report.rml b/addons/account_budget/report/budget_report.rml index cd12f60108d..577e03af9f4 100644 --- a/addons/account_budget/report/budget_report.rml +++ b/addons/account_budget/report/budget_report.rml @@ -161,13 +161,6 @@ - - - - Printing date: [[ time.strftime('%Y-%m-%d') ]] at [[ time.strftime('%H:%M:%S') ]] - - - @@ -180,19 +173,19 @@ A/c No. - Budget + Budget - Period Budget + Period Budget - Performance + Performance - Spread + Spread - % performance + % performance diff --git a/addons/account_budget/report/crossovered_budget_report.rml b/addons/account_budget/report/crossovered_budget_report.rml index e297c8b3ca2..0533042822a 100644 --- a/addons/account_budget/report/crossovered_budget_report.rml +++ b/addons/account_budget/report/crossovered_budget_report.rml @@ -127,16 +127,16 @@ Description - Theoretical Amount + Theoretical Amt - Planned Amount + Planned Amt - Practical Amount + Practical Amt - Perc(%) + Perc(%) From 23536f523426e69aa9dff5975c05bfdc44058196 Mon Sep 17 00:00:00 2001 From: vth Date: Mon, 11 Oct 2010 14:37:18 +0530 Subject: [PATCH 10/26] [FIX] account: bzr revid: vth@tinyerp.com-20101011090718-xbv7khokdw6u2jrl --- addons/account/project/project_view.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/addons/account/project/project_view.xml b/addons/account/project/project_view.xml index fd52619fb10..8006a972915 100644 --- a/addons/account/project/project_view.xml +++ b/addons/account/project/project_view.xml @@ -182,6 +182,7 @@ + From fc0bf8f9b5cbf9ddd0ee42b6cb9295221bc4c57e Mon Sep 17 00:00:00 2001 From: Mustufa Rangwala Date: Mon, 11 Oct 2010 14:37:37 +0530 Subject: [PATCH 11/26] [REF] bzr revid: mra@mra-laptop-20101011090737-vlzoqec2p2jf1sgq --- addons/account/account_cash_statement.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/addons/account/account_cash_statement.py b/addons/account/account_cash_statement.py index 445072605ed..6431454b715 100644 --- a/addons/account/account_cash_statement.py +++ b/addons/account/account_cash_statement.py @@ -151,15 +151,14 @@ class account_cash_statement(osv.osv): res[r] = round(res[r], 2) return res - def _get_company(self, cr, uid, context={}): + def _get_company(self, cr, uid, context=None): user_pool = self.pool.get('res.users') company_pool = self.pool.get('res.company') - user = user_pool.browse(cr, uid, uid, context) - company_id = user.company_id and user.company_id.id + user = user_pool.browse(cr, uid, uid, context=context) + company_id = user.company_id if not company_id: - company_id = company_pool.search(cr, uid, [])[0] - - return company_id + company_id = company_pool.search(cr, uid, []) + return company_id and company_id[0] or False def _get_cash_open_box_lines(self, cr, uid, context={}): res = [] From 1aa17c185e850454fb642512bc63c14bb3ca7bf9 Mon Sep 17 00:00:00 2001 From: Mustufa Rangwala Date: Mon, 11 Oct 2010 14:38:32 +0530 Subject: [PATCH 12/26] [FIX] Analytic journal items => Search view bzr revid: mra@mra-laptop-20101011090832-dr4a1nb6i594wyz7 --- addons/account/project/project_view.xml | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/addons/account/project/project_view.xml b/addons/account/project/project_view.xml index 8006a972915..d5249310276 100644 --- a/addons/account/project/project_view.xml +++ b/addons/account/project/project_view.xml @@ -180,6 +180,7 @@ + @@ -431,13 +432,13 @@ - From 0bfdeafc6331f4531a8e92caf16ac1fcaa900d9d Mon Sep 17 00:00:00 2001 From: vth Date: Mon, 11 Oct 2010 15:02:40 +0530 Subject: [PATCH 13/26] [REF] account/project/analytical account: change the spelling in demo file administratif to administrative bzr revid: vth@tinyerp.com-20101011093240-kv4hwwvda3po4z8l --- addons/account/project/analytic_account_demo.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/account/project/analytic_account_demo.xml b/addons/account/project/analytic_account_demo.xml index 3727f7741bf..8f33f70f856 100644 --- a/addons/account/project/analytic_account_demo.xml +++ b/addons/account/project/analytic_account_demo.xml @@ -198,7 +198,7 @@ - Administratif + Administrative 1 From 5785d49b746262fe1b4e9b7e35e13c26de605185 Mon Sep 17 00:00:00 2001 From: Mustufa Rangwala Date: Mon, 11 Oct 2010 15:25:42 +0530 Subject: [PATCH 14/26] [REF] bzr revid: mra@mra-laptop-20101011095542-exml7h0edupu3q8w --- addons/account/project/project_view.xml | 1 - 1 file changed, 1 deletion(-) diff --git a/addons/account/project/project_view.xml b/addons/account/project/project_view.xml index d5249310276..809f69673fe 100644 --- a/addons/account/project/project_view.xml +++ b/addons/account/project/project_view.xml @@ -180,7 +180,6 @@ - From 1efa951effb07b835f2a6a0727535caa0cea935b Mon Sep 17 00:00:00 2001 From: "ARA (OpenERP)" Date: Mon, 11 Oct 2010 15:46:12 +0530 Subject: [PATCH 15/26] [REF] cleaning code of account_payment bzr revid: ara@tinyerp.com-20101011101612-g5kumq1dr7i73bn3 --- addons/account_payment/__init__.py | 2 +- addons/account_payment/__openerp__.py | 6 ++--- addons/account_payment/account_move_line.py | 22 +++++++++---------- addons/account_payment/account_payment.py | 2 +- addons/account_payment/report/__init__.py | 6 ++--- .../account_payment/report/payment_order.py | 12 +++++----- .../wizard/account_payment_order.py | 2 +- .../wizard/account_payment_pay.py | 2 +- .../account_payment_populate_statement.py | 6 ++--- 9 files changed, 30 insertions(+), 30 deletions(-) diff --git a/addons/account_payment/__init__.py b/addons/account_payment/__init__.py index 82a05aa73e9..6188de6a9da 100644 --- a/addons/account_payment/__init__.py +++ b/addons/account_payment/__init__.py @@ -29,4 +29,4 @@ import account_move_line import account_invoice import report -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file diff --git a/addons/account_payment/__openerp__.py b/addons/account_payment/__openerp__.py index be0ca2a127b..7ccafd90eb4 100644 --- a/addons/account_payment/__openerp__.py +++ b/addons/account_payment/__openerp__.py @@ -28,9 +28,9 @@ "depends": ["account"], "init_xml": [], "description": """ - This module provides : - * a more efficient way to manage invoice payment. - * a basic mechanism to easily plug various automated payment. +This module provides : +* a more efficient way to manage invoice payment. +* a basic mechanism to easily plug various automated payment. """, 'author': 'OpenERP SA', 'depends': ['account_voucher'], diff --git a/addons/account_payment/account_move_line.py b/addons/account_payment/account_move_line.py index 3f9b6c4b094..2b9ea22d824 100644 --- a/addons/account_payment/account_move_line.py +++ b/addons/account_payment/account_move_line.py @@ -47,7 +47,7 @@ class account_move_line(osv.osv): return r def _to_pay_search(self, cr, uid, obj, name, args, context): - if not len(args): + if not args: return [] line_obj = self.pool.get('account.move.line') query = line_obj._query_get(cr, uid, context={}) @@ -63,17 +63,17 @@ class account_move_line(osv.osv): ) %(operator)s %%s ''' % {'operator': x[1]}, args)) sql_args = tuple(map(itemgetter(2), args)) - cr.execute(('''select id - from account_move_line l - where account_id in (select id - from account_account - where type=%s and active) - and reconcile_id is null - and credit > 0 - and ''' + where + ' and ' + query), ('payable',)+sql_args ) + cr.execute(('''SELECT id + FROM account_move_line l + WHERE account_id IN (select id + FROM account_account + WHERE type=%s AND active) + AND reconcile_id IS null + AND credit > 0 + AND ''' + where + ' and ' + query), ('payable',)+sql_args ) res = cr.fetchall() - if not len(res): + if not res: return [('id','=','0')] return [('id','in',map(lambda x:x[0], res))] @@ -110,7 +110,7 @@ class account_move_line(osv.osv): return line2bank _columns = { - 'amount_to_pay' : fields.function(amount_to_pay, method=True, + 'amount_to_pay': fields.function(amount_to_pay, method=True, type='float', string='Amount to pay', fnct_search=_to_pay_search), } diff --git a/addons/account_payment/account_payment.py b/addons/account_payment/account_payment.py index 1c0596ddf96..e4a121fb03e 100644 --- a/addons/account_payment/account_payment.py +++ b/addons/account_payment/account_payment.py @@ -330,7 +330,7 @@ class payment_line(osv.osv): 'info_owner': fields.function(info_owner, string="Owner Account", method=True, type="text", help='Address of the Main Partner'), 'info_partner': fields.function(info_partner, string="Destination Account", method=True, type="text", help='Address of the Ordering Customer.'), 'date': fields.date('Payment Date', help="If no payment date is specified, the bank will treat this payment line directly"), - 'create_date': fields.datetime('Created' , readonly=True), + 'create_date': fields.datetime('Created', readonly=True), 'state': fields.selection([('normal','Free'), ('structured','Structured')], 'Communication Type', required=True), 'bank_statement_line_id': fields.many2one('account.bank.statement.line', 'Bank statement line') } diff --git a/addons/account_payment/report/__init__.py b/addons/account_payment/report/__init__.py index 5a5c1dab1f2..e9d7f4013ac 100644 --- a/addons/account_payment/report/__init__.py +++ b/addons/account_payment/report/__init__.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- ############################################################################## -# +# # OpenERP, Open Source Management Solution # Copyright (C) 2004-2010 Tiny SPRL (). # @@ -15,9 +15,9 @@ # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . +# along with this program. If not, see . # ############################################################################## import payment_order -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file diff --git a/addons/account_payment/report/payment_order.py b/addons/account_payment/report/payment_order.py index a00c7a7871b..e0b0713c614 100644 --- a/addons/account_payment/report/payment_order.py +++ b/addons/account_payment/report/payment_order.py @@ -31,11 +31,11 @@ class payment_order(report_sxw.rml_parse): self.localcontext.update( { 'time': time, 'get_invoice_name': self._get_invoice_name, - 'get_company_currency' : self._get_company_currency, - 'get_company_currency_symbol': self._get_company_currency_symbol, - 'get_amount_total_in_currency' : self._get_amount_total_in_currency, - 'get_amount_total' : self._get_amount_total, - 'get_account_name' : self._get_account_name, + 'get_company_currency': self._get_company_currency, + 'get_company_currency_symbol': self._get_company_currency_symbol, + 'get_amount_total_in_currency': self._get_amount_total_in_currency, + 'get_amount_total': self._get_amount_total, + 'get_account_name': self._get_account_name, }) def _get_invoice_name(self, invoice_id): @@ -87,4 +87,4 @@ class payment_order(report_sxw.rml_parse): report_sxw.report_sxw('report.payment.order', 'payment.order', 'addons/account_payment/report/payment_order.rml', parser=payment_order, header="external") -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file diff --git a/addons/account_payment/wizard/account_payment_order.py b/addons/account_payment/wizard/account_payment_order.py index 97a66e937ca..4a070f05a27 100644 --- a/addons/account_payment/wizard/account_payment_order.py +++ b/addons/account_payment/wizard/account_payment_order.py @@ -28,7 +28,7 @@ class payment_order_create(osv.osv_memory): Create a payment object with lines corresponding to the account move line to pay according to the date and the mode provided by the user. Hypothesis: - - Small number of non-reconcilied move line , payment mode and bank account type, + - Small number of non-reconcilied move line, payment mode and bank account type, - Big number of partner and bank account. If a type is given, unsuitable account Entry lines are ignored. diff --git a/addons/account_payment/wizard/account_payment_pay.py b/addons/account_payment/wizard/account_payment_pay.py index 49858151670..132ab33af2c 100644 --- a/addons/account_payment/wizard/account_payment_pay.py +++ b/addons/account_payment/wizard/account_payment_pay.py @@ -36,7 +36,7 @@ class account_payment_make_payment(osv.osv_memory): obj_payment_order.set_done(cr, uid, context['active_id'], context) return {} # t = order.mode and order.mode.type.code or 'manual' -# if t == 'manual' : +# if t == 'manual': # obj_payment_order.set_done(cr,uid,context['active_id'],context) # return {} # diff --git a/addons/account_payment/wizard/account_payment_populate_statement.py b/addons/account_payment/wizard/account_payment_populate_statement.py index 53c9f14b6e8..7697d4eea6d 100644 --- a/addons/account_payment/wizard/account_payment_populate_statement.py +++ b/addons/account_payment/wizard/account_payment_populate_statement.py @@ -77,13 +77,13 @@ class account_payment_populate_statement(osv.osv_memory): if line.partner_id: # line['partner_id'] = mv.partner_id.id - if amount < 0 : + if amount < 0: account = line.partner_id.property_account_payable.id - else : + else: account = line.partner_id.property_account_receivable.id if line.move_line_id: - voucher_res = { 'type': 'payment' , + voucher_res = { 'type': 'payment', 'name': line.name, 'partner_id': line.partner_id.id, 'journal_id': statement.journal_id.id, From fa8bd9305df3ee312c0a6af2ad7a8347cfa27e86 Mon Sep 17 00:00:00 2001 From: vth Date: Mon, 11 Oct 2010 15:53:00 +0530 Subject: [PATCH 16/26] [REF] account bzr revid: vth@tinyerp.com-20101011102300-59rukbdh3ps9m2dm --- .../account_analytic_analysis.py | 14 +++---- .../account_analytic_plans.py | 6 +-- .../report/crossovered_analytic.py | 8 ++-- addons/analytic/analytic.py | 38 +++++++++---------- .../analytic_journal_billing_rate.py | 8 ++-- .../analytic_user_function.py | 2 +- 6 files changed, 38 insertions(+), 38 deletions(-) diff --git a/addons/account_analytic_analysis/account_analytic_analysis.py b/addons/account_analytic_analysis/account_analytic_analysis.py index d9e9bf3907b..108b6acfc97 100644 --- a/addons/account_analytic_analysis/account_analytic_analysis.py +++ b/addons/account_analytic_analysis/account_analytic_analysis.py @@ -146,7 +146,7 @@ class account_analytic_account(osv.osv): from account_analytic_line \ where account_id IN %s \ and invoice_id is null \ - GROUP BY account_analytic_line.account_id" ,(parent_ids,)) + GROUP BY account_analytic_line.account_id", (parent_ids,)) for account_id, lwd in cr.fetchall(): if account_id not in res: res[account_id] = {} @@ -258,7 +258,7 @@ class account_analytic_account(osv.osv): on account_analytic_line.journal_id = account_analytic_journal.id \ where account_analytic_line.account_id IN %s \ and account_analytic_journal.type = 'sale' \ - group by account_analytic_line.account_id" ,(parent_ids,)) + group by account_analytic_line.account_id", (parent_ids,)) for account_id, sum in cr.fetchall(): res[account_id] = round(sum,2) @@ -436,7 +436,7 @@ class account_analytic_account_summary_user(osv.osv): 'account_id': fields.many2one('account.analytic.account', 'Analytic Account', readonly=True), 'unit_amount': fields.function(_unit_amount, method=True, type='float', string='Total Time'), - 'user' : fields.many2one('res.users', 'User'), + 'user': fields.many2one('res.users', 'User'), } def init(self, cr): @@ -484,7 +484,7 @@ class account_analytic_account_summary_user(osv.osv): if fields==None: fields = self._columns.keys() - # construct a clause for the rules : + # construct a clause for the rules: d1, d2, tables = self.pool.get('ir.rule').domain_get(cr, user, self._name, 'read', context=context) # all inherited fields + all non inherited fields for which the attribute whose name is in load is True @@ -493,7 +493,7 @@ class account_analytic_account_summary_user(osv.osv): res = [] cr.execute('SELECT MAX(id) FROM res_users') max_user = cr.fetchone()[0] - if len(fields_pre) : + if fields_pre: fields_pre2 = map(lambda x: (x in ('create_date', 'write_date')) and ('date_trunc(\'second\', '+x+') as '+x) or '"'+x+'"', fields_pre) for i in range(0, len(ids), cr.IN_MAX): sub_ids = ids[i:i+cr.IN_MAX] @@ -661,14 +661,14 @@ class account_analytic_account_summary_month(osv.osv): if fields==None: fields = self._columns.keys() - # construct a clause for the rules : + # construct a clause for the rules: d1, d2, tables = self.pool.get('ir.rule').domain_get(cr, user, self._name) # all inherited fields + all non inherited fields for which the attribute whose name is in load is True fields_pre = filter(lambda x: x in self._columns and getattr(self._columns[x],'_classic_write'), fields) + self._inherits.values() res = [] - if len(fields_pre) : + if fields_pre: fields_pre2 = map(lambda x: (x in ('create_date', 'write_date')) and ('date_trunc(\'second\', '+x+') as '+x) or '"'+x+'"', fields_pre) for i in range(0, len(ids), cr.IN_MAX): sub_ids = ids[i:i+cr.IN_MAX] diff --git a/addons/account_analytic_plans/account_analytic_plans.py b/addons/account_analytic_plans/account_analytic_plans.py index e85275a9bba..73b0fcb301d 100644 --- a/addons/account_analytic_plans/account_analytic_plans.py +++ b/addons/account_analytic_plans/account_analytic_plans.py @@ -200,10 +200,10 @@ class account_analytic_plan_instance(osv.osv): for l in temp_list: if vals.has_key(l): for tempo in vals[l]: - if acct_anal_acct.search(cr, uid, [('parent_id','child_of',[item.root_analytic_id.id]),('id','=',tempo[2]['analytic_account_id'])]): + if acct_anal_acct.search(cr, uid,[('parent_id','child_of',[item.root_analytic_id.id]),('id','=',tempo[2]['analytic_account_id'])]): total_per_plan += tempo[2]['rate'] if total_per_plan < item.min_required or total_per_plan > item.max_required: - raise osv.except_osv(_('Value Error') ,_('The Total Should be Between %s and %s') % (str(item.min_required), str(item.max_required))) + raise osv.except_osv(_('Value Error'),_('The Total Should be Between %s and %s') % (str(item.min_required), str(item.max_required))) return super(account_analytic_plan_instance, self).create(cr, uid, vals, context) @@ -240,7 +240,7 @@ class account_analytic_plan_instance_line(osv.osv): 'rate': 100.0 } def name_get(self, cr, uid, ids, context=None): - if not len(ids): + if not ids: return [] reads = self.read(cr, uid, ids, ['analytic_account_id'], context) res = [] diff --git a/addons/account_analytic_plans/report/crossovered_analytic.py b/addons/account_analytic_plans/report/crossovered_analytic.py index f8a975a4c25..f4d35f936e1 100644 --- a/addons/account_analytic_plans/report/crossovered_analytic.py +++ b/addons/account_analytic_plans/report/crossovered_analytic.py @@ -29,8 +29,8 @@ class crossovered_analytic(report_sxw.rml_parse): self.localcontext.update( { 'time': time, 'lines': self._lines, - 'ref_lines' : self._ref_lines, - 'find_children':self.find_children, + 'ref_lines': self._ref_lines, + 'find_children': self.find_children, }) self.base_amount = 0.00 @@ -99,7 +99,7 @@ class crossovered_analytic(report_sxw.rml_parse): if selected_ids: query="SELECT sum(aal.amount) AS amt, sum(aal.unit_amount) AS qty FROM account_analytic_line AS aal, account_analytic_account AS aaa \ WHERE aal.account_id=aaa.id AND aal.id IN ("+','.join(map(str,selected_ids))+") AND (aal.journal_id " + journal +") AND aal.date>='"+ str(form['date1']) +"'"" AND aal.date<='" + str(form['date2']) + "'" - + self.cr.execute(query) info=self.cr.dictfetchall() @@ -133,7 +133,7 @@ class crossovered_analytic(report_sxw.rml_parse): for acc_id in self.final_list: selected_ids = line_pool.search(self.cr,self.uid,[('account_id','=',acc_id),('move_id','in',self.dict_acc_ref[form['ref']])]) if selected_ids: - query="SELECT aaa.code as code , sum(aal.amount) AS amt, sum(aal.unit_amount) AS qty,aaa.name as acc_name,aal.account_id as id FROM account_analytic_line AS aal, account_analytic_account AS aaa \ + query="SELECT aaa.code as code, sum(aal.amount) AS amt, sum(aal.unit_amount) AS qty,aaa.name as acc_name,aal.account_id as id FROM account_analytic_line AS aal, account_analytic_account AS aaa \ WHERE aal.account_id=aaa.id AND aal.id IN ("+','.join(map(str,selected_ids))+") AND (aal.journal_id " + journal +") AND aal.date>='"+ str(form['date1']) +"'"" AND aal.date<='" + str(form['date2']) + "'"" GROUP BY aal.account_id,aaa.name,aaa.code ORDER BY aal.account_id" self.cr.execute(query) diff --git a/addons/analytic/analytic.py b/addons/analytic/analytic.py index 66c74a72bc9..5f68cf98c1a 100644 --- a/addons/analytic/analytic.py +++ b/addons/analytic/analytic.py @@ -156,7 +156,7 @@ class account_analytic_account(osv.osv): return dict([(i, res[i]) for i in ids]) def name_get(self, cr, uid, ids, context=None): - if not len(ids): + if not ids: return [] res = [] for account in self.browse(cr, uid, ids, context=context): @@ -174,7 +174,7 @@ class account_analytic_account(osv.osv): return dict(res) _columns = { - 'name' : fields.char('Account Name', size=128, required=True), + 'name': fields.char('Account Name', size=128, required=True), 'complete_name': fields.function(_complete_name_calc, method=True, type='char', string='Full Account Name'), 'code': fields.char('Account Code', size=24), 'type': fields.selection([('view','View'), ('normal','Normal')], 'Account Type', help='If you select the View Type, it means you won\'t allow to create journal entries using that account.'), @@ -182,14 +182,14 @@ class account_analytic_account(osv.osv): 'parent_id': fields.many2one('account.analytic.account', 'Parent Analytic Account', select=2), 'child_ids': fields.one2many('account.analytic.account', 'parent_id', 'Child Accounts'), 'line_ids': fields.one2many('account.analytic.line', 'account_id', 'Analytic Entries'), - 'balance' : fields.function(_balance_calc, method=True, type='float', string='Balance'), - 'debit' : fields.function(_debit_calc, method=True, type='float', string='Debit'), - 'credit' : fields.function(_credit_calc, method=True, type='float', string='Credit'), + 'balance': fields.function(_balance_calc, method=True, type='float', string='Balance'), + 'debit': fields.function(_debit_calc, method=True, type='float', string='Debit'), + 'credit': fields.function(_credit_calc, method=True, type='float', string='Credit'), 'quantity': fields.function(_quantity_calc, method=True, type='float', string='Quantity'), 'quantity_max': fields.float('Maximum Quantity', help='Sets the higher limit of quantity of hours.'), - 'partner_id' : fields.many2one('res.partner', 'Associated Partner'), - 'contact_id' : fields.many2one('res.partner.address', 'Contact'), - 'user_id' : fields.many2one('res.users', 'Account Manager'), + 'partner_id': fields.many2one('res.partner', 'Associated Partner'), + 'contact_id': fields.many2one('res.partner.address', 'Contact'), + 'user_id': fields.many2one('res.users', 'Account Manager'), 'date_start': fields.date('Date Start'), 'date': fields.date('Date End'), 'company_id': fields.many2one('res.company', 'Company', required=True), @@ -210,10 +210,10 @@ class account_analytic_account(osv.osv): return self.pool.get('res.company').search(cr, uid, [('parent_id', '=', False)])[0] _defaults = { - 'type' : 'normal', + 'type': 'normal', 'company_id': _default_company, - 'state' : 'open', - 'user_id' : lambda self, cr, uid, ctx : uid, + 'state': 'open', + 'user_id': lambda self, cr, uid, ctx: uid, 'partner_id': lambda self, cr, uid, ctx: ctx.get('partner_id', False), 'contact_id': lambda self, cr, uid, ctx: ctx.get('contact_id', False), 'date_start': time.strftime('%Y-%m-%d') @@ -244,7 +244,7 @@ class account_analytic_account(osv.osv): partner = parent['partner_id'][0] else: partner = False - res = {'value' : {}} + res = {'value': {}} if partner: res['value']['partner_id'] = partner return res @@ -271,19 +271,19 @@ class account_analytic_line(osv.osv): _description = 'Analytic Line' _columns = { - 'name' : fields.char('Description', size=256, required=True), - 'date' : fields.date('Date', required=True, select=1), - 'amount' : fields.float('Amount', required=True, help='Calculated by multiplying the quantity and the price given in the Product\'s cost price. Always expressed in the company main currency.', digits_compute=dp.get_precision('Account')), - 'unit_amount' : fields.float('Quantity', help='Specifies the amount of quantity to count.'), - 'account_id' : fields.many2one('account.analytic.account', 'Analytic Account', required=True, ondelete='cascade', select=True), - 'user_id' : fields.many2one('res.users', 'User'), + 'name': fields.char('Description', size=256, required=True), + 'date': fields.date('Date', required=True, select=1), + 'amount': fields.float('Amount', required=True, help='Calculated by multiplying the quantity and the price given in the Product\'s cost price. Always expressed in the company main currency.', digits_compute=dp.get_precision('Account')), + 'unit_amount': fields.float('Quantity', help='Specifies the amount of quantity to count.'), + 'account_id': fields.many2one('account.analytic.account', 'Analytic Account', required=True, ondelete='cascade', select=True), + 'user_id': fields.many2one('res.users', 'User'), 'company_id': fields.related('account_id', 'company_id', type='many2one', relation='res.company', string='Company', store=True, readonly=True), } _defaults = { 'date': time.strftime('%Y-%m-%d'), 'company_id': lambda self,cr,uid,c: self.pool.get('res.company')._company_default_get(cr, uid, 'account.analytic.line', context=c), - 'amount' : 0.00 + 'amount': 0.00 } _order = 'date desc' diff --git a/addons/analytic_journal_billing_rate/analytic_journal_billing_rate.py b/addons/analytic_journal_billing_rate/analytic_journal_billing_rate.py index 609d1cad7d9..5718a9fdaa7 100644 --- a/addons/analytic_journal_billing_rate/analytic_journal_billing_rate.py +++ b/addons/analytic_journal_billing_rate/analytic_journal_billing_rate.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- ############################################################################## -# +# # OpenERP, Open Source Management Solution # Copyright (C) 2004-2010 Tiny SPRL (). # @@ -15,7 +15,7 @@ # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . +# along with this program. If not, see . # ############################################################################## @@ -38,7 +38,7 @@ class account_analytic_account(osv.osv): _inherit = "account.analytic.account" _columns = { - 'journal_rate_ids' : fields.one2many('analytic_journal_rate_grid', 'account_id', 'Invoicing Rate per Journal'), + 'journal_rate_ids': fields.one2many('analytic_journal_rate_grid', 'account_id', 'Invoicing Rate per Journal'), } account_analytic_account() @@ -92,7 +92,7 @@ class hr_analytic_timesheet(osv.osv): if to_invoice: res.setdefault('value',{}) res['value']['to_invoice'] = to_invoice[0] - + return res hr_analytic_timesheet() diff --git a/addons/analytic_user_function/analytic_user_function.py b/addons/analytic_user_function/analytic_user_function.py index 21fe0a7da29..04f66fb8daa 100644 --- a/addons/analytic_user_function/analytic_user_function.py +++ b/addons/analytic_user_function/analytic_user_function.py @@ -40,7 +40,7 @@ class account_analytic_account(osv.osv): _inherit = "account.analytic.account" _columns = { - 'user_product_ids' : fields.one2many('analytic_user_funct_grid', 'account_id', 'Users/Products Rel.'), + 'user_product_ids': fields.one2many('analytic_user_funct_grid', 'account_id', 'Users/Products Rel.'), } account_analytic_account() From 15da4879d949b075b7620d1baeaf2621586df7fc Mon Sep 17 00:00:00 2001 From: Mustufa Rangwala Date: Mon, 11 Oct 2010 16:21:16 +0530 Subject: [PATCH 17/26] [REF] Account followup bzr revid: mra@mra-laptop-20101011105116-oe24vzkv2etdehcl --- addons/account_followup/account_followup.py | 8 ++++---- .../wizard/account_followup_print.py | 12 ++++++------ 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/addons/account_followup/account_followup.py b/addons/account_followup/account_followup.py index 02986acb184..1d0ca8a500c 100644 --- a/addons/account_followup/account_followup.py +++ b/addons/account_followup/account_followup.py @@ -32,7 +32,7 @@ class followup(osv.osv): } _defaults = { 'company_id': lambda s, cr, uid, c: s.pool.get('res.company')._company_default_get(cr, uid, 'account_followup.followup', context=c), - } + } followup() @@ -46,7 +46,7 @@ class followup_line(osv.osv): 'start': fields.selection([('days','Net Days'),('end_of_month','End of Month')], 'Type of Term', size=64, required=True), 'followup_id': fields.many2one('account_followup.followup', 'Follow Ups', required=True, ondelete="cascade"), 'description': fields.text('Printed Message', translate=True), - } + } followup_line() @@ -63,7 +63,7 @@ class res_company(osv.osv): _inherit = "res.company" _columns = { 'follow_up_msg' : fields.text('Follow-up Message', translate=True), - } + } _defaults = { 'overdue_msg': ''' @@ -80,7 +80,7 @@ Thanks, %(user_signature)s %(company_name)s ''' - } + } res_company() diff --git a/addons/account_followup/wizard/account_followup_print.py b/addons/account_followup/wizard/account_followup_print.py index fe635a080c7..be353220e99 100644 --- a/addons/account_followup/wizard/account_followup_print.py +++ b/addons/account_followup/wizard/account_followup_print.py @@ -61,12 +61,12 @@ class account_followup_print(osv.osv_memory): 'views': [(resource_id,'form')], 'type': 'ir.actions.act_window', 'target': 'new', - } + } _defaults = { 'date': time.strftime('%Y-%m-%d'), 'followup_id': _get_followup, - } + } account_followup_print() @@ -80,7 +80,7 @@ class account_followup_print_all(osv.osv_memory): 'partner_lang': fields.boolean('Send Email in Partner Language', help='Do not change message text, if you want to send email in partner language, or configure from company'), 'email_body': fields.text('Email body'), 'summary': fields.text('Summary', required=True, readonly=True) - } + } def _get_summary(self, cr, uid, context=None): if context is None: context = {} @@ -285,14 +285,14 @@ class account_followup_print_all(osv.osv_memory): 'ids': [], 'model': 'account_followup.followup', 'form': data - } + } return { 'type': 'ir.actions.report.xml', 'report_name': 'account_followup.followup.print', 'datas': datas, - } + } account_followup_print_all() -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file From faf70e7b3af98de4aefa60529ff03d054ec72503 Mon Sep 17 00:00:00 2001 From: "psi (Open ERP)" Date: Mon, 11 Oct 2010 16:55:50 +0530 Subject: [PATCH 18/26] [IMP] account_analytic_analysis, account_analytic_default, account_analytic_plans: code cleaning bzr revid: psi@tinyerp.co.in-20101011112550-ygkqmzmuhu1j7dm3 --- .../account_analytic_entries_report_view.xml | 24 +- .../account_analytic_analysis.py | 217 +++++++++--------- .../account_analytic_default.py | 71 +++--- .../account_analytic_plans.py | 181 ++++++++------- .../report/crossovered_analytic.py | 71 +++--- .../wizard/account_crossovered_analytic.py | 23 +- .../wizard/analytic_plan_create_model.py | 12 +- 7 files changed, 300 insertions(+), 299 deletions(-) diff --git a/addons/account/report/account_analytic_entries_report_view.xml b/addons/account/report/account_analytic_entries_report_view.xml index 34d23826e80..6f1094599b5 100644 --- a/addons/account/report/account_analytic_entries_report_view.xml +++ b/addons/account/report/account_analytic_entries_report_view.xml @@ -56,18 +56,7 @@ - - - - - - - - - - - - + @@ -83,6 +72,17 @@ + + + + + + + + + + + diff --git a/addons/account_analytic_analysis/account_analytic_analysis.py b/addons/account_analytic_analysis/account_analytic_analysis.py index 108b6acfc97..633524e3aaa 100644 --- a/addons/account_analytic_analysis/account_analytic_analysis.py +++ b/addons/account_analytic_analysis/account_analytic_analysis.py @@ -34,7 +34,7 @@ class account_analytic_account(osv.osv): dp = 2 res = dict([(i, {}) for i in ids]) - parent_ids = tuple(self.search(cr, uid, [('parent_id', 'child_of', ids)])) + parent_ids = tuple(self.search(cr, uid, [('parent_id', 'child_of', ids)], context=context)) accounts = self.browse(cr, uid, ids, context=context) for f in fields: @@ -62,10 +62,10 @@ class account_analytic_account(osv.osv): for id in ids: res[id][f] = 0.0 if parent_ids: - cr.execute("select account_analytic_line.account_id, max(date) \ - from account_analytic_line \ - where account_id IN %s \ - and invoice_id is not null \ + cr.execute("SELECT account_analytic_line.account_id, MAX(date) \ + FROM account_analytic_line \ + WHERE account_id IN %s \ + AND invoice_id IS NOT NULL \ GROUP BY account_analytic_line.account_id;", (parent_ids,)) for account_id, sum in cr.fetchall(): if account_id not in res: @@ -85,25 +85,25 @@ class account_analytic_account(osv.osv): # This computation doesn't take care of pricelist ! # Just consider list_price cr.execute("""SELECT account_analytic_account.id, \ - COALESCE(sum (product_template.list_price * \ + COALESCE(SUM (product_template.list_price * \ account_analytic_line.unit_amount * \ - ((100-hr_timesheet_invoice_factor.factor)/100)),0.0) \ + ((100-hr_timesheet_invoice_factor.factor)/100)), 0.0) \ AS ca_to_invoice \ FROM product_template \ - join product_product \ - on product_template.id = product_product.product_tmpl_id \ + JOIN product_product \ + ON product_template.id = product_product.product_tmpl_id \ JOIN account_analytic_line \ - on account_analytic_line.product_id = product_product.id \ + ON account_analytic_line.product_id = product_product.id \ JOIN account_analytic_journal \ - on account_analytic_line.journal_id = account_analytic_journal.id \ + ON account_analytic_line.journal_id = account_analytic_journal.id \ JOIN account_analytic_account \ - on account_analytic_account.id = account_analytic_line.account_id \ + ON account_analytic_account.id = account_analytic_line.account_id \ JOIN hr_timesheet_invoice_factor \ - on hr_timesheet_invoice_factor.id = account_analytic_account.to_invoice \ + ON hr_timesheet_invoice_factor.id = account_analytic_account.to_invoice \ WHERE account_analytic_account.id IN %s \ - AND account_analytic_line.invoice_id is null \ + AND account_analytic_line.invoice_id IS NULL \ AND account_analytic_line.to_invoice IS NOT NULL \ - and account_analytic_journal.type in ('purchase','general') \ + AND account_analytic_journal.type IN ('purchase','general') \ GROUP BY account_analytic_account.id;""", (parent_ids,)) for account_id, sum in cr.fetchall(): if account_id not in res: @@ -124,13 +124,13 @@ class account_analytic_account(osv.osv): for id in ids: res[id][f] = '' if parent_ids: - cr.execute ("select account_analytic_line.account_id, \ - date(max(account_invoice.date_invoice)) \ - from account_analytic_line \ - join account_invoice \ - on account_analytic_line.invoice_id = account_invoice.id \ - where account_analytic_line.account_id IN %s \ - and account_analytic_line.invoice_id is not null \ + cr.execute ("SELECT account_analytic_line.account_id, \ + DATE(MAX(account_invoice.date_invoice)) \ + FROM account_analytic_line \ + JOIN account_invoice \ + ON account_analytic_line.invoice_id = account_invoice.id \ + WHERE account_analytic_line.account_id IN %s \ + AND account_analytic_line.invoice_id IS NOT NULL \ GROUP BY account_analytic_line.account_id",(parent_ids,)) for account_id, lid in cr.fetchall(): res[account_id][f] = lid @@ -142,11 +142,11 @@ class account_analytic_account(osv.osv): for id in ids: res[id][f] = '' if parent_ids: - cr.execute("select account_analytic_line.account_id, max(date) \ - from account_analytic_line \ - where account_id IN %s \ - and invoice_id is null \ - GROUP BY account_analytic_line.account_id", (parent_ids,)) + cr.execute("SELECT account_analytic_line.account_id, MAX(date) \ + FROM account_analytic_line \ + WHERE account_id IN %s \ + AND invoice_id IS NULL \ + GROUP BY account_analytic_line.account_id" ,(parent_ids,)) for account_id, lwd in cr.fetchall(): if account_id not in res: res[account_id] = {} @@ -159,13 +159,13 @@ class account_analytic_account(osv.osv): for id in ids: res[id][f] = 0.0 if parent_ids: - cr.execute("select account_analytic_line.account_id, COALESCE(sum(unit_amount),0.0) \ - from account_analytic_line \ - join account_analytic_journal \ - on account_analytic_line.journal_id = account_analytic_journal.id \ - where account_analytic_line.account_id IN %s \ - and account_analytic_journal.type='general' \ - and invoice_id is null \ + cr.execute("SELECT account_analytic_line.account_id, COALESCE(SUM(unit_amount), 0.0) \ + FROM account_analytic_line \ + JOIN account_analytic_journal \ + ON account_analytic_line.journal_id = account_analytic_journal.id \ + WHERE account_analytic_line.account_id IN %s \ + AND account_analytic_journal.type='general' \ + AND invoice_id IS NULL \ AND to_invoice IS NOT NULL \ GROUP BY account_analytic_line.account_id;",(parent_ids,)) for account_id, sua in cr.fetchall(): @@ -182,12 +182,12 @@ class account_analytic_account(osv.osv): for id in ids: res[id][f] = 0.0 if parent_ids: - cr.execute("select account_analytic_line.account_id,COALESCE(SUM(unit_amount),0.0) \ - from account_analytic_line \ - join account_analytic_journal \ - on account_analytic_line.journal_id = account_analytic_journal.id \ - where account_analytic_line.account_id IN %s \ - and account_analytic_journal.type='general' \ + cr.execute("SELECT account_analytic_line.account_id, COALESCE(SUM(unit_amount), 0.0) \ + FROM account_analytic_line \ + JOIN account_analytic_journal \ + ON account_analytic_line.journal_id = account_analytic_journal.id \ + WHERE account_analytic_line.account_id IN %s \ + AND account_analytic_journal.type='general' \ GROUP BY account_analytic_line.account_id",(parent_ids,)) ff = cr.fetchall() for account_id, hq in ff: @@ -211,24 +211,24 @@ class account_analytic_account(osv.osv): # This computation doesn't take care of pricelist ! # Just consider list_price if parent_ids: - cr.execute("""select account_analytic_line.account_id as account_id, \ - COALESCE(sum((account_analytic_line.unit_amount * pt.list_price) \ + cr.execute("""SELECT account_analytic_line.account_id AS account_id, \ + COALESCE(SUM((account_analytic_line.unit_amount * pt.list_price) \ - (account_analytic_line.unit_amount * pt.list_price \ - * hr.factor)),0.0) as somme - from account_analytic_line \ - left join account_analytic_journal \ - on (account_analytic_line.journal_id = account_analytic_journal.id) \ - join product_product pp \ - on (account_analytic_line.product_id = pp.id) \ - join product_template pt \ - on (pp.product_tmpl_id = pt.id) \ - join account_analytic_account a \ - on (a.id=account_analytic_line.account_id) \ - join hr_timesheet_invoice_factor hr \ - on (hr.id=a.to_invoice) \ - where account_analytic_line.account_id IN %s \ - and a.to_invoice IS NOT NULL \ - and account_analytic_journal.type IN ('purchase','general') + * hr.factor)), 0.0) AS somme + FROM account_analytic_line \ + LEFT JOIN account_analytic_journal \ + ON (account_analytic_line.journal_id = account_analytic_journal.id) \ + JOIN product_product pp \ + ON (account_analytic_line.product_id = pp.id) \ + JOIN product_template pt \ + ON (pp.product_tmpl_id = pt.id) \ + JOIN account_analytic_account a \ + ON (a.id=account_analytic_line.account_id) \ + JOIN hr_timesheet_invoice_factor hr \ + ON (hr.id=a.to_invoice) \ + WHERE account_analytic_line.account_id IN %s \ + AND a.to_invoice IS NOT NULL \ + AND account_analytic_journal.type IN ('purchase', 'general') GROUP BY account_analytic_line.account_id""",(parent_ids,)) for account_id, sum in cr.fetchall(): res2[account_id] = round(sum, dp) @@ -250,53 +250,51 @@ class account_analytic_account(osv.osv): def _ca_invoiced_calc(self, cr, uid, ids, name, arg, context=None): res = {} - parent_ids = tuple(self.search(cr, uid, [('parent_id', 'child_of', ids)])) + parent_ids = tuple(self.search(cr, uid, [('parent_id', 'child_of', ids)], context=context)) if parent_ids: - cr.execute("select account_analytic_line.account_id, COALESCE(sum(amount_currency),0.0) \ - from account_analytic_line \ - join account_analytic_journal \ - on account_analytic_line.journal_id = account_analytic_journal.id \ - where account_analytic_line.account_id IN %s \ - and account_analytic_journal.type = 'sale' \ - group by account_analytic_line.account_id", (parent_ids,)) + cr.execute("SELECT account_analytic_line.account_id, COALESCE(SUM(amount_currency), 0.0) \ + FROM account_analytic_line \ + JOIN account_analytic_journal \ + ON account_analytic_line.journal_id = account_analytic_journal.id \ + WHERE account_analytic_line.account_id IN %s \ + AND account_analytic_journal.type = 'sale' \ + GROUP BY account_analytic_line.account_id", (parent_ids,)) for account_id, sum in cr.fetchall(): res[account_id] = round(sum,2) - - return self._compute_currency_for_level_tree(cr, uid, ids, parent_ids, res, context) + return self._compute_currency_for_level_tree(cr, uid, ids, parent_ids, res, context=context) def _total_cost_calc(self, cr, uid, ids, name, arg, context=None): res = {} - parent_ids = tuple(self.search(cr, uid, [('parent_id', 'child_of', ids)])) + parent_ids = tuple(self.search(cr, uid, [('parent_id', 'child_of', ids)], context=context)) if parent_ids: - cr.execute("""select account_analytic_line.account_id,COALESCE(sum(amount_currency),0.0) \ - - from account_analytic_line \ - join account_analytic_journal \ - on account_analytic_line.journal_id = account_analytic_journal.id \ - where account_analytic_line.account_id IN %s \ - and amount<0 \ + cr.execute("""SELECT account_analytic_line.account_id, COALESCE(SUM(amount_currency), 0.0) \ + FROM account_analytic_line \ + JOIN account_analytic_journal \ + ON account_analytic_line.journal_id = account_analytic_journal.id \ + WHERE account_analytic_line.account_id IN %s \ + AND amount<0 \ GROUP BY account_analytic_line.account_id""",(parent_ids,)) for account_id, sum in cr.fetchall(): res[account_id] = round(sum,2) - return self._compute_currency_for_level_tree(cr, uid, ids, parent_ids, res, context) + return self._compute_currency_for_level_tree(cr, uid, ids, parent_ids, res, context=context) def _remaining_hours_calc(self, cr, uid, ids, name, arg, context=None): res = {} - for account in self.browse(cr, uid, ids): + for account in self.browse(cr, uid, ids, context=context): if account.quantity_max != 0: res[account.id] = account.quantity_max - account.hours_quantity else: - res[account.id]=0.0 + res[account.id] = 0.0 for id in ids: res[id] = round(res.get(id, 0.0),2) return res def _hours_qtt_invoiced_calc(self, cr, uid, ids, name, arg, context=None): res = {} - for account in self.browse(cr, uid, ids): + for account in self.browse(cr, uid, ids, context=context): res[account.id] = account.hours_quantity - account.hours_qtt_non_invoiced if res[account.id] < 0: - res[account.id]=0.0 + res[account.id] = 0.0 for id in ids: res[id] = round(res.get(id, 0.0),2) return res @@ -414,7 +412,7 @@ class account_analytic_account_summary_user(osv.osv): max_user = cr.fetchone()[0] account_ids = [int(str(x/max_user - (x%max_user == 0 and 1 or 0))) for x in ids] user_ids = [int(str(x-((x/max_user - (x%max_user == 0 and 1 or 0)) *max_user))) for x in ids] - parent_ids = tuple(account_obj.search(cr, uid, [('parent_id', 'child_of', account_ids)])) + parent_ids = tuple(account_obj.search(cr, uid, [('parent_id', 'child_of', account_ids)], context=context)) if parent_ids: cr.execute('SELECT id, unit_amount ' \ 'FROM account_analytic_analysis_summary_user ' \ @@ -477,19 +475,19 @@ class account_analytic_account_summary_user(osv.osv): def _read_flat(self, cr, user, ids, fields, context=None, load='_classic_read'): if not context: - context={} + context = {} if not ids: return [] - if fields==None: + if fields is None: fields = self._columns.keys() + res_trans_obj = self.pool.get('ir.translation') # construct a clause for the rules: d1, d2, tables = self.pool.get('ir.rule').domain_get(cr, user, self._name, 'read', context=context) # all inherited fields + all non inherited fields for which the attribute whose name is in load is True fields_pre = filter(lambda x: x in self._columns and getattr(self._columns[x],'_classic_write'), fields) + self._inherits.values() - res = [] cr.execute('SELECT MAX(id) FROM res_users') max_user = cr.fetchone()[0] @@ -498,9 +496,9 @@ class account_analytic_account_summary_user(osv.osv): for i in range(0, len(ids), cr.IN_MAX): sub_ids = ids[i:i+cr.IN_MAX] if d1: - cr.execute('select %s from \"%s\" where id IN (%s) ' \ - 'and account_id IN (%s) ' \ - 'and "user" IN (%s) and %s order by %s' % \ + cr.execute('SELECT %s FROM \"%s\" WHERE id IN (%s) ' \ + 'AND account_id IN (%s) ' \ + 'AND "user" IN (%s) AND %s ORDER BY %s' % \ (','.join(fields_pre2 + ['id']), self._table, ','.join([str(x) for x in sub_ids]), ','.join([str(x/max_user - (x%max_user == 0 and 1 or 0)) for x in sub_ids]), @@ -510,9 +508,9 @@ class account_analytic_account_summary_user(osv.osv): raise except_orm(_('AccessError'), _('You try to bypass an access rule (Document type: %s).') % self._description) else: - cr.execute('select %s from \"%s\" where id IN (%s) ' \ - 'and account_id IN (%s) ' \ - 'and "user" IN (%s) order by %s' % \ + cr.execute('SELECT %s FROM \"%s\" WHERE id IN (%s) ' \ + 'AND account_id IN (%s) ' \ + 'AND "user" IN (%s) ORDER BY %s' % \ (','.join(fields_pre2 + ['id']), self._table, ','.join([str(x) for x in sub_ids]), ','.join([str(x/max_user - (x%max_user == 0 and 1 or 0)) for x in sub_ids]), @@ -521,7 +519,6 @@ class account_analytic_account_summary_user(osv.osv): res.extend(cr.dictfetchall()) else: res = map(lambda x: {'id': x}, ids) - res_trans_obj = self.pool.get('ir.translation') for f in fields_pre: if self._columns[f].translate: ids = map(lambda x: x['id'], res) @@ -579,7 +576,7 @@ class account_analytic_account_summary_month(osv.osv): account_obj = self.pool.get('account.analytic.account') account_ids = [int(str(int(x))[:-6]) for x in ids] month_ids = [int(str(int(x))[-6:]) for x in ids] - parent_ids = tuple(account_obj.search(cr, uid, [('parent_id', 'child_of', account_ids)])) + parent_ids = tuple(account_obj.search(cr, uid, [('parent_id', 'child_of', account_ids)], context=context)) if parent_ids: cr.execute('SELECT id, unit_amount ' \ 'FROM account_analytic_analysis_summary_month ' \ @@ -598,11 +595,9 @@ class account_analytic_account_summary_month(osv.osv): return res _columns = { - 'account_id': fields.many2one('account.analytic.account', 'Analytic Account', - readonly=True), - 'unit_amount': fields.function(_unit_amount, method=True, type='float', - string='Total Time'), - 'month': fields.char('Month', size=25, readonly=True), + 'account_id': fields.many2one('account.analytic.account', 'Analytic Account', readonly=True), + 'unit_amount': fields.function(_unit_amount, method=True, type='float', string='Total Time'), + 'month': fields.char('Month', size=32, readonly=True), } def init(self, cr): @@ -654,28 +649,27 @@ class account_analytic_account_summary_month(osv.osv): def _read_flat(self, cr, user, ids, fields, context=None, load='_classic_read'): if not context: - context={} + context = {} if not ids: return [] - if fields==None: + if fields is None: fields = self._columns.keys() - - # construct a clause for the rules: - d1, d2, tables = self.pool.get('ir.rule').domain_get(cr, user, self._name) + res_trans_obj = self.pool.get('ir.translation') + # construct a clause for the rules : + d1, d2, tables= self.pool.get('ir.rule').domain_get(cr, user, self._name) # all inherited fields + all non inherited fields for which the attribute whose name is in load is True fields_pre = filter(lambda x: x in self._columns and getattr(self._columns[x],'_classic_write'), fields) + self._inherits.values() - res = [] if fields_pre: fields_pre2 = map(lambda x: (x in ('create_date', 'write_date')) and ('date_trunc(\'second\', '+x+') as '+x) or '"'+x+'"', fields_pre) for i in range(0, len(ids), cr.IN_MAX): sub_ids = ids[i:i+cr.IN_MAX] if d1: - cr.execute('select %s from \"%s\" where id IN (%s) ' \ - 'and account_id IN (%s) ' \ - 'and month_id IN (%s) and %s order by %s' % \ + cr.execute('SELECT %s FROM \"%s\" WHERE id IN (%s) ' \ + 'AND account_id IN (%s) ' \ + 'AND month_id IN (%s) AND %s ORDER BY %s' % \ (','.join(fields_pre2 + ['id']), self._table, ','.join([str(x) for x in sub_ids]), ','.join([str(x)[:-6] for x in sub_ids]), @@ -685,9 +679,9 @@ class account_analytic_account_summary_month(osv.osv): raise except_orm(_('AccessError'), _('You try to bypass an access rule (Document type: %s).') % self._description) else: - cr.execute('select %s from \"%s\" where id IN (%s) ' \ - 'and account_id IN (%s) ' \ - 'and month_id IN (%s) order by %s' % \ + cr.execute('SELECT %s FROM \"%s\" WHERE id IN (%s) ' \ + 'AND account_id IN (%s) ' \ + 'AND month_id IN (%s) ORDER BY %s' % \ (','.join(fields_pre2 + ['id']), self._table, ','.join([str(x) for x in sub_ids]), ','.join([str(x)[:-6] for x in sub_ids]), @@ -697,7 +691,6 @@ class account_analytic_account_summary_month(osv.osv): else: res = map(lambda x: {'id': x}, ids) - res_trans_obj = self.pool.get('ir.translation') for f in fields_pre: if self._columns[f].translate: ids = map(lambda x: x['id'], res) @@ -739,10 +732,8 @@ class account_analytic_account_summary_month(osv.osv): res2 = self._columns[f].get(cr, self, ids, f, user, context=context, values=res) for record in res: record[f] = res2[record['id']] - return res account_analytic_account_summary_month() -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: - +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file diff --git a/addons/account_analytic_default/account_analytic_default.py b/addons/account_analytic_default/account_analytic_default.py index dce86597a4c..ebc78956a93 100644 --- a/addons/account_analytic_default/account_analytic_default.py +++ b/addons/account_analytic_default/account_analytic_default.py @@ -21,13 +21,13 @@ import time -from osv import fields,osv +from osv import fields, osv class account_analytic_default(osv.osv): - _name = 'account.analytic.default' - _description = 'Analytic Distribution' - _rec_name = 'analytic_id' - _order = 'sequence' + _name = "account.analytic.default" + _description = "Analytic Distribution" + _rec_name = "analytic_id" + _order = "sequence" _columns = { 'sequence': fields.integer('Sequence', help="Gives the sequence order when displaying a list of analytic distribution."), 'analytic_id': fields.many2one('account.analytic.account', 'Analytic Account'), @@ -38,50 +38,50 @@ class account_analytic_default(osv.osv): 'date_start': fields.date('Start Date'), 'date_stop': fields.date('End Date'), } - + def account_get(self, cr, uid, product_id=None, partner_id=None, user_id=None, date=None, context=None): domain = [] if product_id: - domain += ['|',('product_id','=',product_id)] - domain += [('product_id','=',False)] + domain += ['|', ('product_id', '=', product_id)] + domain += [('product_id','=', False)] if partner_id: - domain += ['|',('partner_id','=',partner_id)] - domain += [('partner_id','=',False)] + domain += ['|', ('partner_id', '=', partner_id)] + domain += [('partner_id', '=', False)] if user_id: - domain += ['|',('user_id','=',user_id)] - domain += [('user_id','=',False)] + domain += ['|',('user_id', '=', user_id)] + domain += [('user_id','=', False)] if date: - domain += ['|',('date_start','<=',date),('date_start','=',False)] - domain += ['|',('date_stop','>=',date),('date_stop','=',False)] + domain += ['|', ('date_start', '<=', date), ('date_start', '=', False)] + domain += ['|', ('date_stop', '>=', date), ('date_stop', '=', False)] best_index = -1 res = False for rec in self.browse(cr, uid, self.search(cr, uid, domain, context=context), context=context): index = 0 - if rec.product_id: index+=1 - if rec.partner_id: index+=1 - if rec.user_id: index+=1 - if rec.date_start: index+=1 - if rec.date_stop: index+=1 - if index>best_index: + if rec.product_id: index += 1 + if rec.partner_id: index += 1 + if rec.user_id: index += 1 + if rec.date_start: index += 1 + if rec.date_stop: index += 1 + if index > best_index: res = rec best_index = index return res - + account_analytic_default() class account_invoice_line(osv.osv): - _inherit = 'account.invoice.line' - _description = 'Invoice Line' + _inherit = "account.invoice.line" + _description = "Invoice Line" def product_id_change(self, cr, uid, ids, product, uom, qty=0, name='', type='out_invoice', partner_id=False, fposition_id=False, price_unit=False, address_invoice_id=False, currency_id=False, context=None): - res_prod = super(account_invoice_line,self).product_id_change(cr, uid, ids, product, uom, qty, name, type, partner_id, fposition_id, price_unit, address_invoice_id, currency_id=currency_id, context=context) - rec = self.pool.get('account.analytic.default').account_get(cr, uid, product, partner_id, uid, time.strftime('%Y-%m-%d'), context) + res_prod = super(account_invoice_line, self).product_id_change(cr, uid, ids, product, uom, qty, name, type, partner_id, fposition_id, price_unit, address_invoice_id, currency_id=currency_id, context=context) + rec = self.pool.get('account.analytic.default').account_get(cr, uid, product, partner_id, uid, time.strftime('%Y-%m-%d'), context=context) if rec: - res_prod['value'].update({'account_analytic_id':rec.analytic_id.id}) + res_prod['value'].update({'account_analytic_id': rec.analytic_id.id}) else: - res_prod['value'].update({'account_analytic_id':False}) + res_prod['value'].update({'account_analytic_id': False}) return res_prod - + account_invoice_line() @@ -95,28 +95,27 @@ class stock_picking(osv.osv): if rec: return rec.analytic_id.id - return super(stock_picking, self)._get_account_analytic_invoice(cursor, - user, picking, move_line) + return super(stock_picking, self)._get_account_analytic_invoice(cursor, user, picking, move_line) stock_picking() class sale_order_line(osv.osv): - _inherit = 'sale.order.line' + _inherit = "sale.order.line" # Method overridden to set the analytic account by default on criterion match def invoice_line_create(self, cr, uid, ids, context=None): - create_ids = super(sale_order_line,self).invoice_line_create(cr, uid, ids, context) + create_ids = super(sale_order_line, self).invoice_line_create(cr, uid, ids, context=context) if not ids: return create_ids - sale_line = self.browse(cr, uid, ids[0], context) + sale_line = self.browse(cr, uid, ids[0], context=context) inv_line_obj = self.pool.get('account.invoice.line') anal_def_obj = self.pool.get('account.analytic.default') - for line in inv_line_obj.browse(cr, uid, create_ids, context): - rec = anal_def_obj.account_get(cr, uid, line.product_id.id, sale_line.order_id.partner_id.id, sale_line.order_id.user_id.id, time.strftime('%Y-%m-%d'), context) + for line in inv_line_obj.browse(cr, uid, create_ids, context=context): + rec = anal_def_obj.account_get(cr, uid, line.product_id.id, sale_line.order_id.partner_id.id, sale_line.order_id.user_id.id, time.strftime('%Y-%m-%d'), context=context) if rec: - inv_line_obj.write(cr, uid, [line.id], {'account_analytic_id':rec.analytic_id.id}, context=context) + inv_line_obj.write(cr, uid, [line.id], {'account_analytic_id': rec.analytic_id.id}, context=context) return create_ids sale_order_line() diff --git a/addons/account_analytic_plans/account_analytic_plans.py b/addons/account_analytic_plans/account_analytic_plans.py index 73b0fcb301d..0e3ec4b33ca 100644 --- a/addons/account_analytic_plans/account_analytic_plans.py +++ b/addons/account_analytic_plans/account_analytic_plans.py @@ -18,8 +18,9 @@ # along with this program. If not, see . # ############################################################################## -from lxml import etree + import time +from lxml import etree from osv import fields, osv import tools @@ -34,10 +35,10 @@ class one2many_mod2(fields.one2many): res[id] = [] ids2 = None if 'journal_id' in context: - journal = obj.pool.get('account.journal').browse(cr, user, context['journal_id'], context) + journal = obj.pool.get('account.journal').browse(cr, user, context['journal_id'], context=context) pnum = int(name[7]) -1 plan = journal.plan_id - if plan and len(plan.plan_ids)>pnum: + if plan and len(plan.plan_ids) > pnum: acc_id = plan.plan_ids[pnum].root_analytic_id.id ids2 = obj.pool.get(self._obj).search(cr, user, [(self._fields_id,'in',ids),('analytic_account_id','child_of',[acc_id])], limit=self._limit) if ids2 is None: @@ -50,8 +51,8 @@ class account_analytic_plan(osv.osv): _name = "account.analytic.plan" _description = "Analytic Plan" _columns = { - 'name': fields.char('Analytic Plan', size=64, required=True, select=True,), - 'plan_ids': fields.one2many('account.analytic.plan.line','plan_id','Analytic Plans'), + 'name': fields.char('Analytic Plan', size=64, required=True, select=True), + 'plan_ids': fields.one2many('account.analytic.plan.line', 'plan_id', 'Analytic Plans'), } account_analytic_plan() @@ -61,10 +62,10 @@ class account_analytic_plan_line(osv.osv): _description = "Analytic Plan Line" _order = "sequence, id" _columns = { - 'plan_id':fields.many2one('account.analytic.plan','Analytic Plan'), + 'plan_id': fields.many2one('account.analytic.plan','Analytic Plan'), 'name': fields.char('Plan Name', size=64, required=True, select=True), - 'sequence':fields.integer('Sequence'), - 'root_analytic_id': fields.many2one('account.analytic.account','Root Account',help="Root account of this plan.",required=False), + 'sequence': fields.integer('Sequence'), + 'root_analytic_id': fields.many2one('account.analytic.account', 'Root Account', help="Root account of this plan.", required=False), 'min_required': fields.float('Minimum Allowed (%)'), 'max_required': fields.float('Maximum Allowed (%)'), } @@ -76,27 +77,28 @@ class account_analytic_plan_line(osv.osv): account_analytic_plan_line() class account_analytic_plan_instance(osv.osv): - _name = 'account.analytic.plan.instance' - _description = 'Analytic Plan Instance' + _name = "account.analytic.plan.instance" + _description = "Analytic Plan Instance" _columns = { - 'name':fields.char('Analytic Distribution', size=64), - 'code':fields.char('Distribution Code', size=16), + 'name': fields.char('Analytic Distribution', size=64), + 'code': fields.char('Distribution Code', size=16), 'journal_id': fields.many2one('account.analytic.journal', 'Analytic Journal' ), - 'account_ids':fields.one2many('account.analytic.plan.instance.line', 'plan_id', 'Account Id'), - 'account1_ids':one2many_mod2('account.analytic.plan.instance.line', 'plan_id', 'Account1 Id'), - 'account2_ids':one2many_mod2('account.analytic.plan.instance.line', 'plan_id', 'Account2 Id'), - 'account3_ids':one2many_mod2('account.analytic.plan.instance.line', 'plan_id', 'Account3 Id'), - 'account4_ids':one2many_mod2('account.analytic.plan.instance.line', 'plan_id', 'Account4 Id'), - 'account5_ids':one2many_mod2('account.analytic.plan.instance.line', 'plan_id', 'Account5 Id'), - 'account6_ids':one2many_mod2('account.analytic.plan.instance.line', 'plan_id', 'Account6 Id'), - 'plan_id':fields.many2one('account.analytic.plan', "Model's Plan"), + 'account_ids': fields.one2many('account.analytic.plan.instance.line', 'plan_id', 'Account Id'), + 'account1_ids': one2many_mod2('account.analytic.plan.instance.line', 'plan_id', 'Account1 Id'), + 'account2_ids': one2many_mod2('account.analytic.plan.instance.line', 'plan_id', 'Account2 Id'), + 'account3_ids': one2many_mod2('account.analytic.plan.instance.line', 'plan_id', 'Account3 Id'), + 'account4_ids': one2many_mod2('account.analytic.plan.instance.line', 'plan_id', 'Account4 Id'), + 'account5_ids': one2many_mod2('account.analytic.plan.instance.line', 'plan_id', 'Account5 Id'), + 'account6_ids': one2many_mod2('account.analytic.plan.instance.line', 'plan_id', 'Account6 Id'), + 'plan_id': fields.many2one('account.analytic.plan', "Model's Plan"), } def search(self, cr, user, args, offset=0, limit=None, order=None, context=None, count=False): if context is None: context = {} + journal_obj = self.pool.get('account.journal') if context.get('journal_id', False): - journal = self.pool.get('account.journal').browse(cr, user, [context['journal_id']], context=context)[0] + journal = journal_obj.browse(cr, user, [context['journal_id']], context=context)[0] analytic_journal = journal.analytic_journal_id and journal.analytic_journal_id.id or False args.append('|') args.append(('journal_id', '=', analytic_journal)) @@ -108,15 +110,16 @@ class account_analytic_plan_instance(osv.osv): def copy(self, cr, uid, id, default=None, context=None): if not default: default = {} - default.update({'account1_ids':False, 'account2_ids':False, 'account3_ids':False, + default.update({'account1_ids':False, 'account2_ids':False, 'account3_ids':False, 'account4_ids':False, 'account5_ids':False, 'account6_ids':False}) - return super(account_analytic_plan_instance, self).copy(cr, uid, id, default, context) + return super(account_analytic_plan_instance, self).copy(cr, uid, id, default, context=context) def _default_journal(self, cr, uid, context=None): if not context: context = {} + journal_obj = self.pool.get('account.journal') if context.has_key('journal_id') and context['journal_id']: - journal = self.pool.get('account.journal').browse(cr, uid, context['journal_id']) + journal = journal_obj.browse(cr, uid, context['journal_id'], context=context) if journal.analytic_journal_id: return journal.analytic_journal_id.id return False @@ -127,7 +130,7 @@ class account_analytic_plan_instance(osv.osv): } def name_get(self, cr, uid, ids, context=None): res = [] - for inst in self.browse(cr, uid, ids, context): + for inst in self.browse(cr, uid, ids, context=context): name = inst.name or '/' if name and inst.code: name=name+' ('+inst.code+')' @@ -135,7 +138,7 @@ class account_analytic_plan_instance(osv.osv): return res def name_search(self, cr, uid, name, args=None, operator='ilike', context=None, limit=100): - args= args or [] + args = args or [] if name: ids = self.search(cr, uid, [('code', '=', name)] + args, limit=limit, context=context or {}) if not ids: @@ -145,15 +148,16 @@ class account_analytic_plan_instance(osv.osv): return self.name_get(cr, uid, ids, context or {}) def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False): - wiz_id = self.pool.get('ir.actions.act_window').search(cr, uid, [("name","=","analytic.plan.create.model.action")]) + wiz_id = self.pool.get('ir.actions.act_window').search(cr, uid, [("name","=","analytic.plan.create.model.action")], context=context) res = super(account_analytic_plan_instance,self).fields_view_get(cr, uid, view_id, view_type, context, toolbar=toolbar, submenu=submenu) - + journal_obj = self.pool.get('account.journal') + analytic_plan_obj = self.pool.get('account.analytic.plan') if (res['type']=='form'): plan_id = False - if context.get('journal_id',False): - plan_id = self.pool.get('account.journal').browse(cr, uid, int(context['journal_id']), context).plan_id - elif context.get('plan_id',False): - plan_id = self.pool.get('account.analytic.plan').browse(cr, uid, int(context['plan_id']), context) + if context.get('journal_id', False): + plan_id = journal_obj.browse(cr, uid, int(context['journal_id']), context=context).plan_id + elif context.get('plan_id', False): + plan_id = analytic_plan_obj.browse(cr, uid, int(context['plan_id']), context=context) if plan_id: i=1 @@ -183,40 +187,43 @@ class account_analytic_plan_instance(osv.osv): return res def create(self, cr, uid, vals, context=None): + journal_obj = self.pool.get('account.journal') + ana_plan_instance_obj = self.pool.get('account.analytic.plan.instance') + acct_anal_acct = self.pool.get('account.analytic.account') + acct_anal_plan_line_obj = self.pool.get('account.analytic.plan.line') if context and 'journal_id' in context: - journal= self.pool.get('account.journal').browse(cr, uid, context['journal_id']) + journal = journal_obj.browse(cr, uid, context['journal_id'], context=context) - pids = self.pool.get('account.analytic.plan.instance').search(cr, uid, [('name','=',vals['name']),('code','=',vals['code']),('plan_id','<>',False)]) + pids = ana_plan_instance_obj.search(cr, uid, [('name','=',vals['name']), ('code','=',vals['code']), ('plan_id','<>',False)], context=context) if pids: raise osv.except_osv(_('Error'), _('A model having this name and code already exists !')) - acct_anal_acct = self.pool.get('account.analytic.account') - acct_anal_plan_line_obj = self.pool.get('account.analytic.plan.line') - res = acct_anal_plan_line_obj.search(cr, uid, [('plan_id','=',journal.plan_id.id)]) + res = acct_anal_plan_line_obj.search(cr, uid, [('plan_id','=',journal.plan_id.id)], context=context) for i in res: total_per_plan = 0 - item = acct_anal_plan_line_obj.browse(cr, uid, i) - temp_list=['account1_ids','account2_ids','account3_ids','account4_ids','account5_ids','account6_ids'] + item = acct_anal_plan_line_obj.browse(cr, uid, i, context=context) + temp_list = ['account1_ids','account2_ids','account3_ids','account4_ids','account5_ids','account6_ids'] for l in temp_list: if vals.has_key(l): for tempo in vals[l]: - if acct_anal_acct.search(cr, uid,[('parent_id','child_of',[item.root_analytic_id.id]),('id','=',tempo[2]['analytic_account_id'])]): + if acct_anal_acct.search(cr, uid, [('parent_id', 'child_of', [item.root_analytic_id.id]), ('id', '=', tempo[2]['analytic_account_id'])], context=context): total_per_plan += tempo[2]['rate'] if total_per_plan < item.min_required or total_per_plan > item.max_required: raise osv.except_osv(_('Value Error'),_('The Total Should be Between %s and %s') % (str(item.min_required), str(item.max_required))) - return super(account_analytic_plan_instance, self).create(cr, uid, vals, context) + return super(account_analytic_plan_instance, self).create(cr, uid, vals, context=context) def write(self, cr, uid, ids, vals, context=None, check=True, update_check=True): - this = self.browse(cr, uid, ids[0]) + this = self.browse(cr, uid, ids[0], context=context) + invoice_line_obj = self.pool.get('account.invoice.line') if this.plan_id and not vals.has_key('plan_id'): #this instance is a model, so we have to create a new plan instance instead of modifying it #copy the existing model - temp_id = self.copy(cr, uid, this.id, None, context) + temp_id = self.copy(cr, uid, this.id, None, context=context) #get the list of the invoice line that were linked to the model - list = self.pool.get('account.invoice.line').search(cr, uid, [('analytics_id','=',this.id)]) + lists = invoice_line_obj.search(cr, uid, [('analytics_id','=',this.id)], context=context) #make them link to the copy - self.pool.get('account.invoice.line').write(cr, uid, list, {'analytics_id':temp_id}, context) + invoice_line_obj.write(cr, uid, lists, {'analytics_id':temp_id}, context=context) #and finally modify the old model to be not a model anymore vals['plan_id'] = False @@ -224,17 +231,17 @@ class account_analytic_plan_instance(osv.osv): vals['name'] = this.name and (str(this.name)+'*') or "*" if not vals.has_key('code'): vals['code'] = this.code and (str(this.code)+'*') or "*" - return super(account_analytic_plan_instance, self).write(cr, uid, ids, vals, context) + return super(account_analytic_plan_instance, self).write(cr, uid, ids, vals, context=context) account_analytic_plan_instance() class account_analytic_plan_instance_line(osv.osv): - _name='account.analytic.plan.instance.line' - _description = 'Analytic Instance Line' - _columns={ - 'plan_id':fields.many2one('account.analytic.plan.instance', 'Plan Id'), - 'analytic_account_id':fields.many2one('account.analytic.account', 'Analytic Account', required=True), - 'rate':fields.float('Rate (%)', required=True), + _name = "account.analytic.plan.instance.line" + _description = "Analytic Instance Line" + _columns = { + 'plan_id': fields.many2one('account.analytic.plan.instance', 'Plan Id'), + 'analytic_account_id': fields.many2one('account.analytic.account', 'Analytic Account', required=True), + 'rate': fields.float('Rate (%)', required=True), } _defaults = { 'rate': 100.0 @@ -242,7 +249,7 @@ class account_analytic_plan_instance_line(osv.osv): def name_get(self, cr, uid, ids, context=None): if not ids: return [] - reads = self.read(cr, uid, ids, ['analytic_account_id'], context) + reads = self.read(cr, uid, ids, ['analytic_account_id'], context=context) res = [] for record in reads: res.append((record['id'], record['analytic_account_id'])) @@ -251,44 +258,44 @@ class account_analytic_plan_instance_line(osv.osv): account_analytic_plan_instance_line() class account_journal(osv.osv): - _inherit='account.journal' - _name='account.journal' + _inherit = "account.journal" + _name = "account.journal" _columns = { - 'plan_id':fields.many2one('account.analytic.plan', 'Analytic Plans'), + 'plan_id': fields.many2one('account.analytic.plan', 'Analytic Plans'), } account_journal() class account_invoice_line(osv.osv): - _inherit='account.invoice.line' - _name='account.invoice.line' + _inherit = "account.invoice.line" + _name = "account.invoice.line" _columns = { - 'analytics_id':fields.many2one('account.analytic.plan.instance', 'Analytic Distribution'), + 'analytics_id': fields.many2one('account.analytic.plan.instance', 'Analytic Distribution'), } def create(self, cr, uid, vals, context=None): - if 'analytics_id' in vals and isinstance(vals['analytics_id'],tuple): + if 'analytics_id' in vals and isinstance(vals['analytics_id'], tuple): vals['analytics_id'] = vals['analytics_id'][0] - return super(account_invoice_line, self).create(cr, uid, vals, context) + return super(account_invoice_line, self).create(cr, uid, vals, context=context) def move_line_get_item(self, cr, uid, line, context=None): - res= super(account_invoice_line,self).move_line_get_item(cr, uid, line, context={}) - res ['analytics_id']=line.analytics_id and line.analytics_id.id or False + res = super(account_invoice_line, self).move_line_get_item(cr, uid, line, context=context) + res ['analytics_id'] = line.analytics_id and line.analytics_id.id or False return res def product_id_change(self, cr, uid, ids, product, uom, qty=0, name='', type='out_invoice', partner_id=False, fposition_id=False, price_unit=False, address_invoice_id=False, currency_id=False, context=None): - res_prod = super(account_invoice_line,self).product_id_change(cr, uid, ids, product, uom, qty, name, type, partner_id, fposition_id, price_unit, address_invoice_id, currency_id, context=context) - rec = self.pool.get('account.analytic.default').account_get(cr, uid, product, partner_id, uid, time.strftime('%Y-%m-%d'), context) + res_prod = super(account_invoice_line, self).product_id_change(cr, uid, ids, product, uom, qty, name, type, partner_id, fposition_id, price_unit, address_invoice_id, currency_id, context=context) + rec = self.pool.get('account.analytic.default').account_get(cr, uid, product, partner_id, uid, time.strftime('%Y-%m-%d'), context=context) if rec and rec.analytics_id: - res_prod['value'].update({'analytics_id':rec.analytics_id.id}) + res_prod['value'].update({'analytics_id': rec.analytics_id.id}) return res_prod account_invoice_line() class account_move_line(osv.osv): - _inherit='account.move.line' - _name='account.move.line' + _inherit = "account.move.line" + _name = "account.move.line" _columns = { 'analytics_id':fields.many2one('account.analytic.plan.instance', 'Analytic Distribution'), } @@ -300,9 +307,9 @@ class account_move_line(osv.osv): return data def create_analytic_lines(self, cr, uid, ids, context=None): - super(account_move_line, self).create_analytic_lines(cr, uid, ids, context) + super(account_move_line, self).create_analytic_lines(cr, uid, ids, context=context) analytic_line_obj = self.pool.get('account.analytic.line') - for line in self.browse(cr, uid, ids, context): + for line in self.browse(cr, uid, ids, context=context): if line.analytics_id: if not line.journal_id.analytic_journal_id: raise osv.except_osv(_('No Analytic Journal !'),_("You have to define an analytic journal on the '%s' journal!") % (line.journal_id.name,)) @@ -333,24 +340,25 @@ account_move_line() class account_invoice(osv.osv): _name = "account.invoice" - _inherit="account.invoice" + _inherit = "account.invoice" def line_get_convert(self, cr, uid, x, part, date, context=None): - res=super(account_invoice,self).line_get_convert(cr, uid, x, part, date, context) - res['analytics_id']=x.get('analytics_id',False) + res=super(account_invoice,self).line_get_convert(cr, uid, x, part, date, context=context) + res['analytics_id'] = x.get('analytics_id', False) return res def _get_analytic_lines(self, cr, uid, id): inv = self.browse(cr, uid, [id])[0] cur_obj = self.pool.get('res.currency') + invoice_line_obj = self.pool.get('account.invoice.line') + acct_ins_obj = self.pool.get('account.analytic.plan.instance') company_currency = inv.company_id.currency_id.id if inv.type in ('out_invoice', 'in_refund'): sign = 1 else: sign = -1 - iml = self.pool.get('account.invoice.line').move_line_get(cr, uid, inv.id) - acct_ins_obj = self.pool.get('account.analytic.plan.instance') + iml = invoice_line_obj.move_line_get(cr, uid, inv.id) for il in iml: if il.get('analytics_id', False): @@ -369,8 +377,8 @@ class account_invoice(osv.osv): al_vals = { 'name': il['name'], 'date': inv['date_invoice'], - 'unit_amount':qtty, - 'product_id':il['product_id'], + 'unit_amount': qtty, + 'product_id': il['product_id'], 'account_id': line2.analytic_account_id.id, 'amount': amt, 'product_uom_id': il['uos_id'], @@ -378,7 +386,7 @@ class account_invoice(osv.osv): 'journal_id': self._get_journal_analytic(cr, uid, inv.type), 'ref': ref, } - il['analytic_lines'].append((0,0,al_vals)) + il['analytic_lines'].append((0, 0, al_vals)) return iml account_invoice() @@ -391,7 +399,7 @@ class account_analytic_plan(osv.osv): account_analytic_plan() class analytic_default(osv.osv): - _inherit = 'account.analytic.default' + _inherit = "account.analytic.default" _columns = { 'analytics_id': fields.many2one('account.analytic.plan.instance', 'Analytic Distribution'), } @@ -399,21 +407,20 @@ class analytic_default(osv.osv): analytic_default() class sale_order_line(osv.osv): - _inherit = 'sale.order.line' + _inherit = "sale.order.line" # Method overridden to set the analytic account by default on criterion match def invoice_line_create(self, cr, uid, ids, context=None): - create_ids = super(sale_order_line,self).invoice_line_create(cr, uid, ids, context) + create_ids = super(sale_order_line,self).invoice_line_create(cr, uid, ids, context=context) + inv_line_obj = self.pool.get('account.invoice.line') + acct_anal_def_obj = self.pool.get('account.analytic.default') if ids: - sale_line = self.browse(cr, uid, ids[0], context) - inv_line_obj = self.pool.get('account.invoice.line') - acct_anal_def_obj = self.pool.get('account.analytic.default') - - for line in inv_line_obj.browse(cr, uid, create_ids, context): + sale_line = self.browse(cr, uid, ids[0], context=context) + for line in inv_line_obj.browse(cr, uid, create_ids, context=context): rec = acct_anal_def_obj.account_get(cr, uid, line.product_id.id, sale_line.order_id.partner_id.id, uid, time.strftime('%Y-%m-%d'), context) if rec: - inv_line_obj.write(cr, uid, [line.id], {'analytics_id':rec.analytics_id.id}, context=context) + inv_line_obj.write(cr, uid, [line.id], {'analytics_id': rec.analytics_id.id}, context=context) return create_ids sale_order_line() diff --git a/addons/account_analytic_plans/report/crossovered_analytic.py b/addons/account_analytic_plans/report/crossovered_analytic.py index f4d35f936e1..67b25ae6013 100644 --- a/addons/account_analytic_plans/report/crossovered_analytic.py +++ b/addons/account_analytic_plans/report/crossovered_analytic.py @@ -39,11 +39,12 @@ class crossovered_analytic(report_sxw.rml_parse): final_list = [] parent_list = [] set_list = [] + analytic_obj = self.pool.get('account.analytic.account') for id in ref_ids: # to avoid duplicate entries if id not in to_return_ids: - to_return_ids.append(self.pool.get('account.analytic.account').search(self.cr,self.uid,[('parent_id','child_of',[id])])) - data_accnt = self.pool.get('account.analytic.account').browse(self.cr,self.uid,to_return_ids[0]) + to_return_ids.append(analytic_obj.search(self.cr,self.uid,[('parent_id','child_of',[id])])) + data_accnt = analytic_obj.browse(self.cr,self.uid,to_return_ids[0]) for data in data_accnt: if data.parent_id and data.parent_id.id == ref_ids[0]: parent_list.append(data.id) @@ -54,7 +55,7 @@ class crossovered_analytic(report_sxw.rml_parse): def set_account(self,cats): lst = [] - category = self.pool.get('account.analytic.account').read(self.cr,self.uid,cats) + category = self.pool.get('account.analytic.account').read(self.cr, self.uid, cats) for cat in category: lst.append(cat['id']) if cat['child_ids']: @@ -75,44 +76,44 @@ class crossovered_analytic(report_sxw.rml_parse): else: journal = 'is not null' - query_general = "select id from account_analytic_line where (journal_id " + journal +") AND date>='"+ str(form['date1']) +"'"" AND date<='" + str(form['date2']) + "'" + query_general = "SELECT id FROM account_analytic_line WHERE (journal_id " + journal +") AND date>='"+ str(form['date1']) +"'"" AND date<='" + str(form['date2']) + "'" self.cr.execute(query_general) - l_ids=self.cr.fetchall() + l_ids = self.cr.fetchall() line_ids = [x[0] for x in l_ids] obj_line = line_pool.browse(self.cr,self.uid,line_ids) #this structure will be usefull for easily knowing the account_analytic_line that are related to the reference account. At this purpose, we save the move_id of analytic lines. self.dict_acc_ref[form['ref']] = [] - children_list = self.pool.get('account.analytic.account').search(self.cr,self.uid,[('parent_id','child_of',[form['ref']])]) + children_list = acc_pool.search(self.cr, self.uid, [('parent_id', 'child_of', [form['ref']])]) for obj in obj_line: if obj.account_id.id in children_list: if obj.move_id and obj.move_id.id not in self.dict_acc_ref[form['ref']]: self.dict_acc_ref[form['ref']].append(obj.move_id.id) - res['ref_name'] = acc_pool.name_get(self.cr,self.uid,[form['ref']])[0][1] - res['ref_code'] = acc_pool.browse(self.cr,self.uid,form['ref']).code + res['ref_name'] = acc_pool.name_get(self.cr, self.uid, [form['ref']])[0][1] + res['ref_code'] = acc_pool.browse(self.cr, self.uid, form['ref']).code self.final_list = children_list - selected_ids = line_pool.search(self.cr,self.uid,[('account_id','in',self.final_list)]) + selected_ids = line_pool.search(self.cr, self.uid, [('account_id', 'in' ,self.final_list)]) if selected_ids: - query="SELECT sum(aal.amount) AS amt, sum(aal.unit_amount) AS qty FROM account_analytic_line AS aal, account_analytic_account AS aaa \ - WHERE aal.account_id=aaa.id AND aal.id IN ("+','.join(map(str,selected_ids))+") AND (aal.journal_id " + journal +") AND aal.date>='"+ str(form['date1']) +"'"" AND aal.date<='" + str(form['date2']) + "'" + query = "SELECT SUM(aal.amount) AS amt, SUM(aal.unit_amount) AS qty FROM account_analytic_line AS aal, account_analytic_account AS aaa \ + WHERE aal.account_id = aaa.id AND aal.id IN ("+','.join(map(str,selected_ids))+") AND (aal.journal_id " + journal +") AND aal.date>='"+ str(form['date1']) +"'"" AND aal.date<='" + str(form['date2']) + "'" self.cr.execute(query) info=self.cr.dictfetchall() - res['ref_qty']=info[0]['qty'] - res['ref_amt']=info[0]['amt'] - self.base_amount= info[0]['amt'] - res['ref_qty']=0.0 - res['ref_amt']=0.0 - self.base_amount= 0.0 + res['ref_qty'] = info[0]['qty'] + res['ref_amt'] = info[0]['amt'] + self.base_amount = info[0]['amt'] + res['ref_qty'] = 0.0 + res['ref_amt'] = 0.0 + self.base_amount = 0.0 result.append(res) return result - def _lines(self,form,ids={}): + def _lines(self, form, ids={}): if not ids: ids = self.ids @@ -122,43 +123,43 @@ class crossovered_analytic(report_sxw.rml_parse): journal= 'is not null' acc_pool = self.pool.get('account.analytic.account') - line_pool=self.pool.get('account.analytic.line') - acc_id=[] - final=[] - child_ids=[] - self.list_ids=[] + line_pool = self.pool.get('account.analytic.line') + acc_id = [] + final = [] + child_ids = [] + self.list_ids = [] self.final_list = self.find_children(ids) for acc_id in self.final_list: - selected_ids = line_pool.search(self.cr,self.uid,[('account_id','=',acc_id),('move_id','in',self.dict_acc_ref[form['ref']])]) + selected_ids = line_pool.search(self.cr, self.uid, [('account_id','=',acc_id), ('move_id', 'in', self.dict_acc_ref[form['ref']])]) if selected_ids: - query="SELECT aaa.code as code, sum(aal.amount) AS amt, sum(aal.unit_amount) AS qty,aaa.name as acc_name,aal.account_id as id FROM account_analytic_line AS aal, account_analytic_account AS aaa \ + query="SELECT aaa.code AS code, SUM(aal.amount) AS amt, SUM(aal.unit_amount) AS qty, aaa.name AS acc_name, aal.account_id AS id FROM account_analytic_line AS aal, account_analytic_account AS aaa \ WHERE aal.account_id=aaa.id AND aal.id IN ("+','.join(map(str,selected_ids))+") AND (aal.journal_id " + journal +") AND aal.date>='"+ str(form['date1']) +"'"" AND aal.date<='" + str(form['date2']) + "'"" GROUP BY aal.account_id,aaa.name,aaa.code ORDER BY aal.account_id" self.cr.execute(query) res = self.cr.dictfetchall() if res: for element in res: - if self.base_amount<>0.00: - element['perc']= (element['amt'] / self.base_amount) * 100.00 + if self.base_amount <> 0.00: + element['perc'] = (element['amt'] / self.base_amount) * 100.00 else: - element['perc']=0.00 + element['perc'] = 0.00 else: - result={} - res=[] - result['id']=acc_id - data_account = acc_pool.browse(self.cr,self.uid,acc_id) - result['acc_name']=data_account.name + result = {} + res = [] + result['id'] = acc_id + data_account = acc_pool.browse(self.cr, self.uid, acc_id) + result['acc_name'] = data_account.name result['code'] = data_account.code - result['amt']=result['qty']=result['perc']=0.00 + result['amt'] = result['qty'] = result['perc'] = 0.00 if not form['empty_line']: res.append(result) else: result = {} res = [] result['id'] = acc_id - data_account = acc_pool.browse(self.cr,self.uid,acc_id) + data_account = acc_pool.browse(self.cr, self.uid, acc_id) result['acc_name'] = data_account.name result['code'] = data_account.code result['amt'] = result['qty'] = result['perc'] = 0.00 diff --git a/addons/account_analytic_plans/wizard/account_crossovered_analytic.py b/addons/account_analytic_plans/wizard/account_crossovered_analytic.py index 97df80e23fc..2b36fec2cc9 100644 --- a/addons/account_analytic_plans/wizard/account_crossovered_analytic.py +++ b/addons/account_analytic_plans/wizard/account_crossovered_analytic.py @@ -18,37 +18,38 @@ # along with this program. If not, see . # ############################################################################## + import time from osv import osv, fields from tools.translate import _ class account_crossovered_analytic(osv.osv_memory): - _name = 'account.crossovered.analytic' - _description = 'Print Crossovered Analytic' + _name = "account.crossovered.analytic" + _description = "Print Crossovered Analytic" _columns = { 'date1': fields.date('Start Date', required=True), 'date2': fields.date('End Date', required=True), 'journal_ids': fields.many2many('account.analytic.journal', 'crossovered_journal_rel', 'crossover_id', 'journal_id', 'Analytic Journal'), 'ref': fields.many2one('account.analytic.account', 'Analytic Account Reference', required=False), 'empty_line': fields.boolean('Dont show empty lines'), - } + } _defaults = { - 'date1': lambda *a: time.strftime('%Y-01-01'), - 'date2': lambda *a: time.strftime('%Y-%m-%d'), - } + 'date1': time.strftime('%Y-01-01'), + 'date2': time.strftime('%Y-%m-%d'), + } def print_report(self, cr, uid, ids, context=None): - cr.execute('select account_id from account_analytic_line') + cr.execute('SELECT account_id FROM account_analytic_line') res = cr.fetchall() acc_ids = [x[0] for x in res] data = self.read(cr, uid, ids, [], context=context)[0] - obj_acc = self.pool.get('account.analytic.account').browse(cr, uid, data['ref']) + obj_acc = self.pool.get('account.analytic.account').browse(cr, uid, data['ref'], context=context) name = obj_acc.name - account_ids = self.pool.get('account.analytic.account').search(cr, uid, [('parent_id', 'child_of', [data['ref']])]) + account_ids = self.pool.get('account.analytic.account').search(cr, uid, [('parent_id', 'child_of', [data['ref']])], context=context) flag = True for acc in account_ids: @@ -62,12 +63,12 @@ class account_crossovered_analytic(osv.osv_memory): 'ids': [], 'model': 'account.analytic.account', 'form': data - } + } return { 'type': 'ir.actions.report.xml', 'report_name': 'account.analytic.account.crossovered.analytic', 'datas': datas, - } + } account_crossovered_analytic() diff --git a/addons/account_analytic_plans/wizard/analytic_plan_create_model.py b/addons/account_analytic_plans/wizard/analytic_plan_create_model.py index dc108d1700a..777421798cd 100644 --- a/addons/account_analytic_plans/wizard/analytic_plan_create_model.py +++ b/addons/account_analytic_plans/wizard/analytic_plan_create_model.py @@ -18,24 +18,26 @@ # along with this program. If not, see . # ############################################################################## + from osv import osv from tools.translate import _ class analytic_plan_create_model(osv.osv_memory): - _name = 'analytic.plan.create.model' - _description = 'analytic.plan.create.model' + _name = "analytic.plan.create.model" + _description = "analytic.plan.create.model" def activate(self, cr, uid, ids, context=None): plan_obj = self.pool.get('account.analytic.plan.instance') mod_obj = self.pool.get('ir.model.data') + anlytic_plan_obj = self.pool.get('account.analytic.plan') if 'active_id' in context and context['active_id']: plan = plan_obj.browse(cr, uid, context['active_id'], context=context) if (not plan.name) or (not plan.code): raise osv.except_osv(_('Error'), _('Please put a name and a code before saving the model !')) - pids = self.pool.get('account.analytic.plan').search(cr, uid, [], context=context) - if (not pids): + pids = anlytic_plan_obj.search(cr, uid, [], context=context) + if not pids: raise osv.except_osv(_('Error'), _('No analytic plan defined !')) - plan_obj.write(cr, uid, [context['active_id']], {'plan_id':pids[0]}) + plan_obj.write(cr, uid, [context['active_id']], {'plan_id':pids[0]}, context=context) model_data_ids = mod_obj.search(cr, uid, [('model', '=', 'ir.ui.view'),('name', '=', 'view_analytic_plan_create_model')], context=context) resource_id = mod_obj.read(cr, uid, model_data_ids, fields=['res_id'], context=context)[0]['res_id'] From 6b8353e933af1506a2e5521400ba7effc2bd1c82 Mon Sep 17 00:00:00 2001 From: "ARA (OpenERP)" Date: Mon, 11 Oct 2010 16:58:45 +0530 Subject: [PATCH 19/26] [FIX] Fix the account yml warning bzr revid: ara@tinyerp.com-20101011112845-tii4g0uiokjmdp24 --- addons/account/test/account_report.yml | 58 +++++++++++++------------- 1 file changed, 30 insertions(+), 28 deletions(-) diff --git a/addons/account/test/account_report.yml b/addons/account/test/account_report.yml index 7e4295da45b..5bb868cd5d2 100644 --- a/addons/account/test/account_report.yml +++ b/addons/account/test/account_report.yml @@ -1,6 +1,6 @@ - In order to test the PDF reports defined on an invoice, we will print an Invoice Report -- +- !python {model: account.invoice}: | import netsvc, tools, os (data, format) = netsvc.LocalService('report.account.invoice').create(cr, uid, [ref('account.test_invoice_1')], {}, {}) @@ -9,7 +9,7 @@ - In order to test the PDF reports defined on a partner, we will print the Overdue Report -- +- !python {model: res.partner}: | import netsvc, tools, os (data, format) = netsvc.LocalService('report.account.overdue').create(cr, uid, [ref('base.res_partner_asus'),ref('base.res_partner_agrolait'),ref('base.res_partner_c2c')], {}, {}) @@ -18,7 +18,7 @@ - In order to test the PDF reports defined on Account Move, we will print the Voucher Report -- +- !python {model: account.move}: | import netsvc, tools, os (data, format) = netsvc.LocalService('report.account.move.voucher').create(cr, uid, [ref('account.account_move_0')], {}, {}) @@ -32,7 +32,7 @@ name : Tax Code Test - Print Tax Code entries report -- +- !python {model: account.tax.code}: | import netsvc, tools, os (data, format) = netsvc.LocalService('report.account.tax.code.entries').create(cr, uid, [ref('account_tax_code_0')], {}, {}) @@ -51,7 +51,7 @@ - In order to test the PDF reports defined on an invoice, we will print an invoice -- +- !python {model: account.invoice}: | import netsvc, tools, os (data, format) = netsvc.LocalService('report.account.invoice').create(cr, uid, [ref('account.test_invoice_1')], {}, {}) @@ -65,6 +65,8 @@ import netsvc, tools, os, time import datetime from mx.DateTime import * + import warnings + warnings.filterwarnings('ignore',".*struct integer overflow masking is deprecated*") start = datetime.date.fromtimestamp(time.mktime(time.strptime(time.strftime('%Y-%m-%d'), "%Y-%m-%d"))) start = DateTime(int(start.year), int(start.month), int(start.day)) res = {} @@ -84,9 +86,9 @@ ctx['fiscalyear'] = fy_id ctx['journal_ids'] = journal_ids ctx['chart_account_id'] = ref('account.chart0') - + query_line = obj_move._query_get(cr, uid, obj='l', context=ctx) - + data_dict = {'model': 'ir.ui.menu', 'form': {'chart_account_id':ref('account.chart0'),'initial_balance': 1, 'periods': period_list,'journal_ids':journal_ids, 'page_split': 0, 'date_from': time.strftime('%Y-%m-%d'), 'period_length': 30, 'amount_currency': 0,'query_line' : query_line, 'result_selection': 'customer','direction_selection': 'past','fiscalyear_id':fy_id}} data_dict['form'].update(res) (data, format) = netsvc.LocalService('report.account.aged_trial_balance').create(cr, uid, [], data_dict, {}) @@ -122,10 +124,10 @@ (data, format) = netsvc.LocalService('report.account.account.balance').create(cr, uid, [ref('account.bal'),ref('account.gpf')], data_dict, {'periods': []}) if tools.config['test_report_directory']: file(os.path.join(tools.config['test_report_directory'], 'account-account_balance-normal.'+format), 'wb+').write(data) - + data_dict.update({'model': 'ir.ui.menu'}) data_dict['form'].update({'active_ids':[ref('account.bal'),ref('account.gpf')]}) - + (data, format) = netsvc.LocalService('report.account.account.balance').create(cr, uid, [], data_dict, {'periods': []}) if tools.config['test_report_directory']: file(os.path.join(tools.config['test_report_directory'], 'account-account_balance-normal-menu.'+format), 'wb+').write(data) @@ -145,16 +147,16 @@ ctx['fiscalyear'] = fy_id ctx['journal_ids'] = journal_ids ctx['chart_account_id'] = ref('account.chart0') - + query_line = obj_move._query_get(cr, uid, obj='l', context=ctx) data_dict = {'model': 'account.journal.period', 'id':journal_period_ids[0], 'form': {'chart_account_id':ref('account.chart0'),'display_account':'bal_all','filter': 'filter_no','amount_currency': 0,'compare_pattern': 'none','account_choice': 'moves','landscape':0,'period_manner': 'actual','fiscalyear_id': fy_id ,'query_line':query_line,'target_move': 'all','periods': period_list,'journal_ids':journal_ids,'id':ref('account.bal') }} (data, format) = netsvc.LocalService('report.account.central.journal').create(cr, uid, journal_period_ids, data_dict, {}) if tools.config['test_report_directory']: file(os.path.join(tools.config['test_report_directory'], 'account-central_journal.'+format), 'wb+').write(data) - + data_dict.update({'model': 'ir.ui.menu'}) data_dict['form'].update({'active_ids':journal_period_ids}) - + (data, format) = netsvc.LocalService('report.account.central.journal').create(cr, uid, [], data_dict, {}) if tools.config['test_report_directory']: file(os.path.join(tools.config['test_report_directory'], 'account-central_journal-menu.'+format), 'wb+').write(data) @@ -167,13 +169,13 @@ period_list = self.pool.get('account.period').search(cr, uid, [('fiscalyear_id', 'in', [fy_id])], context=context) journal_ids = [ref('account.sales_journal'),ref('account.refund_sales_journal'),ref('account.expenses_journal'),ref('account.refund_expenses_journal'),ref('account.bank_journal'),ref('account.check_journal'),ref('account.cash_journal')] journal_period_ids = self.pool.get('account.journal.period').search(cr, uid, [('journal_id', 'in', journal_ids), ('period_id', 'in', period_list)], context=context) - + obj_move = self.pool.get('account.move.line') ctx = {} ctx['fiscalyear'] = fy_id ctx['journal_ids'] = journal_ids ctx['chart_account_id'] = ref('account.chart0') - + query_line = obj_move._query_get(cr, uid, obj='l', context=ctx) data_dict = {'model': 'ir.ui.menu','id':journal_period_ids[0], 'form': {'chart_account_id':ref('account.chart0'),'display_account':'bal_all','filter': 'filter_no','amount_currency': 0,'compare_pattern': 'none','account_choice': 'moves','landscape':0,'period_manner': 'actual','fiscalyear_id': fy_id ,'query_line':query_line,'target_move': 'all','periods': period_list,'journal_ids':journal_ids, 'active_ids':journal_period_ids}} (data, format) = netsvc.LocalService('report.account.general.journal').create(cr, uid, journal_period_ids, data_dict, {}) @@ -189,15 +191,15 @@ period_list = self.pool.get('account.period').search(cr, uid, [('fiscalyear_id', 'in', [fy_id])], context=context) journal_ids = [ref('account.sales_journal'),ref('account.refund_sales_journal'),ref('account.expenses_journal'),ref('account.refund_expenses_journal'),ref('account.bank_journal'),ref('account.check_journal'),ref('account.cash_journal')] acc_ids = [ref('account.bal'),ref('account.gpf')] - + obj_move = self.pool.get('account.move.line') ctx = {} ctx['fiscalyear'] = fy_id ctx['journal_ids'] = journal_ids ctx['chart_account_id'] = ref('account.chart0') - + query_line = obj_move._query_get(cr, uid, obj='l', context=ctx) - + data_dict = {'model': 'account.account', 'form': {'initial_balance': 1,'initial_bal_query': query_line,'chart_account_id':ref('account.chart0'),'display_account':'bal_all','filter': 'filter_no','sortby': 'sort_date','amount_currency': 0,'landscape':0,'period_manner': 'actual','fiscalyear_id': fy_id ,'query_line':query_line,'target_move': 'all','periods': period_list,'journal_ids':journal_ids,'id':ref('account.bal') }} (data, format) = netsvc.LocalService('report.account.general.ledger').create(cr, uid, acc_ids, data_dict, {}) if tools.config['test_report_directory']: @@ -217,15 +219,15 @@ period_list = self.pool.get('account.period').search(cr, uid, [('fiscalyear_id', 'in', [fy_id])], context=context) journal_ids = [ref('account.sales_journal'),ref('account.refund_sales_journal'),ref('account.expenses_journal'),ref('account.refund_expenses_journal'),ref('account.bank_journal'),ref('account.check_journal'),ref('account.cash_journal')] acc_ids = [ref('account.bal'),ref('account.gpf')] - + obj_move = self.pool.get('account.move.line') ctx = {} ctx['fiscalyear'] = fy_id ctx['journal_ids'] = journal_ids ctx['chart_account_id'] = ref('account.chart0') - + query_line = obj_move._query_get(cr, uid, obj='l', context=ctx) - + data_dict = {'model': 'account.account', 'form': {'initial_balance': 1,'initial_bal_query':query_line,'chart_account_id':ref('account.chart0'),'display_account':'bal_all','filter': 'filter_no','sortby': 'sort_date','amount_currency': 0,'landscape':1,'period_manner': 'actual','fiscalyear_id': fy_id ,'query_line':query_line,'target_move': 'all','periods': period_list,'journal_ids':journal_ids,'id':ref('account.bal') }} (data, format) = netsvc.LocalService('report.account.general.ledger_landscape').create(cr, uid, acc_ids, data_dict, {}) if tools.config['test_report_directory']: @@ -252,17 +254,17 @@ ctx['fiscalyear'] = fy_id ctx['journal_ids'] = journal_ids ctx['chart_account_id'] = ref('account.chart0') - + query_line = obj_move._query_get(cr, uid, obj='l', context=ctx) - + data_dict = {'model': 'account.journal.period', 'id':journal_period_ids[0], 'form': {'sort_selection': 'date','chart_account_id':ref('account.chart0'),'display_account':'bal_all','filter': 'filter_no','amount_currency': 0,'compare_pattern': 'none','account_choice': 'moves','landscape':0,'period_manner': 'actual','fiscalyear_id': fy_id ,'query_line':query_line,'target_move': 'all','periods': period_list,'journal_ids':journal_ids,'id':ref('account.bal') }} (data, format) = netsvc.LocalService('report.account.journal.period.print').create(cr, uid, journal_period_ids, data_dict, {}) if tools.config['test_report_directory']: file(os.path.join(tools.config['test_report_directory'], 'account-print_journal.'+format), 'wb+').write(data) - + data_dict.update({'model': 'ir.ui.menu'}) data_dict['form'].update({'active_ids':journal_period_ids}) - + (data, format) = netsvc.LocalService('report.account.journal.period.print').create(cr, uid, [], data_dict, {}) if tools.config['test_report_directory']: file(os.path.join(tools.config['test_report_directory'], 'account-print_journal-menu.'+format), 'wb+').write(data) @@ -281,7 +283,7 @@ ctx['fiscalyear'] = fy_id ctx['journal_ids'] = journal_ids ctx['chart_account_id'] = ref('account.chart0') - + query_line = obj_move._query_get(cr, uid, obj='l', context=ctx) data_dict = {'model': 'ir.ui.menu', 'form': {'result_selection': 'customer','chart_account_id':ref('account.chart0'),'display_account':'bal_all','filter': 'filter_no','display_type': 0,'journal_ids':journal_ids,'display_partner': 'non-zero_balance','fiscalyear': fy_id ,'target_move': 'all','query_line':query_line}} (data, format) = netsvc.LocalService('report.account.partner.balance').create(cr, uid, [], data_dict, {}) @@ -302,9 +304,9 @@ ctx['fiscalyear'] = fy_id ctx['journal_ids'] = journal_ids ctx['chart_account_id'] = ref('account.chart0') - + query_line = obj_move._query_get(cr, uid, obj='l', context=ctx) - + data_dict = {'model': 'ir.ui.menu', 'form': {'initial_bal_query':query_line,'amount_currency': 0,'reconcil': True,'initial_balance':1,'page_split': True,'result_selection': 'customer','chart_account_id':ref('account.chart0'),'display_account':'bal_all','filter': 'filter_no','display_type': 0,'journal_ids':journal_ids,'display_partner': 'non-zero_balance','fiscalyear': fy_id ,'target_move': 'all','query_line':query_line}} (data, format) = netsvc.LocalService('report.account.third_party_ledger').create(cr, uid, [], data_dict, {}) if tools.config['test_report_directory']: @@ -324,7 +326,7 @@ ctx['fiscalyear'] = fy_id ctx['journal_ids'] = journal_ids ctx['chart_account_id'] = ref('account.chart0') - + query_line = obj_move._query_get(cr, uid, obj='l', context=ctx) data_dict = {'model': 'ir.ui.menu', 'form': {'initial_bal_query':query_line,'amount_currency': 0,'reconcil': True,'initial_balance':1,'page_split': False,'result_selection': 'customer','chart_account_id':ref('account.chart0'),'display_account':'bal_all','filter': 'filter_no','display_type': 0,'journal_ids':journal_ids,'display_partner': 'non-zero_balance','fiscalyear': fy_id ,'target_move': 'all','query_line':query_line}} (data, format) = netsvc.LocalService('report.account.third_party_ledger_other').create(cr, uid, [], data_dict, {}) From affab14974d28c1da6b672bb924114f9e9c3fb9d Mon Sep 17 00:00:00 2001 From: vth Date: Mon, 11 Oct 2010 18:08:01 +0530 Subject: [PATCH 20/26] [IMP] account payment : For make payment , method directly called from the account_payment.py instead of wizard bzr revid: vth@tinyerp.com-20101011123801-x0oqn20p5azfxkxs --- addons/account_payment/account_payment.py | 14 ++++++-------- addons/account_payment/account_payment_view.xml | 5 ++--- .../account_payment/account_payment_workflow.xml | 8 +++++--- 3 files changed, 13 insertions(+), 14 deletions(-) diff --git a/addons/account_payment/account_payment.py b/addons/account_payment/account_payment.py index e4a121fb03e..a70e8fb75c3 100644 --- a/addons/account_payment/account_payment.py +++ b/addons/account_payment/account_payment.py @@ -18,6 +18,7 @@ # along with this program. If not, see . # ############################################################################## + import time from osv import osv, fields @@ -118,11 +119,10 @@ class payment_order(osv.osv): self.write(cr, uid, order['id'],{'reference':reference}) return True - def set_done(self, cr, uid, id, *args): - self.write(cr,uid,id,{'date_done': time.strftime('%Y-%m-%d'), - 'state': 'done',}) + def set_done(self, cr, uid, ids, *args): wf_service = netsvc.LocalService("workflow") - wf_service.trg_validate(uid, 'payment.order', id, 'done', cr) + self.write(cr, uid, ids, {'date_done': time.strftime('%Y-%m-%d')}) + wf_service.trg_validate(uid, 'payment.order', ids[0], 'done', cr) return True def copy(self, cr, uid, id, default={}, context=None): @@ -162,7 +162,6 @@ class payment_line(osv.osv): _name = 'payment.line' _description = 'Payment Line' - def translate(self, orig): return { "due_date": "date_maturity", @@ -337,7 +336,7 @@ class payment_line(osv.osv): _defaults = { 'name': lambda obj, cursor, user, context: obj.pool.get('ir.sequence' ).get(cursor, user, 'payment.line'), - 'state': lambda *args: 'normal', + 'state': 'normal', 'currency': _get_currency, 'company_currency': _get_currency, 'date': _get_date, @@ -438,5 +437,4 @@ class payment_line(osv.osv): payment_line() -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: - +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file diff --git a/addons/account_payment/account_payment_view.xml b/addons/account_payment/account_payment_view.xml index e9238ec62f9..01c8965f9a4 100644 --- a/addons/account_payment/account_payment_view.xml +++ b/addons/account_payment/account_payment_view.xml @@ -142,7 +142,7 @@