[MERGE] new v8 api by rco
[odoo/odoo.git] / addons / analytic / analytic.py
index 1d728ba..e31efa0 100644 (file)
@@ -159,7 +159,8 @@ class account_analytic_account(osv.osv):
                 if account.company_id.currency_id.id != value:
                     raise osv.except_osv(_('Error!'), _("If you set a company, the currency selected has to be the same as it's currency. \nYou can remove the company belonging, and thus change the currency, only on analytic account of type 'view'. This can be really useful for consolidation purposes of several companies charts with different currencies, for example."))
         if value:
-            return cr.execute("""update account_analytic_account set currency_id=%s where id=%s""", (value, account.id, ))
+            cr.execute("""update account_analytic_account set currency_id=%s where id=%s""", (value, account.id))
+            self.invalidate_cache(cr, uid, ['currency_id'], [account.id], context=context)
 
     def _currency(self, cr, uid, ids, field_name, arg, context=None):
         result = {}
@@ -173,7 +174,7 @@ class account_analytic_account(osv.osv):
     _columns = {
         'name': fields.char('Account/Contract Name', required=True, track_visibility='onchange'),
         'complete_name': fields.function(_get_full_name, type='char', string='Full Name'),
-        'code': fields.char('Reference', select=True, track_visibility='onchange'),
+        'code': fields.char('Reference', select=True, track_visibility='onchange', copy=False),
         'type': fields.selection([('view','Analytic View'), ('normal','Analytic Account'),('contract','Contract or Project'),('template','Template of Contract')], 'Type of Account', required=True,
                                  help="If you select the View Type, it means you won\'t allow to create journal entries using that account.\n"\
                                   "The type 'Analytic account' stands for usual accounts that you only want to use in accounting.\n"\
@@ -196,7 +197,14 @@ class account_analytic_account(osv.osv):
         'date_start': fields.date('Start Date'),
         'date': fields.date('Expiration Date', select=True, track_visibility='onchange'),
         '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([('template', 'Template'),('draft','New'),('open','In Progress'),('pending','To Renew'),('close','Closed'),('cancelled', 'Cancelled')], 'Status', required=True, track_visibility='onchange'),
+        'state': fields.selection([('template', 'Template'),
+                                   ('draft','New'),
+                                   ('open','In Progress'),
+                                   ('pending','To Renew'),
+                                   ('close','Closed'),
+                                   ('cancelled', 'Cancelled')],
+                                  'Status', required=True,
+                                  track_visibility='onchange', copy=False),
         'currency_id': fields.function(_currency, fnct_inv=_set_company_currency, #the currency_id field is readonly except if it's a view account and if there is no company
             store = {
                 'res.company': (_get_analytic_account, ['currency_id'], 10),
@@ -266,10 +274,7 @@ class account_analytic_account(osv.osv):
         if not default:
             default = {}
         analytic = self.browse(cr, uid, id, context=context)
-        default.update(
-            code=False,
-            line_ids=[],
-            name=_("%s (copy)") % (analytic['name']))
+        default['name'] = _("%s (copy)") % analytic['name']
         return super(account_analytic_account, self).copy(cr, uid, id, default, context=context)
 
     def on_change_company(self, cr, uid, id, company_id):