Default values should be immutable
Affects | Status | Importance | Assigned to | Milestone | ||
---|---|---|---|---|---|---|
Odoo Addons (MOVED TO GITHUB) | Status tracked in Trunk | |||||
Extra-trunk |
Opinion
|
Low
|
Unassigned | |||
Trunk |
Opinion
|
Low
|
OpenERP R&D Addons Team 2 | |||
Odoo GTK Client (MOVED TO GITHUB) |
Opinion
|
Low
|
OpenERP sa GTK client R&D | |||
Odoo Server (MOVED TO GITHUB) | Status tracked in Trunk | |||||
Trunk |
Fix Released
|
Low
|
Unassigned |
Bug Description
Often in the code base we have:
def foo(...., context={},....):
....
As explained in comment #1, this should be changed to
def foo(...., context=None,....):
# you should add this test only if the context is actually used
if context is None:
context={}
....
(This bug originally proposed the other way round hence the "nope" in comment #1.)
(xmo) Complements of information:
* The test should be `context is None` rather than `not context`: the caller could provide an empty dict argument {} and expect to have data in it after the call, if a test is done using `not context` an empty dict will match and the function will be creating a brand new context.
* The test should *only ever* performed when the current function fetches data from the context. If you don't do anything with the context but forward it to other functions and methods (e.g. read() or create()), no need to test for anything.
Related branches
- OpenERP Core Team: Pending requested
-
Diff: 543 lines (+87/-47)23 files modifiedhistory/check_profile_l10n_all.py (+3/-1)
openerp/addons/base/ir/ir_default.py (+1/-1)
openerp/addons/base/ir/ir_filters.py (+1/-1)
openerp/addons/base/ir/ir_model.py (+1/-1)
openerp/addons/base/ir/ir_sequence.py (+1/-1)
openerp/addons/base/ir/ir_translation.py (+1/-1)
openerp/addons/base/ir/ir_ui_view.py (+2/-2)
openerp/addons/base/ir/workflow/print_instance.py (+1/-1)
openerp/addons/base/ir/workflow/workflow.py (+2/-2)
openerp/addons/base/module/module.py (+1/-1)
openerp/addons/base/res/ir_property.py (+1/-1)
openerp/addons/base/res/res_bank.py (+3/-3)
openerp/addons/base/res/res_company.py (+4/-4)
openerp/addons/base/res/res_lang.py (+2/-2)
openerp/addons/base/res/res_log.py (+1/-1)
openerp/addons/base/res/res_partner.py (+15/-7)
openerp/addons/base/res/res_request.py (+1/-1)
openerp/report/render/rml2html/utils.py (+3/-1)
openerp/report/render/rml2pdf/trml2pdf.py (+22/-8)
openerp/report/render/rml2pdf/utils.py (+3/-1)
openerp/report/render/rml2txt/rml2txt.py (+8/-4)
openerp/report/render/rml2txt/utils.py (+3/-1)
openerp/tools/safe_eval.py (+7/-1)
- OpenERP Core Team: Pending requested
-
Diff: 4844 lines (+556/-493)241 files modifiedaccount/account.py (+39/-13)
account/account_bank.py (+3/-3)
account/account_move_line.py (+1/-1)
account/project/wizard/account_analytic_chart.py (+1/-1)
account/project/wizard/account_analytic_inverted_balance_report.py (+1/-1)
account/project/wizard/project_account_analytic_line.py (+1/-1)
account/report/account_balance.py (+1/-1)
account/report/account_central_journal.py (+1/-1)
account/report/account_general_journal.py (+1/-1)
account/report/account_report.py (+1/-1)
account/report/account_tax_report.py (+6/-2)
account/res_currency.py (+1/-1)
account/wizard/account_invoice_state.py (+1/-1)
account/wizard/account_journal_select.py (+1/-1)
account/wizard/account_move_bank_reconcile.py (+1/-1)
account/wizard/account_move_journal.py (+1/-1)
account/wizard/account_move_line_reconcile_select.py (+1/-1)
account/wizard/account_move_line_select.py (+1/-1)
account/wizard/account_move_line_unreconcile_select.py (+1/-1)
account/wizard/account_period_close.py (+1/-1)
account/wizard/account_reconcile.py (+1/-1)
account/wizard/account_reconcile_partner_process.py (+1/-1)
account/wizard/account_state_open.py (+1/-1)
account/wizard/account_subscription_generate.py (+1/-1)
account/wizard/account_unreconcile.py (+1/-1)
account_analytic_plans/report/crossovered_analytic.py (+6/-4)
account_analytic_plans/wizard/analytic_plan_create_model.py (+1/-1)
account_anglo_saxon/__init__.py (+1/-1)
account_anglo_saxon/sale.py (+0/-43)
account_asset/account_asset.py (+5/-3)
account_budget/report/analytic_account_budget_report.py (+5/-3)
account_budget/report/budget_report.py (+3/-1)
account_budget/report/crossovered_budget_report.py (+3/-1)
account_budget/wizard/account_budget_analytic.py (+1/-1)
account_budget/wizard/account_budget_crossovered_report.py (+1/-1)
account_budget/wizard/account_budget_report.py (+1/-1)
account_coda/account_coda.py (+4/-2)
account_followup/__init__.py (+1/-1)
account_followup/wizard/__init__.py (+1/-1)
account_followup/wizard/account_followup_print.py (+1/-1)
account_invoice_layout/wizard/account_invoice_special_message.py (+1/-1)
account_payment/__init__.py (+1/-1)
account_payment/account_invoice.py (+1/-1)
account_payment/account_move_line.py (+2/-2)
account_payment/account_payment.py (+3/-1)
account_payment/report/__init__.py (+1/-1)
account_payment/report/payment_order.py (+2/-2)
account_payment/wizard/__init__.py (+1/-1)
account_payment/wizard/account_payment_order.py (+1/-1)
account_payment/wizard/account_payment_pay.py (+1/-1)
account_payment/wizard/account_payment_populate_statement.py (+1/-1)
account_sequence/__init__.py (+1/-1)
account_voucher/__init__.py (+1/-1)
account_voucher/account_voucher.py (+4/-2)
account_voucher/report/__init__.py (+1/-1)
account_voucher/report/account_voucher.py (+1/-1)
account_voucher/report/account_voucher_print.py (+1/-1)
account_voucher/wizard/__init__.py (+1/-1)
account_voucher/wizard/account_voucher_unreconcile.py (+1/-1)
analytic/analytic.py (+1/-1)
anonymization/anonymization.py (+2/-2)
auction/auction.py (+1/-1)
auction/barcode/code39.py (+1/-1)
auction/barcode/common.py (+1/-1)
auction/report/auction_invoice.py (+1/-1)
auction/report/auction_total_rml.py (+4/-4)
auction/report/buyer_form_report.py (+1/-1)
auction/report/buyer_list.py (+1/-1)
auction/report/huissier.py (+1/-1)
auction/report/photo_shadow.py (+1/-1)
auction/report/seller_form_report.py (+1/-1)
audittrail/audittrail.py (+7/-3)
base_contact/base_contact.py (+3/-3)
base_crypt/crypt.py (+3/-1)
base_module_doc_rst/report/ir_module_reference_print_graph.py (+1/-1)
base_module_quality/__init__.py (+1/-1)
base_module_quality/base_module_quality.py (+15/-3)
base_module_quality/method_test/method_test.py (+1/-1)
base_module_quality/object_test/object_test.py (+1/-1)
base_module_quality/pep8_test/pep8_test.py (+1/-1)
base_module_quality/structure_test/structure_test.py (+1/-1)
base_module_quality/unit_test/unit_test.py (+1/-1)
base_module_quality/wizard/module_quality_check.py (+1/-1)
base_module_quality/wizard/quality_save_report.py (+1/-1)
base_module_quality/workflow_test/workflow_test.py (+1/-1)
base_module_record/wizard/base_module_record_objects.py (+1/-1)
base_module_record/wizard/base_module_save.py (+1/-1)
base_report_designer/openerp_sxw2rml/openerp_sxw2rml.py (+17/-15)
base_report_designer/plugin/openerp_report_designer/bin/script/About.py (+1/-1)
base_report_designer/plugin/openerp_report_designer/bin/script/AddAttachment.py (+8/-8)
base_report_designer/plugin/openerp_report_designer/bin/script/Change.py (+2/-2)
base_report_designer/plugin/openerp_report_designer/bin/script/ConvertBracesToField.py (+3/-3)
base_report_designer/plugin/openerp_report_designer/bin/script/ConvertFieldsToBraces.py (+1/-1)
base_report_designer/plugin/openerp_report_designer/bin/script/ExportToRML.py (+1/-1)
base_report_designer/plugin/openerp_report_designer/bin/script/Expression.py (+3/-3)
base_report_designer/plugin/openerp_report_designer/bin/script/Fields.py (+6/-6)
base_report_designer/plugin/openerp_report_designer/bin/script/ModifyExistingReport.py (+3/-3)
base_report_designer/plugin/openerp_report_designer/bin/script/NewReport.py (+3/-3)
base_report_designer/plugin/openerp_report_designer/bin/script/Repeatln.py (+4/-4)
base_report_designer/plugin/openerp_report_designer/bin/script/SendToServer.py (+4/-4)
base_report_designer/plugin/openerp_report_designer/bin/script/ServerParameter.py (+4/-4)
base_report_designer/plugin/openerp_report_designer/bin/script/Translation.py (+6/-6)
base_report_designer/plugin/openerp_report_designer/bin/script/lib/error.py (+1/-1)
base_report_designer/plugin/openerp_report_designer/bin/script/lib/functions.py (+14/-8)
base_report_designer/plugin/openerp_report_designer/bin/script/lib/logreport.py (+1/-1)
base_report_designer/plugin/openerp_report_designer/bin/script/lib/rpc.py (+2/-2)
base_report_designer/plugin/openerp_report_designer/bin/script/lib/tools.py (+3/-3)
base_report_designer/plugin/openerp_report_designer/bin/script/modify.py (+1/-1)
base_report_designer/plugin/openerp_report_designer/test/test_fields.py (+5/-1)
base_setup/base_setup.py (+1/-1)
base_synchro/base_synchro_obj.py (+5/-3)
base_vat/__init__.py (+1/-1)
base_vat/res_company.py (+1/-1)
caldav/caldav_node.py (+11/-11)
crm/crm.py (+3/-1)
crm/crm_lead.py (+1/-1)
crm_claim/crm_claim.py (+1/-1)
crm_helpdesk/crm_helpdesk.py (+1/-1)
crm_profiling/crm_profiling.py (+1/-1)
delivery/wizard/delivery_sale_order.py (+1/-1)
document/content_index.py (+4/-4)
document/document.py (+1/-1)
document/document_directory.py (+3/-3)
document/nodes.py (+26/-24)
document/odt2txt.py (+3/-3)
document/std_index.py (+8/-8)
document_webdav/document_webdav.py (+1/-1)
document_webdav/redirect.py (+1/-1)
document_webdav/test_davclient.py (+1/-1)
document_webdav/webdav.py (+1/-1)
document_webdav/webdav_server.py (+6/-6)
email_template/html2text.py (+4/-3)
email_template/wizard/mail_compose_message.py (+1/-1)
event/event.py (+1/-1)
event/report/__init__.py (+1/-1)
event/res_partner.py (+1/-1)
event/wizard/event_confirm.py (+1/-1)
event_moodle/event_moodle.py (+1/-1)
event_project/event_project.py (+1/-1)
event_project/wizard/event_project_retro.py (+1/-1)
hr_attendance/wizard/__init__.py (+1/-1)
hr_attendance/wizard/hr_attendance_bymonth.py (+1/-1)
hr_attendance/wizard/hr_attendance_byweek.py (+1/-1)
hr_attendance/wizard/hr_attendance_error.py (+1/-1)
hr_evaluation/hr_evaluation.py (+1/-1)
hr_payroll/report/report_contribution_register.py (+1/-1)
hr_payroll/report/report_payslip.py (+1/-1)
hr_payroll/report/report_payslip_details.py (+1/-1)
hr_payroll_account/__init__.py (+1/-1)
hr_payroll_account/wizard/__init__.py (+1/-1)
hr_payroll_account/wizard/hr_payroll_payslips_by_employees.py (+1/-1)
hr_recruitment/hr_recruitment.py (+1/-1)
hr_recruitment/wizard/hr_recruitment_create_partner_job.py (+2/-2)
hr_recruitment/wizard/hr_recruitment_employee_hired.py (+2/-2)
hr_timesheet_invoice/hr_timesheet_invoice.py (+1/-1)
hr_timesheet_invoice/report/account_analytic_profit.py (+1/-1)
hr_timesheet_invoice/wizard/hr_timesheet_invoice_create.py (+1/-1)
hr_timesheet_sheet/hr_timesheet_sheet.py (+2/-2)
hr_timesheet_sheet/wizard/hr_timesheet_current.py (+1/-1)
idea/idea.py (+1/-1)
import_base/import_framework.py (+1/-1)
import_sugarcrm/import_sugarcrm.py (+3/-3)
l10n_be/__init__.py (+1/-1)
l10n_be_invoice_bba/invoice.py (+6/-6)
l10n_br/l10n_br.py (+1/-1)
l10n_ch/partner.py (+1/-1)
l10n_ch/payment.py (+1/-1)
l10n_ch/report/report_webkit_html.py (+1/-1)
l10n_ch/wizard/create_dta.py (+1/-1)
l10n_fr/l10n_fr.py (+1/-1)
l10n_fr/report/base_report.py (+1/-1)
l10n_fr/wizard/fr_report_bilan.py (+1/-1)
l10n_fr/wizard/fr_report_compute_resultant.py (+1/-1)
l10n_lu/wizard/pdf_ext.py (+1/-1)
lunch/report/order.py (+2/-2)
mail/mail_thread.py (+1/-1)
membership/report/__init__.py (+1/-1)
membership/report/report_membership.py (+1/-1)
membership/wizard/__init__.py (+1/-1)
mrp/mrp.py (+5/-3)
mrp/procurement.py (+1/-1)
mrp/report/bom_structure.py (+2/-2)
mrp/stock.py (+1/-1)
mrp_operations/mrp_operations.py (+1/-1)
plugin/plugin_handler.py (+1/-1)
point_of_sale/report/account_statement.py (+1/-1)
point_of_sale/report/all_closed_cashbox_of_the_day.py (+9/-9)
point_of_sale/report/pos_details.py (+3/-3)
point_of_sale/report/pos_details_summary.py (+2/-2)
point_of_sale/report/pos_lines.py (+2/-2)
point_of_sale/report/pos_payment_report.py (+3/-3)
point_of_sale/report/pos_payment_report_user.py (+2/-2)
point_of_sale/report/pos_receipt.py (+1/-1)
point_of_sale/report/pos_sales_user.py (+2/-2)
point_of_sale/report/pos_sales_user_today.py (+2/-2)
point_of_sale/report/pos_users_product.py (+2/-2)
point_of_sale/report/report_cash_register.py (+1/-1)
procurement/company.py (+1/-1)
product/product.py (+2/-2)
product/report/product_pricelist.py (+4/-4)
product_manufacturer/product_manufacturer.py (+1/-1)
product_visible_discount/__init__.py (+1/-1)
project/project.py (+14/-10)
project/wizard/project_task_reevaluate.py (+1/-1)
project_gtd/project_gtd.py (+1/-1)
project_gtd/wizard/project_gtd_empty.py (+1/-1)
project_mailgate/project_mailgate.py (+3/-1)
project_mrp/project_procurement.py (+1/-1)
project_timesheet/project_timesheet.py (+1/-1)
project_timesheet/report/task_report.py (+2/-2)
purchase/purchase.py (+2/-2)
purchase/wizard/purchase_order_group.py (+1/-1)
purchase_requisition/purchase_requisition.py (+1/-1)
report_webkit/ir_report.py (+1/-1)
report_webkit/report_helper.py (+1/-1)
resource/faces/task.py (+2/-1)
resource/resource.py (+1/-1)
sale/edi/sale_order.py (+1/-1)
sale/report/__init__.py (+1/-1)
sale/sale.py (+5/-3)
sale/wizard/__init__.py (+1/-1)
sale/wizard/sale_make_invoice.py (+1/-1)
sale_crm/__init__.py (+1/-1)
sale_layout/sale_layout.py (+1/-1)
sale_order_dates/sale_order_dates.py (+1/-1)
stock/report/lot_overview.py (+1/-1)
stock/report/lot_overview_all.py (+1/-1)
stock/report/product_stock.py (+3/-1)
stock/report/report_stock.py (+2/-2)
stock/report/stock_by_location.py (+1/-1)
stock/report/stock_inventory_move_report.py (+1/-1)
stock/stock.py (+10/-4)
stock_invoice_directly/wizard/stock_invoice.py (+1/-1)
stock_location/procurement_pull.py (+1/-1)
stock_planning/stock_planning.py (+1/-1)
stock_planning/wizard/stock_planning_createlines.py (+1/-1)
survey/survey.py (+2/-2)
survey/wizard/__init__.py (+1/-1)
survey/wizard/survey_answer.py (+5/-5)
wiki/web/widgets/rss/feedparser.py (+3/-1)
wiki/web/widgets/wikimarkup/__init__.py (+4/-2)
- OpenERP Core Team: Pending requested
-
Diff: 5307 lines (+656/-625)193 files modifiedaccount/account.py (+44/-17)
account/account_bank.py (+3/-3)
account/account_move_line.py (+1/-1)
account/project/wizard/account_analytic_chart.py (+1/-1)
account/project/wizard/account_analytic_inverted_balance_report.py (+1/-1)
account/project/wizard/project_account_analytic_line.py (+1/-1)
account/report/account_balance.py (+1/-1)
account/report/account_central_journal.py (+1/-1)
account/report/account_general_journal.py (+1/-1)
account/report/account_report.py (+1/-1)
account/report/account_tax_report.py (+6/-2)
account/res_currency.py (+0/-1)
account/wizard/account_invoice_state.py (+1/-1)
account/wizard/account_journal_select.py (+1/-1)
account/wizard/account_move_bank_reconcile.py (+1/-1)
account/wizard/account_move_journal.py (+1/-1)
account/wizard/account_move_line_reconcile_select.py (+1/-1)
account/wizard/account_move_line_select.py (+1/-1)
account/wizard/account_move_line_unreconcile_select.py (+1/-1)
account/wizard/account_reconcile.py (+1/-1)
account/wizard/account_state_open.py (+1/-1)
account/wizard/account_subscription_generate.py (+1/-1)
account/wizard/account_unreconcile.py (+1/-1)
account_analytic_plans/report/crossovered_analytic.py (+6/-4)
account_anglo_saxon/__init__.py (+1/-1)
account_anglo_saxon/sale.py (+0/-43)
account_asset/account_asset.py (+5/-3)
account_budget/report/analytic_account_budget_report.py (+5/-3)
account_budget/report/budget_report.py (+3/-1)
account_budget/report/crossovered_budget_report.py (+3/-1)
account_budget/wizard/account_budget_analytic.py (+1/-1)
account_budget/wizard/account_budget_crossovered_report.py (+1/-1)
account_budget/wizard/account_budget_report.py (+1/-1)
account_followup/__init__.py (+1/-1)
account_followup/wizard/__init__.py (+1/-1)
account_followup/wizard/account_followup_print.py (+1/-1)
account_payment/__init__.py (+1/-1)
account_payment/account_invoice.py (+1/-1)
account_payment/account_move_line.py (+2/-2)
account_payment/account_payment.py (+3/-1)
account_payment/report/__init__.py (+1/-1)
account_payment/report/payment_order.py (+2/-2)
account_payment/wizard/__init__.py (+1/-1)
account_payment/wizard/account_payment_pay.py (+1/-1)
account_payment/wizard/account_payment_populate_statement.py (+1/-1)
account_sequence/__init__.py (+1/-1)
account_voucher/__init__.py (+1/-1)
account_voucher/account_voucher.py (+4/-2)
account_voucher/report/__init__.py (+1/-1)
anonymization/anonymization.py (+2/-2)
audittrail/audittrail.py (+11/-5)
base_crypt/crypt.py (+3/-1)
base_module_doc_rst/report/ir_module_reference_print_graph.py (+1/-1)
base_module_record/wizard/base_module_record_objects.py (+1/-1)
base_report_designer/openerp_sxw2rml/openerp_sxw2rml.py (+17/-15)
base_report_designer/plugin/openerp_report_designer/bin/script/About.py (+1/-1)
base_report_designer/plugin/openerp_report_designer/bin/script/AddAttachment.py (+8/-8)
base_report_designer/plugin/openerp_report_designer/bin/script/Change.py (+2/-2)
base_report_designer/plugin/openerp_report_designer/bin/script/ConvertBracesToField.py (+26/-24)
base_report_designer/plugin/openerp_report_designer/bin/script/ConvertFieldsToBraces.py (+1/-1)
base_report_designer/plugin/openerp_report_designer/bin/script/ExportToRML.py (+1/-1)
base_report_designer/plugin/openerp_report_designer/bin/script/Expression.py (+3/-3)
base_report_designer/plugin/openerp_report_designer/bin/script/Fields.py (+6/-6)
base_report_designer/plugin/openerp_report_designer/bin/script/ModifyExistingReport.py (+3/-3)
base_report_designer/plugin/openerp_report_designer/bin/script/NewReport.py (+3/-3)
base_report_designer/plugin/openerp_report_designer/bin/script/Repeatln.py (+4/-4)
base_report_designer/plugin/openerp_report_designer/bin/script/SendToServer.py (+4/-4)
base_report_designer/plugin/openerp_report_designer/bin/script/ServerParameter.py (+4/-7)
base_report_designer/plugin/openerp_report_designer/bin/script/Translation.py (+6/-6)
base_report_designer/plugin/openerp_report_designer/bin/script/lib/error.py (+1/-1)
base_report_designer/plugin/openerp_report_designer/bin/script/lib/functions.py (+14/-8)
base_report_designer/plugin/openerp_report_designer/bin/script/lib/logreport.py (+1/-2)
base_report_designer/plugin/openerp_report_designer/bin/script/lib/rpc.py (+2/-2)
base_report_designer/plugin/openerp_report_designer/bin/script/lib/tools.py (+3/-3)
base_report_designer/plugin/openerp_report_designer/bin/script/modify.py (+1/-1)
base_report_designer/plugin/openerp_report_designer/test/test_fields.py (+7/-1)
base_vat/__init__.py (+1/-1)
base_vat/res_company.py (+1/-1)
caldav/caldav_node.py (+11/-11)
crm/crm.py (+6/-7)
crm/crm_lead.py (+1/-2)
crm_claim/crm_claim.py (+2/-2)
crm_helpdesk/crm_helpdesk.py (+5/-6)
crm_profiling/crm_profiling.py (+1/-1)
document/content_index.py (+4/-5)
document/document.py (+1/-1)
document/document_directory.py (+2/-2)
document/nodes.py (+26/-28)
document/odt2txt.py (+3/-3)
document/std_index.py (+8/-8)
document_webdav/document_webdav.py (+1/-1)
document_webdav/redirect.py (+1/-1)
document_webdav/test_davclient.py (+1/-2)
document_webdav/webdav.py (+1/-1)
document_webdav/webdav_server.py (+6/-6)
email_template/html2text.py (+53/-51)
event/event.py (+2/-1)
event/report/__init__.py (+1/-1)
event/wizard/event_confirm.py (+1/-1)
event_moodle/event_moodle.py (+1/-1)
event_project/event_project.py (+1/-1)
event_project/wizard/event_project_retro.py (+1/-1)
hr_attendance/wizard/hr_attendance_bymonth.py (+1/-1)
hr_attendance/wizard/hr_attendance_byweek.py (+1/-1)
hr_attendance/wizard/hr_attendance_error.py (+1/-1)
hr_evaluation/hr_evaluation.py (+3/-3)
hr_payroll/report/report_contribution_register.py (+1/-1)
hr_payroll/report/report_payslip.py (+1/-1)
hr_payroll/report/report_payslip_details.py (+1/-1)
hr_payroll_account/__init__.py (+1/-1)
hr_payroll_account/wizard/__init__.py (+1/-1)
hr_payroll_account/wizard/hr_payroll_payslips_by_employees.py (+1/-1)
hr_recruitment/hr_recruitment.py (+7/-9)
hr_recruitment/wizard/hr_recruitment_create_partner_job.py (+1/-1)
hr_recruitment/wizard/hr_recruitment_employee_hired.py (+2/-2)
hr_timesheet_invoice/hr_timesheet_invoice.py (+3/-2)
hr_timesheet_invoice/report/account_analytic_profit.py (+1/-1)
hr_timesheet_invoice/wizard/hr_timesheet_invoice_create.py (+7/-5)
hr_timesheet_sheet/hr_timesheet_sheet.py (+2/-2)
hr_timesheet_sheet/wizard/hr_timesheet_current.py (+1/-1)
idea/idea.py (+6/-5)
import_base/import_framework.py (+1/-1)
import_sugarcrm/import_sugarcrm.py (+3/-3)
l10n_be/__init__.py (+1/-1)
l10n_be_coda/l10n_be_coda.py (+10/-3)
l10n_be_invoice_bba/invoice.py (+39/-40)
l10n_br/l10n_br.py (+1/-1)
l10n_ch/partner.py (+1/-1)
l10n_ch/payment.py (+1/-1)
l10n_ch/report/report_webkit_html.py (+1/-1)
l10n_ch/wizard/create_dta.py (+1/-1)
l10n_fr/l10n_fr.py (+0/-4)
l10n_fr/report/base_report.py (+1/-1)
l10n_lu/wizard/pdf_ext.py (+1/-1)
lunch/report/order.py (+2/-2)
mail/mail_thread.py (+2/-2)
membership/report/__init__.py (+1/-1)
membership/report/report_membership.py (+1/-1)
membership/wizard/__init__.py (+1/-1)
mrp/mrp.py (+9/-5)
mrp/procurement.py (+1/-1)
mrp/report/bom_structure.py (+2/-2)
mrp/stock.py (+1/-1)
mrp_operations/mrp_operations.py (+1/-1)
plugin/plugin_handler.py (+17/-19)
point_of_sale/report/account_statement.py (+1/-1)
point_of_sale/report/all_closed_cashbox_of_the_day.py (+9/-9)
point_of_sale/report/pos_details.py (+3/-3)
point_of_sale/report/pos_details_summary.py (+1/-1)
point_of_sale/report/pos_lines.py (+2/-2)
point_of_sale/report/pos_payment_report.py (+3/-3)
point_of_sale/report/pos_payment_report_user.py (+2/-2)
point_of_sale/report/pos_receipt.py (+1/-1)
point_of_sale/report/pos_sales_user.py (+1/-1)
point_of_sale/report/pos_sales_user_today.py (+2/-2)
point_of_sale/report/pos_users_product.py (+2/-2)
product/product.py (+2/-2)
product/report/product_pricelist.py (+6/-5)
product_manufacturer/product_manufacturer.py (+1/-1)
product_visible_discount/__init__.py (+1/-1)
project/project.py (+15/-16)
project/wizard/project_task_reevaluate.py (+1/-1)
project_gtd/project_gtd.py (+1/-1)
project_gtd/wizard/project_gtd_empty.py (+1/-1)
project_mrp/project_procurement.py (+1/-1)
project_timesheet/project_timesheet.py (+1/-1)
project_timesheet/report/task_report.py (+1/-1)
purchase/purchase.py (+6/-9)
purchase/wizard/purchase_order_group.py (+1/-1)
purchase_requisition/purchase_requisition.py (+1/-1)
report_webkit/ir_report.py (+1/-1)
report_webkit/report_helper.py (+1/-1)
resource/faces/task.py (+2/-1)
resource/resource.py (+1/-1)
sale/report/__init__.py (+1/-1)
sale/sale.py (+8/-6)
sale/wizard/__init__.py (+1/-1)
sale_crm/__init__.py (+1/-1)
sale_order_dates/sale_order_dates.py (+1/-1)
stock/report/lot_overview.py (+1/-1)
stock/report/lot_overview_all.py (+1/-1)
stock/report/product_stock.py (+3/-1)
stock/report/report_stock.py (+4/-4)
stock/report/stock_by_location.py (+1/-1)
stock/report/stock_inventory_move_report.py (+1/-1)
stock/stock.py (+10/-4)
stock_invoice_directly/wizard/stock_invoice.py (+1/-1)
stock_location/procurement_pull.py (+1/-1)
stock_planning/stock_planning.py (+1/-1)
stock_planning/wizard/stock_planning_createlines.py (+1/-1)
survey/survey.py (+2/-2)
survey/wizard/__init__.py (+1/-1)
survey/wizard/survey_answer.py (+5/-5)
summary: |
- default Context=False in methods/functions + Default Context should be None in methods/functions |
description: | updated |
description: | updated |
description: | updated |
description: | updated |
description: | updated |
description: | updated |
Changed in openobject-client: | |
status: | New → Confirmed |
tags: | added: context refactoring |
Changed in openobject-client: | |
importance: | Undecided → Low |
assignee: | nobody → OpenERP sa GTK client R&D (openerp-dev-gtk) |
Changed in openobject-client: | |
status: | Confirmed → Invalid |
tags: | added: long-term |
Nope. Because `{}` is mutable, if it's set as a default argument it "sticks" around for the lifecycle of the function (so until the server is shut down), and if `context` is modified anywhere within the function (or within the functions it calls itself) then next time around the key set in it will appear again:
>>> def foo(k, v, context={}):
... print context
... context[k] = v
... print context
...
>>> foo('a','b')
{}
{'a': 'b'}
>>> foo('c','d')
{'a': 'b'}
{'a': 'b', 'c': 'd'}
>>> foo('e','f')
{'a': 'b', 'c': 'd'}
{'a': 'b', 'c': 'd', 'e': 'f'}
This issue can create pretty subtle bugs (though it's the worst when it impacts appended/extended lists).
In fact, any instance of `context={}` should very much be replaced by `context=None`, not the other way around.