[IMP] analytic, account_analytic_account : The field 'template_id' need to moved...
authorDivyesh Makwana (Open ERP) <mdi@tinyerp.com>
Mon, 23 Jul 2012 12:05:31 +0000 (17:35 +0530)
committerDivyesh Makwana (Open ERP) <mdi@tinyerp.com>
Mon, 23 Jul 2012 12:05:31 +0000 (17:35 +0530)
bzr revid: mdi@tinyerp.com-20120723120531-38reqpofvzh69bo7

addons/account_analytic_analysis/account_analytic_analysis.py
addons/account_analytic_analysis/account_analytic_analysis_view.xml
addons/analytic/analytic.py
addons/analytic/analytic_view.xml

index 6e15fe1..524d5de 100644 (file)
@@ -455,7 +455,6 @@ class account_analytic_account(osv.osv):
         'invoice_on_timesheets' : fields.boolean("Invoice On Timesheets"),
         'month_ids': fields.function(_analysis_all, multi='analytic_analysis', type='many2many', relation='account_analytic_analysis.summary.month', string='Month'),
         'user_ids': fields.function(_analysis_all, multi='analytic_analysis', type="many2many", relation='account_analytic_analysis.summary.user', string='User'),
-        'template_id': fields.many2one('account.analytic.account', 'Template of Contract'),
         'hours_qtt_est': fields.float('Estimation of Hours to Invoice'),
         'est_total' : fields.function(_sum_of_fields, type="float",multi="sum_of_all", string="Total Estimation"),
         'invoiced_total' : fields.function(_sum_of_fields, type="float",multi="sum_of_all", string="Total Invoiced"),
@@ -483,18 +482,15 @@ class account_analytic_account(osv.osv):
     def on_change_template(self, cr, uid, ids, template_id, context=None):
         if not template_id:
             return {}
-        res = {'value':{}}
-        template = self.browse(cr, uid, template_id, context=context)
-        res['value']['date_start'] = template.date_start
-        res['value']['date'] = template.date
-        res['value']['fix_price_invoices'] = template.fix_price_invoices
-        res['value']['invoice_on_timesheets'] = template.invoice_on_timesheets
-        res['value']['quantity_max'] = template.quantity_max
-        res['value']['hours_qtt_est'] = template.hours_qtt_est
-        res['value']['amount_max'] = template.amount_max
-        res['value']['to_invoice'] = template.to_invoice.id
-        res['value']['pricelist_id'] = template.pricelist_id.id
-        res['value']['description'] = template.description
+        res = super(account_analytic_account, self).on_change_template(cr, uid, ids, template_id, context=context)
+        if template_id and 'value' in res:
+            template = self.browse(cr, uid, template_id, context=context)
+            res['value']['fix_price_invoices'] = template.fix_price_invoices
+            res['value']['invoice_on_timesheets'] = template.invoice_on_timesheets
+            res['value']['hours_qtt_est'] = template.hours_qtt_est
+            res['value']['amount_max'] = template.amount_max
+            res['value']['to_invoice'] = template.to_invoice.id
+            res['value']['pricelist_id'] = template.pricelist_id.id
         return res
 account_analytic_account()
 
index ead87c1..3283906 100644 (file)
@@ -20,9 +20,6 @@
             <field name="inherit_id" ref="analytic.view_account_analytic_account_form"/>
             <field eval="40" name="priority"/>
             <field name="arch" type="xml">
-                <xpath expr='//field[@name="type"]' position='after'>
-                    <field name="template_id" on_change="on_change_template(template_id,context)"  domain="[('type','=','template')]" attrs="{'invisible': [('type','in',['view', 'normal','template'])]}" context="{'default_type' : 'template'}"/>
-                </xpath>
                 <xpath expr='//div[@name="duration"]' position="after" version="7.0">
                     <label for="quantity_max"/>
                     <div>
index af8b161..c16ed82 100644 (file)
@@ -161,6 +161,7 @@ class account_analytic_account(osv.osv):
                                   "The type 'Analytic account' stands for usual accounts that you only want to use in accounting.\n"\
                                   "If you select Contract or Project, it offers you the possibility to manage the validity and the invoicing options for this account.\n"\
                                   "The special type 'Template of Project' allows you to define a template with default data that you can reuse easily."),
+        'template_id': fields.many2one('account.analytic.account', 'Template of Contract'),
         'description': fields.text('Description'),
         'parent_id': fields.many2one('account.analytic.account', 'Parent Analytic Account', select=2),
         'child_ids': fields.one2many('account.analytic.account', 'parent_id', 'Child Accounts'),
@@ -184,6 +185,17 @@ class account_analytic_account(osv.osv):
             }, string='Currency', type='many2one', relation='res.currency'),
     }
     
+    def on_change_template(self, cr, uid, ids, template_id, context=None):
+        if not template_id:
+            return {}
+        res = {'value':{}}
+        template = self.browse(cr, uid, template_id, context=context)
+        res['value']['date_start'] = template.date_start
+        res['value']['date'] = template.date
+        res['value']['quantity_max'] = template.quantity_max
+        res['value']['description'] = template.description
+        return res
+    
     def on_change_partner_id(self, cr, uid, ids,partner_id, name, context={}):
         res={}
         if partner_id:
index 6d6a38b..d590506 100644 (file)
@@ -18,6 +18,7 @@
                                 <field name="partner_id" on_change="on_change_partner_id(partner_id, name)" attrs="{'required':[('type','=','contract')]}"/>
                                 <field name="parent_id" on_change="on_change_parent(parent_id)" attrs="{'invisible': [('type','in',['contract','template'])]}"/>
                                 <field name="type"/>
+                                <field name="template_id" on_change="on_change_template(template_id,context)" domain="[('type','=','template')]" attrs="{'invisible': [('type','in',['view', 'normal','template'])]}" context="{'default_type' : 'template'}"/>
                             </group>
                             <group>
                                 <field name="code"/>