[MERGE] trunk-unmutable-defaults-abo: fix the last few methods that still have mutable defaults

also improve code style (methods signatures and whitespaces)
contribution of Lionel Sausin from Numerigraphe

bzr revid: abo@openerp.com-20121002120634-ms2ins653tktqfnt
This commit is contained in:
Antonin Bourguignon 2012-10-02 14:06:34 +02:00
commit c28dfb19e1
193 changed files with 655 additions and 581 deletions

View File

@ -595,12 +595,15 @@ class account_account(osv.osv):
res.append((record['id'], name))
return res
def copy(self, cr, uid, id, default={}, context=None, done_list=[], local=False):
def copy(self, cr, uid, id, default=None, context=None, done_list=None, local=False):
if default is None:
default = {}
else:
default = default.copy()
if done_list is None:
done_list = []
account = self.browse(cr, uid, id, context=context)
new_child_ids = []
if not default:
default = {}
default = default.copy()
default.update(code=_("%s (copy)") % (account['code'] or ''))
if not local:
done_list = []
@ -777,11 +780,14 @@ class account_journal(osv.osv):
(_check_currency, 'Configuration error!\nThe currency chosen should be shared by the default accounts too.', ['currency','default_debit_account_id','default_credit_account_id']),
]
def copy(self, cr, uid, id, default={}, context=None, done_list=[], local=False):
journal = self.browse(cr, uid, id, context=context)
if not default:
def copy(self, cr, uid, id, default=None, context=None, done_list=None, local=False):
if default is None:
default = {}
else:
default = default.copy()
if done_list is None:
done_list = []
journal = self.browse(cr, uid, id, context=context)
default.update(
code=_("%s (copy)") % (journal['code'] or ''),
name=_("%s (copy)") % (journal['name'] or ''),
@ -1178,7 +1184,7 @@ class account_fiscalyear(osv.osv):
'end_journal_period_id':fields.many2one('account.journal.period','End of Year Entries Journal', readonly=True),
}
def copy(self, cr, uid, id, default={}, context=None):
def copy(self, cr, uid, id, default=None, context=None):
default.update({
'period_ids': [],
'end_journal_period_id': False
@ -1437,9 +1443,15 @@ class account_move(osv.osv):
result = super(account_move, self).create(cr, uid, vals, context)
return result
def copy(self, cr, uid, id, default={}, context=None):
def copy(self, cr, uid, id, default=None, context=None):
if context is None:
default = {}
else:
default = default.copy()
if context is None:
context = {}
else:
context = context.copy()
default.update({
'state':'draft',
'name':'/',
@ -2269,7 +2281,10 @@ class account_model(osv.osv):
_defaults = {
'legend': lambda self, cr, uid, context:_('You can specify year, month and date in the name of the model using the following labels:\n\n%(year)s: To Specify Year \n%(month)s: To Specify Month \n%(date)s: Current Date\n\ne.g. My model on %(date)s'),
}
def generate(self, cr, uid, ids, datas={}, context=None):
def generate(self, cr, uid, ids, data=None, context=None):
if data is None:
data = {}
move_ids = []
entry = {}
account_move_obj = self.pool.get('account.move')
@ -2280,8 +2295,8 @@ class account_model(osv.osv):
if context is None:
context = {}
if datas.get('date', False):
context.update({'date': datas['date']})
if data.get('date', False):
context.update({'date': data['date']})
move_date = context.get('date', time.strftime('%Y-%m-%d'))
move_date = datetime.strptime(move_date,"%Y-%m-%d")
@ -2467,10 +2482,10 @@ class account_subscription_line(osv.osv):
all_moves = []
obj_model = self.pool.get('account.model')
for line in self.browse(cr, uid, ids, context=context):
datas = {
data = {
'date': line.date,
}
move_ids = obj_model.generate(cr, uid, [line.subscription_id.model_id.id], datas, context)
move_ids = obj_model.generate(cr, uid, [line.subscription_id.model_id.id], data, context)
tocheck[line.subscription_id.id] = True
self.write(cr, uid, [line.id], {'move_id':move_ids[0]})
all_moves.extend(move_ids)
@ -3236,7 +3251,7 @@ class wizard_multi_charts_accounts(osv.osv_memory):
property_obj.create(cr, uid, vals, context=context)
return True
def _install_template(self, cr, uid, template_id, company_id, code_digits=None, obj_wizard=None, acc_ref={}, taxes_ref={}, tax_code_ref={}, context=None):
def _install_template(self, cr, uid, template_id, company_id, code_digits=None, obj_wizard=None, acc_ref=None, taxes_ref=None, tax_code_ref=None, context=None):
'''
This function recursively loads the template objects and create the real objects from them.
@ -3254,6 +3269,12 @@ class wizard_multi_charts_accounts(osv.osv_memory):
* a last identical containing the mapping of tax code templates and tax codes
:rtype: tuple(dict, dict, dict)
'''
if acc_ref is None:
acc_ref = {}
if taxes_ref is None:
taxes_ref = {}
if tax_code_ref is None:
tax_code_ref = {}
template = self.pool.get('account.chart.template').browse(cr, uid, template_id, context=context)
if template.parent_id:
tmp1, tmp2, tmp3 = self._install_template(cr, uid, template.parent_id.id, company_id, code_digits=code_digits, acc_ref=acc_ref, taxes_ref=taxes_ref, tax_code_ref=tax_code_ref, context=context)
@ -3266,7 +3287,7 @@ class wizard_multi_charts_accounts(osv.osv_memory):
tax_code_ref.update(tmp3)
return acc_ref, taxes_ref, tax_code_ref
def _load_template(self, cr, uid, template_id, company_id, code_digits=None, obj_wizard=None, account_ref={}, taxes_ref={}, tax_code_ref={}, context=None):
def _load_template(self, cr, uid, template_id, company_id, code_digits=None, obj_wizard=None, account_ref=None, taxes_ref=None, tax_code_ref=None, context=None):
'''
This function generates all the objects from the templates
@ -3284,6 +3305,12 @@ class wizard_multi_charts_accounts(osv.osv_memory):
* a last identical containing the mapping of tax code templates and tax codes
:rtype: tuple(dict, dict, dict)
'''
if account_ref is None:
account_ref = {}
if taxes_ref is None:
taxes_ref = {}
if tax_code_ref is None:
tax_code_ref = {}
template = self.pool.get('account.chart.template').browse(cr, uid, template_id, context=context)
obj_tax_code_template = self.pool.get('account.tax.code.template')
obj_acc_tax = self.pool.get('account.tax')

View File

@ -29,12 +29,12 @@ class bank(osv.osv):
'currency_id': fields.related('journal_id', 'currency', type="many2one", relation='res.currency', readonly=True,
string="Currency", help="Currency of the related account journal."),
}
def create(self, cr, uid, data, context={}):
def create(self, cr, uid, data, context=None):
result = super(bank, self).create(cr, uid, data, context=context)
self.post_write(cr, uid, [result], context=context)
return result
def write(self, cr, uid, ids, data, context={}):
def write(self, cr, uid, ids, data, context=None):
result = super(bank, self).write(cr, uid, ids, data, context=context)
self.post_write(cr, uid, ids, context=context)
return result
@ -53,7 +53,7 @@ class bank(osv.osv):
data['currency_name'] = data['currency_id'] and currency_name[data['currency_id'][0]] or ''
return super(bank, self)._prepare_name_get(cr, uid, bank_dicts, context=context)
def post_write(self, cr, uid, ids, context={}):
def post_write(self, cr, uid, ids, context=None):
if isinstance(ids, (int, long)):
ids = [ids]

View File

@ -1105,7 +1105,7 @@ class account_move_line(osv.osv):
'has been confirmed.') % res[2])
return res
def _remove_move_reconcile(self, cr, uid, move_ids=[], context=None):
def _remove_move_reconcile(self, cr, uid, move_ids=None, context=None):
# Function remove move rencocile ids related with moves
obj_move_line = self.pool.get('account.move.line')
obj_move_rec = self.pool.get('account.move.reconcile')

View File

@ -68,7 +68,7 @@ class account_balance(report_sxw.rml_parse, common_report_header):
return self.pool.get('account.account').browse(self.cr, self.uid, data['form']['id']).company_id.name
return super(account_balance ,self)._get_account(data)
def lines(self, form, ids=[], done=None):#, level=1):
def lines(self, form, ids=None, done=None):
def _process_child(accounts, disp_acc, parent):
account_rec = [acct for acct in accounts if acct['id']==parent][0]
currency_obj = self.pool.get('res.currency')

View File

@ -160,7 +160,7 @@ class tax_report(report_sxw.rml_parse, common_report_header):
i+=1
return res
def _get_codes(self, based_on, company_id, parent=False, level=0, period_list=[], context=None):
def _get_codes(self, based_on, company_id, parent=False, level=0, period_list=None, context=None):
obj_tc = self.pool.get('account.tax.code')
ids = obj_tc.search(self.cr, self.uid, [('parent_id','=',parent),('company_id','=',company_id)], order='sequence', context=context)
@ -171,7 +171,11 @@ class tax_report(report_sxw.rml_parse, common_report_header):
res += self._get_codes(based_on, company_id, code.id, level+1, context=context)
return res
def _add_codes(self, based_on, account_list=[], period_list=[], context=None):
def _add_codes(self, based_on, account_list=None, period_list=None, context=None):
if account_list is None:
account_list = []
if period_list is None:
period_list = []
res = []
obj_tc = self.pool.get('account.tax.code')
for account in account_list:

View File

@ -45,4 +45,3 @@ class res_currency_account(osv.osv):
res_currency_account()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -38,7 +38,7 @@ class account_move_journal(osv.osv_memory):
_defaults = {
'target_move': 'all'
}
def _get_period(self, cr, uid, context={}):
def _get_period(self, cr, uid, context=None):
"""
Return default account period value
"""

View File

@ -112,7 +112,9 @@ class crossovered_analytic(report_sxw.rml_parse):
result.append(res)
return result
def _lines(self, form, ids={}):
def _lines(self, form, ids=None):
if ids is None:
ids = {}
if not ids:
ids = self.ids

View File

@ -75,7 +75,7 @@ class account_asset_asset(osv.osv):
_name = 'account.asset.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)
if periods:
return periods[0]
@ -176,7 +176,9 @@ class account_asset_asset(osv.osv):
year = depreciation_date.year
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, {
'state':'open'
}, context)
@ -304,7 +306,7 @@ class account_asset_asset(osv.osv):
default.update({'depreciation_line_ids': [], 'state': 'draft'})
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 = []
period_obj = self.pool.get('account.period')
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
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:
ids = self.ids
if not done:

View File

@ -34,7 +34,9 @@ class budget_report(report_sxw.rml_parse):
})
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:
ids = self.ids
if not done:

View File

@ -37,7 +37,9 @@ class budget_report(report_sxw.rml_parse):
})
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:
ids = self.ids
if not done:

View File

@ -26,7 +26,7 @@ from tools.translate import _
class account_move_line(osv.osv):
_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
(excepting cancelled orders)"""
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)
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({
'state': 'draft',
'line_ids': [],

View File

@ -1275,7 +1275,9 @@ class account_voucher(osv.osv):
self.reconcile_send_note(cr, uid, [voucher.id], context=context)
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({
'state': 'draft',
'number': False,

View File

@ -202,7 +202,7 @@ class audittrail_objects_proxy(object_proxy):
res = value
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
@ -211,6 +211,8 @@ class audittrail_objects_proxy(object_proxy):
@param model: Object which values are being changed
@param lines: List of values for line is to be created
"""
if lines is None:
lines = []
pool = pooler.get_pool(cr.dbname)
obj_pool = pool.get(model.model)
model_pool = pool.get('ir.model')
@ -349,7 +351,7 @@ class audittrail_objects_proxy(object_proxy):
data[(model.id, resource_id)] = {'text':values_text, 'value': values}
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
(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):
The reason why the structure returned is build as above is because when modifying an existing
record, we may have to log a change done in a x2many field of that object
"""
if field_list is None:
field_list = []
key = (model.id, resource_id)
lines = {
key: []
@ -416,7 +420,7 @@ class audittrail_objects_proxy(object_proxy):
lines[key].append(data)
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
data (i.e before the method was executed) and the new data and creates audittrail log
@ -435,6 +439,8 @@ class audittrail_objects_proxy(object_proxy):
on specific fields only.
:return: True
"""
if field_list is None:
field_list = []
# loop on all the given ids
for res_id in res_ids:
# compare old and new values and get audittrail log lines accordingly

View File

@ -47,7 +47,9 @@ import logging
magic_md5 = '$1$'
_logger = logging.getLogger(__name__)
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()
return ''.join( sample( symbols, length ) )

View File

@ -58,9 +58,11 @@ class DomApiGeneral:
temp = string.replace("""%""","")
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.
Optional: also test for certain attribute/value pairs."""
if attr_dict is None:
attr_dict = {}
children = []
for c in parent.childNodes:
if c.nodeType == c.ELEMENT_NODE and c.nodeName == name:

View File

@ -215,7 +215,9 @@ class ConvertBracesToField( unohelper.Base, XJobExecutor ):
sObject = self.getRes(sock,res[myval]['relation'], sVar[sVar.find("/")+1:])
return sObject
def getBraces(self,aReportSyntex=[]):
def getBraces(self, aReportSyntex=None):
if aReportSyntex is None:
aReportSyntex = []
desktop=getDesktop()
doc = desktop.getCurrentComponent()
aSearchString=[]

View File

@ -117,7 +117,6 @@ class ServerParameter( unohelper.Base, XJobExecutor ):
#self.win.doModalDialog("lstDatabase",docinfo.getUserFieldValue(2))
def btnOk_clicked(self, oActionEvent):
sLogin=self.win.getEditText("txtLoginName")
sPassword=self.win.getEditText("txtPassword")
global url
@ -157,7 +156,6 @@ class ServerParameter( unohelper.Base, XJobExecutor ):
self.logobj.log_write('successful login',LOG_INFO, ': successful login from %s using database %s' % (sLogin, sDatabase))
self.win.endExecute()
def btnCancel_clicked(self, oActionEvent):
self.win.endExecute()
@ -172,5 +170,4 @@ if __name__<>"package" and __name__=="__main__":
elif __name__=="package":
g_ImplementationHelper.addImplementation( ServerParameter, "org.openoffice.openerp.report.serverparam", ("com.sun.star.task.Job",),)
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -59,7 +59,13 @@ if __name__<>"package":
database="test"
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:
global url
sock=RPCSession(url)

View File

@ -45,5 +45,4 @@ class Logger(object):
def shutdown(self):
logging.shutdown()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -10,7 +10,13 @@ import time
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 = []
if recur is None:
recur = []
res = sock.execute('terp', 3, 'admin', 'account.invoice', 'fields_get')
key = res.keys()
key.sort()

View File

@ -217,7 +217,6 @@ class crm_case_resource_type(osv.osv):
'section_id': fields.many2one('crm.case.section', 'Sales Team'),
}
def _links_get(self, cr, uid, context=None):
"""Gets links value for reference field"""
obj = self.pool.get('res.request.link')

View File

@ -311,7 +311,6 @@ class crm_lead(base_stage, format_address, osv.osv):
}
return {'value' : values}
def _check(self, cr, uid, ids=False, context=None):
""" Override of the base.stage method.
Function called by the scheduler to process cases for date actions

View File

@ -139,9 +139,9 @@ class crm_helpdesk(base_state, base_stage, osv.osv):
return super(crm_helpdesk,self).message_update(cr, uid, ids, msg, update_vals=update_vals, context=context)
# ******************************
# ---------------------------------------------------
# OpenChatter
# ******************************
# ---------------------------------------------------
def case_get_note_msg_prefix(self, cr, uid, id, context=None):
""" override of default base_state method. """
@ -152,5 +152,4 @@ class crm_helpdesk(base_state, base_stage, osv.osv):
self.message_post(cr, uid, ids, body=msg, context=context)
return True
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -77,7 +77,7 @@ def _get_parents(cr, uid, ids):
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
@param cr: the current row, from the database cursor,

View File

@ -104,7 +104,6 @@ class indexer(object):
def __repr__(self):
return "<indexer %s.%s>" %(self.__module__, self.__class__.__name__)
def mime_match(mime, mdict):
if mdict.has_key(mime):
return (mime, mdict[mime])

View File

@ -149,7 +149,7 @@ class document_file(osv.osv):
_sql_constraints = [
# 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)
parent_id = vals.get('parent_id', False)
res_model = vals.get('res_model', False)

View File

@ -234,7 +234,7 @@ class document_directory(osv.osv):
default.update(name=_("%s (copy)") % (name))
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)
parent_id=vals.get('parent_id',False)
ressource_parent_type_id=vals.get('ressource_parent_type_id',False)

View File

@ -434,7 +434,9 @@ class node_database(node_class):
"""
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)
self.unixperms = 040750
self.uidperms = 5
@ -666,7 +668,6 @@ class node_dir(node_database):
return dirobj.create(cr, uid, val)
def create_child(self, cr, path, data=None):
""" API function to create a child file object and node
Return the node_* created
@ -1210,7 +1211,6 @@ class node_file(node_class):
return False
return self.file_id == other.file_id
def open_data(self, cr, mode):
stor = self.storage_id
assert stor, "No storage for file #%s." % self.file_id
@ -1395,7 +1395,6 @@ class node_content(node_class):
if res and res[0][0]:
self.mimetype = str(res[0][0])
def get_data(self, cr, fil_obj=None):
cntobj = self.context._dirobj.pool.get('document.directory.content')
if not self.check_perms(4):
@ -1558,5 +1557,4 @@ class nodefd_static(StringIO, node_descriptor):
cr.close()
StringIO.close(self)
#eof
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

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

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

@ -683,7 +683,7 @@ class DAVClient(object):
assert d2 == d, "Data does not match"
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
@param noclobber will prevent overwritting a resource (If-None-Match)
@param mime will set the content-type
@ -705,5 +705,4 @@ class DAVClient(object):
etag = m.getheader('ETag')
return etag or True
#eof
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

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

@ -338,7 +338,8 @@ class _html2text(sgmllib.SGMLParser):
def pbr(self):
if self.p_p == 0: self.p_p = 1
def p(self): self.p_p = 2
def p(self):
self.p_p = 2
def o(self, data, puredata=0, force=0):
if self.abbr_data is not None: self.abbr_data += data
@ -411,7 +412,8 @@ class _html2text(sgmllib.SGMLParser):
if r'\/script>' in data: self.quiet -= 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'))

View File

@ -223,6 +223,7 @@ class event_event(osv.osv):
'company_id': lambda self,cr,uid,c: self.pool.get('res.company')._company_default_get(cr, uid, 'event.event', context=c),
'user_id': lambda obj, cr, uid, context: uid,
}
def subscribe_to_event(self, cr, uid, ids, context=None):
register_pool = self.pool.get('event.registration')
user_pool = self.pool.get('res.users')
@ -252,6 +253,7 @@ class event_event(osv.osv):
_constraints = [
(_check_closing_date, 'Error ! Closing Date cannot be set before Beginning Date.', ['date_end']),
]
def onchange_event_type(self, cr, uid, ids, type_event, context=None):
if type_event:
type_info = self.pool.get('event.type').browse(cr,uid,type_event,context)
@ -347,7 +349,6 @@ class event_registration(osv.osv):
'phone': fields.char('Phone', size=64),
'name': fields.char('Name', size=128, select=True),
}
_defaults = {
'nb_register': 1,
'state': 'draft',

View File

@ -43,6 +43,7 @@ class hr_evaluation_plan(osv.osv):
'month_next': 12,
'company_id': lambda s,cr,uid,c: s.pool.get('res.company')._company_default_get(cr, uid, 'account.account', context=c),
}
hr_evaluation_plan()
class hr_evaluation_plan_phase(osv.osv):
@ -95,6 +96,7 @@ Thanks,
'''),
}
hr_evaluation_plan_phase()
class hr_employee(osv.osv):
@ -210,8 +212,6 @@ class hr_evaluation(osv.osv):
elif phase.action == "self":
children = [evaluation.employee_id]
for child in children:
# if not child.user_id:
# continue
int_id = hr_eval_inter_obj.create(cr, uid, {
'evaluation_id': evaluation.id,

View File

@ -494,7 +494,6 @@ class hr_applicant(base_stage, osv.Model):
message = _("Applicant has been <b>created</b>.")
return self.message_post(cr, uid, ids, body=message, context=context)
class hr_job(osv.osv):
_inherit = "hr.job"
_name = "hr.job"
@ -505,7 +504,6 @@ class hr_job(osv.osv):
help="Email alias for this job position. New emails will automatically "
"create new applicants for this job position."),
}
_defaults = {
'alias_domain': False, # always hide alias during creation
}

View File

@ -199,6 +199,7 @@ class hr_analytic_timesheet(osv.osv):
hr_analytic_timesheet()
class account_invoice(osv.osv):
_inherit = "account.invoice"
@ -218,6 +219,7 @@ class account_invoice(osv.osv):
account_invoice()
class account_move_line(osv.osv):
_inherit = "account.move.line"
@ -234,4 +236,3 @@ class account_move_line(osv.osv):
account_move_line()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -38,7 +38,7 @@ class account_analytic_line(osv.osv):
# 'price': boolean
# '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')
res_partner_obj = self.pool.get('res.partner')
account_payment_term_obj = self.pool.get('account.payment.term')
@ -52,6 +52,8 @@ class account_analytic_line(osv.osv):
invoices = []
if context is None:
context = {}
if data is None:
data = {}
account_ids = {}
for line in self.pool.get('account.analytic.line').browse(cr, uid, ids, context=context):

View File

@ -39,6 +39,7 @@ class idea_category(osv.osv):
('name', 'unique(name)', 'The name of the category must be unique' )
]
_order = 'name asc'
idea_category()
class idea_idea(osv.osv):
@ -65,24 +66,24 @@ class idea_idea(osv.osv):
}
_order = 'name asc'
def idea_cancel(self, cr, uid, ids, context={}):
def idea_cancel(self, cr, uid, ids, context=None):
self.write(cr, uid, ids, { 'state': 'cancel' })
self.message_post(cr, uid, ids, body=_('Idea canceled.'), context=context)
return True
def idea_open(self, cr, uid, ids, context={}):
def idea_open(self, cr, uid, ids, context=None):
self.write(cr, uid, ids, { 'state': 'open'})
self.message_post(cr, uid, ids, body=_('Idea accepted.'), context=context)
return True
def idea_close(self, cr, uid, ids, context={}):
def idea_close(self, cr, uid, ids, context=None):
self.message_post(cr, uid, ids, body=_('Idea done.'), context=context)
self.write(cr, uid, ids, { 'state': 'close' })
return True
def idea_draft(self, cr, uid, ids, context={}):
def idea_draft(self, cr, uid, ids, context=None):
self.message_post(cr, uid, ids, body=_('Idea reset to draft.'), context=context)
self.write(cr, uid, ids, { 'state': 'draft' })
return True
idea_idea()
idea_idea()

View File

@ -171,6 +171,7 @@ class account_coda_trans_type(osv.osv):
'parent_id': fields.many2one('account.coda.trans.type', 'Parent'),
'description': fields.text('Description', translate=True),
}
account_coda_trans_type()
class account_coda_trans_code(osv.osv):
@ -187,6 +188,7 @@ class account_coda_trans_code(osv.osv):
'description': fields.char('Description', size=128, translate=True, select=2),
'comment': fields.text('Comment', translate=True),
}
account_coda_trans_code()
class account_coda_trans_category(osv.osv):
@ -197,6 +199,7 @@ class account_coda_trans_category(osv.osv):
'category': fields.char('Transaction Category', size=3, required=True),
'description': fields.char('Description', size=256, translate=True),
}
account_coda_trans_category()
class account_coda_comm_type(osv.osv):
@ -210,13 +213,16 @@ class account_coda_comm_type(osv.osv):
_sql_constraints = [
('code_uniq', 'unique (code)','The Structured Communication Code must be unique !')
]
account_coda_comm_type()
class coda_bank_statement(osv.osv):
_name = '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):
return context['journal_id']
return False
@ -232,7 +238,7 @@ class coda_bank_statement(osv.osv):
res[r] = round(res[r], 2)
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)
if periods:
return periods[0]
@ -404,6 +410,7 @@ class account_bank_statement_line_global(osv.osv):
_columns = {
'coda_statement_line_ids': fields.one2many('coda.bank.statement.line', 'globalisation_id', 'CODA Bank Statement Lines', readonly=True),
}
account_bank_statement_line_global()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -174,7 +174,7 @@ class account_invoice(osv.osv):
'\nPlease create manually a unique BBA Structured Communication.'))
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)):
ids = [ids]
for inv in self.browse(cr, uid, ids, context):
@ -204,7 +204,6 @@ class account_invoice(osv.osv):
'reference_type': fields.selection(_get_reference_type, 'Communication Type',
required=True),
}
_constraints = [
(_check_communication, 'Invalid BBA Structured Communication !', ['Communication']),
]

View File

@ -29,7 +29,6 @@ class l10n_fr_report(osv.osv):
'name': fields.char('Name', size=128),
'line_ids': fields.one2many('l10n.fr.line', 'report_id', 'Lines'),
}
_sql_constraints = [
('code_uniq', 'unique (code)','The code report must be unique !')
]
@ -61,7 +60,4 @@ class res_company(osv.osv):
res_company()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

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

View File

@ -274,13 +274,15 @@ class mrp_bom(osv.osv):
return {'value': {'name': prod.name, 'product_uom': prod.uom_id.id}}
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.
@param product_id: Selected product.
@param product_uom: Unit of measure of a product.
@param properties: List of related properties.
@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,))
ids = map(lambda x: x[0], cr.fetchall())
max_prop = 0
@ -295,7 +297,7 @@ class mrp_bom(osv.osv):
max_prop = prop
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.
@param bom: BoM of particular product.
@param factor: Factor of product UoM.
@ -609,11 +611,13 @@ class mrp_production(osv.osv):
self.write(cr, uid, ids, {'state': 'picking_except'})
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.
@param properties: List containing dictionaries of properties.
@return: No. of products.
"""
if properties is None:
properties = []
results = []
bom_obj = self.pool.get('mrp.bom')
uom_obj = self.pool.get('product.uom')

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'),
}
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.
@return: True or False
"""

View File

@ -422,7 +422,7 @@ class mrp_production(osv.osv):
pass
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.
@param properties: List containing dictionaries of properties.
@return: No. of products.

View File

@ -6,7 +6,6 @@ Created on 18 oct. 2011
from osv import osv, fields
class plugin_handler(osv.osv_memory):
_name = 'plugin.handler'
@ -61,7 +60,6 @@ class plugin_handler(osv.osv_memory):
name = self.pool.get(model).name_get(cr, uid, [res_id])[0][1]
return (model,res_id, url,name)
def document_type(self, cr, uid, context=None):
"""
Return the list of available model to push

View File

@ -24,6 +24,7 @@ from report import report_sxw
from osv import osv
import pooler
from tools.translate import _
class product_pricelist(report_sxw.rml_parse):
def __init__(self, cr, uid, name, context):
super(product_pricelist, self).__init__(cr, uid, name, context=context)
@ -123,5 +124,5 @@ class product_pricelist(report_sxw.rml_parse):
return price
report_sxw.report_sxw('report.product.pricelist','product.product','addons/product/report/product_pricelist.rml',parser=product_pricelist)
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -55,7 +55,6 @@ class project_task_type(osv.osv):
}
_order = 'sequence'
def short_name(name):
"""Keep first word(s) of name to make it small enough
but distinctive"""
@ -191,7 +190,6 @@ class project(osv.osv):
# Lambda indirection method to avoid passing a copy of the overridable method when declaring the field
_alias_models = lambda self, *args, **kwargs: self._get_alias_models(*args, **kwargs)
_columns = {
'complete_name': fields.function(_complete_name, string="Project Name", type='char', size=250),
'active': fields.boolean('Active', help="If the active field is set to False, it will allow you to hide the project without removing it."),
@ -311,11 +309,12 @@ class project(osv.osv):
task_obj.duplicate_task(cr, uid, map_task_id, context=context)
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:
context = {}
if default is None:
default = {}
default = default or {}
context['active_test'] = False
default['state'] = 'open'
default['tasks'] = []
@ -686,7 +685,9 @@ class task(base_stage, osv.osv):
#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))]})
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.update({'work_ids':[], 'date_start': False, 'date_end': False, 'date_deadline': False})
if not default.get('remaining_hours', False):
@ -699,7 +700,6 @@ class task(base_stage, osv.osv):
default.update({'name':new_name})
return super(task, self).copy_data(cr, uid, id, default, context)
def _is_template(self, cr, uid, ids, field_name, arg, context=None):
res = {}
for task in self.browse(cr, uid, ids, context=context):
@ -777,7 +777,6 @@ class task(base_stage, osv.osv):
'color': fields.integer('Color Index'),
'user_email': fields.related('user_id', 'email', type='char', string='User Email', readonly=True),
}
_defaults = {
'stage_id': _get_default_stage_id,
'project_id': _get_default_project_id,
@ -790,7 +789,6 @@ class task(base_stage, osv.osv):
'user_id': lambda obj, cr, uid, context: uid,
'company_id': lambda self, cr, uid, c: self.pool.get('res.company')._company_default_get(cr, uid, 'project.task', context=c),
}
_order = "priority, sequence, date_start, name, id"
def set_priority(self, cr, uid, ids, priority, *args):
@ -853,9 +851,8 @@ class task(base_stage, osv.osv):
(_check_recursion, 'Error ! You cannot create recursive tasks.', ['parent_ids']),
(_check_dates, 'Error ! Task end-date must be greater then task start-date', ['date_start','date_end'])
]
#
# Override view according to the company definition
#
def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False):
users_obj = self.pool.get('res.users')
if context is None: context = {}
@ -887,9 +884,9 @@ class task(base_stage, osv.osv):
res['fields'][f]['string'] = res['fields'][f]['string'].replace('Hours',tm)
return res
# ****************************************
# ----------------------------------------
# Case management
# ****************************************
# ----------------------------------------
def stage_find(self, cr, uid, cases, section_id, domain=[], order='sequence', context=None):
""" Override of the base.stage method
@ -1021,10 +1018,12 @@ class task(base_stage, osv.osv):
new_attachment_ids.append(attachment.copy(cr, uid, attachment_id, default={'res_id': delegated_task_id}, context=context))
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.
"""
if delegate_data is None:
delegate_data = {}
assert delegate_data['user_id'], _("Delegated User should be specified")
delegated_tasks = {}
for task in self.browse(cr, uid, ids, context=context):
@ -1170,7 +1169,7 @@ class task(base_stage, osv.osv):
return result
# ---------------------------------------------------
# mail gateway
# Mail gateway
# ---------------------------------------------------
def message_new(self, cr, uid, msg, custom_values=None, context=None):

View File

@ -31,9 +31,6 @@ import decimal_precision as dp
from osv.orm import browse_record, browse_null
from tools import DEFAULT_SERVER_DATE_FORMAT, DEFAULT_SERVER_DATETIME_FORMAT, DATETIME_FORMATS_MAP
#
# Model definition
#
class purchase_order(osv.osv):
def _amount_all(self, cr, uid, ids, field_name, arg, context=None):
@ -239,7 +236,6 @@ class purchase_order(osv.osv):
else:
raise osv.except_osv(_('Invalid Action!'), _('In order to delete a purchase order, you must cancel it first.'))
# TODO: temporary fix in 5.0, to remove in 5.2 when subflows support
# automatically sending subflow.delete upon deletion
wf_service = netsvc.LocalService("workflow")
for id in unlink_ids:
@ -380,7 +376,7 @@ class purchase_order(osv.osv):
for line in po.order_line:
if line.state=='draft':
todo.append(line.id)
# current_name = self.name_get(cr, uid, ids)[0][1]
self.pool.get('purchase.order.line').action_confirm(cr, uid, todo, context)
for id in ids:
self.write(cr, uid, [id], {'state' : 'confirmed', 'validator' : uid})
@ -665,7 +661,7 @@ class purchase_order(osv.osv):
list_key.sort()
return tuple(list_key)
# compute what the new orders should contain
# Compute what the new orders should contain
new_orders = {}
@ -1098,4 +1094,5 @@ class mail_mail(osv.osv):
return super(mail_mail, self)._postprocess_sent_message(cr, uid, mail=mail, context=context)
mail_mail()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -35,7 +35,7 @@ from webkit_report import WebKitParser
from report.report_sxw import 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
if netsvc.Service._services.get(name, False):
service = netsvc.Service._services[name]

View File

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

View File

@ -253,7 +253,7 @@ class sale_order(osv.osv):
return osv.osv.unlink(self, cr, uid, unlink_ids, context=context)
def onchange_pricelist_id(self, cr, uid, ids, pricelist_id, order_lines, context={}):
def onchange_pricelist_id(self, cr, uid, ids, pricelist_id, order_lines, context=None):
if (not pricelist_id) or (not order_lines):
return {}
warning = {
@ -262,7 +262,6 @@ class sale_order(osv.osv):
}
return {'warning': warning}
def onchange_partner_id(self, cr, uid, ids, part):
if not part:
return {'value': {'partner_invoice_id': False, 'partner_shipping_id': False, 'payment_term': False, 'fiscal_position': False}}
@ -437,7 +436,9 @@ class sale_order(osv.osv):
return False
return True
def action_invoice_create(self, cr, uid, ids, grouped=False, states=['confirmed', 'done', 'exception'], date_inv = False, context=None):
def action_invoice_create(self, cr, uid, ids, grouped=False, states=None, date_inv = False, context=None):
if states is None:
states = ['confirmed', 'done', 'exception']
res = False
invoices = {}
invoice_ids = []
@ -879,7 +880,7 @@ class sale_order_line(osv.osv):
'product_uos': []}}
if not date_order:
date_order = time.strftime(DEFAULT_SERVER_DATE_FORMAT)
#
result = {}
warning_msgs = {}
product_obj = product_obj.browse(cr, uid, product, context=context)
@ -995,6 +996,7 @@ class mail_compose_message(osv.osv):
wf_service = netsvc.LocalService("workflow")
wf_service.trg_validate(uid, 'sale.order', context.get('default_res_id', False), 'quotation_sent', cr)
return super(mail_compose_message, self).send_mail(cr, uid, ids, context=context)
mail_compose_message()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -42,7 +42,9 @@ class external_pdf(render):
class report_stock(report_int):
def create(self, cr, uid, ids, datas, context={}):
def create(self, cr, uid, ids, datas, context=None):
if context is None:
context = {}
product_ids = ids
if 'location_id' in context:
location_id = context['location_id']

View File

@ -74,10 +74,9 @@ class stock_report_prodlots(osv.osv):
group by location_id, product_id, prodlot_id
)""")
def unlink(self, cr, uid, ids, context={}):
def unlink(self, cr, uid, ids, context=None):
raise osv.except_osv(_('Error!'), _('You cannot delete any record!'))
stock_report_prodlots()
class stock_report_tracklots(osv.osv):
@ -131,7 +130,7 @@ class stock_report_tracklots(osv.osv):
group by location_id, product_id, tracking_id
)""")
def unlink(self, cr, uid, ids, context={}):
def unlink(self, cr, uid, ids, context=None):
raise osv.except_osv(_('Error!'), _('You cannot delete any record!'))
stock_report_tracklots()
@ -162,6 +161,7 @@ class report_stock_lines_date(osv.osv):
where p.active='true'
group by p.id
)""")
report_stock_lines_date()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -26,7 +26,7 @@ from report.interface import toxml
#FIXME: we should use toxml
class report_custom(report_rml):
def create_xml(self, cr, uid, ids, datas, context={}):
def create_xml(self, cr, uid, ids, datas, context=None):
config = """
<config>
<date>09/09/2005</date>

View File

@ -346,22 +346,28 @@ class stock_location(osv.osv):
})
return product_obj.get_product_available(cr, uid, product_ids, context=context)
def _product_get(self, cr, uid, id, product_ids=False, context=None, states=['done']):
def _product_get(self, cr, uid, id, product_ids=False, context=None, states=None):
"""
@param product_ids:
@param states:
@return:
"""
if states is None:
states = ['done']
ids = id and [id] or []
return self._product_get_multi_location(cr, uid, ids, product_ids, context=context, states=states)
def _product_all_get(self, cr, uid, id, product_ids=False, context=None, states=['done']):
def _product_all_get(self, cr, uid, id, product_ids=False, context=None, states=None):
if states is None:
states = ['done']
# build the list of ids of children of the location given by id
ids = id and [id] or []
location_ids = self.search(cr, uid, [('location_id', 'child_of', ids)])
return self._product_get_multi_location(cr, uid, location_ids, product_ids, context, states)
def _product_virtual_get(self, cr, uid, id, product_ids=False, context=None, states=['done']):
def _product_virtual_get(self, cr, uid, id, product_ids=False, context=None, states=None):
if states is None:
states = ['done']
return self._product_all_get(cr, uid, id, product_ids, context, ['confirmed', 'waiting', 'assigned', 'done'])
def _product_reserve(self, cr, uid, ids, product_id, product_qty, context=None, lock=False):
@ -522,7 +528,7 @@ class stock_tracking(osv.osv):
def unlink(self, cr, uid, ids, context=None):
raise osv.except_osv(_('Error!'), _('You cannot remove a lot line.'))
def action_traceability(self, cr, uid, ids, context={}):
def action_traceability(self, cr, uid, ids, context=None):
""" It traces the information of a product
@param self: The object pointer.
@param cr: A database cursor

View File

@ -406,7 +406,7 @@ class stock_planning(osv.osv):
res[val.id] = 'Future'
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 = {}
for val in self.browse(cr, uid, ids, context=context):
res[val.id]={}