[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
This commit is contained in:
psi (Open ERP) 2011-01-17 16:50:56 +05:30
parent de9b76381c
commit ec8823d2d3
12 changed files with 41 additions and 41 deletions

View File

@ -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.'), '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), '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), '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'), 'narration':fields.text('Narration'),
'company_id': fields.related('journal_id','company_id',type='many2one',relation='res.company',string='Company', store=True, readonly=True), 'company_id': fields.related('journal_id','company_id',type='many2one',relation='res.company',string='Company', store=True, readonly=True),
} }

View File

@ -494,12 +494,12 @@ class account_move_line(osv.osv):
'journal_id': fields.many2one('account.journal', 'Journal', required=True, select=1), '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"), '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'), '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_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, 'date': fields.related('move_id','date', string='Effective date', type='date', required=True, select=True,
store = { store = {
'account.move': (_get_move_lines, ['date'], 20) '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'), '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), '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'), 'balance': fields.function(_balance, fnct_search=_balance_search, method=True, string='Balance'),

View File

@ -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 \'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 \'Paid\' state is set automatically when invoice is paid.\
\n* The \'Cancelled\' state is used when user cancel invoice.'), \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_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)]}, '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 "\ 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."), "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)]}), 'partner_id': fields.many2one('res.partner', 'Partner', change_default=True, readonly=True, required=True, states={'draft':[('readonly',False)]}),

View File

@ -54,7 +54,7 @@ class account_move_line(osv.osv):
_inherit = 'account.move.line' _inherit = 'account.move.line'
_columns = { _columns = {
'followup_line_id': fields.many2one('account_followup.followup.line', 'Follow-up Level'), '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() account_move_line()

View File

@ -181,7 +181,7 @@ class account_voucher(osv.osv):
('receipt','Receipt'), ('receipt','Receipt'),
],'Default Type', readonly=True, states={'draft':[('readonly',False)]}), ],'Default Type', readonly=True, states={'draft':[('readonly',False)]}),
'name':fields.char('Memo', size=256, 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)]}), '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)]}), '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)]}), '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)]}), ],'Payment', select=True, readonly=True, states={'draft':[('readonly',False)]}),
'tax_id':fields.many2one('account.tax', 'Tax', 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), '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([ 'payment_option':fields.selection([
('without_writeoff', 'Keep Open'), ('without_writeoff', 'Keep Open'),
('with_writeoff', 'Reconcile with Write-Off'), ('with_writeoff', 'Reconcile with Write-Off'),

View File

@ -60,7 +60,7 @@ class account_analytic_account(osv.osv):
return res return res
where_date = '' where_date = ''
where_clause_args = [tuple(child_ids)] where_clause_args = [tuple(child_ids)]
if context.get('from_date', False): if context.get('from_date', False):
where_date += " AND l.date >= %s" where_date += " AND l.date >= %s"
where_clause_args += [context['from_date']] where_clause_args += [context['from_date']]
@ -71,20 +71,20 @@ class account_analytic_account(osv.osv):
SELECT a.id, SELECT a.id,
sum( sum(
CASE WHEN l.amount > 0 CASE WHEN l.amount > 0
THEN l.amount THEN l.amount
ELSE 0.0 ELSE 0.0
END END
) as debit, ) as debit,
sum( sum(
CASE WHEN l.amount < 0 CASE WHEN l.amount < 0
THEN -l.amount THEN -l.amount
ELSE 0.0 ELSE 0.0
END END
) as credit, ) as credit,
COALESCE(SUM(l.amount),0) AS balance, COALESCE(SUM(l.amount),0) AS balance,
COALESCE(SUM(l.unit_amount),0) AS quantity COALESCE(SUM(l.unit_amount),0) AS quantity
FROM account_analytic_account a FROM account_analytic_account a
LEFT JOIN account_analytic_line l ON (a.id = l.account_id) LEFT JOIN account_analytic_line l ON (a.id = l.account_id)
WHERE a.id IN %s WHERE a.id IN %s
""" + where_date + """ """ + where_date + """
GROUP BY a.id""", where_clause_args) 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'), 'contact_id': fields.many2one('res.partner.address', 'Contact'),
'user_id': fields.many2one('res.users', 'Account Manager'), 'user_id': fields.many2one('res.users', 'Account Manager'),
'date_start': fields.date('Date Start'), '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. '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, '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.\ help='* When an account is created its in \'Draft\' state.\
@ -230,7 +230,7 @@ class account_analytic_line(osv.osv):
_columns = { _columns = {
'name': fields.char('Description', size=256, required=True), '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')), '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.'), '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')]), 'account_id': fields.many2one('account.analytic.account', 'Analytic Account', required=True, ondelete='cascade', select=True, domain=[('type','<>','view')]),

View File

@ -143,7 +143,7 @@ class hr_evaluation(osv.osv):
_description = "Employee Evaluation" _description = "Employee Evaluation"
_rec_name = 'employee_id' _rec_name = 'employee_id'
_columns = { _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), 'employee_id': fields.many2one('hr.employee', "Employee", required=True),
'note_summary': fields.text('Evaluation Summary'), 'note_summary': fields.text('Evaluation Summary'),
'note_action': fields.text('Action Plan', 'note_action': fields.text('Action Plan',
@ -165,7 +165,7 @@ class hr_evaluation(osv.osv):
('done','Done'), ('done','Done'),
('cancel','Cancelled'), ('cancel','Cancelled'),
], 'State', required=True, readonly=True), ], 'State', required=True, readonly=True),
'date_close': fields.date('Ending Date'), 'date_close': fields.date('Ending Date', select=True),
'progress': fields.float("Progress"), 'progress': fields.float("Progress"),
} }
_defaults = { _defaults = {

View File

@ -60,12 +60,12 @@ class hr_expense_expense(osv.osv):
'name': fields.char('Description', size=128, required=True), 'name': fields.char('Description', size=128, required=True),
'id': fields.integer('Sheet ID', readonly=True), 'id': fields.integer('Sheet ID', readonly=True),
'ref': fields.char('Reference', size=32), '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"), '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), 'employee_id': fields.many2one('hr.employee', "Employee", required=True),
'user_id': fields.many2one('res.users', 'User', 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_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', help = "Date of the acceptation of the sheet expense. It's filled when the button Accept 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'), 'user_valid': fields.many2one('res.users', 'Validation User'),
'account_move_id': fields.many2one('account.move', 'Ledger Posting'), '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)]} ), 'line_ids': fields.one2many('hr.expense.line', 'expense_id', 'Expense Lines', readonly=True, states={'draft':[('readonly',False)]} ),

View File

@ -126,7 +126,7 @@ class hr_applicant(crm.crm_case, osv.osv):
'partner_id': fields.many2one('res.partner', 'Partner'), 'partner_id': fields.many2one('res.partner', 'Partner'),
'partner_address_id': fields.many2one('res.partner.address', 'Partner Contact', \ 'partner_address_id': fields.many2one('res.partner.address', 'Partner Contact', \
domain="[('partner_id','=',partner_id)]"), 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), 'write_date': fields.datetime('Update Date', readonly=True),
'stage_id': fields.many2one ('hr.recruitment.stage', 'Stage'), 'stage_id': fields.many2one ('hr.recruitment.stage', 'Stage'),
'state': fields.selection(AVAILABLE_STATES, 'State', size=16, readonly=True, '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'), 'company_id': fields.many2one('res.company', 'Company'),
'user_id': fields.many2one('res.users', 'Responsible'), 'user_id': fields.many2one('res.users', 'Responsible'),
# Applicant Columns # Applicant Columns
'date_closed': fields.datetime('Closed', readonly=True), 'date_closed': fields.datetime('Closed', readonly=True, select=True),
'date_open': fields.datetime('Opened', readonly=True), 'date_open': fields.datetime('Opened', readonly=True, select=True),
'date': fields.datetime('Date'), 'date': fields.datetime('Date'),
'date_action': fields.date('Next Action Date'), 'date_action': fields.date('Next Action Date'),
'title_action': fields.char('Next Action', size=64), 'title_action': fields.char('Next Action', size=64),

View File

@ -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)]}), '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_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_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_ids' : one2many_mod('hr.analytic.timesheet', 'sheet_id',
'Timesheet lines', domain=[('date', '=', time.strftime('%Y-%m-%d'))], 'Timesheet lines', domain=[('date', '=', time.strftime('%Y-%m-%d'))],
readonly=True, states={ readonly=True, states={

View File

@ -33,7 +33,7 @@ class pos_config_journal(osv.osv):
""" Point of Sale journal configuration""" """ Point of Sale journal configuration"""
_name = 'pos.config.journal' _name = 'pos.config.journal'
_description = "Journal Configuration" _description = "Journal Configuration"
_columns = { _columns = {
'name': fields.char('Description', size=64), 'name': fields.char('Description', size=64),
'code': fields.char('Code', size=64), 'code': fields.char('Code', size=64),
@ -46,7 +46,7 @@ pos_config_journal()
class pos_company_discount(osv.osv): class pos_company_discount(osv.osv):
""" Company Discount and Cashboxes """ """ Company Discount and Cashboxes """
_inherit = 'res.company' _inherit = 'res.company'
_columns = { _columns = {
'company_discount': fields.float('Max Discount(%)', digits_compute=dp.get_precision('Point Of Sale')), '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')), '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), 'num_sale': fields.char('Internal Note', size=64),
'shop_id': fields.many2one('sale.shop', 'Shop', required=True, 'shop_id': fields.many2one('sale.shop', 'Shop', required=True,
states={'draft': [('readonly', False)]}, readonly=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, 'date_validation': fields.function(_get_date_payment,
method=True, method=True,
string='Validation Date', string='Validation Date',
type='date', store=True), type='date', select=True, store=True),
'date_payment': fields.function(_get_date_payment2, method=True, 'date_payment': fields.function(_get_date_payment2, method=True,
string='Payment Date', string='Payment Date',
type='date', store=True), type='date', select=True, store=True),
'date_validity': fields.date('Validity Date', required=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_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."), '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): 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. @param name: Names of fields.
@return: True @return: True
""" """
@ -570,9 +570,9 @@ class pos_order(osv.osv):
return statement_id return statement_id
def add_product(self, cr, uid, order_id, product_id, qty, context=None): def add_product(self, cr, uid, order_id, product_id, qty, context=None):
"""Create a new order line the order""" """Create a new order line the order"""
line_obj = self.pool.get('pos.order.line') line_obj = self.pool.get('pos.order.line')
values = self.read(cr, uid, order_id, ['partner_id', 'pricelist_id']) 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 return order_line_id, price
def refund(self, cr, uid, ids, context=None): def refund(self, cr, uid, ids, context=None):
"""Create a copy of order for refund order""" """Create a copy of order for refund order"""
clone_list = [] clone_list = []
line_obj = self.pool.get('pos.order.line') line_obj = self.pool.get('pos.order.line')
@ -620,9 +620,9 @@ class pos_order(osv.osv):
return clone_list return clone_list
def action_invoice(self, cr, uid, ids, context=None): def action_invoice(self, cr, uid, ids, context=None):
"""Create a invoice of order """ """Create a invoice of order """
inv_ref = self.pool.get('account.invoice') inv_ref = self.pool.get('account.invoice')
inv_line_ref = self.pool.get('account.invoice.line') inv_line_ref = self.pool.get('account.invoice.line')
product_obj = self.pool.get('product.product') product_obj = self.pool.get('product.product')

View File

@ -185,7 +185,7 @@ class sale_order(osv.osv):
for line in self.pool.get('sale.order.line').browse(cr, uid, ids, context=context): for line in self.pool.get('sale.order.line').browse(cr, uid, ids, context=context):
result[line.order_id.id] = True result[line.order_id.id] = True
return result.keys() return result.keys()
_columns = { _columns = {
'name': fields.char('Order Reference', size=64, required=True, 'name': fields.char('Order Reference', size=64, required=True,
readonly=True, states={'draft': [('readonly', False)]}, select=True), readonly=True, states={'draft': [('readonly', False)]}, select=True),
@ -202,9 +202,9 @@ class sale_order(osv.osv):
('done', 'Done'), ('done', 'Done'),
('cancel', 'Cancelled') ('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), ], '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)]}), 'date_order': fields.date('Ordered Date', required=True, readonly=True, select=True, states={'draft': [('readonly', False)]}),
'create_date': fields.date('Creation Date', readonly=True, help="Date on which sales order is created."), '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, help="Date on which sales order is confirmed."), '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), '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_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."), '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."),