[MERGE/IMP]:lp:~openerp-dev/openobject-addons/trunk-contract-apa-improvements-dbr
authorAmit Patel (OpenERP) <apa@tinyerp.com>
Thu, 7 Jun 2012 11:44:02 +0000 (17:14 +0530)
committerAmit Patel (OpenERP) <apa@tinyerp.com>
Thu, 7 Jun 2012 11:44:02 +0000 (17:14 +0530)
bzr revid: apa@tinyerp.com-20120607114402-dzv6t6q8nn2muyv1

1  2 
addons/account_analytic_analysis/account_analytic_analysis.py
addons/analytic/analytic.py
addons/analytic/analytic_view.xml

@@@ -488,8 -488,10 +488,13 @@@ class account_analytic_account(osv.osv)
              res['value']['date_start'] = str(template.date_start)
          if template.date:
              res['value']['date'] = str(template.date)
++        res['value']['fix_price_invoices'] = template.fix_price_invoices
++        res['value']['invoice_on_timesheets'] = template.invoice_on_timesheets
++        res['value']['charge_expenses'] = template.charge_expenses
          res['value']['quantity_max'] = template.quantity_max
          res['value']['remaining_hours'] = template.remaining_hours
+         res['value']['amount_max'] = template.amount_max
+         res['value']['expense_max'] = template.expense_max
          res['value']['to_invoice'] = template.to_invoice.id
          res['value']['pricelist_id'] = template.pricelist_id.id
          res['value']['description'] = template.description
@@@ -184,9 -183,9 +185,7 @@@ class account_analytic_account(osv.osv)
          res={}
          if partner_id:
              part = self.pool.get('res.partner').browse(cr, uid, partner_id,context=context)
--            if not name:
--                res['name'] = part.name
 -            if part.user_id:res['user_id'] = part.user_id.id
 +            if part.user_id:res['manager_id'] = part.user_id.id
          return {'value': res}
  
      def _default_company(self, cr, uid, context=None):
          default['line_ids'] = []
          return super(account_analytic_account, self).copy(cr, uid, id, default, context=context)
  
+     def fields_view_get(self, cr, user, view_id=None, view_type='form', context=None, toolbar=False, submenu=False):
+         res = super(account_analytic_account, self).fields_view_get(cr, user, view_id, view_type, context, toolbar=toolbar, submenu=submenu)
 -        if view_type == 'form':
 -            doc = etree.XML(res['arch'])
 -            nodes = doc.xpath("//field[@name='name']")
++        
++        doc = etree.XML(res['arch'])
++        node = []
++        if view_type == 'form':node = doc.xpath("//field[@name='name']")
++        if view_type == 'tree':node = doc.xpath("//field[@name='complete_name']")
++        if node:
++            curr_node = node[0]
+             if context.get('default_type') == 'contract':
 -                for node in nodes:
 -                    node.set('string', 'Contract/Project Name')
 -            if context.get('default_type') == 'template':
 -                for node in nodes:
 -                    node.set('string', 'Template/Project Name')
 -            res['arch'] = etree.tostring(doc)
++                curr_node.set('string', 'Contract/Project Name')
++                curr_node.set('placeholder', 'Contract or Project name')
++            elif context.get('default_type') == 'template':
++                curr_node.set('string', 'Template Name')
++                curr_node.set('placeholder', 'Template name')
++            else:
++                curr_node.set('string', 'Account Name')
++                curr_node.set('placeholder', 'Account name')
++        res['arch'] = etree.tostring(doc)
+         return res
      def on_change_company(self, cr, uid, id, company_id):
          if not company_id:
              return {}
                  <form  layout="manual">
                      <sheet string="Analytic account" layout="auto">
                          <group colspan="4" col="4" class="oe_form_group_label_border">
-                             <field name="name" string="Contract/Project Name"/>
-                             <field name="partner_id" on_change="on_change_partner_id(partner_id, name)" required="True"/>
+                             <field name="name"/>
+                             <field name="partner_id" on_change="on_change_partner_id(partner_id, name)" attrs="{'required':[('type','!=','template')]}"/>
                              <field name="code"/>
 -                            <field name="user_id"/>
 +                            <field name="manager_id"/>
                              <field name="company_id" on_change="on_change_company(company_id)" select="2" widget="selection" groups="base.group_multi_company" attrs="{'required': [('type','&lt;&gt;','view')]}"/>
                              <field name="type" select="2"/>
                              <field name="parent_id" on_change="on_change_parent(parent_id)" attrs="{'invisible': [('type','in',['contract','template'])]}"/>