[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

@ -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:

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

@ -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

@ -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

@ -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

@ -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

@ -58,9 +58,11 @@ class DomApiGeneral:
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:

View File

@ -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

@ -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)

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

@ -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

@ -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

@ -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

@ -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

@ -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

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

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

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

@ -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

@ -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

@ -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

@ -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

@ -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

@ -265,7 +265,7 @@ class project(osv.osv):
task_obj.duplicate_task(cr, uid, map_task_id, context=context) task_obj.duplicate_task(cr, uid, map_task_id, context=context)
return True return True
def copy(self, cr, uid, id, default={}, context=None): def copy(self, cr, uid, id, default=None, context=None):
if context is None: if context is None:
context = {} context = {}
@ -581,7 +581,9 @@ class task(osv.osv):
#FIXME why there is already the copy and the old one #FIXME why there is already the copy and the old one
self.write(cr, uid, new, {'parent_ids':[(6,0,set(parent_ids))], 'child_ids':[(6,0, set(child_ids))]}) self.write(cr, uid, new, {'parent_ids':[(6,0,set(parent_ids))], 'child_ids':[(6,0, set(child_ids))]})
def copy_data(self, cr, uid, id, default={}, context=None): def copy_data(self, cr, uid, id, default=None, context=None):
if default is None:
default = {}
default = default or {} default = default or {}
default.update({'work_ids':[], 'date_start': False, 'date_end': False, 'date_deadline': False}) default.update({'work_ids':[], 'date_start': False, 'date_end': False, 'date_deadline': False})
if not default.get('remaining_hours', False): if not default.get('remaining_hours', False):
@ -810,7 +812,7 @@ class task(osv.osv):
} }
return res return res
def do_close(self, cr, uid, ids, context={}): def do_close(self, cr, uid, ids, context=None):
""" """
Close Task Close Task
""" """
@ -868,7 +870,7 @@ class task(osv.osv):
self.write(cr, uid, [task.id], {'state': 'open'}, context=context) self.write(cr, uid, [task.id], {'state': 'open'}, context=context)
return True return True
def do_cancel(self, cr, uid, ids, context={}): def do_cancel(self, cr, uid, ids, context=None):
request = self.pool.get('res.request') request = self.pool.get('res.request')
tasks = self.browse(cr, uid, ids, context=context) tasks = self.browse(cr, uid, ids, context=context)
self._check_child_task(cr, uid, ids, context=context) self._check_child_task(cr, uid, ids, context=context)
@ -889,7 +891,7 @@ class task(osv.osv):
self.write(cr, uid, [task.id], {'state': 'cancelled', 'remaining_hours':0.0}, context=context) self.write(cr, uid, [task.id], {'state': 'cancelled', 'remaining_hours':0.0}, context=context)
return True return True
def do_open(self, cr, uid, ids, context={}): def do_open(self, cr, uid, ids, context=None):
if not isinstance(ids,list): ids = [ids] if not isinstance(ids,list): ids = [ids]
tasks= self.browse(cr, uid, ids, context=context) tasks= self.browse(cr, uid, ids, context=context)
for t in tasks: for t in tasks:
@ -901,7 +903,7 @@ class task(osv.osv):
self.log(cr, uid, t.id, message) self.log(cr, uid, t.id, message)
return True return True
def do_draft(self, cr, uid, ids, context={}): def do_draft(self, cr, uid, ids, context=None):
self.write(cr, uid, ids, {'state': 'draft'}, context=context) self.write(cr, uid, ids, {'state': 'draft'}, context=context)
return True return True
@ -915,10 +917,12 @@ class task(osv.osv):
return new_attachment_ids return new_attachment_ids
def do_delegate(self, cr, uid, ids, delegate_data={}, context=None): def do_delegate(self, cr, uid, ids, delegate_data=None, context=None):
""" """
Delegate Task to another users. Delegate Task to another users.
""" """
if delegate_data is None:
delegate_data = {}
assert delegate_data['user_id'], _("Delegated User should be specified") assert delegate_data['user_id'], _("Delegated User should be specified")
delegated_tasks = {} delegated_tasks = {}
for task in self.browse(cr, uid, ids, context=context): for task in self.browse(cr, uid, ids, context=context):
@ -950,7 +954,7 @@ class task(osv.osv):
delegated_tasks[task.id] = delegated_task_id delegated_tasks[task.id] = delegated_task_id
return delegated_tasks return delegated_tasks
def do_pending(self, cr, uid, ids, context={}): def do_pending(self, cr, uid, ids, context=None):
self.write(cr, uid, ids, {'state': 'pending'}, context=context) self.write(cr, uid, ids, {'state': 'pending'}, context=context)
for (id, name) in self.name_get(cr, uid, ids): for (id, name) in self.name_get(cr, uid, ids):
message = _("The task '%s' is pending.") % name message = _("The task '%s' is pending.") % name

View File

@ -47,7 +47,9 @@ class project_tasks(osv.osv):
self.write(cr, uid, [res_id], data, context) self.write(cr, uid, [res_id], data, context)
return res_id return res_id
def message_update(self, cr, uid, ids, msg, data={}, default_act='pending'): def message_update(self, cr, uid, ids, msg, data=None, default_act='pending'):
if data is None:
data = {}
data.update({ data.update({
'description': msg['body_text'], 'description': msg['body_text'],
}) })

View File

@ -35,7 +35,7 @@ from webkit_report import WebKitParser
from report.report_sxw import rml_parse from report.report_sxw import rml_parse
def register_report(name, model, tmpl_path, parser=rml_parse): def register_report(name, model, tmpl_path, parser=rml_parse):
"Register the report into the services" """Register the report into the services"""
name = 'report.%s' % name name = 'report.%s' % name
if netsvc.Service._services.get(name, False): if netsvc.Service._services.get(name, False):
service = netsvc.Service._services[name] service = netsvc.Service._services[name]

View File

@ -567,7 +567,8 @@ class _ValueWrapper(object):
return result return result
#@-node:_cmp #@-node:_cmp
#@+node:__getattr__ #@+node:__getattr__
def __getattr__(self, name): return getattr(self._value, name) def __getattr__(self, name):
return getattr(self._value, name)
#@-node:__getattr__ #@-node:__getattr__
#@+node:__getitem__ #@+node:__getitem__
def __getitem__(self, slice): def __getitem__(self, slice):

View File

@ -53,7 +53,7 @@ class sale_order_line(osv.osv):
seq += 1 seq += 1
return invoice_line_ids return invoice_line_ids
def onchange_sale_order_line_view(self, cr, uid, id, type, context={}, *args): def onchange_sale_order_line_view(self, cr, uid, id, type, context=None, *args):
temp = {} temp = {}
temp['value'] = {} temp['value'] = {}
if (not type): if (not type):

View File

@ -406,7 +406,7 @@ class stock_planning(osv.osv):
res[val.id] = 'Future' res[val.id] = 'Future'
return res return res
def _get_op(self, cr, uid, ids, field_names, arg, context=None): # op = OrderPoint def _get_op(self, cr, uid, ids, field_names, arg, context=None):
res = {} res = {}
for val in self.browse(cr, uid, ids, context=context): for val in self.browse(cr, uid, ids, context=context):
res[val.id]={} res[val.id]={}

4
addons/wiki/web/widgets/rss/feedparser.py Executable file → Normal file
View File

@ -2446,8 +2446,10 @@ def _stripDoctype(data):
data = doctype_pattern.sub('', data) data = doctype_pattern.sub('', data)
return version, data return version, data
def parse(url_file_stream_or_string, etag=None, modified=None, agent=None, referrer=None, handlers=[]): def parse(url_file_stream_or_string, etag=None, modified=None, agent=None, referrer=None, handlers=None):
'''Parse a feed from a URL, file, stream, or string''' '''Parse a feed from a URL, file, stream, or string'''
if handlers is None:
handlers = []
result = FeedParserDict() result = FeedParserDict()
result['feed'] = FeedParserDict() result['feed'] = FeedParserDict()
result['entries'] = [] result['entries'] = []

View File

@ -489,7 +489,7 @@ class BaseParser(object):
return text.encode("utf-8") return text.encode("utf-8")
return text return text
def strip(self, text, stripcomments=False, dontstrip=[]): def strip(self, text, stripcomments=False, dontstrip=None):
render = True render = True
commentState = {} commentState = {}
@ -2087,7 +2087,9 @@ mTagHooks = {}
# <quote cite="person">quote</quote> # <quote cite="person">quote</quote>
from cgi import escape from cgi import escape
def hook_quote(env, body, attributes={}): def hook_quote(env, body, attributes=None):
if attributes is None:
attributes = {}
text = [u'<div class="blockquote">'] text = [u'<div class="blockquote">']
if 'cite' in attributes: if 'cite' in attributes:
text.append(u"<strong class=\"cite\">%s wrote:</strong>\n" % escape(attributes['cite'])) text.append(u"<strong class=\"cite\">%s wrote:</strong>\n" % escape(attributes['cite']))