[MERGE]: Merged lp:~openerp-dev/openobject-addons/trunk-event_improvements-atp-event_...
authorAtul Patel (OpenERP) <atp@tinyerp.com>
Sun, 29 Apr 2012 18:07:29 +0000 (23:37 +0530)
committerAtul Patel (OpenERP) <atp@tinyerp.com>
Sun, 29 Apr 2012 18:07:29 +0000 (23:37 +0530)
bzr revid: atp@tinyerp.com-20120429180729-nscqe9nix9am0367

addons/event/event.py
addons/event/event_view.xml
addons/event/static/src/css/event.css
addons/event_sale/__openerp__.py
addons/event_sale/event_sale.py
addons/event_sale/event_sale_view.xml
addons/sale/sale_view.xml

index 5e948c1..5b14f25 100644 (file)
@@ -220,7 +220,7 @@ class event_event(osv.osv):
         'note': fields.text('Description', readonly=False, states={'done': [('readonly', True)]}),
         'company_id': fields.many2one('res.company', 'Company', required=False, change_default=True, readonly=False, states={'done': [('readonly', True)]}),
         'is_subscribed' : fields.function(_subscribe_fnc, type="boolean", string='Subscribed'),
-        'location_id': fields.many2one('res.company','Organization Address', readonly=False, states={'done': [('readonly', True)]}),
+        'location_id': fields.many2one('res.partner','Organization Address', readonly=False, states={'done': [('readonly', True)]}),
         
     }
 
index 4e61844..c6cf379 100644 (file)
                                                <td width="auto">
                                                <table>
                                                                                        <tr>
-                                                                                               <td class="oe_td_date_border">Start</td><td><field name="date_begin" nolabel="1"/></td>
+                                                                                               <td class="oe_td_date_border">Start: </td><td><field name="date_begin" nolabel="1"/></td>
                                                                                        </tr>
                                                                                        <tr>
                                                                                                <td class="oe_td_date_border">End</td><td><field name="date_end" nolabel="1"/></td>
index d89131f..7cf87ff 100644 (file)
@@ -130,10 +130,10 @@ div.oe_fold_column{
 { 
     width:380px;
     height:200px;
-    border:1px; 
+    border:1px solid black; 
     margin-left:auto; 
     margin-right:auto; 
-    border:solid #677933;
+    
 }
 .oe_td_border
 {
index fb7134f..d8f6899 100644 (file)
@@ -34,7 +34,7 @@ This module allows you to automatize and connect your registration creation with
 It defines a new kind of service products that offers you the possibility to choose an event category associated with it. When you encode a sale order for that product, you will be able to choose an existing event of that category and when you confirm your sale order it will automatically create a registration for this event.
 """,
     'author': 'OpenERP SA',
-    'depends': ['event','sale','sale_crm','portal'],
+    'depends': ['event','sale','sale_crm'],
     'update_xml': [
         'event_sale_view.xml',
     ],
index 93be776..1e0e745 100644 (file)
@@ -35,6 +35,15 @@ class product(osv.osv):
 
 product()
 
+class sale_order(osv.osv):
+    _inherit = 'sale.order'
+    _columns = {
+    'partner_id': fields.many2one('res.partner', 'Customer', readonly=False, states={'draft': [('readonly', False)]}, required=False, change_default=True, select=True),
+    'partner_invoice_id': fields.many2one('res.partner', 'Invoice Address', readonly=False, required=False, states={'draft': [('readonly', False)]}, help="Invoice address for current sales order."),
+    'partner_shipping_id': fields.many2one('res.partner', 'Shipping Address', readonly=False, required=False, states={'draft': [('readonly', False)]}, help="Shipping address for current sales order."),
+    }
+    
+
 class sale_order_line(osv.osv):
     _inherit = 'sale.order.line'
     _columns = {
@@ -71,7 +80,6 @@ class sale_order_line(osv.osv):
     def button_confirm(self, cr, uid, ids, context=None):
         '''
         create registration with sale order
-
         '''
         registration_obj = self.pool.get('event.registration')
         sale_obj = self.pool.get('sale.order')
@@ -100,45 +108,45 @@ class event_event(osv.osv):
                     'event_item_ids': fields.one2many('event.items','event_id', 'Event Items'),
                 }
 
-    def make_order(self, cr, uid, ids, partner_id, context=None):
+    def open_qoutation(self, cr, uid, ids, partner_id, context=None):
+        res = {}
+        event_pool = self.pool.get('event.event')
+        register_pool = self.pool.get('event.registration')
+        sale_order_line_pool = self.pool.get('sale.order.line')
         sale_order = self.pool.get('sale.order')
-        sale_order_line_obj = self.pool.get('sale.order.line')
-        res_partner_obj = self.pool.get('res.partner')
-        prod_pricelist_obj = self.pool.get('product.pricelist')
-        res_users_obj = self.pool.get('res.users')
-        customer = res_partner_obj.browse(cr, uid, partner_id, context=context)
-        partner_id = res_users_obj.browse(cr, uid, uid, context=context).partner_id.id
-        if not partner_id:
-            user_name = res_users_obj.browse(cr, uid, uid, context=context).name
-            partner_id =  res_partner_obj.create(cr, uid, {'name': user_name})
-        
-        price_list = prod_pricelist_obj.search(cr,uid,[],context=context)[0]
-        
-        for order_lines in self.browse(cr, uid, ids, context=context):
-            if order_lines.event_item_ids:
-                product = order_lines.id
-                sale_id = sale_order.create(cr, uid, {
-                            'partner_id': partner_id,
-                            'pricelist_id': price_list,
-                            'partner_invoice_id': partner_id,
-                            'partner_shipping_id': partner_id,
-                            'date_order': order_lines.date_begin
-                })
-            
-                for line in order_lines.event_item_ids:
-                    
-                    sale_order_line_obj.create(cr, uid, {
-                        'order_id': sale_id,
-                        'name': order_lines.name,
-                        'product_uom_qty': line.qty,
-                        'product_id': product,
-                        'product_uom': line.uom_id.id,
-                        'price_unit': line.price,
-                        'date_planned': line.sales_end_date,
+        user = self.pool.get("res.users").browse(cr, uid, uid, context=context)
+        for event_id in self.browse(cr, uid, ids, context=context):
+            prod_pricelist_obj = self.pool.get('product.pricelist')
+            sale_order_lines = []
+            price_list = prod_pricelist_obj.search(cr,uid,[],context=context)[0]
+            new_sale_id = sale_order.create(cr, uid, {
+                'date_order': event_id.date_begin,
+                'pricelist_id': price_list,
+                })            
+            if event_id.event_item_ids:
+                for items in event_id.event_item_ids:
+                    product = items.product_id.id
+                    sale_order_line = sale_order_line_pool.create(cr, uid, {
+                        'order_id': new_sale_id,                                
+                        'name': items.product_id.name,
+                        'product_uom_qty': items.qty,
+                        'product_id': items.product_id.id,
+                        'product_uom': items.uom_id.id,
+                        'price_unit': items.price,
+                        'date_planned': items.sales_end_date,
                     }, context=context)
-            self.write(cr, uid, ids, {'state': 'confirm'}, context=context)
-        return True
-
+                res = {
+                        'name': _('Quotation'),
+                        'view_type': 'form',
+                        'view_mode': 'form',
+                        'res_model': 'sale.order',
+                        'res_id': new_sale_id,
+                        'type': 'ir.actions.act_window',
+                        'nodestroy': True,
+                        'target': 'new',
+                }
+                self.write(cr, uid, ids, {'state': 'confirm'}, context=context)
+        return res
 
 class event_items(osv.osv):
     _name = "event.items"
index ff0ead1..52a0723 100644 (file)
@@ -39,7 +39,7 @@
                                <xpath expr="//group[@string='vanue']" position="after">
                                                <field name="event_item_ids" nolabel="1"/><newline/>
                                                <div class="oe_right">
-                                                       <button string="Order Now" name="make_order" help="Order Event" type="object" icon="gtk-ok" attrs="{'invisible':[('state','=','confirm')]}"/>
+                                                       <button string="Order Now" name="open_qoutation" help="Order Event" type="object" icon="gtk-ok" attrs="{'invisible':[('state','=','confirm')]}"/>
                                                </div>
                                </xpath>
                                <xpath expr="//group[@string='vanue']" position="attributes">
index 3d597b8..21c15dc 100644 (file)
                     </group>
                     <notebook colspan="5">
                         <page string="Sales Order">
-                            <field name="partner_id" on_change="onchange_partner_id(partner_id)" domain="[('customer','=',True)]" context="{'search_default_customer':1}" required="1"/>
+                            <field name="partner_id" on_change="onchange_partner_id(partner_id)" domain="[('customer','=',True)]" context="{'search_default_customer':1}" />
                             <field domain="[('parent_id','=',partner_id)]" name="partner_invoice_id" groups="sale.group_delivery_invoice_address" options='{"quick_create": false}'/>
                             <field domain="[('parent_id','=',partner_id)]" name="partner_shipping_id" groups="sale.group_delivery_invoice_address" options='{"quick_create": false}'/>
                             <field domain="[('type','=','sale')]" name="pricelist_id" groups="product.group_sale_pricelist" on_change="onchange_pricelist_id(pricelist_id,order_line)"/>