[FIX] unmutable default in the remaining modules

[REF] coding style consistency

lp bug: https://launchpad.net/bugs/525808 fixed

bzr revid: ls@numerigraphe.fr-20120305184003-er00xtj9vtcw7gna
This commit is contained in:
Numerigraphe - Lionel Sausin 2012-03-05 19:40:03 +01:00
parent 520e2c680f
commit 2d2a44dcf2
211 changed files with 461 additions and 440 deletions

View File

@ -34,7 +34,7 @@ class crossovered_analytic(report_sxw.rml_parse):
}) })
self.base_amount = 0.00 self.base_amount = 0.00
def find_children(self,ref_ids): def find_children(self, ref_ids):
to_return_ids = [] to_return_ids = []
final_list = [] final_list = []
parent_list = [] parent_list = []
@ -53,7 +53,7 @@ class crossovered_analytic(report_sxw.rml_parse):
final_list.extend(set_list) final_list.extend(set_list)
return final_list #to_return_ids[0] return final_list #to_return_ids[0]
def set_account(self,cats): def set_account(self, cats):
lst = [] lst = []
category = self.pool.get('account.analytic.account').read(self.cr, self.uid, cats) category = self.pool.get('account.analytic.account').read(self.cr, self.uid, cats)
for cat in category: for cat in category:
@ -62,7 +62,7 @@ class crossovered_analytic(report_sxw.rml_parse):
lst.extend(self.set_account(cat['child_ids'])) lst.extend(self.set_account(cat['child_ids']))
return lst return lst
def _ref_lines(self,form): def _ref_lines(self, form):
result = [] result = []
res = {} res = {}
acc_pool = self.pool.get('account.analytic.account') acc_pool = self.pool.get('account.analytic.account')

View File

@ -1,43 +0,0 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2009 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/>.
#
##############################################################################
from osv import fields, osv
#class sale_order_line(osv.osv):
# _name = 'sale.order.line'
# _description = 'Sale Order line'
# _inherit = 'sale.order.line'
#
# def invoice_line_create(self, cr, uid, ids, context={}):
# line_ids = super('sale_order_line',self).invoice_line_create(cr, uid, ids, context)
# invoice_line_obj = self.pool.get('account.invoice.line')
# for line in invoice_line_obj.browse(cr, uid, line_ids):
# if line.product_id:
# a = line.product_id.product_tmpl_id.property_stock_account_output and line.product_id.product_tmpl_id.property_stock_account_output.id
# if not a:
# a = line.product_id.categ_id.property_stock_account_output_categ and line.product_id.categ_id.property_stock_account_output_categ.id
# if a:
# a = self.pool.get('account.fiscal.position').map_account(cr, uid, fpos, a)
# invoice_line_obj.write(cr, uid, line.id, {'account_id':a})
#
#sale_order_line()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -75,7 +75,7 @@ class account_asset_asset(osv.osv):
_name = 'account.asset.asset' _name = 'account.asset.asset'
_description = 'Asset' _description = 'Asset'
def _get_period(self, cr, uid, context={}): def _get_period(self, cr, uid, context=None):
periods = self.pool.get('account.period').find(cr, uid) periods = self.pool.get('account.period').find(cr, uid)
if periods: if periods:
return periods[0] return periods[0]
@ -176,7 +176,9 @@ class account_asset_asset(osv.osv):
year = depreciation_date.year year = depreciation_date.year
return True return True
def validate(self, cr, uid, ids, context={}): def validate(self, cr, uid, ids, context=None):
if context is None:
context = {}
return self.write(cr, uid, ids, { return self.write(cr, uid, ids, {
'state':'open' 'state':'open'
}, context) }, context)
@ -304,7 +306,7 @@ class account_asset_asset(osv.osv):
default.update({'depreciation_line_ids': [], 'state': 'draft'}) default.update({'depreciation_line_ids': [], 'state': 'draft'})
return super(account_asset_asset, self).copy(cr, uid, id, default, context=context) return super(account_asset_asset, self).copy(cr, uid, id, default, context=context)
def _compute_entries(self, cr, uid, ids, period_id, context={}): def _compute_entries(self, cr, uid, ids, period_id, context=None):
result = [] result = []
period_obj = self.pool.get('account.period') period_obj = self.pool.get('account.period')
depreciation_obj = self.pool.get('account.asset.depreciation.line') depreciation_obj = self.pool.get('account.asset.depreciation.line')

View File

@ -35,7 +35,9 @@ class analytic_account_budget_report(report_sxw.rml_parse):
}) })
self.context = context self.context = context
def funct(self, object, form, ids={}, done=None, level=1): def funct(self, object, form, ids=None, done=None, level=1):
if ids is None:
ids = {}
if not ids: if not ids:
ids = self.ids ids = self.ids
if not done: if not done:
@ -153,7 +155,7 @@ class analytic_account_budget_report(report_sxw.rml_parse):
tot['perc'] = float(tot['prac'] / tot['theo']) * 100 tot['perc'] = float(tot['prac'] / tot['theo']) * 100
return result return result
def funct_total(self,form): def funct_total(self, form):
result = [] result = []
res = {} res = {}
res = { res = {

View File

@ -34,7 +34,9 @@ class budget_report(report_sxw.rml_parse):
}) })
self.context = context self.context = context
def funct(self, object, form, ids={}, done=None, level=1): def funct(self, object, form, ids=None, done=None, level=1):
if ids is None:
ids = {}
if not ids: if not ids:
ids = self.ids ids = self.ids
if not done: if not done:

View File

@ -37,7 +37,9 @@ class budget_report(report_sxw.rml_parse):
}) })
self.context = context self.context = context
def funct(self, object, form, ids={}, done=None, level=1): def funct(self, object, form, ids=None, done=None, level=1):
if ids is None:
ids = {}
if not ids: if not ids:
ids = self.ids ids = self.ids
if not done: if not done:

View File

@ -217,7 +217,9 @@ class coda_bank_statement(osv.osv):
_name = 'coda.bank.statement' _name = 'coda.bank.statement'
_description = 'CODA Bank Statement' _description = 'CODA Bank Statement'
def _default_journal_id(self, cr, uid, context={}): def _default_journal_id(self, cr, uid, context=None):
if context is None:
context = {}
if context.get('journal_id', False): if context.get('journal_id', False):
return context['journal_id'] return context['journal_id']
return False return False
@ -233,7 +235,7 @@ class coda_bank_statement(osv.osv):
res[r] = round(res[r], 2) res[r] = round(res[r], 2)
return res return res
def _get_period(self, cr, uid, context={}): def _get_period(self, cr, uid, context=None):
periods = self.pool.get('account.period').find(cr, uid) periods = self.pool.get('account.period').find(cr, uid)
if periods: if periods:
return periods[0] return periods[0]

View File

@ -209,7 +209,7 @@ class account_followup_print_all(osv.osv_memory):
to_update[str(id)]= {'level': fups[followup_line_id][1], 'partner_id': stat_line_id} to_update[str(id)]= {'level': fups[followup_line_id][1], 'partner_id': stat_line_id}
return {'partner_ids': partner_list, 'to_update': to_update} return {'partner_ids': partner_list, 'to_update': to_update}
def do_mail(self ,cr, uid, ids, context=None): def do_mail(self, cr, uid, ids, context=None):
mod_obj = self.pool.get('ir.model.data') mod_obj = self.pool.get('ir.model.data')
move_obj = self.pool.get('account.move.line') move_obj = self.pool.get('account.move.line')
user_obj = self.pool.get('res.users') user_obj = self.pool.get('res.users')

View File

@ -26,7 +26,7 @@ from tools.translate import _
class account_move_line(osv.osv): class account_move_line(osv.osv):
_inherit = "account.move.line" _inherit = "account.move.line"
def amount_to_pay(self, cr, uid, ids, name, arg={}, context=None): def amount_to_pay(self, cr, uid, ids, name, arg=None, context=None):
""" Return the amount still to pay regarding all the payemnt orders """ Return the amount still to pay regarding all the payemnt orders
(excepting cancelled orders)""" (excepting cancelled orders)"""
if not ids: if not ids:

View File

@ -139,7 +139,9 @@ class payment_order(osv.osv):
wf_service.trg_validate(uid, 'payment.order', ids[0], 'done', cr) wf_service.trg_validate(uid, 'payment.order', ids[0], 'done', cr)
return True return True
def copy(self, cr, uid, id, default={}, context=None): def copy(self, cr, uid, id, default=None, context=None):
if default is None:
default = {}
default.update({ default.update({
'state': 'draft', 'state': 'draft',
'line_ids': [], 'line_ids': [],

View File

@ -77,7 +77,7 @@ class payment_order(report_sxw.rml_parse):
user = pool.get('res.users').browse(self.cr, self.uid, self.uid) user = pool.get('res.users').browse(self.cr, self.uid, self.uid)
return user.company_id and user.company_id.currency_id and user.company_id.currency_id.symbol or False return user.company_id and user.company_id.currency_id and user.company_id.currency_id.symbol or False
def _get_account_name(self,bank_id): def _get_account_name(self, bank_id):
if bank_id: if bank_id:
pool = pooler.get_pool(self.cr.dbname) pool = pooler.get_pool(self.cr.dbname)
value_name = pool.get('res.partner.bank').name_get(self.cr, self.uid, [bank_id]) value_name = pool.get('res.partner.bank').name_get(self.cr, self.uid, [bank_id])

View File

@ -830,7 +830,7 @@ class account_voucher(osv.osv):
res['account_id'] = account_id res['account_id'] = account_id
return {'value':res} return {'value':res}
def _sel_context(self, cr, uid, voucher_id,context=None): def _sel_context(self, cr, uid, voucher_id, context=None):
""" """
Select the context to use accordingly if it needs to be multicurrency or not. Select the context to use accordingly if it needs to be multicurrency or not.
@ -1251,7 +1251,9 @@ class account_voucher(osv.osv):
move_line_pool.reconcile_partial(cr, uid, rec_ids, writeoff_acc_id=voucher.writeoff_acc_id.id, writeoff_period_id=voucher.period_id.id, writeoff_journal_id=voucher.journal_id.id) move_line_pool.reconcile_partial(cr, uid, rec_ids, writeoff_acc_id=voucher.writeoff_acc_id.id, writeoff_period_id=voucher.period_id.id, writeoff_journal_id=voucher.journal_id.id)
return True return True
def copy(self, cr, uid, id, default={}, context=None): def copy(self, cr, uid, id, default=None, context=None):
if default is None:
default = {}
default.update({ default.update({
'state': 'draft', 'state': 'draft',
'number': False, 'number': False,

View File

@ -219,7 +219,7 @@ class account_analytic_account(osv.osv):
default['line_ids'] = [] default['line_ids'] = []
return super(account_analytic_account, self).copy(cr, uid, id, default, context=context) return super(account_analytic_account, self).copy(cr, uid, id, default, context=context)
def on_change_partner_id(self, cr, uid, id, partner_id, context={}): def on_change_partner_id(self, cr, uid, id, partner_id, context=None):
if not partner_id: if not partner_id:
return {'value': {'contact_id': False}} return {'value': {'contact_id': False}}
addr = self.pool.get('res.partner').address_get(cr, uid, [partner_id], ['invoice']) addr = self.pool.get('res.partner').address_get(cr, uid, [partner_id], ['invoice'])

View File

@ -350,7 +350,7 @@ class ir_model_fields_anonymize_wizard(osv.osv_memory):
}) })
raise osv.except_osv(error_type, error_msg) raise osv.except_osv(error_type, error_msg)
def anonymize_database(self,cr, uid, ids, context=None): def anonymize_database(self, cr, uid, ids, context=None):
"""Sets the 'anonymized' state to defined fields""" """Sets the 'anonymized' state to defined fields"""
# create a new history record: # create a new history record:
@ -485,7 +485,7 @@ class ir_model_fields_anonymize_wizard(osv.osv_memory):
'target':'new', 'target':'new',
} }
def reverse_anonymize_database(self,cr, uid, ids, context=None): def reverse_anonymize_database(self, cr, uid, ids, context=None):
"""Set the 'clear' state to defined fields""" """Set the 'clear' state to defined fields"""
ir_model_fields_anonymization_model = self.pool.get('ir.model.fields.anonymization') ir_model_fields_anonymization_model = self.pool.get('ir.model.fields.anonymization')

View File

@ -533,7 +533,7 @@ class auction_lots(osv.osv):
return self._sum_taxes_by_type_and_id(costs) return self._sum_taxes_by_type_and_id(costs)
# sum remise limite net and ristourne # sum remise limite net and ristourne
def compute_seller_costs_summed(self, cr, uid, ids): #ach_pay_id def compute_seller_costs_summed(self, cr, uid, ids):
"""This Fuction sum Net remittance limit and refund""" """This Fuction sum Net remittance limit and refund"""

View File

@ -114,7 +114,7 @@ def _encode39(str, cksum):
class _Code39Base(Barcode): class _Code39Base(Barcode):
def __init__(self, value = "", **args): def __init__(self, value="", **args):
self.xdim = inch * 0.0075 self.xdim = inch * 0.0075
self.lquiet = None self.lquiet = None
self.rquiet = None self.rquiet = None

View File

@ -39,7 +39,7 @@ class Barcode(Flowable):
"""Abstract Base for barcodes. Includes implementations of """Abstract Base for barcodes. Includes implementations of
some methods suitable for the more primitive barcode types""" some methods suitable for the more primitive barcode types"""
def __init__(self, value = ''): def __init__(self, value=''):
self.value = value self.value = value
if not hasattr(self, 'gap'): if not hasattr(self, 'gap'):

View File

@ -26,7 +26,7 @@ class auction_invoice(report_int):
def __init__(self, name): def __init__(self, name):
report_int.__init__(self, name) report_int.__init__(self, name)
def create(self,cr, uid, ids, datas, context): def create(self, cr, uid, ids, datas, context):
lots = self.pool.get('auction.lots').read(cr, uid, ids, ['ach_inv_id'], context=context) lots = self.pool.get('auction.lots').read(cr, uid, ids, ['ach_inv_id'], context=context)
invoices = {} invoices = {}

View File

@ -65,7 +65,7 @@ class auction_total_rml(report_sxw.rml_parse):
return auct_dat return auct_dat
def sum_taxes(self,auction_id): def sum_taxes(self, auction_id):
self.cr.execute("select count(1) from auction_lots where id IN %s and auction_id=%s group by auction_id ", (tuple(self.total_obj),auction_id,)) self.cr.execute("select count(1) from auction_lots where id IN %s and auction_id=%s group by auction_id ", (tuple(self.total_obj),auction_id,))
res = self.cr.fetchone() res = self.cr.fetchone()
return res[0] return res[0]
@ -105,17 +105,17 @@ class auction_total_rml(report_sxw.rml_parse):
res = self.cr.fetchone() res = self.cr.fetchone()
return str(res[0]) or 0.0 return str(res[0]) or 0.0
def sum_credit(self,auction_id): def sum_credit(self, auction_id):
self.cr.execute("select sum(buyer_price) from auction_lots where id IN %s and auction_id=%s", (tuple(self.total_obj),auction_id,)) self.cr.execute("select sum(buyer_price) from auction_lots where id IN %s and auction_id=%s", (tuple(self.total_obj),auction_id,))
res = self.cr.fetchone() res = self.cr.fetchone()
return str(res[0]) return str(res[0])
def sum_debit_buyer(self,auction_id): def sum_debit_buyer(self, auction_id):
self.cr.execute("select sum(buyer_price) from auction_lots where id IN %s and auction_id=%s", (tuple(self.total_obj),auction_id,)) self.cr.execute("select sum(buyer_price) from auction_lots where id IN %s and auction_id=%s", (tuple(self.total_obj),auction_id,))
res = self.cr.fetchone() res = self.cr.fetchone()
return str(res[0] or 0) return str(res[0] or 0)
def sum_debit(self,object_id): def sum_debit(self, object_id):
self.cr.execute("select sum(seller_price) from auction_lots where auction_id=%s", (object_id,)) self.cr.execute("select sum(seller_price) from auction_lots where auction_id=%s", (object_id,))
res = self.cr.fetchone() res = self.cr.fetchone()
return str(res[0] or 0) return str(res[0] or 0)

View File

@ -58,7 +58,7 @@ class buyer_form_report(report_sxw.rml_parse):
lots.append(object) lots.append(object)
return ret_dict.values() return ret_dict.values()
def grand_buyer_total(self,o): def grand_buyer_total(self, o):
grand_total = 0 grand_total = 0
for oo in o: for oo in o:
grand_total =grand_total + oo['obj_price'] +self.sum_taxes(oo) grand_total =grand_total + oo['obj_price'] +self.sum_taxes(oo)

View File

@ -62,7 +62,7 @@ class buyer_list(report_sxw.rml_parse):
auct_dat.append(auc_dates_fields) auct_dat.append(auc_dates_fields)
return auct_dat return auct_dat
def lines_lots_auct_lot(self,obj): def lines_lots_auct_lot(self, obj):
auc_date_ids = self.pool.get('auction.dates').search(self.cr, self.uid, ([('name','like',obj['name'])])) auc_date_ids = self.pool.get('auction.dates').search(self.cr, self.uid, ([('name','like',obj['name'])]))

View File

@ -30,7 +30,7 @@ class report_custom(report_rml):
def __init__(self, name, table, tmpl, xsl): def __init__(self, name, table, tmpl, xsl):
report_rml.__init__(self, name, table, tmpl, xsl) report_rml.__init__(self, name, table, tmpl, xsl)
def create_xml(self,cr, uid, ids, datas, context=None): def create_xml(self, cr, uid, ids, datas, context=None):
pool= pooler.get_pool(cr.dbname) pool= pooler.get_pool(cr.dbname)
lots = pool.get('auction.lots').browse(cr, uid, ids, context=context) lots = pool.get('auction.lots').browse(cr, uid, ids, context=context)
auction = lots[0].auction_id auction = lots[0].auction_id

View File

@ -19,7 +19,7 @@
# #
############################################################################## ##############################################################################
def convert_catalog(from_file, to_file, size=220) : def convert_catalog(from_file, to_file, size=220):
return __convert(from_file, to_file, size) return __convert(from_file, to_file, size)
def convert(from_file, to_file): def convert(from_file, to_file):

View File

@ -58,7 +58,7 @@ class seller_form_report(report_sxw.rml_parse):
lots = partner.get('lots') lots = partner.get('lots')
lots.append(object) lots.append(object)
return ret_dict.values() return ret_dict.values()
def grand_seller_total(self,o): def grand_seller_total(self, o):
grand_total = 0 grand_total = 0
for oo in o: for oo in o:
grand_total =grand_total + oo['obj_price']+ self.sum_taxes(oo) grand_total =grand_total + oo['obj_price']+ self.sum_taxes(oo)

View File

@ -201,7 +201,7 @@ class audittrail_objects_proxy(object_proxy):
res = value res = value
return res return res
def create_log_line(self, cr, uid, log_id, model, lines=[]): def create_log_line(self, cr, uid, log_id, model, lines=None):
""" """
Creates lines for changed fields with its old and new values Creates lines for changed fields with its old and new values
@ -210,6 +210,8 @@ class audittrail_objects_proxy(object_proxy):
@param model: Object which values are being changed @param model: Object which values are being changed
@param lines: List of values for line is to be created @param lines: List of values for line is to be created
""" """
if lines is None:
lines = []
pool = pooler.get_pool(cr.dbname) pool = pooler.get_pool(cr.dbname)
obj_pool = pool.get(model.model) obj_pool = pool.get(model.model)
model_pool = pool.get('ir.model') model_pool = pool.get('ir.model')
@ -348,7 +350,7 @@ class audittrail_objects_proxy(object_proxy):
data[(model.id, resource_id)] = {'text':values_text, 'value': values} data[(model.id, resource_id)] = {'text':values_text, 'value': values}
return data return data
def prepare_audittrail_log_line(self, cr, uid, pool, model, resource_id, method, old_values, new_values, field_list=[]): def prepare_audittrail_log_line(self, cr, uid, pool, model, resource_id, method, old_values, new_values, field_list=None):
""" """
This function compares the old data (i.e before the method was executed) and the new data This function compares the old data (i.e before the method was executed) and the new data
(after the method was executed) and returns a structure with all the needed information to (after the method was executed) and returns a structure with all the needed information to
@ -378,6 +380,8 @@ class audittrail_objects_proxy(object_proxy):
record (res.partner, for example), we may have to log a change done in a x2many field (on record (res.partner, for example), we may have to log a change done in a x2many field (on
res.partner.address, for example) res.partner.address, for example)
""" """
if field_list is None:
field_list = []
key = (model.id, resource_id) key = (model.id, resource_id)
lines = { lines = {
key: [] key: []
@ -416,7 +420,7 @@ class audittrail_objects_proxy(object_proxy):
lines[key].append(data) lines[key].append(data)
return lines return lines
def process_data(self, cr, uid, pool, res_ids, model, method, old_values={}, new_values={}, field_list=[]): def process_data(self, cr, uid, pool, res_ids, model, method, old_values=None, new_values=None, field_list=None):
""" """
This function processes and iterates recursively to log the difference between the old This function processes and iterates recursively to log the difference between the old
data (i.e before the method was executed) and the new data and creates audittrail log data (i.e before the method was executed) and the new data and creates audittrail log

View File

@ -175,7 +175,7 @@ class res_partner_address(osv.osv):
ids = self.pool.get('res.partner.location').search(cr, uid, [('partner_id','=',context['default_partner_id'])], context=context) ids = self.pool.get('res.partner.location').search(cr, uid, [('partner_id','=',context['default_partner_id'])], context=context)
return ids and ids[0] or False return ids and ids[0] or False
def onchange_location_id(self,cr, uid, ids, location_id=False, context={}): def onchange_location_id(self, cr, uid, ids, location_id=False, context=None):
if not location_id: if not location_id:
return {} return {}
location = self.pool.get('res.partner.location').browse(cr, uid, location_id, context=context) location = self.pool.get('res.partner.location').browse(cr, uid, location_id, context=context)
@ -209,7 +209,7 @@ class res_partner_address(osv.osv):
'name' : fields.related('contact_id', 'name', type='char', size=64, string="Contact Name", store=True), 'name' : fields.related('contact_id', 'name', type='char', size=64, string="Contact Name", store=True),
'title' : fields.related('contact_id', 'title', type='many2one', relation='res.partner.title', string="Title", store=True), 'title' : fields.related('contact_id', 'title', type='many2one', relation='res.partner.title', string="Title", store=True),
} }
def create(self, cr, uid, data, context={}): def create(self, cr, uid, data, context=None):
if not data.get('location_id', False): if not data.get('location_id', False):
loc_id = self.pool.get('res.partner.location').create(cr, uid, { loc_id = self.pool.get('res.partner.location').create(cr, uid, {
'street': data.get('street',''), 'street': data.get('street',''),
@ -241,7 +241,7 @@ class res_partner_address(osv.osv):
'location_id': _default_location_id 'location_id': _default_location_id
} }
def default_get(self, cr, uid, fields=[], context=None): def default_get(self, cr, uid, fields=None, context=None):
if context is None: if context is None:
context = {} context = {}
if 'default_type' in context: if 'default_type' in context:

View File

@ -45,7 +45,9 @@ from service import security
magic_md5 = '$1$' magic_md5 = '$1$'
def gen_salt( length=8, symbols=ascii_letters + digits ): def gen_salt( length=8, symbols=None):
if symbols is None:
symbols = ascii_letters + digits
seed() seed()
return ''.join( sample( symbols, length ) ) return ''.join( sample( symbols, length ) )

View File

@ -115,7 +115,9 @@ class abstract_quality_check(object):
self.log.debug('get_objects() obj_list: %s', ','.join(obj_list)) self.log.debug('get_objects() obj_list: %s', ','.join(obj_list))
return obj_list return obj_list
def get_model_ids(self, cr, uid, models=[]): def get_model_ids(self, cr, uid, models=None):
if models is None:
models = []
# This function returns all ids of the given objects.. # This function returns all ids of the given objects..
if not models: if not models:
return [] return []
@ -133,7 +135,12 @@ class abstract_quality_check(object):
result_ids[obj] = ids result_ids[obj] = ids
return result_ids return result_ids
def format_table(self, header=[], data_list={}): #This function can work forwidget="text_wiki" def format_table(self, header=None, data_list=None):
#This function can work forwidget="text_wiki"
if header is None:
header = []
if data_list is None:
data_list = {}
detail = "" detail = ""
detail += (header[0]) % tuple(header[1]) detail += (header[0]) % tuple(header[1])
frow = '\n|-' frow = '\n|-'
@ -144,7 +151,12 @@ class abstract_quality_check(object):
detail = detail + '\n|}' detail = detail + '\n|}'
return detail return detail
def format_html_table(self, header=[], data_list=[]): #This function can work for widget="html_tag" def format_html_table(self, header=None, data_list=None):
#This function can work for widget="html_tag"
if header is None:
header = []
if data_list is None:
data_list = []
# function create html table.... # function create html table....
detail = "" detail = ""
detail += (header[0]) % tuple(header[1]) detail += (header[0]) % tuple(header[1])

View File

@ -127,7 +127,7 @@ class base_module_record_objects(osv.osv_memory):
_name = 'base.module.record.objects' _name = 'base.module.record.objects'
_description = "Base Module Record Objects" _description = "Base Module Record Objects"
def inter_call(self,cr,uid,data,context=None): def inter_call(self, cr, uid, data, context=None):
res=base_module_save._create_module(self, cr, uid, data, context) res=base_module_save._create_module(self, cr, uid, data, context)
mod_obj = self.pool.get('ir.model.data') mod_obj = self.pool.get('ir.model.data')
model_data_ids = mod_obj.search(cr, uid,[('model', '=', 'ir.ui.view'), ('name', '=', 'module_create_form_view')], context=context) model_data_ids = mod_obj.search(cr, uid,[('model', '=', 'ir.ui.view'), ('name', '=', 'module_create_form_view')], context=context)

View File

@ -42,11 +42,11 @@ import copy
class DomApiGeneral: class DomApiGeneral:
"""General DOM API utilities.""" """General DOM API utilities."""
def __init__(self,content_string="",file=""): def __init__(self, content_string="", file=""):
self.content_string = content_string self.content_string = content_string
self.re_digits = re.compile(r"(.*?\d)(pt|cm|mm|inch|in)") self.re_digits = re.compile(r"(.*?\d)(pt|cm|mm|inch|in)")
def _unitTuple(self,string): def _unitTuple(self, string):
"""Split values and units to a tuple.""" """Split values and units to a tuple."""
temp = self.re_digits.findall(string) temp = self.re_digits.findall(string)
if not temp: if not temp:
@ -54,13 +54,15 @@ class DomApiGeneral:
else: else:
return (temp[0]) return (temp[0])
def stringPercentToFloat(self,string): def stringPercentToFloat(self, string):
temp = string.replace("""%""","") temp = string.replace("""%""","")
return float(temp)/100 return float(temp)/100
def findChildrenByName(self,parent,name,attr_dict={}): def findChildrenByName(self, parent, name, attr_dict=None):
"""Helper functions. Does not work recursively. """Helper functions. Does not work recursively.
Optional: also test for certain attribute/value pairs.""" Optional: also test for certain attribute/value pairs."""
if attr_dict is None:
attr_dict = {}
children = [] children = []
for c in parent.childNodes: for c in parent.childNodes:
if c.nodeType == c.ELEMENT_NODE and c.nodeName == name: if c.nodeType == c.ELEMENT_NODE and c.nodeName == name:
@ -70,7 +72,7 @@ class DomApiGeneral:
else: else:
return self._selectForAttributes(nodelist=children,attr_dict=attr_dict) return self._selectForAttributes(nodelist=children,attr_dict=attr_dict)
def _selectForAttributes(self,nodelist,attr_dict): def _selectForAttributes(self, nodelist, attr_dict):
"Helper function.""" "Helper function."""
selected_nodes = [] selected_nodes = []
for n in nodelist: for n in nodelist:
@ -83,7 +85,7 @@ class DomApiGeneral:
selected_nodes.append(n) selected_nodes.append(n)
return selected_nodes return selected_nodes
def _stringToTuple(self,s): def _stringToTuple(self, s):
"""Helper function.""" """Helper function."""
try: try:
temp = string.split(s,",") temp = string.split(s,",")
@ -91,13 +93,13 @@ class DomApiGeneral:
except: except:
return None return None
def _tupleToString(self,t): def _tupleToString(self, t):
try: try:
return self.openOfficeStringUtf8("%s,%s" % (t[0],t[1])) return self.openOfficeStringUtf8("%s,%s" % (t[0],t[1]))
except: except:
return None return None
def _lengthToFloat(self,value): def _lengthToFloat(self, value):
v = value v = value
if not self.re_digits.search(v): if not self.re_digits.search(v):
return v return v
@ -113,7 +115,7 @@ class DomApiGeneral:
except: except:
return v return v
def openOfficeStringUtf8(self,string): def openOfficeStringUtf8(self, string):
if type(string) == unicode: if type(string) == unicode:
return string.encode("utf-8") return string.encode("utf-8")
tempstring = unicode(string,"cp1252").encode("utf-8") tempstring = unicode(string,"cp1252").encode("utf-8")
@ -121,7 +123,7 @@ class DomApiGeneral:
class DomApi(DomApiGeneral): class DomApi(DomApiGeneral):
"""This class provides a DOM-API for XML-Files from an SXW-Archive.""" """This class provides a DOM-API for XML-Files from an SXW-Archive."""
def __init__(self,xml_content,xml_styles): def __init__(self, xml_content, xml_styles):
DomApiGeneral.__init__(self) DomApiGeneral.__init__(self)
self.content_dom = xml.dom.minidom.parseString(xml_content) self.content_dom = xml.dom.minidom.parseString(xml_content)
self.styles_dom = xml.dom.minidom.parseString(xml_styles) self.styles_dom = xml.dom.minidom.parseString(xml_styles)
@ -145,7 +147,7 @@ class DomApi(DomApiGeneral):
for s in self.style_dict.keys(): for s in self.style_dict.keys():
self.style_properties_dict[s] = self.getStylePropertiesDict(s) self.style_properties_dict[s] = self.getStylePropertiesDict(s)
def updateWithPercents(self,dict,updatedict): def updateWithPercents(self, dict, updatedict):
"""Sometimes you find values like "115%" in the style hierarchy.""" """Sometimes you find values like "115%" in the style hierarchy."""
if not updatedict: if not updatedict:
# no style hierarchies for this style? => # no style hierarchies for this style? =>
@ -244,7 +246,7 @@ class DomApi(DomApiGeneral):
def toxml(self): def toxml(self):
return self.content_dom.toxml(encoding="utf-8") return self.content_dom.toxml(encoding="utf-8")
def getStylePropertiesDict(self,style_name): def getStylePropertiesDict(self, style_name):
res = {} res = {}
if self.style_dict[style_name].hasAttribute("style:parent-style-name"): if self.style_dict[style_name].hasAttribute("style:parent-style-name"):
@ -265,7 +267,7 @@ class PyOpenOffice(object):
self.save_pict = save_pict self.save_pict = save_pict
self.images = {} self.images = {}
def oo_read(self,fname): def oo_read(self, fname):
z = zipfile.ZipFile(fname,"r") z = zipfile.ZipFile(fname,"r")
content = z.read('content.xml') content = z.read('content.xml')
style = z.read('styles.xml') style = z.read('styles.xml')
@ -281,7 +283,7 @@ class PyOpenOffice(object):
z.close() z.close()
return content,style return content,style
def oo_replace(self,content): def oo_replace(self, content):
regex = [ regex = [
(r"<para[^>]*/>", ""), (r"<para[^>]*/>", ""),
(r"<para(.*)>(.*?)<text:line-break[^>]*/>", "<para$1>$2</para><para$1>"), (r"<para(.*)>(.*?)<text:line-break[^>]*/>", "<para$1>$2</para><para$1>"),
@ -290,7 +292,7 @@ class PyOpenOffice(object):
content = re.sub(key, val, content) content = re.sub(key, val, content)
return content return content
def unpackNormalize(self,sourcefile): def unpackNormalize(self, sourcefile):
c,s = self.oo_read(sourcefile) c,s = self.oo_read(sourcefile)
c = self.oo_replace(c) c = self.oo_replace(c)
dom = DomApi(c,s) dom = DomApi(c,s)

View File

@ -52,7 +52,7 @@ if __name__<>'package':
from lib.gui import * from lib.gui import *
class About(unohelper.Base, XJobExecutor): class About(unohelper.Base, XJobExecutor):
def __init__(self,ctx): def __init__(self, ctx):
self.ctx = ctx self.ctx = ctx
self.module = "openerp_report" self.module = "openerp_report"
self.version = "0.1" self.version = "0.1"

View File

@ -64,7 +64,7 @@ class AddAttachment(unohelper.Base, XJobExecutor ):
'PDF' : 'pdf', 'PDF' : 'pdf',
'OpenOffice': 'sxw', 'OpenOffice': 'sxw',
} }
def __init__(self,ctx): def __init__(self, ctx):
self.ctx = ctx self.ctx = ctx
self.module = "openerp_report" self.module = "openerp_report"
self.version = "0.1" self.version = "0.1"
@ -132,7 +132,7 @@ class AddAttachment(unohelper.Base, XJobExecutor ):
self.win.addButton('btnCancel', -2 - 27 , -5 , 30 , 15, 'Cancel' ,actionListenerProc = self.btnCancel_clicked ) self.win.addButton('btnCancel', -2 - 27 , -5 , 30 , 15, 'Cancel' ,actionListenerProc = self.btnCancel_clicked )
self.win.doModalDialog("lstResourceType", self.Kind.keys()[0]) self.win.doModalDialog("lstResourceType", self.Kind.keys()[0])
def btnSearch_clicked( self, oActionEvent ): def btnSearch_clicked(self, oActionEvent):
modelSelectedItem = self.win.getListBoxSelectedItem("lstmodel") modelSelectedItem = self.win.getListBoxSelectedItem("lstmodel")
if modelSelectedItem == "": if modelSelectedItem == "":
return return
@ -151,7 +151,7 @@ class AddAttachment(unohelper.Base, XJobExecutor ):
for result in self.aSearchResult: for result in self.aSearchResult:
self.lstResource.addItem(result[1],result[0]) self.lstResource.addItem(result[1],result[0])
def _send_attachment( self, name, data, res_model, res_id ): def _send_attachment(self, name, data, res_model, res_id):
desktop = getDesktop() desktop = getDesktop()
oDoc2 = desktop.getCurrentComponent() oDoc2 = desktop.getCurrentComponent()
docinfo = oDoc2.getDocumentInfo() docinfo = oDoc2.getDocumentInfo()
@ -166,7 +166,7 @@ class AddAttachment(unohelper.Base, XJobExecutor ):
return self.sock.execute( database, uid, self.password, 'ir.attachment', 'create', params ) return self.sock.execute( database, uid, self.password, 'ir.attachment', 'create', params )
def send_attachment( self, model, resource_id ): def send_attachment(self, model, resource_id):
desktop = getDesktop() desktop = getDesktop()
oDoc2 = desktop.getCurrentComponent() oDoc2 = desktop.getCurrentComponent()
docinfo = oDoc2.getDocumentInfo() docinfo = oDoc2.getDocumentInfo()
@ -187,7 +187,7 @@ class AddAttachment(unohelper.Base, XJobExecutor ):
data = read_data_from_file( get_absolute_file_path( url ) ) data = read_data_from_file( get_absolute_file_path( url ) )
return self._send_attachment( os.path.basename( url ), data, model, resource_id ) return self._send_attachment( os.path.basename( url ), data, model, resource_id )
def btnOkWithoutInformation_clicked( self, oActionEvent ): def btnOkWithoutInformation_clicked(self, oActionEvent):
desktop = getDesktop() desktop = getDesktop()
oDoc2 = desktop.getCurrentComponent() oDoc2 = desktop.getCurrentComponent()
docinfo = oDoc2.getDocumentInfo() docinfo = oDoc2.getDocumentInfo()
@ -199,7 +199,7 @@ class AddAttachment(unohelper.Base, XJobExecutor ):
res = self.send_attachment( docinfo.getUserFieldValue(3), docinfo.getUserFieldValue(2) ) res = self.send_attachment( docinfo.getUserFieldValue(3), docinfo.getUserFieldValue(2) )
self.win.endExecute() self.win.endExecute()
def btnOkWithInformation_clicked(self,oActionEvent): def btnOkWithInformation_clicked(self, oActionEvent):
if self.win.getListBoxSelectedItem("lstResourceType") == "": if self.win.getListBoxSelectedItem("lstResourceType") == "":
ErrorDialog( "Please select resource type", "", "Selection ERROR" ) ErrorDialog( "Please select resource type", "", "Selection ERROR" )
return return
@ -221,7 +221,7 @@ class AddAttachment(unohelper.Base, XJobExecutor ):
res = self.send_attachment( self.dModel[self.win.getListBoxSelectedItem('lstmodel')], resourceid ) res = self.send_attachment( self.dModel[self.win.getListBoxSelectedItem('lstmodel')], resourceid )
self.win.endExecute() self.win.endExecute()
def btnCancel_clicked( self, oActionEvent ): def btnCancel_clicked(self, oActionEvent):
self.win.endExecute() self.win.endExecute()
def doc2pdf(self, strFile): def doc2pdf(self, strFile):
@ -262,7 +262,7 @@ class AddAttachment(unohelper.Base, XJobExecutor ):
# Can be None if len(strFilterSubName) <= 0 # Can be None if len(strFilterSubName) <= 0
return filename return filename
def _MakePropertyValue(self, cName = "", uValue = u"" ): def _MakePropertyValue(self, cName="", uValue=u"" ):
oPropertyValue = createUnoStruct( "com.sun.star.beans.PropertyValue" ) oPropertyValue = createUnoStruct( "com.sun.star.beans.PropertyValue" )
if cName: if cName:
oPropertyValue.Name = cName oPropertyValue.Name = cName

View File

@ -59,7 +59,7 @@ if __name__<>"package":
database="test" database="test"
class Change( unohelper.Base, XJobExecutor ): class Change( unohelper.Base, XJobExecutor ):
def __init__(self,ctx): def __init__(self, ctx):
self.ctx = ctx self.ctx = ctx
self.module = "openerp_report" self.module = "openerp_report"
self.version = "0.1" self.version = "0.1"
@ -107,7 +107,7 @@ class Change( unohelper.Base, XJobExecutor ):
self.lstProtocol.addItem(i,self.lstProtocol.getItemCount() ) self.lstProtocol.addItem(i,self.lstProtocol.getItemCount() )
self.win.doModalDialog( "lstProtocol", protocol) self.win.doModalDialog( "lstProtocol", protocol)
def btnNext_clicked(self,oActionEvent): def btnNext_clicked(self, oActionEvent):
global url global url
aVal='' aVal=''
#aVal= Fetature used #aVal= Fetature used

View File

@ -63,7 +63,7 @@ if __name__<>"package":
class ConvertBracesToField( unohelper.Base, XJobExecutor ): class ConvertBracesToField( unohelper.Base, XJobExecutor ):
def __init__(self,ctx): def __init__(self, ctx):
self.ctx = ctx self.ctx = ctx
self.module = "openerp_report" self.module = "openerp_report"
@ -198,7 +198,7 @@ class ConvertBracesToField( unohelper.Base, XJobExecutor ):
info = reduce(lambda x, y: x+y, traceback.format_exception(sys.exc_type, sys.exc_value, sys.exc_traceback)) info = reduce(lambda x, y: x+y, traceback.format_exception(sys.exc_type, sys.exc_value, sys.exc_traceback))
self.logobj.log_write('ConvertBraceToField', LOG_ERROR, info) self.logobj.log_write('ConvertBraceToField', LOG_ERROR, info)
def getRes(self,sock,sObject,sVar): def getRes(self, sock, sObject, sVar):
desktop=getDesktop() desktop=getDesktop()
doc =desktop.getCurrentComponent() doc =desktop.getCurrentComponent()
docinfo=doc.getDocumentInfo() docinfo=doc.getDocumentInfo()
@ -215,7 +215,7 @@ class ConvertBracesToField( unohelper.Base, XJobExecutor ):
sObject = self.getRes(sock,res[myval]['relation'], sVar[sVar.find("/")+1:]) sObject = self.getRes(sock,res[myval]['relation'], sVar[sVar.find("/")+1:])
return sObject return sObject
def getBraces(self,aReportSyntex=[]): def getBraces(self, aReportSyntex=None):
desktop=getDesktop() desktop=getDesktop()
doc = desktop.getCurrentComponent() doc = desktop.getCurrentComponent()
aSearchString=[] aSearchString=[]

View File

@ -57,7 +57,7 @@ if __name__<>"package":
uid = 3 uid = 3
class ConvertFieldsToBraces( unohelper.Base, XJobExecutor ): class ConvertFieldsToBraces( unohelper.Base, XJobExecutor ):
def __init__(self,ctx): def __init__(self, ctx):
self.ctx = ctx self.ctx = ctx
self.module = "openerp_report" self.module = "openerp_report"
self.version = "0.1" self.version = "0.1"

View File

@ -67,7 +67,7 @@ if __name__<>"package":
class ExportToRML( unohelper.Base, XJobExecutor ): class ExportToRML( unohelper.Base, XJobExecutor ):
def __init__(self,ctx): def __init__(self, ctx):
self.ctx = ctx self.ctx = ctx
self.module = "openerp_report" self.module = "openerp_report"
self.version = "0.1" self.version = "0.1"

View File

@ -57,7 +57,7 @@ if __name__<>"package":
uid = 3 uid = 3
class Expression(unohelper.Base, XJobExecutor ): class Expression(unohelper.Base, XJobExecutor ):
def __init__(self,sExpression="",sName="", bFromModify=False): def __init__(self, sExpression="", sName="", bFromModify=False):
LoginTest() LoginTest()
if not loginstatus and __name__=="package": if not loginstatus and __name__=="package":
exit(1) exit(1)
@ -75,7 +75,7 @@ class Expression(unohelper.Base, XJobExecutor ):
self.win.doModalDialog("",None) self.win.doModalDialog("",None)
def btnOk_clicked( self, oActionEvent ): def btnOk_clicked(self, oActionEvent):
desktop=getDesktop() desktop=getDesktop()
doc = desktop.getCurrentComponent() doc = desktop.getCurrentComponent()
text = doc.Text text = doc.Text
@ -105,7 +105,7 @@ class Expression(unohelper.Base, XJobExecutor ):
else: else:
ErrorDialog("Please Fill appropriate data in Name field or \nExpression field") ErrorDialog("Please Fill appropriate data in Name field or \nExpression field")
def btnCancel_clicked( self, oActionEvent ): def btnCancel_clicked(self, oActionEvent):
self.win.endExecute() self.win.endExecute()
if __name__<>"package" and __name__=="__main__": if __name__<>"package" and __name__=="__main__":

View File

@ -64,7 +64,7 @@ if __name__<>"package":
class Fields(unohelper.Base, XJobExecutor ): class Fields(unohelper.Base, XJobExecutor ):
def __init__(self,sVariable="",sFields="",sDisplayName="",bFromModify=False): def __init__(self, sVariable="", sFields="", sDisplayName="", bFromModify=False):
LoginTest() LoginTest()
if not loginstatus and __name__=="package": if not loginstatus and __name__=="package":
exit(1) exit(1)
@ -177,7 +177,7 @@ class Fields(unohelper.Base, XJobExecutor ):
ErrorDialog("Please insert user define field Field-1 or Field-4","Just go to File->Properties->User Define \nField-1 Eg. http://localhost:8069 \nOR \nField-4 Eg. account.invoice") ErrorDialog("Please insert user define field Field-1 or Field-4","Just go to File->Properties->User Define \nField-1 Eg. http://localhost:8069 \nOR \nField-4 Eg. account.invoice")
self.win.endExecute() self.win.endExecute()
def lstbox_selected(self,oItemEvent): def lstbox_selected(self, oItemEvent):
try: try:
desktop=getDesktop() desktop=getDesktop()
@ -200,7 +200,7 @@ class Fields(unohelper.Base, XJobExecutor ):
if self.bModify: if self.bModify:
self.win.setEditText("txtUName",self.sGDisplayName) self.win.setEditText("txtUName",self.sGDisplayName)
def getRes(self,sock ,sObject,sVar): def getRes(self, sock, sObject, sVar):
desktop=getDesktop() desktop=getDesktop()
doc =desktop.getCurrentComponent() doc =desktop.getCurrentComponent()
docinfo=doc.getDocumentInfo() docinfo=doc.getDocumentInfo()
@ -219,7 +219,7 @@ class Fields(unohelper.Base, XJobExecutor ):
else: else:
return sObject return sObject
def cmbVariable_selected(self,oItemEvent): def cmbVariable_selected(self, oItemEvent):
if self.count > 0 : if self.count > 0 :
try: try:
desktop=getDesktop() desktop=getDesktop()
@ -246,7 +246,7 @@ class Fields(unohelper.Base, XJobExecutor ):
info = reduce(lambda x, y: x+y, traceback.format_exception(sys.exc_type, sys.exc_value, sys.exc_traceback)) info = reduce(lambda x, y: x+y, traceback.format_exception(sys.exc_type, sys.exc_value, sys.exc_traceback))
self.logobj.log_write('Fields', LOG_ERROR, info) self.logobj.log_write('Fields', LOG_ERROR, info)
def btnOk_clicked( self, oActionEvent ): def btnOk_clicked(self, oActionEvent):
desktop=getDesktop() desktop=getDesktop()
doc = desktop.getCurrentComponent() doc = desktop.getCurrentComponent()
cursor = doc.getCurrentController().getViewCursor() cursor = doc.getCurrentController().getViewCursor()
@ -281,7 +281,7 @@ class Fields(unohelper.Base, XJobExecutor ):
else: else:
ErrorDialog("Please Fill appropriate data in Name field \nor select perticular value from the list of fields") ErrorDialog("Please Fill appropriate data in Name field \nor select perticular value from the list of fields")
def btnCancel_clicked( self, oActionEvent ): def btnCancel_clicked(self, oActionEvent):
self.win.endExecute() self.win.endExecute()
if __name__<>"package" and __name__=="__main__": if __name__<>"package" and __name__=="__main__":

View File

@ -66,7 +66,7 @@ if __name__<>'package':
# #
class ModifyExistingReport(unohelper.Base, XJobExecutor): class ModifyExistingReport(unohelper.Base, XJobExecutor):
def __init__(self,ctx): def __init__(self, ctx):
self.ctx = ctx self.ctx = ctx
self.module = "openerp_report" self.module = "openerp_report"
self.version = "0.1" self.version = "0.1"
@ -178,10 +178,10 @@ class ModifyExistingReport(unohelper.Base, XJobExecutor):
self.win.endExecute() self.win.endExecute()
def btnCancel_clicked( self, oActionEvent ): def btnCancel_clicked(self, oActionEvent):
self.win.endExecute() self.win.endExecute()
def btnDelete_clicked( self, oActionEvent ): def btnDelete_clicked(self, oActionEvent):
desktop=getDesktop() desktop=getDesktop()
doc = desktop.getCurrentComponent() doc = desktop.getCurrentComponent()
docinfo=doc.getDocumentInfo() docinfo=doc.getDocumentInfo()

View File

@ -66,7 +66,7 @@ if __name__<>"package":
# #
# #
class NewReport(unohelper.Base, XJobExecutor): class NewReport(unohelper.Base, XJobExecutor):
def __init__(self,ctx): def __init__(self, ctx):
self.ctx = ctx self.ctx = ctx
self.module = "openerp_report" self.module = "openerp_report"
self.version = "0.1" self.version = "0.1"
@ -99,7 +99,7 @@ class NewReport(unohelper.Base, XJobExecutor):
self.win.addButton('btnCancel',-2 - 70 - 5 ,-5, 35,15,'Cancel' ,actionListenerProc = self.btnCancel_clicked ) self.win.addButton('btnCancel',-2 - 70 - 5 ,-5, 35,15,'Cancel' ,actionListenerProc = self.btnCancel_clicked )
self.win.doModalDialog("",None) self.win.doModalDialog("",None)
def btnOk_clicked(self,oActionEvent): def btnOk_clicked(self, oActionEvent):
desktop=getDesktop() desktop=getDesktop()
doc = desktop.getCurrentComponent() doc = desktop.getCurrentComponent()
docinfo=doc.getDocumentInfo() docinfo=doc.getDocumentInfo()
@ -107,7 +107,7 @@ class NewReport(unohelper.Base, XJobExecutor):
self.logobj.log_write('Module Name',LOG_INFO, ':Module use in creating a report %s using database %s' % (self.aModuleName[self.lstModule.getSelectedItemPos()], database)) self.logobj.log_write('Module Name',LOG_INFO, ':Module use in creating a report %s using database %s' % (self.aModuleName[self.lstModule.getSelectedItemPos()], database))
self.win.endExecute() self.win.endExecute()
def btnCancel_clicked( self, oActionEvent ): def btnCancel_clicked(self, oActionEvent):
self.win.endExecute() self.win.endExecute()
if __name__<>"package" and __name__=="__main__": if __name__<>"package" and __name__=="__main__":

View File

@ -64,7 +64,7 @@ if __name__<>"package":
#class RepeatIn: #class RepeatIn:
class RepeatIn( unohelper.Base, XJobExecutor ): class RepeatIn( unohelper.Base, XJobExecutor ):
def __init__(self,sObject="",sVariable="",sFields="",sDisplayName="",bFromModify=False): def __init__(self, sObject="", sVariable="", sFields="", sDisplayName="", bFromModify=False):
# Interface Design # Interface Design
LoginTest() LoginTest()
self.logobj=Logger() self.logobj=Logger()
@ -204,7 +204,7 @@ class RepeatIn( unohelper.Base, XJobExecutor ):
ErrorDialog("Please Select Appropriate module" ,"Create new report from: \nOpenERP -> Open a New Report") ErrorDialog("Please Select Appropriate module" ,"Create new report from: \nOpenERP -> Open a New Report")
self.win.endExecute() self.win.endExecute()
def lstbox_selected(self,oItemEvent): def lstbox_selected(self, oItemEvent):
sItem=self.win.getListBoxSelectedItem("lstFields") sItem=self.win.getListBoxSelectedItem("lstFields")
sMain=self.aListRepeatIn[self.win.getListBoxSelectedItemPos("lstFields")] sMain=self.aListRepeatIn[self.win.getListBoxSelectedItemPos("lstFields")]
@ -215,7 +215,7 @@ class RepeatIn( unohelper.Base, XJobExecutor ):
self.win.setEditText("txtName",sMain[sMain.rfind("/")+1:]) self.win.setEditText("txtName",sMain[sMain.rfind("/")+1:])
self.win.setEditText("txtUName","|-."+sItem[sItem.rfind("/")+1:]+".-|") self.win.setEditText("txtUName","|-."+sItem[sItem.rfind("/")+1:]+".-|")
def cmbVariable_selected(self,oItemEvent): def cmbVariable_selected(self, oItemEvent):
if self.count > 0 : if self.count > 0 :
@ -290,7 +290,7 @@ class RepeatIn( unohelper.Base, XJobExecutor ):
else: else:
ErrorDialog("Please Fill appropriate data in Object Field or Name field \nor select perticular value from the list of fields") ErrorDialog("Please Fill appropriate data in Object Field or Name field \nor select perticular value from the list of fields")
def btnCancel_clicked( self, oActionEvent ): def btnCancel_clicked(self, oActionEvent):
self.win.endExecute() self.win.endExecute()
if __name__<>"package" and __name__=="__main__": if __name__<>"package" and __name__=="__main__":

View File

@ -74,7 +74,7 @@ class SendtoServer(unohelper.Base, XJobExecutor):
'HTML' : 'html' 'HTML' : 'html'
} }
def __init__(self,ctx): def __init__(self, ctx):
self.ctx = ctx self.ctx = ctx
self.module = "openerp_report" self.module = "openerp_report"
self.version = "0.1" self.version = "0.1"
@ -138,10 +138,10 @@ class SendtoServer(unohelper.Base, XJobExecutor):
self.win.doModalDialog("lstResourceType", self.Kind.keys()[0]) self.win.doModalDialog("lstResourceType", self.Kind.keys()[0])
def lstbox_selected(self,oItemEvent): def lstbox_selected(self, oItemEvent):
pass pass
def btnCancel_clicked( self, oActionEvent ): def btnCancel_clicked(self, oActionEvent):
self.win.endExecute() self.win.endExecute()
def btnOk_clicked(self, oActionEvent): def btnOk_clicked(self, oActionEvent):
@ -223,7 +223,7 @@ class SendtoServer(unohelper.Base, XJobExecutor):
id=self.sock.execute(database, uid, self.password, 'ir.actions.report.xml' ,'create', params) id=self.sock.execute(database, uid, self.password, 'ir.actions.report.xml' ,'create', params)
return id return id
def getInverseFieldsRecord(self,nVal): def getInverseFieldsRecord(self, nVal):
desktop=getDesktop() desktop=getDesktop()
doc = desktop.getCurrentComponent() doc = desktop.getCurrentComponent()
count=0 count=0

View File

@ -59,7 +59,7 @@ if __name__<>"package":
database="test" database="test"
class ServerParameter( unohelper.Base, XJobExecutor ): class ServerParameter( unohelper.Base, XJobExecutor ):
def __init__(self, aVal= None, sURL=""): def __init__(self, aVal=None, sURL=""):
self.module = "openerp_report" self.module = "openerp_report"
self.version = "0.1" self.version = "0.1"
desktop=getDesktop() desktop=getDesktop()
@ -116,7 +116,7 @@ class ServerParameter( unohelper.Base, XJobExecutor ):
#self.win.doModalDialog("lstDatabase",docinfo.getUserFieldValue(2)) #self.win.doModalDialog("lstDatabase",docinfo.getUserFieldValue(2))
def btnOk_clicked(self,oActionEvent): def btnOk_clicked(self, oActionEvent):
sLogin=self.win.getEditText("txtLoginName") sLogin=self.win.getEditText("txtLoginName")
sPassword=self.win.getEditText("txtPassword") sPassword=self.win.getEditText("txtPassword")
@ -158,10 +158,10 @@ class ServerParameter( unohelper.Base, XJobExecutor ):
self.win.endExecute() self.win.endExecute()
def btnCancel_clicked( self, oActionEvent ): def btnCancel_clicked(self, oActionEvent):
self.win.endExecute() self.win.endExecute()
def btnPrevious_clicked(self,oActionEvent): def btnPrevious_clicked(self, oActionEvent):
self.win.endExecute() self.win.endExecute()
Change(None) Change(None)
self.win.endExecute() self.win.endExecute()

View File

@ -61,7 +61,7 @@ if __name__<>"package":
class AddLang(unohelper.Base, XJobExecutor ): class AddLang(unohelper.Base, XJobExecutor ):
def __init__(self,sVariable="",sFields="",sDisplayName="",bFromModify=False): def __init__(self, sVariable="", sFields="", sDisplayName="", bFromModify=False):
LoginTest() LoginTest()
if not loginstatus and __name__=="package": if not loginstatus and __name__=="package":
exit(1) exit(1)
@ -157,7 +157,7 @@ class AddLang(unohelper.Base, XJobExecutor ):
ErrorDialog("Please insert user define field Field-1 or Field-4","Just go to File->Properties->User Define \nField-1 Eg. http://localhost:8069 \nOR \nField-4 Eg. account.invoice") ErrorDialog("Please insert user define field Field-1 or Field-4","Just go to File->Properties->User Define \nField-1 Eg. http://localhost:8069 \nOR \nField-4 Eg. account.invoice")
self.win.endExecute() self.win.endExecute()
def lstbox_selected(self,oItemEvent): def lstbox_selected(self, oItemEvent):
try: try:
desktop=getDesktop() desktop=getDesktop()
@ -183,7 +183,7 @@ class AddLang(unohelper.Base, XJobExecutor ):
if self.bModify: if self.bModify:
self.win.setEditText("txtUName",self.sGDisplayName) self.win.setEditText("txtUName",self.sGDisplayName)
def getRes(self,sock ,sObject,sVar): def getRes(self, sock, sObject, sVar):
desktop=getDesktop() desktop=getDesktop()
doc =desktop.getCurrentComponent() doc =desktop.getCurrentComponent()
docinfo=doc.getDocumentInfo() docinfo=doc.getDocumentInfo()
@ -203,7 +203,7 @@ class AddLang(unohelper.Base, XJobExecutor ):
return sObject return sObject
def cmbVariable_selected(self,oItemEvent): def cmbVariable_selected(self, oItemEvent):
if self.count > 0 : if self.count > 0 :
try: try:
desktop=getDesktop() desktop=getDesktop()
@ -229,7 +229,7 @@ class AddLang(unohelper.Base, XJobExecutor ):
except: except:
import traceback;traceback.print_exc() import traceback;traceback.print_exc()
def btnOk_clicked( self, oActionEvent ): def btnOk_clicked(self, oActionEvent):
self.bOkay = True self.bOkay = True
desktop=getDesktop() desktop=getDesktop()
doc = desktop.getCurrentComponent() doc = desktop.getCurrentComponent()
@ -263,7 +263,7 @@ class AddLang(unohelper.Base, XJobExecutor ):
else: else:
ErrorDialog("Please Fill appropriate data in Name field \nor select perticular value from the list of fields") ErrorDialog("Please Fill appropriate data in Name field \nor select perticular value from the list of fields")
def btnCancel_clicked( self, oActionEvent ): def btnCancel_clicked(self, oActionEvent):
self.win.endExecute() self.win.endExecute()

View File

@ -48,7 +48,7 @@
if __name__<>"package": if __name__<>"package":
from gui import * from gui import *
class ErrorDialog: class ErrorDialog:
def __init__(self,sErrorMsg, sErrorHelpMsg="",sTitle="Error Message"): def __init__(self, sErrorMsg, sErrorHelpMsg="", sTitle="Error Message"):
self.win = DBModalDialog(50, 50, 150, 90, sTitle) self.win = DBModalDialog(50, 50, 150, 90, sTitle)
self.win.addFixedText("lblErrMsg", 5, 5, 190, 25, sErrorMsg) self.win.addFixedText("lblErrMsg", 5, 5, 190, 25, sErrorMsg)
self.win.addFixedText("lblErrHelpMsg", 5, 30, 190, 25, sErrorHelpMsg) self.win.addFixedText("lblErrHelpMsg", 5, 30, 190, 25, sErrorHelpMsg)

View File

@ -59,7 +59,13 @@ if __name__<>"package":
database="test" database="test"
uid = 1 uid = 1
def genTree(object,aList,insField,host,level=3, ending=[], ending_excl=[], recur=[], root='', actualroot=""): def genTree(object, aList, insField, host, level=3, ending=None, ending_excl=None, recur=None, root='', actualroot=""):
if ending is None:
ending = []
if ending_excl is None:
ending_excl = []
if recur is None:
recur = []
try: try:
global url global url
sock=RPCSession(url) sock=RPCSession(url)
@ -79,7 +85,7 @@ def genTree(object,aList,insField,host,level=3, ending=[], ending_excl=[], recur
info = reduce(lambda x, y: x+y, traceback.format_exception(sys.exc_type, sys.exc_value, sys.exc_traceback)) info = reduce(lambda x, y: x+y, traceback.format_exception(sys.exc_type, sys.exc_value, sys.exc_traceback))
obj.log_write('Function', LOG_ERROR, info) obj.log_write('Function', LOG_ERROR, info)
def VariableScope(oTcur,insVariable,aObjectList,aComponentAdd,aItemList,sTableName=""): def VariableScope(oTcur, insVariable, aObjectList, aComponentAdd, aItemList, sTableName=""):
if sTableName.find(".") != -1: if sTableName.find(".") != -1:
for i in range(len(aItemList)): for i in range(len(aItemList)):
if aComponentAdd[i]==sTableName: if aComponentAdd[i]==sTableName:
@ -96,7 +102,7 @@ def VariableScope(oTcur,insVariable,aObjectList,aComponentAdd,aItemList,sTableNa
if aObjectList[j][:aObjectList[j].find("(")] == sLVal and sLVal!="": if aObjectList[j][:aObjectList[j].find("(")] == sLVal and sLVal!="":
insVariable.append(aObjectList[j]) insVariable.append(aObjectList[j])
def getList(aObjectList,host,count): def getList(aObjectList, host, count):
desktop=getDesktop() desktop=getDesktop()
doc =desktop.getCurrentComponent() doc =desktop.getCurrentComponent()
docinfo=doc.getDocumentInfo() docinfo=doc.getDocumentInfo()
@ -128,7 +134,7 @@ def getList(aObjectList,host,count):
else: else:
aObjectList.append("List of " + docinfo.getUserFieldValue(3)) aObjectList.append("List of " + docinfo.getUserFieldValue(3))
def getRelation(sRelName, sItem, sObjName, aObjectList, host ): def getRelation(sRelName, sItem, sObjName, aObjectList, host):
global url global url
sock=RPCSession(url) sock=RPCSession(url)
global passwd global passwd
@ -143,7 +149,7 @@ def getRelation(sRelName, sItem, sObjName, aObjectList, host ):
getRelation(res[k]['relation'], sItem[sItem.find(".")+1:], sObjName,aObjectList,host) getRelation(res[k]['relation'], sItem[sItem.find(".")+1:], sObjName,aObjectList,host)
def getPath(sPath,sMain): def getPath(sPath, sMain):
desktop=getDesktop() desktop=getDesktop()
doc =desktop.getCurrentComponent() doc =desktop.getCurrentComponent()
oParEnum = doc.getTextFields().createEnumeration() oParEnum = doc.getTextFields().createEnumeration()
@ -161,7 +167,7 @@ def getPath(sPath,sMain):
getPath(sPath, sMain) getPath(sPath, sMain)
return sPath return sPath
def EnumDocument(aItemList,aComponentAdd): def EnumDocument(aItemList, aComponentAdd):
desktop = getDesktop() desktop = getDesktop()
parent="" parent=""
bFlag = False bFlag = False
@ -183,7 +189,7 @@ def EnumDocument(aItemList,aComponentAdd):
aItemList.append( templist ) aItemList.append( templist )
aComponentAdd.append( parent ) aComponentAdd.append( parent )
def getChildTable(oPar,aItemList,aComponentAdd,sTableName=""): def getChildTable(oPar, aItemList, aComponentAdd, sTableName=""):
sNames = oPar.getCellNames() sNames = oPar.getCellNames()
bEmptyTableFlag=True bEmptyTableFlag=True
for val in sNames: for val in sNames:
@ -229,7 +235,7 @@ def getChildTable(oPar,aItemList,aComponentAdd,sTableName=""):
aComponentAdd.append(sTableName+"."+oPar.Name) aComponentAdd.append(sTableName+"."+oPar.Name)
return 0 return 0
def getRecersiveSection(oCurrentSection,aSectionList): def getRecersiveSection(oCurrentSection, aSectionList):
desktop=getDesktop() desktop=getDesktop()
doc =desktop.getCurrentComponent() doc =desktop.getCurrentComponent()
oParEnum=doc.getText().createEnumeration() oParEnum=doc.getText().createEnumeration()

View File

@ -39,7 +39,7 @@ def log_detail(self):
logger.setLevel(logging.INFO) logger.setLevel(logging.INFO)
class Logger(object): class Logger(object):
def log_write(self,name,level,msg): def log_write(self, name, level, msg):
log = logging.getLogger(name) log = logging.getLogger(name)
getattr(log,level)(msg) getattr(log,level)(msg)

View File

@ -52,7 +52,7 @@ class RPCGateway(object):
class RPCSession(object): class RPCSession(object):
def __init__(self,url): def __init__(self, url):
m = re.match('^(http[s]?://|socket://)([\w.\-]+):(\d{1,5})$', url or '') m = re.match('^(http[s]?://|socket://)([\w.\-]+):(\d{1,5})$', url or '')
@ -152,7 +152,7 @@ class XMLRPCGateway(RPCGateway):
return res return res
def execute(self, sDatabase,UID,sPassword,obj, method, *args): def execute(self, sDatabase, UID, sPassword, obj, method, *args):
global rpc_url global rpc_url
sock = xmlrpclib.ServerProxy(rpc_url + 'object') sock = xmlrpclib.ServerProxy(rpc_url + 'object')

View File

@ -21,19 +21,19 @@
############################################################################## ##############################################################################
import urllib import urllib
def get_absolute_file_path( url ): def get_absolute_file_path(url):
url_unquoted = urllib.unquote(url) url_unquoted = urllib.unquote(url)
return os.name == 'nt' and url_unquoted[1:] or url_unquoted return os.name == 'nt' and url_unquoted[1:] or url_unquoted
# This function reads the content of a file and return it to the caller # This function reads the content of a file and return it to the caller
def read_data_from_file( filename ): def read_data_from_file(filename):
fp = file( filename, "rb" ) fp = file( filename, "rb" )
data = fp.read() data = fp.read()
fp.close() fp.close()
return data return data
# This function writes the content to a file # This function writes the content to a file
def write_data_to_file( filename, data ): def write_data_to_file(filename, data):
fp = file( filename, 'wb' ) fp = file( filename, 'wb' )
fp.write( data ) fp.write( data )
fp.close() fp.close()

View File

@ -61,7 +61,7 @@ if __name__<>"package":
uid = 3 uid = 3
class modify(unohelper.Base, XJobExecutor ): class modify(unohelper.Base, XJobExecutor ):
def __init__( self, ctx ): def __init__(self, ctx):
self.ctx = ctx self.ctx = ctx
self.module = "openerp_report" self.module = "openerp_report"
self.version = "0.1" self.version = "0.1"

View File

@ -10,7 +10,11 @@ import time
sock = xmlrpclib.ServerProxy('http://localhost:8069/xmlrpc/object') sock = xmlrpclib.ServerProxy('http://localhost:8069/xmlrpc/object')
def get(object, level=3, ending=[], ending_excl=[], recur=[], root=''): def get(object, level=3, ending=None, ending_excl=None, recur=None, root=''):
if ending is None:
ending = []
if ending_excl is None:
ending_excl = []
res = sock.execute('terp', 3, 'admin', 'account.invoice', 'fields_get') res = sock.execute('terp', 3, 'admin', 'account.invoice', 'fields_get')
key = res.keys() key = res.keys()
key.sort() key.sort()

View File

@ -84,7 +84,7 @@ def _lang_get(self, cr, uid, context=None):
res = [(r['code'], r['name']) for r in res] res = [(r['code'], r['name']) for r in res]
return res return res
def _tz_get(self,cr,uid, context=None): def _tz_get(self, cr, uid, context=None):
return [(x, x) for x in pytz.all_timezones] return [(x, x) for x in pytz.all_timezones]
class user_preferences_config(osv.osv_memory): class user_preferences_config(osv.osv_memory):

View File

@ -65,10 +65,12 @@ class base_synchro_obj(osv.osv):
# Return a list of changes: [ (date, id) ] # Return a list of changes: [ (date, id) ]
# #
def get_ids(self, cr, uid, object, dt, domain=[], context=None): def get_ids(self, cr, uid, object, dt, domain=None, context=None):
return self._get_ids(cr, uid, object, dt, domain, context=context) return self._get_ids(cr, uid, object, dt, domain=domain, context=context)
def _get_ids(self, cr, uid, object, dt, domain=[], context=None): def _get_ids(self, cr, uid, object, dt, domain=None, context=None):
if domain is None:
domain = []
result = [] result = []
if dt: if dt:
domain2 = domain+[('write_date','>=',dt)] domain2 = domain+[('write_date','>=',dt)]

View File

@ -42,7 +42,7 @@ class node_calendar_collection(nodes.node_dir):
DAV_M_NS = dict_merge2(nodes.node_dir.DAV_M_NS, DAV_M_NS = dict_merge2(nodes.node_dir.DAV_M_NS,
{ "http://calendarserver.org/ns/" : '_get_dav', } ) { "http://calendarserver.org/ns/" : '_get_dav', } )
def _file_get(self,cr, nodename=False): def _file_get(self, cr, nodename=False):
return [] return []
def _child_get(self, cr, name=False, parent_id=False, domain=None): def _child_get(self, cr, name=False, parent_id=False, domain=None):
@ -99,7 +99,7 @@ class node_calendar_res_col(nodes.node_res_obj):
DAV_M_NS = dict_merge2(nodes.node_res_obj.DAV_M_NS, DAV_M_NS = dict_merge2(nodes.node_res_obj.DAV_M_NS,
{ "http://calendarserver.org/ns/" : '_get_dav', } ) { "http://calendarserver.org/ns/" : '_get_dav', } )
def _file_get(self,cr, nodename=False): def _file_get(self, cr, nodename=False):
return [] return []
def _child_get(self, cr, name=False, parent_id=False, domain=None): def _child_get(self, cr, name=False, parent_id=False, domain=None):
@ -180,7 +180,7 @@ class node_calendar(nodes.node_class):
http_options = { 'DAV': ['calendar-access'] } http_options = { 'DAV': ['calendar-access'] }
def __init__(self,path, parent, context, calendar): def __init__(self, path, parent, context, calendar):
super(node_calendar,self).__init__(path, parent,context) super(node_calendar,self).__init__(path, parent,context)
self.calendar_id = calendar.id self.calendar_id = calendar.id
self.mimetype = 'application/x-directory' self.mimetype = 'application/x-directory'
@ -271,7 +271,7 @@ class node_calendar(nodes.node_class):
def children(self, cr, domain=None): def children(self, cr, domain=None):
return self._child_get(cr, domain=domain) return self._child_get(cr, domain=domain)
def child(self,cr, name, domain=None): def child(self, cr, name, domain=None):
res = self._child_get(cr, name, domain=domain) res = self._child_get(cr, name, domain=domain)
if res: if res:
return res[0] return res[0]
@ -353,16 +353,16 @@ class node_calendar(nodes.node_class):
return None return None
def set_data(self, cr, data, fil_obj = None): def set_data(self, cr, data, fil_obj=None):
uid = self.context.uid uid = self.context.uid
calendar_obj = self.context._dirobj.pool.get('basic.calendar') calendar_obj = self.context._dirobj.pool.get('basic.calendar')
res = calendar_obj.import_cal(cr, uid, data, self.calendar_id) res = calendar_obj.import_cal(cr, uid, data, self.calendar_id)
return res return res
def get_data_len(self, cr, fil_obj = None): def get_data_len(self, cr, fil_obj=None):
return self.content_length return self.content_length
def _get_ttag(self,cr): def _get_ttag(self, cr):
return 'calendar-%d' % (self.calendar_id,) return 'calendar-%d' % (self.calendar_id,)
def rmcol(self, cr): def rmcol(self, cr):
@ -441,7 +441,7 @@ class res_node_calendar(nodes.node_class):
http_options = { 'DAV': ['calendar-access'] } http_options = { 'DAV': ['calendar-access'] }
def __init__(self,path, parent, context, res_obj, res_model=None, res_id=None): def __init__(self, path, parent, context, res_obj, res_model=None, res_id=None):
super(res_node_calendar,self).__init__(path, parent, context) super(res_node_calendar,self).__init__(path, parent, context)
self.mimetype = 'text/calendar' self.mimetype = 'text/calendar'
self.create_date = parent.create_date self.create_date = parent.create_date
@ -474,10 +474,10 @@ class res_node_calendar(nodes.node_class):
def _get_caldav_calendar_data(self, cr): def _get_caldav_calendar_data(self, cr):
return self.get_data(cr) return self.get_data(cr)
def get_data_len(self, cr, fil_obj = None): def get_data_len(self, cr, fil_obj=None):
return self.content_length return self.content_length
def set_data(self, cr, data, fil_obj = None): def set_data(self, cr, data, fil_obj=None):
uid = self.context.uid uid = self.context.uid
context = self.context.context.copy() context = self.context.context.copy()
context.update(self.dctx) context.update(self.dctx)
@ -486,7 +486,7 @@ class res_node_calendar(nodes.node_class):
res = calendar_obj.import_cal(cr, uid, data, self.calendar_id, context=context) res = calendar_obj.import_cal(cr, uid, data, self.calendar_id, context=context)
return res return res
def _get_ttag(self,cr): def _get_ttag(self, cr):
res = False res = False
if self.model and self.res_id: if self.model and self.res_id:
res = '%s_%d' % (self.model, self.res_id) res = '%s_%d' % (self.model, self.res_id)

View File

@ -331,7 +331,9 @@ class crm_case(crm_base):
And object that inherit (orm inheritance) from a class the overwrite copy And object that inherit (orm inheritance) from a class the overwrite copy
""" """
def stage_find(self, cr, uid, section_id, domain=[], order='sequence'): def stage_find(self, cr, uid, section_id, domain=None, order='sequence'):
if domain is None:
domain = []
domain = list(domain) domain = list(domain)
if section_id: if section_id:
domain.append(('section_ids', '=', section_id)) domain.append(('section_ids', '=', section_id))

View File

@ -239,7 +239,7 @@ class crm_lead(crm_case, osv.osv):
def on_change_optout(self, cr, uid, ids, optout): def on_change_optout(self, cr, uid, ids, optout):
return {'value':{'optout':optout,'optin':False}} return {'value':{'optout':optout,'optin':False}}
def onchange_stage_id(self, cr, uid, ids, stage_id, context={}): def onchange_stage_id(self, cr, uid, ids, stage_id, context=None):
if not stage_id: if not stage_id:
return {'value':{}} return {'value':{}}
stage = self.pool.get('crm.case.stage').browse(cr, uid, stage_id, context) stage = self.pool.get('crm.case.stage').browse(cr, uid, stage_id, context)

View File

@ -157,7 +157,7 @@ class crm_claim(crm.crm_case, osv.osv):
self.write(cr, uid, [res_id], vals, context=context) self.write(cr, uid, [res_id], vals, context=context)
return res_id return res_id
def message_update(self, cr, uid, ids, msg, vals={}, default_act='pending', context=None): def message_update(self, cr, uid, ids, msg, vals=None, default_act='pending', context=None):
if isinstance(ids, (str, int, long)): if isinstance(ids, (str, int, long)):
ids = [ids] ids = [ids]

View File

@ -112,7 +112,7 @@ class crm_helpdesk(crm.crm_case, osv.osv):
self.write(cr, uid, [res_id], vals, context) self.write(cr, uid, [res_id], vals, context)
return res_id return res_id
def message_update(self, cr, uid, ids, msg, vals={}, default_act='pending', context=None): def message_update(self, cr, uid, ids, msg, vals=None, default_act='pending', context=None):
if isinstance(ids, (str, int, long)): if isinstance(ids, (str, int, long)):
ids = [ids] ids = [ids]

View File

@ -77,7 +77,7 @@ def _get_parents(cr, uid, ids):
return ids_to_check return ids_to_check
def test_prof(cr, uid, seg_id, pid, answers_ids = []): def test_prof(cr, uid, seg_id, pid, answers_ids=None):
""" return True if the partner pid fetch the segmentation rule seg_id """ return True if the partner pid fetch the segmentation rule seg_id
@param cr: the current row, from the database cursor, @param cr: the current row, from the database cursor,

View File

@ -44,7 +44,7 @@ class make_delivery(osv.osv_memory):
return res return res
def view_init(self, cr , uid , fields, context=None): def view_init(self, cr, uid, fields, context=None):
if context is None: if context is None:
context = {} context = {}
order_obj = self.pool.get('sale.order') order_obj = self.pool.get('sale.order')

View File

@ -51,7 +51,7 @@ class indexer(object):
return mts[0] return mts[0]
return None return None
def indexContent(self, content, filename=None, realfile = None): def indexContent(self, content, filename=None, realfile=None):
""" Use either content or the real file, to index. """ Use either content or the real file, to index.
Some parsers will work better with the actual Some parsers will work better with the actual
content, others parse a file easier. Try the content, others parse a file easier. Try the
@ -95,10 +95,10 @@ class indexer(object):
raise NhException('No appropriate method to index file') raise NhException('No appropriate method to index file')
def _doIndexContent(self,content): def _doIndexContent(self, content):
raise NhException("Content not handled here") raise NhException("Content not handled here")
def _doIndexFile(self,fpath): def _doIndexFile(self, fpath):
raise NhException("Content not handled here") raise NhException("Content not handled here")
def __repr__(self): def __repr__(self):
@ -136,7 +136,7 @@ class contentIndex(object):
if not f: if not f:
raise Exception("Your indexer should at least suport a mimetype or extension") raise Exception("Your indexer should at least suport a mimetype or extension")
def doIndex(self, content, filename=None, content_type=None, realfname = None, debug=False): def doIndex(self, content, filename=None, content_type=None, realfname=None, debug=False):
fobj = None fobj = None
fname = None fname = None
mime = None mime = None

View File

@ -146,7 +146,7 @@ class document_file(osv.osv):
_sql_constraints = [ _sql_constraints = [
# filename_uniq is not possible in pure SQL # filename_uniq is not possible in pure SQL
] ]
def _check_duplication(self, cr, uid, vals, ids=[], op='create'): def _check_duplication(self, cr, uid, vals, ids=None, op='create'):
name = vals.get('name', False) name = vals.get('name', False)
parent_id = vals.get('parent_id', False) parent_id = vals.get('parent_id', False)
res_model = vals.get('res_model', False) res_model = vals.get('res_model', False)

View File

@ -69,7 +69,7 @@ class document_directory(osv.osv):
} }
def _get_root_directory(self, cr,uid, context=None): def _get_root_directory(self, cr, uid, context=None):
objid=self.pool.get('ir.model.data') objid=self.pool.get('ir.model.data')
try: try:
mid = objid._get_id(cr, uid, 'document', 'dir_root') mid = objid._get_id(cr, uid, 'document', 'dir_root')
@ -224,7 +224,7 @@ class document_directory(osv.osv):
pass pass
return res return res
def _locate_child(self, cr, uid, root_id, uri,nparent, ncontext): def _locate_child(self, cr, uid, root_id, uri, nparent, ncontext):
""" try to locate the node in uri, """ try to locate the node in uri,
Return a tuple (node_dir, remaining_path) Return a tuple (node_dir, remaining_path)
""" """
@ -237,7 +237,7 @@ class document_directory(osv.osv):
default.update({'name': name+ " (copy)"}) default.update({'name': name+ " (copy)"})
return super(document_directory,self).copy(cr, uid, id, default, context=context) return super(document_directory,self).copy(cr, uid, id, default, context=context)
def _check_duplication(self, cr, uid, vals, ids=[], op='create'): def _check_duplication(self, cr, uid, vals, ids=None, op='create'):
name=vals.get('name',False) name=vals.get('name',False)
parent_id=vals.get('parent_id',False) parent_id=vals.get('parent_id',False)
ressource_parent_type_id=vals.get('ressource_parent_type_id',False) ressource_parent_type_id=vals.get('ressource_parent_type_id',False)

View File

@ -253,7 +253,7 @@ class node_class(object):
print "node_class.children()" print "node_class.children()"
return [] #stub return [] #stub
def child(self,cr, name, domain=None): def child(self, cr, name, domain=None):
print "node_class.child()" print "node_class.child()"
return None return None
@ -271,7 +271,7 @@ class node_class(object):
print "node_class.path_get()" print "node_class.path_get()"
return False return False
def get_data(self,cr): def get_data(self, cr):
raise TypeError('no data for %s'% self.type) raise TypeError('no data for %s'% self.type)
def open_data(self, cr, mode): def open_data(self, cr, mode):
@ -288,10 +288,10 @@ class node_class(object):
""" """
raise TypeError('no data for %s' % self.type) raise TypeError('no data for %s' % self.type)
def _get_storage(self,cr): def _get_storage(self, cr):
raise RuntimeError("no storage for base class") raise RuntimeError("no storage for base class")
def get_etag(self,cr): def get_etag(self, cr):
""" Get a tag, unique per object + modification. """ Get a tag, unique per object + modification.
see. http://tools.ietf.org/html/rfc2616#section-13.3.3 """ see. http://tools.ietf.org/html/rfc2616#section-13.3.3 """
@ -435,7 +435,9 @@ class node_database(node_class):
""" """
our_type = 'database' our_type = 'database'
def __init__(self, path=[], parent=False, context=None): def __init__(self, path=None, parent=False, context=None):
if path is None:
path = []
super(node_database,self).__init__(path, parent, context) super(node_database,self).__init__(path, parent, context)
self.unixperms = 040750 self.unixperms = 040750
self.uidperms = 5 self.uidperms = 5
@ -478,11 +480,11 @@ class node_database(node_class):
return res return res
def _file_get(self,cr, nodename=False): def _file_get(self, cr, nodename=False):
res = [] res = []
return res return res
def _get_ttag(self,cr): def _get_ttag(self, cr):
return 'db-%s' % cr.dbname return 'db-%s' % cr.dbname
def mkdosname(company_name, default='noname'): def mkdosname(company_name, default='noname'):
@ -694,7 +696,7 @@ class node_dir(node_database):
fnode.set_data(cr, data, fil) fnode.set_data(cr, data, fil)
return fnode return fnode
def _get_ttag(self,cr): def _get_ttag(self, cr):
return 'dir-%d' % self.dir_id return 'dir-%d' % self.dir_id
def move_to(self, cr, ndir_node, new_name=False, fil_obj=None, ndir_obj=None, in_write=False): def move_to(self, cr, ndir_node, new_name=False, fil_obj=None, ndir_obj=None, in_write=False):
@ -803,7 +805,7 @@ class node_res_dir(node_class):
def children(self, cr, domain=None): def children(self, cr, domain=None):
return self._child_get(cr, domain=domain) return self._child_get(cr, domain=domain)
def child(self,cr, name, domain=None): def child(self, cr, name, domain=None):
res = self._child_get(cr, name, domain=domain) res = self._child_get(cr, name, domain=domain)
if res: if res:
return res[0] return res[0]
@ -879,7 +881,7 @@ class node_res_dir(node_class):
res.append(self.res_obj_class(res_name, self.dir_id, self, self.context, self.res_model, bo)) res.append(self.res_obj_class(res_name, self.dir_id, self, self.context, self.res_model, bo))
return res return res
def _get_ttag(self,cr): def _get_ttag(self, cr):
return 'rdir-%d' % self.dir_id return 'rdir-%d' % self.dir_id
class node_res_obj(node_class): class node_res_obj(node_class):
@ -890,7 +892,7 @@ class node_res_obj(node_class):
node_dirs (with limited domain). node_dirs (with limited domain).
""" """
our_type = 'collection' our_type = 'collection'
def __init__(self, path, dir_id, parent, context, res_model, res_bo, res_id = None): def __init__(self, path, dir_id, parent, context, res_model, res_bo, res_id=None):
super(node_res_obj,self).__init__(path, parent,context) super(node_res_obj,self).__init__(path, parent,context)
assert parent assert parent
#todo: more info from dirr #todo: more info from dirr
@ -959,7 +961,7 @@ class node_res_obj(node_class):
return res[0] return res[0]
return None return None
def _file_get(self,cr, nodename=False): def _file_get(self, cr, nodename=False):
res = [] res = []
is_allowed = self.check_perms((nodename and 1) or 5) is_allowed = self.check_perms((nodename and 1) or 5)
if not is_allowed: if not is_allowed:
@ -1161,7 +1163,7 @@ class node_res_obj(node_class):
fnode.set_data(cr, data, fil) fnode.set_data(cr, data, fil)
return fnode return fnode
def _get_ttag(self,cr): def _get_ttag(self, cr):
return 'rodir-%d-%d' % (self.dir_id, self.res_id) return 'rodir-%d-%d' % (self.dir_id, self.res_id)
node_res_dir.res_obj_class = node_res_obj node_res_dir.res_obj_class = node_res_obj
@ -1263,7 +1265,7 @@ class node_file(node_class):
else: else:
self.path = dirpath[0] self.path = dirpath[0]
def get_data(self, cr, fil_obj = None): def get_data(self, cr, fil_obj=None):
""" Retrieve the data for some file. """ Retrieve the data for some file.
fil_obj may optionally be specified, and should be a browse object fil_obj may optionally be specified, and should be a browse object
for the file. This is useful when the caller has already initiated for the file. This is useful when the caller has already initiated
@ -1279,14 +1281,14 @@ class node_file(node_class):
stobj = self.context._dirobj.pool.get('document.storage') stobj = self.context._dirobj.pool.get('document.storage')
return stobj.get_data(cr, self.context.uid,stor, self,self.context.context, fil_obj) return stobj.get_data(cr, self.context.uid,stor, self,self.context.context, fil_obj)
def get_data_len(self, cr, fil_obj = None): def get_data_len(self, cr, fil_obj=None):
# TODO: verify with the storage object! # TODO: verify with the storage object!
bin_size = self.context.context.get('bin_size', False) bin_size = self.context.context.get('bin_size', False)
if bin_size and not self.content_length: if bin_size and not self.content_length:
self.content_length = fil_obj.db_datas self.content_length = fil_obj.db_datas
return self.content_length return self.content_length
def set_data(self, cr, data, fil_obj = None): def set_data(self, cr, data, fil_obj=None):
""" Store data at some file. """ Store data at some file.
fil_obj may optionally be specified, and should be a browse object fil_obj may optionally be specified, and should be a browse object
for the file. This is useful when the caller has already initiated for the file. This is useful when the caller has already initiated
@ -1300,7 +1302,7 @@ class node_file(node_class):
stobj = self.context._dirobj.pool.get('document.storage') stobj = self.context._dirobj.pool.get('document.storage')
return stobj.set_data(cr, self.context.uid,stor, self, data, self.context.context, fil_obj) return stobj.set_data(cr, self.context.uid,stor, self, data, self.context.context, fil_obj)
def _get_ttag(self,cr): def _get_ttag(self, cr):
return 'file-%d' % self.file_id return 'file-%d' % self.file_id
def move_to(self, cr, ndir_node, new_name=False, fil_obj=None, ndir_obj=None, in_write=False): def move_to(self, cr, ndir_node, new_name=False, fil_obj=None, ndir_obj=None, in_write=False):
@ -1363,7 +1365,7 @@ class node_file(node_class):
class node_content(node_class): class node_content(node_class):
our_type = 'content' our_type = 'content'
def __init__(self, path, parent, context, cnt, dctx = None, act_id=None): def __init__(self, path, parent, context, cnt, dctx=None, act_id=None):
super(node_content,self).__init__(path, parent,context) super(node_content,self).__init__(path, parent,context)
self.cnt_id = cnt.id self.cnt_id = cnt.id
self.create_date = False self.create_date = False
@ -1383,7 +1385,7 @@ class node_content(node_class):
self.dctx.update(dctx) self.dctx.update(dctx)
self.act_id = act_id self.act_id = act_id
def fill_fields(self, cr, dctx = None): def fill_fields(self, cr, dctx=None):
""" Try to read the object and fill missing fields, like mimetype, """ Try to read the object and fill missing fields, like mimetype,
dates etc. dates etc.
This function must be different from the constructor, because This function must be different from the constructor, because
@ -1397,7 +1399,7 @@ class node_content(node_class):
self.mimetype = str(res[0][0]) self.mimetype = str(res[0][0])
def get_data(self, cr, fil_obj = None): def get_data(self, cr, fil_obj=None):
cntobj = self.context._dirobj.pool.get('document.directory.content') cntobj = self.context._dirobj.pool.get('document.directory.content')
if not self.check_perms(4): if not self.check_perms(4):
raise IOError(errno.EPERM, "Permission denied") raise IOError(errno.EPERM, "Permission denied")
@ -1427,7 +1429,7 @@ class node_content(node_class):
return nodefd_content(self, cr, mode, ctx) return nodefd_content(self, cr, mode, ctx)
def get_data_len(self, cr, fil_obj = None): def get_data_len(self, cr, fil_obj=None):
# FIXME : here, we actually generate the content twice!! # FIXME : here, we actually generate the content twice!!
# we should have cached the generated content, but it is # we should have cached the generated content, but it is
# not advisable to do keep it in memory, until we have a cache # not advisable to do keep it in memory, until we have a cache
@ -1436,7 +1438,7 @@ class node_content(node_class):
self.get_data(cr,fil_obj) self.get_data(cr,fil_obj)
return self.content_length return self.content_length
def set_data(self, cr, data, fil_obj = None): def set_data(self, cr, data, fil_obj=None):
cntobj = self.context._dirobj.pool.get('document.directory.content') cntobj = self.context._dirobj.pool.get('document.directory.content')
if not self.check_perms(2): if not self.check_perms(2):
raise IOError(errno.EPERM, "Permission denied") raise IOError(errno.EPERM, "Permission denied")
@ -1445,7 +1447,7 @@ class node_content(node_class):
ctx.update(self.dctx) ctx.update(self.dctx)
return cntobj.process_write(cr, self.context.uid, self, data, ctx) return cntobj.process_write(cr, self.context.uid, self, data, ctx)
def _get_ttag(self,cr): def _get_ttag(self, cr):
return 'cnt-%d%s' % (self.cnt_id,(self.act_id and ('-' + str(self.act_id))) or '') return 'cnt-%d%s' % (self.cnt_id,(self.act_id and ('-' + str(self.act_id))) or '')
def get_dav_resourcetype(self, cr): def get_dav_resourcetype(self, cr):

6
addons/document/odt2txt.py Executable file → Normal file
View File

@ -24,11 +24,11 @@ import sys, zipfile, xml.dom.minidom
import StringIO import StringIO
class OpenDocumentTextFile : class OpenDocumentTextFile :
def __init__ (self, filepath) : def __init__ (self, filepath):
zip = zipfile.ZipFile(filepath) zip = zipfile.ZipFile(filepath)
self.content = xml.dom.minidom.parseString(zip.read("content.xml")) self.content = xml.dom.minidom.parseString(zip.read("content.xml"))
def toString (self) : def toString (self):
""" Converts the document to a string. """ """ Converts the document to a string. """
buffer = u"" buffer = u""
for val in ["text:p", "text:h", "text:list"]: for val in ["text:p", "text:h", "text:list"]:
@ -36,7 +36,7 @@ class OpenDocumentTextFile :
buffer += self.textToString(paragraph) + "\n" buffer += self.textToString(paragraph) + "\n"
return buffer return buffer
def textToString(self, element) : def textToString(self, element):
buffer = u"" buffer = u""
for node in element.childNodes : for node in element.childNodes :
if node.nodeType == xml.dom.Node.TEXT_NODE : if node.nodeType == xml.dom.Node.TEXT_NODE :

View File

@ -38,7 +38,7 @@ def _to_unicode(s):
except UnicodeError: except UnicodeError:
return s return s
def textToString(element) : def textToString(element):
buffer = u"" buffer = u""
for node in element.childNodes : for node in element.childNodes :
if node.nodeType == xml.dom.Node.TEXT_NODE : if node.nodeType == xml.dom.Node.TEXT_NODE :
@ -55,7 +55,7 @@ class TxtIndex(indexer):
def _getExtensions(self): def _getExtensions(self):
return ['.txt', '.py'] return ['.txt', '.py']
def _doIndexContent(self,content): def _doIndexContent(self, content):
return content return content
cntIndex.register(TxtIndex()) cntIndex.register(TxtIndex())
@ -67,7 +67,7 @@ class PptxIndex(indexer):
def _getExtensions(self): def _getExtensions(self):
return ['.pptx'] return ['.pptx']
def _doIndexFile(self,fname): def _doIndexFile(self, fname):
def toString () : def toString () :
""" Converts the document to a string. """ """ Converts the document to a string. """
buffer = u"" buffer = u""
@ -95,7 +95,7 @@ class DocIndex(indexer):
def _getExtensions(self): def _getExtensions(self):
return ['.doc'] return ['.doc']
def _doIndexFile(self,fname): def _doIndexFile(self, fname):
try: try:
pop = Popen(['antiword', fname], shell=False, stdout=PIPE) pop = Popen(['antiword', fname], shell=False, stdout=PIPE)
(data, _) = pop.communicate() (data, _) = pop.communicate()
@ -115,7 +115,7 @@ class DocxIndex(indexer):
def _getExtensions(self): def _getExtensions(self):
return ['.docx'] return ['.docx']
def _doIndexFile(self,fname): def _doIndexFile(self, fname):
zip = zipfile.ZipFile(fname) zip = zipfile.ZipFile(fname)
content = xml.dom.minidom.parseString(zip.read("word/document.xml")) content = xml.dom.minidom.parseString(zip.read("word/document.xml"))
def toString () : def toString () :
@ -140,7 +140,7 @@ class XlsxIndex(indexer):
def _getExtensions(self): def _getExtensions(self):
return ['.xlsx'] return ['.xlsx']
def _doIndexFile(self,fname): def _doIndexFile(self, fname):
zip = zipfile.ZipFile(fname) zip = zipfile.ZipFile(fname)
content = xml.dom.minidom.parseString(zip.read("xl/sharedStrings.xml")) content = xml.dom.minidom.parseString(zip.read("xl/sharedStrings.xml"))
def toString () : def toString () :
@ -164,7 +164,7 @@ class PdfIndex(indexer):
def _getExtensions(self): def _getExtensions(self):
return ['.pdf'] return ['.pdf']
def _doIndexFile(self,fname): def _doIndexFile(self, fname):
pop = Popen(['pdftotext', '-enc', 'UTF-8', '-nopgbrk', fname, '-'], shell=False, stdout=PIPE) pop = Popen(['pdftotext', '-enc', 'UTF-8', '-nopgbrk', fname, '-'], shell=False, stdout=PIPE)
(data, _) = pop.communicate() (data, _) = pop.communicate()
return _to_unicode(data) return _to_unicode(data)
@ -180,7 +180,7 @@ class ImageNoIndex(indexer):
return [] return []
#return ['.png','.jpg','.gif','.jpeg','.bmp','.tiff'] #return ['.png','.jpg','.gif','.jpeg','.bmp','.tiff']
def _doIndexContent(self,content): def _doIndexContent(self, content):
return 'image' return 'image'

View File

@ -57,7 +57,7 @@ class document_davdir(osv.osv):
# TODO group # TODO group
return return
def _locate_child(self, cr, uid, root_id, uri,nparent, ncontext): def _locate_child(self, cr, uid, root_id, uri, nparent, ncontext):
""" try to locate the node in uri, """ try to locate the node in uri,
Return a tuple (node_dir, remaining_path) Return a tuple (node_dir, remaining_path)
""" """

View File

@ -30,7 +30,7 @@ class RedirectHTTPHandler(HttpLogHandler, FixSendError, HttpOptions, HTTPHandler
_HTTP_OPTIONS = { 'Allow': ['OPTIONS', 'GET', 'HEAD', 'PROPFIND'] } _HTTP_OPTIONS = { 'Allow': ['OPTIONS', 'GET', 'HEAD', 'PROPFIND'] }
redirect_paths = {} redirect_paths = {}
def __init__(self,request, client_address, server): def __init__(self, request, client_address, server):
HTTPHandler.__init__(self,request,client_address,server) HTTPHandler.__init__(self,request,client_address,server)
def send_head(self): def send_head(self):

2
addons/document_webdav/test_davclient.py Executable file → Normal file
View File

@ -682,7 +682,7 @@ class DAVClient(object):
assert d2 == d, "Data does not match" assert d2 == d, "Data does not match"
return ctype, rrange, d return ctype, rrange, d
def gd_put(self, path, body=None, srcpath=None, mime=None, noclobber=False, ): def gd_put(self, path, body=None, srcpath=None, mime=None, noclobber=False):
""" HTTP PUT """ HTTP PUT
@param noclobber will prevent overwritting a resource (If-None-Match) @param noclobber will prevent overwritting a resource (If-None-Match)
@param mime will set the content-type @param mime will set the content-type

View File

@ -236,7 +236,7 @@ def mk_prop_response(self, uri, good_props, bad_props, doc):
return re return re
def mk_propname_response(self,uri,propnames,doc): def mk_propname_response(self, uri, propnames, doc):
""" make a new <prop> result element for a PROPNAME request """ make a new <prop> result element for a PROPNAME request
This will simply format the propnames list. This will simply format the propnames list.

View File

@ -81,7 +81,7 @@ class DAVHandler(HttpOptions, FixSendError, DAVRequestHandler):
'DELETE', 'TRACE', 'REPORT', ] 'DELETE', 'TRACE', 'REPORT', ]
} }
def get_userinfo(self,user,pw): def get_userinfo(self, user, pw):
return False return False
def _log(self, message): def _log(self, message):
@ -167,7 +167,7 @@ class DAVHandler(HttpOptions, FixSendError, DAVRequestHandler):
self.close_connection = 1 self.close_connection = 1
DAVRequestHandler.send_header(self, key, value) DAVRequestHandler.send_header(self, key, value)
def send_body(self, DATA, code = None, msg = None, desc = None, ctype='application/octet-stream', headers=None): def send_body(self, DATA, code=None, msg=None, desc=None, ctype='application/octet-stream', headers=None):
if headers and 'Connection' in headers: if headers and 'Connection' in headers:
pass pass
elif self.request_version in ('HTTP/1.0', 'HTTP/0.9'): elif self.request_version in ('HTTP/1.0', 'HTTP/0.9'):
@ -441,10 +441,10 @@ class dummy_dav_interface(object):
def __init__(self, parent): def __init__(self, parent):
self.parent = parent self.parent = parent
def get_propnames(self,uri): def get_propnames(self, uri):
return self.PROPS return self.PROPS
def get_prop(self,uri,ns,propname): def get_prop(self, uri, ns, propname):
if self.M_NS.has_key(ns): if self.M_NS.has_key(ns):
prefix=self.M_NS[ns] prefix=self.M_NS[ns]
else: else:
@ -460,10 +460,10 @@ class dummy_dav_interface(object):
def get_data(self, uri, range=None): def get_data(self, uri, range=None):
raise DAV_NotFound raise DAV_NotFound
def _get_dav_creationdate(self,uri): def _get_dav_creationdate(self, uri):
return time.strftime("%Y-%m-%dT%H:%M:%SZ", time.gmtime()) return time.strftime("%Y-%m-%dT%H:%M:%SZ", time.gmtime())
def _get_dav_getlastmodified(self,uri): def _get_dav_getlastmodified(self, uri):
return time.strftime("%a, %d %b %Y %H:%M:%S GMT", time.gmtime()) return time.strftime("%a, %d %b %Y %H:%M:%S GMT", time.gmtime())
def _get_dav_displayname(self, uri): def _get_dav_displayname(self, uri):

5
addons/email_template/html2text.py Executable file → Normal file
View File

@ -338,7 +338,7 @@ class _html2text(sgmllib.SGMLParser):
def pbr(self): def pbr(self):
if self.p_p == 0: self.p_p = 1 if self.p_p == 0: self.p_p = 1
def p(self): self.p_p = 2 def p(self):
def o(self, data, puredata=0, force=0): def o(self, data, puredata=0, force=0):
if self.abbr_data is not None: self.abbr_data += data if self.abbr_data is not None: self.abbr_data += data
@ -411,7 +411,8 @@ class _html2text(sgmllib.SGMLParser):
if r'\/script>' in data: self.quiet -= 1 if r'\/script>' in data: self.quiet -= 1
self.o(data, 1) self.o(data, 1)
def unknown_decl(self, data): pass def unknown_decl(self, data):
pass
def wrapwrite(text): sys.stdout.write(text.encode('utf8')) def wrapwrite(text): sys.stdout.write(text.encode('utf8'))

View File

@ -27,7 +27,7 @@ from tools.translate import _
import tools import tools
def _reopen(self,res_id,model): def _reopen(self, res_id, model):
return {'type': 'ir.actions.act_window', return {'type': 'ir.actions.act_window',
'view_mode': 'form', 'view_mode': 'form',
'view_type': 'form', 'view_type': 'form',

View File

@ -66,7 +66,7 @@ class event_event(osv.osv):
res.append((record['id'], name)) res.append((record['id'], name))
return res return res
def _name_get_fnc(self, cr, uid, ids,prop,unknow, context=None): def _name_get_fnc(self, cr, uid, ids, prop, unknow, context=None):
res = self.name_get(cr, uid, ids, context=context) res = self.name_get(cr, uid, ids, context=context)
return dict(res) return dict(res)

View File

@ -125,7 +125,7 @@ class event_moodle(osv.osv):
passwd = passwd + '+' passwd = passwd + '+'
return passwd return passwd
def check_email(self,email): def check_email(self, email):
""" """
check if email is correct check if email is correct

View File

@ -244,7 +244,7 @@ class hr_evaluation(osv.osv):
raise osv.except_osv(_('Warning !'),_("You cannot change state, because some appraisal in waiting answer or draft state")) raise osv.except_osv(_('Warning !'),_("You cannot change state, because some appraisal in waiting answer or draft state"))
return True return True
def button_done(self,cr, uid, ids, context=None): def button_done(self, cr, uid, ids, context=None):
self.write(cr, uid, ids,{'progress': 1 * 100}, context=context) self.write(cr, uid, ids,{'progress': 1 * 100}, context=context)
self.write(cr, uid, ids,{'state':'done', 'date_close': time.strftime('%Y-%m-%d')}, context=context) self.write(cr, uid, ids,{'state':'done', 'date_close': time.strftime('%Y-%m-%d')}, context=context)
return True return True

View File

@ -213,7 +213,7 @@ class hr_applicant(crm.crm_case, osv.osv):
} }
def onchange_job(self,cr, uid, ids, job, context=None): def onchange_job(self, cr, uid, ids, job, context=None):
result = {} result = {}
if job: if job:

View File

@ -29,7 +29,7 @@ class hr_recruitment_partner_create(osv.osv_memory):
'close': fields.boolean('Close job request'), 'close': fields.boolean('Close job request'),
} }
def view_init(self, cr , uid , fields_list, context=None): def view_init(self, cr, uid, fields_list, context=None):
case_obj = self.pool.get('hr.applicant') case_obj = self.pool.get('hr.applicant')
if context is None: if context is None:
context = {} context = {}

View File

@ -26,7 +26,7 @@ class hired_employee(osv.osv_memory):
_name = 'hired.employee' _name = 'hired.employee'
_description = 'Create Employee' _description = 'Create Employee'
def case_close(self, cr, uid,ids, context=None): def case_close(self, cr, uid, ids, context=None):
""" """
@param self: The object pointer @param self: The object pointer
@param cr: the current row, from the database cursor, @param cr: the current row, from the database cursor,
@ -39,7 +39,7 @@ class hired_employee(osv.osv_memory):
self.pool.get('hr.applicant').case_close(cr, uid,context.get('active_ids',[])) self.pool.get('hr.applicant').case_close(cr, uid,context.get('active_ids',[]))
return {} return {}
def case_close_with_emp(self, cr, uid,ids, context=None): def case_close_with_emp(self, cr, uid, ids, context=None):
""" """
@param self: The object pointer @param self: The object pointer
@param cr: the current row, from the database cursor, @param cr: the current row, from the database cursor,

View File

@ -77,7 +77,7 @@ class account_analytic_account(osv.osv):
_defaults = { _defaults = {
'pricelist_id': lambda self, cr, uid, ctx: ctx.get('pricelist_id', False), 'pricelist_id': lambda self, cr, uid, ctx: ctx.get('pricelist_id', False),
} }
def on_change_partner_id(self, cr, uid, id, partner_id, context={}): def on_change_partner_id(self, cr, uid, id, partner_id, context=None):
res = super(account_analytic_account, self).on_change_partner_id(cr, uid, id, partner_id, context) res = super(account_analytic_account, self).on_change_partner_id(cr, uid, id, partner_id, context)
if (not res.get('value', False)) or not partner_id: if (not res.get('value', False)) or not partner_id:
return res return res

View File

@ -38,7 +38,7 @@ class account_analytic_line(osv.osv):
# 'price': boolean # 'price': boolean
# 'product': many2one id # 'product': many2one id
# } # }
def invoice_cost_create(self, cr, uid, ids, data={}, context=None): def invoice_cost_create(self, cr, uid, ids, data=None, context=None):
analytic_account_obj = self.pool.get('account.analytic.account') analytic_account_obj = self.pool.get('account.analytic.account')
res_partner_obj = self.pool.get('res.partner') res_partner_obj = self.pool.get('res.partner')
account_payment_term_obj = self.pool.get('account.payment.term') account_payment_term_obj = self.pool.get('account.payment.term')

View File

@ -374,7 +374,7 @@ class hr_timesheet_sheet(osv.osv):
'department_id':fields.many2one('hr.department','Department'), 'department_id':fields.many2one('hr.department','Department'),
} }
def _default_date_from(self,cr, uid, context=None): def _default_date_from(self, cr, uid, context=None):
user = self.pool.get('res.users').browse(cr, uid, uid, context=context) user = self.pool.get('res.users').browse(cr, uid, uid, context=context)
r = user.company_id and user.company_id.timesheet_range or 'month' r = user.company_id and user.company_id.timesheet_range or 'month'
if r=='month': if r=='month':
@ -385,7 +385,7 @@ class hr_timesheet_sheet(osv.osv):
return time.strftime('%Y-01-01') return time.strftime('%Y-01-01')
return time.strftime('%Y-%m-%d') return time.strftime('%Y-%m-%d')
def _default_date_to(self,cr, uid, context=None): def _default_date_to(self, cr, uid, context=None):
user = self.pool.get('res.users').browse(cr, uid, uid, context=context) user = self.pool.get('res.users').browse(cr, uid, uid, context=context)
r = user.company_id and user.company_id.timesheet_range or 'month' r = user.company_id and user.company_id.timesheet_range or 'month'
if r=='month': if r=='month':

View File

@ -234,7 +234,7 @@ class idea_idea(osv.osv):
res_id = super(idea_idea, self).create(cr, user, vals, context=context) res_id = super(idea_idea, self).create(cr, user, vals, context=context)
return res_id return res_id
def copy(self, cr, uid, id, default={}, context=None): def copy(self, cr, uid, id, default=None, context=None):
""" """
Create the new record in idea_idea model from existing one Create the new record in idea_idea model from existing one
@param cr: A database cursor @param cr: A database cursor

View File

@ -228,7 +228,7 @@ class import_framework(Thread):
return map return map
def _fields_mapp(self,dict_sugar, openerp_dict, table): def _fields_mapp(self, dict_sugar, openerp_dict, table):
""" """
call all the mapper and transform data call all the mapper and transform data
to be compatible with import_data to be compatible with import_data

View File

@ -179,7 +179,7 @@ class account_invoice(osv.osv):
'\nPlease create manually a unique BBA Structured Communication.')) '\nPlease create manually a unique BBA Structured Communication.'))
return super(account_invoice, self).create(cr, uid, vals, context=context) return super(account_invoice, self).create(cr, uid, vals, context=context)
def write(self, cr, uid, ids, vals, context={}): def write(self, cr, uid, ids, vals, context=None):
if isinstance(ids, (int, long)): if isinstance(ids, (int, long)):
ids = [ids] ids = [ids]
for inv in self.browse(cr, uid, ids, context): for inv in self.browse(cr, uid, ids, context):

View File

@ -24,7 +24,7 @@ from osv import osv
class payment_order(osv.osv): class payment_order(osv.osv):
_inherit = 'payment.order' _inherit = 'payment.order'
def get_wizard(self,mode): def get_wizard(self, mode):
if mode == 'dta': if mode == 'dta':
return 'l10n_ch', 'action_dta_create' return 'l10n_ch', 'action_dta_create'

View File

@ -67,7 +67,7 @@ class l10n_ch_report_webkit_html(report_sxw.rml_parse):
self._check(ids) self._check(ids)
return super(l10n_ch_report_webkit_html, self).set_context(objects, data, ids, report_type=report_type) return super(l10n_ch_report_webkit_html, self).set_context(objects, data, ids, report_type=report_type)
def police_absolute_path(self, inner_path) : def police_absolute_path(self, inner_path):
"""Will get the ocrb police absolute path""" """Will get the ocrb police absolute path"""
path = addons.get_module_resource(os.path.join('l10n_ch', 'report', inner_path)) path = addons.get_module_resource(os.path.join('l10n_ch', 'report', inner_path))
return path return path

View File

@ -41,7 +41,7 @@ TRANS=[
(u'ä','a'), (u'ä','a'),
] ]
def _u2a(text) : def _u2a(text):
"""Tries to convert unicode charactere to asci equivalence""" """Tries to convert unicode charactere to asci equivalence"""
if not text : return "" if not text : return ""
txt = "" txt = ""

View File

@ -57,7 +57,7 @@ trailer
%%EOF %%EOF
""" """
def output_field( f ): def output_field(f):
return "\xfe\xff" + "".join( [ "\x00"+c for c in f ] ) return "\xfe\xff" + "".join( [ "\x00"+c for c in f ] )
def extract_keys(lines): def extract_keys(lines):

View File

@ -26,14 +26,14 @@ from osv import osv
class order(report_sxw.rml_parse): class order(report_sxw.rml_parse):
def get_lines(self, user,objects): def get_lines(self, user, objects):
lines=[] lines=[]
for obj in objects: for obj in objects:
if user.id==obj.user_id.id: if user.id==obj.user_id.id:
lines.append(obj) lines.append(obj)
return lines return lines
def get_total(self, user,objects): def get_total(self, user, objects):
lines=[] lines=[]
for obj in objects: for obj in objects:
if user.id==obj.user_id.id: if user.id==obj.user_id.id:

View File

@ -134,7 +134,7 @@ class mail_thread(osv.osv):
self.message_append_dict(cr, uid, [res_id], msg_dict, context=context) self.message_append_dict(cr, uid, [res_id], msg_dict, context=context)
return res_id return res_id
def message_update(self, cr, uid, ids, msg_dict, vals={}, default_act=None, context=None): def message_update(self, cr, uid, ids, msg_dict, vals=None, default_act=None, context=None):
"""Called by ``message_process`` when a new message is received """Called by ``message_process`` when a new message is received
for an existing thread. The default behavior is to create a for an existing thread. The default behavior is to create a
new mail.message in the given thread (by calling new mail.message in the given thread (by calling

0
addons/mail/static/scripts/openerp_mailgate.py Executable file → Normal file
View File

View File

@ -271,13 +271,15 @@ class mrp_bom(osv.osv):
return {'value': {'name': prod.name, 'product_uom': prod.uom_id.id}} return {'value': {'name': prod.name, 'product_uom': prod.uom_id.id}}
return {} return {}
def _bom_find(self, cr, uid, product_id, product_uom, properties=[]): def _bom_find(self, cr, uid, product_id, product_uom, properties=None):
""" Finds BoM for particular product and product uom. """ Finds BoM for particular product and product uom.
@param product_id: Selected product. @param product_id: Selected product.
@param product_uom: Unit of measure of a product. @param product_uom: Unit of measure of a product.
@param properties: List of related properties. @param properties: List of related properties.
@return: False or BoM id. @return: False or BoM id.
""" """
if properties is None:
properties = []
cr.execute('select id from mrp_bom where product_id=%s and bom_id is null order by sequence', (product_id,)) cr.execute('select id from mrp_bom where product_id=%s and bom_id is null order by sequence', (product_id,))
ids = map(lambda x: x[0], cr.fetchall()) ids = map(lambda x: x[0], cr.fetchall())
max_prop = 0 max_prop = 0
@ -292,7 +294,7 @@ class mrp_bom(osv.osv):
max_prop = prop max_prop = prop
return result return result
def _bom_explode(self, cr, uid, bom, factor, properties=[], addthis=False, level=0, routing_id=False): def _bom_explode(self, cr, uid, bom, factor, properties=None, addthis=False, level=0, routing_id=False):
""" Finds Products and Work Centers for related BoM for manufacturing order. """ Finds Products and Work Centers for related BoM for manufacturing order.
@param bom: BoM of particular product. @param bom: BoM of particular product.
@param factor: Factor of product UoM. @param factor: Factor of product UoM.
@ -577,7 +579,7 @@ class mrp_production(osv.osv):
self.write(cr, uid, ids, {'state': 'picking_except'}) self.write(cr, uid, ids, {'state': 'picking_except'})
return True return True
def action_compute(self, cr, uid, ids, properties=[], context=None): def action_compute(self, cr, uid, ids, properties=None, context=None):
""" Computes bills of material of a product. """ Computes bills of material of a product.
@param properties: List containing dictionaries of properties. @param properties: List containing dictionaries of properties.
@return: No. of products. @return: No. of products.

View File

@ -33,7 +33,7 @@ class procurement_order(osv.osv):
'property_ids': fields.many2many('mrp.property', 'procurement_property_rel', 'procurement_id','property_id', 'Properties'), 'property_ids': fields.many2many('mrp.property', 'procurement_property_rel', 'procurement_id','property_id', 'Properties'),
} }
def check_produce_product(self, cr, uid, procurement, context=[]): def check_produce_product(self, cr, uid, procurement, context=None):
""" Finds the bill of material for the product from procurement order. """ Finds the bill of material for the product from procurement order.
@return: True or False @return: True or False
""" """

View File

@ -35,7 +35,7 @@ class bom_structure(report_sxw.rml_parse):
def get_children(self, object, level=0): def get_children(self, object, level=0):
result = [] result = []
def _get_rec(object,level): def _get_rec(object, level):
for l in object: for l in object:
res = {} res = {}
res['name'] = l.name res['name'] = l.name

View File

@ -372,7 +372,7 @@ class mrp_production(osv.osv):
pass pass
return result return result
def action_compute(self, cr, uid, ids, properties=[], context=None): def action_compute(self, cr, uid, ids, properties=None, context=None):
""" Computes bills of material of a product and planned date of work order. """ Computes bills of material of a product and planned date of work order.
@param properties: List containing dictionaries of properties. @param properties: List containing dictionaries of properties.
@return: No. of products. @return: No. of products.

View File

@ -132,7 +132,7 @@ class plugin_handler(osv.osv_memory):
return ('res.partner', partner_id, url) return ('res.partner', partner_id, url)
# Specific to outlook rfc822 is not available so we split in arguments headerd,body,attachemnts # Specific to outlook rfc822 is not available so we split in arguments headerd,body,attachemnts
def push_message_outlook(self, cr, uid, model, headers,res_id=0 ,body_text=False, body_html=False, attachments=False): def push_message_outlook(self, cr, uid, model, headers, res_id=0 , body_text=False, body_html=False, attachments=False):
# ---------------------------------------- # ----------------------------------------
# solution 1 # solution 1
# construct a fake rfc822 from the separated arguement # construct a fake rfc822 from the separated arguement

View File

@ -38,13 +38,13 @@ class all_closed_cashbox_of_the_day(report_sxw.rml_parse):
'get_net_total_starting':self._get_net_total_starting, 'get_net_total_starting':self._get_net_total_starting,
}) })
def _get_user(self,line_ids): def _get_user(self, line_ids):
sql = "select name from res_users where id = %d"%(line_ids['create_uid']) sql = "select name from res_users where id = %d"%(line_ids['create_uid'])
self.cr.execute(sql) self.cr.execute(sql)
user = self.cr.fetchone() user = self.cr.fetchone()
return user[0] return user[0]
def _get_data(self,user): def _get_data(self, user):
data = {} data = {}
sql = """ SELECT abs.journal_id,abs.id,abs.date,abs.closing_date,abs.name as statement,aj.name as journal,ap.name as period,ru.name as user,rc.name as company, sql = """ SELECT abs.journal_id,abs.id,abs.date,abs.closing_date,abs.name as statement,aj.name as journal,ap.name as period,ru.name as user,rc.name as company,
abs.state,abs.balance_end_real FROM account_bank_statement as abs abs.state,abs.balance_end_real FROM account_bank_statement as abs
@ -57,7 +57,7 @@ class all_closed_cashbox_of_the_day(report_sxw.rml_parse):
data = self.cr.dictfetchall() data = self.cr.dictfetchall()
return data return data
def _get_lines(self,statement): def _get_lines(self, statement):
data = {} data = {}
sql = """ select absl.* from account_bank_statement_line as absl, account_bank_statement as abs sql = """ select absl.* from account_bank_statement_line as absl, account_bank_statement as abs
where absl.statement_id = abs.id and abs.id = %d"""%(statement['id']) where absl.statement_id = abs.id and abs.id = %d"""%(statement['id'])
@ -65,7 +65,7 @@ class all_closed_cashbox_of_the_day(report_sxw.rml_parse):
data = self.cr.dictfetchall() data = self.cr.dictfetchall()
return data return data
def _get_bal(self,data): def _get_bal(self, data):
res = {} res = {}
sql =""" select sum(pieces*number) as bal from account_cashbox_line where starting_id = %d """%(data['id']) sql =""" select sum(pieces*number) as bal from account_cashbox_line where starting_id = %d """%(data['id'])
self.cr.execute(sql) self.cr.execute(sql)
@ -75,7 +75,7 @@ class all_closed_cashbox_of_the_day(report_sxw.rml_parse):
else: else:
return False return False
def _get_sub_total(self,user,data,date): def _get_sub_total(self, user, data, date):
res={} res={}
self.cr.execute(""" select sum(absl.amount) from account_bank_statement as abs self.cr.execute(""" select sum(absl.amount) from account_bank_statement as abs
LEFT JOIN account_bank_statement_line as absl ON abs.id = absl.statement_id LEFT JOIN account_bank_statement_line as absl ON abs.id = absl.statement_id
@ -90,7 +90,7 @@ class all_closed_cashbox_of_the_day(report_sxw.rml_parse):
else: else:
return False return False
def _get_partner(self,statement): def _get_partner(self, statement):
res = {} res = {}
if statement['pos_statement_id']: if statement['pos_statement_id']:
sql =""" select rp.name from account_bank_statement_line as absl,res_partner as rp sql =""" select rp.name from account_bank_statement_line as absl,res_partner as rp
@ -102,7 +102,7 @@ class all_closed_cashbox_of_the_day(report_sxw.rml_parse):
else: else:
return 0.00 return 0.00
def _get_net_total_starting(self,user): def _get_net_total_starting(self, user):
lst = [] lst = []
res={} res={}
total_ending_bal = 0.0 total_ending_bal = 0.0
@ -124,7 +124,7 @@ class all_closed_cashbox_of_the_day(report_sxw.rml_parse):
lst.append(total_starting_bal) lst.append(total_starting_bal)
return lst return lst
def _get_net_total(self,user): def _get_net_total(self, user):
res={} res={}
sql = """select sum(absl.amount) as net_total from account_bank_statement as abs sql = """select sum(absl.amount) as net_total from account_bank_statement as abs
LEFT JOIN account_bank_statement_line as absl ON abs.id = absl.statement_id LEFT JOIN account_bank_statement_line as absl ON abs.id = absl.statement_id

View File

@ -24,7 +24,7 @@ from report import report_sxw
class pos_details(report_sxw.rml_parse): class pos_details(report_sxw.rml_parse):
def _get_invoice(self,inv_id): def _get_invoice(self, inv_id):
res={} res={}
if inv_id: if inv_id:
self.cr.execute("select number from account_invoice as ac where id = %s", (inv_id,)) self.cr.execute("select number from account_invoice as ac where id = %s", (inv_id,))
@ -37,7 +37,7 @@ class pos_details(report_sxw.rml_parse):
user_obj = self.pool.get('res.users') user_obj = self.pool.get('res.users')
return user_obj.search(self.cr, self.uid, []) return user_obj.search(self.cr, self.uid, [])
def _pos_sales_details(self,form): def _pos_sales_details(self, form):
pos_obj = self.pool.get('pos.order') pos_obj = self.pool.get('pos.order')
user_obj = self.pool.get('res.users') user_obj = self.pool.get('res.users')
data = [] data = []
@ -74,7 +74,7 @@ class pos_details(report_sxw.rml_parse):
def _get_sales_total_2(self): def _get_sales_total_2(self):
return self.total return self.total
def _get_sum_invoice_2(self,form): def _get_sum_invoice_2(self, form):
pos_obj = self.pool.get('pos.order') pos_obj = self.pool.get('pos.order')
user_obj = self.pool.get('res.users') user_obj = self.pool.get('res.users')
user_ids = form['user_ids'] or self._get_all_users() user_ids = form['user_ids'] or self._get_all_users()

View File

@ -42,7 +42,7 @@ class pos_details_summary(report_sxw.rml_parse):
'getcompany':self.get_company 'getcompany':self.get_company
}) })
def get_company(self,objects): def get_company(self, objects):
comp=[obj.company_id.name for obj in objects] comp=[obj.company_id.name for obj in objects]
return '%s' % (comp[0]) return '%s' % (comp[0])

Some files were not shown because too many files have changed in this diff Show More