openerp-dev-web team mailing list archive
-
openerp-dev-web team
-
Mailing list archive
-
Message #01233
[Merge] lp:~openerp-commiter/openobject-addons/trunk-dev-addons3-psi into lp:~openerp-dev/openobject-addons/trunk-dev-addons3
psi (OpenERP) has proposed merging lp:~openerp-commiter/openobject-addons/trunk-dev-addons3-psi into lp:~openerp-dev/openobject-addons/trunk-dev-addons3.
Requested reviews:
OpenERP R&D Team (openerp-dev)
Related bugs:
#568537 The __compute method of account_account needs optmization to improve Accounting Performance!
https://bugs.launchpad.net/bugs/568537
#662538 account - account_move_lines for payables and receivables must have partner_id - missing check
https://bugs.launchpad.net/bugs/662538
#665326 Multi_company : Journal entry missing for company OpenERP IN.
https://bugs.launchpad.net/bugs/665326
#667619 Export po file from OpenERP, Accounting reports does not translated.
https://bugs.launchpad.net/bugs/667619
Hello sir,
Here i am proposing optimized code of __compute method to imporve Accounting Performance.
Thanks
PSI
--
https://code.launchpad.net/~openerp-commiter/openobject-addons/trunk-dev-addons3-psi/+merge/43512
Your team OpenERP R&D Team is requested to review the proposed merge of lp:~openerp-commiter/openobject-addons/trunk-dev-addons3-psi into lp:~openerp-dev/openobject-addons/trunk-dev-addons3.
=== modified file 'account/account.py'
--- account/account.py 2010-12-09 06:07:11 +0000
+++ account/account.py 2010-12-13 12:49:56 +0000
@@ -289,20 +289,20 @@
sums = {}
while brs:
current = brs[0]
- can_compute = True
- for child in current.child_id:
- if child.id not in sums:
- can_compute = False
- try:
- brs.insert(0, brs.pop(brs.index(child)))
- except ValueError:
- brs.insert(0, child)
- if can_compute:
- brs.pop(0)
- for fn in field_names:
- sums.setdefault(current.id, {})[fn] = accounts.get(current.id, {}).get(fn, 0.0)
- if current.child_id:
- sums[current.id][fn] += sum(sums[child.id][fn] for child in current.child_id)
+# can_compute = True
+# for child in current.child_id:
+# if child.id not in sums:
+# can_compute = False
+# try:
+# brs.insert(0, brs.pop(brs.index(child)))
+# except ValueError:
+# brs.insert(0, child)
+# if can_compute:
+ brs.pop(0)
+ for fn in field_names:
+ sums.setdefault(current.id, {})[fn] = accounts.get(current.id, {}).get(fn, 0.0)
+ if current.child_id:
+ sums[current.id][fn] += sum(sums[child.id][fn] for child in current.child_id)
res = {}
null_result = dict((fn, 0.0) for fn in field_names)
for id in ids:
=== modified file 'account/invoice.py'
--- account/invoice.py 2010-12-10 12:13:27 +0000
+++ account/invoice.py 2010-12-13 12:49:56 +0000
@@ -1312,7 +1312,6 @@
if context is None:
context = {}
company_id = context.get('company_id',False)
- tax_obj = self.pool.get('account.tax')
if not partner_id:
raise osv.except_osv(_('No Partner Defined !'),_("You must first select a partner !") )
if not product:
@@ -1401,24 +1400,17 @@
if a:
result['account_id'] = a
- tax_ids = tax_obj.search(cr, uid, [('company_id', '=', company_id)])
if type in ('out_invoice', 'out_refund'):
- sale_taxes_def = map(lambda x: x.id, res.taxes_id)
- sale_tax_ids = [tax for tax in tax_ids if tax in sale_taxes_def]
- sale_taxes = tax_obj.browse(cr, uid, sale_tax_ids)
- sale_taxes_all = sale_taxes and sale_taxes or (a and self.pool.get('account.account').browse(cr, uid, a).tax_ids or False)
- tax_id = fpos_obj.map_tax(cr, uid, fpos, sale_taxes_all)
+ taxes = res.taxes_id and res.taxes_id or (a and self.pool.get('account.account').browse(cr, uid, a).tax_ids or False)
+ tax_id = fpos_obj.map_tax(cr, uid, fpos, taxes)
else:
- pur_taxes_def = map(lambda x: x.id, res.supplier_taxes_id)
- pur_tax_ids = [tax for tax in tax_ids if tax in pur_taxes_def]
- pur_taxes = tax_obj.browse(cr, uid, pur_tax_ids)
- pur_taxes_all = pur_taxes and pur_taxes or (a and self.pool.get('account.account').browse(cr, uid, a).tax_ids or False)
- tax_id = fpos_obj.map_tax(cr, uid, fpos, pur_taxes_all)
-
+ taxes = res.supplier_taxes_id and res.supplier_taxes_id or (a and self.pool.get('account.account').browse(cr, uid, a).tax_ids or False)
+ tax_id = fpos_obj.map_tax(cr, uid, fpos, taxes)
if type in ('in_invoice', 'in_refund'):
result.update( {'price_unit': price_unit or res.standard_price,'invoice_line_tax_id': tax_id} )
else:
result.update({'price_unit': res.list_price, 'invoice_line_tax_id': tax_id})
+
# if not name:
result['name'] = res.partner_ref
=== modified file 'account_voucher/account_voucher.py'
--- account_voucher/account_voucher.py 2010-12-10 05:27:57 +0000
+++ account_voucher/account_voucher.py 2010-12-13 12:49:56 +0000
@@ -159,6 +159,27 @@
res[voucher.id] = abs(voucher.amount - abs(credit - debit))
return res
+ def _compute_lines(self, cr, uid, ids, name, args, context=None):
+ result = {}
+ for invoice in self.browse(cr, uid, ids, context):
+ src = []
+ lines = []
+ if invoice.move_id:
+ for m in invoice.move_id.line_id:
+ temp_lines = []
+ if m.reconcile_id:
+ temp_lines = map(lambda x: x.id, m.reconcile_id.line_id)
+ elif m.reconcile_partial_id:
+ temp_lines = map(lambda x: x.id, m.reconcile_partial_id.line_partial_ids)
+ else:
+ temp_lines = map(lambda x: x.id, m.move_id.line_id)
+ lines += [x for x in temp_lines if x not in lines]
+ src.append(m.id)
+ if context.get('type', 'sale') in ('receipt', 'payment'):
+ lines = filter(lambda x: x not in src, lines)
+ result[invoice.id] = lines
+ return result
+
_name = 'account.voucher'
_description = 'Accounting Voucher'
_order = "date desc, id desc"
@@ -199,7 +220,7 @@
'reference': fields.char('Ref #', size=64, readonly=True, states={'draft':[('readonly',False)]}, help="Transaction reference number."),
'number': fields.char('Number', size=32, readonly=True,),
'move_id':fields.many2one('account.move', 'Account Entry'),
- 'move_ids': fields.related('move_id','line_id', type='one2many', relation='account.move.line', string='Journal Items', readonly=True),
+ 'move_ids': fields.function(_compute_lines, method=True, relation='account.move.line', type="one2many", string='Journal Items'),
'partner_id':fields.many2one('res.partner', 'Partner', change_default=1, readonly=True, states={'draft':[('readonly',False)]}),
'audit': fields.related('move_id','to_check', type='boolean', relation='account.move', string='Audit Complete ?'),
'pay_now':fields.selection([
@@ -212,12 +233,14 @@
'payment_option':fields.selection([
('without_writeoff', 'Without Write-off'),
('with_writeoff', 'With Write-off'),
- ], 'Payment Option', required=True, readonly=True, states={'draft': [('readonly', False)]}),
- 'writeoff_acc_id': fields.many2one('account.account', 'Write-Off account', readonly=True, states={'draft': [('readonly', False)]}),
- 'writeoff_journal_id': fields.many2one('account.journal', 'Write-Off journal', readonly=True, states={'draft': [('readonly', False)]}),
+ ], 'Payment Option', required=True, readonly=True, states={'draft': [('readonly', False)]},
+ help=' * Select \'Without Write-off\' for partial reconciliation of the voucher. \
+ \n* Select \'With Write-off\' for full reconciliation of the voucher with write-off amount.'),
+ 'writeoff_acc_id': fields.many2one('account.account', 'Write-Off account', readonly=True, states={'draft': [('readonly', False)]}, help='This account will be used for write-off entries'),
+ 'writeoff_journal_id': fields.many2one('account.journal', 'Write-Off journal', readonly=True, states={'draft': [('readonly', False)]}, help='This journal will be used for write-off entries'),
'comment': fields.char('Comment', size=64, readonly=True, states={'draft': [('readonly', False)]}),
'analytic_id': fields.many2one('account.analytic.account','Analytic Account', readonly=True, states={'draft': [('readonly', False)]}),
- 'writeoff_amount': fields.function(_get_writeoff_amount, method=True, string='Writeoff Amount', type='float', readonly=True),
+ 'writeoff_amount': fields.function(_get_writeoff_amount, method=True, string='Writeoff Amount', type='float', readonly=True, help='Total write-off amount.'),
}
_defaults = {
'period_id': _get_period,
Follow ups