Amit Parmar (OpenERP) has proposed merging 
lp:~openerp-dev/openobject-addons/trunk-usability-modify_sale_application_configuration-aar
 into lp:~openerp-dev/openobject-addons/trunk-usability.

Requested reviews:
  Amit (Open ERP) (apa-tiny)

For more details, see:
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-usability-modify_sale_application_configuration-aar/+merge/70293
-- 
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-usability-modify_sale_application_configuration-aar/+merge/70293
Your team OpenERP R&D Team is subscribed to branch 
lp:~openerp-dev/openobject-addons/trunk-usability.
=== modified file 'hr_timesheet/hr_timesheet.py'
--- hr_timesheet/hr_timesheet.py	2011-01-14 00:11:01 +0000
+++ hr_timesheet/hr_timesheet.py	2011-08-03 16:12:50 +0000
@@ -30,7 +30,8 @@
     _inherit = "hr.employee"
     _columns = {
         'product_id': fields.many2one('product.product', 'Product', help="Specifies employee's designation as a product with type 'service'."),
-        'journal_id': fields.many2one('account.analytic.journal', 'Analytic Journal')
+        'journal_id': fields.many2one('account.analytic.journal', 'Analytic Journal'),
+        'uom_id': fields.related('product_id', 'uom_id', type='many2one', relation='product.uom', string='UoM', store=True, readonly=True)
     }
 
     def _getAnalyticJournal(self, cr, uid, context=None):

=== modified file 'hr_timesheet/hr_timesheet_data.xml'
--- hr_timesheet/hr_timesheet_data.xml	2011-07-12 09:27:29 +0000
+++ hr_timesheet/hr_timesheet_data.xml	2011-08-03 16:12:50 +0000
@@ -14,6 +14,7 @@
         </record>
 
         <record id="hr.employee" model="hr.employee">
+            <field name="uom_id" ref="product.uom_hour"/>
             <field name="product_id" ref="product_consultant"/>
         </record>
         

=== modified file 'hr_timesheet/hr_timesheet_view.xml'
--- hr_timesheet/hr_timesheet_view.xml	2011-04-07 09:27:30 +0000
+++ hr_timesheet/hr_timesheet_view.xml	2011-08-03 16:12:50 +0000
@@ -101,12 +101,17 @@
             <field name="model">hr.employee</field>
             <field name="inherit_id" ref="hr.view_employee_form"/>
             <field name="arch" type="xml">
+                
+                <xpath expr="/form/group/group/field[@name='parent_id']" position="after">
+                    <field name="uom_id"/>
+                </xpath>
                 <page string="Categories" position="after">
                     <page string="Timesheets" groups="base.group_hr_user">
                         <field name="product_id" domain="[('type','=','service')]"/>
                         <field name="journal_id" widget="selection"/>
                     </page>
                 </page>
+                         
             </field>
         </record>
 

=== modified file 'sale/sale.py'
--- sale/sale.py	2011-07-08 11:50:51 +0000
+++ sale/sale.py	2011-08-03 16:12:50 +0000
@@ -22,7 +22,7 @@
 from datetime import datetime, timedelta
 from dateutil.relativedelta import relativedelta
 import time
-
+import pooler
 from osv import fields, osv
 from tools.translate import _
 import decimal_precision as dp
@@ -205,7 +205,7 @@
             ('invoice_except', 'Invoice Exception'),
             ('done', 'Done'),
             ('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="Givwizard = self.browse(cr, uid, ids)[0]es 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, select=True, states={'draft': [('readonly', False)]}),
         '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, select=True, help="Date on which sales order is confirmed."),
@@ -1175,43 +1175,109 @@
 class sale_config_picking_policy(osv.osv_memory):
     _name = 'sale.config.picking_policy'
     _inherit = 'res.config'
-
+    '''def _get_options(cr, uid, ids, context=None):
+        product_obj = self.pool.get('product.uom')
+        uom_ids = product_obj.search(cr, uid, [])
+        res = []
+        for i in product_obj.browse(cr, uid, uom_ids):
+            if i.category_id.name == 'Working Time':
+                res.append(i.id)
+        
+        return res'''
     _columns = {
         'name': fields.char('Name', size=64),
         'order_policy': fields.selection([
             ('manual', 'Invoice Based on Sales Orders'),
             ('picking', 'Invoice Based on Deliveries'),
-        ], 'Invoicing Method', required=True,
-           help="You can generate invoices based on sales orders or based on shippings."),
-        'step': fields.selection([
-            ('one', 'Delivery Order Only'),
-            ('two', 'Picking List & Delivery Order')
-        ], 'Steps To Deliver a Sales Order', required=True,
-           help="By default, OpenERP is able to manage complex routing and paths "\
-           "of products in your warehouse and partner locations. This will configure "\
-           "the most common and simple methods to deliver products to the customer "\
-           "in one or two operations by the worker.")
+        ], 'Main Method Based On', required=True, help="You can generate invoices based on sales orders or based on shippings.", readonly=True),
+        'sale_orders': fields.boolean('Based on Sales Orders',),
+        'deli_orders': fields.boolean('Based on Delivery Orders'),
+        'task_work': fields.boolean('Based on Tasks\' Work'),
+        'timesheet': fields.boolean('Based on Timesheet'),
+        'charge_delivery': fields.boolean('Do you charge the delivery', readonly=True),
+        
+        'time_unit': fields.many2one('product.uom','Main Working Time Unit', readonly=True)
     }
     _defaults = {
         'order_policy': 'manual',
-        'step': 'one'
+        
     }
-
+    
+    def onchange_order(self, cr, uid, ids, sale, deli, context=None):
+        res = {}
+        
+        if sale or deli:
+            res.update({'order_policy': 'manual'})
+        elif not sale and not deli:
+            res.update({'order_policy': 'manual'})
+        else:
+            return {}
+            
+        return {'value':res}
+    
+        
     def execute(self, cr, uid, ids, context=None):
         ir_values_obj = self.pool.get('ir.values')
-        ir_model_data_obj = self.pool.get('ir.model.data')
-        stock_location_obj = self.pool.get('stock.location')
-        location_id = ir_model_data_obj.get_object_reference(cr, uid, 'stock', 'stock_location_output')
-        location_id = location_id and location_id[1] or False
-        chaining_type = False
-        for o in self.browse(cr, uid, ids, context=context):
-            ir_values_obj.set(cr, uid, 'default', False, 'order_policy', ['sale.order'], o.order_policy)
-            if o.step == 'one':
-                chaining_type = 'transparent'
-            else:
-                chaining_type = 'manual'
-            stock_location_obj.write(cr, uid, [location_id], {'chained_auto_packing': chaining_type})
-
+        data_obj = self.pool.get('ir.model.data')
+        menu_obj = self.pool.get('ir.ui.menu')
+        module_obj = self.pool.get('ir.module.module')
+        module_upgrade_obj = self.pool.get('base.module.upgrade')
+        module_name = []
+        group_ids=[]
+        group_name = ['group_sale_salesman','group_sale_manager']
+        
+        for name in group_name:
+            data_id = data_obj.name_search(cr, uid, name)
+            group_ids.append(data_obj.browse(cr,uid,data_id[0][0]).res_id)
+        
+        wizard = self.browse(cr, uid, ids)[0]
+        
+        if wizard.sale_orders:
+            menu_name = 'menu_invoicing_sales_order_lines'
+            data_id = data_obj.name_search(cr, uid, menu_name)
+            menu_id = data_obj.browse(cr,uid,data_id[0][0]).res_id
+            menu_obj.write(cr, uid, menu_id, {'groups_id':[(4,group_ids[0]),(4,group_ids[1])]}) 
+        
+        if wizard.deli_orders:
+            menu_name = 'menu_action_picking_list_to_invoice'
+            data_id = data_obj.name_search(cr, uid, menu_name)
+            menu_id = data_obj.browse(cr,uid,data_id[0][0]).res_id
+            menu_obj.write(cr, uid, menu_id, {'groups_id':[(4,group_ids[0]),(4,group_ids[1])]})
+        
+        if wizard.task_work:
+            module_name.append('project_timesheet')
+            module_name.append('account_analytic_analysis')
+            
+        if wizard.timesheet:
+            module_name.append('account_analytic_analysis')
+            
+        if wizard.charge_delivery:
+            module_name.append('delivery')    
+        
+        if wizard.time_unit:
+            product_obj = self.pool.get('product.product')
+            product_id = product_obj.name_search(cr, uid, 'Employee')
+            product_obj.write(cr, uid, product_id[0][0], {'uom_id':wizard.time_unit.id})
+            
+        if len(module_name):
+            module_ids = []
+            need_install = False
+            module_ids = []
+            for module in module_name:
+                data_id = module_obj.name_search(cr,uid,module)
+                module_ids.append(data_id[0][0])
+               
+            for module in module_obj.browse(cr, uid, module_ids):
+                if module.state == 'uninstalled':
+                    module_obj.state_update(cr, uid, [module.id], 'to install', ['uninstalled'], context)
+                    need_install = True
+                    cr.commit()
+            if need_install:
+                pooler.restart_pool(cr.dbname, update_module=True)[1]
+        
+        ir_values_obj.set(cr, uid, 'default', False, 'order_policy', ['sale.order'], wizard.order_policy)  
+        
+   
 sale_config_picking_policy()
 
 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

=== modified file 'sale/sale_view.xml'
--- sale/sale_view.xml	2011-07-20 13:09:43 +0000
+++ sale/sale_view.xml	2011-08-03 16:12:50 +0000
@@ -527,9 +527,9 @@
 
         <menuitem id="menu_invoiced" name="Invoicing" parent="base.menu_base_partner" sequence="5"
             groups="-base.group_extended"/>
-        <menuitem action="action_order_line_tree2" id="menu_invoicing_sales_order_lines" parent="menu_invoiced" sequence="2" groups="base.group_sale_salesman,base.group_sale_manager"/>
+        <menuitem action="action_order_line_tree2" id="menu_invoicing_sales_order_lines" parent="menu_invoiced" sequence="2" groups="base.group_no_one"/>
         <!-- configartion view -->
-
+           
         <record id="view_config_picking_policy" model="ir.ui.view">
             <field name="name">Set Up Your Invoicing Method</field>
             <field name="model">sale.config.picking_policy</field>
@@ -540,25 +540,49 @@
                 <form position="attributes">
                   <attribute name="string">Sales Application Configuration</attribute>
                 </form>
-                <separator string="title" position="attributes">
-                <attribute name="string">Configure Sales Order Logistics</attribute>
-                  </separator>
-                  <xpath expr="//label[@string='description']" position="attributes">
-                    <attribute name="string">Define your invoice method. A services company usually invoices based on sale orders while a retailer usually invoices based on deliveries.</attribute>
-                  </xpath>
-                <xpath expr='//separator[@string="vsep"]' position='attributes'>
-                      <attribute name='rowspan'>15</attribute>
-                      <attribute name='string'></attribute>
-                  </xpath>
-                <group string="res_config_contents" position="replace">
-                  <field name="order_policy"/>
-                  <newline/>
-                  <field name="step" groups="base.group_extended"/>
+                <group colspan="4" col="8" position="replace">
+                    <group col="4">
+                        <separator string="How do you generate your costumer invoice ?"/>
+                        
+                    </group>
+                    <group col="4">
+                        <separator string="Options"/>
+                    </group>
+                    <newline/>
+                    <group col="2">
+                        <label align="0.0" string="Based on Sales Orders" width="200" colspan="1"/>
+                        <field name="sale_orders" on_change="onchange_order(sale_orders,deli_orders)" nolabel="1"/>
+                        
+                        <label align="0.0" string="Based on Delivery Orders" width="200" colspan="1"/>
+                        <field name="deli_orders" on_change="onchange_order(sale_orders,deli_orders)" nolabel="1"/>
+                        
+                        <label align="0.0" string="Based on Task's Work" width="200" colspan="1"/>
+                        <field name="task_work" nolabel="1"/>
+                        
+                        <label align="0.0" string="Based on Timesheet" width="200" colspan="1"/>
+                        <field name="timesheet" nolabel="1"/>
+                    </group>
+                    <group col="3">
+                		<label align="0.0" string="Main Method Based On" width="200" colspan="1"/>
+                		
+                        <field name="order_policy" attrs="{'readonly':['|',('sale_orders','!=',True),('deli_orders','!=',True)]}" nolabel="1"/>
+                        
+                    	<newline/>
+                    	<label align="0.0" string="Do you charge the delivery" width="200" colspan="1"/>
+            			<field name="charge_delivery" attrs="{'readonly':[('sale_orders','!=',True), ('deli_orders','!=',True)]}" nolabel="1"/>
+            			
+                    	<newline/>
+                    	<label align="0.0" string="Main Working Time Unit" width="200" colspan="1"/>
+                    	<field name="time_unit" attrs="{'readonly':[('task_work','=',False),('timesheet','=',False)]}" widget="selection" domain="[('category_id','=',3)]" nolabel="1"/>
+                  	</group>
+                    
+                    
                 </group>
                 <xpath expr='//button[@name="action_skip"]' position='replace'/>
               </data>
             </field>
         </record>
+        
 
         <record id="action_config_picking_policy" model="ir.actions.act_window">
             <field name="name">Set up your Invoicing Method</field>

=== modified file 'sale/stock_view.xml'
--- sale/stock_view.xml	2011-01-14 00:11:01 +0000
+++ sale/stock_view.xml	2011-08-03 16:12:50 +0000
@@ -74,7 +74,7 @@
             <field name="context">{'contact_display': 'partner_address', 'search_default_to_invoice': 1, 'search_default_done': 1}</field>
             <field name="search_view_id" ref="stock.view_picking_out_search"/>
         </record>
-        <menuitem action="outgoing_picking_list_to_invoice" id="menu_action_picking_list_to_invoice" parent="sale.menu_invoiced" sequence="20"/>
+        <menuitem action="outgoing_picking_list_to_invoice" id="menu_action_picking_list_to_invoice" parent="sale.menu_invoiced" groups="base.group_no_one" sequence="20"/>
 
     </data>
 </openerp>

_______________________________________________
Mailing list: https://launchpad.net/~openerp-dev-gtk
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~openerp-dev-gtk
More help   : https://help.launchpad.net/ListHelp

Reply via email to