[REF] Event, Membership, pos: Cleaning and code improved

bzr revid: mra@mra-laptop-20101027042913-y963rgrq3bcog1qs
This commit is contained in:
Mustufa Rangwala 2010-10-27 09:59:13 +05:30
parent 02d922e395
commit 8b0db0ccc4
11 changed files with 27 additions and 39 deletions

View File

@ -252,14 +252,12 @@ class event_event(osv.osv):
Checks for recursion level for event
"""
level = 100
while len(ids):
cr.execute('SELECT DISTINCT parent_id FROM event_event WHERE id IN %s', (tuple(ids),))
ids = filter(None, map(lambda x: x[0], cr.fetchall()))
if not level:
return False
level -= 1
return True
def _check_closing_date(self, cr, uid, ids):

View File

@ -127,3 +127,5 @@ class report_event_registration(osv.osv):
""")
report_event_registration()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -19,7 +19,7 @@
#
##############################################################################
from osv import fields, osv
from osv import osv
class event_confirm(osv.osv_memory):
"""

View File

@ -27,7 +27,7 @@ class event_confirm_registration(osv.osv_memory):
Confirm Event Registration
"""
_name = "event.confirm.registration"
_description = "Event Registraion"
_description = "Confirmation for Event Registration"
_columns = {
'msg': fields.text('Message', readonly=True),
@ -68,4 +68,4 @@ class event_confirm_registration(osv.osv_memory):
event_confirm_registration()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -57,6 +57,7 @@ class event_make_invoice(osv.osv_memory):
if not event_reg.event_id.product_id:
raise osv.except_osv(_('Warning !'),
_("Event related doesn't have any product defined"))
if not event_reg.partner_invoice_id:
raise osv.except_osv(_('Warning !'),
_("Registration doesn't have any partner to invoice."))
@ -79,8 +80,8 @@ class event_make_invoice(osv.osv_memory):
tree_id = mod_obj._get_id(cr, uid, 'account', 'invoice_tree')
tree_res = mod_obj.browse(cr, uid, tree_id, context=context).res_id
return {
'domain': "[('id','in',%s)]" % res,
'name': 'Invoices',
'domain': "[('id', 'in', %s)]" % res,
'name': 'Customer Invoices',
'view_type': 'form',
'view_mode': 'tree,form',
'res_model': 'account.invoice',

View File

@ -19,13 +19,10 @@
#
##############################################################################
import netsvc
import tools
from osv import fields, osv
from tools.translate import _
from decimal_precision import decimal_precision as dp
class partner_event_registration(osv.osv_memory):
""" event Registration """
@ -149,5 +146,4 @@ class partner_event_registration(osv.osv_memory):
partner_event_registration()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -454,6 +454,7 @@ class product_template(osv.osv):
_columns = {
'member_price': fields.float('Member Price', digits_compute= dp.get_precision('Sale Price')),
}
product_template()
class Product(osv.osv):
@ -513,8 +514,8 @@ class account_invoice_line(osv.osv):
"""
if not context:
context={}
res = super(account_invoice_line, self).write(cr, uid, ids, vals, context=context)
member_line_obj = self.pool.get('membership.membership_line')
res = super(account_invoice_line, self).write(cr, uid, ids, vals, context=context)
for line in self.browse(cr, uid, ids, context=context):
if line.invoice_id.type == 'out_invoice':
ml_ids = member_line_obj.search(cr, uid, [('account_invoice_line', '=', line.id)], context=context)
@ -552,9 +553,9 @@ class account_invoice_line(osv.osv):
def create(self, cr, uid, vals, context=None):
"""Overrides orm create method
"""
member_line_obj = self.pool.get('membership.membership_line')
result = super(account_invoice_line, self).create(cr, uid, vals, context=context)
line = self.browse(cr, uid, result, context=context)
member_line_obj = self.pool.get('membership.membership_line')
if line.invoice_id.type == 'out_invoice':
ml_ids = member_line_obj.search(cr, uid, [('account_invoice_line', '=', line.id)], context=context)
if line.product_id and line.product_id.membership and not ml_ids:

View File

@ -33,7 +33,6 @@ STATE = [
('paid', 'Paid Member'),
]
class report_membership(osv.osv):
'''Membership Analysis'''

View File

@ -36,9 +36,7 @@ class membership_invoice(osv.osv_memory):
"""
if not product_id:
return {'value': {'unit_price': False}}
else:
unit_price=self.pool.get('product.product').price_get(cr, uid, [product_id])[product_id]
return {'value': {'member_price': unit_price}}
return {'value': {'member_price': self.pool.get('product.product').price_get(cr, uid, [product_id])[product_id]}}
def membership_invoice(self, cr, uid, ids, context=None):
partner_obj = self.pool.get('res.partner')
@ -53,14 +51,14 @@ class membership_invoice(osv.osv_memory):
'amount': data.member_price
}
invoice_list = partner_obj.create_membership_invoice(cr, uid, context.get('active_ids', []), datas=datas, context=context)
return {
'domain': [('id', 'in', invoice_list)],
'name': 'Membership Invoice',
'name': 'Membership Invoices',
'view_type': 'form',
'view_mode': 'tree,form',
'res_model': 'account.invoice',
'type': 'ir.actions.act_window',
# missing search view ?
}
membership_invoice()

View File

@ -34,10 +34,10 @@ class account_journal(osv.osv):
'check_dtls': False,
'auto_cash': True,
}
account_journal()
class account_cash_statement(osv.osv):
_inherit = 'account.bank.statement'
def _equal_balance(self, cr, uid, cash_id, context=None):
@ -52,16 +52,11 @@ class account_cash_statement(osv.osv):
return True
def _user_allow(self, cr, uid, statement_id, context=None):
if context is None:
context = {}
res = False
uids = []
statement = self.browse(cr, uid, statement_id, context=context)
for user in statement.journal_id.journal_users:
uids.append(user.id)
if uid in uids:
res = True
return res
if uid == user.id:
return True
return False
def _get_cash_open_box_lines(self, cr, uid, context=None):
if context is None:
@ -80,7 +75,7 @@ class account_cash_statement(osv.osv):
def _get_default_cash_close_box_lines(self, cr, uid, context=None):
if context is None:
context = {}
res = super(account_cash_statement,self)._get_default_cash_close_box_lines(cr, uid, context)
res = super(account_cash_statement,self)._get_default_cash_close_box_lines(cr, uid, context=context)
curr = [0.01, 0.02, 0.05, 0.10, 0.20, 0.50]
for rs in curr:
dct = {

View File

@ -51,7 +51,6 @@ class pos_company_discount(osv.osv):
pos_company_discount()
class pos_order(osv.osv):
""" Point of sale gives business owners a convenient way of checking out customers
and of recording sales """
@ -67,10 +66,10 @@ class pos_order(osv.osv):
raise osv.except_osv(_('Invalid action !'), _('Cannot delete a point of sale which is closed or contains confirmed cashboxes!'))
return super(pos_order, self).unlink(cr, uid, ids, context=context)
def onchange_partner_pricelist(self, cr, uid, ids, part, context=None):
def onchange_partner_pricelist(self, cr, uid, ids, part=False, context=None):
""" Changed price list on_change of partner_id"""
if not part:
return {}
return {'value': {}}
pricelist = self.pool.get('res.partner').browse(cr, uid, part, context=context).property_product_pricelist.id
return {'value': {'pricelist_id': pricelist}}
@ -106,10 +105,10 @@ class pos_order(osv.osv):
val = None
for order in self.browse(cr, uid, ids):
cr.execute("SELECT date_payment FROM pos_order WHERE id = %s", (order.id,))
date_p=cr.fetchone()
date_p=date_p and date_p[0] or None
date_p = cr.fetchone()
date_p = date_p and date_p[0] or None
if date_p:
res[order.id]=date_p
res[order.id] = date_p
return res
cr.execute(" SELECT MAX(l.date) "
" FROM account_move_line l, account_move m, account_invoice i, account_move_reconcile r, pos_order o "
@ -283,7 +282,6 @@ class pos_order(osv.osv):
'journal_entry': fields.boolean('Journal Entry'),
}
def _select_pricelist(self, cr, uid, context=None):
""" To get default pricelist for the order"
@param name: Names of fields.
@ -469,7 +467,6 @@ class pos_order(osv.osv):
wf_service = netsvc.LocalService("workflow")
wf_service.trg_validate(uid, 'stock.picking', picking_id, 'button_confirm', cr)
picking_obj.force_assign(cr, uid, [picking_id], context)
return True
def set_to_draft(self, cr, uid, ids, *args):
@ -1226,6 +1223,7 @@ class stock_picking(osv.osv):
_columns = {
'pos_order': fields.many2one('pos.order', 'Pos order'),
}
stock_picking()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: