[MERGE]: Merged with tpa's branch.
authorUjjvala Collins (OpenERP) <uco@tinyerp.com>
Fri, 2 Mar 2012 09:04:35 +0000 (14:34 +0530)
committerUjjvala Collins (OpenERP) <uco@tinyerp.com>
Fri, 2 Mar 2012 09:04:35 +0000 (14:34 +0530)
bzr revid: uco@tinyerp.com-20120302090435-257rxp9nsy6bryjg

1  2 
addons/account/res_config.py
addons/crm/res_config.py
addons/product/res_config.py
addons/sale/res_config.py

@@@ -30,16 -30,17 +30,16 @@@ class account_configuration(osv.osv_mem
                  ('no_tax', 'No Tax'),
                  ('global_on_order', 'Global On Order'),
                  ('on_order_line', 'On Order Lines'),
 -            ], 'Taxes', required=True,
 -            help = """
 -            This allows you to set tax policy to sale order.
 -            if you want to set global tax on sale order then select Global On Order it will add 'Global On Order' group to employees.
 -            if you want to set tax On Order Lines then select On Order Lines it will add 'On Order Lines' group to employees.
 +            ], 'Taxes', required=True, 
 +            help="""
 +                If you want to apply global tax on sale order then select 'Global On Order' it will add 'Global On Order' group to employees.
 +                If you want to apply different taxes for sale order lines then select 'On Order Lines' it will add 'On Order Lines' group to employees.
              """),
              'tax_value': fields.float('Value'),
      }
-     
      _defaults = {
 -        'tax_policy': 'global_on_order',
 +            'tax_policy': 'global_on_order',
      }
  
      def get_default_tax_policy(self, cr, uid, ids, context=None):
          else:
              applied_groups.update({'tax_policy': 'no_tax'})
          return applied_groups
 -    
 +
      def _check_default_tax(self, cr, uid, context=None):
          ir_values_obj = self.pool.get('ir.values')
          for tax in ir_values_obj.get(cr, uid, 'default', False, ['product.product']):
              if tax[1] == 'taxes_id':
                  return tax[2]
          return False
 -    
 +
      def default_get(self, cr, uid, fields_list, context=None):
          ir_values_obj = self.pool.get('ir.values')
          res = super(account_configuration, self).default_get(cr, uid, fields_list, context=context)
@@@ -74,7 -75,7 +74,7 @@@
          if self._check_default_tax(cr, uid, context) and res['fields'].get('tax_value'):
              res['fields']['tax_value'] = {'domain': [], 'views': {}, 'context': {}, 'selectable': True, 'type': 'many2one', 'relation': 'account.tax', 'string': 'Value'}
          return res
 -    
 +
      def set_tax_policy(self, cr, uid, ids, vals, context=None):
          data_obj = self.pool.get('ir.model.data')
          users_obj = self.pool.get('res.users')
              users_obj.write(cr, uid, [uid], {'groups_id': [(3,remove_group_id)]})
              ir_values_obj.set(cr, uid, 'default', False, 'groups_id', ['res.users'], [(3,remove_group_id)])
          else:
 -            groups = [order_group_id, remove_group_id]
 +            groups = [order_group_id, order_line_group_id]
              for group_id in groups:
                  groups_obj.write(cr, uid, [user_group_id], {'implied_ids': [(3,group_id)]})
                  users_obj.write(cr, uid, [uid], {'groups_id': [(3,group_id)]})
                  ir_values_obj.set(cr, uid, 'default', False, 'groups_id', ['res.users'], [(3,group_id)])
  
 -    def set_tax_value(self, cr, uid, ids, vals, context=None):
 -        chart_account_obj = self.pool.get('wizard.multi.charts.accounts')
 -        acc_installer_obj = self.pool.get('account.installer')
 -        chart_template_obj = self.pool.get('account.chart.template')
 -        tax_obj = self.pool.get('account.tax')
 -        chart_template_ids = chart_template_obj.search(cr, uid, [('visible', '=', True)], context=context)
 -        taxes = []
 -        if chart_template_ids:
 -            name = _('Tax %.2f%%') % vals.get('tax_value')
 -            taxes = tax_obj.search(cr, uid, [('name', '=', name)], context=context)
 -        check_default_taxes = self._check_default_tax(cr, uid, context)
 -        if not check_default_taxes and not taxes:
 -            installer_id = acc_installer_obj.create(cr, uid, {}, context=context)
 -            acc_installer_obj.execute(cr, uid, [installer_id], context=context)
 -            if chart_template_ids:
 -                code_digits = chart_account_obj.onchange_chart_template_id(cr, uid, [], chart_template_ids[0], context=context)['value']['code_digits']
 -                object_id = chart_account_obj.create(cr, uid, {'code_digits': code_digits}, context=context)
 -                chart_account_obj.execute(cr, uid, [object_id], context=context)
 -        return check_default_taxes
 -    
  account_configuration()
diff --combined addons/crm/res_config.py
@@@ -25,12 -25,16 +25,12 @@@ class crm_configuration(osv.osv_memory)
      _inherit = 'res.config'
  
      _columns = {
 -        'module_crm_caldav' : fields.boolean("Caldav synchronization",
 -                                    help="""
 -                                    This allows you Caldav features in Meeting, Share meeting with other calendar clients like sunbird.
 -                                    It installs crm_caldav module.
 -                                    """),
 -        'module_fetchmail_crm': fields.boolean("Lead/Opportunity mail gateway",
 -                                               help = """
 -                                               this allows you to configure your incoming mail server.
 -                                               It installs fetchmail_crm module.
 -                                               """),
 +        'module_crm_caldav' : fields.boolean("Use caldav to synchronize Meetings",
 +                                    help="""This allows you Caldav features in Meeting, Share meeting with other calendar clients like sunbird.
 +                                    It installs crm_caldav module."""),
 +        'module_fetchmail_crm': fields.boolean("Lead/Opportunity mail gateway", help="""
 +                                                This allows you to configure your incoming mail server,
 +                                               It installs fetchmail_crm module."""),
          'server' : fields.char('Server Name', size=256),
          'port' : fields.integer('Port'),
          'type': fields.selection([
          'is_ssl': fields.boolean('SSL/TLS', help="Connections are encrypted with SSL/TLS through a dedicated port (default: IMAPS=993, POP=995)"),
          'user' : fields.char('Username', size=256),
          'password' : fields.char('Password', size=1024),
-         'module_import_sugarcrm' : fields.boolean("Import data from sugarCRM?",
+         'module_import_sugarcrm' : fields.boolean("SugarCRM Import",
                                      help="""Import SugarCRM Leads, Opportunities, Users, Accounts, Contacts, Employees, Meetings, Phonecalls, Emails, and Project, Project Tasks Data into OpenERP Module.
                                      It installs import_sugarcrm module.
                                      """),
-         'module_import_google' : fields.boolean("Import Contacts & Meetings from Google",
+         'module_import_google' : fields.boolean("Google Import",
                                      help="""
-                                     Import google contact in partner address and add google calendar events details in Meeting
+                                     Import google contact in partner address and add google calendar events details in Meeting.
                                      It installs import_google module.
                                      """),
          'module_wiki_sale_faq' : fields.boolean("Install a sales FAQ?",
@@@ -65,7 -69,7 +65,7 @@@
                                      """),
          'module_google_map' : fields.boolean("Google maps on customer",
                                      help="""
-                                     This allows yopu to locate customer on Google Map
+                                     This allows yopu to locate customer on Google Map.
                                      It installs google_map module.
                                      """),
          'module_plugin_thunderbird': fields.boolean('Thunderbird plugin',
@@@ -95,7 -99,7 +95,7 @@@
          ir_values_obj = self.pool.get('ir.values')
          result = {}
          installed_modules = self.get_default_installed_modules(cr, uid, ids, context=context)
 -        if 'fetchmail_crm' in installed_modules.keys():
 +        if 'module_fetchmail_crm' in installed_modules.keys():
              for val in ir_values_obj.get(cr, uid, 'default', False, ['fetchmail.server']):
                  result.update({val[1]: val[2]})
          return result
          model_obj = self.pool.get('ir.model')
          fetchmail_obj = self.pool.get('fetchmail.server')
          ir_values_obj = self.pool.get('ir.values')
 -        if vals.get('fetchmail_crm'):
 -            object_id = model_obj.search(cr, uid, [('model','=','crm.lead')])[0]
 +        object_id = model_obj.search(cr, uid, [('model','=','crm.lead')])
 +        if vals.get('module_fetchmail_crm') and object_id:
              fetchmail_vals = {
                      'name': 'Incoming Leads',
 -                    'object_id': object_id,
 +                    'object_id': object_id[0],
                      'server': vals.get('server'),
                      'port': vals.get('port'),
                      'is_ssl': vals.get('is_ssl'),
                      'password': vals.get('password')
              }
              server_ids = fetchmail_obj.search(cr, uid, [])
 -            if not self.get_default_installed_modules(cr, uid, ['fetchmail_crm'], context) or not server_ids:
 +            if not self.get_default_installed_modules(cr, uid, ids, context) or not server_ids:
                  tt = fetchmail_obj.create(cr, uid, fetchmail_vals, context=context)
              else:
                  fetchmail_ids = fetchmail_obj.search(cr, uid, [('name','=','Incoming Leads')], context=context)
@@@ -25,15 -25,16 +25,15 @@@ class product_groups_configuration(osv.
      _inherit = 'res.config'
  
      _columns = {
 -        'group_sale_pricelist_per_customer':fields.boolean("Pricelist per customer ",
 -                                                           help="""
 -                                                           Allows to manage different prices based on rules per category of customers. Example: 10% for retailers, promotion of 5 EUR on this product,
 -                                                           It assigns the "pricelist" group to all employees
 -                                                           """),
 +        'group_sale_pricelist_per_customer':fields.boolean("Pricelist per customer",
 +                                                           help="""Allows to manage different prices based on rules per category of customers. 
 +                                                           Example: 10% for retailers, promotion of 5 EUR on this product, etc.
 +                                                           It assigns the "Pricelist" group to all employees."""),
          'group_sale_uom_per_product':fields.boolean("UOM per product",
                                                      help="""
 -                                                    This allow different unit of measure per product,
 -                                                    It assigns the "UOM per product" group to all employees
 +                                                    Allows you to select and maintain different unit of measures per product.
 +                                                    It assigns the "UOM per product" group to all employees.
                                                      """),
  }
-     
  product_groups_configuration()
@@@ -23,23 -23,31 +23,23 @@@ from osv import fields, os
  import pooler
  from tools.translate import _
  
 -MODULE_LIST = [
 -               'analytic_user_function', 'analytic_journal_billing_rate', 'import_sugarcrm',
 -               'import_google', 'crm_caldav', 'wiki_sale_faq', 'base_contact','sale_layout','warning',
 -               'google_map', 'fetchmail_crm', 'plugin_thunderbird', 'plugin_outlook','account_analytic_analysis',
 -               'project_timesheet', 'account_analytic_analysis', 'project_mrp', 'delivery',
 -               'sale_margin', 'sale_journal'
 -]
 -
  class sale_configuration(osv.osv_memory):
      _inherit = 'res.config'
  
      _columns = {
 -        'sale_orders': fields.boolean('Based on Sales Orders',),
 -        'deli_orders': fields.boolean('Based on Delivery Orders'),
 +        'sale_orders': fields.boolean('Based on Sales Orders', 
 +                                      help="To allow your salesman to make invoices for sale order lines using 'Lines to Invoice' menu."),
 +        'deli_orders': fields.boolean('Based on Delivery Orders',
 +                                      help="To allow your salesman to make invoices for Delivery Orders using 'Deliveries to Invoice' menu."),
          'task_work': fields.boolean('Based on Tasks\' Work',
 -                                    help="""
 -                                    This allows to you transfer the entries under tasks defined for Project Management to
 +                                    help="""Lets you transfer the entries under tasks defined for Project Management to
                                      the Timesheet line entries for particular date and particular user  with the effect of creating, editing and deleting either ways.
 -                                    Automatically creates project tasks from procurement lines.
 -                                    It installs the project_timesheet and project_mrp module.
 -                                    """),
 -        'timesheet': fields.boolean('Based on Timesheet',
 +                                    and to automatically creates project tasks from procurement lines.
 +                                    It installs the project_timesheet and project_mrp module"""),
 +        'module_account_analytic_analysis': fields.boolean('Based on Timesheet',
                                      help = """For modifying account analytic view to show important data to project manager of services companies,
 -                                    You can also view the report of account analytic summary user-wise as well as month wise
 -                                    ,It installs the account_analytic_analysis module."""),
 +                                    You can also view the report of account analytic summary user-wise as well as month wise.
 +                                    It installs the account_analytic_analysis module."""),
          'order_policy': fields.selection([
              ('manual', 'Invoice Based on Sales Orders'),
              ('picking', 'Invoice Based on Deliveries'),
@@@ -51,9 -59,9 +51,9 @@@
                                     It installs the delivery module.
                                     """),
          'time_unit': fields.many2one('product.uom','Working Time Unit'),
 -        'picking_policy' : fields.boolean("Deliver all products at once?", help = "You can set picking policy from sale order that will allow you to deliver all products at one."),
 -        'group_sale_delivery_address':fields.boolean("Multiple Address",help="This allows you to set different delivery address and picking address.It assigns Multiple Address group to employee."),
 -        'group_sale_disc_per_sale_order_line':fields.boolean("Discounts per sale order lines ",help="This allows you to apply discounts per sale order lines. It assigns Discounts per sale order lines group to employee."),
 +        'picking_policy' : fields.boolean("Deliver all products at once?", help = "You can set picking policy on sale order that will allow you to deliver all products at once."),
 +        'group_sale_delivery_address':fields.boolean("Multiple Address",help="This allows you to set different delivery address and picking address,it assigns Multiple Address group to all employees."),
 +        'group_sale_disc_per_sale_order_line':fields.boolean("Discounts per sale order lines ",help="This allows you to apply discounts per sale order lines, it assigns Discounts per sale order lines group to all employees."),
          'module_sale_layout':fields.boolean("Notes & subtotals per line",help="Allows to format sale order lines using notes, separators, titles and subtotals. It installs the sale_layout module."),
          'module_warning': fields.boolean("Alerts by products or customers",
                                    help="""To trigger warnings in OpenERP objects.
          'module_analytic_user_function' : fields.boolean("User function by contracts",
                                      help="""This allows you to define what is the default function of a specific user on a given account
                                      This is mostly used when a user encodes his timesheet: the values are retrieved and the fields are auto-filled. But the possibility to change these values is still available.
-                                     It Installs analytic_user_function module"""),
+                                     It Installs analytic_user_function module."""),
          'module_analytic_journal_billing_rate' : fields.boolean("Billing rates by contracts",
                                      help=""" This allows you to define what is the default invoicing rate for a specific journal on a given account.
                                      It installs analytic_journal_billing_rate module.
--                                    """),
 -        'module_account_analytic_analysis': fields.boolean('Contracts',
 -                                    help = """
 -                                    For modifying account analytic view to show important data to project manager of services companies,
 -                                    You can also view the report of account analytic summary user-wise as well as month wise.
 -                                    It installs the account_analytic_analysis module."""),
++                                    """)
      }
 -
 -    def get_default_applied_groups(self, cr, uid, ids, context=None):
 -        applied_groups = {}
 -        user_obj = self.pool.get('res.users')
 -        dataobj = self.pool.get('ir.model.data')
 -
 -        groups = []
 -        user_group_ids = user_obj.browse(cr, uid, uid, context=context).groups_id
 -
 -        for group_id in user_group_ids:
 -            groups.append(group_id.id)
 -
 -        for id in groups:
 -            key_id = dataobj.search(cr, uid,[('res_id','=',id),('model','=','res.groups')],context=context)
 -            key = dataobj.browse(cr, uid, key_id[0], context=context).name
 -            applied_groups[key] = True
 -
 -        return applied_groups
 -
 +    
      def get_default_installed_modules(self, cr, uid, ids, context=None):
 -        module_obj = self.pool.get('ir.module.module')
 -        data_obj = self.pool.get('ir.model.data')
 -        module_ids = module_obj.search(cr, uid,
 -                           [('name','in',MODULE_LIST),
 -                            ('state','in',['to install', 'installed', 'to upgrade'])],
 -                           context=context)
 -        installed_modules = dict([(mod.name,True) for mod in module_obj.browse(cr, uid, module_ids, context=context)])
 -        if installed_modules.get('project_mrp') and installed_modules.get('project_timesheet'):
 +        installed_modules = super(sale_configuration, self).get_default_installed_modules(cr, uid, ids, context=context)
 +        if installed_modules.get('module_project_mrp') and installed_modules.get('module_project_timesheet'):
              installed_modules['task_work'] = True
+             prod_id = data_obj.get_object(cr, uid, 'product', 'product_consultant').id
+             uom_id = self.pool.get('product.product').browse(cr, uid, prod_id).uom_id.id
+             defaults.update({'time_unit': uom_id})
 -        if installed_modules.get('account_analytic_analysis'):
 -            installed_modules['timesheet'] = True
 -            prod_id = data_obj.get_object(cr, uid, 'product', 'product_consultant').id
 -            uom_id = self.pool.get('product.product').browse(cr, uid, prod_id).uom_id.id
 -            defaults.update({'time_unit': uom_id})
          return installed_modules
-     
      def get_default_sale_configs(self, cr, uid, ids, context=None):
          ir_values_obj = self.pool.get('ir.values')
          data_obj = self.pool.get('ir.model.data')
              result[res[1]] = res[2]
          return result
      
 -    def get_default_groups(self, cr, uid, ids, context=None):
 -        ir_values_obj = self.pool.get('ir.values')
 -        result = {}
 -        for res in ir_values_obj.get(cr, uid, 'default', False, ['res.users']):
 -            result[res[1]] = res[2]
 -        return result
 -    
      def default_get(self, cr, uid, fields_list, context=None):
          result = super(sale_configuration, self).default_get(
              cr, uid, fields_list, context=context)
          #TODO: TO BE IMPLEMENTED
          for method in dir(self):
              if method.startswith('set_'):
                  getattr(self, method)(cr, uid, ids, vals, context)
          return True
  
 -    def set_modules(self, cr, uid, ids, vals, context=None):
 -        module_obj = self.pool.get('ir.module.module')
 -        MODULE_LIST = vals.get('modules')
 +    def set_installed_modules(self, cr, uid, ids, vals, context=None):
          if vals.get('task_work'):
 -            vals.update({'project_timesheet': True,'project_mrp': True})
 -        if vals.get('timesheet'):
 -            vals.update({'account_analytic_analysis': True})
 -        for k, v in vals.items():
 -            if k in MODULE_LIST:
 -                installed = self.get_default_installed_modules(cr, uid, [k], context)
 -                if v == True and not installed.get(k):
 -                    module_id = module_obj.search(cr, uid, [('name','=',k)])
 -                    module_obj.button_immediate_install(cr, uid, module_id, context)
 -                elif v == False and installed.get(k):
 -                    module_id = module_obj.search(cr, uid, [('name','=',k)])
 -                    module_obj.button_uninstall(self, cr, uid, module_id, context=None)
 -                    module_obj.button_upgrade(self, cr, uid, module_id, context=None)
 +            vals.update({'module_project_timesheet': True, 'module_project_mrp': True})
 +        else:
 +            vals.update({'module_project_timesheet': False, 'module_project_mrp': False})
 +
 +        super(sale_configuration, self).set_installed_modules(cr, uid, ids, vals, context=context)
  
      def set_sale_defaults(self, cr, uid, ids, vals, context=None):
          ir_values_obj = self.pool.get('ir.values')
              
          return res
  
 -    def set_groups(self, cr, uid, ids, vals, context=None):
 -        data_obj = self.pool.get('ir.model.data')
 -        users_obj = self.pool.get('res.users')
 -        groups_obj = self.pool.get('res.groups')
 -        ir_values_obj = self.pool.get('ir.values')
 -        dummy,user_group_id = data_obj.get_object_reference(cr, uid, 'base', 'group_user')
 -        for group in vals.keys():
 -            if group.startswith('group_'):
 -                dummy,group_id = data_obj.get_object_reference(cr, uid, 'base', group)
 -                if vals[group]:
 -                    groups_obj.write(cr, uid, [user_group_id], {'implied_ids': [(4,group_id)]})
 -                    users_obj.write(cr, uid, [uid], {'groups_id': [(4,group_id)]})
 -                    ir_values_obj.set(cr, uid, 'default', False, 'groups_id', ['res.users'], [(4,group_id)])
 -                else:
 -                    groups_obj.write(cr, uid, [user_group_id], {'implied_ids': [(3,group_id)]})
 -                    users_obj.write(cr, uid, [uid], {'groups_id': [(3,group_id)]})
 -                    ir_values_obj.set(cr, uid, 'default', False, 'groups_id', ['res.users'], [(3,group_id)])
 -
 -    def onchange_tax_policy(self, cr, uid, ids, tax_policy, tax_value, context=None):
 -        res = {'value': {}}
 -        if isinstance(tax_value, (int)):
 -            self.set_default_taxes(cr, uid, ids, {'tax_value': [tax_value]}, context=context)
 +    def onchange_tax_policy(self, cr, uid, ids, tax_policy, context=None):
          self.set_tax_policy(cr, uid, ids, {'tax_policy': tax_policy}, context=context)
 -        return res
 +        return {'value': {}}
      
      def set_default_taxes(self, cr, uid, ids, vals, context=None):
          ir_values_obj = self.pool.get('ir.values')