[REM]: Remove unused code and refactor code as per specification

bzr revid: atp@tinyerp.com-20120523134448-9vqtiufzjgmmaq0b
This commit is contained in:
Atul Patel (OpenERP) 2012-05-23 19:14:48 +05:30
parent 2d0d1d71ce
commit e21492a8bf
15 changed files with 5 additions and 495 deletions

View File

@ -54,7 +54,6 @@ Note that:
'demo_xml': ['event_demo.xml'],
'test': ['test/process/event_draft2done.yml'],
'js': ['static/src/js/google_map.js'],
'qweb': ['static/src/xml/event_address.xml'],
'css': ['static/src/css/event.css'],
'installable': True,
'application': True,

View File

@ -218,14 +218,11 @@ 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'),
'available_qty': fields.integer('Availabel Quantity'),
'sale_end_date': fields.datetime('SalesEnd'),
'city': fields.related('address_id', 'city', type='char', string='City'),
'street': fields.related('address_id', 'street', type='char', string='Street'),
'country_id': fields.related('address_id', 'country_id', relation='res.country', type='many2one', string='Country'),
'state_id': fields.related('address_id', 'state_id', relation="res.country.state", type="many2one", string='Fed. State'),
'zip': fields.related('address_id','zip', type="char", string="Zip"),
'city': fields.related('address_id', 'city', type='char', string='City'),
'street': fields.related('address_id', 'street', type='char', string='Street'),
'country_id': fields.related('address_id', 'country_id', relation='res.country', type='many2one', string='Country'),
'state_id': fields.related('address_id', 'state_id', relation="res.country.state", type="many2one", string='Fed. State'),
'zip': fields.related('address_id','zip', type="char", string="Zip"),
}
_defaults = {

View File

@ -1,9 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<template>
<td id = "address_text" t-name="address">
<t t-esc="record.street"/> <br/>
<t t-esc="record.city"/> <br/>
<t t-esc="record.country_id[1]"/>
</td>
</template>

View File

@ -35,14 +35,10 @@ It defines a new kind of service products that offers you the possibility to cho
'author': 'OpenERP SA',
'depends': ['event','sale','sale_crm'],
'update_xml': [
'security/ir.model.access.csv',
'event_sale_view.xml',
],
'demo_xml': ['event_demo.xml'],
'test':['test/confirm.yml'],
'css': ['static/src/css/event_page.css'],
'js': ['static/src/js/google_map.js'],
'qweb': ['static/src/xml/event_address.xml'],
'installable': True,
'active': False,
}

View File

@ -93,108 +93,3 @@ class sale_order_line(osv.osv):
message = _("The registration %s has been created from the Sale Order %s.") % (registration_id, order_line.order_id.name)
registration_obj.log(cr, uid, registration_id, message)
return super(sale_order_line, self).button_confirm(cr, uid, ids, context=context)
class event_event(osv.osv):
_inherit = 'event.event'
_columns = {
'event_item_ids': fields.one2many('event.items','event_id', 'Event Items'),
}
def order_now(self, cr, uid, ids, context=None):
res = {}
register_pool = self.pool.get('event.registration')
sale_order_line_pool = self.pool.get('sale.order.line')
sale_order = self.pool.get('sale.order')
partner_pool = self.pool.get("res.partner")
data_obj = self.pool.get("ir.model.data")
prod_pricelist_obj = self.pool.get('product.pricelist')
user = self.pool.get("res.users").browse(cr, uid, uid, context=context)
partner_ids = partner_pool.search(cr, uid, [('name', '=', user.name), ('email', '=', user.user_email)])
if not partner_ids:
# partner not found create new partner.....
new_partner_id = partner_pool.create(cr, uid, {'name': user.name, 'email': user.user_email})
partner_invoice_id = partner_pool.address_get(cr, uid, [new_partner_id], ['invoice'])['invoice']
partner_shipping_id = partner_pool.address_get(cr, uid, [new_partner_id], ['delivery'])['delivery']
else:
new_partner_id = partner_ids[0]
partner_invoice_id = partner_pool.address_get(cr, uid, [new_partner_id], ['invoice'])['invoice']
partner_shipping_id = partner_pool.address_get(cr, uid, [new_partner_id], ['delivery'])['delivery']
for event_id in self.browse(cr, uid, ids, context=context):
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,
'partner_id': new_partner_id,
'partner_invoice_id': partner_invoice_id,
'partner_shipping_id': partner_shipping_id
})
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,
'price_unit': items.price,
'date_planned': items.sales_end_date,
}, context=context)
view_id = data_obj._get_id(cr, uid, 'sale', 'view_order_form')
if view_id:
res_id = data_obj.browse(cr, uid, view_id, context=context).res_id
res = {
'name': _('Quotation'),
'view_type': 'form',
'view_mode': 'form',
'res_model': 'sale.order',
'res_id': new_sale_id,
'views':[(res_id,'form'), (False, 'tree')],
'type': 'ir.actions.act_window',
'nodestroy': True,
'target': 'current',
}
return res
def subscribe_to_event(self, cr, uid, ids, context=None):
res = {}
data_obj = self.pool.get("ir.model.data")
view_id = data_obj._get_id(cr, uid, 'event_sale', 'view_event_page')
if view_id:
res_id = data_obj.browse(cr, uid, view_id, context=context).res_id
res = {
'name': _('Event Page'),
'view_type': 'form',
'view_mode': 'form',
'views':[(res_id,'form'), (False, 'tree')],
'res_model': 'event.event',
'res_id': ids[0],
'type': 'ir.actions.act_window',
'nodestroy': True,
'target': 'current',
}
return res
class event_items(osv.osv):
_name = "event.items"
_columns = {
'product_id': fields.many2one('product.product', 'Product', required=True),
'price': fields.integer('Price'),
#Need to convert this integer field in to dynamic selection.. TODO
# 'max_qty': fields.integer('Max.Quantity available'),
'qty': fields.integer('Quantity'),
'uom_id': fields.many2one('product.uom', 'UoM'),
'discount': fields.integer('Discount'),
'event_id': fields.many2one('event.event', 'Event'),
'sales_end_date': fields.date('Sales End')
}
def onchange_product_id(self, cr, uid, ids, product, context=None):
product_obj = self.pool.get('product.product')
data = {}
if not product:
return {'value': data}
price = product_obj.browse(cr, uid, product).list_price
uom = product_obj.browse(cr, uid, product).uom_id.id
data['price'] = price
data['uom_id'] = uom
return {'value': data}

View File

@ -29,120 +29,6 @@
</xpath>
</field>
</record>
<!-- Events Organisation/CONFIGURATION/EVENTS PAGE VIEW -->
<record model="ir.ui.view" id="view_event_page">
<field name="name">Events</field>
<field name="model">event.event</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Events" layout="manual">
<div class="oe_form_topbar" readonly="1">
<button string="Cancel Event" name="button_cancel" states="draft,confirm" type="object" icon="gtk-cancel"/>
<button string="Confirm Event" name="button_confirm" states="draft" type="object" icon="gtk-apply"/>
<button string="Event Done" name="button_done" states="confirm" type="object" icon="gtk-jump-to"/>
<button string="Set To Draft" name="button_draft" states="cancel,done" type="object" icon="gtk-convert"/>
<div class="oe_right">
<field name="state" nolabel="1" widget="statusbar" statusbar_visible="draft,open,done" statusbar_colors='{"pending":"blue"}'/>
</div>
</div>
<sheet string="Event Form" layout="auto">
<group col="2">
<group col="2">
<div class="oe_event_title">
<field name="name" nolabel="1" readonly="1"/>
</div>
<newline/>
<group colspan="4" name="venue">
<div class="oe_sub1"> Venue : </div>
<field name="address_id_id" nolabel="1"/>
</group>
<field name="event_item_ids" nolabel="1">
<tree editable="top" string="Event Items">
<field name="product_id" readonly="1" />
<field name="sales_end_date" readonly="1"/>
<field name="price" readonly="1"/>
<!-- <field name="max_qty" readonly="1" groups="event.group_event_manager"/>-->
<field name="qty" attrs="{'readonly':[('product_id','=',False)]}" groups="event.group_event_user" />
</tree>
</field>
<newline/>
<div class="oe_right">
<button name="order_now" string="Order Now" type="object" icon="gtk-apply"/>
</div>
</group>
<group>
<div id = "oe_mapbox" class="oe_mapbox"> </div><newline/>
<table>
<tr>
<td width="70px" class="oe_td_border">
Where
</td>
<td width="auto">
<field name="address_id" widget ="geo_address" nolabel="1"/>
</td>
<td width="210px">
<table align="right">
<tr>
<td class="oe_td_date_border">Start: </td><td><field name="date_begin" nolabel="1" readonly="1"/></td>
</tr>
<tr>
<td class="oe_td_date_border">End</td><td><field name="date_end" nolabel="1" readonly="1"/></td>
</tr>
</table>
</td>
</tr>
</table>
</group>
</group>
<separator string="" colspan="4"/>
<label string="Event Details:" colspan="4"/>
<field name="note" colspan="4" nolabel="1" readonly="1"/>
</sheet>
</form>
</field>
</record>
<record model="ir.ui.view" id="view_event_form_inherit">
<field name="name">Events Inherit</field>
<field name="model">event.event</field>
<field name="type">form</field>
<field name="inherit_id" ref="event.view_event_form"/>
<field name="arch" type="xml">
<xpath expr="//page[@string='Extra Info']" position="after">
<page string="Event Item">
<field name="event_item_ids" nolabel="1">
<tree editable="top" string="Event Items">
<field name="product_id" string="Ticket Type" domain="[('event_ok','=',True)]" on_change="onchange_product_id(product_id)"/>
<field name="sales_end_date" />
<field name="price"/>
<!-- <field name="max_qty" groups="event.group_event_manager"/> -->
<field name="qty" attrs="{'readonly':[('product_id','=',False)]}" groups="event.group_event_user"/>
</tree>
</field>
<newline/>
</page>
</xpath>
</field>
</record>
<record id="view_event_kanban_inherit" model="ir.ui.view">
<field name="name">event.inherit.kanban</field>
<field name="model">event.event</field>
<field name="type">kanban</field>
<field name="inherit_id" ref="event.view_event_kanban"/>
<field name="arch" type="xml">
<xpath expr="//div/t/t/input[@name='subscribe']" position="replace">
<input type="hidden"/>
</xpath>
</field>
</record>
</data>
</openerp>

View File

@ -1,2 +0,0 @@
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_event_items,event.items,event_sale.model_event_items,event.group_event_user,1,1,0,0
1 id name model_id:id group_id:id perm_read perm_write perm_create perm_unlink
2 access_event_items event.items event_sale.model_event_items event.group_event_user 1 1 0 0

View File

@ -1,31 +0,0 @@
.oe_event_title{
font-size: 25px;
}
.oe_sub1
{
float:left;
height:50px;
border-right: 1px solid black;
border-color: #DCDCDC;
}
.oe_mapbox
{
width:auto;
height:200px;
margin-left:auto;
margin-right:auto;
text-align: right;
}
.oe_td_border
{
width: 5em;
padding: 2px;
border-right: 1px solid black;
text-align: center;
border-color: #DCDCDC;
}
.oe_td_date_border
{
border-right:1px solid black;
border-color: #DCDCDC;
}

View File

@ -1,64 +0,0 @@
openerp.event = function(instance){
instance.web.form.widgets.add('geo_address', 'instance.event.GeoAddress');
instance.event.GeoAddress = instance.web.form.AbstractField.extend(_.extend({}, {
init : function(){
this._super.apply(this,arguments);
this.googleMapsLoaded = $.Deferred();
},
start:function(){
},
set_input_id:function(id){
},
Map_Load: function() {
var self = this;
if(this.googleMapsLoaded.state() != "pending"){return this.googleMapsLoaded.promise();}
googleMapsCallback = function () {
self.googleMapsLoaded.resolve();
};
$.ajax({
url: "https://maps.googleapis.com/maps/api/js?v=3&callback=googleMapsCallback&sensor=false",
dataType: "script"
}).fail(self.googleMapsLoaded.reject);
return this.googleMapsLoaded.promise();
},
set_value:function(value){
var self = this;
this.get_address(value).done(function(value){
if(!self.__parentedParent.$element.find("#address_text").length)self.__parentedParent.$element.find(".oe_td_border").after(instance.web.qweb.render("address",{'record': value}));
var address = _.str.sprintf(' %(street)s, %(city)s, %(country_id[1])s', value);
var defer = self.Map_Load();
defer.done(function(){
return self.render_map(address);
});
});
},
get_address:function(value){
if (!value || value.length == 0){
return $.Deferred().reject();
}
return new instance.web.DataSet (this,this.field.relation, this.build_context()).read_ids(value[0],["street","city","country_id"]);
},
render_map: function(address){
var geocoder = new google.maps.Geocoder();
geocoder.geocode( { 'address': address}, function(results, status){
if (status == google.maps.GeocoderStatus.OK){
var lat = results[0].geometry.location.lat(),lng =results[0].geometry.location.lng();
var myOptions = {
zoom: 17,
center: new google.maps.LatLng(lat,lng),
mapTypeId: google.maps.MapTypeId.ROADMAP
}
return new google.maps.Marker({
map : new google.maps.Map(document.getElementById("oe_mapbox"),myOptions),
position: new google.maps.LatLng(lat,lng)
});
}
});
},
get_value:function(){
}
}));
};

View File

@ -1,9 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<template>
<td id = "address_text" t-name="address">
<t t-esc="record.street"/> <br/>
<t t-esc="record.city"/> <br/>
<t t-esc="record.country_id[1]"/>
</td>
</template>

View File

@ -1,22 +0,0 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2011 OpenERP S.A (<http://www.openerp.com>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
import portal_event
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -1,40 +0,0 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2011 OpenERP S.A (<http://www.openerp.com>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
{
'name' : "Portal Event",
'version' : "1.0",
'depends' : ["portal", "event_sale"],
'author' : "OpenERP SA",
'category': 'Portal',
'description': """
This module defines 'portals' to customize the access to your OpenERP database
for external users.
""",
'update_xml': [
'security/portal_event_security.xml',
'security/ir.model.access.csv',
],
'website': 'http://www.openerp.com',
'installable': True,
}
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -1,47 +0,0 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
import time
from osv import fields, osv
from tools.translate import _
class event_event(osv.osv):
_inherit = 'event.event'
def make_quotation(self, cr, uid, ids, context=None):
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')
partner_pool = self.pool.get('res.partner')
prod_pricelist_obj = self.pool.get('product.pricelist')
res_users_obj = self.pool.get('res.users')
user = res_users_obj.browse(cr, uid, uid, context=context)
partner_ids = partner_pool.search(cr, uid, [('name', '=', user.name), ('email', '=', user.user_email)])
if partner_ids:
res_users_obj.write(cr, uid, user.id, {'partner_id': partner_ids[0]})
if not partner_ids:
raise osv.except_osv(_('Error !'),
_('There is no Partner defined ' \
'for this event:'))
res = super(event_event,self).make_quotation(cr, uid, ids, context)
return res

View File

@ -1,6 +0,0 @@
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_event,event,event.model_event_event,portal_event.group_event_portal,1,0,0,0
access_registration,registration,event.model_event_registration,portal_event.group_event_portal,1,0,0,0
access_event_items,event.items,event.model_event_event,portal_event.group_event_portal,1,1,1,0
access_product_product,product.product,product.model_product_product,portal_event.group_event_portal,1,0,0,0
access_product_uom,product.uom,product.model_product_uom,portal_event.group_event_portal,1,0,0,0
1 id name model_id:id group_id:id perm_read perm_write perm_create perm_unlink
2 access_event event event.model_event_event portal_event.group_event_portal 1 0 0 0
3 access_registration registration event.model_event_registration portal_event.group_event_portal 1 0 0 0
4 access_event_items event.items event.model_event_event portal_event.group_event_portal 1 1 1 0
5 access_product_product product.product product.model_product_product portal_event.group_event_portal 1 0 0 0
6 access_product_uom product.uom product.model_product_uom portal_event.group_event_portal 1 0 0 0

View File

@ -1,33 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<!-- Creating Portal Group -->
<record id="group_event_portal" model="res.groups">
<field name="name">Event Portal Groups</field>
<field ref="event.module_category_event_management" name="category_id"/>
</record>
<record id="portal_event" model="res.portal">
<field name="name">Portal User</field>
<field name="group_id" ref="group_event_portal"/>
</record>
<!-- Sale Portal Access Rules -->
<record id="portal_event_rule" model="ir.rule">
<field name="name">Personal Events</field>
<field ref="event.model_event_event" name="model_id"/>
<field name="domain_force">[]</field>
<field name="groups" eval="[(4, ref('group_event_portal'))]"/>
</record>
<record id="portal_registration_rule" model="ir.rule">
<field name="name">Personal Registrations</field>
<field ref="event.model_event_registration" name="model_id"/>
<field name="domain_force">[('partner_id.email','=',user.login)]</field>
<field name="groups" eval="[(4, ref('group_event_portal'))]"/>
</record>
</data>
</openerp>