From ec8823d2d3dc248bbaabca002a78b4dfa014b86d Mon Sep 17 00:00:00 2001 From: "psi (Open ERP)" Date: Mon, 17 Jan 2011 16:50:56 +0530 Subject: [PATCH] [FIX] account, account_*, hr_*, point_of_sale, sale: performance issues - account_move_lines and others lp bug: https://launchpad.net/bugs/693833 fixed bzr revid: psi@tinyerp.co.in-20110117112056-ryw0wyjltqzeuhzt --- addons/account/account.py | 2 +- addons/account/account_move_line.py | 6 ++--- addons/account/invoice.py | 4 ++-- addons/account_followup/account_followup.py | 2 +- addons/account_voucher/account_voucher.py | 4 ++-- addons/analytic/analytic.py | 14 +++++------ addons/hr_evaluation/hr_evaluation.py | 4 ++-- addons/hr_expense/hr_expense.py | 6 ++--- addons/hr_recruitment/hr_recruitment.py | 6 ++--- .../hr_timesheet_sheet/hr_timesheet_sheet.py | 2 +- addons/point_of_sale/point_of_sale.py | 24 +++++++++---------- addons/sale/sale.py | 8 +++---- 12 files changed, 41 insertions(+), 41 deletions(-) diff --git a/addons/account/account.py b/addons/account/account.py index 166d475fcba..ba53475bb30 100644 --- a/addons/account/account.py +++ b/addons/account/account.py @@ -1130,7 +1130,7 @@ class account_move(osv.osv): 'to_check': fields.boolean('To Review', help='Check this box if you are unsure of that journal entry and if you want to note it as \'to be reviewed\' by an accounting expert.'), 'partner_id': fields.related('line_id', 'partner_id', type="many2one", relation="res.partner", string="Partner", store=True), 'amount': fields.function(_amount_compute, method=True, string='Amount', digits_compute=dp.get_precision('Account'), type='float', fnct_search=_search_amount), - 'date': fields.date('Date', required=True, states={'posted':[('readonly',True)]}), + 'date': fields.date('Date', required=True, states={'posted':[('readonly',True)]}, select=True), 'narration':fields.text('Narration'), 'company_id': fields.related('journal_id','company_id',type='many2one',relation='res.company',string='Company', store=True, readonly=True), } diff --git a/addons/account/account_move_line.py b/addons/account/account_move_line.py index e232be457f0..645cacd6994 100644 --- a/addons/account/account_move_line.py +++ b/addons/account/account_move_line.py @@ -494,12 +494,12 @@ class account_move_line(osv.osv): 'journal_id': fields.many2one('account.journal', 'Journal', required=True, select=1), 'blocked': fields.boolean('Litigation', help="You can check this box to mark this journal item as a litigation with the associated partner"), 'partner_id': fields.many2one('res.partner', 'Partner', select=1, ondelete='restrict'), - 'date_maturity': fields.date('Due date', help="This field is used for payable and receivable journal entries. You can put the limit date for the payment of this line."), - 'date': fields.related('move_id','date', string='Effective date', type='date', required=True, + 'date_maturity': fields.date('Due date', select=True ,help="This field is used for payable and receivable journal entries. You can put the limit date for the payment of this line."), + 'date': fields.related('move_id','date', string='Effective date', type='date', required=True, select=True, store = { 'account.move': (_get_move_lines, ['date'], 20) }), - 'date_created': fields.date('Creation date'), + 'date_created': fields.date('Creation date', select=True), 'analytic_lines': fields.one2many('account.analytic.line', 'move_id', 'Analytic lines'), 'centralisation': fields.selection([('normal','Normal'),('credit','Credit Centralisation'),('debit','Debit Centralisation')], 'Centralisation', size=6), 'balance': fields.function(_balance, fnct_search=_balance_search, method=True, string='Balance'), diff --git a/addons/account/invoice.py b/addons/account/invoice.py index 78b3322bbf4..4ca3d094593 100644 --- a/addons/account/invoice.py +++ b/addons/account/invoice.py @@ -211,8 +211,8 @@ class account_invoice(osv.osv): \n* The \'Open\' state is used when user create invoice,a invoice number is generated.Its in open state till user does not pay invoice. \ \n* The \'Paid\' state is set automatically when invoice is paid.\ \n* The \'Cancelled\' state is used when user cancel invoice.'), - 'date_invoice': fields.date('Invoice Date', states={'paid':[('readonly',True)], 'open':[('readonly',True)], 'close':[('readonly',True)]}, help="Keep empty to use the current date"), - 'date_due': fields.date('Due Date', states={'paid':[('readonly',True)], 'open':[('readonly',True)], 'close':[('readonly',True)]}, + 'date_invoice': fields.date('Invoice Date', states={'paid':[('readonly',True)], 'open':[('readonly',True)], 'close':[('readonly',True)]}, select=True, help="Keep empty to use the current date", select=True), + 'date_due': fields.date('Due Date', states={'paid':[('readonly',True)], 'open':[('readonly',True)], 'close':[('readonly',True)]}, select=True, help="If you use payment terms, the due date will be computed automatically at the generation "\ "of accounting entries. If you keep the payment term and the due date empty, it means direct payment. The payment term may compute several due dates, for example 50% now, 50% in one month."), 'partner_id': fields.many2one('res.partner', 'Partner', change_default=True, readonly=True, required=True, states={'draft':[('readonly',False)]}), diff --git a/addons/account_followup/account_followup.py b/addons/account_followup/account_followup.py index 5bbfe80cc24..c798c703f37 100644 --- a/addons/account_followup/account_followup.py +++ b/addons/account_followup/account_followup.py @@ -54,7 +54,7 @@ class account_move_line(osv.osv): _inherit = 'account.move.line' _columns = { 'followup_line_id': fields.many2one('account_followup.followup.line', 'Follow-up Level'), - 'followup_date': fields.date('Latest Follow-up'), + 'followup_date': fields.date('Latest Follow-up', select=True), } account_move_line() diff --git a/addons/account_voucher/account_voucher.py b/addons/account_voucher/account_voucher.py index 66be989b22c..6c6f2865ceb 100644 --- a/addons/account_voucher/account_voucher.py +++ b/addons/account_voucher/account_voucher.py @@ -181,7 +181,7 @@ class account_voucher(osv.osv): ('receipt','Receipt'), ],'Default Type', readonly=True, states={'draft':[('readonly',False)]}), 'name':fields.char('Memo', size=256, readonly=True, states={'draft':[('readonly',False)]}), - 'date':fields.date('Date', readonly=True, states={'draft':[('readonly',False)]}, help="Effective date for accounting entries"), + 'date':fields.date('Date', readonly=True, select=True, states={'draft':[('readonly',False)]}, help="Effective date for accounting entries"), 'journal_id':fields.many2one('account.journal', 'Journal', required=True, readonly=True, states={'draft':[('readonly',False)]}), 'account_id':fields.many2one('account.account', 'Account', required=True, readonly=True, states={'draft':[('readonly',False)]}), 'line_ids':fields.one2many('account.voucher.line','voucher_id','Voucher Lines', readonly=True, states={'draft':[('readonly',False)]}), @@ -218,7 +218,7 @@ class account_voucher(osv.osv): ],'Payment', select=True, readonly=True, states={'draft':[('readonly',False)]}), 'tax_id':fields.many2one('account.tax', 'Tax', readonly=True, states={'draft':[('readonly',False)]}), 'pre_line':fields.boolean('Previous Payments ?', required=False), - 'date_due': fields.date('Due Date', readonly=True, states={'draft':[('readonly',False)]}), + 'date_due': fields.date('Due Date', readonly=True, select=True, states={'draft':[('readonly',False)]}), 'payment_option':fields.selection([ ('without_writeoff', 'Keep Open'), ('with_writeoff', 'Reconcile with Write-Off'), diff --git a/addons/analytic/analytic.py b/addons/analytic/analytic.py index 03e9a9608cd..a353ca92177 100644 --- a/addons/analytic/analytic.py +++ b/addons/analytic/analytic.py @@ -60,7 +60,7 @@ class account_analytic_account(osv.osv): return res where_date = '' - where_clause_args = [tuple(child_ids)] + where_clause_args = [tuple(child_ids)] if context.get('from_date', False): where_date += " AND l.date >= %s" where_clause_args += [context['from_date']] @@ -71,20 +71,20 @@ class account_analytic_account(osv.osv): SELECT a.id, sum( CASE WHEN l.amount > 0 - THEN l.amount + THEN l.amount ELSE 0.0 END ) as debit, sum( CASE WHEN l.amount < 0 THEN -l.amount - ELSE 0.0 + ELSE 0.0 END ) as credit, COALESCE(SUM(l.amount),0) AS balance, COALESCE(SUM(l.unit_amount),0) AS quantity - FROM account_analytic_account a - LEFT JOIN account_analytic_line l ON (a.id = l.account_id) + FROM account_analytic_account a + LEFT JOIN account_analytic_line l ON (a.id = l.account_id) WHERE a.id IN %s """ + where_date + """ GROUP BY a.id""", where_clause_args) @@ -128,7 +128,7 @@ class account_analytic_account(osv.osv): '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'), + 'date': fields.date('Date End', select=True), 'company_id': fields.many2one('res.company', 'Company', required=False), #not required because we want to allow different companies to use the same chart of account, except for leaf accounts. 'state': fields.selection([('draft','Draft'),('open','Open'), ('pending','Pending'),('cancelled', 'Cancelled'),('close','Closed'),('template', 'Template')], 'State', required=True, help='* When an account is created its in \'Draft\' state.\ @@ -230,7 +230,7 @@ class account_analytic_line(osv.osv): _columns = { 'name': fields.char('Description', size=256, required=True), - 'date': fields.date('Date', required=True, select=1), + 'date': fields.date('Date', required=True, select=True), '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, domain=[('type','<>','view')]), diff --git a/addons/hr_evaluation/hr_evaluation.py b/addons/hr_evaluation/hr_evaluation.py index b04bef02e17..4a9a46920f5 100644 --- a/addons/hr_evaluation/hr_evaluation.py +++ b/addons/hr_evaluation/hr_evaluation.py @@ -143,7 +143,7 @@ class hr_evaluation(osv.osv): _description = "Employee Evaluation" _rec_name = 'employee_id' _columns = { - 'date': fields.date("Evaluation Deadline", required=True), + 'date': fields.date("Evaluation Deadline", required=True, select=True), 'employee_id': fields.many2one('hr.employee', "Employee", required=True), 'note_summary': fields.text('Evaluation Summary'), 'note_action': fields.text('Action Plan', @@ -165,7 +165,7 @@ class hr_evaluation(osv.osv): ('done','Done'), ('cancel','Cancelled'), ], 'State', required=True, readonly=True), - 'date_close': fields.date('Ending Date'), + 'date_close': fields.date('Ending Date', select=True), 'progress': fields.float("Progress"), } _defaults = { diff --git a/addons/hr_expense/hr_expense.py b/addons/hr_expense/hr_expense.py index e7fd63eadb4..9cb53f81dce 100644 --- a/addons/hr_expense/hr_expense.py +++ b/addons/hr_expense/hr_expense.py @@ -60,12 +60,12 @@ class hr_expense_expense(osv.osv): 'name': fields.char('Description', size=128, required=True), 'id': fields.integer('Sheet ID', readonly=True), 'ref': fields.char('Reference', size=32), - 'date': fields.date('Date'), + 'date': fields.date('Date', select=True), 'journal_id': fields.many2one('account.journal', 'Force Journal', help = "The journal used when the expense is invoiced"), 'employee_id': fields.many2one('hr.employee', "Employee", required=True), 'user_id': fields.many2one('res.users', 'User', required=True), - 'date_confirm': fields.date('Confirmation Date', help = "Date of the confirmation of the sheet expense. It's filled when the button Confirm is pressed."), - 'date_valid': fields.date('Validation Date', help = "Date of the acceptation of the sheet expense. It's filled when the button Accept is pressed."), + 'date_confirm': fields.date('Confirmation Date', select=True, help = "Date of the confirmation of the sheet expense. It's filled when the button Confirm is pressed."), + 'date_valid': fields.date('Validation Date', select=True, help = "Date of the acceptation of the sheet expense. It's filled when the button Accept is pressed."), 'user_valid': fields.many2one('res.users', 'Validation User'), 'account_move_id': fields.many2one('account.move', 'Ledger Posting'), 'line_ids': fields.one2many('hr.expense.line', 'expense_id', 'Expense Lines', readonly=True, states={'draft':[('readonly',False)]} ), diff --git a/addons/hr_recruitment/hr_recruitment.py b/addons/hr_recruitment/hr_recruitment.py index 7aebc3ef268..02643a3e90e 100644 --- a/addons/hr_recruitment/hr_recruitment.py +++ b/addons/hr_recruitment/hr_recruitment.py @@ -126,7 +126,7 @@ class hr_applicant(crm.crm_case, osv.osv): 'partner_id': fields.many2one('res.partner', 'Partner'), 'partner_address_id': fields.many2one('res.partner.address', 'Partner Contact', \ domain="[('partner_id','=',partner_id)]"), - 'create_date': fields.datetime('Creation Date', readonly=True), + 'create_date': fields.datetime('Creation Date', readonly=True, select=True), 'write_date': fields.datetime('Update Date', readonly=True), 'stage_id': fields.many2one ('hr.recruitment.stage', 'Stage'), 'state': fields.selection(AVAILABLE_STATES, 'State', size=16, readonly=True, @@ -137,8 +137,8 @@ class hr_applicant(crm.crm_case, osv.osv): 'company_id': fields.many2one('res.company', 'Company'), 'user_id': fields.many2one('res.users', 'Responsible'), # Applicant Columns - 'date_closed': fields.datetime('Closed', readonly=True), - 'date_open': fields.datetime('Opened', readonly=True), + 'date_closed': fields.datetime('Closed', readonly=True, select=True), + 'date_open': fields.datetime('Opened', readonly=True, select=True), 'date': fields.datetime('Date'), 'date_action': fields.date('Next Action Date'), 'title_action': fields.char('Next Action', size=64), diff --git a/addons/hr_timesheet_sheet/hr_timesheet_sheet.py b/addons/hr_timesheet_sheet/hr_timesheet_sheet.py index 85795b352f1..3a4c4e5e29d 100644 --- a/addons/hr_timesheet_sheet/hr_timesheet_sheet.py +++ b/addons/hr_timesheet_sheet/hr_timesheet_sheet.py @@ -262,7 +262,7 @@ class hr_timesheet_sheet(osv.osv): 'user_id': fields.related('employee_id', 'user_id', type="many2one", relation="res.users", store=True, string="User", required=False, readonly=True),#fields.many2one('res.users', 'User', required=True, select=1, states={'confirm':[('readonly', True)], 'done':[('readonly', True)]}), 'date_from': fields.date('Date from', required=True, select=1, readonly=True, states={'new':[('readonly', False)]}), 'date_to': fields.date('Date to', required=True, select=1, readonly=True, states={'new':[('readonly', False)]}), - 'date_current': fields.date('Current date', required=True), + 'date_current': fields.date('Current date', required=True, select=1), 'timesheet_ids' : one2many_mod('hr.analytic.timesheet', 'sheet_id', 'Timesheet lines', domain=[('date', '=', time.strftime('%Y-%m-%d'))], readonly=True, states={ diff --git a/addons/point_of_sale/point_of_sale.py b/addons/point_of_sale/point_of_sale.py index f359b8208d7..1db9ebbe26b 100644 --- a/addons/point_of_sale/point_of_sale.py +++ b/addons/point_of_sale/point_of_sale.py @@ -33,7 +33,7 @@ class pos_config_journal(osv.osv): """ Point of Sale journal configuration""" _name = 'pos.config.journal' _description = "Journal Configuration" - + _columns = { 'name': fields.char('Description', size=64), 'code': fields.char('Code', size=64), @@ -46,7 +46,7 @@ pos_config_journal() class pos_company_discount(osv.osv): """ Company Discount and Cashboxes """ _inherit = 'res.company' - + _columns = { 'company_discount': fields.float('Max Discount(%)', digits_compute=dp.get_precision('Point Of Sale')), 'max_diff': fields.float('Max Difference for Cashboxes', digits_compute=dp.get_precision('Point Of Sale Discount')), @@ -247,14 +247,14 @@ class pos_order(osv.osv): 'num_sale': fields.char('Internal Note', size=64), 'shop_id': fields.many2one('sale.shop', 'Shop', required=True, states={'draft': [('readonly', False)]}, readonly=True), - 'date_order': fields.datetime('Date Ordered', readonly=True), + 'date_order': fields.datetime('Date Ordered', readonly=True, select=True), 'date_validation': fields.function(_get_date_payment, method=True, string='Validation Date', - type='date', store=True), + type='date', select=True, store=True), 'date_payment': fields.function(_get_date_payment2, method=True, string='Payment Date', - type='date', store=True), + type='date', select=True, store=True), 'date_validity': fields.date('Validity Date', required=True), 'user_id': fields.many2one('res.users', 'Connected Salesman', help="Person who uses the the cash register. It could be a reliever, a student or an interim employee."), 'user_salesman_id': fields.many2one('res.users', 'Cashier', required=True, help="User who is logged into the system."), @@ -329,7 +329,7 @@ class pos_order(osv.osv): def test_order_lines(self, cr, uid, order, context=None): - """ Test order line is created or not for the order + """ Test order line is created or not for the order @param name: Names of fields. @return: True """ @@ -570,9 +570,9 @@ class pos_order(osv.osv): return statement_id def add_product(self, cr, uid, order_id, product_id, qty, context=None): - + """Create a new order line the order""" - + line_obj = self.pool.get('pos.order.line') values = self.read(cr, uid, order_id, ['partner_id', 'pricelist_id']) @@ -593,9 +593,9 @@ class pos_order(osv.osv): return order_line_id, price def refund(self, cr, uid, ids, context=None): - + """Create a copy of order for refund order""" - + clone_list = [] line_obj = self.pool.get('pos.order.line') @@ -620,9 +620,9 @@ class pos_order(osv.osv): return clone_list def action_invoice(self, cr, uid, ids, context=None): - + """Create a invoice of order """ - + inv_ref = self.pool.get('account.invoice') inv_line_ref = self.pool.get('account.invoice.line') product_obj = self.pool.get('product.product') diff --git a/addons/sale/sale.py b/addons/sale/sale.py index 3ed49f44b74..b0c7e1484b2 100644 --- a/addons/sale/sale.py +++ b/addons/sale/sale.py @@ -185,7 +185,7 @@ class sale_order(osv.osv): for line in self.pool.get('sale.order.line').browse(cr, uid, ids, context=context): result[line.order_id.id] = True return result.keys() - + _columns = { 'name': fields.char('Order Reference', size=64, required=True, readonly=True, states={'draft': [('readonly', False)]}, select=True), @@ -202,9 +202,9 @@ class sale_order(osv.osv): ('done', 'Done'), ('cancel', 'Cancelled') ], 'Order State', readonly=True, help="Gives the state of the quotation or sales order. \nThe exception state is automatically set when a cancel operation occurs in the invoice validation (Invoice Exception) or in the picking list process (Shipping Exception). \nThe 'Waiting Schedule' state is set when the invoice is confirmed but waiting for the scheduler to run on the date 'Ordered Date'.", select=True), - 'date_order': fields.date('Ordered Date', required=True, readonly=True, states={'draft': [('readonly', False)]}), - 'create_date': fields.date('Creation Date', readonly=True, help="Date on which sales order is created."), - 'date_confirm': fields.date('Confirmation Date', readonly=True, help="Date on which sales order is confirmed."), + 'date_order': fields.date('Ordered Date', required=True, readonly=True, select=True, states={'draft': [('readonly', False)]}), + 'create_date': fields.date('Creation Date', readonly=True, select=True, help="Date on which sales order is created."), + 'date_confirm': fields.date('Confirmation Date', readonly=True, select=True, help="Date on which sales order is confirmed."), 'user_id': fields.many2one('res.users', 'Salesman', states={'draft': [('readonly', False)]}, select=True), 'partner_id': fields.many2one('res.partner', 'Customer', readonly=True, states={'draft': [('readonly', False)]}, required=True, change_default=True, select=True), 'partner_invoice_id': fields.many2one('res.partner.address', 'Invoice Address', readonly=True, required=True, states={'draft': [('readonly', False)]}, help="Invoice address for current sales order."),