From 5ce261d56e181ae9a6ad2a94880423d721876bc7 Mon Sep 17 00:00:00 2001 From: greg-apieum <> Date: Wed, 24 Feb 2010 09:50:30 +0100 Subject: [PATCH 1/4] ADD .* to .bzrignore and remove uneeded files bzr revid: greg-apieum-20100224085030-6h382yp21pgn40rr --- addons/.bzrignore | 1 + addons/account_invoice_layout/.project | 17 ----------------- addons/account_invoice_layout/.pydevproject | 6 ------ 3 files changed, 1 insertion(+), 23 deletions(-) create mode 100644 addons/.bzrignore delete mode 100644 addons/account_invoice_layout/.project delete mode 100644 addons/account_invoice_layout/.pydevproject diff --git a/addons/.bzrignore b/addons/.bzrignore new file mode 100644 index 00000000000..8d98f9debde --- /dev/null +++ b/addons/.bzrignore @@ -0,0 +1 @@ +.* diff --git a/addons/account_invoice_layout/.project b/addons/account_invoice_layout/.project deleted file mode 100644 index 9fcfcc5ebf0..00000000000 --- a/addons/account_invoice_layout/.project +++ /dev/null @@ -1,17 +0,0 @@ - - - account_invoice_layout - - - - - - org.python.pydev.PyDevBuilder - - - - - - org.python.pydev.pythonNature - - diff --git a/addons/account_invoice_layout/.pydevproject b/addons/account_invoice_layout/.pydevproject deleted file mode 100644 index b4c1448c08b..00000000000 --- a/addons/account_invoice_layout/.pydevproject +++ /dev/null @@ -1,6 +0,0 @@ - - - - -python 2.4 - From f15d0a6895b6153ec799c1be1ba34bb294a3baf3 Mon Sep 17 00:00:00 2001 From: greg-apieum <> Date: Wed, 24 Feb 2010 09:54:04 +0100 Subject: [PATCH 2/4] [CLEAN] Set Withespaces to PEP8 format bzr revid: greg-apieum-20100224085404-j1onx0jxchv3m51a --- addons/account/account.py | 702 +++++++------- addons/account/account_analytic_line.py | 74 +- addons/account/account_bank_statement.py | 90 +- addons/account/account_move_line.py | 200 ++-- addons/account/company.py | 2 +- addons/account/installer.py | 4 +- addons/account/invoice.py | 414 ++++----- addons/account/partner.py | 36 +- addons/account/product.py | 4 +- addons/account/project/project.py | 12 +- .../account/project/report/account_journal.py | 2 +- .../project/report/analytic_balance.py | 26 +- .../account/project/report/analytic_check.py | 10 +- .../project/report/analytic_journal.py | 8 +- addons/account/project/report/cost_ledger.py | 10 +- .../report/inverted_analytic_balance.py | 18 +- .../project/report/quantity_cost_ledger.py | 12 +- .../wizard_account_analytic_analytic_check.py | 8 +- .../wizard_account_analytic_balance_report.py | 8 +- ...analytic_cost_ledger_for_journal_report.py | 10 +- ...ard_account_analytic_cost_ledger_report.py | 6 +- ...ccount_analytic_inverted_balance_report.py | 8 +- .../wizard_account_analytic_journal_report.py | 8 +- .../wizard/wizard_account_analytic_line.py | 14 +- .../wizard/wizard_analytic_account_chart.py | 4 +- addons/account/report/account_balance.py | 40 +- addons/account/report/account_journal.py | 20 +- addons/account/report/account_tax_code.py | 2 +- addons/account/report/aged_trial_balance.py | 26 +- addons/account/report/central_journal.py | 10 +- addons/account/report/general_journal.py | 54 +- addons/account/report/general_ledger.py | 64 +- .../report/general_ledger_landscape.py | 68 +- addons/account/report/overdue.py | 18 +- addons/account/report/partner_balance.py | 92 +- addons/account/report/rml_parse.py | 30 +- addons/account/report/tax_report.py | 62 +- addons/account/report/third_party_ledger.py | 82 +- addons/account/sequence.py | 10 +- addons/account/test/test_parent_structure.py | 16 +- .../wizard/wizard_account_balance_report.py | 24 +- addons/account/wizard/wizard_account_chart.py | 8 +- .../wizard/wizard_aged_trial_balance.py | 28 +- .../wizard/wizard_automatic_reconcile.py | 38 +- .../account/wizard/wizard_bank_reconcile.py | 4 +- .../account/wizard/wizard_central_journal.py | 8 +- .../account/wizard/wizard_change_currency.py | 26 +- .../account/wizard/wizard_fiscalyear_close.py | 34 +- .../wizard/wizard_fiscalyear_close_state.py | 8 +- .../account/wizard/wizard_general_journal.py | 8 +- .../wizard/wizard_general_ledger_report.py | 40 +- addons/account/wizard/wizard_invoice_state.py | 4 +- addons/account/wizard/wizard_journal.py | 20 +- .../account/wizard/wizard_journal_select.py | 2 +- .../account/wizard/wizard_move_line_select.py | 2 +- .../wizard/wizard_open_closed_fiscalyear.py | 8 +- .../wizard/wizard_partner_balance_report.py | 28 +- addons/account/wizard/wizard_pay_invoice.py | 38 +- addons/account/wizard/wizard_period_close.py | 2 +- addons/account/wizard/wizard_print_journal.py | 12 +- addons/account/wizard/wizard_reconcile.py | 12 +- .../account/wizard/wizard_reconcile_select.py | 4 +- addons/account/wizard/wizard_refund.py | 26 +- addons/account/wizard/wizard_state_open.py | 2 +- .../wizard/wizard_statement_from_invoice.py | 46 +- .../wizard/wizard_subscription_generate.py | 4 +- .../wizard/wizard_third_party_ledger.py | 40 +- addons/account/wizard/wizard_unreconcile.py | 2 +- .../wizard/wizard_unreconcile_select.py | 2 +- addons/account/wizard/wizard_use_model.py | 28 +- .../wizard/wizard_validate_account_move.py | 8 +- addons/account/wizard/wizard_vat.py | 6 +- addons/account_analytic_analysis/__terp__.py | 2 +- .../account_analytic_analysis.py | 130 +-- .../account_analytic_default.py | 58 +- .../account_analytic_plans.py | 158 ++-- .../report/crossovered_analytic.py | 100 +- .../wizard/create_model.py | 10 +- .../wizard/wizard_crossovered_analytic.py | 20 +- addons/account_anglo_saxon/__init__.py | 2 +- addons/account_anglo_saxon/__terp__.py | 4 +- addons/account_anglo_saxon/invoice.py | 40 +- addons/account_anglo_saxon/product.py | 4 +- addons/account_anglo_saxon/purchase.py | 4 +- addons/account_anglo_saxon/stock.py | 8 +- addons/account_balance/account_move_line.py | 14 +- .../account_balance/report/account_balance.py | 344 +++---- .../report/account_balance_landscape.py | 340 +++---- addons/account_balance/report/rml_parse.py | 48 +- .../wizard/wizard_account_balance_report.py | 54 +- addons/account_budget/crossovered_budget.py | 142 +-- .../report/analytic_account_budget_report.py | 112 +-- addons/account_budget/report/budget_report.py | 16 +- .../report/crossovered_budget_report.py | 144 +-- .../wizard/wizard_analytic_account_budget.py | 6 +- .../wizard/wizard_budget_report.py | 10 +- .../wizard/wizard_budget_spread.py | 4 +- .../wizard_crossovered_budget_report.py | 8 +- ...izard_crossovered_budget_summary_report.py | 8 +- .../account_date_check/account_date_check.py | 22 +- addons/account_followup/followup.py | 4 +- .../report/report_followup_print.py | 8 +- .../wizard/wizard_followup_print.py | 42 +- .../account_invoice_layout.py | 62 +- .../report/report_account_invoice_layout.py | 180 ++-- .../report/special_message_invoice.py | 182 ++-- .../wizard/invoice_special_message.py | 2 +- addons/account_payment/account_move_line.py | 12 +- addons/account_payment/payment.py | 210 ++--- .../account_payment/report/payment_order.py | 4 +- addons/account_payment/wizard/wizard_pay.py | 18 +- .../wizard/wizard_payment_order.py | 28 +- .../wizard/wizard_populate_statement.py | 2 +- addons/account_report/account.py | 120 +-- .../report/accounting_report.py | 8 +- .../account_report/report/print_indicator.py | 210 ++--- .../wizard/wizard_print_indicators.py | 20 +- .../wizard_print_indicators_with_pdf.py | 34 +- addons/account_reporting/account.py | 78 +- .../report/account_report_bs.py | 36 +- .../wizard/wizard_account_balance_report.py | 14 +- .../account_tax_include/invoice_tax_incl.py | 48 +- addons/account_voucher/__terp__.py | 4 +- addons/account_voucher/account.py | 112 +-- .../account_voucher/report/report_voucher.py | 18 +- .../report/report_voucher_amount.py | 12 +- addons/account_voucher/report/rml_parse.py | 48 +- addons/account_voucher/voucher.py | 210 ++--- addons/account_voucher/wizard/open_voucher.py | 34 +- addons/analytic/project.py | 120 +-- .../analytic_journal_billing_rate.py | 40 +- .../analytic_user_function.py | 68 +- addons/association/profile_association.py | 6 +- addons/auction/auction.py | 578 ++++++------ addons/auction/barcode/code128.py | 186 ++-- addons/auction/barcode/code39.py | 96 +- addons/auction/barcode/code93.py | 58 +- addons/auction/barcode/common.py | 108 +-- addons/auction/barcode/fourstate.py | 56 +- addons/auction/barcode/test.py | 18 +- addons/auction/barcode/usps.py | 26 +- addons/auction/report/artists_lots.py | 6 +- addons/auction/report/auction_artists.py | 2 +- addons/auction/report/auction_bids.py | 2 +- addons/auction/report/auction_buyer_result.py | 2 +- addons/auction/report/auction_invoice.py | 8 +- addons/auction/report/auction_result.py | 2 +- addons/auction/report/auction_total_rml.py | 54 +- addons/auction/report/bids_lots.py | 2 +- addons/auction/report/bids_phones_details.py | 2 +- addons/auction/report/buyer_form_report.py | 20 +- addons/auction/report/buyer_list.py | 34 +- addons/auction/report/catalog2.py | 46 +- addons/auction/report/huissier.py | 14 +- addons/auction/report/lots_list.py | 2 +- addons/auction/report/lots_list_inventory.py | 2 +- addons/auction/report/photo_shadow.py | 20 +- addons/auction/report/report_lot_bar_code.py | 2 +- addons/auction/report/seller_address.py | 12 +- addons/auction/report/seller_form_report.py | 18 +- addons/auction/report/total.py | 18 +- .../auction/wizard/auction_catalog_flagey.py | 8 +- .../wizard/auction_wizard_able_taken.py | 8 +- .../wizard/auction_wizard_enable_taken.py | 6 +- addons/auction/wizard/wizard_aie_send.py | 58 +- .../auction/wizard/wizard_aie_send_result.py | 20 +- .../wizard/wizard_auction_invoice_buyer.py | 28 +- .../auction/wizard/wizard_auction_journal.py | 20 +- addons/auction/wizard/wizard_emporte.py | 8 +- addons/auction/wizard/wizard_lot_date_move.py | 20 +- .../auction/wizard/wizard_lots_buyer_map.py | 22 +- addons/auction/wizard/wizard_lots_cancel.py | 10 +- addons/auction/wizard/wizard_lots_invoice.py | 12 +- .../auction/wizard/wizard_lots_numerotate.py | 44 +- addons/auction/wizard/wizard_lots_pay.py | 8 +- addons/auction/wizard/wizard_lots_sms.py | 8 +- addons/auction/wizard/wizard_pay.py | 46 +- addons/auction/wizard/wizard_payer.py | 8 +- .../wizard/wizard_transfer_unsold_object.py | 20 +- addons/audittrail/audittrail.py | 164 ++-- addons/audittrail/wizard/wizard_view_log.py | 22 +- addons/base_action_rule/__terp__.py | 2 +- addons/base_action_rule/base_action_rule.py | 140 +-- addons/base_calendar/__terp__.py | 28 +- addons/base_calendar/base_calendar.py | 416 ++++----- .../wizard/wizard_cal_edit_event.py | 36 +- addons/base_contact/__terp__.py | 2 +- addons/base_contact/base_contact.py | 72 +- addons/base_iban/base_iban.py | 20 +- addons/base_module_quality/__init__.py | 2 +- .../base_module_quality.py | 16 +- .../method_test/method_test.py | 6 +- .../object_test/object_test.py | 10 +- .../pep8_test/pep8_test.py | 6 +- .../pylint_test/pylint_test.py | 10 +- .../speed_test/speed_test.py | 10 +- .../structure_test/structure_test.py | 16 +- .../terp_test/terp_test.py | 8 +- .../unit_test/unit_test.py | 20 +- .../wizard/module_quality_check.py | 4 +- .../wizard/quality_save_report.py | 4 +- .../workflow_test/workflow_test.py | 12 +- .../base_module_record/base_module_record.py | 142 +-- .../wizard/base_module_record_data.py | 58 +- .../wizard/base_module_record_objects.py | 62 +- .../wizard/base_module_save.py | 46 +- .../base_report_creator.py | 246 ++--- .../wizard/base_report_creator_open.py | 8 +- .../wizard/report_menu_create.py | 14 +- .../wizard/wiz_set_filter_fields.py | 164 ++-- .../base_report_designer.py | 16 +- .../wizard/base_report_designer_modify.py | 32 +- .../wizard/tiny_sxw2rml/tiny_sxw2rml.py | 98 +- addons/base_setup/__init__.py | 4 +- addons/base_setup/__terp__.py | 2 +- addons/base_setup/installer.py | 4 +- addons/base_setup/todo.py | 6 +- addons/base_vat/partner.py | 10 +- addons/board/board.py | 22 +- addons/board/wizard/board_wizard.py | 14 +- addons/board_hr/__terp__.py | 2 +- addons/board_warehouse/__terp__.py | 2 +- addons/caldav/DAV/BufferingHTTPServer.py | 14 +- addons/caldav/DAV/WebDAVServer.py | 204 ++--- addons/caldav/DAV/constants.py | 12 +- addons/caldav/DAV/davcmd.py | 120 +-- addons/caldav/DAV/davcopy.py | 62 +- addons/caldav/DAV/davmove.py | 38 +- addons/caldav/DAV/delete.py | 16 +- addons/caldav/DAV/errors.py | 32 +- addons/caldav/DAV/iface.py | 92 +- addons/caldav/DAV/propfind.py | 206 ++--- addons/caldav/DAV/status.py | 2 +- addons/caldav/DAV/utils.py | 92 +- addons/caldav/__terp__.py | 30 +- addons/caldav/caldav.py | 178 ++-- addons/caldav/caldav_cache.py | 10 +- addons/caldav/caldav_fs.py | 140 +-- addons/caldav/caldav_node.py | 32 +- addons/caldav/webdav_server.py | 32 +- addons/caldav/wizard/wizard_cal_export.py | 26 +- addons/caldav/wizard/wizard_cal_import.py | 36 +- addons/caldav/wizard/wizard_cal_subscribe.py | 38 +- addons/crm/__terp__.py | 100 +- addons/crm/crm.py | 156 ++-- addons/crm/crm_action_rule.py | 72 +- addons/crm/crm_claim.py | 14 +- addons/crm/crm_fundraising.py | 22 +- addons/crm/crm_helpdesk.py | 4 +- addons/crm/crm_lead.py | 6 +- addons/crm/crm_mailgate.py | 48 +- addons/crm/crm_meeting.py | 20 +- addons/crm/crm_operators.py | 16 +- addons/crm/crm_opportunity.py | 8 +- addons/crm/crm_phonecall.py | 2 +- addons/crm/crm_segmentation.py | 46 +- addons/crm/report/crm_report.py | 32 +- addons/crm/report/report_businessopp.py | 52 +- .../openerp_mailgate/openerp_mailgate.py | 96 +- addons/crm/wizard/crm_lead_wizard.py | 56 +- addons/crm/wizard/crm_opportunity_wizard.py | 94 +- addons/crm/wizard/crm_phonecall_wizard.py | 68 +- .../crm/wizard/wizard_crm_new_send_email.py | 38 +- addons/crm/wizard/wizard_crm_send_email.py | 20 +- addons/crm/wizard/wizard_history_event.py | 24 +- addons/crm_caldav/__terp__.py | 26 +- addons/crm_caldav/crm_caldav.py | 6 +- addons/crm_hr/__terp__.py | 2 +- addons/crm_hr/crm_hr.py | 10 +- addons/crm_hr/report/report_crm_hr.py | 14 +- addons/crm_hr/wizard/crm_hr_wizard.py | 12 +- addons/crm_profiling/crm_profiling.py | 78 +- .../wizard/open_questionnaire.py | 2 +- addons/crm_project/__terp__.py | 4 +- addons/crm_project/crm_project_bug.py | 20 +- .../report/report_crm_project_bug.py | 32 +- addons/crm_project/wizard/crm_bug_wizard.py | 52 +- addons/delivery/delivery.py | 58 +- addons/delivery/sale.py | 6 +- addons/delivery/stock.py | 14 +- addons/delivery/wizard/delivery_sale_order.py | 12 +- addons/document/__terp__.py | 2 +- addons/document/content_index.py | 92 +- addons/document/directory_content.py | 30 +- addons/document/directory_report.py | 24 +- addons/document/document.py | 150 +-- addons/document/document_directory.py | 148 +-- addons/document/document_storage.py | 110 +-- addons/document/nodes.py | 476 +++++----- addons/document/odt2txt.py | 4 +- addons/document/std_index.py | 26 +- addons/document/test_cindex.py | 18 +- addons/document_ftp/__terp__.py | 2 +- addons/document_ftp/doc_conf_wizard.py | 18 +- addons/document_ftp/ftpserver/__init__.py | 2 +- .../document_ftp/ftpserver/abstracted_fs.py | 270 +++--- addons/document_ftp/ftpserver/authorizer.py | 6 +- addons/document_ftp/ftpserver/ftpserver.py | 344 +++---- addons/document_ics/__terp__.py | 2 +- addons/document_ics/document_ics.py | 76 +- .../document_ics_config_wizard.py | 20 +- .../DAV/BufferingHTTPServer.py | 14 +- addons/document_webdav/DAV/WebDAVServer.py | 204 ++--- addons/document_webdav/DAV/constants.py | 12 +- addons/document_webdav/DAV/davcmd.py | 120 +-- addons/document_webdav/DAV/davcopy.py | 62 +- addons/document_webdav/DAV/davmove.py | 38 +- addons/document_webdav/DAV/delete.py | 16 +- addons/document_webdav/DAV/errors.py | 32 +- addons/document_webdav/DAV/iface.py | 92 +- addons/document_webdav/DAV/propfind.py | 206 ++--- addons/document_webdav/DAV/status.py | 2 +- addons/document_webdav/DAV/utils.py | 92 +- addons/document_webdav/cache.py | 10 +- addons/document_webdav/dav_fs.py | 272 +++--- addons/document_webdav/webdav_server.py | 38 +- addons/event/event.py | 224 ++--- addons/event/wizard/confirm_registration.py | 12 +- addons/event/wizard/event_registration.py | 2 +- .../wizard/event_registrations_partner.py | 20 +- addons/event/wizard/make_invoice.py | 48 +- addons/event_project/event.py | 10 +- addons/event_project/wizard/event_task.py | 10 +- addons/event_project/wizard/project_wizard.py | 10 +- addons/google_map/google_map.py | 4 +- addons/google_map/wizard/google_map_launch.py | 22 +- addons/hr/__terp__.py | 2 +- addons/hr/hr.py | 22 +- addons/hr/hr_department.py | 28 +- addons/hr_attendance/hr_attendance.py | 40 +- .../hr_attendance/report/attendance_errors.py | 22 +- addons/hr_attendance/report/bymonth.py | 14 +- addons/hr_attendance/report/timesheet.py | 8 +- .../wizard/print_attendance_error.py | 12 +- addons/hr_attendance/wizard/print_byweek.py | 6 +- addons/hr_attendance/wizard/sign_in_out.py | 24 +- addons/hr_contract/hr_contract.py | 20 +- addons/hr_evaluation/__terp__.py | 2 +- addons/hr_evaluation/hr_evaluation.py | 64 +- addons/hr_expense/hr_expense.py | 54 +- addons/hr_expense/report/expense.py | 4 +- addons/hr_holidays/hr.py | 140 +-- .../post-01-convert-limits-into-requests.py | 4 +- .../report/holidays_summary_report.py | 262 +++--- addons/hr_holidays/wizard/holidays_summary.py | 26 +- .../wizard/holidays_summary_employees.py | 22 +- addons/hr_timesheet/hr_timesheet.py | 32 +- addons/hr_timesheet/report/user_timesheet.py | 8 +- addons/hr_timesheet/report/users_timesheet.py | 20 +- addons/hr_timesheet/wizard/sign_in_out.py | 16 +- .../wizard/wizard_print_timesheet.py | 8 +- .../wizard/wizard_print_timesheet_users.py | 10 +- .../hr_timesheet_invoice.py | 24 +- .../report/account_analytic_profit.py | 82 +- .../report/cost_ledger.py | 14 +- .../wizard/account_analytic_profit.py | 16 +- .../hr_timesheet_final_invoice_create.py | 26 +- .../wizard/hr_timesheet_invoice_create.py | 38 +- ...ard_account_analytic_cost_ledger_report.py | 8 +- .../hr_timesheet_sheet/hr_timesheet_sheet.py | 98 +- .../wizard/wizard_timesheet_current.py | 8 +- .../wizard/wizard_timesheet_department.py | 12 +- addons/idea/__terp__.py | 2 +- addons/idea/idea.py | 62 +- addons/idea/wizard/idea_vote.py | 8 +- addons/l10n_be/__terp__.py | 14 +- .../l10n_be/wizard/account_vat_declaration.py | 52 +- addons/l10n_be/wizard/partner_vat_listing.py | 76 +- addons/l10n_be/wizard/wizard_vat_intra.py | 58 +- addons/l10n_ch/__terp__.py | 10 +- addons/l10n_ch/dta.py | 24 +- addons/l10n_ch/invoice.py | 20 +- addons/l10n_ch/partner.py | 14 +- addons/l10n_ch/payment.py | 6 +- addons/l10n_ch/report/bvr.py | 34 +- addons/l10n_ch/wizard/bvr_import.py | 16 +- addons/l10n_ch/wizard/dta_wizard.py | 130 +-- addons/l10n_ch/wizard/journal_config.py | 48 +- addons/l10n_ch/wizard/wizard_bvr.py | 2 +- addons/l10n_ch_chart_c2c_pcg/wizard/config.py | 12 +- addons/l10n_fr/l10n_fr.py | 2 +- addons/l10n_fr/report/base_report.py | 86 +- addons/l10n_fr/report/bilan.py | 2 +- addons/l10n_fr/report/cdr.py | 2 +- addons/l10n_fr/wizard/bilan.py | 4 +- addons/l10n_fr/wizard/cdr.py | 2 +- addons/l10n_lu/wizard/pdf_ext.py | 16 +- addons/l10n_lu/wizard/print_vat.py | 12 +- addons/lunch/__terp__.py | 6 +- addons/lunch/lunch.py | 92 +- addons/lunch/report/order.py | 2 +- addons/lunch/wizard/cancel.py | 6 +- addons/lunch/wizard/confirm.py | 8 +- addons/lunch/wizard/reset_box.py | 22 +- addons/mail_gateway/__terp__.py | 8 +- addons/mail_gateway/mail_gateway.py | 140 +-- .../mail_gateway/wizard/wizard_fetch_mail.py | 32 +- addons/membership/membership.py | 122 +-- .../membership/wizard/invoice_membership.py | 12 +- addons/mrp/__terp__.py | 2 +- addons/mrp/company.py | 10 +- addons/mrp/mrp.py | 376 ++++---- addons/mrp/report/bom_structure.py | 18 +- addons/mrp/report/order.py | 2 +- addons/mrp/report/price.py | 32 +- addons/mrp/report/workcenter_load.py | 58 +- addons/mrp/schedulers.py | 10 +- addons/mrp/wizard/make_procurement.py | 6 +- .../wizard/wizard_change_production_qty.py | 26 +- .../wizard/wizard_orderpoint_procurement.py | 6 +- addons/mrp/wizard/wizard_price.py | 4 +- addons/mrp/wizard/wizard_procurement.py | 2 +- addons/mrp/wizard/wizard_schedulers_all.py | 6 +- addons/mrp/wizard/wizard_track_prod.py | 6 +- addons/mrp/wizard/wizard_workcenter_load.py | 8 +- addons/mrp_operations/mrp_operations.py | 274 +++--- .../mrp_operations/report/mrp_code_barcode.py | 2 +- .../mrp_operations/report/mrp_wc_barcode.py | 2 +- addons/mrp_repair/mrp_repair.py | 194 ++-- addons/mrp_repair/report/order.py | 6 +- .../mrp_repair/wizard/wizard_cancel_repair.py | 10 +- .../mrp_repair/wizard/wizard_make_invoice.py | 14 +- addons/mrp_subproduct/mrp_subproduct.py | 26 +- addons/olap/cli/tinybi.py | 22 +- addons/olap/cube/axis.py | 2 +- addons/olap/cube/axis_map.py | 10 +- addons/olap/cube/common.py | 42 +- addons/olap/cube/cross.py | 12 +- addons/olap/cube/cube.py | 2 +- addons/olap/cube/level.py | 74 +- addons/olap/cube/levels/level_date.py | 62 +- addons/olap/cube/levels/level_normal.py | 8 +- addons/olap/cube/mdx_operator.py | 2 +- addons/olap/cube/mdx_output/mdx_output.py | 8 +- addons/olap/cube/mdx_parser.py | 68 +- addons/olap/cube/measure.py | 26 +- addons/olap/cube/query.py | 98 +- addons/olap/cube/slicer.py | 2 +- addons/olap/cube/warehouse.py | 131 ++- addons/olap/olap.py | 856 +++++++++--------- .../wizard/wizard_application_configure.py | 182 ++-- addons/olap/wizard/wizard_clear_logs.py | 20 +- addons/olap/wizard/wizard_load_columns.py | 14 +- .../wizard/wizard_load_configured_table.py | 24 +- addons/olap/wizard/wizard_load_data.py | 256 +++--- addons/olap/wizard/wizard_query_builder.py | 116 +-- addons/olap/wizard/wizard_test_connection.py | 14 +- addons/olap_crm/__init__.py | 2 +- addons/olap_extract/__init__.py | 2 +- addons/olap_extract/wizard_olap_extract.py | 222 ++--- addons/olap_sale/__init__.py | 2 +- addons/point_of_sale/__terp__.py | 4 +- .../point_of_sale/account_bank_statement.py | 90 +- addons/point_of_sale/pos.py | 376 ++++---- .../pos_account_bank_statement.py | 4 +- .../point_of_sale/report/account_statement.py | 2 +- .../report/all_closed_cashbox_of_the_day.py | 42 +- addons/point_of_sale/report/pos_details.py | 74 +- .../report/pos_details_summary.py | 10 +- addons/point_of_sale/report/pos_invoice.py | 2 +- addons/point_of_sale/report/pos_lines.py | 8 +- .../report/pos_payment_report.py | 14 +- .../report/pos_payment_report_date.py | 16 +- .../report/pos_payment_report_user.py | 16 +- addons/point_of_sale/report/pos_receipt.py | 6 +- .../report/pos_receipt_with_remboursment.py | 8 +- .../pos_receipt_without_remboursment.py | 8 +- addons/point_of_sale/report/pos_sales_user.py | 6 +- .../report/pos_sales_user_today.py | 6 +- .../pos_sales_user_today_current_user.py | 10 +- .../point_of_sale/report/pos_users_product.py | 16 +- addons/point_of_sale/wizard/wizard_confirm.py | 8 +- .../point_of_sale/wizard/wizard_discount.py | 12 +- .../wizard/wizard_open_statement.py | 48 +- .../wizard/wizard_pos_details.py | 10 +- .../wizard/wizard_pos_payment.py | 22 +- .../wizard/wizard_pos_payment_report_date.py | 10 +- .../wizard/wizard_pos_payment_report_user.py | 6 +- .../wizard/wizard_pos_sales_user.py | 12 +- .../wizard/wizard_pos_sales_user_today.py | 8 +- addons/point_of_sale/wizard/wizard_receipt.py | 4 +- .../wizard/wizard_refund_order.py | 80 +- addons/point_of_sale/wizard/wizard_return.py | 174 ++-- .../wizard/wizard_scan_product.py | 2 +- addons/process/process.py | 58 +- addons/product/company.py | 10 +- addons/product/partner.py | 8 +- addons/product/pricelist.py | 68 +- addons/product/product.py | 164 ++-- addons/product/report/pricelist.py | 62 +- addons/product/report/product_pricelist.py | 56 +- addons/product/wizard/wizard_price.py | 2 +- addons/product_margin/product_margin.py | 100 +- .../wizard/wizard_product_margin.py | 22 +- .../profile_accounting/profile_accounting.py | 4 +- .../profile_manufacturing.py | 4 +- addons/profile_tools/installer.py | 2 +- addons/project/company.py | 2 +- addons/project/project.py | 160 ++-- addons/project/project_mailgate.py | 40 +- addons/project/report/_date_compute.py | 16 +- addons/project/report/gantt.py | 36 +- addons/project/report/gantt_report.py | 12 +- addons/project/wizard/close_task.py | 2 +- addons/project/wizard/compute_tasks_date.py | 82 +- .../wizard/duplicate_template_wizard.py | 16 +- addons/project/wizard/task_delegate.py | 6 +- addons/project_caldav/__terp__.py | 26 +- addons/project_caldav/project_caldav.py | 8 +- addons/project_gtd/project_gtd.py | 48 +- .../project_gtd/wizard/project_gtd_daily.py | 2 +- .../project_gtd/wizard/project_gtd_empty.py | 4 +- addons/project_gtd/wizard/project_gtd_fill.py | 4 +- addons/project_long_term/__terp__.py | 4 +- addons/project_long_term/project.py | 12 +- .../wizard/compute_phases_date.py | 74 +- addons/project_mrp/mrp.py | 18 +- addons/project_planning/__terp__.py | 2 +- addons/project_planning/project_planning.py | 54 +- .../project_retro_planning.py | 20 +- addons/project_timesheet/project_timesheet.py | 40 +- addons/purchase/partner.py | 8 +- addons/purchase/purchase.py | 138 +-- addons/purchase/report/order.py | 8 +- addons/purchase/report/request_quotation.py | 2 +- addons/purchase/stock.py | 4 +- .../purchase_analytic_plans.py | 14 +- addons/purchase_manual/purchase_manual.py | 16 +- .../wizard/wizard_purchase_line_invoice.py | 18 +- addons/purchase_tender/__terp__.py | 2 +- addons/purchase_tender/purchase_tender.py | 18 +- addons/report_account/report_receivable.py | 58 +- addons/report_analytic/report_analytic.py | 2 +- .../report_analytic_line.py | 8 +- addons/report_crm/__terp__.py | 4 +- addons/report_crm/report_crm.py | 60 +- addons/report_crm/report_crm_claim.py | 34 +- addons/report_crm/report_crm_fundraising.py | 34 +- addons/report_crm/report_crm_lead.py | 34 +- addons/report_crm/report_crm_opportunity.py | 36 +- addons/report_crm/report_crm_phonecall.py | 34 +- addons/report_document/report_document.py | 42 +- addons/report_intrastat/report/invoice.py | 2 +- addons/report_intrastat/report_intrastat.py | 10 +- addons/report_mrp/report_mrp.py | 12 +- addons/report_project/report_project.py | 14 +- addons/report_purchase/report_purchase.py | 46 +- addons/report_sale/report_sale.py | 64 +- addons/report_task/__terp__.py | 2 +- addons/report_task/report_task.py | 36 +- addons/report_timesheet/report_timesheet.py | 54 +- addons/resource/__terp__.py | 2 +- addons/resource/faces/pcalendar.py | 16 +- addons/resource/faces/plocale.py | 4 +- addons/resource/faces/task.py | 24 +- addons/resource/faces/timescale.py | 6 +- addons/resource/faces/utils.py | 8 +- addons/resource/resource.py | 82 +- addons/sale/mrp.py | 38 +- addons/sale/product.py | 10 +- addons/sale/report/order.py | 2 +- addons/sale/report/sale_prepare_allot.py | 10 +- addons/sale/sale.py | 114 +-- addons/sale/stock.py | 10 +- addons/sale/unit_test/test.py | 86 +- addons/sale/wizard/make_invoice.py | 12 +- addons/sale/wizard/make_invoice_advance.py | 40 +- .../sale/wizard/wizard_sale_line_invoice.py | 12 +- .../sale_analytic_plans.py | 14 +- addons/sale_crm/sale_crm.py | 4 +- addons/sale_crm/wizard/makesale.py | 12 +- .../sale_delivery_report/report/shipping.py | 2 +- addons/sale_journal/sale_journal.py | 40 +- addons/sale_journal/sale_journal_inherit.py | 4 +- .../sale_journal_picking_report.py | 44 +- addons/sale_journal/sale_journal_report.py | 24 +- addons/scrum/report/_burndown.py | 20 +- addons/scrum/report/sprint_burndown.py | 22 +- addons/scrum/report/task_burndown.py | 44 +- addons/scrum/scrum.py | 46 +- addons/scrum/wizard/backlog_to_task.py | 4 +- addons/service/profile_service.py | 4 +- addons/stock/__terp__.py | 2 +- addons/stock/partner.py | 12 +- addons/stock/product.py | 64 +- addons/stock/report/lot_location.py | 8 +- addons/stock/report/lot_overview.py | 10 +- addons/stock/report/lot_overview_all.py | 10 +- addons/stock/report/picking.py | 2 +- addons/stock/report/product_stock.py | 22 +- addons/stock/report/stock_by_location.py | 10 +- addons/stock/report/stock_graph.py | 44 +- addons/stock/report_stock.py | 10 +- addons/stock/stock.py | 264 +++--- addons/stock/stock_wizard.py | 96 +- addons/stock/wizard/inventory_merge_zero.py | 6 +- addons/stock/wizard/stock_traceability.py | 6 +- addons/stock/wizard/wizard_inventory.py | 28 +- .../stock/wizard/wizard_invoice_onshipping.py | 10 +- .../stock/wizard/wizard_location_product.py | 14 +- addons/stock/wizard/wizard_partial_move.py | 34 +- addons/stock/wizard/wizard_partial_picking.py | 28 +- addons/stock/wizard/wizard_return.py | 62 +- .../wizard/wizard_split_inventory_lots.py | 24 +- addons/stock/wizard/wizard_split_lot_line.py | 2 +- addons/stock/wizard/wizard_ups.py | 4 +- addons/stock_location/stock.py | 8 +- .../stock_no_autopicking.py | 4 +- addons/subscription/subscription.py | 44 +- addons/survey/__terp__.py | 2 +- .../survey/report/survey_analysis_report.py | 118 +-- .../survey/report/survey_browse_response.py | 132 +-- addons/survey/report/survey_form.py | 244 ++--- addons/survey/survey.py | 446 ++++----- addons/survey/wizard/__init__.py | 2 +- addons/survey/wizard/wizard_browse_answer.py | 22 +- addons/survey/wizard/wizard_print_survey.py | 22 +- addons/survey/wizard/wizard_survey.py | 106 +-- addons/thunderbird/__terp__.py | 2 +- addons/thunderbird/partner/partner.py | 90 +- addons/users_ldap/users_ldap.py | 16 +- addons/warning/warning.py | 134 +-- addons/wiki/wiki.py | 64 +- addons/wiki/wizard/create_menu.py | 16 +- addons/wiki/wizard/make_index.py | 4 +- addons/wiki/wizard/open_help.py | 8 +- addons/wiki/wizard/open_page.py | 10 +- addons/wiki/wizard/show_diff.py | 6 +- 628 files changed, 14215 insertions(+), 14216 deletions(-) diff --git a/addons/account/account.py b/addons/account/account.py index 516c185b652..16c58cd6fce 100644 --- a/addons/account/account.py +++ b/addons/account/account.py @@ -42,7 +42,7 @@ class account_payment_term(osv.osv): 'line_ids': fields.one2many('account.payment.term.line', 'payment_id', 'Terms'), } _defaults = { - 'active': lambda *a: 1, + 'active': lambda * a: 1, } _order = "name" @@ -65,7 +65,7 @@ class account_payment_term(osv.osv): next_date += RelativeDateTime(day=line.days2) if line.days2 > 0: next_date += RelativeDateTime(day=line.days2, months=1) - result.append( (next_date.strftime('%Y-%m-%d'), amt) ) + result.append((next_date.strftime('%Y-%m-%d'), amt)) amount -= amt return result @@ -91,15 +91,15 @@ class account_payment_term_line(osv.osv): 'payment_id': fields.many2one('account.payment.term', 'Payment Term', required=True, select=True), } _defaults = { - 'value': lambda *a: 'balance', - 'sequence': lambda *a: 5, - 'days2': lambda *a: 0, + 'value': lambda * a: 'balance', + 'sequence': lambda * a: 5, + 'days2': lambda * a: 0, } _order = "sequence" def _check_percent(self, cr, uid, ids, context={}): obj = self.browse(cr, uid, ids[0]) - if obj.value == 'procent' and ( obj.value_amount < 0.0 or obj.value_amount > 1.0): + if obj.value == 'procent' and (obj.value_amount < 0.0 or obj.value_amount > 1.0): return False return True @@ -122,9 +122,9 @@ class account_account_type(osv.osv): 'sign': fields.selection([(-1, 'Negative'), (1, 'Positive')], 'Sign on Reports', required=True, help='Allows you to change the sign of the balance amount displayed in the reports, so that you can see positive figures instead of negative ones in expenses accounts.'), } _defaults = { - 'close_method': lambda *a: 'none', - 'sequence': lambda *a: 5, - 'sign': lambda *a: 1, + 'close_method': lambda * a: 'none', + 'sequence': lambda * a: 5, + 'sign': lambda * a: 1, } _order = "sequence" account_account_type() @@ -159,14 +159,14 @@ class account_account(osv.osv): while pos < len(args): if args[pos][0] == 'code' and args[pos][1] in ('like', 'ilike') and args[pos][2]: - args[pos] = ('code', '=like', str(args[pos][2].replace('%', ''))+'%') + args[pos] = ('code', '=like', str(args[pos][2].replace('%', '')) + '%') if args[pos][0] == 'journal_id': if not args[pos][2]: del args[pos] continue jour = self.pool.get('account.journal').browse(cr, uid, args[pos][2]) if (not (jour.account_control_ids or jour.type_control_ids)) or not args[pos][2]: - args[pos] = ('type','not in',('consolidation','view')) + args[pos] = ('type', 'not in', ('consolidation', 'view')) continue ids3 = map(lambda x: x.id, jour.type_control_ids) ids1 = super(account_account, self).search(cr, uid, [('user_type', 'in', ids3)]) @@ -216,14 +216,14 @@ class account_account(osv.osv): wheres.append(aml_query.strip()) query = " AND ".join(wheres) - cr.execute("SELECT l.account_id as id, " +\ + cr.execute("SELECT l.account_id as id, " + \ ' , '.join(map(lambda x: mapping[x], field_names)) + "FROM " \ "account_move_line l " \ "WHERE " \ "l.account_id =ANY(%s) " \ + query + - " GROUP BY l.account_id",(ids2,)) + " GROUP BY l.account_id", (ids2,)) for res in cr.dictfetchall(): accounts[res['id']] = res @@ -256,7 +256,7 @@ class account_account(osv.osv): def _get_company_currency(self, cr, uid, ids, field_name, arg, context={}): result = {} for rec in self.browse(cr, uid, ids, context): - result[rec.id] = (rec.company_id.currency_id.id,rec.company_id.currency_id.code) + result[rec.id] = (rec.company_id.currency_id.id, rec.company_id.currency_id.code) return result def _get_child_ids(self, cr, uid, ids, field_name, arg, context={}): @@ -289,11 +289,11 @@ class account_account(osv.osv): "special effects in Open ERP: view can not have entries, consolidation are accounts that "\ "can have children accounts for multi-company consolidations, payable/receivable are for "\ "partners accounts (for debit/credit computations), closed for depreciated accounts."), - 'user_type': fields.many2one('account.account.type', 'Account Type', required=True, + 'user_type': fields.many2one('account.account.type', 'Account Type', required=True, help="These types are defined according to your country. The type contains more information "\ "about the account and its specificities."), 'parent_id': fields.many2one('account.account', 'Parent', ondelete='cascade'), - 'child_parent_ids': fields.one2many('account.account','parent_id','Children'), + 'child_parent_ids': fields.one2many('account.account', 'parent_id', 'Children'), 'child_consol_ids': fields.many2many('account.account', 'account_account_consol_rel', 'child_id', 'parent_id', 'Consolidated Children'), 'child_id': fields.function(_get_child_ids, method=True, type='many2many', relation="account.account", string="Child Accounts"), 'balance': fields.function(__compute, digits=(16, int(config['price_accuracy'])), method=True, string='Balance', multi='balance'), @@ -329,13 +329,13 @@ class account_account(osv.osv): return self.pool.get('res.company').search(cr, uid, [('parent_id', '=', False)])[0] _defaults = { - 'type': lambda *a : 'view', - 'reconcile': lambda *a: False, + 'type': lambda * a : 'view', + 'reconcile': lambda * a: False, 'company_id': _default_company, - 'active': lambda *a: True, - 'check_history': lambda *a: True, - 'currency_mode': lambda *a: 'current', - 'company_id': lambda s,cr,uid,c: s.pool.get('res.company')._company_default_get(cr, uid, 'account.account', context=c), + 'active': lambda * a: True, + 'check_history': lambda * a: True, + 'currency_mode': lambda * a: 'current', + 'company_id': lambda s, cr, uid, c: s.pool.get('res.company')._company_default_get(cr, uid, 'account.account', context=c), } def _check_recursion(self, cr, uid, ids): @@ -344,7 +344,7 @@ class account_account(osv.osv): if (obj_self in obj_self.child_consol_ids) or (p_id and (p_id is obj_self.id)): return False while(ids): - cr.execute('select distinct child_id from account_account_consol_rel where parent_id =ANY(%s)',(ids,)) + cr.execute('select distinct child_id from account_account_consol_rel where parent_id =ANY(%s)', (ids,)) child_ids = filter(None, map(lambda x: x[0], cr.fetchall())) c_ids = child_ids if (p_id and (p_id in c_ids)) or (obj_self.id in c_ids): @@ -383,11 +383,11 @@ class account_account(osv.osv): except: pass if name: - ids = self.search(cr, user, [('code', '=like', name+"%")]+args, limit=limit) + ids = self.search(cr, user, [('code', '=like', name + "%")] + args, limit=limit) if not ids: - ids = self.search(cr, user, [('shortcut', '=', name)]+ args, limit=limit) + ids = self.search(cr, user, [('shortcut', '=', name)] + args, limit=limit) if not ids: - ids = self.search(cr, user, [('name', operator, name)]+ args, limit=limit) + ids = self.search(cr, user, [('name', operator, name)] + args, limit=limit) else: ids = self.search(cr, user, args, context=context, limit=limit) return self.name_get(cr, user, ids, context=context) @@ -400,7 +400,7 @@ class account_account(osv.osv): for record in reads: name = record['name'] if record['code']: - name = record['code'] + ' '+name + name = record['code'] + ' ' + name res.append((record['id'], name)) return res @@ -435,18 +435,18 @@ class account_account(osv.osv): elif method == 'unlink': raise osv.except_osv(_('Error !'), _('You cannot remove an account which has account entries!. ')) return True - + def write(self, cr, uid, ids, vals, context=None): if not context: context = {} if 'active' in vals and not vals['active']: self._check_moves(cr, uid, ids, "write", context) return super(account_account, self).write(cr, uid, ids, vals, context=context) - + def unlink(self, cr, uid, ids, context={}): self._check_moves(cr, uid, ids, "unlink", context) return super(account_account, self).unlink(cr, uid, ids, context) - + account_account() class account_journal_view(osv.osv): @@ -465,7 +465,7 @@ class account_journal_column(osv.osv): result = [] cols = self.pool.get('account.move.line')._columns for col in cols: - result.append( (col, cols[col].string) ) + result.append((col, cols[col].string)) result.sort() return result _name = "account.journal.column" @@ -495,8 +495,8 @@ class account_journal(osv.osv): " Select 'Situation' to be used at the time of making vouchers."), 'refund_journal': fields.boolean('Refund Journal', help='Fill this if the journal is to be used for refunds of invoices.'), - 'type_control_ids': fields.many2many('account.account.type', 'account_journal_type_rel', 'journal_id','type_id', 'Type Controls', domain=[('code','<>','view'), ('code', '<>', 'closed')]), - 'account_control_ids': fields.many2many('account.account', 'account_account_type_rel', 'journal_id','account_id', 'Account', domain=[('type','<>','view'), ('type', '<>', 'closed')]), + 'type_control_ids': fields.many2many('account.account.type', 'account_journal_type_rel', 'journal_id', 'type_id', 'Type Controls', domain=[('code', '<>', 'view'), ('code', '<>', 'closed')]), + 'account_control_ids': fields.many2many('account.account', 'account_account_type_rel', 'journal_id', 'account_id', 'Account', domain=[('type', '<>', 'view'), ('type', '<>', 'closed')]), 'active': fields.boolean('Active', help="If the active field is set to true, it will allow you to hide the journal without removing it."), 'view_id': fields.many2one('account.journal.view', 'View', required=True, help="Gives the view used when writing or browsing entries in this journal. The view tells Open ERP which fields should be visible, required or readonly and in which order. You can create your own view for a faster encoding in each journal."), @@ -510,15 +510,15 @@ class account_journal(osv.osv): 'groups_id': fields.many2many('res.groups', 'account_journal_group_rel', 'journal_id', 'group_id', 'Groups'), 'currency': fields.many2one('res.currency', 'Currency', help='The currency used to enter statement'), 'entry_posted': fields.boolean('Skip \'Draft\' State for Created Entries', help='Check this box if you don\'t want new account moves to pass through the \'draft\' state and instead goes directly to the \'posted state\' without any manual validation.'), - 'company_id': fields.many2one('res.company', 'Company', required=True,select=1), + 'company_id': fields.many2one('res.company', 'Company', required=True, select=1), 'invoice_sequence_id': fields.many2one('ir.sequence', 'Invoice Sequence', \ help="The sequence used for invoice numbers in this journal."), } _defaults = { - 'active': lambda *a: 1, - 'user_id': lambda self,cr,uid,context: uid, - 'company_id': lambda self,cr,uid,c: self.pool.get('res.users').browse(cr, uid, uid, c).company_id.id, + 'active': lambda * a: 1, + 'user_id': lambda self, cr, uid, context: uid, + 'company_id': lambda self, cr, uid, c: self.pool.get('res.users').browse(cr, uid, uid, c).company_id.id, } def create(self, cr, uid, vals, context={}): journal_id = super(account_journal, self).create(cr, uid, vals, context) @@ -535,14 +535,14 @@ class account_journal(osv.osv): def name_search(self, cr, user, name, args=None, operator='ilike', context=None, limit=100): if not args: - args=[] + args = [] if not context: - context={} + context = {} ids = [] if name: - ids = self.search(cr, user, [('code','ilike',name)]+ args, limit=limit) + ids = self.search(cr, user, [('code', 'ilike', name)] + args, limit=limit) if not ids: - ids = self.search(cr, user, [('name',operator,name)]+ args, limit=limit) + ids = self.search(cr, user, [('name', operator, name)] + args, limit=limit) return self.name_get(cr, user, ids, context=context) account_journal() @@ -557,18 +557,18 @@ class account_fiscalyear(osv.osv): 'date_start': fields.date('Start Date', required=True), 'date_stop': fields.date('End Date', required=True), 'period_ids': fields.one2many('account.period', 'fiscalyear_id', 'Periods'), - 'state': fields.selection([('draft','Draft'), ('done','Done')], 'State', readonly=True, + 'state': fields.selection([('draft', 'Draft'), ('done', 'Done')], 'State', readonly=True, help='When fiscal year is created. The state is \'Draft\'. At the end of the year it is in \'Done\' state.'), } _defaults = { - 'state': lambda *a: 'draft', - 'company_id': lambda self,cr,uid,c: self.pool.get('res.users').browse(cr, uid, uid, c).company_id.id, + 'state': lambda * a: 'draft', + 'company_id': lambda self, cr, uid, c: self.pool.get('res.users').browse(cr, uid, uid, c).company_id.id, } _order = "date_start" - def _check_duration(self,cr,uid,ids): - obj_fy=self.browse(cr,uid,ids[0]) + def _check_duration(self, cr, uid, ids): + obj_fy = self.browse(cr, uid, ids[0]) if obj_fy.date_stop < obj_fy.date_start: return False return True @@ -577,17 +577,17 @@ class account_fiscalyear(osv.osv): (_check_duration, 'Error ! The duration of the Fiscal Year is invalid. ', ['date_stop']) ] - def create_period3(self,cr, uid, ids, context={}): + def create_period3(self, cr, uid, ids, context={}): return self.create_period(cr, uid, ids, context, 3) - def create_period(self,cr, uid, ids, context={}, interval=1): + def create_period(self, cr, uid, ids, context={}, interval=1): for fy in self.browse(cr, uid, ids, context): ds = mx.DateTime.strptime(fy.date_start, '%Y-%m-%d') - while ds.strftime('%Y-%m-%d')fy.date_stop: - de=mx.DateTime.strptime(fy.date_stop, '%Y-%m-%d') + if de.strftime('%Y-%m-%d') > fy.date_stop: + de = mx.DateTime.strptime(fy.date_stop, '%Y-%m-%d') self.pool.get('account.period').create(cr, uid, { 'name': ds.strftime('%m/%Y'), @@ -619,27 +619,27 @@ class account_period(osv.osv): 'code': fields.char('Code', size=12), 'special': fields.boolean('Opening/Closing Period', size=12, help="These periods can overlap."), - 'date_start': fields.date('Start of Period', required=True, states={'done':[('readonly',True)]}), - 'date_stop': fields.date('End of Period', required=True, states={'done':[('readonly',True)]}), - 'fiscalyear_id': fields.many2one('account.fiscalyear', 'Fiscal Year', required=True, states={'done':[('readonly',True)]}, select=True), - 'state': fields.selection([('draft','Draft'), ('done','Done')], 'State', readonly=True, + 'date_start': fields.date('Start of Period', required=True, states={'done':[('readonly', True)]}), + 'date_stop': fields.date('End of Period', required=True, states={'done':[('readonly', True)]}), + 'fiscalyear_id': fields.many2one('account.fiscalyear', 'Fiscal Year', required=True, states={'done':[('readonly', True)]}, select=True), + 'state': fields.selection([('draft', 'Draft'), ('done', 'Done')], 'State', readonly=True, help='When monthly periods are created. The state is \'Draft\'. At the end of monthly period it is in \'Done\' state.'), 'company_id': fields.many2one('res.company', 'Company', required=True) } _defaults = { - 'state': lambda *a: 'draft', - 'company_id': lambda self,cr,uid,c: self.pool.get('res.users').browse(cr, uid, uid, c).company_id.id, + 'state': lambda * a: 'draft', + 'company_id': lambda self, cr, uid, c: self.pool.get('res.users').browse(cr, uid, uid, c).company_id.id, } _order = "date_start" - def _check_duration(self,cr,uid,ids,context={}): - obj_period=self.browse(cr,uid,ids[0]) + def _check_duration(self, cr, uid, ids, context={}): + obj_period = self.browse(cr, uid, ids[0]) if obj_period.date_stop < obj_period.date_start: return False return True - def _check_year_limit(self,cr,uid,ids,context={}): - for obj_period in self.browse(cr,uid,ids): + def _check_year_limit(self, cr, uid, ids, context={}): + for obj_period in self.browse(cr, uid, ids): if obj_period.special: continue @@ -649,9 +649,9 @@ class account_period(osv.osv): obj_period.fiscalyear_id.date_start > obj_period.date_stop: return False - pids = self.search(cr, uid, [('date_stop','>=',obj_period.date_start),('date_start','<=',obj_period.date_stop),('special','=',False),('id','<>',obj_period.id)]) + pids = self.search(cr, uid, [('date_stop', '>=', obj_period.date_start), ('date_start', '<=', obj_period.date_stop), ('special', '=', False), ('id', '<>', obj_period.id)]) for period in self.browse(cr, uid, pids): - if period.fiscalyear_id.company_id.id==obj_period.fiscalyear_id.company_id.id: + if period.fiscalyear_id.company_id.id == obj_period.fiscalyear_id.company_id.id: return False return True @@ -661,24 +661,24 @@ class account_period(osv.osv): ] def next(self, cr, uid, period, step, context={}): - ids = self.search(cr, uid, [('date_start','>',period.date_start)]) - if len(ids)>=step: - return ids[step-1] + ids = self.search(cr, uid, [('date_start', '>', period.date_start)]) + if len(ids) >= step: + return ids[step - 1] return False def find(self, cr, uid, dt=None, context={}): if not dt: dt = time.strftime('%Y-%m-%d') #CHECKME: shouldn't we check the state of the period? - ids = self.search(cr, uid, [('date_start','<=',dt),('date_stop','>=',dt)]) + ids = self.search(cr, uid, [('date_start', '<=', dt), ('date_stop', '>=', dt)]) if not ids: - raise osv.except_osv(_('Error !'), _('No period defined for this date: %s !\nPlease create a fiscal year.')%dt) + raise osv.except_osv(_('Error !'), _('No period defined for this date: %s !\nPlease create a fiscal year.') % dt) return ids def action_draft(self, cr, uid, ids, *args): users_roles = self.pool.get('res.users').browse(cr, uid, uid).roles_id for role in users_roles: - if role.name=='Period': + if role.name == 'Period': mode = 'draft' for id in ids: cr.execute('update account_journal_period set state=%s where period_id=%s', (mode, id)) @@ -707,7 +707,7 @@ class account_journal_period(osv.osv): 'period_id': fields.many2one('account.period', 'Period', required=True, ondelete="cascade"), 'icon': fields.function(_icon_get, method=True, string='Icon', type='char', size=32), 'active': fields.boolean('Active', required=True, help="If the active field is set to true, it will allow you to hide the journal period without removing it."), - 'state': fields.selection([('draft','Draft'), ('printed','Printed'), ('done','Done')], 'State', required=True, readonly=True, + 'state': fields.selection([('draft', 'Draft'), ('printed', 'Printed'), ('done', 'Done')], 'State', required=True, readonly=True, help='When journal period is created. The state is \'Draft\'. If a report is printed it comes to \'Printed\' state. When all transactions are done, it comes in \'Done\' state.'), 'fiscalyear_id': fields.related('period_id', 'fiscalyear_id', string='Fiscal Year', type='many2one', relation='account.fiscalyear'), 'company_id' : fields.many2one('res.company', 'Company') @@ -726,10 +726,10 @@ class account_journal_period(osv.osv): return super(account_journal_period, self).write(cr, uid, ids, vals, context) def create(self, cr, uid, vals, context={}): - period_id=vals.get('period_id',False) + period_id = vals.get('period_id', False) if period_id: - period = self.pool.get('account.period').browse(cr, uid,period_id) - vals['state']=period.state + period = self.pool.get('account.period').browse(cr, uid, period_id) + vals['state'] = period.state return super(account_journal_period, self).create(cr, uid, vals, context) def unlink(self, cr, uid, ids, context={}): @@ -737,9 +737,9 @@ class account_journal_period(osv.osv): return super(account_journal_period, self).unlink(cr, uid, ids, context) _defaults = { - 'state': lambda *a: 'draft', - 'active': lambda *a: True, - 'company_id': lambda self,cr,uid,c: self.pool.get('res.users').browse(cr, uid, uid, c).company_id.id, + 'state': lambda * a: 'draft', + 'active': lambda * a: True, + 'company_id': lambda self, cr, uid, c: self.pool.get('res.users').browse(cr, uid, uid, c).company_id.id, } _order = "period_id" @@ -749,7 +749,7 @@ class account_fiscalyear(osv.osv): _inherit = "account.fiscalyear" _description = "Fiscal Year" _columns = { - 'end_journal_period_id':fields.many2one('account.journal.period','End of Year Entries Journal', readonly=True), + 'end_journal_period_id':fields.many2one('account.journal.period', 'End of Year Entries Journal', readonly=True), } account_fiscalyear() @@ -764,10 +764,10 @@ class account_move(osv.osv): def name_get(self, cursor, user, ids, context=None): if not len(ids): return [] - res=[] - data_move = self.pool.get('account.move').browse(cursor,user,ids) + res = [] + data_move = self.pool.get('account.move').browse(cursor, user, ids) for move in data_move: - if move.state=='draft': + if move.state == 'draft': name = '*' + str(move.id) else: name = move.name @@ -782,14 +782,14 @@ class account_move(osv.osv): else: return False - def _amount_compute(self, cr, uid, ids, name, args, context, where =''): + def _amount_compute(self, cr, uid, ids, name, args, context, where=''): if not ids: return {} - cr.execute('select move_id,sum(debit) from account_move_line where move_id =ANY(%s) group by move_id',(ids,)) + cr.execute('select move_id,sum(debit) from account_move_line where move_id =ANY(%s) group by move_id', (ids,)) result = dict(cr.fetchall()) for id in ids: result.setdefault(id, 0.0) return result - + def _search_amount(self, cr, uid, obj, name, args, context): ids = [] cr.execute('select move_id,sum(debit) from account_move_line group by move_id') @@ -797,12 +797,12 @@ class account_move(osv.osv): for item in args: if item[1] == '>=': - res = [('id', 'in', [k for k,v in result.iteritems() if v >= item[2]])] + res = [('id', 'in', [k for k, v in result.iteritems() if v >= item[2]])] else: - res = [('id', 'in', [k for k,v in result.iteritems() if v <= item[2]])] + res = [('id', 'in', [k for k, v in result.iteritems() if v <= item[2]])] ids += res - if not ids: + if not ids: return [('id', '>', '0')] return ids @@ -810,35 +810,35 @@ class account_move(osv.osv): _columns = { 'name': fields.char('Number', size=64, required=True), 'ref': fields.char('Reference', size=64), - 'period_id': fields.many2one('account.period', 'Period', required=True, states={'posted':[('readonly',True)]}), - 'journal_id': fields.many2one('account.journal', 'Journal', required=True, states={'posted':[('readonly',True)]}), - 'state': fields.selection([('draft','Draft'), ('posted','Posted')], 'State', required=True, readonly=True, + 'period_id': fields.many2one('account.period', 'Period', required=True, states={'posted':[('readonly', True)]}), + 'journal_id': fields.many2one('account.journal', 'Journal', required=True, states={'posted':[('readonly', True)]}), + 'state': fields.selection([('draft', 'Draft'), ('posted', 'Posted')], 'State', required=True, readonly=True, help='When new account move is created the state will be \'Draft\'. When all the payments are done it will be in \'Posted\' state.'), - 'line_id': fields.one2many('account.move.line', 'move_id', 'Entries', states={'posted':[('readonly',True)]}), + 'line_id': fields.one2many('account.move.line', 'move_id', 'Entries', states={'posted':[('readonly', True)]}), 'to_check': fields.boolean('To Be Verified'), 'partner_id': fields.related('line_id', 'partner_id', type="many2one", relation="res.partner", string="Partner"), - 'amount': fields.function(_amount_compute, method=True, string='Amount', digits=(16,int(config['price_accuracy'])), type='float', fnct_search=_search_amount), + 'amount': fields.function(_amount_compute, method=True, string='Amount', digits=(16, int(config['price_accuracy'])), type='float', fnct_search=_search_amount), 'date': fields.date('Date', required=True), 'type': fields.selection([ - ('pay_voucher','Cash Payment'), - ('bank_pay_voucher','Bank Payment'), - ('rec_voucher','Cash Receipt'), - ('bank_rec_voucher','Bank Receipt'), - ('cont_voucher','Contra'), - ('journal_sale_vou','Journal Sale'), - ('journal_pur_voucher','Journal Purchase'), - ('journal_voucher','Journal Voucher'), - ],'Type', readonly=True, select=True, states={'draft':[('readonly',False)]}), - 'narration':fields.text('Narration', readonly=True, select=True, states={'draft':[('readonly',False)]}), - 'company_id': fields.related('journal_id','company_id',type='many2one',relation='res.company',string='Company',store=True), + ('pay_voucher', 'Cash Payment'), + ('bank_pay_voucher', 'Bank Payment'), + ('rec_voucher', 'Cash Receipt'), + ('bank_rec_voucher', 'Bank Receipt'), + ('cont_voucher', 'Contra'), + ('journal_sale_vou', 'Journal Sale'), + ('journal_pur_voucher', 'Journal Purchase'), + ('journal_voucher', 'Journal Voucher'), + ], 'Type', readonly=True, select=True, states={'draft':[('readonly', False)]}), + 'narration':fields.text('Narration', readonly=True, select=True, states={'draft':[('readonly', False)]}), + 'company_id': fields.related('journal_id', 'company_id', type='many2one', relation='res.company', string='Company', store=True), } _defaults = { - 'name': lambda *a: '/', - 'state': lambda *a: 'draft', + 'name': lambda * a: '/', + 'state': lambda * a: 'draft', 'period_id': _get_period, - 'type' : lambda *a : 'journal_voucher', - 'date': lambda *a:time.strftime('%Y-%m-%d'), - 'company_id': lambda self,cr,uid,c: self.pool.get('res.users').browse(cr, uid, uid, c).company_id.id, + 'type' : lambda * a : 'journal_voucher', + 'date': lambda * a:time.strftime('%Y-%m-%d'), + 'company_id': lambda self, cr, uid, c: self.pool.get('res.users').browse(cr, uid, uid, c).company_id.id, } def _check_centralisation(self, cursor, user, ids): @@ -872,7 +872,7 @@ class account_move(osv.osv): def post(self, cr, uid, ids, context=None): if self.validate(cr, uid, ids, context) and len(ids): for move in self.browse(cr, uid, ids): - if move.name =='/': + if move.name == '/': new_name = False journal = move.journal_id if journal.sequence_id: @@ -883,7 +883,7 @@ class account_move(osv.osv): if new_name: self.write(cr, uid, [move.id], {'name':new_name}) - cr.execute('update account_move set state=%s where id =ANY(%s) ',('posted',ids,)) + cr.execute('update account_move set state=%s where id =ANY(%s) ', ('posted', ids,)) else: raise osv.except_osv(_('Integrity Error !'), _('You can not validate a non-balanced entry !')) return True @@ -896,7 +896,7 @@ class account_move(osv.osv): if not line.journal_id.update_posted: raise osv.except_osv(_('Error !'), _('You can not modify a posted entry of this journal !\nYou should set the journal to allow cancelling entries if you want to do that.')) if len(ids): - cr.execute('update account_move set state=%s where id =ANY(%s)',('draft',ids,)) + cr.execute('update account_move set state=%s where id =ANY(%s)', ('draft', ids,)) return True def write(self, cr, uid, ids, vals, context={}): @@ -942,7 +942,7 @@ class account_move(osv.osv): if default is None: default = {} default = default.copy() - default.update({'state':'draft', 'name':'/',}) + default.update({'state':'draft', 'name':'/', }) return super(account_move, self).copy(cr, uid, id, default, context) def unlink(self, cr, uid, ids, context={}, check=True): @@ -965,14 +965,14 @@ class account_move(osv.osv): move = self.browse(cr, uid, [id])[0] amount = 0 for line in move.line_id: - amount+= (line.debit - line.credit) + amount += (line.debit - line.credit) return amount def _centralise(self, cr, uid, move, mode, context=None): if context is None: context = {} - if mode=='credit': + if mode == 'credit': account_id = move.journal_id.default_debit_account_id.id mode2 = 'debit' if not account_id: @@ -996,7 +996,7 @@ class account_move(osv.osv): else: context.update({'journal_id': move.journal_id.id, 'period_id': move.period_id.id}) line_id = self.pool.get('account.move.line').create(cr, uid, { - 'name': _(mode.capitalize()+' Centralisation'), + 'name': _(mode.capitalize() + ' Centralisation'), 'centralisation': mode, 'account_id': account_id, 'move_id': move.id, @@ -1016,9 +1016,9 @@ class account_move(osv.osv): else: line_id2 = 0 - cr.execute('select sum('+mode+') from account_move_line where move_id=%s and id<>%s', (move.id, line_id2)) + cr.execute('select sum(' + mode + ') from account_move_line where move_id=%s and id<>%s', (move.id, line_id2)) result = cr.fetchone()[0] or 0.0 - cr.execute('update account_move_line set '+mode2+'=%s where id=%s', (result, line_id)) + cr.execute('update account_move_line set ' + mode2 + '=%s where id=%s', (result, line_id)) return True # @@ -1032,17 +1032,17 @@ class account_move(osv.osv): #unlink analytic lines on move_lines for obj_line in move.line_id: for obj in obj_line.analytic_lines: - self.pool.get('account.analytic.line').unlink(cr,uid,obj.id) + self.pool.get('account.analytic.line').unlink(cr, uid, obj.id) journal = move.journal_id amount = 0 line_ids = [] line_draft_ids = [] - company_id=None + company_id = None for line in move.line_id: amount += line.debit - line.credit line_ids.append(line.id) - if line.state=='draft': + if line.state == 'draft': line_draft_ids.append(line.id) if not company_id: @@ -1065,7 +1065,7 @@ class account_move(osv.osv): todo = [] account = {} account2 = {} - if journal.type not in ('purchase','sale'): + if journal.type not in ('purchase', 'sale'): continue for line in move.line_id: @@ -1121,10 +1121,10 @@ class account_move_reconcile(osv.osv): 'create_date': fields.date('Creation date', readonly=True), } _defaults = { - 'name': lambda self,cr,uid,ctx={}: self.pool.get('ir.sequence').get(cr, uid, 'account.reconcile') or '/', + 'name': lambda self, cr, uid, ctx = {}: self.pool.get('ir.sequence').get(cr, uid, 'account.reconcile') or '/', } def reconcile_partial_check(self, cr, uid, ids, type='auto', context={}): - total = 0.0 + total = 0.0 for rec in self.browse(cr, uid, ids, context): for line in rec.line_partial_ids: total += (line.debit or 0.0) - (line.credit or 0.0) @@ -1140,12 +1140,12 @@ class account_move_reconcile(osv.osv): return [] result = [] for r in self.browse(cr, uid, ids, context): - total = reduce(lambda y,t: (t.debit or 0.0) - (t.credit or 0.0) + y, r.line_partial_ids, 0.0) + total = reduce(lambda y, t: (t.debit or 0.0) - (t.credit or 0.0) + y, r.line_partial_ids, 0.0) if total: name = '%s (%.2f)' % (r.name, total) - result.append((r.id,name)) + result.append((r.id, name)) else: - result.append((r.id,r.name)) + result.append((r.id, r.name)) return result @@ -1164,7 +1164,7 @@ class account_tax_code(osv.osv): This code is used for some tax declarations. """ - def _sum(self, cr, uid, ids, name, args, context, where =''): + def _sum(self, cr, uid, ids, name, args, context, where=''): ids2 = self.search(cr, uid, [('parent_id', 'child_of', ids)]) if context.get('based_on', 'invoices') == 'payments': cr.execute('SELECT line.tax_code_id, sum(line.tax_amount) \ @@ -1172,17 +1172,17 @@ class account_tax_code(osv.osv): account_move AS move \ LEFT JOIN account_invoice invoice ON \ (invoice.move_id = move.id) \ - WHERE line.tax_code_id =ANY(%s) '+where+' \ + WHERE line.tax_code_id =ANY(%s) ' + where + ' \ AND move.id = line.move_id \ AND ((invoice.state = \'paid\') \ OR (invoice.id IS NULL)) \ - GROUP BY line.tax_code_id',(ids2,)) + GROUP BY line.tax_code_id', (ids2,)) else: cr.execute('SELECT line.tax_code_id, sum(line.tax_amount) \ FROM account_move_line AS line \ - WHERE line.tax_code_id =ANY(%s) '+where+' \ - GROUP BY line.tax_code_id',(ids2,)) - res=dict(cr.fetchall()) + WHERE line.tax_code_id =ANY(%s) ' + where + ' \ + GROUP BY line.tax_code_id', (ids2,)) + res = dict(cr.fetchall()) for record in self.browse(cr, uid, ids, context): def _rec_get(record): amount = res.get(record.id, 0.0) @@ -1201,7 +1201,7 @@ class account_tax_code(osv.osv): if fiscalyear_id: pids = map(lambda x: str(x.id), self.pool.get('account.fiscalyear').browse(cr, uid, fiscalyear_id).period_ids) if pids: - where = ' and period_id in (' + (','.join(pids))+')' + where = ' and period_id in (' + (','.join(pids)) + ')' return self._sum(cr, uid, ids, name, args, context, where=where) @@ -1214,7 +1214,7 @@ class account_tax_code(osv.osv): return dict.fromkeys(ids, 0.0) period_id = period_id[0] return self._sum(cr, uid, ids, name, args, context, - where=' and line.period_id='+str(period_id)) + where=' and line.period_id=' + str(period_id)) _name = 'account.tax.code' _description = 'Tax Code' @@ -1239,7 +1239,7 @@ class account_tax_code(osv.osv): return [] if isinstance(ids, (int, long)): ids = [ids] - reads = self.read(cr, uid, ids, ['name','code'], context, load='_classic_write') + reads = self.read(cr, uid, ids, ['name', 'code'], context, load='_classic_write') return [(x['id'], (x['code'] and x['code'] + ' - ' or '') + x['name']) \ for x in reads] @@ -1250,13 +1250,13 @@ class account_tax_code(osv.osv): return self.pool.get('res.company').search(cr, uid, [('parent_id', '=', False)])[0] _defaults = { 'company_id': _default_company, - 'sign': lambda *args: 1.0, - 'notprintable': lambda *a: False, + 'sign': lambda * args: 1.0, + 'notprintable': lambda * a: False, } def _check_recursion(self, cr, uid, ids): level = 100 while len(ids): - cr.execute('select distinct parent_id from account_tax_code where id =ANY(%s)',(ids,)) + cr.execute('select distinct parent_id from account_tax_code where id =ANY(%s)', (ids,)) ids = filter(None, map(lambda x:x[0], cr.fetchall())) if not level: return False @@ -1286,11 +1286,11 @@ class account_tax(osv.osv): _columns = { 'name': fields.char('Tax Name', size=64, required=True, translate=True, help="This name will be displayed on reports"), 'sequence': fields.integer('Sequence', required=True, help="The sequence field is used to order the tax lines from the lowest sequences to the higher ones. The order is important if you have a tax with several tax children. In this case, the evaluation order is important."), - 'amount': fields.float('Amount', required=True, digits=(14,4), help="For Tax Type percent enter % ratio between 0-1."), + 'amount': fields.float('Amount', required=True, digits=(14, 4), help="For Tax Type percent enter % ratio between 0-1."), 'active': fields.boolean('Active', help="If the active field is set to true, it will allow you to hide the tax without removing it."), - 'type': fields.selection( [('percent','Percent'), ('fixed','Fixed'), ('none','None'), ('code','Python Code'),('balance','Balance')], 'Tax Type', required=True, + 'type': fields.selection([('percent', 'Percent'), ('fixed', 'Fixed'), ('none', 'None'), ('code', 'Python Code'), ('balance', 'Balance')], 'Tax Type', required=True, help="The computation method for the tax amount."), - 'applicable_type': fields.selection( [('true','True'), ('code','Python Code')], 'Applicable Type', required=True, + 'applicable_type': fields.selection([('true', 'True'), ('code', 'Python Code')], 'Applicable Type', required=True, help="If not applicable (computed through a Python code), the tax won't appear on the invoice."), 'domain':fields.char('Domain', size=32, help="This field is only used if you develop your own module allowing developers to create specific taxes in a custom domain."), 'account_collected_id':fields.many2one('account.account', 'Invoice Tax Account'), @@ -1301,7 +1301,7 @@ class account_tax(osv.osv): 'python_compute':fields.text('Python Code'), 'python_compute_inv':fields.text('Python Code (reverse)'), 'python_applicable':fields.text('Python Code'), - 'tax_group': fields.selection([('vat','VAT'),('other','Other')], 'Tax Group', help="If a default tax is given in the partner it only overrides taxes from accounts (or products) in the same group."), + 'tax_group': fields.selection([('vat', 'VAT'), ('other', 'Other')], 'Tax Group', help="If a default tax is given in the partner it only overrides taxes from accounts (or products) in the same group."), # # Fields used for the VAT declaration @@ -1319,27 +1319,27 @@ class account_tax(osv.osv): 'ref_tax_sign': fields.float('Tax Code Sign', help="Usually 1 or -1."), 'include_base_amount': fields.boolean('Included in base amount', help="Indicates if the amount of tax must be included in the base amount for the computation of the next taxes"), 'company_id': fields.many2one('res.company', 'Company', required=True), - 'description': fields.char('Tax Code',size=32), + 'description': fields.char('Tax Code', size=32), 'price_include': fields.boolean('Tax Included in Price', help="Check this if the price you use on the product and invoices includes this tax."), - 'type_tax_use': fields.selection([('sale','Sale'),('purchase','Purchase'),('all','All')], 'Tax Application', required=True) + 'type_tax_use': fields.selection([('sale', 'Sale'), ('purchase', 'Purchase'), ('all', 'All')], 'Tax Application', required=True) } def search(self, cr, uid, args, offset=0, limit=None, order=None, context=None, count=False): if context and context.has_key('type'): - if context['type'] in ('out_invoice','out_refund'): - args.append(('type_tax_use','in',['sale','all'])) - elif context['type'] in ('in_invoice','in_refund'): - args.append(('type_tax_use','in',['purchase','all'])) + if context['type'] in ('out_invoice', 'out_refund'): + args.append(('type_tax_use', 'in', ['sale', 'all'])) + elif context['type'] in ('in_invoice', 'in_refund'): + args.append(('type_tax_use', 'in', ['purchase', 'all'])) return super(account_tax, self).search(cr, uid, args, offset, limit, order, context, count) def name_get(self, cr, uid, ids, context={}): if not len(ids): return [] res = [] - for record in self.read(cr, uid, ids, ['description','name'], context): + for record in self.read(cr, uid, ids, ['description', 'name'], context): name = record['description'] and record['description'] or record['name'] - res.append((record['id'],name )) + res.append((record['id'], name)) return res def _default_company(self, cr, uid, context={}): @@ -1348,21 +1348,21 @@ class account_tax(osv.osv): return user.company_id.id return self.pool.get('res.company').search(cr, uid, [('parent_id', '=', False)])[0] _defaults = { - 'python_compute': lambda *a: '''# price_unit\n# address : res.partner.address object or False\n# product : product.product object or None\n# partner : res.partner object or None\n\nresult = price_unit * 0.10''', - 'python_compute_inv': lambda *a: '''# price_unit\n# address : res.partner.address object or False\n# product : product.product object or False\n\nresult = price_unit * 0.10''', - 'applicable_type': lambda *a: 'true', - 'type': lambda *a: 'percent', - 'amount': lambda *a: 0, - 'price_include': lambda *a: 0, - 'active': lambda *a: 1, - 'type_tax_use': lambda *a: 'all', - 'sequence': lambda *a: 1, - 'tax_group': lambda *a: 'vat', - 'ref_tax_sign': lambda *a: 1, - 'ref_base_sign': lambda *a: 1, - 'tax_sign': lambda *a: 1, - 'base_sign': lambda *a: 1, - 'include_base_amount': lambda *a: False, + 'python_compute': lambda * a: '''# price_unit\n# address : res.partner.address object or False\n# product : product.product object or None\n# partner : res.partner object or None\n\nresult = price_unit * 0.10''', + 'python_compute_inv': lambda * a: '''# price_unit\n# address : res.partner.address object or False\n# product : product.product object or False\n\nresult = price_unit * 0.10''', + 'applicable_type': lambda * a: 'true', + 'type': lambda * a: 'percent', + 'amount': lambda * a: 0, + 'price_include': lambda * a: 0, + 'active': lambda * a: 1, + 'type_tax_use': lambda * a: 'all', + 'sequence': lambda * a: 1, + 'tax_group': lambda * a: 'vat', + 'ref_tax_sign': lambda * a: 1, + 'ref_base_sign': lambda * a: 1, + 'tax_sign': lambda * a: 1, + 'base_sign': lambda * a: 1, + 'include_base_amount': lambda * a: False, 'company_id': _default_company, } _order = 'sequence' @@ -1370,7 +1370,7 @@ class account_tax(osv.osv): def _applicable(self, cr, uid, taxes, price_unit, address_id=None, product=None, partner=None): res = [] for tax in taxes: - if tax.applicable_type=='code': + if tax.applicable_type == 'code': localdict = {'price_unit':price_unit, 'address':self.pool.get('res.partner.address').browse(cr, uid, address_id), 'product':product, 'partner':partner} exec tax.python_applicable in localdict if localdict.get('result', False): @@ -1383,7 +1383,7 @@ class account_tax(osv.osv): taxes = self._applicable(cr, uid, taxes, price_unit, address_id, product, partner) res = [] - cur_price_unit=price_unit + cur_price_unit = price_unit for tax in taxes: # we compute the amount for the current tax object and append it to the result @@ -1403,22 +1403,22 @@ class account_tax(osv.osv): 'ref_tax_code_id': tax.ref_tax_code_id.id, } res.append(data) - if tax.type=='percent': + if tax.type == 'percent': amount = cur_price_unit * tax.amount data['amount'] = amount - elif tax.type=='fixed': + elif tax.type == 'fixed': data['amount'] = tax.amount - data['tax_amount']=quantity + data['tax_amount'] = quantity # data['amount'] = quantity - elif tax.type=='code': + elif tax.type == 'code': address = address_id and self.pool.get('res.partner.address').browse(cr, uid, address_id) or None localdict = {'price_unit':cur_price_unit, 'address':address, 'product':product, 'partner':partner} exec tax.python_compute in localdict amount = localdict['result'] data['amount'] = amount - elif tax.type=='balance': - data['amount'] = cur_price_unit - reduce(lambda x,y: y.get('amount',0.0)+x, res, 0.0) + elif tax.type == 'balance': + data['amount'] = cur_price_unit - reduce(lambda x, y: y.get('amount', 0.0) + x, res, 0.0) data['balance'] = cur_price_unit amount2 = data['amount'] @@ -1430,20 +1430,20 @@ class account_tax(osv.osv): res.extend(child_tax) if tax.child_depend: for r in res: - for name in ('base','ref_base'): - if latest[name+'_code_id'] and latest[name+'_sign'] and not r[name+'_code_id']: - r[name+'_code_id'] = latest[name+'_code_id'] - r[name+'_sign'] = latest[name+'_sign'] + for name in ('base', 'ref_base'): + if latest[name + '_code_id'] and latest[name + '_sign'] and not r[name + '_code_id']: + r[name + '_code_id'] = latest[name + '_code_id'] + r[name + '_sign'] = latest[name + '_sign'] r['price_unit'] = latest['price_unit'] - latest[name+'_code_id'] = False - for name in ('tax','ref_tax'): - if latest[name+'_code_id'] and latest[name+'_sign'] and not r[name+'_code_id']: - r[name+'_code_id'] = latest[name+'_code_id'] - r[name+'_sign'] = latest[name+'_sign'] + latest[name + '_code_id'] = False + for name in ('tax', 'ref_tax'): + if latest[name + '_code_id'] and latest[name + '_sign'] and not r[name + '_code_id']: + r[name + '_code_id'] = latest[name + '_code_id'] + r[name + '_sign'] = latest[name + '_sign'] r['amount'] = data['amount'] - latest[name+'_code_id'] = False + latest[name + '_code_id'] = False if tax.include_base_amount: - cur_price_unit+=amount2 + cur_price_unit += amount2 return res def compute(self, cr, uid, taxes, price_unit, quantity, address_id=None, product=None, partner=None): @@ -1459,7 +1459,7 @@ class account_tax(osv.osv): res = self._unit_compute(cr, uid, taxes, price_unit, address_id, product, partner, quantity) total = 0.0 for r in res: - if r.get('balance',False): + if r.get('balance', False): r['amount'] = round(r['balance'] * quantity, int(config['price_accuracy'])) - total else: r['amount'] = round(r['amount'] * quantity, int(config['price_accuracy'])) @@ -1476,30 +1476,30 @@ class account_tax(osv.osv): tax_parent_tot = 0.0 for tax in taxes: - if (tax.type=='percent') and not tax.include_base_amount: + if (tax.type == 'percent') and not tax.include_base_amount: tax_parent_tot += tax.amount for tax in taxes: - if (tax.type=='fixed') and not tax.include_base_amount: + if (tax.type == 'fixed') and not tax.include_base_amount: cur_price_unit -= tax.amount for tax in taxes: - if tax.type=='percent': + if tax.type == 'percent': if tax.include_base_amount: amount = cur_price_unit - (cur_price_unit / (1 + tax.amount)) else: amount = (cur_price_unit / (1 + tax_parent_tot)) * tax.amount - elif tax.type=='fixed': + elif tax.type == 'fixed': amount = tax.amount - elif tax.type=='code': + elif tax.type == 'code': address = address_id and self.pool.get('res.partner.address').browse(cr, uid, address_id) or None localdict = {'price_unit':cur_price_unit, 'address':address, 'product':product, 'partner':partner} exec tax.python_compute_inv in localdict amount = localdict['result'] - elif tax.type=='balance': - amount = cur_price_unit - reduce(lambda x,y: y.get('amount',0.0)+x, res, 0.0) + elif tax.type == 'balance': + amount = cur_price_unit - reduce(lambda x, y: y.get('amount', 0.0) + x, res, 0.0) # data['balance'] = cur_price_unit @@ -1556,7 +1556,7 @@ class account_tax(osv.osv): res = self._unit_compute_inv(cr, uid, taxes, price_unit, address_id, product, partner=None) total = 0.0 for r in res: - if r.get('balance',False): + if r.get('balance', False): r['amount'] = round(r['balance'] * quantity, int(config['price_accuracy'])) - total else: r['amount'] = round(r['amount'] * quantity, int(config['price_accuracy'])) @@ -1576,7 +1576,7 @@ class account_model(osv.osv): 'ref': fields.char('Reference', size=64), 'journal_id': fields.many2one('account.journal', 'Journal', required=True), 'lines_id': fields.one2many('account.model.line', 'model_id', 'Model Entries'), - 'legend' :fields.text('Legend',readonly=True,size=100), + 'legend' :fields.text('Legend', readonly=True, size=100), } _defaults = { @@ -1586,7 +1586,7 @@ class account_model(osv.osv): move_ids = [] for model in self.browse(cr, uid, ids, context): context.update({'date':datas['date']}) - period_id = self.pool.get('account.period').find(cr, uid, dt=context.get('date',False)) + period_id = self.pool.get('account.period').find(cr, uid, dt=context.get('date', False)) if not period_id: raise osv.except_osv(_('No period found !'), _('Unable to find a valid period !')) period_id = period_id[0] @@ -1594,7 +1594,7 @@ class account_model(osv.osv): 'ref': model.ref, 'period_id': period_id, 'journal_id': model.journal_id.id, - 'date': context.get('date',time.strftime('%Y-%m-%d')) + 'date': context.get('date', time.strftime('%Y-%m-%d')) }) move_ids.append(move_id) for line in model.lines_id: @@ -1612,11 +1612,11 @@ class account_model(osv.osv): 'move_id': move_id, 'ref': line.ref, 'partner_id': line.partner_id.id, - 'date': context.get('date',time.strftime('%Y-%m-%d')), + 'date': context.get('date', time.strftime('%Y-%m-%d')), 'date_maturity': time.strftime('%Y-%m-%d') }) c = context.copy() - c.update({'journal_id': model.journal_id.id,'period_id': period_id}) + c.update({'journal_id': model.journal_id.id, 'period_id': period_id}) self.pool.get('account.move.line').create(cr, uid, val, context=c) return move_ids account_model() @@ -1641,15 +1641,15 @@ class account_model_line(osv.osv): 'currency_id': fields.many2one('res.currency', 'Currency'), 'partner_id': fields.many2one('res.partner', 'Partner'), - 'date_maturity': fields.selection([('today','Date of the day'), ('partner','Partner Payment Term')], 'Maturity date', help="The maturity date of the generated entries for this model. You can choose between the creation date or the creation date of the entries plus the partner payment terms."), - 'date': fields.selection([('today','Date of the day'), ('partner','Partner Payment Term')], 'Current Date', required=True, help="The date of the generated entries"), + 'date_maturity': fields.selection([('today', 'Date of the day'), ('partner', 'Partner Payment Term')], 'Maturity date', help="The maturity date of the generated entries for this model. You can choose between the creation date or the creation date of the entries plus the partner payment terms."), + 'date': fields.selection([('today', 'Date of the day'), ('partner', 'Partner Payment Term')], 'Current Date', required=True, help="The date of the generated entries"), } _defaults = { - 'date': lambda *a: 'today' + 'date': lambda * a: 'today' } _order = 'sequence' _sql_constraints = [ - ('credit_debit1', 'CHECK (credit*debit=0)', 'Wrong credit or debit value in model (Credit Or Debit Must Be "0")!'), + ('credit_debit1', 'CHECK (credit*debit=0)', 'Wrong credit or debit value in model (Credit Or Debit Must Be "0")!'), ('credit_debit2', 'CHECK (credit+debit>=0)', 'Wrong credit or debit value in model (Credit + Debit Must Be greater "0")!'), ] account_model_line() @@ -1670,17 +1670,17 @@ class account_subscription(osv.osv): 'date_start': fields.date('Start Date', required=True), 'period_total': fields.integer('Number of Periods', required=True), 'period_nbr': fields.integer('Period', required=True), - 'period_type': fields.selection([('day','days'),('month','month'),('year','year')], 'Period Type', required=True), - 'state': fields.selection([('draft','Draft'),('running','Running'),('done','Done')], 'State', required=True, readonly=True), + 'period_type': fields.selection([('day', 'days'), ('month', 'month'), ('year', 'year')], 'Period Type', required=True), + 'state': fields.selection([('draft', 'Draft'), ('running', 'Running'), ('done', 'Done')], 'State', required=True, readonly=True), 'lines_id': fields.one2many('account.subscription.line', 'subscription_id', 'Subscription Lines') } _defaults = { - 'date_start': lambda *a: time.strftime('%Y-%m-%d'), - 'period_type': lambda *a: 'month', - 'period_total': lambda *a: 12, - 'period_nbr': lambda *a: 1, - 'state': lambda *a: 'draft', + 'date_start': lambda * a: time.strftime('%Y-%m-%d'), + 'period_type': lambda * a: 'month', + 'period_total': lambda * a: 12, + 'period_nbr': lambda * a: 1, + 'state': lambda * a: 'draft', } def state_draft(self, cr, uid, ids, context={}): self.write(cr, uid, ids, {'state':'draft'}) @@ -1719,11 +1719,11 @@ class account_subscription(osv.osv): 'date': ds, 'subscription_id': sub.id, }) - if sub.period_type=='day': + if sub.period_type == 'day': ds = (mx.DateTime.strptime(ds, '%Y-%m-%d') + RelativeDateTime(days=sub.period_nbr)).strftime('%Y-%m-%d') - if sub.period_type=='month': + if sub.period_type == 'month': ds = (mx.DateTime.strptime(ds, '%Y-%m-%d') + RelativeDateTime(months=sub.period_nbr)).strftime('%Y-%m-%d') - if sub.period_type=='year': + if sub.period_type == 'year': ds = (mx.DateTime.strptime(ds, '%Y-%m-%d') + RelativeDateTime(years=sub.period_nbr)).strftime('%Y-%m-%d') self.write(cr, uid, ids, {'state':'running'}) return True @@ -1768,35 +1768,35 @@ class account_config_wizard(osv.osv_memory): help="Name of the fiscal year as displayed in reports."), 'date1': fields.date('Start Date', required=True), 'date2': fields.date('End Date', required=True), - 'period':fields.selection([('month','Month'), ('3months','3 Months')], + 'period':fields.selection([('month', 'Month'), ('3months', '3 Months')], 'Periods', required=True), } _defaults = { - 'code': lambda *a: time.strftime('%Y'), - 'name': lambda *a: time.strftime('%Y'), - 'date1': lambda *a: time.strftime('%Y-01-01'), - 'date2': lambda *a: time.strftime('%Y-12-31'), - 'period':lambda *a:'month', + 'code': lambda * a: time.strftime('%Y'), + 'name': lambda * a: time.strftime('%Y'), + 'date1': lambda * a: time.strftime('%Y-01-01'), + 'date2': lambda * a: time.strftime('%Y-12-31'), + 'period':lambda * a:'month', } def execute(self, cr, uid, ids, context=None): - for res in self.read(cr,uid,ids): + for res in self.read(cr, uid, ids): if 'date1' in res and 'date2' in res: res_obj = self.pool.get('account.fiscalyear') - start_date=res['date1'] - end_date=res['date2'] - name=res['name']#DateTime.strptime(start_date, '%Y-%m-%d').strftime('%m.%Y') + '-' + DateTime.strptime(end_date, '%Y-%m-%d').strftime('%m.%Y') - vals={ + start_date = res['date1'] + end_date = res['date2'] + name = res['name']#DateTime.strptime(start_date, '%Y-%m-%d').strftime('%m.%Y') + '-' + DateTime.strptime(end_date, '%Y-%m-%d').strftime('%m.%Y') + vals = { 'name':name, 'code':name, 'date_start':start_date, 'date_stop':end_date, } - new_id=res_obj.create(cr, uid, vals, context=context) - if res['period']=='month': - res_obj.create_period(cr,uid,[new_id]) - elif res['period']=='3months': - res_obj.create_period3(cr,uid,[new_id]) + new_id = res_obj.create(cr, uid, vals, context=context) + if res['period'] == 'month': + res_obj.create_period(cr, uid, [new_id]) + elif res['period'] == '3months': + res_obj.create_period3(cr, uid, [new_id]) account_config_wizard() @@ -1811,20 +1811,20 @@ account_tax_template() class account_account_template(osv.osv): _order = "code" _name = "account.account.template" - _description ='Templates for Accounts' + _description = 'Templates for Accounts' _columns = { 'name': fields.char('Name', size=128, required=True, select=True), 'currency_id': fields.many2one('res.currency', 'Secondary Currency', help="Forces all moves for this account to have this secondary currency."), 'code': fields.char('Code', size=64), 'type': fields.selection([ - ('receivable','Receivable'), - ('payable','Payable'), - ('view','View'), - ('consolidation','Consolidation'), - ('other','Others'), - ('closed','Closed'), - ], 'Internal Type', required=True,help="This type is used to differentiate types with "\ + ('receivable', 'Receivable'), + ('payable', 'Payable'), + ('view', 'View'), + ('consolidation', 'Consolidation'), + ('other', 'Others'), + ('closed', 'Closed'), + ], 'Internal Type', required=True, help="This type is used to differentiate types with "\ "special effects in Open ERP: view can not have entries, consolidation are accounts that "\ "can have children accounts for multi-company consolidations, payable/receivable are for "\ "partners accounts (for debit/credit computations), closed for depreciated accounts."), @@ -1834,22 +1834,22 @@ class account_account_template(osv.osv): 'reconcile': fields.boolean('Allow Reconciliation', help="Check this option if you want the user to reconcile entries in this account."), 'shortcut': fields.char('Shortcut', size=12), 'note': fields.text('Note'), - 'parent_id': fields.many2one('account.account.template','Parent Account Template', ondelete='cascade'), - 'child_parent_ids':fields.one2many('account.account.template','parent_id','Children'), - 'tax_ids': fields.many2many('account.tax.template', 'account_account_template_tax_rel','account_id','tax_id', 'Default Taxes'), + 'parent_id': fields.many2one('account.account.template', 'Parent Account Template', ondelete='cascade'), + 'child_parent_ids':fields.one2many('account.account.template', 'parent_id', 'Children'), + 'tax_ids': fields.many2many('account.tax.template', 'account_account_template_tax_rel', 'account_id', 'tax_id', 'Default Taxes'), 'nocreate': fields.boolean('Optional create', help="If checked, the new chart of accounts will not contain this by default."), } _defaults = { - 'reconcile': lambda *a: False, - 'type' : lambda *a :'view', - 'nocreate': lambda *a: False, + 'reconcile': lambda * a: False, + 'type' : lambda * a :'view', + 'nocreate': lambda * a: False, } def _check_recursion(self, cr, uid, ids): level = 100 while len(ids): - cr.execute('select parent_id from account_account_template where id =ANY(%s)',(ids,)) + cr.execute('select parent_id from account_account_template where id =ANY(%s)', (ids,)) ids = filter(None, map(lambda x:x[0], cr.fetchall())) if not level: return False @@ -1864,13 +1864,13 @@ class account_account_template(osv.osv): def name_get(self, cr, uid, ids, context={}): if not len(ids): return [] - reads = self.read(cr, uid, ids, ['name','code'], context) + reads = self.read(cr, uid, ids, ['name', 'code'], context) res = [] for record in reads: name = record['name'] if record['code']: - name = record['code']+' '+name - res.append((record['id'],name )) + name = record['code'] + ' ' + name + res.append((record['id'], name)) return res account_account_template() @@ -1882,16 +1882,16 @@ class account_add_tmpl_wizard(osv.osv_memory): _name = 'account.addtmpl.wizard' def _get_def_cparent(self, cr, uid, context): - acc_obj=self.pool.get('account.account') - tmpl_obj=self.pool.get('account.account.template') + acc_obj = self.pool.get('account.account') + tmpl_obj = self.pool.get('account.account.template') #print "Searching for ",context - tids=tmpl_obj.read(cr, uid, [context['tmpl_ids']],['parent_id']) + tids = tmpl_obj.read(cr, uid, [context['tmpl_ids']], ['parent_id']) if not tids or not tids[0]['parent_id']: return False - ptids = tmpl_obj.read(cr, uid, [tids[0]['parent_id'][0]],['code']) + ptids = tmpl_obj.read(cr, uid, [tids[0]['parent_id'][0]], ['code']) if not ptids or not ptids[0]['code']: raise osv.except_osv(_('Error !'), _('Cannot locate parent code for template account!')) - res = acc_obj.search(cr,uid,[('code','=',ptids[0]['code'])]) + res = acc_obj.search(cr, uid, [('code', '=', ptids[0]['code'])]) if res: return res[0] else: @@ -1903,17 +1903,17 @@ class account_add_tmpl_wizard(osv.osv_memory): _defaults = { 'cparent_id': _get_def_cparent, } - - def action_create(self,cr,uid,ids,context=None): - acc_obj=self.pool.get('account.account') - tmpl_obj=self.pool.get('account.account.template') - data= self.read(cr,uid,ids) - company_id = acc_obj.read(cr,uid,[data[0]['cparent_id']],['company_id'])[0]['company_id'][0] - account_template = tmpl_obj.browse(cr,uid,context['tmpl_ids']) + + def action_create(self, cr, uid, ids, context=None): + acc_obj = self.pool.get('account.account') + tmpl_obj = self.pool.get('account.account.template') + data = self.read(cr, uid, ids) + company_id = acc_obj.read(cr, uid, [data[0]['cparent_id']], ['company_id'])[0]['company_id'][0] + account_template = tmpl_obj.browse(cr, uid, context['tmpl_ids']) #tax_ids = [] #for tax in account_template.tax_ids: # tax_ids.append(tax_template_ref[tax.id]) - vals={ + vals = { 'name': account_template.name, #'sign': account_template.sign, 'currency_id': account_template.currency_id and account_template.currency_id.id or False, @@ -1928,10 +1928,10 @@ class account_add_tmpl_wizard(osv.osv_memory): 'company_id': company_id, } # print "Creating:", vals - new_account = acc_obj.create(cr,uid,vals) + new_account = acc_obj.create(cr, uid, vals) return {'type':'state', 'state': 'end' } - - def action_cancel(self,cr,uid,ids,context=None): + + def action_cancel(self, cr, uid, ids, context=None): return { 'type': 'state', 'state': 'end' } account_add_tmpl_wizard() @@ -1953,8 +1953,8 @@ class account_tax_code_template(osv.osv): } _defaults = { - 'sign': lambda *args: 1.0, - 'notprintable': lambda *a: False, + 'sign': lambda * args: 1.0, + 'notprintable': lambda * a: False, } def name_get(self, cr, uid, ids, context=None): @@ -1962,14 +1962,14 @@ class account_tax_code_template(osv.osv): return [] if isinstance(ids, (int, long)): ids = [ids] - reads = self.read(cr, uid, ids, ['name','code'], context, load='_classic_write') + reads = self.read(cr, uid, ids, ['name', 'code'], context, load='_classic_write') return [(x['id'], (x['code'] and x['code'] + ' - ' or '') + x['name']) \ for x in reads] def _check_recursion(self, cr, uid, ids): level = 100 while len(ids): - cr.execute('select distinct parent_id from account_tax_code_template where id =ANY(%s)',(ids,)) + cr.execute('select distinct parent_id from account_tax_code_template where id =ANY(%s)', (ids,)) ids = filter(None, map(lambda x:x[0], cr.fetchall())) if not level: return False @@ -1984,21 +1984,21 @@ account_tax_code_template() class account_chart_template(osv.osv): - _name="account.chart.template" - _description= "Templates for Account Chart" + _name = "account.chart.template" + _description = "Templates for Account Chart" - _columns={ + _columns = { 'name': fields.char('Name', size=64, required=True), - 'account_root_id': fields.many2one('account.account.template','Root Account',required=True,domain=[('parent_id','=',False)]), - 'tax_code_root_id': fields.many2one('account.tax.code.template','Root Tax Code',required=True,domain=[('parent_id','=',False)]), + 'account_root_id': fields.many2one('account.account.template', 'Root Account', required=True, domain=[('parent_id', '=', False)]), + 'tax_code_root_id': fields.many2one('account.tax.code.template', 'Root Tax Code', required=True, domain=[('parent_id', '=', False)]), 'tax_template_ids': fields.one2many('account.tax.template', 'chart_template_id', 'Tax Template List', help='List of all the taxes that have to be installed by the wizard'), - 'bank_account_view_id': fields.many2one('account.account.template','Bank Account',required=True), - 'property_account_receivable': fields.many2one('account.account.template','Receivable Account'), - 'property_account_payable': fields.many2one('account.account.template','Payable Account'), - 'property_account_expense_categ': fields.many2one('account.account.template','Expense Category Account'), - 'property_account_income_categ': fields.many2one('account.account.template','Income Category Account'), - 'property_account_expense': fields.many2one('account.account.template','Expense Account on Product Template'), - 'property_account_income': fields.many2one('account.account.template','Income Account on Product Template'), + 'bank_account_view_id': fields.many2one('account.account.template', 'Bank Account', required=True), + 'property_account_receivable': fields.many2one('account.account.template', 'Receivable Account'), + 'property_account_payable': fields.many2one('account.account.template', 'Payable Account'), + 'property_account_expense_categ': fields.many2one('account.account.template', 'Expense Category Account'), + 'property_account_income_categ': fields.many2one('account.account.template', 'Income Category Account'), + 'property_account_expense': fields.many2one('account.account.template', 'Expense Account on Product Template'), + 'property_account_income': fields.many2one('account.account.template', 'Income Account on Product Template'), } account_chart_template() @@ -2012,9 +2012,9 @@ class account_tax_template(osv.osv): 'chart_template_id': fields.many2one('account.chart.template', 'Chart Template', required=True), 'name': fields.char('Tax Name', size=64, required=True), 'sequence': fields.integer('Sequence', required=True, help="The sequence field is used to order the taxes lines from lower sequences to higher ones. The order is important if you have a tax that has several tax children. In this case, the evaluation order is important."), - 'amount': fields.float('Amount', required=True, digits=(14,4), help="For Tax Type percent enter % ratio between 0-1."), - 'type': fields.selection( [('percent','Percent'), ('fixed','Fixed'), ('none','None'), ('code','Python Code')], 'Tax Type', required=True), - 'applicable_type': fields.selection( [('true','True'), ('code','Python Code')], 'Applicable Type', required=True, help="If not applicable (computed through a Python code), the tax won't appear on the invoice."), + 'amount': fields.float('Amount', required=True, digits=(14, 4), help="For Tax Type percent enter % ratio between 0-1."), + 'type': fields.selection([('percent', 'Percent'), ('fixed', 'Fixed'), ('none', 'None'), ('code', 'Python Code')], 'Tax Type', required=True), + 'applicable_type': fields.selection([('true', 'True'), ('code', 'Python Code')], 'Applicable Type', required=True, help="If not applicable (computed through a Python code), the tax won't appear on the invoice."), 'domain':fields.char('Domain', size=32, help="This field is only used if you develop your own module allowing developers to create specific taxes in a custom domain."), 'account_collected_id':fields.many2one('account.account.template', 'Invoice Tax Account'), 'account_paid_id':fields.many2one('account.account.template', 'Refund Tax Account'), @@ -2023,7 +2023,7 @@ class account_tax_template(osv.osv): 'python_compute':fields.text('Python Code'), 'python_compute_inv':fields.text('Python Code (reverse)'), 'python_applicable':fields.text('Python Code'), - 'tax_group': fields.selection([('vat','VAT'),('other','Other')], 'Tax Group', help="If a default tax if given in the partner it only override taxes from account (or product) of the same group."), + 'tax_group': fields.selection([('vat', 'VAT'), ('other', 'Other')], 'Tax Group', help="If a default tax if given in the partner it only override taxes from account (or product) of the same group."), # # Fields used for the VAT declaration @@ -2041,16 +2041,16 @@ class account_tax_template(osv.osv): 'ref_tax_sign': fields.float('Tax Code Sign', help="Usually 1 or -1."), 'include_base_amount': fields.boolean('Include in Base Amount', help="Set if the amount of tax must be included in the base amount before computing the next taxes."), 'description': fields.char('Internal Name', size=32), - 'type_tax_use': fields.selection([('sale','Sale'),('purchase','Purchase'),('all','All')], 'Tax Use In', required=True,) + 'type_tax_use': fields.selection([('sale', 'Sale'), ('purchase', 'Purchase'), ('all', 'All')], 'Tax Use In', required=True,) } def name_get(self, cr, uid, ids, context={}): if not len(ids): return [] res = [] - for record in self.read(cr, uid, ids, ['description','name'], context): + for record in self.read(cr, uid, ids, ['description', 'name'], context): name = record['description'] and record['description'] or record['name'] - res.append((record['id'],name )) + res.append((record['id'], name)) return res def _default_company(self, cr, uid, context={}): @@ -2060,19 +2060,19 @@ class account_tax_template(osv.osv): return self.pool.get('res.company').search(cr, uid, [('parent_id', '=', False)])[0] _defaults = { - 'python_compute': lambda *a: '''# price_unit\n# address : res.partner.address object or False\n# product : product.product object or None\n# partner : res.partner object or None\n\nresult = price_unit * 0.10''', - 'python_compute_inv': lambda *a: '''# price_unit\n# address : res.partner.address object or False\n# product : product.product object or False\n\nresult = price_unit * 0.10''', - 'applicable_type': lambda *a: 'true', - 'type': lambda *a: 'percent', - 'amount': lambda *a: 0, - 'sequence': lambda *a: 1, - 'tax_group': lambda *a: 'vat', - 'ref_tax_sign': lambda *a: 1, - 'ref_base_sign': lambda *a: 1, - 'tax_sign': lambda *a: 1, - 'base_sign': lambda *a: 1, - 'include_base_amount': lambda *a: False, - 'type_tax_use': lambda *a: 'all', + 'python_compute': lambda * a: '''# price_unit\n# address : res.partner.address object or False\n# product : product.product object or None\n# partner : res.partner object or None\n\nresult = price_unit * 0.10''', + 'python_compute_inv': lambda * a: '''# price_unit\n# address : res.partner.address object or False\n# product : product.product object or False\n\nresult = price_unit * 0.10''', + 'applicable_type': lambda * a: 'true', + 'type': lambda * a: 'percent', + 'amount': lambda * a: 0, + 'sequence': lambda * a: 1, + 'tax_group': lambda * a: 'vat', + 'ref_tax_sign': lambda * a: 1, + 'ref_base_sign': lambda * a: 1, + 'tax_sign': lambda * a: 1, + 'base_sign': lambda * a: 1, + 'include_base_amount': lambda * a: False, + 'type_tax_use': lambda * a: 'all', } _order = 'sequence' @@ -2113,8 +2113,8 @@ class account_fiscal_position_account_template(osv.osv): _rec_name = 'position_id' _columns = { 'position_id': fields.many2one('account.fiscal.position.template', 'Fiscal Position', required=True, ondelete='cascade'), - 'account_src_id': fields.many2one('account.account.template', 'Account Source', domain=[('type','<>','view')], required=True), - 'account_dest_id': fields.many2one('account.account.template', 'Account Destination', domain=[('type','<>','view')], required=True) + 'account_src_id': fields.many2one('account.account.template', 'Account Source', domain=[('type', '<>', 'view')], required=True), + 'account_dest_id': fields.many2one('account.account.template', 'Account Destination', domain=[('type', '<>', 'view')], required=True) } account_fiscal_position_account_template() @@ -2134,15 +2134,15 @@ class wizard_multi_charts_accounts(osv.osv_memory): * generates all taxes and tax codes, changing account assignations * generates all accounting properties and assigns them correctly """ - _name='wizard.multi.charts.accounts' + _name = 'wizard.multi.charts.accounts' _inherit = 'res.config' _columns = { - 'company_id':fields.many2one('res.company','Company',required=True), - 'chart_template_id': fields.many2one('account.chart.template','Chart Template',required=True), - 'bank_accounts_id': fields.one2many('account.bank.accounts.wizard', 'bank_account_id', 'Bank Accounts',required=True), - 'code_digits':fields.integer('# of Digits',required=True,help="No. of Digits to use for account code"), - 'seq_journal':fields.boolean('Separated Journal Sequences',help="Check this box if you want to use a different sequence for each created journal. Otherwise, all will use the same sequence."), + 'company_id':fields.many2one('res.company', 'Company', required=True), + 'chart_template_id': fields.many2one('account.chart.template', 'Chart Template', required=True), + 'bank_accounts_id': fields.one2many('account.bank.accounts.wizard', 'bank_account_id', 'Bank Accounts', required=True), + 'code_digits':fields.integer('# of Digits', required=True, help="No. of Digits to use for account code"), + 'seq_journal':fields.boolean('Separated Journal Sequences', help="Check this box if you want to use a different sequence for each created journal. Otherwise, all will use the same sequence."), } def _get_chart(self, cr, uid, context={}): @@ -2151,13 +2151,13 @@ class wizard_multi_charts_accounts(osv.osv_memory): return ids[0] return False _defaults = { - 'company_id': lambda self, cr, uid, c: self.pool.get('res.users').browse(cr,uid,[uid],c)[0].company_id.id, + 'company_id': lambda self, cr, uid, c: self.pool.get('res.users').browse(cr, uid, [uid], c)[0].company_id.id, 'chart_template_id': _get_chart, - 'code_digits': lambda *a:6, + 'code_digits': lambda * a:6, } def execute(self, cr, uid, ids, context=None): - obj_multi = self.browse(cr,uid,ids[0]) + obj_multi = self.browse(cr, uid, ids[0]) obj_acc = self.pool.get('account.account') obj_acc_tax = self.pool.get('account.tax') obj_journal = self.pool.get('account.journal') @@ -2178,9 +2178,9 @@ class wizard_multi_charts_accounts(osv.osv_memory): todo_dict = {} #create all the tax code - children_tax_code_template = self.pool.get('account.tax.code.template').search(cr, uid, [('parent_id','child_of',[tax_code_root_id])], order='id') + children_tax_code_template = self.pool.get('account.tax.code.template').search(cr, uid, [('parent_id', 'child_of', [tax_code_root_id])], order='id') for tax_code_template in self.pool.get('account.tax.code.template').browse(cr, uid, children_tax_code_template): - vals={ + vals = { 'name': (tax_code_root_id == tax_code_template.id) and obj_multi.company_id.name or tax_code_template.name, 'code': tax_code_template.code, 'info': tax_code_template.info, @@ -2188,7 +2188,7 @@ class wizard_multi_charts_accounts(osv.osv_memory): 'company_id': company_id, 'sign': tax_code_template.sign, } - new_tax_code = self.pool.get('account.tax.code').create(cr,uid,vals) + new_tax_code = self.pool.get('account.tax.code').create(cr, uid, vals) #recording the new tax code to do the mapping tax_code_template_ref[tax_code_template.id] = new_tax_code @@ -2221,7 +2221,7 @@ class wizard_multi_charts_accounts(osv.osv_memory): 'company_id': company_id, 'type_tax_use': tax.type_tax_use } - new_tax = obj_acc_tax.create(cr,uid,vals_tax) + new_tax = obj_acc_tax.create(cr, uid, vals_tax) #as the accounts have not been created yet, we have to wait before filling these fields todo_dict[new_tax] = { 'account_collected_id': tax.account_collected_id and tax.account_collected_id.id or False, @@ -2232,7 +2232,7 @@ class wizard_multi_charts_accounts(osv.osv_memory): #deactivate the parent_store functionnality on account_account for rapidity purpose self.pool._init = True - children_acc_template = obj_acc_template.search(cr, uid, [('parent_id','child_of',[obj_acc_root.id]),('nocreate','!=',True)]) + children_acc_template = obj_acc_template.search(cr, uid, [('parent_id', 'child_of', [obj_acc_root.id]), ('nocreate', '!=', True)]) children_acc_template.sort() for account_template in obj_acc_template.browse(cr, uid, children_acc_template): tax_ids = [] @@ -2243,9 +2243,9 @@ class wizard_multi_charts_accounts(osv.osv_memory): dig = obj_multi.code_digits code_main = account_template.code and len(account_template.code) or 0 code_acc = account_template.code or '' - if code_main>0 and code_main<=dig and account_template.type != 'view': - code_acc=str(code_acc) + (str('0'*(dig-code_main))) - vals={ + if code_main > 0 and code_main <= dig and account_template.type != 'view': + code_acc = str(code_acc) + (str('0' * (dig - code_main))) + vals = { 'name': (obj_acc_root.id == account_template.id) and obj_multi.company_id.name or account_template.name, #'sign': account_template.sign, 'currency_id': account_template.currency_id and account_template.currency_id.id or False, @@ -2256,16 +2256,16 @@ class wizard_multi_charts_accounts(osv.osv_memory): 'shortcut': account_template.shortcut, 'note': account_template.note, 'parent_id': account_template.parent_id and ((account_template.parent_id.id in acc_template_ref) and acc_template_ref[account_template.parent_id.id]) or False, - 'tax_ids': [(6,0,tax_ids)], + 'tax_ids': [(6, 0, tax_ids)], 'company_id': company_id, } - new_account = obj_acc.create(cr,uid,vals) + new_account = obj_acc.create(cr, uid, vals) acc_template_ref[account_template.id] = new_account #reactivate the parent_store functionnality on account_account self.pool._init = False self.pool.get('account.account')._parent_store_compute(cr) - for key,value in todo_dict.items(): + for key, value in todo_dict.items(): if value['account_collected_id'] or value['account_paid_id']: obj_acc_tax.write(cr, uid, [key], { 'account_collected_id': acc_template_ref[value['account_collected_id']], @@ -2273,13 +2273,13 @@ class wizard_multi_charts_accounts(osv.osv_memory): }) # Creating Journals - vals_journal={} - view_id = self.pool.get('account.journal.view').search(cr,uid,[('name','=','Journal View')])[0] - seq_id = obj_sequence.search(cr,uid,[('name','=','Account Journal')])[0] + vals_journal = {} + view_id = self.pool.get('account.journal.view').search(cr, uid, [('name', '=', 'Journal View')])[0] + seq_id = obj_sequence.search(cr, uid, [('name', '=', 'Account Journal')])[0] if obj_multi.seq_journal: - seq_id_sale = obj_sequence.search(cr,uid,[('name','=','Sale Journal')])[0] - seq_id_purchase = obj_sequence.search(cr,uid,[('name','=','Purchase Journal')])[0] + seq_id_sale = obj_sequence.search(cr, uid, [('name', '=', 'Sale Journal')])[0] + seq_id_purchase = obj_sequence.search(cr, uid, [('name', '=', 'Purchase Journal')])[0] else: seq_id_sale = seq_id seq_id_purchase = seq_id @@ -2296,7 +2296,7 @@ class wizard_multi_charts_accounts(osv.osv_memory): vals_journal['default_credit_account_id'] = acc_template_ref[obj_multi.chart_template_id.property_account_income_categ.id] vals_journal['default_debit_account_id'] = acc_template_ref[obj_multi.chart_template_id.property_account_income_categ.id] - obj_journal.create(cr,uid,vals_journal) + obj_journal.create(cr, uid, vals_journal) # Purchase Journal vals_journal['name'] = _('Purchase Journal') @@ -2308,11 +2308,11 @@ class wizard_multi_charts_accounts(osv.osv_memory): vals_journal['default_credit_account_id'] = acc_template_ref[obj_multi.chart_template_id.property_account_expense_categ.id] vals_journal['default_debit_account_id'] = acc_template_ref[obj_multi.chart_template_id.property_account_expense_categ.id] - obj_journal.create(cr,uid,vals_journal) + obj_journal.create(cr, uid, vals_journal) # Bank Journals - view_id_cash = self.pool.get('account.journal.view').search(cr,uid,[('name','=','Cash Journal View')])[0] - view_id_cur = self.pool.get('account.journal.view').search(cr,uid,[('name','=','Multi-Currency Cash Journal View')])[0] + view_id_cash = self.pool.get('account.journal.view').search(cr, uid, [('name', '=', 'Cash Journal View')])[0] + view_id_cur = self.pool.get('account.journal.view').search(cr, uid, [('name', '=', 'Multi-Currency Cash Journal View')])[0] ref_acc_bank = obj_multi.chart_template_id.bank_account_view_id current_num = 1 @@ -2322,11 +2322,11 @@ class wizard_multi_charts_accounts(osv.osv_memory): dig = obj_multi.code_digits if ref_acc_bank.code: try: - new_code = str(int(ref_acc_bank.code.ljust(dig,'0')) + current_num) - except Exception,e: - new_code = str(ref_acc_bank.code.ljust(dig-len(str(current_num)),'0')) + str(current_num) + new_code = str(int(ref_acc_bank.code.ljust(dig, '0')) + current_num) + except Exception, e: + new_code = str(ref_acc_bank.code.ljust(dig - len(str(current_num)), '0')) + str(current_num) vals = { - 'name': line.acc_no.bank and line.acc_no.bank.name+' '+tmp or tmp, + 'name': line.acc_no.bank and line.acc_no.bank.name + ' ' + tmp or tmp, 'currency_id': line.currency_id and line.currency_id.id or False, 'code': new_code, 'type': 'other', @@ -2335,18 +2335,18 @@ class wizard_multi_charts_accounts(osv.osv_memory): 'parent_id': acc_template_ref[ref_acc_bank.id] or False, 'company_id': company_id, } - acc_cash_id = obj_acc.create(cr,uid,vals) + acc_cash_id = obj_acc.create(cr, uid, vals) if obj_multi.seq_journal: - vals_seq={ + vals_seq = { 'name': _('Bank Journal ') + vals['name'], 'code': 'account.journal', } - seq_id = obj_sequence.create(cr,uid,vals_seq) + seq_id = obj_sequence.create(cr, uid, vals_seq) #create the bank journal - vals_journal['name']= vals['name'] - vals_journal['code']= _('BNK') + str(current_num) + vals_journal['name'] = vals['name'] + vals_journal['code'] = _('BNK') + str(current_num) vals_journal['sequence_id'] = seq_id vals_journal['type'] = 'cash' if line.currency_id: @@ -2356,7 +2356,7 @@ class wizard_multi_charts_accounts(osv.osv_memory): vals_journal['view_id'] = view_id_cash vals_journal['default_credit_account_id'] = acc_cash_id vals_journal['default_debit_account_id'] = acc_cash_id - obj_journal.create(cr,uid,vals_journal) + obj_journal.create(cr, uid, vals_journal) current_num += 1 @@ -2365,23 +2365,23 @@ class wizard_multi_charts_accounts(osv.osv_memory): fields_obj = self.pool.get('ir.model.fields') todo_list = [ - ('property_account_receivable','res.partner','account.account'), - ('property_account_payable','res.partner','account.account'), - ('property_account_expense_categ','product.category','account.account'), - ('property_account_income_categ','product.category','account.account'), - ('property_account_expense','product.template','account.account'), - ('property_account_income','product.template','account.account') + ('property_account_receivable', 'res.partner', 'account.account'), + ('property_account_payable', 'res.partner', 'account.account'), + ('property_account_expense_categ', 'product.category', 'account.account'), + ('property_account_income_categ', 'product.category', 'account.account'), + ('property_account_expense', 'product.template', 'account.account'), + ('property_account_income', 'product.template', 'account.account') ] for record in todo_list: r = [] - r = property_obj.search(cr, uid, [('name','=', record[0] ),('company_id','=',company_id)]) + r = property_obj.search(cr, uid, [('name', '=', record[0]), ('company_id', '=', company_id)]) account = getattr(obj_multi.chart_template_id, record[0]) - field = fields_obj.search(cr, uid, [('name','=',record[0]),('model','=',record[1]),('relation','=',record[2])]) + field = fields_obj.search(cr, uid, [('name', '=', record[0]), ('model', '=', record[1]), ('relation', '=', record[2])]) vals = { 'name': record[0], 'company_id': company_id, 'fields_id': field[0], - 'value': account and 'account.account,'+str(acc_template_ref[account.id]) or False, + 'value': account and 'account.account,' + str(acc_template_ref[account.id]) or False, } if r: #the property exist: modify it @@ -2390,7 +2390,7 @@ class wizard_multi_charts_accounts(osv.osv_memory): #create the property property_obj.create(cr, uid, vals) - fp_ids = obj_fiscal_position_template.search(cr, uid,[('chart_template_id', '=', obj_multi.chart_template_id.id)]) + fp_ids = obj_fiscal_position_template.search(cr, uid, [('chart_template_id', '=', obj_multi.chart_template_id.id)]) if fp_ids: for position in obj_fiscal_position_template.browse(cr, uid, fp_ids): @@ -2422,10 +2422,10 @@ class wizard_multi_charts_accounts(osv.osv_memory): wizard_multi_charts_accounts() class account_bank_accounts_wizard(osv.osv_memory): - _name='account.bank.accounts.wizard' + _name = 'account.bank.accounts.wizard' _columns = { - 'acc_no':fields.many2one('res.partner.bank','Account No.',required=True), + 'acc_no':fields.many2one('res.partner.bank', 'Account No.', required=True), 'bank_account_id':fields.many2one('wizard.multi.charts.accounts', 'Bank Account', required=True), 'currency_id':fields.many2one('res.currency', 'Currency'), } diff --git a/addons/account/account_analytic_line.py b/addons/account/account_analytic_line.py index b41ef632477..4173376d7cb 100644 --- a/addons/account/account_analytic_line.py +++ b/addons/account/account_analytic_line.py @@ -30,12 +30,12 @@ from tools import config class account_analytic_line(osv.osv): _name = 'account.analytic.line' _description = 'Analytic lines' - + def _amount_currency(self, cr, uid, ids, field_name, arg, context={}): result = {} for rec in self.browse(cr, uid, ids, context): - cmp_cur_id=rec.company_id.currency_id.id - aa_cur_id=rec.account_id.currency_id.id + cmp_cur_id = rec.company_id.currency_id.id + aa_cur_id = rec.account_id.currency_id.id # Always provide the amount in currency if cmp_cur_id != aa_cur_id: cur_obj = self.pool.get('res.currency') @@ -46,23 +46,23 @@ class account_analytic_line(osv.osv): rec.account_id.currency_id.id, rec.amount, context=ctx) else: - result[rec.id]=rec.amount + result[rec.id] = rec.amount return result - + def _get_account_currency(self, cr, uid, ids, field_name, arg, context={}): result = {} for rec in self.browse(cr, uid, ids, context): # Always provide second currency - result[rec.id] = (rec.account_id.currency_id.id,rec.account_id.currency_id.code) + result[rec.id] = (rec.account_id.currency_id.id, rec.account_id.currency_id.code) return result - + def _get_account_line(self, cr, uid, ids, context={}): aac_ids = {} for acc in self.pool.get('account.analytic.account').browse(cr, uid, ids): aac_ids[acc.id] = True aal_ids = [] if aac_ids: - aal_ids = self.pool.get('account.analytic.line').search(cr, uid, [('account_id','in',aac_ids.keys())], context=context) + aal_ids = self.pool.get('account.analytic.line').search(cr, uid, [('account_id', 'in', aac_ids.keys())], context=context) return aal_ids _columns = { @@ -81,37 +81,37 @@ class account_analytic_line(osv.osv): 'currency_id': fields.function(_get_account_currency, method=True, type='many2one', relation='res.currency', string='Account currency', store={ 'account.analytic.account': (_get_account_line, ['company_id'], 50), - 'account.analytic.line': (lambda self,cr,uid,ids,c={}: ids, ['amount','unit_amount'],10), + 'account.analytic.line': (lambda self, cr, uid, ids, c={}: ids, ['amount', 'unit_amount'], 10), }, help="The related account currency if not equal to the company one."), - 'company_id': fields.many2one('res.company','Company',required=True), + 'company_id': fields.many2one('res.company', 'Company', required=True), 'amount_currency': fields.function(_amount_currency, method=True, digits=(16, int(config['price_accuracy'])), string='Amount currency', store={ 'account.analytic.account': (_get_account_line, ['company_id'], 50), - 'account.analytic.line': (lambda self,cr,uid,ids,c={}: ids, ['amount','unit_amount'],10), + 'account.analytic.line': (lambda self, cr, uid, ids, c={}: ids, ['amount', 'unit_amount'], 10), }, help="The amount expressed in the related account currency if not equal to the company one."), 'ref': fields.char('Ref.', size=64), } _defaults = { - 'date': lambda *a: time.strftime('%Y-%m-%d'), - 'company_id': lambda self,cr,uid,c: self.pool.get('res.company')._company_default_get(cr, uid, 'account.analytic.line', c), + 'date': lambda * a: time.strftime('%Y-%m-%d'), + 'company_id': lambda self, cr, uid, c: self.pool.get('res.company')._company_default_get(cr, uid, 'account.analytic.line', c), } _order = 'date' - + def search(self, cr, uid, args, offset=0, limit=None, order=None, context=None, count=False): if context is None: context = {} - if context.get('from_date',False): - args.append(['date', '>=',context['from_date']]) - - if context.get('to_date',False): - args.append(['date','<=',context['to_date']]) - + if context.get('from_date', False): + args.append(['date', '>=', context['from_date']]) + + if context.get('to_date', False): + args.append(['date', '<=', context['to_date']]) + return super(account_analytic_line, self).search(cr, uid, args, offset, limit, order, context=context, count=count) - + def _check_company(self, cr, uid, ids): lines = self.browse(cr, uid, ids) for l in lines: @@ -121,16 +121,16 @@ class account_analytic_line(osv.osv): _constraints = [ # (_check_company, 'You can not create analytic line that is not in the same company than the account line', ['account_id']) ] - + # Compute the cost based on the price type define into company # property_valuation_price_type property - def on_change_unit_amount(self, cr, uid, id, prod_id, unit_amount,company_id, + def on_change_unit_amount(self, cr, uid, id, prod_id, unit_amount, company_id, unit=False, context=None): - if context==None: - context={} + if context == None: + context = {} uom_obj = self.pool.get('product.uom') product_obj = self.pool.get('product.product') - company_obj=self.pool.get('res.company') + company_obj = self.pool.get('res.company') if prod_id: prod = product_obj.browse(cr, uid, prod_id) a = prod.product_tmpl_id.property_account_expense.id @@ -142,15 +142,15 @@ class account_analytic_line(osv.osv): 'for this product: "%s" (id:%d)') % \ (prod.name, prod.id,)) if not company_id: - company_id=company_obj._company_default_get(cr, uid, 'account.analytic.line', context) - - # Compute based on pricetype - pricetype=self.pool.get('product.price.type').browse(cr,uid,company_obj.browse(cr,uid,company_id).property_valuation_price_type.id) - amount_unit=prod.price_get(pricetype.field, context)[prod.id] + company_id = company_obj._company_default_get(cr, uid, 'account.analytic.line', context) - amount=amount_unit*unit_amount or 1.0 + # Compute based on pricetype + pricetype = self.pool.get('product.price.type').browse(cr, uid, company_obj.browse(cr, uid, company_id).property_valuation_price_type.id) + amount_unit = prod.price_get(pricetype.field, context)[prod.id] + + amount = amount_unit * unit_amount or 1.0 return {'value': { - 'amount': - round(amount, 2), + 'amount':-round(amount, 2), 'general_account_id': a, }} return {} @@ -161,7 +161,7 @@ class account_analytic_line(osv.osv): cr.execute('select name from account_analytic_account where id=%s', (context['account_id'],)) res = cr.fetchone() if res: - res = _('Entries: ')+ (res[0] or '') + res = _('Entries: ') + (res[0] or '') return res return False @@ -173,14 +173,14 @@ class timesheet_invoice(osv.osv): _description = "Analytic account costs and revenues" _auto = False _columns = { - 'name': fields.char('Year',size=64,required=False, readonly=True), + 'name': fields.char('Year', size=64, required=False, readonly=True), 'account_id':fields.many2one('account.analytic.account', 'Analytic Account', readonly=True, select=True), 'journal_id': fields.many2one('account.analytic.journal', 'Journal', readonly=True), 'quantity': fields.float('Quantities', readonly=True), 'cost': fields.float('Credit', readonly=True), 'revenue': fields.float('Debit', readonly=True), - 'month':fields.selection([('01','January'), ('02','February'), ('03','March'), ('04','April'), ('05','May'), ('06','June'), - ('07','July'), ('08','August'), ('09','September'), ('10','October'), ('11','November'), ('12','December')],'Month',readonly=True), + 'month':fields.selection([('01', 'January'), ('02', 'February'), ('03', 'March'), ('04', 'April'), ('05', 'May'), ('06', 'June'), + ('07', 'July'), ('08', 'August'), ('09', 'September'), ('10', 'October'), ('11', 'November'), ('12', 'December')], 'Month', readonly=True), } _order = 'name desc, account_id' def init(self, cr): diff --git a/addons/account/account_bank_statement.py b/addons/account/account_bank_statement.py index 01c1eb7fa37..fe596c4bee9 100644 --- a/addons/account/account_bank_statement.py +++ b/addons/account/account_bank_statement.py @@ -114,17 +114,17 @@ class account_bank_statement(osv.osv): states={'confirm': [('readonly', True)]}, domain=[('type', '=', 'cash')]), 'period_id': fields.many2one('account.period', 'Period', required=True, states={'confirm':[('readonly', True)]}), - 'balance_start': fields.float('Starting Balance', digits=(16,2), - states={'confirm':[('readonly',True)]}), - 'balance_end_real': fields.float('Ending Balance', digits=(16,2), + 'balance_start': fields.float('Starting Balance', digits=(16, 2), + states={'confirm':[('readonly', True)]}), + 'balance_end_real': fields.float('Ending Balance', digits=(16, 2), states={'confirm':[('readonly', True)]}), 'balance_end': fields.function(_end_balance, method=True, string='Balance'), 'line_ids': fields.one2many('account.bank.statement.line', 'statement_id', 'Statement lines', states={'confirm':[('readonly', True)]}), 'move_line_ids': fields.one2many('account.move.line', 'statement_id', - 'Entry lines', states={'confirm':[('readonly',True)]}), - 'state': fields.selection([('draft', 'Draft'),('confirm', 'Confirmed')], + 'Entry lines', states={'confirm':[('readonly', True)]}), + 'state': fields.selection([('draft', 'Draft'), ('confirm', 'Confirmed')], 'State', required=True, states={'confirm': [('readonly', True)]}, readonly="1", help='When new statement is created the state will be \'Draft\'. \ @@ -134,10 +134,10 @@ class account_bank_statement(osv.osv): } _defaults = { - 'name': lambda self, cr, uid, context=None: \ + 'name': lambda self, cr, uid, context = None: \ self.pool.get('ir.sequence').get(cr, uid, 'account.bank.statement'), - 'date': lambda *a: time.strftime('%Y-%m-%d'), - 'state': lambda *a: 'draft', + 'date': lambda * a: time.strftime('%Y-%m-%d'), + 'state': lambda * a: 'draft', 'balance_start': _default_balance_start, 'journal_id': _default_journal_id, 'period_id': _get_period, @@ -156,7 +156,7 @@ class account_bank_statement(osv.osv): context=context).company_id.currency_id.id for st in self.browse(cr, uid, ids, context): - if not st.state=='draft': + if not st.state == 'draft': continue if not (abs((st.balance_end or 0.0) - st.balance_end_real) < 0.0001): @@ -183,7 +183,7 @@ class account_bank_statement(osv.osv): 'date': move.date, }, context=context) account_bank_statement_line_obj.write(cr, uid, [move.id], { - 'move_ids': [(4,move_id, False)] + 'move_ids': [(4, move_id, False)] }) if not move.amount: continue @@ -193,7 +193,7 @@ class account_bank_statement(osv.osv): account_id = st.journal_id.default_credit_account_id.id else: account_id = st.journal_id.default_debit_account_id.id - acc_cur = ((move.amount<=0) and st.journal_id.default_debit_account_id) or move.account_id + acc_cur = ((move.amount <= 0) and st.journal_id.default_debit_account_id) or move.account_id amount = res_currency_obj.compute(cr, uid, st.currency.id, company_currency_id, move.amount, context=context, account=acc_cur) @@ -208,8 +208,8 @@ class account_bank_statement(osv.osv): 'move_id': move_id, 'partner_id': ((move.partner_id) and move.partner_id.id) or False, 'account_id': (move.account_id) and move.account_id.id, - 'credit': ((amount>0) and amount) or 0.0, - 'debit': ((amount<0) and -amount) or 0.0, + 'credit': ((amount > 0) and amount) or 0.0, + 'debit': ((amount < 0) and - amount) or 0.0, 'statement_id': st.id, 'journal_id': st.journal_id.id, 'period_id': st.period_id.id, @@ -227,7 +227,7 @@ class account_bank_statement(osv.osv): if move.account_id and move.account_id.currency_id and move.account_id.currency_id.id <> company_currency_id: val['currency_id'] = move.account_id.currency_id.id - if company_currency_id==move.account_id.currency_id.id: + if company_currency_id == move.account_id.currency_id.id: amount_cur = move.amount else: amount_cur = res_currency_obj.compute(cr, uid, company_currency_id, @@ -246,8 +246,8 @@ class account_bank_statement(osv.osv): 'move_id': move_id, 'partner_id': ((move.partner_id) and move.partner_id.id) or False, 'account_id': (newline.account_id) and newline.account_id.id, - 'debit': newline.amount>0 and newline.amount or 0.0, - 'credit': newline.amount<0 and -newline.amount or 0.0, + 'debit': newline.amount > 0 and newline.amount or 0.0, + 'credit': newline.amount < 0 and - newline.amount or 0.0, 'statement_id': st.id, 'journal_id': st.journal_id.id, 'period_id': st.period_id.id, @@ -269,7 +269,7 @@ class account_bank_statement(osv.osv): 'move_id': move_id, 'partner_id': ((move.partner_id) and move.partner_id.id) or False, 'account_id': account_id, - 'credit': ((amount < 0) and -amount) or 0.0, + 'credit': ((amount < 0) and - amount) or 0.0, 'debit': ((amount > 0) and amount) or 0.0, 'statement_id': st.id, 'journal_id': st.journal_id.id, @@ -289,7 +289,7 @@ class account_bank_statement(osv.osv): if move.reconcile_id and move.reconcile_id.line_ids: torec += map(lambda x: x.id, move.reconcile_id.line_ids) #try: - if abs(move.reconcile_amount-move.amount)<0.0001: + if abs(move.reconcile_amount - move.amount) < 0.0001: writeoff_acc_id = False #There should only be one write-off account! @@ -312,7 +312,7 @@ class account_bank_statement(osv.osv): def button_cancel(self, cr, uid, ids, context={}): done = [] for st in self.browse(cr, uid, ids, context): - if st.state=='draft': + if st.state == 'draft': continue ids = [] for line in st.line_ids: @@ -356,7 +356,7 @@ class account_bank_statement(osv.osv): raise osv.except_osv(_('Invalid action !'), _('Cannot delete bank statement which are already confirmed !')) osv.osv.unlink(self, cr, uid, unlink_ids, context=context) return True - + account_bank_statement() @@ -396,10 +396,10 @@ class account_bank_statement_reconcile(osv.osv): currency_id = context.get('currency_id', company_currency_id) acc_cur = None - if context.get('journal_id', False) and context.get('account_id',False): - st =self.pool.get('account.journal').browse(cursor, user, context['journal_id']) + if context.get('journal_id', False) and context.get('account_id', False): + st = self.pool.get('account.journal').browse(cursor, user, context['journal_id']) acc = self.pool.get('account.account').browse(cursor, user, context['account_id']) - acc_cur = (( context.get('amount',0.0)<=0) and st.default_debit_account_id) or acc + acc_cur = ((context.get('amount', 0.0) <= 0) and st.default_debit_account_id) or acc for reconcile_id in ids: res[reconcile_id] = res_currency_obj.compute(cursor, user, @@ -418,10 +418,10 @@ class account_bank_statement_reconcile(osv.osv): currency_id = context.get('currency_id', company_currency_id) acc_cur = None - if context.get('journal_id', False) and context.get('account_id',False): - st =self.pool.get('account.journal').browse(cursor, user, context['journal_id']) + if context.get('journal_id', False) and context.get('account_id', False): + st = self.pool.get('account.journal').browse(cursor, user, context['journal_id']) acc = self.pool.get('account.account').browse(cursor, user, context['account_id']) - acc_cur = (( context.get('amount',0.0)<=0) and st.default_debit_account_id) or acc + acc_cur = ((context.get('amount', 0.0) <= 0) and st.default_debit_account_id) or acc return res_currency_obj.compute(cursor, user, currency_id, company_currency_id, @@ -459,7 +459,7 @@ class account_bank_statement_reconcile(osv.osv): return res def name_get(self, cursor, user, ids, context=None): - res= [] + res = [] for o in self.browse(cursor, user, ids, context=context): result = 0.0 res_currency = '' @@ -471,7 +471,7 @@ class account_bank_statement_reconcile(osv.osv): result += line.debit - line.credit if res_currency: res_currency = ' ' + res_currency - res.append((o.id, '[%.2f'% (result - o.total_new,) + res_currency + ']' )) + res.append((o.id, '[%.2f' % (result - o.total_new,) + res_currency + ']')) return res _columns = { @@ -500,14 +500,14 @@ class account_bank_statement_reconcile(osv.osv): 'reconcile_id', 'Bank Statement Line'), } _defaults = { - 'name': lambda *a: time.strftime('%Y-%m-%d'), - 'partner_id': lambda obj, cursor, user, context=None: \ + 'name': lambda * a: time.strftime('%Y-%m-%d'), + 'partner_id': lambda obj, cursor, user, context = None: \ context.get('partner', False), 'total_amount': _default_amount, 'total_currency': _default_currency, - 'total_second_amount': lambda obj, cursor, user, context=None: \ + 'total_second_amount': lambda obj, cursor, user, context = None: \ context.get('amount', 0.0), - 'total_second_currency': lambda obj, cursor, user, context=None: \ + 'total_second_currency': lambda obj, cursor, user, context = None: \ context.get('currency_id', False), 'total_balance': _default_amount, } @@ -521,10 +521,10 @@ class account_bank_statement_reconcile_line(osv.osv): 'account_id': fields.many2one('account.account', 'Account', required=True), 'line_id': fields.many2one('account.bank.statement.reconcile', 'Reconcile'), 'amount': fields.float('Amount', required=True), - 'analytic_id': fields.many2one('account.analytic.account',"Analytic Account") + 'analytic_id': fields.many2one('account.analytic.account', "Analytic Account") } _defaults = { - 'name': lambda *a: 'Write-Off', + 'name': lambda * a: 'Write-Off', } account_bank_statement_reconcile_line() @@ -549,7 +549,7 @@ class account_bank_statement_line(osv.osv): if type == 'supplier': account_id = part.property_account_payable.id else: - account_id = part.property_account_receivable.id + account_id = part.property_account_receivable.id cursor.execute('SELECT sum(debit-credit) \ FROM account_move_line \ @@ -590,19 +590,19 @@ class account_bank_statement_line(osv.osv): 'date': fields.date('Date', required=True), 'amount': fields.float('Amount'), 'type': fields.selection([ - ('supplier','Supplier'), - ('customer','Customer'), - ('general','General') + ('supplier', 'Supplier'), + ('customer', 'Customer'), + ('general', 'General') ], 'Type', required=True), 'partner_id': fields.many2one('res.partner', 'Partner'), - 'account_id': fields.many2one('account.account','Account', + 'account_id': fields.many2one('account.account', 'Account', required=True), 'statement_id': fields.many2one('account.bank.statement', 'Statement', select=True, required=True, ondelete='cascade'), 'reconcile_id': fields.many2one('account.bank.statement.reconcile', - 'Reconcile', states={'confirm':[('readonly',True)]}), + 'Reconcile', states={'confirm':[('readonly', True)]}), 'move_ids': fields.many2many('account.move', - 'account_bank_statement_line_move_rel', 'move_id','statement_id', + 'account_bank_statement_line_move_rel', 'move_id', 'statement_id', 'Moves'), 'ref': fields.char('Reference', size=32), 'note': fields.text('Notes'), @@ -611,10 +611,10 @@ class account_bank_statement_line(osv.osv): 'sequence': fields.integer('Sequence', help="Gives the sequence order when displaying a list of bank statement line."), } _defaults = { - 'name': lambda self,cr,uid,context={}: self.pool.get('ir.sequence').get(cr, uid, 'account.bank.statement.line'), - 'date': lambda *a: time.strftime('%Y-%m-%d'), - 'type': lambda *a: 'general', - 'sequence': lambda *a: 10, + 'name': lambda self, cr, uid, context = {}: self.pool.get('ir.sequence').get(cr, uid, 'account.bank.statement.line'), + 'date': lambda * a: time.strftime('%Y-%m-%d'), + 'type': lambda * a: 'general', + 'sequence': lambda * a: 10, } account_bank_statement_line() diff --git a/addons/account/account_move_line.py b/addons/account/account_move_line.py index 8355cf6be3c..3fd1babd69f 100644 --- a/addons/account/account_move_line.py +++ b/addons/account/account_move_line.py @@ -40,23 +40,23 @@ class account_move_line(osv.osv): fiscalyear_clause = (','.join([str(x) for x in fiscalyear_ids])) or '0' else: fiscalyear_clause = '%s' % context['fiscalyear'] - state=context.get('state',False) + state = context.get('state', False) where_move_state = '' where_move_lines_by_date = '' if context.get('date_from', False) and context.get('date_to', False): - where_move_lines_by_date = " AND " +obj+".move_id in ( select id from account_move where date >= '" +context['date_from']+"' AND date <= '"+context['date_to']+"')" + where_move_lines_by_date = " AND " + obj + ".move_id in ( select id from account_move where date >= '" + context['date_from'] + "' AND date <= '" + context['date_to'] + "')" if state: if state.lower() not in ['all']: - where_move_state= " AND "+obj+".move_id in (select id from account_move where account_move.state = '"+state+"')" + where_move_state = " AND " + obj + ".move_id in (select id from account_move where account_move.state = '" + state + "')" if context.get('periods', False): ids = ','.join([str(x) for x in context['periods']]) - return obj+".state<>'draft' AND "+obj+".period_id in (SELECT id from account_period WHERE fiscalyear_id in (%s) AND id in (%s)) %s %s" % (fiscalyear_clause, ids,where_move_state,where_move_lines_by_date) + return obj + ".state<>'draft' AND " + obj + ".period_id in (SELECT id from account_period WHERE fiscalyear_id in (%s) AND id in (%s)) %s %s" % (fiscalyear_clause, ids, where_move_state, where_move_lines_by_date) else: - return obj+".state<>'draft' AND "+obj+".period_id in (SELECT id from account_period WHERE fiscalyear_id in (%s) %s %s)" % (fiscalyear_clause,where_move_state,where_move_lines_by_date) + return obj + ".state<>'draft' AND " + obj + ".period_id in (SELECT id from account_period WHERE fiscalyear_id in (%s) %s %s)" % (fiscalyear_clause, where_move_state, where_move_lines_by_date) def default_get(self, cr, uid, fields, context={}): data = self._default_get(cr, uid, fields, context) @@ -69,9 +69,9 @@ class account_move_line(osv.osv): for obj_line in self.browse(cr, uid, ids, context): if obj_line.analytic_account_id: if not obj_line.journal_id.analytic_journal_id: - raise osv.except_osv(_('No Analytic Journal !'),_("You have to define an analytic journal on the '%s' journal!") % (obj_line.journal_id.name,)) + raise osv.except_osv(_('No Analytic Journal !'), _("You have to define an analytic journal on the '%s' journal!") % (obj_line.journal_id.name,)) amt = (obj_line.credit or 0.0) - (obj_line.debit or 0.0) - vals_lines={ + vals_lines = { 'name': obj_line.name, 'date': obj_line.date, 'account_id': obj_line.analytic_account_id.id, @@ -84,7 +84,7 @@ class account_move_line(osv.osv): 'ref': obj_line.ref, 'move_id':obj_line.id } - new_id = self.pool.get('account.analytic.line').create(cr,uid,vals_lines) + new_id = self.pool.get('account.analytic.line').create(cr, uid, vals_lines) return True def _default_get_move_form_hook(self, cursor, user, data): @@ -99,23 +99,23 @@ class account_move_line(osv.osv): # Compute simple values data = super(account_move_line, self).default_get(cr, uid, fields, context) # Starts: Manual entry from account.move form - if context.get('lines',[]): + if context.get('lines', []): - total_new=0.00 + total_new = 0.00 for i in context['lines']: if i[2]: - total_new +=(i[2]['debit'] or 0.00)- (i[2]['credit'] or 0.00) + total_new += (i[2]['debit'] or 0.00) - (i[2]['credit'] or 0.00) for item in i[2]: - data[item]=i[2][item] + data[item] = i[2][item] if context['journal']: - journal_obj=self.pool.get('account.journal').browse(cr,uid,context['journal']) + journal_obj = self.pool.get('account.journal').browse(cr, uid, context['journal']) if journal_obj.type == 'purchase': - if total_new>0: + if total_new > 0: account = journal_obj.default_credit_account_id else: account = journal_obj.default_debit_account_id else: - if total_new>0: + if total_new > 0: account = journal_obj.default_credit_account_id else: account = journal_obj.default_debit_account_id @@ -125,11 +125,11 @@ class account_move_line(osv.osv): part = self.pool.get('res.partner').browse(cr, uid, data['partner_id']) account = self.pool.get('account.fiscal.position').map_account(cr, uid, part and part.property_account_position or False, account.id) account = self.pool.get('account.account').browse(cr, uid, account) - data['account_id'] = account.id + data['account_id'] = account.id s = -total_new - data['debit'] = s>0 and s or 0.0 - data['credit'] = s<0 and -s or 0.0 + data['debit'] = s > 0 and s or 0.0 + data['credit'] = s < 0 and - s or 0.0 data = self._default_get_move_form_hook(cr, uid, data) return data # Ends: Manual entry from account.move form @@ -142,7 +142,7 @@ class account_move_line(osv.osv): # Compute the current move move_id = False partner_id = False - if context.get('journal_id',False) and context.get('period_id',False): + if context.get('journal_id', False) and context.get('period_id', False): if 'move_id' in fields: cr.execute('select move_id \ from \ @@ -195,12 +195,12 @@ class account_move_line(osv.osv): data['partner_id'] = partner_id if move.journal_id.type == 'purchase': - if total>0: + if total > 0: account = move.journal_id.default_credit_account_id else: account = move.journal_id.default_debit_account_id else: - if total>0: + if total > 0: account = move.journal_id.default_credit_account_id else: account = move.journal_id.default_debit_account_id @@ -221,13 +221,13 @@ class account_move_line(osv.osv): total -= t['amount'] s = -total - data['debit'] = s>0 and s or 0.0 - data['credit'] = s<0 and -s or 0.0 + data['debit'] = s > 0 and s or 0.0 + data['credit'] = s < 0 and - s or 0.0 if account and account.currency_id: data['currency_id'] = account.currency_id.id acc = account - if s>0: + if s > 0: acc = acc1 v = self.pool.get('res.currency').compute(cr, uid, account.company_id.currency_id.id, @@ -241,12 +241,12 @@ class account_move_line(osv.osv): return map(lambda x: x.id, ml.move_id.line_id) def _balance(self, cr, uid, ids, prop, unknow_none, unknow_dict): - res={} + res = {} # TODO group the foreach in sql for id in ids: cr.execute('SELECT date,account_id FROM account_move_line WHERE id=%s', (id,)) dt, acc = cr.fetchone() - cr.execute('SELECT SUM(debit-credit) FROM account_move_line WHERE account_id=%s AND (date<%s OR (date=%s AND id<=%s))', (acc,dt,dt,id)) + cr.execute('SELECT SUM(debit-credit) FROM account_move_line WHERE account_id=%s AND (date<%s OR (date=%s AND id<=%s))', (acc, dt, dt, id)) res[id] = cr.fetchone()[0] return res @@ -258,7 +258,7 @@ class account_move_line(osv.osv): cursor.execute('SELECT l.id, i.id ' \ 'FROM account_move_line l, account_invoice i ' \ 'WHERE l.move_id = i.move_id ' \ - 'AND l.id =ANY(%s)',(ids,)) + 'AND l.id =ANY(%s)', (ids,)) invoice_ids = [] for line_id, invoice_id in cursor.fetchall(): res[line_id] = invoice_id @@ -278,7 +278,7 @@ class account_move_line(osv.osv): result = [] for line in self.browse(cr, uid, ids, context): if line.ref: - result.append((line.id, (line.name or '')+' ('+line.ref+')')) + result.append((line.id, (line.name or '') + ' (' + line.ref + ')')) else: result.append((line.id, line.name)) return result @@ -289,9 +289,9 @@ class account_move_line(osv.osv): if not len(args): return [] - where = ' and '.join(map(lambda x: '(abs(sum(debit-credit))'+x[1]+str(x[2])+')',args)) + where = ' and '.join(map(lambda x: '(abs(sum(debit-credit))' + x[1] + str(x[2]) + ')', args)) cursor.execute('select id, sum(debit-credit) from account_move_line \ - group by id,debit,credit having '+where) + group by id,debit,credit having ' + where) res = cursor.fetchall() if not len(res): return [('id', '=', '0')] @@ -352,19 +352,19 @@ class account_move_line(osv.osv): _columns = { 'name': fields.char('Name', size=64, required=True), - 'quantity': fields.float('Quantity', digits=(16,2), help="The optional quantity expressed by this line, eg: number of product sold. The quantity is not a legal requirement but is very useful for some reports."), + 'quantity': fields.float('Quantity', digits=(16, 2), help="The optional quantity expressed by this line, eg: number of product sold. The quantity is not a legal requirement but is very useful for some reports."), 'product_uom_id': fields.many2one('product.uom', 'UoM'), 'product_id': fields.many2one('product.product', 'Product'), - 'debit': fields.float('Debit', digits=(16,int(tools.config['price_accuracy']))), - 'credit': fields.float('Credit', digits=(16,int(tools.config['price_accuracy']))), - 'account_id': fields.many2one('account.account', 'Account', required=True, ondelete="cascade", domain=[('type','<>','view'), ('type', '<>', 'closed')], select=2), - 'move_id': fields.many2one('account.move', 'Move', ondelete="cascade", states={'valid':[('readonly',True)]}, help="The move of this entry line.", select=2), + 'debit': fields.float('Debit', digits=(16, int(tools.config['price_accuracy']))), + 'credit': fields.float('Credit', digits=(16, int(tools.config['price_accuracy']))), + 'account_id': fields.many2one('account.account', 'Account', required=True, ondelete="cascade", domain=[('type', '<>', 'view'), ('type', '<>', 'closed')], select=2), + 'move_id': fields.many2one('account.move', 'Move', ondelete="cascade", states={'valid':[('readonly', True)]}, help="The move of this entry line.", select=2), 'ref': fields.char('Ref.', size=64), 'statement_id': fields.many2one('account.bank.statement', 'Statement', help="The bank statement used for bank reconciliation", select=1), 'reconcile_id': fields.many2one('account.move.reconcile', 'Reconcile', readonly=True, ondelete='set null', select=2), 'reconcile_partial_id': fields.many2one('account.move.reconcile', 'Partial Reconcile', readonly=True, ondelete='set null', select=2), - 'amount_currency': fields.float('Amount Currency', help="The amount expressed in an optional other currency if it is a multi-currency entry.", digits=(16,int(tools.config['price_accuracy']))), + 'amount_currency': fields.float('Amount Currency', help="The amount expressed in an optional other currency if it is a multi-currency entry.", digits=(16, int(tools.config['price_accuracy']))), 'currency_id': fields.many2one('res.currency', 'Currency', help="The optional other currency if it is a multi-currency entry."), 'period_id': fields.many2one('account.period', 'Period', required=True, select=2), @@ -373,26 +373,26 @@ class account_move_line(osv.osv): 'partner_id': fields.many2one('res.partner', 'Partner'), 'date_maturity': fields.date('Maturity date', help="This field is used for payable and receivable entries. You can put the limit date for the payment of this entry line."), - 'date': fields.related('move_id','date', string='Effective date', type='date', required=True, + 'date': fields.related('move_id', 'date', string='Effective date', type='date', required=True, store={ 'account.move': (_get_move_lines, ['date'], 20) }), 'date_created': fields.date('Creation date'), 'analytic_lines': fields.one2many('account.analytic.line', 'move_id', 'Analytic lines'), - 'centralisation': fields.selection([('normal','Normal'),('credit','Credit Centralisation'),('debit','Debit Centralisation')], 'Centralisation', size=6), + 'centralisation': fields.selection([('normal', 'Normal'), ('credit', 'Credit Centralisation'), ('debit', 'Debit Centralisation')], 'Centralisation', size=6), 'balance': fields.function(_balance, fnct_search=_balance_search, method=True, string='Balance'), - 'state': fields.selection([('draft','Draft'), ('valid','Valid')], 'State', readonly=True, + 'state': fields.selection([('draft', 'Draft'), ('valid', 'Valid')], 'State', readonly=True, help='When new move line is created the state will be \'Draft\'.\n* When all the payments are done it will be in \'Valid\' state.'), 'tax_code_id': fields.many2one('account.tax.code', 'Tax Account', help="The Account can either be a base tax code or a tax code account."), - 'tax_amount': fields.float('Tax/Base Amount', digits=(16,int(tools.config['price_accuracy'])), select=True, help="If the Tax account is a tax code account, this field will contain the taxed amount.If the tax account is base tax code, "\ + 'tax_amount': fields.float('Tax/Base Amount', digits=(16, int(tools.config['price_accuracy'])), select=True, help="If the Tax account is a tax code account, this field will contain the taxed amount.If the tax account is base tax code, "\ "this field will contain the basic amount(without tax)."), 'invoice': fields.function(_invoice, method=True, string='Invoice', type='many2one', relation='account.invoice', fnct_search=_invoice_search), 'account_tax_id':fields.many2one('account.tax', 'Tax'), 'analytic_account_id' : fields.many2one('account.analytic.account', 'Analytic Account'), #TODO: remove this - 'amount_taxed':fields.float("Taxed Amount",digits=(16,int(tools.config['price_accuracy']))), - 'company_id': fields.related('account_id','company_id',type='many2one',relation='res.company',string='Company',store=True) + 'amount_taxed':fields.float("Taxed Amount", digits=(16, int(tools.config['price_accuracy']))), + 'company_id': fields.related('account_id', 'company_id', type='many2one', relation='res.company', string='Company', store=True) } @@ -419,19 +419,19 @@ class account_move_line(osv.osv): return cur and cur.id or False _defaults = { - 'blocked': lambda *a: False, - 'centralisation': lambda *a: 'normal', + 'blocked': lambda * a: False, + 'centralisation': lambda * a: 'normal', 'date': _get_date, - 'date_created': lambda *a: time.strftime('%Y-%m-%d'), - 'state': lambda *a: 'draft', + 'date_created': lambda * a: time.strftime('%Y-%m-%d'), + 'state': lambda * a: 'draft', 'currency_id': _get_currency, 'journal_id': lambda self, cr, uid, c: c.get('journal_id', False), 'period_id': lambda self, cr, uid, c: c.get('period_id', False), - 'company_id': lambda self,cr,uid,c: self.pool.get('res.company')._company_default_get(cr, uid, 'account.move.line', context=c) + 'company_id': lambda self, cr, uid, c: self.pool.get('res.company')._company_default_get(cr, uid, 'account.move.line', context=c) } _order = "date desc,id desc" _sql_constraints = [ - ('credit_debit1', 'CHECK (credit*debit=0)', 'Wrong credit or debit value in accounting entry !'), + ('credit_debit1', 'CHECK (credit*debit=0)', 'Wrong credit or debit value in accounting entry !'), ('credit_debit2', 'CHECK (credit+debit>=0)', 'Wrong credit or debit value in accounting entry !'), ] @@ -467,14 +467,14 @@ class account_move_line(osv.osv): if (not currency_id) or (not account_id): return {} result = {} - acc =self.pool.get('account.account').browse(cr, uid, account_id) - if (amount>0) and journal: + acc = self.pool.get('account.account').browse(cr, uid, account_id) + if (amount > 0) and journal: x = self.pool.get('account.journal').browse(cr, uid, journal).default_credit_account_id if x: acc = x - v = self.pool.get('res.currency').compute(cr, uid, currency_id,acc.company_id.currency_id.id, amount, account=acc) + v = self.pool.get('res.currency').compute(cr, uid, currency_id, acc.company_id.currency_id.id, amount, account=acc) result['value'] = { - 'debit': v>0 and v or 0.0, - 'credit': v<0 and -v or 0.0 + 'debit': v > 0 and v or 0.0, + 'credit': v < 0 and - v or 0.0 } return result @@ -495,13 +495,13 @@ class account_move_line(osv.osv): val['date_maturity'] = res[0][0] if not account_id: id1 = part.property_account_payable.id - id2 = part.property_account_receivable.id + id2 = part.property_account_receivable.id if journal: jt = self.pool.get('account.journal').browse(cr, uid, journal).type - if jt=='sale': + if jt == 'sale': val['account_id'] = self.pool.get('account.fiscal.position').map_account(cr, uid, part and part.property_account_position or False, id2) - elif jt=='purchase': + elif jt == 'purchase': val['account_id'] = self.pool.get('account.fiscal.position').map_account(cr, uid, part and part.property_account_position or False, id1) if val.get('account_id', False): d = self.onchange_account_id(cr, uid, ids, val['account_id']) @@ -546,11 +546,11 @@ class account_move_line(osv.osv): unmerge.append(line.id) total += (line.debit or 0.0) - (line.credit or 0.0) if not total: - res = self.reconcile(cr, uid, merges+unmerge, context=context) + res = self.reconcile(cr, uid, merges + unmerge, context=context) return res r_id = self.pool.get('account.move.reconcile').create(cr, uid, { 'type': type, - 'line_partial_ids': map(lambda x: (4,x,False), merges+unmerge) + 'line_partial_ids': map(lambda x: (4, x, False), merges + unmerge) }) self.pool.get('account.move.reconcile').reconcile_partial_check(cr, uid, [r_id] + merges_rec, context=context) return True @@ -574,14 +574,14 @@ class account_move_line(osv.osv): writeoff = debit - credit # Ifdate_p in context => take this date if context.has_key('date_p') and context['date_p']: - date=context['date_p'] + date = context['date_p'] else: date = time.strftime('%Y-%m-%d') cr.execute('SELECT account_id, reconcile_id \ FROM account_move_line \ WHERE id =ANY(%s) \ - GROUP BY account_id,reconcile_id',(ids,)) + GROUP BY account_id,reconcile_id', (ids,)) r = cr.fetchall() #TODO: move this check to a constraint in the account_move_reconcile object if (len(r) != 1) and not context.get('fy_closing', False): @@ -611,9 +611,9 @@ class account_move_line(osv.osv): # If comment exist in context, take it if 'comment' in context and context['comment']: - libelle=context['comment'] + libelle = context['comment'] else: - libelle='Write-Off' + libelle = 'Write-Off' writeoff_lines = [ (0, 0, { @@ -624,7 +624,7 @@ class account_move_line(osv.osv): 'date':date, 'partner_id':partner_id, 'currency_id': account.currency_id.id or False, - 'amount_currency': account.currency_id.id and -currency or 0.0 + 'amount_currency': account.currency_id.id and - currency or 0.0 }), (0, 0, { 'name':libelle, @@ -651,8 +651,8 @@ class account_move_line(osv.osv): r_id = self.pool.get('account.move.reconcile').create(cr, uid, { #'name': date, 'type': type, - 'line_id': map(lambda x: (4,x,False), ids), - 'line_partial_ids': map(lambda x: (3,x,False), ids) + 'line_id': map(lambda x: (4, x, False), ids), + 'line_partial_ids': map(lambda x: (3, x, False), ids) }) wf_service = netsvc.LocalService("workflow") # the id of the move.reconcile is written in the move.line (self) by the create method above @@ -665,7 +665,7 @@ class account_move_line(osv.osv): if context.get('account_id', False): cr.execute('select code from account_account where id=%s', (context['account_id'],)) res = cr.fetchone() - res = _('Entries: ')+ (res[0] or '') + res = _('Entries: ') + (res[0] or '') return res if (not context.get('journal_id', False)) or (not context.get('period_id', False)): return False @@ -674,12 +674,12 @@ class account_move_line(osv.osv): cr.execute('select code from account_period where id=%s', (context['period_id'],)) p = cr.fetchone()[0] or '' if j or p: - return j+(p and (':'+p) or '') + return j + (p and (':' + p) or '') return False def fields_view_get(self, cr, uid, view_id=None, view_type='form', context={}, toolbar=False, submenu=False): - result = super(osv.osv, self).fields_view_get(cr, uid, view_id,view_type,context,toolbar=toolbar, submenu=submenu) - if view_type=='tree' and 'journal_id' in context: + result = super(osv.osv, self).fields_view_get(cr, uid, view_id, view_type, context, toolbar=toolbar, submenu=submenu) + if view_type == 'tree' and 'journal_id' in context: title = self.view_header_get(cr, uid, view_id, view_type, context) journal = self.pool.get('account.journal').browse(cr, uid, context['journal_id']) @@ -687,7 +687,7 @@ class account_move_line(osv.osv): # its value state = '' for field in journal.view_id.columns_id: - if field.field=='state': + if field.field == 'state': state = ' colors="red:state==\'draft\'"' #xml = '''\n\n\t''' % (title, state) @@ -704,14 +704,14 @@ class account_move_line(osv.osv): for field in journal.view_id.columns_id: fields.append(field.field) attrs = [] - if field.field=='debit': + if field.field == 'debit': attrs.append('sum="Total debit"') - elif field.field=='credit': + elif field.field == 'credit': attrs.append('sum="Total credit"') - elif field.field=='account_tax_id': + elif field.field == 'account_tax_id': attrs.append('domain="[(\'parent_id\',\'=\',False)]"') - elif field.field=='account_id' and journal.id: - attrs.append('domain="[(\'journal_id\', \'=\', '+str(journal.id)+'),(\'type\',\'<>\',\'view\'), (\'type\',\'<>\',\'closed\')]" on_change="onchange_account_id(account_id, partner_id)"') + elif field.field == 'account_id' and journal.id: + attrs.append('domain="[(\'journal_id\', \'=\', ' + str(journal.id) + '),(\'type\',\'<>\',\'view\'), (\'type\',\'<>\',\'closed\')]" on_change="onchange_account_id(account_id, partner_id)"') elif field.field == 'partner_id': attrs.append('on_change="onchange_partner_id(move_id,partner_id,account_id,debit,credit,date,((\'journal_id\' in context) and context[\'journal_id\']) or {})"') if field.readonly: @@ -720,12 +720,12 @@ class account_move_line(osv.osv): attrs.append('required="1"') else: attrs.append('required="0"') - if field.field in ('amount_currency','currency_id'): + if field.field in ('amount_currency', 'currency_id'): attrs.append('on_change="onchange_currency(account_id,amount_currency,currency_id,date,((\'journal_id\' in context) and context[\'journal_id\']) or {})"') if field.field in widths: - attrs.append('width="'+str(widths[field.field])+'"') - xml += '''\n''' % (field.field,' '.join(attrs)) + attrs.append('width="' + str(widths[field.field]) + '"') + xml += '''\n''' % (field.field, ' '.join(attrs)) xml += '''''' result['arch'] = xml @@ -736,8 +736,8 @@ class account_move_line(osv.osv): self._update_check(cr, uid, ids, context) result = False for line in self.browse(cr, uid, ids, context): - context['journal_id']=line.journal_id.id - context['period_id']=line.period_id.id + context['journal_id'] = line.journal_id.id + context['period_id'] = line.period_id.id result = super(account_move_line, self).unlink(cr, uid, [line.id], context=context) if check: self.pool.get('account.move').validate(cr, uid, [line.move_id.id], context=context) @@ -745,7 +745,7 @@ class account_move_line(osv.osv): def write(self, cr, uid, ids, vals, context=None, check=True, update_check=True): if not context: - context={} + context = {} if vals.get('account_tax_id', False): raise osv.except_osv(_('Unable to change tax !'), _('You can not change the tax, you should remove and recreate lines !')) @@ -776,13 +776,13 @@ class account_move_line(osv.osv): cr.execute('select state from account_journal_period where journal_id=%s and period_id=%s', (journal_id, period_id)) result = cr.fetchall() for (state,) in result: - if state=='done': + if state == 'done': raise osv.except_osv(_('Error !'), _('You can not add/modify entries in a closed journal.')) if not result: journal = self.pool.get('account.journal').browse(cr, uid, journal_id, context) period = self.pool.get('account.period').browse(cr, uid, period_id, context) self.pool.get('account.journal.period').create(cr, uid, { - 'name': (journal.code or journal.name)+':'+(period.name or ''), + 'name': (journal.code or journal.name) + ':' + (period.name or ''), 'journal_id': journal.id, 'period_id': period.id }) @@ -791,7 +791,7 @@ class account_move_line(osv.osv): def _update_check(self, cr, uid, ids, context={}): done = {} for line in self.browse(cr, uid, ids, context): - if line.move_id.state<>'draft': + if line.move_id.state <> 'draft': raise osv.except_osv(_('Error !'), _('You can not do this modification on a confirmed entry ! Please note that you can just change some non important fields !')) if line.reconcile_id: raise osv.except_osv(_('Error !'), _('You can not do this modification on a reconciled entry ! Please note that you can just change some non important fields !')) @@ -803,9 +803,9 @@ class account_move_line(osv.osv): def create(self, cr, uid, vals, context=None, check=True): if not context: - context={} + context = {} account_obj = self.pool.get('account.account') - tax_obj=self.pool.get('account.tax') + tax_obj = self.pool.get('account.tax') if ('account_id' in vals) and not account_obj.read(cr, uid, vals['account_id'], ['active'])['active']: raise osv.except_osv(_('Bad account!'), _('You can not use an inactive account!')) if 'journal_id' in vals and 'journal_id' not in context: @@ -826,7 +826,7 @@ class account_move_line(osv.osv): if not move_id: if journal.centralisation: # use the first move ever created for this journal and period - cr.execute('select id, state, name from account_move where journal_id=%s and period_id=%s order by id limit 1', (context['journal_id'],context['period_id'])) + cr.execute('select id, state, name from account_move where journal_id=%s and period_id=%s order by id limit 1', (context['journal_id'], context['period_id'])) res = cr.fetchone() if res: if res[1] != 'draft': @@ -860,7 +860,7 @@ class account_move_line(osv.osv): break if journal.account_control_ids and not ok: for a in journal.account_control_ids: - if a.id==vals['account_id']: + if a.id == vals['account_id']: ok = True break if (account.currency_id) and 'amount_currency' not in vals and account.currency_id.id <> company_currency: @@ -870,14 +870,14 @@ class account_move_line(osv.osv): if 'date' in vals: ctx['date'] = vals['date'] vals['amount_currency'] = cur_obj.compute(cr, uid, account.company_id.currency_id.id, - account.currency_id.id, vals.get('debit', 0.0)-vals.get('credit', 0.0), + account.currency_id.id, vals.get('debit', 0.0) - vals.get('credit', 0.0), context=ctx) if not ok: raise osv.except_osv(_('Bad account !'), _('You can not use this general account in this journal !')) if 'analytic_account_id' in vals and vals['analytic_account_id']: if journal.analytic_journal_id: - vals['analytic_lines'] = [(0,0, { + vals['analytic_lines'] = [(0, 0, { 'name': vals['name'], 'date': vals.get('date', time.strftime('%Y-%m-%d')), 'account_id': vals['analytic_account_id'], @@ -896,7 +896,7 @@ class account_move_line(osv.osv): result = super(osv.osv, self).create(cr, uid, vals, context) # CREATE Taxes if 'account_tax_id' in vals and vals['account_tax_id']: - tax_id=tax_obj.browse(cr,uid,vals['account_tax_id']) + tax_id = tax_obj.browse(cr, uid, vals['account_tax_id']) total = vals['debit'] - vals['credit'] if journal.refund_journal: base_code = 'ref_base_code_id' @@ -912,12 +912,12 @@ class account_move_line(osv.osv): tax_sign = 'tax_sign' tmp_cnt = 0 - for tax in tax_obj.compute(cr,uid,[tax_id],total,1.00): + for tax in tax_obj.compute(cr, uid, [tax_id], total, 1.00): #create the base movement if tmp_cnt == 0: if tax[base_code]: tmp_cnt += 1 - self.write(cr, uid,[result], { + self.write(cr, uid, [result], { 'tax_code_id': tax[base_code], 'tax_amount': tax[base_sign] * abs(total) }) @@ -928,8 +928,8 @@ class account_move_line(osv.osv): 'period_id': vals['period_id'], 'name': tools.ustr(vals['name'] or '') + ' ' + tools.ustr(tax['name'] or ''), 'date': vals['date'], - 'partner_id': vals.get('partner_id',False), - 'ref': vals.get('ref',False), + 'partner_id': vals.get('partner_id', False), + 'ref': vals.get('ref', False), 'account_tax_id': False, 'tax_code_id': tax[base_code], 'tax_amount': tax[base_sign] * abs(total), @@ -947,14 +947,14 @@ class account_move_line(osv.osv): 'period_id': vals['period_id'], 'name': tools.ustr(vals['name'] or '') + ' ' + tools.ustr(tax['name'] or ''), 'date': vals['date'], - 'partner_id': vals.get('partner_id',False), - 'ref': vals.get('ref',False), + 'partner_id': vals.get('partner_id', False), + 'ref': vals.get('ref', False), 'account_tax_id': False, 'tax_code_id': tax[tax_code], 'tax_amount': tax[tax_sign] * abs(tax['amount']), 'account_id': tax[account_id] or vals['account_id'], - 'credit': tax['amount']<0 and -tax['amount'] or 0.0, - 'debit': tax['amount']>0 and tax['amount'] or 0.0, + 'credit': tax['amount'] < 0 and - tax['amount'] or 0.0, + 'debit': tax['amount'] > 0 and tax['amount'] or 0.0, } if data['tax_code_id']: self.create(cr, uid, data, context) @@ -968,7 +968,7 @@ class account_move_line(osv.osv): if check and not context.get('no_store_function'): tmp = self.pool.get('account.move').validate(cr, uid, [vals['move_id']], context) if journal.entry_posted and tmp: - self.pool.get('account.move').button_validate(cr,uid, [vals['move_id']],context) + self.pool.get('account.move').button_validate(cr, uid, [vals['move_id']], context) return result account_move_line() diff --git a/addons/account/company.py b/addons/account/company.py index 2301cc16d9a..07989100e40 100644 --- a/addons/account/company.py +++ b/addons/account/company.py @@ -28,7 +28,7 @@ class res_company(osv.osv): } _defaults = { - 'overdue_msg': lambda *a: 'Would your payment have been carried \ + 'overdue_msg': lambda * a: 'Would your payment have been carried \ out after this mail was sent, please consider the present one as \ void. Do not hesitate to contact our accounting department' } diff --git a/addons/account/installer.py b/addons/account/installer.py index 35a09406891..cb9ad0cbbbd 100644 --- a/addons/account/installer.py +++ b/addons/account/installer.py @@ -29,7 +29,7 @@ class account_installer(osv.osv_memory): def _get_charts(self, cr, uid, context=None): modules = self.pool.get('ir.module.module') - ids = modules.search(cr, uid, [('category_id','=','Account Charts')]) + ids = modules.search(cr, uid, [('category_id', '=', 'Account Charts')]) return list( sorted(((m.name, m.shortdesc) for m in modules.browse(cr, uid, ids)), @@ -71,7 +71,7 @@ class account_installer(osv.osv_memory): context=context)[0]['charts'] self.logger.notifyChannel( 'installer', netsvc.LOG_DEBUG, - 'Installing chart of accounts %s'%chart) + 'Installing chart of accounts %s' % chart) return modules | set([chart]) diff --git a/addons/account/invoice.py b/addons/account/invoice.py index 912095110e7..f48f7dc1902 100644 --- a/addons/account/invoice.py +++ b/addons/account/invoice.py @@ -44,7 +44,7 @@ from tools.translate import _ class account_invoice(osv.osv): def _amount_all(self, cr, uid, ids, name, args, context=None): res = {} - for invoice in self.browse(cr,uid,ids, context=context): + for invoice in self.browse(cr, uid, ids, context=context): res[invoice.id] = { 'amount_untaxed': 0.0, 'amount_tax': 0.0, @@ -67,7 +67,7 @@ class account_invoice(osv.osv): refund_journal = {'out_invoice': False, 'in_invoice': False, 'out_refund': True, 'in_refund': True} journal_obj = self.pool.get('account.journal') res = journal_obj.search(cr, uid, [('type', '=', type2journal.get(type_inv, 'sale')), - ('company_id', '=', company_id),('refund_journal', '=', refund_journal.get(type_inv, False))], + ('company_id', '=', company_id), ('refund_journal', '=', refund_journal.get(type_inv, False))], limit=1) if res: return res[0] @@ -79,14 +79,14 @@ class account_invoice(osv.osv): if user.company_id: return user.company_id.currency_id.id else: - return pooler.get_pool(cr.dbname).get('res.currency').search(cr, uid, [('rate','=',1.0)])[0] + return pooler.get_pool(cr.dbname).get('res.currency').search(cr, uid, [('rate', '=', 1.0)])[0] def _get_journal_analytic(self, cr, uid, type_inv, context=None): type2journal = {'out_invoice': 'sale', 'in_invoice': 'purchase', 'out_refund': 'sale', 'in_refund': 'purchase'} tt = type2journal.get(type_inv, 'sale') - result = self.pool.get('account.analytic.journal').search(cr, uid, [('type','=',tt)], context=context) + result = self.pool.get('account.analytic.journal').search(cr, uid, [('type', '=', tt)], context=context) if not result: - raise osv.except_osv(_('No Analytic Journal !'),_("You must define an analytic journal of type '%s' !") % (tt,)) + raise osv.except_osv(_('No Analytic Journal !'), _("You must define an analytic journal of type '%s' !") % (tt,)) return result[0] def _get_type(self, cr, uid, context=None): @@ -111,7 +111,7 @@ class account_invoice(osv.osv): for inv in data_inv: debit = credit = 0.0 context.update({'date':inv.date_invoice}) - context_unreconciled=context.copy() + context_unreconciled = context.copy() for lines in inv.move_lines: debit_tmp = lines.debit credit_tmp = lines.credit @@ -124,38 +124,38 @@ class account_invoice(osv.osv): context_unreconciled.update({'date':lines.date}) # If amount currency setted, compute for debit and credit in company currency if lines.amount_currency < 0: - credit_tmp=abs(cur_obj.compute(cr, uid, lines.currency_id.id, inv.company_id.currency_id.id, lines.amount_currency, round=False,context=context_unreconciled)) + credit_tmp = abs(cur_obj.compute(cr, uid, lines.currency_id.id, inv.company_id.currency_id.id, lines.amount_currency, round=False, context=context_unreconciled)) elif lines.amount_currency > 0: - debit_tmp=abs(cur_obj.compute(cr, uid, lines.currency_id.id, inv.company_id.currency_id.id, lines.amount_currency, round=False,context=context_unreconciled)) + debit_tmp = abs(cur_obj.compute(cr, uid, lines.currency_id.id, inv.company_id.currency_id.id, lines.amount_currency, round=False, context=context_unreconciled)) # Then, recomput into invoice currency to avoid rounding trouble ! - debit += cur_obj.compute(cr, uid, inv.company_id.currency_id.id, inv.currency_id.id, debit_tmp, round=False,context=context) - credit += cur_obj.compute(cr, uid, inv.company_id.currency_id.id, inv.currency_id.id, credit_tmp, round=False,context=context) + debit += cur_obj.compute(cr, uid, inv.company_id.currency_id.id, inv.currency_id.id, debit_tmp, round=False, context=context) + credit += cur_obj.compute(cr, uid, inv.company_id.currency_id.id, inv.currency_id.id, credit_tmp, round=False, context=context) else: - debit+=debit_tmp - credit+=credit_tmp + debit += debit_tmp + credit += credit_tmp if not inv.amount_total: result = 0.0 - elif inv.type in ('out_invoice','in_refund'): - amount = credit-debit + elif inv.type in ('out_invoice', 'in_refund'): + amount = credit - debit result = inv.amount_total - amount else: - amount = debit-credit + amount = debit - credit result = inv.amount_total - amount # Use is_zero function to avoid rounding trouble => should be fixed into ORM - res[inv.id] = not self.pool.get('res.currency').is_zero(cr, uid, inv.company_id.currency_id,result) and result or 0.0 + res[inv.id] = not self.pool.get('res.currency').is_zero(cr, uid, inv.company_id.currency_id, result) and result or 0.0 return res def _get_lines(self, cr, uid, ids, name, arg, context=None): res = {} for id in ids: - move_lines = self.move_line_id_payment_get(cr,uid,[id]) + move_lines = self.move_line_id_payment_get(cr, uid, [id]) if not move_lines: res[id] = [] continue res[id] = [] - data_lines = self.pool.get('account.move.line').browse(cr,uid,move_lines) + data_lines = self.pool.get('account.move.line').browse(cr, uid, move_lines) partial_ids = []# Keeps the track of ids where partial payments are done with payment terms for line in data_lines: ids_line = [] @@ -165,7 +165,7 @@ class account_invoice(osv.osv): ids_line = line.reconcile_partial_id.line_partial_ids l = map(lambda x: x.id, ids_line) partial_ids.append(line.id) - res[id] =[x for x in l if x <> line.id and x not in partial_ids] + res[id] = [x for x in l if x <> line.id and x not in partial_ids] return res def _get_invoice_line(self, cr, uid, ids, context=None): @@ -210,7 +210,7 @@ class account_invoice(osv.osv): move[line2.move_id.id] = True invoice_ids = [] if move: - invoice_ids = self.pool.get('account.invoice').search(cr, uid, [('move_id','in',move.keys())], context=context) + invoice_ids = self.pool.get('account.invoice').search(cr, uid, [('move_id', 'in', move.keys())], context=context) return invoice_ids def _get_invoice_from_reconcile(self, cr, uid, ids, context={}): @@ -223,21 +223,21 @@ class account_invoice(osv.osv): invoice_ids = [] if move: - invoice_ids = self.pool.get('account.invoice').search(cr, uid, [('move_id','in',move.keys())], context=context) + invoice_ids = self.pool.get('account.invoice').search(cr, uid, [('move_id', 'in', move.keys())], context=context) return invoice_ids _name = "account.invoice" _description = 'Invoice' _order = "number" _columns = { - 'name': fields.char('Description', size=64, select=True,readonly=True, states={'draft':[('readonly',False)]}), + 'name': fields.char('Description', size=64, select=True, readonly=True, states={'draft':[('readonly', False)]}), 'origin': fields.char('Source Document', size=64, help="Reference of the document that produced this invoice."), 'type': fields.selection([ - ('out_invoice','Customer Invoice'), - ('in_invoice','Supplier Invoice'), - ('out_refund','Customer Refund'), - ('in_refund','Supplier Refund'), - ],'Type', readonly=True, select=True, change_default=True), + ('out_invoice', 'Customer Invoice'), + ('in_invoice', 'Supplier Invoice'), + ('out_refund', 'Customer Refund'), + ('in_refund', 'Supplier Refund'), + ], 'Type', readonly=True, select=True, change_default=True), 'number': fields.char('Invoice Number', size=32, readonly=True, help="Unique number of the invoice, computed automatically when the invoice is created."), 'reference': fields.char('Invoice Reference', size=64, help="The partner reference of this invoice."), @@ -246,61 +246,61 @@ class account_invoice(osv.osv): 'comment': fields.text('Additional Information', translate=True), 'state': fields.selection([ - ('draft','Draft'), - ('proforma','Pro-forma'), - ('proforma2','Pro-forma'), - ('open','Open'), - ('paid','Done'), - ('cancel','Cancelled') - ],'State', select=True, readonly=True, + ('draft', 'Draft'), + ('proforma', 'Pro-forma'), + ('proforma2', 'Pro-forma'), + ('open', 'Open'), + ('paid', 'Done'), + ('cancel', 'Cancelled') + ], 'State', select=True, readonly=True, help=' * The \'Draft\' state is used when a user is encoding a new and unconfirmed Invoice. \ \n* The \'Pro-forma\' when invoice is in Pro-forma state,invoice does not have an invoice number. \ \n* The \'Open\' state is used when user create invoice,a invoice number is generated.Its in open state till user does not pay invoice. \ \n* The \'Done\' state is set automatically when invoice is paid.\ \n* The \'Cancelled\' state is used when user cancel invoice.'), - 'date_invoice': fields.date('Date Invoiced', states={'open':[('readonly',True)],'close':[('readonly',True)]}, help="Keep empty to use the current date"), - 'date_due': fields.date('Due Date', states={'open':[('readonly',True)],'close':[('readonly',True)]}, + 'date_invoice': fields.date('Date Invoiced', states={'open':[('readonly', True)], 'close':[('readonly', True)]}, help="Keep empty to use the current date"), + 'date_due': fields.date('Due Date', states={'open':[('readonly', True)], 'close':[('readonly', True)]}, help="If you use payment terms, the due date will be computed automatically at the generation "\ "of accounting entries. If you keep the payment term and the due date empty, it means direct payment. The payment term may compute several due dates, for example 50% now, 50% in one month."), - 'partner_id': fields.many2one('res.partner', 'Partner', change_default=True, readonly=True, required=True, states={'draft':[('readonly',False)]}), - 'address_contact_id': fields.many2one('res.partner.address', 'Contact Address', readonly=True, states={'draft':[('readonly',False)]}), - 'address_invoice_id': fields.many2one('res.partner.address', 'Invoice Address', readonly=True, required=True, states={'draft':[('readonly',False)]}), - 'payment_term': fields.many2one('account.payment.term', 'Payment Term',readonly=True, states={'draft':[('readonly',False)]}, + 'partner_id': fields.many2one('res.partner', 'Partner', change_default=True, readonly=True, required=True, states={'draft':[('readonly', False)]}), + 'address_contact_id': fields.many2one('res.partner.address', 'Contact Address', readonly=True, states={'draft':[('readonly', False)]}), + 'address_invoice_id': fields.many2one('res.partner.address', 'Invoice Address', readonly=True, required=True, states={'draft':[('readonly', False)]}), + 'payment_term': fields.many2one('account.payment.term', 'Payment Term', readonly=True, states={'draft':[('readonly', False)]}, help="If you use payment terms, the due date will be computed automatically at the generation "\ "of accounting entries. If you keep the payment term and the due date empty, it means direct payment. "\ "The payment term may compute several due dates, for example 50% now, 50% in one month."), - 'period_id': fields.many2one('account.period', 'Force Period', domain=[('state','<>','done')], help="Keep empty to use the period of the validation(invoice) date.", readonly=True, states={'draft':[('readonly',False)]}), + 'period_id': fields.many2one('account.period', 'Force Period', domain=[('state', '<>', 'done')], help="Keep empty to use the period of the validation(invoice) date.", readonly=True, states={'draft':[('readonly', False)]}), - 'account_id': fields.many2one('account.account', 'Account', required=True, readonly=True, states={'draft':[('readonly',False)]}, help="The partner account used for this invoice."), - 'invoice_line': fields.one2many('account.invoice.line', 'invoice_id', 'Invoice Lines', readonly=True, states={'draft':[('readonly',False)]}), - 'tax_line': fields.one2many('account.invoice.tax', 'invoice_id', 'Tax Lines', readonly=True, states={'draft':[('readonly',False)]}), + 'account_id': fields.many2one('account.account', 'Account', required=True, readonly=True, states={'draft':[('readonly', False)]}, help="The partner account used for this invoice."), + 'invoice_line': fields.one2many('account.invoice.line', 'invoice_id', 'Invoice Lines', readonly=True, states={'draft':[('readonly', False)]}), + 'tax_line': fields.one2many('account.invoice.tax', 'invoice_id', 'Tax Lines', readonly=True, states={'draft':[('readonly', False)]}), 'move_id': fields.many2one('account.move', 'Invoice Movement', readonly=True, help="Links to the automatically generated Ledger Postings."), - 'amount_untaxed': fields.function(_amount_all, method=True, digits=(16, int(config['price_accuracy'])),string='Untaxed', + 'amount_untaxed': fields.function(_amount_all, method=True, digits=(16, int(config['price_accuracy'])), string='Untaxed', store={ 'account.invoice': (lambda self, cr, uid, ids, c={}: ids, ['invoice_line'], 20), 'account.invoice.tax': (_get_invoice_tax, None, 20), - 'account.invoice.line': (_get_invoice_line, ['price_unit','invoice_line_tax_id','quantity','discount'], 20), + 'account.invoice.line': (_get_invoice_line, ['price_unit', 'invoice_line_tax_id', 'quantity', 'discount'], 20), }, multi='all'), 'amount_tax': fields.function(_amount_all, method=True, digits=(16, int(config['price_accuracy'])), string='Tax', store={ 'account.invoice': (lambda self, cr, uid, ids, c={}: ids, ['invoice_line'], 20), 'account.invoice.tax': (_get_invoice_tax, None, 20), - 'account.invoice.line': (_get_invoice_line, ['price_unit','invoice_line_tax_id','quantity','discount'], 20), + 'account.invoice.line': (_get_invoice_line, ['price_unit', 'invoice_line_tax_id', 'quantity', 'discount'], 20), }, multi='all'), 'amount_total': fields.function(_amount_all, method=True, digits=(16, int(config['price_accuracy'])), string='Total', store={ 'account.invoice': (lambda self, cr, uid, ids, c={}: ids, ['invoice_line'], 20), 'account.invoice.tax': (_get_invoice_tax, None, 20), - 'account.invoice.line': (_get_invoice_line, ['price_unit','invoice_line_tax_id','quantity','discount'], 20), + 'account.invoice.line': (_get_invoice_line, ['price_unit', 'invoice_line_tax_id', 'quantity', 'discount'], 20), }, multi='all'), - 'currency_id': fields.many2one('res.currency', 'Currency', required=True, readonly=True, states={'draft':[('readonly',False)]}), - 'journal_id': fields.many2one('account.journal', 'Journal', required=True,readonly=True, states={'draft':[('readonly',False)]}), + 'currency_id': fields.many2one('res.currency', 'Currency', required=True, readonly=True, states={'draft':[('readonly', False)]}), + 'journal_id': fields.many2one('account.journal', 'Journal', required=True, readonly=True, states={'draft':[('readonly', False)]}), 'company_id': fields.many2one('res.company', 'Company', required=True, change_default=True), - 'check_total': fields.float('Total', digits=(16, int(config['price_accuracy'])), states={'open':[('readonly',True)],'close':[('readonly',True)]}), + 'check_total': fields.float('Total', digits=(16, int(config['price_accuracy'])), states={'open':[('readonly', True)], 'close':[('readonly', True)]}), 'reconciled': fields.function(_reconciled, method=True, string='Paid/Reconciled', type='boolean', store={ 'account.invoice': (lambda self, cr, uid, ids, c={}: ids, None, 50), # Check if we can remove ? @@ -309,12 +309,12 @@ class account_invoice(osv.osv): }, help="The Ledger Postings of the invoice have been reconciled with Ledger Postings of the payment(s)."), 'partner_bank': fields.many2one('res.partner.bank', 'Bank Account', help='The bank account to pay to or to be paid from'), - 'move_lines':fields.function(_get_lines , method=True,type='many2many' , relation='account.move.line',string='Entry Lines'), - 'residual': fields.function(_amount_residual, method=True, digits=(16, int(config['price_accuracy'])),string='Residual', + 'move_lines':fields.function(_get_lines , method=True, type='many2many' , relation='account.move.line', string='Entry Lines'), + 'residual': fields.function(_amount_residual, method=True, digits=(16, int(config['price_accuracy'])), string='Residual', store={ 'account.invoice': (lambda self, cr, uid, ids, c={}: ids, ['invoice_line'], 50), 'account.invoice.tax': (_get_invoice_tax, None, 50), - 'account.invoice.line': (_get_invoice_line, ['price_unit','invoice_line_tax_id','quantity','discount'], 50), + 'account.invoice.line': (_get_invoice_line, ['price_unit', 'invoice_line_tax_id', 'quantity', 'discount'], 50), 'account.move.line': (_get_invoice_from_line, None, 50), 'account.move.reconcile': (_get_invoice_from_reconcile, None, 50), }, @@ -326,12 +326,12 @@ class account_invoice(osv.osv): _defaults = { 'type': _get_type, #'date_invoice': lambda *a: time.strftime('%Y-%m-%d'), - 'state': lambda *a: 'draft', + 'state': lambda * a: 'draft', 'journal_id': _get_journal, 'currency_id': _get_currency, - 'company_id': lambda self,cr,uid,c: self.pool.get('res.company')._company_default_get(cr, uid, 'account.invoice', context=c), - 'reference_type': lambda *a: 'none', - 'check_total': lambda *a: 0.0, + 'company_id': lambda self, cr, uid, c: self.pool.get('res.company')._company_default_get(cr, uid, 'account.invoice', context=c), + 'reference_type': lambda * a: 'none', + 'check_total': lambda * a: 0.0, } def unlink(self, cr, uid, ids, context=None): @@ -367,21 +367,21 @@ class account_invoice(osv.osv): p = self.pool.get('res.partner').browse(cr, uid, partner_id) if company_id: if p.property_account_receivable.company_id.id != company_id and p.property_account_payable.company_id.id != company_id: - rec_pro_id = self.pool.get('ir.property').search(cr,uid,[('name','=','property_account_receivable'),('res_id','=','res.partner,'+str(partner_id)+''),('company_id','=',company_id)]) - pay_pro_id = self.pool.get('ir.property').search(cr,uid,[('name','=','property_account_payable'),('res_id','=','res.partner,'+str(partner_id)+''),('company_id','=',company_id)]) + rec_pro_id = self.pool.get('ir.property').search(cr, uid, [('name', '=', 'property_account_receivable'), ('res_id', '=', 'res.partner,' + str(partner_id) + ''), ('company_id', '=', company_id)]) + pay_pro_id = self.pool.get('ir.property').search(cr, uid, [('name', '=', 'property_account_payable'), ('res_id', '=', 'res.partner,' + str(partner_id) + ''), ('company_id', '=', company_id)]) if not rec_pro_id: - rec_pro_id = self.pool.get('ir.property').search(cr,uid,[('name','=','property_account_receivable'),('company_id','=',company_id)]) + rec_pro_id = self.pool.get('ir.property').search(cr, uid, [('name', '=', 'property_account_receivable'), ('company_id', '=', company_id)]) if not pay_pro_id: - pay_pro_id = self.pool.get('ir.property').search(cr,uid,[('name','=','property_account_payable'),('company_id','=',company_id)]) - rec_line_data = self.pool.get('ir.property').read(cr,uid,rec_pro_id,['name','value','res_id']) - pay_line_data = self.pool.get('ir.property').read(cr,uid,pay_pro_id,['name','value','res_id']) + pay_pro_id = self.pool.get('ir.property').search(cr, uid, [('name', '=', 'property_account_payable'), ('company_id', '=', company_id)]) + rec_line_data = self.pool.get('ir.property').read(cr, uid, rec_pro_id, ['name', 'value', 'res_id']) + pay_line_data = self.pool.get('ir.property').read(cr, uid, pay_pro_id, ['name', 'value', 'res_id']) rec_res_id = rec_line_data and int(rec_line_data[0]['value'].split(',')[1]) or False pay_res_id = pay_line_data and int(pay_line_data[0]['value'].split(',')[1]) or False if not rec_res_id and not pay_res_id: raise osv.except_osv(_('Configration Error !'), _('Can not find account chart for this company, Please Create account.')) - rec_obj_acc=self.pool.get('account.account').browse(cr,uid,[rec_res_id]) - pay_obj_acc=self.pool.get('account.account').browse(cr,uid,[pay_res_id]) + rec_obj_acc = self.pool.get('account.account').browse(cr, uid, [rec_res_id]) + pay_obj_acc = self.pool.get('account.account').browse(cr, uid, [pay_res_id]) p.property_account_receivable = rec_obj_acc[0] p.property_account_payable = pay_obj_acc[0] @@ -409,7 +409,7 @@ class account_invoice(osv.osv): if payment_term != partner_payment_term: if partner_payment_term: to_update = self.onchange_payment_term_date_invoice( - cr,uid,ids,partner_payment_term,date_invoice) + cr, uid, ids, partner_payment_term, date_invoice) result['value'].update(to_update['value']) else: result['value']['date_due'] = False @@ -430,8 +430,8 @@ class account_invoice(osv.osv): def onchange_payment_term_date_invoice(self, cr, uid, ids, payment_term_id, date_invoice): if not payment_term_id: return {} - res={} - pt_obj= self.pool.get('account.payment.term') + res = {} + pt_obj = self.pool.get('account.payment.term') if not date_invoice : date_invoice = time.strftime('%Y-%m-%d') @@ -440,7 +440,7 @@ class account_invoice(osv.osv): if pterm_list: pterm_list = [line[0] for line in pterm_list] pterm_list.sort() - res= {'value':{'date_due': pterm_list[-1]}} + res = {'value':{'date_due': pterm_list[-1]}} else: raise osv.except_osv(_('Data Insufficient !'), _('The Payment Term of Supplier does not have Payment Term Lines(Computation) defined !')) @@ -453,21 +453,21 @@ class account_invoice(osv.osv): return {'value': {}} def onchange_company_id(self, cr, uid, ids, company_id, part_id, type, invoice_line, currency_id): - val={} - dom={} + val = {} + dom = {} if company_id and part_id and type: acc_id = False - partner_obj = self.pool.get('res.partner').browse(cr,uid,part_id) + partner_obj = self.pool.get('res.partner').browse(cr, uid, part_id) if partner_obj.property_account_payable and partner_obj.property_account_receivable: if partner_obj.property_account_payable.company_id.id != company_id and partner_obj.property_account_receivable.company_id.id != company_id: - rec_pro_id = self.pool.get('ir.property').search(cr,uid,[('name','=','property_account_receivable'),('res_id','=','res.partner,'+str(part_id)+''),('company_id','=',company_id)]) - pay_pro_id = self.pool.get('ir.property').search(cr,uid,[('name','=','property_account_payable'),('res_id','=','res.partner,'+str(part_id)+''),('company_id','=',company_id)]) + rec_pro_id = self.pool.get('ir.property').search(cr, uid, [('name', '=', 'property_account_receivable'), ('res_id', '=', 'res.partner,' + str(part_id) + ''), ('company_id', '=', company_id)]) + pay_pro_id = self.pool.get('ir.property').search(cr, uid, [('name', '=', 'property_account_payable'), ('res_id', '=', 'res.partner,' + str(part_id) + ''), ('company_id', '=', company_id)]) if not rec_pro_id: - rec_pro_id = self.pool.get('ir.property').search(cr,uid,[('name','=','property_account_receivable'),('company_id','=',company_id)]) + rec_pro_id = self.pool.get('ir.property').search(cr, uid, [('name', '=', 'property_account_receivable'), ('company_id', '=', company_id)]) if not pay_pro_id: - pay_pro_id = self.pool.get('ir.property').search(cr,uid,[('name','=','property_account_payable'),('company_id','=',company_id)]) - rec_line_data = self.pool.get('ir.property').read(cr,uid,rec_pro_id,['name','value','res_id']) - pay_line_data = self.pool.get('ir.property').read(cr,uid,pay_pro_id,['name','value','res_id']) + pay_pro_id = self.pool.get('ir.property').search(cr, uid, [('name', '=', 'property_account_payable'), ('company_id', '=', company_id)]) + rec_line_data = self.pool.get('ir.property').read(cr, uid, rec_pro_id, ['name', 'value', 'res_id']) + pay_line_data = self.pool.get('ir.property').read(cr, uid, pay_pro_id, ['name', 'value', 'res_id']) rec_res_id = rec_line_data and int(rec_line_data[0]['value'].split(',')[1]) or False pay_res_id = pay_line_data and int(pay_line_data[0]['value'].split(',')[1]) or False if not rec_res_id and not rec_res_id: @@ -477,49 +477,49 @@ class account_invoice(osv.osv): acc_id = rec_res_id else: acc_id = pay_res_id - val= {'account_id': acc_id} + val = {'account_id': acc_id} if ids: if company_id: - inv_obj = self.browse(cr,uid,ids) + inv_obj = self.browse(cr, uid, ids) for line in inv_obj[0].invoice_line: if line.account_id: if line.account_id.company_id.id != company_id: - result_id = self.pool.get('account.account').search(cr,uid,[('name','=',line.account_id.name),('company_id','=',company_id)]) + result_id = self.pool.get('account.account').search(cr, uid, [('name', '=', line.account_id.name), ('company_id', '=', company_id)]) if not result_id: raise osv.except_osv(_('Configration Error !'), _('Can not find account chart for this company in invoice line account, Please Create account.')) - r_id = self.pool.get('account.invoice.line').write(cr,uid,[line.id],{'account_id': result_id[0]}) + r_id = self.pool.get('account.invoice.line').write(cr, uid, [line.id], {'account_id': result_id[0]}) else: if invoice_line: for inv_line in invoice_line: - obj_l = self.pool.get('account.account').browse(cr,uid,inv_line[2]['account_id']) + obj_l = self.pool.get('account.account').browse(cr, uid, inv_line[2]['account_id']) if obj_l.company_id.id != company_id: raise osv.except_osv(_('Configration Error !'), _('invoice line account company is not match with invoice company.')) else: continue if company_id: - val['journal_id']=False - journal_ids=self.pool.get('account.journal').search(cr,uid,[('company_id','=',company_id)]) - dom={'journal_id': [('id','in',journal_ids)]} + val['journal_id'] = False + journal_ids = self.pool.get('account.journal').search(cr, uid, [('company_id', '=', company_id)]) + dom = {'journal_id': [('id', 'in', journal_ids)]} else: - journal_ids=self.pool.get('account.journal').search(cr,uid,[]) - dom={'journal_id': [('id','in',journal_ids)]} - + journal_ids = self.pool.get('account.journal').search(cr, uid, []) + dom = {'journal_id': [('id', 'in', journal_ids)]} + if currency_id and company_id: currency = self.pool.get('res.currency').browse(cr, uid, currency_id) if currency.company_id.id != company_id: val['currency_id'] = False else: val['currency_id'] = currency.id - + if company_id: company = self.pool.get('res.company').browse(cr, uid, company_id) if company.currency_id.company_id.id != company_id: - val['currency_id'] = False + val['currency_id'] = False else: val['currency_id'] = company.currency_id.id - + return {'value' : val, 'domain': dom } # go from canceled state to draft state @@ -542,7 +542,7 @@ class account_invoice(osv.osv): l.id \ from account_move_line l \ left join account_invoice i on (i.move_id=l.move_id) \ - where i.id in ('+','.join(map(str,map(int, ids)))+') and l.account_id=i.account_id') + where i.id in (' + ','.join(map(str, map(int, ids))) + ') and l.account_id=i.account_id') res = map(lambda x: x[0], cr.fetchall()) return res @@ -550,7 +550,7 @@ class account_invoice(osv.osv): if default is None: default = {} default = default.copy() - default.update({'state':'draft', 'number':False, 'move_id':False, 'move_name':False,}) + default.update({'state':'draft', 'number':False, 'move_id':False, 'move_name':False, }) if 'date_invoice' not in default: default['date_invoice'] = False if 'date_due' not in default: @@ -573,7 +573,7 @@ class account_invoice(osv.osv): ait_obj = self.pool.get('account.invoice.tax') for id in ids: cr.execute("DELETE FROM account_invoice_tax WHERE invoice_id=%s", (id,)) - partner = self.browse(cr, uid, id,context=context).partner_id + partner = self.browse(cr, uid, id, context=context).partner_id if partner.lang: context.update({'lang': partner.lang}) for taxe in ait_obj.compute(cr, uid, id, context=context).values(): @@ -591,7 +591,7 @@ class account_invoice(osv.osv): return True def _convert_ref(self, cr, uid, ref): - return (ref or '').replace('/','') + return (ref or '').replace('/', '') def _get_analytic_lines(self, cr, uid, id): inv = self.browse(cr, uid, [id])[0] @@ -610,7 +610,7 @@ class account_invoice(osv.osv): ref = inv.reference else: ref = self._convert_ref(cr, uid, inv.number) - il['analytic_lines'] = [(0,0, { + il['analytic_lines'] = [(0, 0, { 'name': il['name'], 'date': inv['date_invoice'], 'account_id': il['account_analytic_id'], @@ -669,7 +669,7 @@ class account_invoice(osv.osv): if not key in tax_key: raise osv.except_osv(_('Warning !'), _('Taxes missing !')) - if inv.type in ('in_invoice', 'in_refund') and abs(inv.check_total - inv.amount_total) >= (inv.currency_id.rounding/2.0): + if inv.type in ('in_invoice', 'in_refund') and abs(inv.check_total - inv.amount_total) >= (inv.currency_id.rounding / 2.0): raise osv.except_osv(_('Bad total !'), _('Please verify the price of the invoice !\nThe real total does not match the computed total.')) # one move line per tax line @@ -695,10 +695,10 @@ class account_invoice(osv.osv): i['amount_currency'] = False i['currency_id'] = False i['ref'] = ref - if inv.type in ('out_invoice','in_refund'): + if inv.type in ('out_invoice', 'in_refund'): total += i['price'] total_currency += i['amount_currency'] or i['price'] - i['price'] = - i['price'] + i['price'] = -i['price'] else: total -= i['price'] total_currency -= i['amount_currency'] or i['price'] @@ -754,28 +754,28 @@ class account_invoice(osv.osv): date = inv.date_invoice or time.strftime('%Y-%m-%d') part = inv.partner_id.id - line = map(lambda x:(0,0,self.line_get_convert(cr, uid, x, part, date, context={})) ,iml) + line = map(lambda x:(0, 0, self.line_get_convert(cr, uid, x, part, date, context={})) , iml) if inv.journal_id.group_invoice_lines: line2 = {} for x, y, l in line: tmp = str(l['account_id']) - tmp += '-'+str(l.get('tax_code_id',"False")) - tmp += '-'+str(l.get('product_id',"False")) - tmp += '-'+str(l.get('analytic_account_id',"False")) - tmp += '-'+str(l.get('date_maturity',"False")) + tmp += '-' + str(l.get('tax_code_id', "False")) + tmp += '-' + str(l.get('product_id', "False")) + tmp += '-' + str(l.get('analytic_account_id', "False")) + tmp += '-' + str(l.get('date_maturity', "False")) if tmp in line2: am = line2[tmp]['debit'] - line2[tmp]['credit'] + (l['debit'] - l['credit']) line2[tmp]['debit'] = (am > 0) and am or 0.0 - line2[tmp]['credit'] = (am < 0) and -am or 0.0 + line2[tmp]['credit'] = (am < 0) and - am or 0.0 line2[tmp]['tax_amount'] += l['tax_amount'] line2[tmp]['analytic_lines'] += l['analytic_lines'] else: line2[tmp] = l line = [] for key, val in line2.items(): - line.append((0,0,val)) + line.append((0, 0, val)) journal_id = inv.journal_id.id #self._get_journal(cr, uid, {'type': inv['type']}) journal = self.pool.get('account.journal').browse(cr, uid, journal_id) @@ -783,11 +783,11 @@ class account_invoice(osv.osv): raise osv.except_osv(_('UserError'), _('Cannot create invoice move on centralised journal')) move = {'ref': inv.number, 'line_id': line, 'journal_id': journal_id, 'date': date} - period_id=inv.period_id and inv.period_id.id or False + period_id = inv.period_id and inv.period_id.id or False if not period_id: - period_ids= self.pool.get('account.period').search(cr,uid,[('date_start','<=',inv.date_invoice or time.strftime('%Y-%m-%d')),('date_stop','>=',inv.date_invoice or time.strftime('%Y-%m-%d'))]) + period_ids = self.pool.get('account.period').search(cr, uid, [('date_start', '<=', inv.date_invoice or time.strftime('%Y-%m-%d')), ('date_stop', '>=', inv.date_invoice or time.strftime('%Y-%m-%d'))]) if len(period_ids): - period_id=period_ids[0] + period_id = period_ids[0] if period_id: move['period_id'] = period_id for i in line: @@ -796,7 +796,7 @@ class account_invoice(osv.osv): move_id = self.pool.get('account.move').create(cr, uid, move, context=context) new_move_name = self.pool.get('account.move').browse(cr, uid, move_id).name # make the invoice point to that move - self.write(cr, uid, [inv.id], {'move_id': move_id,'period_id':period_id, 'move_name':new_move_name}) + self.write(cr, uid, [inv.id], {'move_id': move_id, 'period_id':period_id, 'move_name':new_move_name}) self.pool.get('account.move').post(cr, uid, [move_id]) self._log_event(cr, uid, ids) return True @@ -807,25 +807,25 @@ class account_invoice(osv.osv): 'partner_id':part, 'name':x['name'][:64], 'date': date, - 'debit':x['price']>0 and x['price'], - 'credit':x['price']<0 and -x['price'], + 'debit':x['price'] > 0 and x['price'], + 'credit':x['price'] < 0 and - x['price'], 'account_id':x['account_id'], 'analytic_lines':x.get('analytic_lines', []), - 'amount_currency':x['price']>0 and abs(x.get('amount_currency', False)) or -abs(x.get('amount_currency', False)), + 'amount_currency':x['price'] > 0 and abs(x.get('amount_currency', False)) or - abs(x.get('amount_currency', False)), 'currency_id':x.get('currency_id', False), 'tax_code_id': x.get('tax_code_id', False), 'tax_amount': x.get('tax_amount', False), - 'ref':x.get('ref',False), - 'quantity':x.get('quantity',1.00), + 'ref':x.get('ref', False), + 'quantity':x.get('quantity', 1.00), 'product_id':x.get('product_id', False), - 'product_uom_id':x.get('uos_id',False), - 'analytic_account_id':x.get('account_analytic_id',False), + 'product_uom_id':x.get('uos_id', False), + 'analytic_account_id':x.get('account_analytic_id', False), } def action_number(self, cr, uid, ids, *args): cr.execute('SELECT id, type, number, move_id, reference ' \ 'FROM account_invoice ' \ - 'WHERE id IN ('+','.join(map(str, ids))+')') + 'WHERE id IN (' + ','.join(map(str, ids)) + ')') obj_inv = self.browse(cr, uid, ids)[0] for (id, invtype, number, move_id, reference) in cr.fetchall(): if not number: @@ -867,7 +867,7 @@ class account_invoice(osv.osv): if i['payment_ids']: self.pool.get('account.move.line').write(cr, uid, i['payment_ids'], {'reconcile_partial_id': False}) self.write(cr, uid, ids, {'state':'cancel', 'move_id':False}) - self._log_event(cr, uid, ids,-1.0, 'Cancel Invoice') + self._log_event(cr, uid, ids, -1.0, 'Cancel Invoice') return True ################### @@ -882,22 +882,22 @@ class account_invoice(osv.osv): return taxes.values() def _log_event(self, cr, uid, ids, factor=1.0, name='Open Invoice'): - invs = self.read(cr, uid, ids, ['type','partner_id','amount_untaxed']) + invs = self.read(cr, uid, ids, ['type', 'partner_id', 'amount_untaxed']) for inv in invs: - part=inv['partner_id'] and inv['partner_id'][0] + part = inv['partner_id'] and inv['partner_id'][0] pc = pr = 0.0 cr.execute('select sum(quantity*price_unit) from account_invoice_line where invoice_id=%s', (inv['id'],)) total = inv['amount_untaxed'] - if inv['type'] in ('in_invoice','in_refund'): - partnertype='supplier' + if inv['type'] in ('in_invoice', 'in_refund'): + partnertype = 'supplier' eventtype = 'purchase' - pc = total*factor + pc = total * factor else: partnertype = 'customer' eventtype = 'sale' - pr = total*factor + pr = total * factor if self.pool.get('res.partner.event.type').check(cr, uid, 'invoice_open'): - self.pool.get('res.partner.event').create(cr, uid, {'name':'Invoice: '+name, 'som':False, 'description':name+' '+str(inv['id']), 'document':name, 'partner_id':part, 'date':time.strftime('%Y-%m-%d %H:%M:%S'), 'canal_id':False, 'user_id':uid, 'partner_type':partnertype, 'probability':1.0, 'planned_revenue':pr, 'planned_cost':pc, 'type':eventtype}) + self.pool.get('res.partner.event').create(cr, uid, {'name':'Invoice: ' + name, 'som':False, 'description':name + ' ' + str(inv['id']), 'document':name, 'partner_id':part, 'date':time.strftime('%Y-%m-%d %H:%M:%S'), 'canal_id':False, 'user_id':uid, 'partner_type':partnertype, 'probability':1.0, 'planned_revenue':pr, 'planned_cost':pc, 'type':eventtype}) return len(invs) def name_get(self, cr, uid, ids, context=None): @@ -909,18 +909,18 @@ class account_invoice(osv.osv): 'out_refund': 'OR: ', 'in_refund': 'SR: ', } - return [(r['id'], types[r['type']]+(r['number'] or '')+' '+(r['name'] or '')) for r in self.read(cr, uid, ids, ['type', 'number', 'name'], context, load='_classic_write')] + return [(r['id'], types[r['type']] + (r['number'] or '') + ' ' + (r['name'] or '')) for r in self.read(cr, uid, ids, ['type', 'number', 'name'], context, load='_classic_write')] def name_search(self, cr, user, name, args=None, operator='ilike', context=None, limit=100): if not args: - args=[] + args = [] if context is None: - context={} + context = {} ids = [] if name: - ids = self.search(cr, user, [('number','=',name)]+ args, limit=limit, context=context) + ids = self.search(cr, user, [('number', '=', name)] + args, limit=limit, context=context) if not ids: - ids = self.search(cr, user, [('name',operator,name)]+ args, limit=limit, context=context) + ids = self.search(cr, user, [('name', operator, name)] + args, limit=limit, context=context) return self.name_get(cr, user, ids, context) def _refund_cleanup_lines(self, cr, uid, lines): @@ -934,16 +934,16 @@ class account_invoice(osv.osv): if 'uos_id' in line: line['uos_id'] = line.get('uos_id', False) and line['uos_id'][0] if 'invoice_line_tax_id' in line: - line['invoice_line_tax_id'] = [(6,0, line.get('invoice_line_tax_id', [])) ] + line['invoice_line_tax_id'] = [(6, 0, line.get('invoice_line_tax_id', [])) ] if 'account_analytic_id' in line: line['account_analytic_id'] = line.get('account_analytic_id', False) and line['account_analytic_id'][0] if 'tax_code_id' in line : - if isinstance(line['tax_code_id'],tuple) and len(line['tax_code_id']) >0 : + if isinstance(line['tax_code_id'], tuple) and len(line['tax_code_id']) > 0 : line['tax_code_id'] = line['tax_code_id'][0] if 'base_code_id' in line : - if isinstance(line['base_code_id'],tuple) and len(line['base_code_id']) >0 : + if isinstance(line['base_code_id'], tuple) and len(line['base_code_id']) > 0 : line['base_code_id'] = line['base_code_id'][0] - return map(lambda x: (0,0,x), lines) + return map(lambda x: (0, 0, x), lines) def refund(self, cr, uid, ids, date=None, period_id=None, description=None): invoices = self.read(cr, uid, ids, ['name', 'type', 'number', 'reference', 'comment', 'date_due', 'partner_id', 'address_contact_id', 'address_invoice_id', 'partner_contact', 'partner_insite', 'partner_ref', 'payment_term', 'account_id', 'currency_id', 'invoice_line', 'tax_line', 'journal_id']) @@ -954,9 +954,9 @@ class account_invoice(osv.osv): type_dict = { 'out_invoice': 'out_refund', # Customer Invoice - 'in_invoice': 'in_refund', # Supplier Invoice + 'in_invoice': 'in_refund', # Supplier Invoice 'out_refund': 'out_invoice', # Customer Refund - 'in_refund': 'in_invoice', # Supplier Refund + 'in_refund': 'in_invoice', # Supplier Refund } @@ -996,17 +996,17 @@ class account_invoice(osv.osv): if context is None: context = {} #TODO check if we can use different period for payment and the writeoff line - assert len(ids)==1, "Can only pay one invoice at a time" + assert len(ids) == 1, "Can only pay one invoice at a time" invoice = self.browse(cr, uid, ids[0]) src_account_id = invoice.account_id.id # Take the seq as name for move - types = {'out_invoice': -1, 'in_invoice': 1, 'out_refund': 1, 'in_refund': -1} + types = {'out_invoice':-1, 'in_invoice': 1, 'out_refund': 1, 'in_refund':-1} direction = types[invoice.type] #take the choosen date if 'date_p' in context and context['date_p']: - date=context['date_p'] + date = context['date_p'] else: - date=time.strftime('%Y-%m-%d') + date = time.strftime('%Y-%m-%d') # Take the amount in currency and the currency of the payment if 'amount_currency' in context and context['amount_currency'] and 'currency_id' in context and context['currency_id']: @@ -1021,8 +1021,8 @@ class account_invoice(osv.osv): ref = self._convert_ref(cr, uid, invoice.number) # Pay attention to the sign for both debit/credit AND amount_currency l1 = { - 'debit': direction * pay_amount>0 and direction * pay_amount, - 'credit': direction * pay_amount<0 and - direction * pay_amount, + 'debit': direction * pay_amount > 0 and direction * pay_amount, + 'credit': direction * pay_amount < 0 and - direction * pay_amount, 'account_id': src_account_id, 'partner_id': invoice.partner_id.id, 'ref':ref, @@ -1032,8 +1032,8 @@ class account_invoice(osv.osv): 'company_id': invoice.company_id.id, } l2 = { - 'debit': direction * pay_amount<0 and - direction * pay_amount, - 'credit': direction * pay_amount>0 and direction * pay_amount, + 'debit': direction * pay_amount < 0 and - direction * pay_amount, + 'credit': direction * pay_amount > 0 and direction * pay_amount, 'account_id': pay_account_id, 'partner_id': invoice.partner_id.id, 'ref':ref, @@ -1055,16 +1055,16 @@ class account_invoice(osv.osv): line_ids = [] total = 0.0 line = self.pool.get('account.move.line') - move_ids = [move_id,] + move_ids = [move_id, ] if invoice.move_id: move_ids.append(invoice.move_id.id) - cr.execute('SELECT id FROM account_move_line WHERE move_id = ANY(%s)',(move_ids,)) - lines = line.browse(cr, uid, map(lambda x: x[0], cr.fetchall()) ) - for l in lines+invoice.payment_ids: - if l.account_id.id==src_account_id: + cr.execute('SELECT id FROM account_move_line WHERE move_id = ANY(%s)', (move_ids,)) + lines = line.browse(cr, uid, map(lambda x: x[0], cr.fetchall())) + for l in lines + invoice.payment_ids: + if l.account_id.id == src_account_id: line_ids.append(l.id) total += (l.debit or 0.0) - (l.credit or 0.0) - if (not round(total,int(config['price_accuracy']))) or writeoff_acc_id: + if (not round(total, int(config['price_accuracy']))) or writeoff_acc_id: self.pool.get('account.move.line').reconcile(cr, uid, line_ids, 'manual', writeoff_acc_id, writeoff_period_id, writeoff_journal_id, context) else: self.pool.get('account.move.line').reconcile_partial(cr, uid, line_ids, 'manual', context) @@ -1075,16 +1075,16 @@ class account_invoice(osv.osv): account_invoice() class account_invoice_line(osv.osv): - def _amount_line(self, cr, uid, ids, prop, unknow_none,unknow_dict): + def _amount_line(self, cr, uid, ids, prop, unknow_none, unknow_dict): res = {} - cur_obj=self.pool.get('res.currency') + cur_obj = self.pool.get('res.currency') for line in self.browse(cr, uid, ids): if line.invoice_id: - res[line.id] = line.price_unit * line.quantity * (1-(line.discount or 0.0)/100.0) + res[line.id] = line.price_unit * line.quantity * (1 - (line.discount or 0.0) / 100.0) cur = line.invoice_id.currency_id res[line.id] = cur_obj.round(cr, uid, cur, res[line.id]) else: - res[line.id] = round(line.price_unit * line.quantity * (1-(line.discount or 0.0)/100.0),int(config['price_accuracy'])) + res[line.id] = round(line.price_unit * line.quantity * (1 - (line.discount or 0.0) / 100.0), int(config['price_accuracy'])) return res @@ -1096,12 +1096,12 @@ class account_invoice_line(osv.osv): for l in context.get('invoice_line', {}): if isinstance(l, (list, tuple)) and len(l) >= 3 and l[2]: tax_obj = self.pool.get('account.tax') - p = l[2].get('price_unit', 0) * (1-l[2].get('discount', 0)/100.0) + p = l[2].get('price_unit', 0) * (1 - l[2].get('discount', 0) / 100.0) t = t - (p * l[2].get('quantity')) taxes = l[2].get('invoice_line_tax_id') if len(taxes[0]) >= 3 and taxes[0][2]: - taxes=tax_obj.browse(cr, uid, taxes[0][2]) - for tax in tax_obj.compute(cr, uid, taxes, p,l[2].get('quantity'), context.get('address_invoice_id', False), l[2].get('product_id', False), context.get('partner_id', False)): + taxes = tax_obj.browse(cr, uid, taxes[0][2]) + for tax in tax_obj.compute(cr, uid, taxes, p, l[2].get('quantity'), context.get('address_invoice_id', False), l[2].get('product_id', False), context.get('partner_id', False)): t = t - tax['amount'] return t return 0 @@ -1114,19 +1114,19 @@ class account_invoice_line(osv.osv): 'invoice_id': fields.many2one('account.invoice', 'Invoice Reference', ondelete='cascade', select=True), 'uos_id': fields.many2one('product.uom', 'Unit of Measure', ondelete='set null'), 'product_id': fields.many2one('product.product', 'Product', ondelete='set null'), - 'account_id': fields.many2one('account.account', 'Account', required=True, domain=[('type','<>','view'), ('type', '<>', 'closed')], help="The income or expense account related to the selected product."), + 'account_id': fields.many2one('account.account', 'Account', required=True, domain=[('type', '<>', 'view'), ('type', '<>', 'closed')], help="The income or expense account related to the selected product."), 'price_unit': fields.float('Unit Price', required=True, digits=(16, int(config['price_accuracy']))), - 'price_subtotal': fields.function(_amount_line, method=True, string='Subtotal',store=True, type="float", digits=(16, int(config['price_accuracy']))), + 'price_subtotal': fields.function(_amount_line, method=True, string='Subtotal', store=True, type="float", digits=(16, int(config['price_accuracy']))), 'quantity': fields.float('Quantity', required=True), 'discount': fields.float('Discount (%)', digits=(16, int(config['price_accuracy']))), - 'invoice_line_tax_id': fields.many2many('account.tax', 'account_invoice_line_tax', 'invoice_line_id', 'tax_id', 'Taxes', domain=[('parent_id','=',False)]), + 'invoice_line_tax_id': fields.many2many('account.tax', 'account_invoice_line_tax', 'invoice_line_id', 'tax_id', 'Taxes', domain=[('parent_id', '=', False)]), 'note': fields.text('Notes', translate=True), 'account_analytic_id': fields.many2one('account.analytic.account', 'Analytic Account'), - 'company_id': fields.related('invoice_id','company_id',type='many2one',relation='res.company',string='Company',store=True) + 'company_id': fields.related('invoice_id', 'company_id', type='many2one', relation='res.company', string='Company', store=True) } _defaults = { - 'quantity': lambda *a: 1, - 'discount': lambda *a: 0.0, + 'quantity': lambda * a: 1, + 'discount': lambda * a: 0.0, 'price_unit': _price_unit_default, } @@ -1136,14 +1136,14 @@ class account_invoice_line(osv.osv): taxes = tax_obj.browse(cr, uid, tax_id) for tax in tax_obj.compute_inv(cr, uid, taxes, price_unit, qty, address_invoice_id, product, partner_id): price_unit = price_unit - tax['amount'] - return {'price_unit': price_unit,'invoice_line_tax_id': tax_id} + return {'price_unit': price_unit, 'invoice_line_tax_id': tax_id} def product_id_change(self, cr, uid, ids, product, uom, qty=0, name='', type='out_invoice', partner_id=False, fposition_id=False, price_unit=False, address_invoice_id=False, currency_id=False, context=None): if context is None: context = {} - company_id = context.get('company_id',False) + company_id = context.get('company_id', False) if not partner_id: - raise osv.except_osv(_('No Partner Defined !'),_("You must first select a partner !") ) + raise osv.except_osv(_('No Partner Defined !'), _("You must first select a partner !")) if not product: if type in ('in_invoice', 'in_refund'): return {'value': {'categ_id': False}, 'domain':{'product_uom':[]}} @@ -1152,18 +1152,18 @@ class account_invoice_line(osv.osv): part = self.pool.get('res.partner').browse(cr, uid, partner_id) fpos = fposition_id and self.pool.get('account.fiscal.position').browse(cr, uid, fposition_id) or False - lang=part.lang + lang = part.lang context.update({'lang': lang}) result = {} res = self.pool.get('product.product').browse(cr, uid, product, context=context) if company_id: - in_pro_id = self.pool.get('ir.property').search(cr,uid,[('name','=','property_account_income'),('res_id','=','product.template,'+str(res.product_tmpl_id.id)+''),('company_id','=',company_id)]) + in_pro_id = self.pool.get('ir.property').search(cr, uid, [('name', '=', 'property_account_income'), ('res_id', '=', 'product.template,' + str(res.product_tmpl_id.id) + ''), ('company_id', '=', company_id)]) if not in_pro_id: - in_pro_id = self.pool.get('ir.property').search(cr,uid,[('name','=','property_account_income_categ'),('res_id','=','product.template,'+str(res.categ_id.id)+''),('company_id','=',company_id)]) - exp_pro_id = self.pool.get('ir.property').search(cr,uid,[('name','=','property_account_expense'),('res_id','=','product.template,'+str(res.product_tmpl_id.id)+''),('company_id','=',company_id)]) + in_pro_id = self.pool.get('ir.property').search(cr, uid, [('name', '=', 'property_account_income_categ'), ('res_id', '=', 'product.template,' + str(res.categ_id.id) + ''), ('company_id', '=', company_id)]) + exp_pro_id = self.pool.get('ir.property').search(cr, uid, [('name', '=', 'property_account_expense'), ('res_id', '=', 'product.template,' + str(res.product_tmpl_id.id) + ''), ('company_id', '=', company_id)]) if not exp_pro_id: - exp_pro_id = self.pool.get('ir.property').search(cr,uid,[('name','=','property_account_expense_categ'),('res_id','=','product.template,'+str(res.categ_id.id)+''),('company_id','=',company_id)]) + exp_pro_id = self.pool.get('ir.property').search(cr, uid, [('name', '=', 'property_account_expense_categ'), ('res_id', '=', 'product.template,' + str(res.categ_id.id) + ''), ('company_id', '=', company_id)]) if not in_pro_id: in_acc = res.product_tmpl_id.property_account_income @@ -1173,7 +1173,7 @@ class account_invoice_line(osv.osv): else: app_acc_in = in_acc_cate else: - app_acc_in = self.pool.get('account.account').browse(cr,uid,in_pro_id)[0] + app_acc_in = self.pool.get('account.account').browse(cr, uid, in_pro_id)[0] if not exp_pro_id: ex_acc = res.product_tmpl_id.property_account_expense ex_acc_cate = res.categ_id.property_account_expense_categ @@ -1182,7 +1182,7 @@ class account_invoice_line(osv.osv): else: app_acc_exp = ex_acc_cate else: - app_acc_exp = self.pool.get('account.account').browse(cr,uid,exp_pro_id)[0] + app_acc_exp = self.pool.get('account.account').browse(cr, uid, exp_pro_id)[0] if not in_pro_id and not exp_pro_id: in_acc = res.product_tmpl_id.property_account_income in_acc_cate = res.categ_id.property_account_income_categ @@ -1198,13 +1198,13 @@ class account_invoice_line(osv.osv): # app_acc_in = self.pool.get('account.account').browse(cr,uid,in_pro_id)[0] # app_acc_exp = self.pool.get('account.account').browse(cr,uid,exp_pro_id)[0] if app_acc_in.company_id.id != company_id and app_acc_exp.company_id.id != company_id: - in_res_id=self.pool.get('account.account').search(cr,uid,[('name','=',app_acc_in.name),('company_id','=',company_id)]) - exp_res_id=self.pool.get('account.account').search(cr,uid,[('name','=',app_acc_exp.name),('company_id','=',company_id)]) + in_res_id = self.pool.get('account.account').search(cr, uid, [('name', '=', app_acc_in.name), ('company_id', '=', company_id)]) + exp_res_id = self.pool.get('account.account').search(cr, uid, [('name', '=', app_acc_exp.name), ('company_id', '=', company_id)]) if not in_res_id and not exp_res_id: raise osv.except_osv(_('Configration Error !'), _('Can not find account chart for this company, Please Create account.')) - in_obj_acc=self.pool.get('account.account').browse(cr,uid,in_res_id) - exp_obj_acc=self.pool.get('account.account').browse(cr,uid,exp_res_id) + in_obj_acc = self.pool.get('account.account').browse(cr, uid, in_res_id) + exp_obj_acc = self.pool.get('account.account').browse(cr, uid, exp_res_id) if in_acc or ex_acc: res.product_tmpl_id.property_account_income = in_obj_acc[0] res.product_tmpl_id.property_account_expense = exp_obj_acc[0] @@ -1212,12 +1212,12 @@ class account_invoice_line(osv.osv): res.categ_id.property_account_income_categ = in_obj_acc[0] res.categ_id.property_account_expense_categ = exp_obj_acc[0] - if type in ('out_invoice','out_refund'): - a = res.product_tmpl_id.property_account_income.id + if type in ('out_invoice', 'out_refund'): + a = res.product_tmpl_id.property_account_income.id if not a: a = res.categ_id.property_account_income_categ.id else: - a = res.product_tmpl_id.property_account_expense.id + a = res.product_tmpl_id.property_account_expense.id if not a: a = res.categ_id.property_account_expense_categ.id @@ -1225,13 +1225,13 @@ class account_invoice_line(osv.osv): if a: result['account_id'] = a - taxep=None + taxep = None tax_obj = self.pool.get('account.tax') if type in ('out_invoice', 'out_refund'): - taxes = res.taxes_id and res.taxes_id or (a and self.pool.get('account.account').browse(cr, uid,a).tax_ids or False) + taxes = res.taxes_id and res.taxes_id or (a and self.pool.get('account.account').browse(cr, uid, a).tax_ids or False) tax_id = self.pool.get('account.fiscal.position').map_tax(cr, uid, fpos, taxes) else: - taxes = res.supplier_taxes_id and res.supplier_taxes_id or (a and self.pool.get('account.account').browse(cr, uid,a).tax_ids or False) + taxes = res.supplier_taxes_id and res.supplier_taxes_id or (a and self.pool.get('account.account').browse(cr, uid, a).tax_ids or False) tax_id = self.pool.get('account.fiscal.position').map_tax(cr, uid, fpos, taxes) if type in ('in_invoice', 'in_refund'): to_update = self.product_id_change_unit_price_inv(cr, uid, tax_id, price_unit or res.standard_price, qty, address_invoice_id, product, partner_id, context=context) @@ -1247,9 +1247,9 @@ class account_invoice_line(osv.osv): if result['uos_id']: res2 = res.uom_id.category_id.id if res2 : - domain = {'uos_id':[('category_id','=',res2 )]} + domain = {'uos_id':[('category_id', '=', res2)]} - prod_pool=self.pool.get('product.product') + prod_pool = self.pool.get('product.product') result['categ_id'] = res.categ_id.id res_final = {'value':result, 'domain':domain} @@ -1283,7 +1283,7 @@ class account_invoice_line(osv.osv): if not mres: continue res.append(mres) - tax_code_found= False + tax_code_found = False for tax in tax_obj.compute(cr, uid, line.invoice_line_tax_id, (line.price_unit * (1.0 - (line['discount'] or 0.0) / 100.0)), line.quantity, inv.address_invoice_id.id, line.product_id, @@ -1342,44 +1342,44 @@ class account_invoice_tax(osv.osv): _columns = { 'invoice_id': fields.many2one('account.invoice', 'Invoice Line', ondelete='cascade', select=True), 'name': fields.char('Tax Description', size=64, required=True), - 'account_id': fields.many2one('account.account', 'Tax Account', required=True, domain=[('type','<>','view'),('type','<>','income'), ('type', '<>', 'closed')]), - 'base': fields.float('Base', digits=(16,int(config['price_accuracy']))), - 'amount': fields.float('Amount', digits=(16,int(config['price_accuracy']))), + 'account_id': fields.many2one('account.account', 'Tax Account', required=True, domain=[('type', '<>', 'view'), ('type', '<>', 'income'), ('type', '<>', 'closed')]), + 'base': fields.float('Base', digits=(16, int(config['price_accuracy']))), + 'amount': fields.float('Amount', digits=(16, int(config['price_accuracy']))), 'manual': fields.boolean('Manual'), 'sequence': fields.integer('Sequence', help="Gives the sequence order when displaying a list of invoice tax."), 'base_code_id': fields.many2one('account.tax.code', 'Base Code', help="The account basis of the tax declaration."), - 'base_amount': fields.float('Base Code Amount', digits=(16,int(config['price_accuracy']))), + 'base_amount': fields.float('Base Code Amount', digits=(16, int(config['price_accuracy']))), 'tax_code_id': fields.many2one('account.tax.code', 'Tax Code', help="The tax basis of the tax declaration."), - 'tax_amount': fields.float('Tax Code Amount', digits=(16,int(config['price_accuracy']))), - 'company_id': fields.related('account_id','company_id',type='many2one',relation='res.company',string='Company',store=True), + 'tax_amount': fields.float('Tax Code Amount', digits=(16, int(config['price_accuracy']))), + 'company_id': fields.related('account_id', 'company_id', type='many2one', relation='res.company', string='Company', store=True), } - def base_change(self, cr, uid, ids, base,currency_id=False,company_id=False,date_invoice=False): + def base_change(self, cr, uid, ids, base, currency_id=False, company_id=False, date_invoice=False): cur_obj = self.pool.get('res.currency') company_obj = self.pool.get('res.company') - company_currency=False + company_currency = False if company_id: - company_currency = company_obj.read(cr,uid,[company_id],['currency_id'])[0]['currency_id'][0] + company_currency = company_obj.read(cr, uid, [company_id], ['currency_id'])[0]['currency_id'][0] if currency_id and company_currency: base = cur_obj.compute(cr, uid, currency_id, company_currency, base, context={'date': date_invoice or time.strftime('%Y-%m-%d')}, round=False) return {'value': {'base_amount':base}} - def amount_change(self, cr, uid, ids, amount,currency_id=False,company_id=False,date_invoice=False): + def amount_change(self, cr, uid, ids, amount, currency_id=False, company_id=False, date_invoice=False): cur_obj = self.pool.get('res.currency') company_obj = self.pool.get('res.company') - company_currency=False + company_currency = False if company_id: - company_currency = company_obj.read(cr,uid,[company_id],['currency_id'])[0]['currency_id'][0] + company_currency = company_obj.read(cr, uid, [company_id], ['currency_id'])[0]['currency_id'][0] if currency_id and company_currency: amount = cur_obj.compute(cr, uid, currency_id, company_currency, amount, context={'date': date_invoice or time.strftime('%Y-%m-%d')}, round=False) return {'value': {'tax_amount':amount}} _order = 'sequence' _defaults = { - 'manual': lambda *a: 1, - 'base_amount': lambda *a: 0.0, - 'tax_amount': lambda *a: 0.0, + 'manual': lambda * a: 1, + 'base_amount': lambda * a: 0.0, + 'tax_amount': lambda * a: 0.0, } def compute(self, cr, uid, invoice_id, context={}): tax_grouped = {} @@ -1390,8 +1390,8 @@ class account_invoice_tax(osv.osv): company_currency = inv.company_id.currency_id.id for line in inv.invoice_line: - for tax in tax_obj.compute(cr, uid, line.invoice_line_tax_id, (line.price_unit* (1-(line.discount or 0.0)/100.0)), line.quantity, inv.address_invoice_id.id, line.product_id, inv.partner_id): - val={} + for tax in tax_obj.compute(cr, uid, line.invoice_line_tax_id, (line.price_unit * (1 - (line.discount or 0.0) / 100.0)), line.quantity, inv.address_invoice_id.id, line.product_id, inv.partner_id): + val = {} val['invoice_id'] = inv.id val['name'] = tax['name'] val['amount'] = tax['amount'] @@ -1399,7 +1399,7 @@ class account_invoice_tax(osv.osv): val['sequence'] = tax['sequence'] val['base'] = tax['price_unit'] * line['quantity'] - if inv.type in ('out_invoice','in_invoice'): + if inv.type in ('out_invoice', 'in_invoice'): val['base_code_id'] = tax['base_code_id'] val['tax_code_id'] = tax['tax_code_id'] val['base_amount'] = cur_obj.compute(cr, uid, inv.currency_id.id, company_currency, val['base'] * tax['base_sign'], context={'date': inv.date_invoice or time.strftime('%Y-%m-%d')}, round=False) diff --git a/addons/account/partner.py b/addons/account/partner.py index 215c4286315..4257c262c8b 100644 --- a/addons/account/partner.py +++ b/addons/account/partner.py @@ -45,7 +45,7 @@ class account_fiscal_position(osv.osv): if tax.tax_src_id.id == t.id: if tax.tax_dest_id: result.append(tax.tax_dest_id.id) - ok=True + ok = True if not ok: result.append(t.id) return result @@ -54,7 +54,7 @@ class account_fiscal_position(osv.osv): if not fposition_id : return account_id for pos in fposition_id.account_ids: - if pos.account_src_id.id==account_id: + if pos.account_src_id.id == account_id: account_id = pos.account_dest_id.id break return account_id @@ -79,8 +79,8 @@ class account_fiscal_position_account(osv.osv): _rec_name = 'position_id' _columns = { 'position_id': fields.many2one('account.fiscal.position', 'Fiscal Position', required=True, ondelete='cascade'), - 'account_src_id': fields.many2one('account.account', 'Account Source', domain=[('type','<>','view')], required=True), - 'account_dest_id': fields.many2one('account.account', 'Account Destination', domain=[('type','<>','view')], required=True) + 'account_src_id': fields.many2one('account.account', 'Account Source', domain=[('type', '<>', 'view')], required=True), + 'account_dest_id': fields.many2one('account.account', 'Account Destination', domain=[('type', '<>', 'view')], required=True) } account_fiscal_position_account() @@ -100,10 +100,10 @@ class res_partner(osv.osv): a.type =ANY(%s) and l.partner_id =ANY(%s) and l.reconcile_id is null and - """+query+""" + """ + query + """ group by l.partner_id, a.type - """,(['receivable','payable'],ids,)) + """, (['receivable', 'payable'], ids,)) tinvert = { 'credit': 'receivable', 'debit': 'payable' @@ -112,32 +112,32 @@ class res_partner(osv.osv): res = {} for id in ids: res[id] = {}.fromkeys(field_names, 0) - for pid,type,val in cr.fetchall(): - if val is None: val=0 - res[pid][maps[type]] = (type=='receivable') and val or -val + for pid, type, val in cr.fetchall(): + if val is None: val = 0 + res[pid][maps[type]] = (type == 'receivable') and val or - val return res def _credit_search(self, cr, uid, obj, name, args, context): if not len(args): return [] - where = ' and '.join(map(lambda x: '(sum(debit-credit)'+x[1]+str(x[2])+')',args)) + where = ' and '.join(map(lambda x: '(sum(debit-credit)' + x[1] + str(x[2]) + ')', args)) query = self.pool.get('account.move.line')._query_get(cr, uid, context={}) - cr.execute(('select partner_id from account_move_line l where account_id in (select id from account_account where type=%s and active) and reconcile_id is null and '+query+' and partner_id is not null group by partner_id having '+where), ('receivable',) ) + cr.execute(('select partner_id from account_move_line l where account_id in (select id from account_account where type=%s and active) and reconcile_id is null and ' + query + ' and partner_id is not null group by partner_id having ' + where), ('receivable',)) res = cr.fetchall() if not len(res): - return [('id','=','0')] - return [('id','in',map(lambda x:x[0], res))] + return [('id', '=', '0')] + return [('id', 'in', map(lambda x:x[0], res))] def _debit_search(self, cr, uid, obj, name, args, context): if not len(args): return [] query = self.pool.get('account.move.line')._query_get(cr, uid, context={}) - where = ' and '.join(map(lambda x: '(sum(debit-credit)'+x[1]+str(x[2])+')',args)) - cr.execute(('select partner_id from account_move_line l where account_id in (select id from account_account where type=%s and active) and reconcile_id is null and '+query+' and partner_id is not null group by partner_id having '+where), ('payable',) ) + where = ' and '.join(map(lambda x: '(sum(debit-credit)' + x[1] + str(x[2]) + ')', args)) + cr.execute(('select partner_id from account_move_line l where account_id in (select id from account_account where type=%s and active) and reconcile_id is null and ' + query + ' and partner_id is not null group by partner_id having ' + where), ('payable',)) res = cr.fetchall() if not len(res): - return [('id','=','0')] - return [('id','in',map(lambda x:x[0], res))] + return [('id', '=', '0')] + return [('id', 'in', map(lambda x:x[0], res))] _columns = { 'credit': fields.function(_credit_debit_get, @@ -177,7 +177,7 @@ class res_partner(osv.osv): 'account.payment.term', type='many2one', relation='account.payment.term', - string ='Payment Term', + string='Payment Term', method=True, view_load=True, help="This payment term will be used instead of the default one for the current partner"), diff --git a/addons/account/product.py b/addons/account/product.py index b2963a34fec..9d76f99fa98 100644 --- a/addons/account/product.py +++ b/addons/account/product.py @@ -53,10 +53,10 @@ class product_template(osv.osv): _columns = { 'taxes_id': fields.many2many('account.tax', 'product_taxes_rel', 'prod_id', 'tax_id', 'Customer Taxes', - domain=[('parent_id','=',False),('type_tax_use','in',['sale','all'])]), + domain=[('parent_id', '=', False), ('type_tax_use', 'in', ['sale', 'all'])]), 'supplier_taxes_id': fields.many2many('account.tax', 'product_supplier_taxes_rel', 'prod_id', 'tax_id', - 'Supplier Taxes', domain=[('parent_id', '=', False),('type_tax_use','in',['purchase','all'])]), + 'Supplier Taxes', domain=[('parent_id', '=', False), ('type_tax_use', 'in', ['purchase', 'all'])]), 'property_account_income': fields.property( 'account.account', type='many2one', diff --git a/addons/account/project/project.py b/addons/account/project/project.py index a844d6dec2e..ba08491bd18 100644 --- a/addons/account/project/project.py +++ b/addons/account/project/project.py @@ -31,22 +31,22 @@ class account_analytic_journal(osv.osv): 'name' : fields.char('Journal name', size=64, required=True), 'code' : fields.char('Journal code', size=8), 'active' : fields.boolean('Active', help="If the active field is set to true, it will allow you to hide the analytic journal without removing it."), - 'type': fields.selection([('sale','Sale'), ('purchase','Purchase'), ('cash','Cash'), ('general','General'), ('situation','Situation')], 'Type', size=32, required=True, help="Gives the type of the analytic journal. When it needs for a document (eg: an invoice) to create analytic entries, Open ERP will look for a matching journal of the same type."), + 'type': fields.selection([('sale', 'Sale'), ('purchase', 'Purchase'), ('cash', 'Cash'), ('general', 'General'), ('situation', 'Situation')], 'Type', size=32, required=True, help="Gives the type of the analytic journal. When it needs for a document (eg: an invoice) to create analytic entries, Open ERP will look for a matching journal of the same type."), 'line_ids' : fields.one2many('account.analytic.line', 'journal_id', 'Lines'), 'company_id': fields.many2one('res.company', 'Company', required=True), } _defaults = { - 'active': lambda *a: True, - 'type': lambda *a: 'general', - 'company_id': lambda self,cr,uid,c: self.pool.get('res.users').browse(cr, uid, uid, c).company_id.id, + 'active': lambda * a: True, + 'type': lambda * a: 'general', + 'company_id': lambda self, cr, uid, c: self.pool.get('res.users').browse(cr, uid, uid, c).company_id.id, } account_analytic_journal() class account_journal(osv.osv): - _inherit="account.journal" + _inherit = "account.journal" _columns = { - 'analytic_journal_id':fields.many2one('account.analytic.journal','Analytic Journal'), + 'analytic_journal_id':fields.many2one('account.analytic.journal', 'Analytic Journal'), } account_journal() diff --git a/addons/account/project/report/account_journal.py b/addons/account/project/report/account_journal.py index 4f7768a7b19..c91cff31bab 100644 --- a/addons/account/project/report/account_journal.py +++ b/addons/account/project/report/account_journal.py @@ -42,7 +42,7 @@ class journal_print(report_sxw.rml_parse): 'lines': self.lines, 'sum_lines': self._sum_lines, } -report_sxw.report_sxw('report.account.analytic.journal.print', 'account.analytic.journal', 'addons/account/project/report/analytic_journal.rml',parser=journal_print) +report_sxw.report_sxw('report.account.analytic.journal.print', 'account.analytic.journal', 'addons/account/project/report/analytic_journal.rml', parser=journal_print) # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/account/project/report/analytic_balance.py b/addons/account/project/report/analytic_balance.py index f7b909ae452..04864966a32 100644 --- a/addons/account/project/report/analytic_balance.py +++ b/addons/account/project/report/analytic_balance.py @@ -27,7 +27,7 @@ from report import report_sxw class account_analytic_balance(report_sxw.rml_parse): def __init__(self, cr, uid, name, context): super(account_analytic_balance, self).__init__(cr, uid, name, context=context) - self.localcontext.update( { + self.localcontext.update({ 'time': time, 'get_objects': self._get_objects, 'lines_g': self._lines_g, @@ -50,10 +50,10 @@ class account_analytic_balance(report_sxw.rml_parse): def get_children(self, ids): ids2 = [] - read_data = self.pool.get('account.analytic.account').read(self.cr, self.uid, ids,['child_ids','code','complete_name','balance']) + read_data = self.pool.get('account.analytic.account').read(self.cr, self.uid, ids, ['child_ids', 'code', 'complete_name', 'balance']) for data in read_data: if (data['id'] not in self.acc_ids): - inculde_empty = True + inculde_empty = True if (not self.empty_acc) and data['balance'] == 0.00: inculde_empty = False if inculde_empty: @@ -103,7 +103,7 @@ class account_analytic_balance(report_sxw.rml_parse): def _move_sum(self, account_id, date1, date2, option): if account_id not in self.acc_data_dict: account_analytic_obj = self.pool.get('account.analytic.account') - ids = account_analytic_obj.search(self.cr, self.uid,[('parent_id', 'child_of', [account_id])]) + ids = account_analytic_obj.search(self.cr, self.uid, [('parent_id', 'child_of', [account_id])]) self.acc_data_dict[account_id] = ids else: ids = self.acc_data_dict[account_id] @@ -111,17 +111,17 @@ class account_analytic_balance(report_sxw.rml_parse): if option == "credit" : self.cr.execute("SELECT -sum(amount) FROM account_analytic_line \ WHERE account_id =ANY(%s) AND date>=%s AND date<=%s AND amount<0", - (ids,date1, date2)) + (ids, date1, date2)) elif option == "debit" : self.cr.execute("SELECT sum(amount) FROM account_analytic_line \ WHERE account_id =ANY(%s)\ AND date>=%s AND date<=%s AND amount>0", - (ids,date1, date2)) + (ids, date1, date2)) elif option == "quantity" : self.cr.execute("SELECT sum(unit_amount) FROM account_analytic_line \ WHERE account_id =ANY(%s)\ AND date>=%s AND date<=%s", - (ids,date1, date2)) + (ids, date1, date2)) return self.cr.fetchone()[0] or 0.0 @@ -150,7 +150,7 @@ class account_analytic_balance(report_sxw.rml_parse): def _move_sum_balance(self, account_id, date1, date2): debit = self._move_sum(account_id, date1, date2, 'debit') credit = self._move_sum(account_id, date1, date2, 'credit') - return (debit-credit) + return (debit - credit) # def _move_sum_quantity(self, account_id, date1, date2): # account_analytic_obj = self.pool.get('account.analytic.account') @@ -170,22 +170,22 @@ class account_analytic_balance(report_sxw.rml_parse): if not self.acc_sum_list: account_analytic_obj = self.pool.get('account.analytic.account') - ids2 = account_analytic_obj.search(self.cr, self.uid,[('parent_id', 'child_of', ids)]) + ids2 = account_analytic_obj.search(self.cr, self.uid, [('parent_id', 'child_of', ids)]) self.acc_sum_list = ids2 else: ids2 = self.acc_sum_list if option == "debit" : self.cr.execute("SELECT sum(amount) FROM account_analytic_line \ WHERE account_id =ANY(%s) AND date>=%s AND date<=%s AND amount>0", - (ids,date1, date2,)) + (ids, date1, date2,)) elif option == "credit" : self.cr.execute("SELECT -sum(amount) FROM account_analytic_line \ WHERE account_id =ANY(%s) AND date>=%s AND date<=%s AND amount<0", - (ids,date1, date2,)) + (ids, date1, date2,)) elif option == "quantity" : self.cr.execute("SELECT sum(unit_amount) FROM account_analytic_line \ WHERE account_id =ANY(%s)AND date>=%s AND date<=%s", - (ids,date1, date2,)) + (ids, date1, date2,)) return self.cr.fetchone()[0] or 0.0 @@ -221,7 +221,7 @@ class account_analytic_balance(report_sxw.rml_parse): def _sum_balance(self, accounts, date1, date2): debit = self._sum_all(accounts, date1, date2, 'debit') or 0.0 credit = self._sum_all(accounts, date1, date2, 'credit') or 0.0 - return (debit-credit) + return (debit - credit) # def _sum_quantity(self, accounts, date1, date2): # ids = map(lambda x: x['id'], accounts) diff --git a/addons/account/project/report/analytic_check.py b/addons/account/project/report/analytic_check.py index 0469c3b6918..49b0a7dfc58 100644 --- a/addons/account/project/report/analytic_check.py +++ b/addons/account/project/report/analytic_check.py @@ -30,7 +30,7 @@ class account_analytic_analytic_check(report_sxw.rml_parse): self.sum_gen_cred = 0.0 self.sum_ana_deb = 0.0 self.sum_ana_cred = 0.0 - self.localcontext.update( { + self.localcontext.update({ 'time': time, 'lines_p': self._lines_p, 'general_debit': self._gen_deb, @@ -69,7 +69,7 @@ class account_analytic_analytic_check(report_sxw.rml_parse): 'ana_debit': ad, 'ana_credit': ac, 'delta_debit': gd - ad, - 'delta_credit': gc - ac,}) + 'delta_credit': gc - ac, }) self.sum_gen_deb += gd self.sum_gen_cred += gc self.sum_ana_deb += ad @@ -125,12 +125,12 @@ class account_analytic_analytic_check(report_sxw.rml_parse): return self.sum_ana_cred def _delta_deb(self, date1, date2): - return (self._gen_deb(date1,date2)-self._ana_deb(date1,date2)) + return (self._gen_deb(date1, date2) - self._ana_deb(date1, date2)) def _delta_cred(self, date1, date2): - return (self._gen_cred(date1,date2)-self._ana_cred(date1,date2)) + return (self._gen_cred(date1, date2) - self._ana_cred(date1, date2)) -report_sxw.report_sxw('report.account.analytic.account.analytic.check', 'account.analytic.account', 'addons/account/project/report/analytic_check.rml',parser=account_analytic_analytic_check, header=False) +report_sxw.report_sxw('report.account.analytic.account.analytic.check', 'account.analytic.account', 'addons/account/project/report/analytic_check.rml', parser=account_analytic_analytic_check, header=False) # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/account/project/report/analytic_journal.py b/addons/account/project/report/analytic_journal.py index e3da7636c0a..8fe64565ccb 100644 --- a/addons/account/project/report/analytic_journal.py +++ b/addons/account/project/report/analytic_journal.py @@ -29,7 +29,7 @@ from report import report_sxw class account_analytic_journal(report_sxw.rml_parse): def __init__(self, cr, uid, name, context): super(account_analytic_journal, self).__init__(cr, uid, name, context=context) - self.localcontext.update( { + self.localcontext.update({ 'time': time, 'lines': self._lines, 'lines_a': self._lines_a, @@ -43,11 +43,11 @@ class account_analytic_journal(report_sxw.rml_parse): return self.pool.get('account.move.line').browse(self.cr, self.uid, ids) def _lines_a(self, move_id, journal_id, date1, date2): - ids = self.pool.get('account.analytic.line').search(self.cr, self.uid, [('move_id','=',move_id), ('journal_id','=',journal_id), ('date','>=',date1), ('date','<=',date2)]) + ids = self.pool.get('account.analytic.line').search(self.cr, self.uid, [('move_id', '=', move_id), ('journal_id', '=', journal_id), ('date', '>=', date1), ('date', '<=', date2)]) if not ids: return [] return self.pool.get('account.analytic.line').browse(self.cr, self.uid, ids) - + def _sum_general(self, journal_id, date1, date2): self.cr.execute('SELECT SUM(debit-credit) FROM account_move_line WHERE id IN (SELECT move_id FROM account_analytic_line WHERE (date>=%s) AND (date<=%s) AND (journal_id=%s) AND (move_id is not null))', (date1, date2, journal_id,)) return self.cr.fetchall()[0][0] or 0 @@ -57,7 +57,7 @@ class account_analytic_journal(report_sxw.rml_parse): res = self.cr.dictfetchone() return res['sum'] or 0 -report_sxw.report_sxw('report.account.analytic.journal', 'account.analytic.journal', 'addons/account/project/report/analytic_journal.rml',parser=account_analytic_journal,header=False) +report_sxw.report_sxw('report.account.analytic.journal', 'account.analytic.journal', 'addons/account/project/report/analytic_journal.rml', parser=account_analytic_journal, header=False) # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/account/project/report/cost_ledger.py b/addons/account/project/report/cost_ledger.py index 9163cd8e0d4..de91f040fb7 100644 --- a/addons/account/project/report/cost_ledger.py +++ b/addons/account/project/report/cost_ledger.py @@ -26,7 +26,7 @@ from report import report_sxw class account_analytic_cost_ledger(report_sxw.rml_parse): def __init__(self, cr, uid, name, context): super(account_analytic_cost_ledger, self).__init__(cr, uid, name, context=context) - self.localcontext.update( { + self.localcontext.update({ 'time': time, 'lines_g': self._lines_g, 'lines_a': self._lines_a, @@ -87,7 +87,7 @@ class account_analytic_cost_ledger(report_sxw.rml_parse): def _account_sum_balance(self, account_id, date1, date2): debit = self._account_sum_debit(account_id, date1, date2) credit = self._account_sum_credit(account_id, date1, date2) - return (debit-credit) + return (debit - credit) def _sum_debit(self, accounts, date1, date2): ids = map(lambda x: x.id, accounts) @@ -101,15 +101,15 @@ class account_analytic_cost_ledger(report_sxw.rml_parse): if not len(ids): return 0.0 ids = map(lambda x: x.id, accounts) - self.cr.execute("SELECT -sum(amount) FROM account_analytic_line WHERE account_id =ANY(%s) AND date>=%s AND date<=%s AND amount<0", (ids,date1, date2,)) + self.cr.execute("SELECT -sum(amount) FROM account_analytic_line WHERE account_id =ANY(%s) AND date>=%s AND date<=%s AND amount<0", (ids, date1, date2,)) return self.cr.fetchone()[0] or 0.0 def _sum_balance(self, accounts, date1, date2): debit = self._sum_debit(accounts, date1, date2) or 0.0 credit = self._sum_credit(accounts, date1, date2) or 0.0 - return (debit-credit) + return (debit - credit) -report_sxw.report_sxw('report.account.analytic.account.cost_ledger', 'account.analytic.account', 'addons/account/project/report/cost_ledger.rml',parser=account_analytic_cost_ledger, header=False) +report_sxw.report_sxw('report.account.analytic.account.cost_ledger', 'account.analytic.account', 'addons/account/project/report/cost_ledger.rml', parser=account_analytic_cost_ledger, header=False) # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/account/project/report/inverted_analytic_balance.py b/addons/account/project/report/inverted_analytic_balance.py index 37f469d4ef8..06e2b524162 100644 --- a/addons/account/project/report/inverted_analytic_balance.py +++ b/addons/account/project/report/inverted_analytic_balance.py @@ -26,7 +26,7 @@ from report import report_sxw class account_inverted_analytic_balance(report_sxw.rml_parse): def __init__(self, cr, uid, name, context): super(account_inverted_analytic_balance, self).__init__(cr, uid, name, context=context) - self.localcontext.update( { + self.localcontext.update({ 'time': time, 'lines_g': self._lines_g, 'lines_a': self._lines_a, @@ -41,7 +41,7 @@ class account_inverted_analytic_balance(report_sxw.rml_parse): self.cr.execute("SELECT aa.name AS name, aa.code AS code, sum(aal.amount) AS balance, sum(aal.unit_amount) AS quantity, aa.id AS id \ FROM account_analytic_line AS aal, account_account AS aa \ WHERE (aal.general_account_id=aa.id) AND (aal.account_id =ANY(%s)) AND (date>=%s) AND (date<=%s) AND aa.active \ - GROUP BY aal.general_account_id, aa.name, aa.code, aal.code, aa.id ORDER BY aal.code", (ids,date1,date2,)) + GROUP BY aal.general_account_id, aa.name, aa.code, aal.code, aa.id ORDER BY aal.code", (ids, date1, date2,)) res = self.cr.dictfetchall() for r in res: @@ -49,7 +49,7 @@ class account_inverted_analytic_balance(report_sxw.rml_parse): r['debit'] = r['balance'] r['credit'] = 0.0 elif r['balance'] < 0: - r['debit'] = 0.0 + r['debit'] = 0.0 r['credit'] = -r['balance'] else: r['debit'] = 0.0 @@ -61,7 +61,7 @@ class account_inverted_analytic_balance(report_sxw.rml_parse): self.cr.execute("SELECT sum(aal.amount) AS balance, sum(aal.unit_amount) AS quantity, aaa.code AS code, aaa.name AS name, account_id \ FROM account_analytic_line AS aal, account_analytic_account AS aaa \ WHERE aal.account_id=aaa.id AND aal.account_id =ANY(%s) AND aal.general_account_id=%s AND aal.date>=%s AND aal.date<=%s \ - GROUP BY aal.account_id, general_account_id, aaa.code, aaa.name ORDER BY aal.account_id", (ids,general_account_id, date1, date2,)) + GROUP BY aal.account_id, general_account_id, aaa.code, aaa.name ORDER BY aal.account_id", (ids, general_account_id, date1, date2,)) res = self.cr.dictfetchall() aaa_obj = self.pool.get('account.analytic.account') @@ -86,29 +86,29 @@ class account_inverted_analytic_balance(report_sxw.rml_parse): ids = map(lambda x: x.id, accounts) self.cr.execute("SELECT sum(amount) \ FROM account_analytic_line \ - WHERE account_id =ANY(%s) AND date>=%s AND date<=%s AND amount>0", (ids,date1, date2,)) + WHERE account_id =ANY(%s) AND date>=%s AND date<=%s AND amount>0", (ids, date1, date2,)) return self.cr.fetchone()[0] or 0.0 def _sum_credit(self, accounts, date1, date2): ids = map(lambda x: x.id, accounts) self.cr.execute("SELECT -sum(amount) \ FROM account_analytic_line \ - WHERE account_id =ANY(%s) AND date>=%s AND date<=%s AND amount<0", (ids,date1, date2,)) + WHERE account_id =ANY(%s) AND date>=%s AND date<=%s AND amount<0", (ids, date1, date2,)) return self.cr.fetchone()[0] or 0.0 def _sum_balance(self, accounts, date1, date2): debit = self._sum_debit(accounts, date1, date2) credit = self._sum_credit(accounts, date1, date2) - return (debit-credit) + return (debit - credit) def _sum_quantity(self, accounts, date1, date2): ids = map(lambda x: x.id, accounts) self.cr.execute("SELECT sum(unit_amount) \ FROM account_analytic_line \ - WHERE account_id =ANY(%s) AND date>=%s AND date<=%s", (ids,date1, date2,)) + WHERE account_id =ANY(%s) AND date>=%s AND date<=%s", (ids, date1, date2,)) return self.cr.fetchone()[0] or 0.0 -report_sxw.report_sxw('report.account.analytic.account.inverted.balance', 'account.analytic.account', 'addons/account/project/report/inverted_analytic_balance.rml',parser=account_inverted_analytic_balance, header=False) +report_sxw.report_sxw('report.account.analytic.account.inverted.balance', 'account.analytic.account', 'addons/account/project/report/inverted_analytic_balance.rml', parser=account_inverted_analytic_balance, header=False) # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/account/project/report/quantity_cost_ledger.py b/addons/account/project/report/quantity_cost_ledger.py index c841c2131ab..b9c29f1d358 100644 --- a/addons/account/project/report/quantity_cost_ledger.py +++ b/addons/account/project/report/quantity_cost_ledger.py @@ -26,7 +26,7 @@ from report import report_sxw class account_analytic_quantity_cost_ledger(report_sxw.rml_parse): def __init__(self, cr, uid, name, context): super(account_analytic_quantity_cost_ledger, self).__init__(cr, uid, name, context=context) - self.localcontext.update( { + self.localcontext.update({ 'time': time, 'lines_g': self._lines_g, 'lines_a': self._lines_a, @@ -54,7 +54,7 @@ class account_analytic_quantity_cost_ledger(report_sxw.rml_parse): AND aa.active \ AND (aal.journal_id =ANY(%s) ) \ GROUP BY aa.code, aa.name, aa.id ORDER BY aa.code", - (account_id, date1, date2,journal_ids)) + (account_id, date1, date2, journal_ids)) res = self.cr.dictfetchall() return res @@ -81,7 +81,7 @@ class account_analytic_quantity_cost_ledger(report_sxw.rml_parse): AND (aal.date>=%s) AND (aal.date<=%s) \ AND (aal.journal_id=aaj.id) AND (aaj.id =ANY(%s)) \ ORDER BY aal.date, aaj.code, aal.code", - (general_account_id, account_id, date1, date2,journal_ids,)) + (general_account_id, account_id, date1, date2, journal_ids,)) res = self.cr.dictfetchall() return res @@ -97,7 +97,7 @@ class account_analytic_quantity_cost_ledger(report_sxw.rml_parse): FROM account_analytic_line \ WHERE account_id = %s AND date >= %s AND date <= %s \ AND journal_id =ANY(%s)", - (account_id, date1, date2,journal_ids,)) + (account_id, date1, date2, journal_ids,)) return self.cr.fetchone()[0] or 0.0 def _sum_quantity(self, accounts, date1, date2, journals): @@ -108,13 +108,13 @@ class account_analytic_quantity_cost_ledger(report_sxw.rml_parse): self.cr.execute("SELECT sum(unit_amount) \ FROM account_analytic_line \ WHERE account_id =ANY(%s) AND date>=%s AND date<=%s", - (date1, date2,ids,)) + (date1, date2, ids,)) else: journal_ids = journals[0][2] self.cr.execute("SELECT sum(unit_amount) \ FROM account_analytic_line \ WHERE account_id =ANY(%s) AND date >= %s AND date <= %s \ - AND journal_id =ANY(%s)",(ids,date1, date2,journal_ids)) + AND journal_id =ANY(%s)", (ids, date1, date2, journal_ids)) return self.cr.fetchone()[0] or 0.0 report_sxw.report_sxw('report.account.analytic.account.quantity_cost_ledger', diff --git a/addons/account/project/wizard/wizard_account_analytic_analytic_check.py b/addons/account/project/wizard/wizard_account_analytic_analytic_check.py index a1bbbc50b8c..f34cb1e88bb 100644 --- a/addons/account/project/wizard/wizard_account_analytic_analytic_check.py +++ b/addons/account/project/wizard/wizard_account_analytic_analytic_check.py @@ -29,15 +29,15 @@ dates_form = ''' ''' dates_fields = { - 'date1': {'string':'Start of period', 'type':'date', 'required':True, 'default': lambda *a: time.strftime('%Y-01-01')}, - 'date2': {'string':'End of period', 'type':'date', 'required':True, 'default': lambda *a: time.strftime('%Y-%m-%d')}, + 'date1': {'string':'Start of period', 'type':'date', 'required':True, 'default': lambda * a: time.strftime('%Y-01-01')}, + 'date2': {'string':'End of period', 'type':'date', 'required':True, 'default': lambda * a: time.strftime('%Y-%m-%d')}, } class wizard_report(wizard.interface): states = { 'init': { - 'actions': [], - 'result': {'type':'form', 'arch':dates_form, 'fields':dates_fields, 'state':[('end','Cancel'), ('report','Print')]} + 'actions': [], + 'result': {'type':'form', 'arch':dates_form, 'fields':dates_fields, 'state':[('end', 'Cancel'), ('report', 'Print')]} }, 'report': { 'actions': [], diff --git a/addons/account/project/wizard/wizard_account_analytic_balance_report.py b/addons/account/project/wizard/wizard_account_analytic_balance_report.py index 916a123d745..dafdbba9960 100644 --- a/addons/account/project/wizard/wizard_account_analytic_balance_report.py +++ b/addons/account/project/wizard/wizard_account_analytic_balance_report.py @@ -30,8 +30,8 @@ dates_form = ''' ''' dates_fields = { - 'date1': {'string':'Start of Period', 'type':'date', 'required':True, 'default': lambda *a: time.strftime('%Y-01-01')}, - 'date2': {'string':'End of Period', 'type':'date', 'required':True, 'default': lambda *a: time.strftime('%Y-%m-%d')}, + 'date1': {'string':'Start of Period', 'type':'date', 'required':True, 'default': lambda * a: time.strftime('%Y-01-01')}, + 'date2': {'string':'End of Period', 'type':'date', 'required':True, 'default': lambda * a: time.strftime('%Y-%m-%d')}, 'empty_acc': {'string':'Empty Accounts ? ', 'type':'boolean', 'help':'Check if you want to display Accounts with 0 balance too.'}, } @@ -39,8 +39,8 @@ dates_fields = { class wizard_report(wizard.interface): states = { 'init': { - 'actions': [], - 'result': {'type':'form', 'arch':dates_form, 'fields':dates_fields, 'state':[('end','Cancel'), ('report','Print')]} + 'actions': [], + 'result': {'type':'form', 'arch':dates_form, 'fields':dates_fields, 'state':[('end', 'Cancel'), ('report', 'Print')]} }, 'report': { 'actions': [], diff --git a/addons/account/project/wizard/wizard_account_analytic_cost_ledger_for_journal_report.py b/addons/account/project/wizard/wizard_account_analytic_cost_ledger_for_journal_report.py index feafab05a47..fb180821314 100644 --- a/addons/account/project/wizard/wizard_account_analytic_cost_ledger_for_journal_report.py +++ b/addons/account/project/wizard/wizard_account_analytic_cost_ledger_for_journal_report.py @@ -32,9 +32,9 @@ _form = ''' ''' _fields = { - 'date1': {'string':'Start of period', 'type':'date', 'required':True, 'default': lambda *a: time.strftime('%Y-01-01')}, - 'date2': {'string':'End of period', 'type':'date', 'required':True, 'default': lambda *a: time.strftime('%Y-%m-%d')}, - 'journal': {'string':'Journals','type':'many2many', 'relation':'account.analytic.journal'}, + 'date1': {'string':'Start of period', 'type':'date', 'required':True, 'default': lambda * a: time.strftime('%Y-01-01')}, + 'date2': {'string':'End of period', 'type':'date', 'required':True, 'default': lambda * a: time.strftime('%Y-%m-%d')}, + 'journal': {'string':'Journals', 'type':'many2many', 'relation':'account.analytic.journal'}, } @@ -47,8 +47,8 @@ class wizard_report(wizard.interface): 'arch': _form, 'fields': _fields, 'state': [ - ('end','Cancel'), - ('report','Print') + ('end', 'Cancel'), + ('report', 'Print') ] } }, diff --git a/addons/account/project/wizard/wizard_account_analytic_cost_ledger_report.py b/addons/account/project/wizard/wizard_account_analytic_cost_ledger_report.py index 2469f7f5c0c..0aea77e7a1e 100644 --- a/addons/account/project/wizard/wizard_account_analytic_cost_ledger_report.py +++ b/addons/account/project/wizard/wizard_account_analytic_cost_ledger_report.py @@ -29,15 +29,15 @@ dates_form = ''' ''' dates_fields = { - 'date1': {'string':'Start of period', 'type':'date', 'required':True, 'default': lambda *a: time.strftime('%Y-01-01')}, - 'date2': {'string':'End of period', 'type':'date', 'required':True, 'default': lambda *a: time.strftime('%Y-%m-%d')}, + 'date1': {'string':'Start of period', 'type':'date', 'required':True, 'default': lambda * a: time.strftime('%Y-01-01')}, + 'date2': {'string':'End of period', 'type':'date', 'required':True, 'default': lambda * a: time.strftime('%Y-%m-%d')}, } class wizard_report(wizard.interface): states = { 'init': { 'actions': [], - 'result': {'type':'form', 'arch':dates_form, 'fields':dates_fields, 'state':[('end','Cancel'),('report','Print')]} + 'result': {'type':'form', 'arch':dates_form, 'fields':dates_fields, 'state':[('end', 'Cancel'), ('report', 'Print')]} }, 'report': { 'actions': [], diff --git a/addons/account/project/wizard/wizard_account_analytic_inverted_balance_report.py b/addons/account/project/wizard/wizard_account_analytic_inverted_balance_report.py index 9219a8ea9ae..fedebf32e91 100644 --- a/addons/account/project/wizard/wizard_account_analytic_inverted_balance_report.py +++ b/addons/account/project/wizard/wizard_account_analytic_inverted_balance_report.py @@ -29,15 +29,15 @@ dates_form = ''' ''' dates_fields = { - 'date1': {'string':'Start of period', 'type':'date', 'required':True, 'default': lambda *a: time.strftime('%Y-01-01')}, - 'date2': {'string':'End of period', 'type':'date', 'required':True, 'default': lambda *a: time.strftime('%Y-%m-%d')}, + 'date1': {'string':'Start of period', 'type':'date', 'required':True, 'default': lambda * a: time.strftime('%Y-01-01')}, + 'date2': {'string':'End of period', 'type':'date', 'required':True, 'default': lambda * a: time.strftime('%Y-%m-%d')}, } class wizard_report(wizard.interface): states = { 'init': { - 'actions': [], - 'result': {'type':'form', 'arch':dates_form, 'fields':dates_fields, 'state':[('end','Cancel'), ('report','Print')]} + 'actions': [], + 'result': {'type':'form', 'arch':dates_form, 'fields':dates_fields, 'state':[('end', 'Cancel'), ('report', 'Print')]} }, 'report': { 'actions': [], diff --git a/addons/account/project/wizard/wizard_account_analytic_journal_report.py b/addons/account/project/wizard/wizard_account_analytic_journal_report.py index 03be104469d..e19a3de75ee 100644 --- a/addons/account/project/wizard/wizard_account_analytic_journal_report.py +++ b/addons/account/project/wizard/wizard_account_analytic_journal_report.py @@ -29,15 +29,15 @@ dates_form = ''' ''' dates_fields = { - 'date1': {'string':'Start of period', 'type':'date', 'required':True, 'default': lambda *a: time.strftime('%Y-01-01')}, - 'date2': {'string':'End of period', 'type':'date', 'required':True, 'default': lambda *a: time.strftime('%Y-%m-%d')}, + 'date1': {'string':'Start of period', 'type':'date', 'required':True, 'default': lambda * a: time.strftime('%Y-01-01')}, + 'date2': {'string':'End of period', 'type':'date', 'required':True, 'default': lambda * a: time.strftime('%Y-%m-%d')}, } class wizard_report(wizard.interface): states = { 'init': { - 'actions': [], - 'result': {'type':'form', 'arch':dates_form, 'fields':dates_fields, 'state':[('end','Cancel'), ('report','Print')]} + 'actions': [], + 'result': {'type':'form', 'arch':dates_form, 'fields':dates_fields, 'state':[('end', 'Cancel'), ('report', 'Print')]} }, 'report': { 'actions': [], diff --git a/addons/account/project/wizard/wizard_account_analytic_line.py b/addons/account/project/wizard/wizard_account_analytic_line.py index e6ebd336c35..dd4348173d6 100644 --- a/addons/account/project/wizard/wizard_account_analytic_line.py +++ b/addons/account/project/wizard/wizard_account_analytic_line.py @@ -24,19 +24,19 @@ import pooler import time from tools.translate import _ -def _action_open_window(self, cr, uid, data, context): +def _action_open_window(self, cr, uid, data, context): domain = [] from_date = data['form']['from_date'] to_date = data['form']['to_date'] if from_date and to_date: - domain = [('date','>=',from_date),('date','<=',to_date)] + domain = [('date', '>=', from_date), ('date', '<=', to_date)] elif from_date: - domain = [('date','>=',from_date)] + domain = [('date', '>=', from_date)] elif to_date: - domain = [('date','<=',to_date)] + domain = [('date', '<=', to_date)] mod_obj = pooler.get_pool(cr.dbname).get('ir.model.data') result = mod_obj._get_id(cr, uid, 'account', 'view_account_analytic_line_filter') - id = mod_obj.read(cr, uid, result, ['res_id']) + id = mod_obj.read(cr, uid, result, ['res_id']) return { 'name': _('Analytic Entries'), @@ -45,7 +45,7 @@ def _action_open_window(self, cr, uid, data, context): 'res_model': 'account.analytic.line', 'type': 'ir.actions.act_window', 'domain': domain, - 'search_view_id': id['res_id'],} + 'search_view_id': id['res_id'], } class account_analytic_line(wizard.interface): @@ -73,7 +73,7 @@ class account_analytic_line(wizard.interface): states = { 'init': { 'actions': [], - 'result': {'type': 'form', 'arch':form1, 'fields':form1_fields, 'state': [('end', 'Cancel','gtk-cancel'),('open', 'Open Entries','gtk-ok')]} + 'result': {'type': 'form', 'arch':form1, 'fields':form1_fields, 'state': [('end', 'Cancel', 'gtk-cancel'), ('open', 'Open Entries', 'gtk-ok')]} }, 'open': { 'actions': [], diff --git a/addons/account/project/wizard/wizard_analytic_account_chart.py b/addons/account/project/wizard/wizard_analytic_account_chart.py index 354fe6e6046..41d81857744 100644 --- a/addons/account/project/wizard/wizard_analytic_account_chart.py +++ b/addons/account/project/wizard/wizard_analytic_account_chart.py @@ -57,8 +57,8 @@ class wizard_analytic_account_chart(wizard.interface): if data['form']['from_date']: result_context.update({'from_date' : data['form']['from_date']}) if data['form']['to_date']: - result_context.update({'to_date' : data['form']['to_date']}) - + result_context.update({'to_date' : data['form']['to_date']}) + result['context'] = str(result_context) return result diff --git a/addons/account/report/account_balance.py b/addons/account/report/account_balance.py index 1a93c371d20..be69494d2d8 100644 --- a/addons/account/report/account_balance.py +++ b/addons/account/report/account_balance.py @@ -45,36 +45,36 @@ class account_balance(report_sxw.rml_parse): self.context = context def get_fiscalyear(self, form): - res=[] + res = [] if form.has_key('fiscalyear'): fisc_id = form['fiscalyear'] if not (fisc_id): return '' self.cr.execute("select name from account_fiscalyear where id = %s" , (int(fisc_id),)) - res=self.cr.fetchone() + res = self.cr.fetchone() return res and res[0] or '' def get_periods(self, form): - result='' + result = '' if form.has_key('periods') and form['periods'][0][2]: period_ids = form['periods'][0][2] - self.cr.execute("select name from account_period where id =ANY(%s)" ,(period_ids)) + self.cr.execute("select name from account_period where id =ANY(%s)" , (period_ids)) res = self.cr.fetchall() len_res = len(res) for r in res: - if (r == res[len_res-1]): - result+=r[0]+". " + if (r == res[len_res - 1]): + result += r[0] + ". " else: - result+=r[0]+", " + result += r[0] + ", " else: - fy_obj = self.pool.get('account.fiscalyear').browse(self.cr,self.uid,form['fiscalyear']) + fy_obj = self.pool.get('account.fiscalyear').browse(self.cr, self.uid, form['fiscalyear']) res = fy_obj.period_ids len_res = len(res) for r in res: - if r == res[len_res-1]: - result+=r.name+". " + if r == res[len_res - 1]: + result += r.name + ". " else: - result+=r.name+", " + result += r.name + ", " return str(result and result[:-1]) or '' @@ -85,24 +85,24 @@ class account_balance(report_sxw.rml_parse): if not ids: return [] if not done: - done={} + done = {} if form.has_key('Account_list') and form['Account_list']: ids = [form['Account_list']] del form['Account_list'] - res={} - result_acc=[] + res = {} + result_acc = [] ctx = self.context.copy() - ctx['state'] = form['context'].get('state','all') + ctx['state'] = form['context'].get('state', 'all') ctx['fiscalyear'] = form['fiscalyear'] - if form['state']=='byperiod' : + if form['state'] == 'byperiod' : ctx['periods'] = form['periods'][0][2] - elif form['state']== 'bydate': + elif form['state'] == 'bydate': ctx['date_from'] = form['date_from'] - ctx['date_to'] = form['date_to'] + ctx['date_to'] = form['date_to'] elif form['state'] == 'all' : ctx['periods'] = form['periods'][0][2] ctx['date_from'] = form['date_from'] - ctx['date_to'] = form['date_to'] + ctx['date_to'] = form['date_to'] # accounts = self.pool.get('account.account').browse(self.cr, self.uid, ids, ctx) # def cmp_code(x, y): # return cmp(x.code, y.code) @@ -110,7 +110,7 @@ class account_balance(report_sxw.rml_parse): child_ids = self.pool.get('account.account')._get_children_and_consol(self.cr, self.uid, ids, ctx) if child_ids: ids = child_ids - accounts = self.pool.get('account.account').read(self.cr, self.uid, ids,['type','code','name','debit','credit','balance','parent_id'], ctx) + accounts = self.pool.get('account.account').read(self.cr, self.uid, ids, ['type', 'code', 'name', 'debit', 'credit', 'balance', 'parent_id'], ctx) for account in accounts: if account['id'] in done: continue diff --git a/addons/account/report/account_journal.py b/addons/account/report/account_journal.py index 830f8152120..71b1e1cd727 100644 --- a/addons/account/report/account_journal.py +++ b/addons/account/report/account_journal.py @@ -29,7 +29,7 @@ from report import report_sxw class journal_print(report_sxw.rml_parse): def __init__(self, cr, uid, name, context): super(journal_print, self).__init__(cr, uid, name, context=context) - self.localcontext.update( { + self.localcontext.update({ 'time': time, 'lines': self.lines, 'sum_debit': self._sum_debit, @@ -37,27 +37,27 @@ class journal_print(report_sxw.rml_parse): }) def lines(self, period_id, journal_id, sort_selection='date', *args): - if type(period_id)==type([]): + if type(period_id) == type([]): ids_final = [] for journal in journal_id: for period in period_id: - ids_journal_period = self.pool.get('account.journal.period').search(self.cr,self.uid, [('journal_id','=',journal),('period_id','=',period)]) + ids_journal_period = self.pool.get('account.journal.period').search(self.cr, self.uid, [('journal_id', '=', journal), ('period_id', '=', period)]) if ids_journal_period: - self.cr.execute('update account_journal_period set state=%s where journal_id=%s and period_id=%s and state=%s', ('printed',journal,period,'draft')) + self.cr.execute('update account_journal_period set state=%s where journal_id=%s and period_id=%s and state=%s', ('printed', journal, period, 'draft')) self.cr.commit() - self.cr.execute('select id from account_move_line where period_id=%s and journal_id=%s and state<>\'draft\' order by ('+ sort_selection +'),id', (period, journal)) + self.cr.execute('select id from account_move_line where period_id=%s and journal_id=%s and state<>\'draft\' order by (' + sort_selection + '),id', (period, journal)) ids = map(lambda x: x[0], self.cr.fetchall()) ids_final.append(ids) line_ids = [] for line_id in ids_final: - a = self.pool.get('account.move.line').browse(self.cr, self.uid, line_id ) + a = self.pool.get('account.move.line').browse(self.cr, self.uid, line_id) line_ids.append(a) return line_ids - self.cr.execute('update account_journal_period set state=%s where journal_id=%s and period_id=%s and state=%s', ('printed',journal_id,period_id,'draft')) + self.cr.execute('update account_journal_period set state=%s where journal_id=%s and period_id=%s and state=%s', ('printed', journal_id, period_id, 'draft')) self.cr.commit() self.cr.execute('select id from account_move_line where period_id=%s and journal_id=%s and state<>\'draft\' order by date,id', (period_id, journal_id)) ids = map(lambda x: x[0], self.cr.fetchall()) - return self.pool.get('account.move.line').browse(self.cr, self.uid, ids ) + return self.pool.get('account.move.line').browse(self.cr, self.uid, ids) def _sum_debit(self, period_id, journal_id): self.cr.execute('select sum(debit) from account_move_line where period_id=%s and journal_id=%s and state<>\'draft\'', (period_id, journal_id)) @@ -66,8 +66,8 @@ class journal_print(report_sxw.rml_parse): def _sum_credit(self, period_id, journal_id): self.cr.execute('select sum(credit) from account_move_line where period_id=%s and journal_id=%s and state<>\'draft\'', (period_id, journal_id)) return self.cr.fetchone()[0] or 0.0 -report_sxw.report_sxw('report.account.journal.period.print', 'account.journal.period', 'addons/account/report/account_journal.rml', parser=journal_print,header=False) -report_sxw.report_sxw('report.account.journal.period.print.wiz', 'account.journal.period', 'addons/account/report/wizard_account_journal.rml', parser=journal_print,header=False) +report_sxw.report_sxw('report.account.journal.period.print', 'account.journal.period', 'addons/account/report/account_journal.rml', parser=journal_print, header=False) +report_sxw.report_sxw('report.account.journal.period.print.wiz', 'account.journal.period', 'addons/account/report/wizard_account_journal.rml', parser=journal_print, header=False) # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/account/report/account_tax_code.py b/addons/account/report/account_tax_code.py index f406d884ec8..e6e4bc6e842 100644 --- a/addons/account/report/account_tax_code.py +++ b/addons/account/report/account_tax_code.py @@ -57,7 +57,7 @@ class account_tax_code_report(rml_parse.rml_parse): }) def get_line(self, obj): - line_ids = self.pool.get('account.move.line').search(self.cr, self.uid, [('tax_code_id','=',obj.id)]) + line_ids = self.pool.get('account.move.line').search(self.cr, self.uid, [('tax_code_id', '=', obj.id)]) if not line_ids: return [] return map(_record_to_report_line, diff --git a/addons/account/report/aged_trial_balance.py b/addons/account/report/aged_trial_balance.py index c13ea96ea50..40c3c796d5c 100644 --- a/addons/account/report/aged_trial_balance.py +++ b/addons/account/report/aged_trial_balance.py @@ -46,12 +46,12 @@ class aged_trial_report(rml_parse.rml_parse): def _get_lines(self, form): - if (form['result_selection'] == 'customer' ): + if (form['result_selection'] == 'customer'): self.ACCOUNT_TYPE = ['receivable'] elif (form['result_selection'] == 'supplier'): self.ACCOUNT_TYPE = ['payable'] else: - self.ACCOUNT_TYPE = ['payable','receivable'] + self.ACCOUNT_TYPE = ['payable', 'receivable'] res = [] @@ -66,7 +66,7 @@ class aged_trial_report(rml_parse.rml_parse): OR (reconcile_id IN (SELECT recon.id FROM account_move_reconcile AS recon WHERE recon.create_date > %s ))) AND (line.partner_id=res_partner.id) AND (account_account.company_id = %s) - ORDER BY res_partner.name""" , (form['date1'],form['company_id'])) + ORDER BY res_partner.name""" , (form['date1'], form['company_id'])) partners = self.cr.dictfetchall() ## mise a 0 du total for i in range(7): @@ -87,7 +87,7 @@ class aged_trial_report(rml_parse.rml_parse): OR (reconcile_id IN (SELECT recon.id FROM account_move_reconcile AS recon WHERE recon.create_date > %s ))) AND (account_account.company_id = %s) AND account_account.active - GROUP BY partner_id""" , (self.ACCOUNT_TYPE, partner_ids,form['date1'],form['company_id'],)) + GROUP BY partner_id""" , (self.ACCOUNT_TYPE, partner_ids, form['date1'], form['company_id'],)) t = self.cr.fetchall() for i in t: totals[i[0]] = i[1] @@ -105,7 +105,7 @@ class aged_trial_report(rml_parse.rml_parse): OR (reconcile_id IN (SELECT recon.id FROM account_move_reconcile AS recon WHERE recon.create_date > %s ))) AND (account_account.company_id = %s) AND account_account.active - GROUP BY partner_id""", (self.ACCOUNT_TYPE, form['date1'], partner_ids,form['date1'], form['company_id'],)) + GROUP BY partner_id""", (self.ACCOUNT_TYPE, form['date1'], partner_ids, form['date1'], form['company_id'],)) t = self.cr.fetchall() for i in t: future_past[i[0]] = i[1] @@ -139,7 +139,7 @@ class aged_trial_report(rml_parse.rml_parse): OR (reconcile_id IN (SELECT recon.id FROM account_move_reconcile AS recon WHERE recon.create_date > %s ))) AND (account_account.company_id = %s) AND account_account.active - GROUP BY partner_id""" , (self.ACCOUNT_TYPE, form[str(i)]['start'], form[str(i)]['stop'],partner_ids ,form['date1'] ,form['company_id'],)) + GROUP BY partner_id""" , (self.ACCOUNT_TYPE, form[str(i)]['start'], form[str(i)]['stop'], partner_ids , form['date1'] , form['company_id'],)) t = self.cr.fetchall() d = {} @@ -177,11 +177,11 @@ class aged_trial_report(rml_parse.rml_parse): values[str(i)] = during and during[0] or "" total = False - if totals.has_key( partner['id'] ): + if totals.has_key(partner['id']): total = [ totals[partner['id']] ] values['total'] = total and total[0] or 0.0 ## Add for total - self.total_account[(i+1)] = self.total_account[(i+1)] + (total and total[0] or 0.0) + self.total_account[(i + 1)] = self.total_account[(i + 1)] + (total and total[0] or 0.0) values['name'] = partner['name'] #t = 0.0 #for i in range(5)+['direction']: @@ -195,20 +195,20 @@ class aged_trial_report(rml_parse.rml_parse): totals = {} for r in res: total += float(r['total'] or 0.0) - for i in range(5)+['direction']: + for i in range(5) + ['direction']: totals.setdefault(str(i), 0.0) totals[str(i)] += float(r[str(i)] or 0.0) return res - def _get_total(self,pos): + def _get_total(self, pos): period = self.total_account[int(pos)] return period - def _get_direction(self,pos): + def _get_direction(self, pos): period = self.total_account[int(pos)] return period - def _get_for_period(self,pos): + def _get_for_period(self, pos): period = self.total_account[int(pos)] return period @@ -220,7 +220,7 @@ class aged_trial_report(rml_parse.rml_parse): report_sxw.report_sxw('report.account.aged_trial_balance', 'res.partner', - 'addons/account/report/aged_trial_balance.rml',parser=aged_trial_report,header=False) + 'addons/account/report/aged_trial_balance.rml', parser=aged_trial_report, header=False) # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/account/report/central_journal.py b/addons/account/report/central_journal.py index 9bc2cfdd1b9..4fefa1e14bb 100644 --- a/addons/account/report/central_journal.py +++ b/addons/account/report/central_journal.py @@ -36,15 +36,15 @@ class journal_print(report_sxw.rml_parse): }) def lines(self, period_id, journal_id, *args): - if type(period_id)==type([]): + if type(period_id) == type([]): ids_final = [] for journal in journal_id: for period in period_id: - ids_journal_period = self.pool.get('account.journal.period').search(self.cr,self.uid, [('journal_id','=',journal),('period_id','=',period)]) + ids_journal_period = self.pool.get('account.journal.period').search(self.cr, self.uid, [('journal_id', '=', journal), ('period_id', '=', period)]) if ids_journal_period: self.cr.execute('select a.code, a.name, sum(debit) as debit, sum(credit) as credit from account_move_line l left join account_account a on (l.account_id=a.id) where l.period_id=%s and l.journal_id=%s and l.state<>\'draft\' group by a.id, a.code, a.name, l.journal_id, l.period_id', (period, journal)) res = self.cr.dictfetchall() - a = {'journal':self.pool.get('account.journal').browse(self.cr, self.uid, journal),'period':self.pool.get('account.period').browse(self.cr, self.uid, period)} + a = {'journal':self.pool.get('account.journal').browse(self.cr, self.uid, journal), 'period':self.pool.get('account.period').browse(self.cr, self.uid, period)} res[0].update(a) ids_final.append(res) return ids_final @@ -59,8 +59,8 @@ class journal_print(report_sxw.rml_parse): def _sum_credit(self, period_id, journal_id): self.cr.execute('select sum(credit) from account_move_line where period_id=%s and journal_id=%s and state<>\'draft\'', (period_id, journal_id)) return self.cr.fetchone()[0] or 0.0 -report_sxw.report_sxw('report.account.central.journal', 'account.journal.period', 'addons/account/report/central_journal.rml',parser=journal_print, header=False) -report_sxw.report_sxw('report.account.central.journal.wiz', 'account.journal.period', 'addons/account/report/wizard_central_journal.rml',parser=journal_print, header=False) +report_sxw.report_sxw('report.account.central.journal', 'account.journal.period', 'addons/account/report/central_journal.rml', parser=journal_print, header=False) +report_sxw.report_sxw('report.account.central.journal.wiz', 'account.journal.period', 'addons/account/report/wizard_central_journal.rml', parser=journal_print, header=False) # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/account/report/general_journal.py b/addons/account/report/general_journal.py index 2da07e04cfd..890c1625042 100644 --- a/addons/account/report/general_journal.py +++ b/addons/account/report/general_journal.py @@ -29,7 +29,7 @@ from report import report_sxw class journal_print(report_sxw.rml_parse): def __init__(self, cr, uid, name, context): super(journal_print, self).__init__(cr, uid, name, context=context) - self.localcontext.update( { + self.localcontext.update({ 'time': time, 'lines': self.lines, 'periods': self.periods, @@ -39,12 +39,12 @@ class journal_print(report_sxw.rml_parse): 'sum_credit': self._sum_credit }) - def set_context(self, objects, data, ids, report_type = None): + def set_context(self, objects, data, ids, report_type=None): super(journal_print, self).set_context(objects, data, ids, report_type) - self.cr.execute('select period_id, journal_id from account_journal_period where id =ANY(%s)',(ids,)) + self.cr.execute('select period_id, journal_id from account_journal_period where id =ANY(%s)', (ids,)) res = self.cr.fetchall() - self.period_ids = map(lambda x:x[0],res) - self.journal_ids = map(lambda x:x[1],res) + self.period_ids = map(lambda x:x[0], res) + self.journal_ids = map(lambda x:x[1], res) # returns a list of period objs def periods(self, journal_period_objs): @@ -59,11 +59,11 @@ class journal_print(report_sxw.rml_parse): return map(lambda x: x.period_id, filtered_objs) def lines(self, period_id, journal_id=[]): - if type(period_id)==type([]): + if type(period_id) == type([]): ids_final = [] for journal in journal_id: for period in period_id: - ids_journal_period = self.pool.get('account.journal.period').search(self.cr,self.uid, [('journal_id','=',journal),('period_id','=',period)]) + ids_journal_period = self.pool.get('account.journal.period').search(self.cr, self.uid, [('journal_id', '=', journal), ('period_id', '=', period)]) if ids_journal_period: ids_final.append(ids_journal_period[0]) data_jour_period = self.pool.get('account.journal.period').browse(self.cr, self.uid, ids_final) @@ -74,7 +74,7 @@ class journal_print(report_sxw.rml_parse): periods.append(data.period_id.id) for period in periods: period_data = self.pool.get('account.period').browse(self.cr, self.uid, period) - self.cr.execute('select j.code, j.name, sum(l.debit) as debit, sum(l.credit) as credit from account_move_line l left join account_journal j on (l.journal_id=j.id) where period_id=%s and journal_id =ANY(%s) and l.state<>\'draft\' group by j.id, j.code, j.name', (period,journal_id,)) + self.cr.execute('select j.code, j.name, sum(l.debit) as debit, sum(l.credit) as credit from account_move_line l left join account_journal j on (l.journal_id=j.id) where period_id=%s and journal_id =ANY(%s) and l.state<>\'draft\' group by j.id, j.code, j.name', (period, journal_id,)) res = self.cr.dictfetchall() res[0].update({'period_name':period_data.name}) res[0].update({'pid':period}) @@ -82,48 +82,48 @@ class journal_print(report_sxw.rml_parse): return lines_data if not self.journal_ids: return [] - self.cr.execute('select j.code, j.name, sum(l.debit) as debit, sum(l.credit) as credit from account_move_line l left join account_journal j on (l.journal_id=j.id) where period_id=%s and journal_id =ANY(%s) and l.state<>\'draft\' group by j.id, j.code, j.name', (period_id,self.journal_ids,)) + self.cr.execute('select j.code, j.name, sum(l.debit) as debit, sum(l.credit) as credit from account_move_line l left join account_journal j on (l.journal_id=j.id) where period_id=%s and journal_id =ANY(%s) and l.state<>\'draft\' group by j.id, j.code, j.name', (period_id, self.journal_ids,)) res = self.cr.dictfetchall() return res - def _sum_debit_period(self, period_id,journal_id=None): - if type(journal_id)==type([]): - self.cr.execute('select sum(debit) from account_move_line where period_id=%s and journal_id =ANY(%s) and state<>\'draft\'', (period_id,journal_id,)) + def _sum_debit_period(self, period_id, journal_id=None): + if type(journal_id) == type([]): + self.cr.execute('select sum(debit) from account_move_line where period_id=%s and journal_id =ANY(%s) and state<>\'draft\'', (period_id, journal_id,)) return self.cr.fetchone()[0] or 0.0 if not self.journal_ids: return 0.0 - self.cr.execute('select sum(debit) from account_move_line where period_id=%s and journal_id =ANY(%s) and state<>\'draft\'', (period_id,self.journal_ids,)) + self.cr.execute('select sum(debit) from account_move_line where period_id=%s and journal_id =ANY(%s) and state<>\'draft\'', (period_id, self.journal_ids,)) return self.cr.fetchone()[0] or 0.0 - def _sum_credit_period(self, period_id,journal_id=None): - if type(journal_id)==type([]): - self.cr.execute('select sum(credit) from account_move_line where period_id=%s and journal_id =ANY(%s) and state<>\'draft\'', (period_id,journal_id,)) + def _sum_credit_period(self, period_id, journal_id=None): + if type(journal_id) == type([]): + self.cr.execute('select sum(credit) from account_move_line where period_id=%s and journal_id =ANY(%s) and state<>\'draft\'', (period_id, journal_id,)) return self.cr.fetchone()[0] or 0.0 if not self.journal_ids: return 0.0 - self.cr.execute('select sum(credit) from account_move_line where period_id=%s and journal_id =ANY(%s) and state<>\'draft\'', (period_id,self.journal_ids,)) + self.cr.execute('select sum(credit) from account_move_line where period_id=%s and journal_id =ANY(%s) and state<>\'draft\'', (period_id, self.journal_ids,)) return self.cr.fetchone()[0] or 0.0 - def _sum_debit(self,period_id=None,journal_id=None): - if type(period_id)==type([]): - self.cr.execute('select sum(debit) from account_move_line where period_id =ANY(%s) and journal_id =ANY(%s) and state<>\'draft\'',(period_id,journal_id,)) + def _sum_debit(self, period_id=None, journal_id=None): + if type(period_id) == type([]): + self.cr.execute('select sum(debit) from account_move_line where period_id =ANY(%s) and journal_id =ANY(%s) and state<>\'draft\'', (period_id, journal_id,)) return self.cr.fetchone()[0] or 0.0 if not self.journal_ids or not self.period_ids: return 0.0 - self.cr.execute('select sum(debit) from account_move_line where period_id =ANY(%s) and journal_id =ANY(%s) and state<>\'draft\'',(self.period_ids,self.journal_ids,)) + self.cr.execute('select sum(debit) from account_move_line where period_id =ANY(%s) and journal_id =ANY(%s) and state<>\'draft\'', (self.period_ids, self.journal_ids,)) return self.cr.fetchone()[0] or 0.0 - def _sum_credit(self,period_id=None,journal_id=None): - if type(period_id)==type([]): - self.cr.execute('select sum(credit) from account_move_line where period_id =ANY(%s) and journal_id =ANY(%s) and state<>\'draft\'',(period_id,journal_id,)) + def _sum_credit(self, period_id=None, journal_id=None): + if type(period_id) == type([]): + self.cr.execute('select sum(credit) from account_move_line where period_id =ANY(%s) and journal_id =ANY(%s) and state<>\'draft\'', (period_id, journal_id,)) return self.cr.fetchone()[0] or 0.0 if not self.journal_ids or not self.period_ids: return 0.0 - self.cr.execute('select sum(credit) from account_move_line where period_id =ANY(%s) and journal_id =ANY(%s) and state<>\'draft\'',(self.period_ids,self.journal_ids,)) + self.cr.execute('select sum(credit) from account_move_line where period_id =ANY(%s) and journal_id =ANY(%s) and state<>\'draft\'', (self.period_ids, self.journal_ids,)) return self.cr.fetchone()[0] or 0.0 -report_sxw.report_sxw('report.account.general.journal', 'account.journal.period', 'addons/account/report/general_journal.rml',parser=journal_print) -report_sxw.report_sxw('report.account.general.journal.wiz', 'account.journal.period', 'addons/account/report/wizard_general_journal.rml',parser=journal_print, header=False) +report_sxw.report_sxw('report.account.general.journal', 'account.journal.period', 'addons/account/report/general_journal.rml', parser=journal_print) +report_sxw.report_sxw('report.account.general.journal.wiz', 'account.journal.period', 'addons/account/report/wizard_general_journal.rml', parser=journal_print, header=False) # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/account/report/general_ledger.py b/addons/account/report/general_ledger.py index 43c298866ed..c86c244e382 100644 --- a/addons/account/report/general_ledger.py +++ b/addons/account/report/general_ledger.py @@ -36,7 +36,7 @@ class general_ledger(rml_parse.rml_parse): - def set_context(self, objects, data, ids, report_type = None): + def set_context(self, objects, data, ids, report_type=None): ## self.borne_date = self.get_min_date(data['form']) ## @@ -58,7 +58,7 @@ class general_ledger(rml_parse.rml_parse): self.tot_currency = 0.0 self.period_sql = "" self.sold_accounts = {} - self.localcontext.update( { + self.localcontext.update({ 'time': time, 'lines': self.lines, 'sum_debit_account': self._sum_debit_account, @@ -71,7 +71,7 @@ class general_ledger(rml_parse.rml_parse): 'sum_currency_amount_account': self._sum_currency_amount_account }) self.context = context - def _calc_contrepartie(self,cr,uid,ids, context={}): + def _calc_contrepartie(self, cr, uid, ids, context={}): result = {} #for id in ids: # result.setdefault(id, False) @@ -89,23 +89,23 @@ class general_ledger(rml_parse.rml_parse): # We have the account ID we will search all account move line from now until this time # We are in the case of we are on the top of the account move Line cr.execute('SELECT distinct(ac.code) as code_rest,ac.name as name_rest from account_account AS ac, account_move_line mv\ - where ac.id = mv.account_id and mv.move_id = %s and mv.account_id <> %s' ,(num_id_move,account_id,)) + where ac.id = mv.account_id and mv.move_id = %s and mv.account_id <> %s' , (num_id_move, account_id,)) res_mv = cr.dictfetchall() # we need a result more than 2 line to make the test so we will made the the on 1 because we have exclude the current line - if (len(res_mv) >=1): + if (len(res_mv) >= 1): concat = '' rup_id = 0 for move_rest in res_mv: concat = concat + move_rest['code_rest'] + '|' result[account_line.id] = concat - if rup_id >5: + if rup_id > 5: # we need to stop the computing and to escape but before we will add "..." result[account_line.id] = concat + '...' break - rup_id+=1 + rup_id += 1 return result - def get_min_date(self,form): + def get_min_date(self, form): ## Get max born from account_fiscal year # @@ -121,10 +121,10 @@ class general_ledger(rml_parse.rml_parse): periods = form['periods'][0][2] if not periods: self.cr.execute(""" - Select min(p.date_start) as start_date,max(p.date_stop) as stop_date from account_period as p where p.fiscalyear_id = %s""",(form['fiscalyear'],)) + Select min(p.date_start) as start_date,max(p.date_stop) as stop_date from account_period as p where p.fiscalyear_id = %s""", (form['fiscalyear'],)) else: self.cr.execute(""" - Select min(p.date_start) as start_date,max(p.date_stop) as stop_date from account_period as p where p.id =ANY(%s)""",(periods,)) + Select min(p.date_start) as start_date,max(p.date_stop) as stop_date from account_period as p where p.id =ANY(%s)""", (periods,)) res = self.cr.dictfetchall() borne_min = res[0]['start_date'] borne_max = res[0]['stop_date'] @@ -135,20 +135,20 @@ class general_ledger(rml_parse.rml_parse): periods = form['periods'][0][2] if not periods: self.cr.execute(""" - Select min(p.date_start) as start_date,max(p.date_stop) as stop_date from account_period as p where p.fiscalyear_id = %s""",(form['fiscalyear'],)) + Select min(p.date_start) as start_date,max(p.date_stop) as stop_date from account_period as p where p.fiscalyear_id = %s""", (form['fiscalyear'],)) else: self.cr.execute(""" - Select min(p.date_start) as start_date,max(p.date_stop) as stop_date from account_period as p where p.id =ANY(%s)""",(periods,)) + Select min(p.date_start) as start_date,max(p.date_stop) as stop_date from account_period as p where p.id =ANY(%s)""", (periods,)) res = self.cr.dictfetchall() period_min = res[0]['start_date'] period_max = res[0]['stop_date'] date_min = form['date_from'] date_max = form['date_to'] - if period_min=',child_account.id)], + [('account_id', '>=', child_account.id)], context=ctx)) <> 0 : res.append(child_account) ## @@ -223,7 +223,7 @@ class general_ledger(rml_parse.rml_parse): ## We will now compute solde initiaux for move in res: self.cr.execute("""SELECT sum(l.debit) AS sum_debit, sum(l.credit) AS sum_credit FROM account_move_line l \ - WHERE l.account_id = %s AND l.date < %s AND l.date > %s""",(move.id,self.borne_date['max_date'],self.borne_date['min_date'])) + WHERE l.account_id = %s AND l.date < %s AND l.date > %s""", (move.id, self.borne_date['max_date'], self.borne_date['min_date'])) resultat = self.cr.dictfetchall() if resultat[0] : if resultat[0]['sum_debit'] == None: @@ -276,11 +276,11 @@ class general_ledger(rml_parse.rml_parse): for l in res: line = self.pool.get('account.move.line').browse(self.cr, self.uid, l['id']) l['move'] = line.move_id.name - self.cr.execute('Select id from account_invoice where move_id =%s',(line.move_id.id,)) + self.cr.execute('Select id from account_invoice where move_id =%s', (line.move_id.id,)) tmpres = self.cr.dictfetchall() if len(tmpres) > 0 : inv = self.pool.get('account.invoice').browse(self.cr, self.uid, tmpres[0]['id']) - l['ref'] = inv_types[inv.type] + ': '+str(inv.number) + l['ref'] = inv_types[inv.type] + ': ' + str(inv.number) if line.partner_id : l['partner'] = line.partner_id.name else : @@ -289,7 +289,7 @@ class general_ledger(rml_parse.rml_parse): # c = time.strptime(l['date'],"%Y-%m-%d") # l['date'] = time.strftime("%d-%m-%Y",c) l['progress'] = sum - l['line_corresp'] = self._calc_contrepartie(self.cr,self.uid,[l['id']])[l['id']] + l['line_corresp'] = self._calc_contrepartie(self.cr, self.uid, [l['id']])[l['id']] # Modification du amount Currency if (l['credit'] > 0): if l['amount_currency'] != None: @@ -304,7 +304,7 @@ class general_ledger(rml_parse.rml_parse): self.cr.execute("SELECT sum(debit) "\ "FROM account_move_line l "\ - "WHERE l.account_id = %s AND "+self.query,(account.id,)) + "WHERE l.account_id = %s AND " + self.query, (account.id,)) ## Add solde init to the result # sum_debit = self.cr.fetchone()[0] or 0.0 @@ -318,7 +318,7 @@ class general_ledger(rml_parse.rml_parse): self.cr.execute("SELECT sum(credit) "\ "FROM account_move_line l "\ - "WHERE l.account_id = %s AND "+ self.query,(account.id,)) + "WHERE l.account_id = %s AND " + self.query, (account.id,)) ## Add solde init to the result # sum_credit = self.cr.fetchone()[0] or 0.0 @@ -332,7 +332,7 @@ class general_ledger(rml_parse.rml_parse): def _sum_solde_account(self, account, form): self.cr.execute("SELECT (sum(debit) - sum(credit)) as tot_solde "\ "FROM account_move_line l "\ - "WHERE l.account_id = %s AND "+ self.query,(account.id,)) + "WHERE l.account_id = %s AND " + self.query, (account.id,)) sum_solde = self.cr.fetchone()[0] or 0.0 if form.get('soldeinit', False): sum_solde += account.init_debit - account.init_credit @@ -344,7 +344,7 @@ class general_ledger(rml_parse.rml_parse): return 0.0 self.cr.execute("SELECT sum(debit) "\ "FROM account_move_line l "\ - "WHERE l.account_id =ANY(%s) AND "+ self.query,(self.child_ids,)) + "WHERE l.account_id =ANY(%s) AND " + self.query, (self.child_ids,)) sum_debit = self.cr.fetchone()[0] or 0.0 return sum_debit @@ -353,7 +353,7 @@ class general_ledger(rml_parse.rml_parse): return 0.0 self.cr.execute("SELECT sum(credit) "\ "FROM account_move_line l "\ - "WHERE l.account_id =ANY(%s) AND "+ self.query,(self.child_ids,)) + "WHERE l.account_id =ANY(%s) AND " + self.query, (self.child_ids,)) ## Add solde init to the result # sum_credit = self.cr.fetchone()[0] or 0.0 @@ -364,14 +364,14 @@ class general_ledger(rml_parse.rml_parse): return 0.0 self.cr.execute("SELECT (sum(debit) - sum(credit)) as tot_solde "\ "FROM account_move_line l "\ - "WHERE l.account_id =ANY(%s) AND "+ self.query,(self.child_ids,)) + "WHERE l.account_id =ANY(%s) AND " + self.query, (self.child_ids,)) sum_solde = self.cr.fetchone()[0] or 0.0 return sum_solde def _set_get_account_currency_code(self, account_id): self.cr.execute("SELECT c.code as code "\ "FROM res_currency c,account_account as ac "\ - "WHERE ac.id = %s AND ac.currency_id = c.id",(account_id,)) + "WHERE ac.id = %s AND ac.currency_id = c.id", (account_id,)) result = self.cr.fetchone() if result: self.account_currency = result[0] diff --git a/addons/account/report/general_ledger_landscape.py b/addons/account/report/general_ledger_landscape.py index dcb4e47fbdd..191eb03f65c 100644 --- a/addons/account/report/general_ledger_landscape.py +++ b/addons/account/report/general_ledger_landscape.py @@ -37,7 +37,7 @@ class general_ledger_landscape(rml_parse.rml_parse): _name = 'report.account.general.ledger_landscape' - def set_context(self, objects, data, ids, report_type = None): + def set_context(self, objects, data, ids, report_type=None): ## self.borne_date = self.get_min_date(data['form']) ## @@ -49,7 +49,7 @@ class general_ledger_landscape(rml_parse.rml_parse): objects = self.pool.get('account.account').browse(self.cr, self.uid, new_ids) - super(general_ledger_landscape, self).set_context(objects, data, new_ids,report_type) + super(general_ledger_landscape, self).set_context(objects, data, new_ids, report_type) def __init__(self, cr, uid, name, context): super(general_ledger_landscape, self).__init__(cr, uid, name, context=context) @@ -59,7 +59,7 @@ class general_ledger_landscape(rml_parse.rml_parse): self.tot_currency = 0.0 self.period_sql = "" self.sold_accounts = {} - self.localcontext.update( { + self.localcontext.update({ 'time': time, 'lines': self.lines, 'sum_debit_account': self._sum_debit_account, @@ -72,7 +72,7 @@ class general_ledger_landscape(rml_parse.rml_parse): 'sum_currency_amount_account': self._sum_currency_amount_account }) self.context = context - def _calc_contrepartie(self,cr,uid,ids, context={}): + def _calc_contrepartie(self, cr, uid, ids, context={}): result = {} #for id in ids: # result.setdefault(id, False) @@ -90,23 +90,23 @@ class general_ledger_landscape(rml_parse.rml_parse): # We have the account ID we will search all account move line from now until this time # We are in the case of we are on the top of the account move Line cr.execute('SELECT distinct(ac.code) as code_rest,ac.name as name_rest from account_account AS ac, account_move_line mv\ - where ac.id = mv.account_id and mv.move_id = %s and mv.account_id <> %s' , (num_id_move,account_id,)) + where ac.id = mv.account_id and mv.move_id = %s and mv.account_id <> %s' , (num_id_move, account_id,)) res_mv = cr.dictfetchall() # we need a result more than 2 line to make the test so we will made the the on 1 because we have exclude the current line - if (len(res_mv) >=1): + if (len(res_mv) >= 1): concat = '' rup_id = 0 for move_rest in res_mv: concat = concat + move_rest['code_rest'] + '|' result[account_line.id] = concat - if rup_id >5: + if rup_id > 5: # we need to stop the computing and to escape but before we will add "..." result[account_line.id] = concat + '...' break - rup_id+=1 + rup_id += 1 return result - def get_min_date(self,form): + def get_min_date(self, form): ## Get max born from account_fiscal year # @@ -122,10 +122,10 @@ class general_ledger_landscape(rml_parse.rml_parse): periods = form['periods'][0][2] if not periods: self.cr.execute(""" - Select min(p.date_start) as start_date,max(p.date_stop) as stop_date from account_period as p where p.fiscalyear_id = %s""" ,(form['fiscalyear'],)) + Select min(p.date_start) as start_date,max(p.date_stop) as stop_date from account_period as p where p.fiscalyear_id = %s""" , (form['fiscalyear'],)) else: self.cr.execute(""" - Select min(p.date_start) as start_date,max(p.date_stop) as stop_date from account_period as p where p.id =ANY(%s)""",(periods,)) + Select min(p.date_start) as start_date,max(p.date_stop) as stop_date from account_period as p where p.id =ANY(%s)""", (periods,)) res = self.cr.dictfetchall() borne_min = res[0]['start_date'] @@ -137,21 +137,21 @@ class general_ledger_landscape(rml_parse.rml_parse): periods = form['periods'][0][2] if not periods: self.cr.execute(""" - Select min(p.date_start) as start_date,max(p.date_stop) as stop_date from account_period as p where p.fiscalyear_id = = %s""" ,(form['fiscalyear'],)) + Select min(p.date_start) as start_date,max(p.date_stop) as stop_date from account_period as p where p.fiscalyear_id = = %s""" , (form['fiscalyear'],)) else: self.cr.execute(""" - Select min(p.date_start) as start_date,max(p.date_stop) as stop_date from account_period as p where p.id =ANY(%s)""",(periods,)) + Select min(p.date_start) as start_date,max(p.date_stop) as stop_date from account_period as p where p.id =ANY(%s)""", (periods,)) res = self.cr.dictfetchall() period_min = res[0]['start_date'] period_max = res[0]['stop_date'] date_min = form['date_from'] date_max = form['date_to'] - if period_min=',child_account.id)], + [('account_id', '>=', child_account.id)], context=ctx)) <> 0 : res.append(child_account) ## @@ -226,7 +226,7 @@ class general_ledger_landscape(rml_parse.rml_parse): ## We will now compute solde initiaux for move in res: self.cr.execute("""SELECT sum(l.debit) AS sum_debit, sum(l.credit) AS sum_credit FROM account_move_line l \ - WHERE l.account_id = %s AND l.date < %s AND l.date > %s""",(move.id,self.borne_date['max_date'],self.borne_date['min_date'])) + WHERE l.account_id = %s AND l.date < %s AND l.date > %s""", (move.id, self.borne_date['max_date'], self.borne_date['min_date'])) resultat = self.cr.dictfetchall() if resultat[0] : if resultat[0]['sum_debit'] == None: @@ -279,11 +279,11 @@ class general_ledger_landscape(rml_parse.rml_parse): for l in res: line = self.pool.get('account.move.line').browse(self.cr, self.uid, l['id']) l['move'] = line.move_id.name - self.cr.execute('Select id from account_invoice where move_id =%s',(line.move_id.id,)) + self.cr.execute('Select id from account_invoice where move_id =%s', (line.move_id.id,)) tmpres = self.cr.dictfetchall() if len(tmpres) > 0 : inv = self.pool.get('account.invoice').browse(self.cr, self.uid, tmpres[0]['id']) - l['ref'] = inv_types[inv.type] + ': '+str(inv.number) + l['ref'] = inv_types[inv.type] + ': ' + str(inv.number) if line.partner_id : l['partner'] = line.partner_id.name else : @@ -292,7 +292,7 @@ class general_ledger_landscape(rml_parse.rml_parse): # c = time.strptime(l['date'],"%Y-%m-%d") # l['date'] = time.strftime("%d-%m-%Y",c) l['progress'] = sum - l['line_corresp'] = self._calc_contrepartie(self.cr,self.uid,[l['id']])[l['id']] + l['line_corresp'] = self._calc_contrepartie(self.cr, self.uid, [l['id']])[l['id']] # Modification du amount Currency if (l['credit'] > 0): if l['amount_currency'] != None: @@ -307,7 +307,7 @@ class general_ledger_landscape(rml_parse.rml_parse): self.cr.execute("SELECT sum(debit) "\ "FROM account_move_line l "\ - "WHERE l.account_id = %s AND "+self.query,(account.id,)) + "WHERE l.account_id = %s AND " + self.query, (account.id,)) ## Add solde init to the result # sum_debit = self.cr.fetchone()[0] or 0.0 @@ -321,7 +321,7 @@ class general_ledger_landscape(rml_parse.rml_parse): self.cr.execute("SELECT sum(credit) "\ "FROM account_move_line l "\ - "WHERE l.account_id = %s AND "+self.query,(account.id,)) + "WHERE l.account_id = %s AND " + self.query, (account.id,)) ## Add solde init to the result # sum_credit = self.cr.fetchone()[0] or 0.0 @@ -335,9 +335,9 @@ class general_ledger_landscape(rml_parse.rml_parse): def _sum_solde_account(self, account, form): self.cr.execute("SELECT (sum(debit) - sum(credit)) as tot_solde "\ "FROM account_move_line l "\ - "WHERE l.account_id = %s AND "+self.query,(account.id,)) + "WHERE l.account_id = %s AND " + self.query, (account.id,)) sum_solde = self.cr.fetchone()[0] or 0.0 - if form.get('soldeinit',False): + if form.get('soldeinit', False): sum_solde += account.init_debit - account.init_credit return sum_solde @@ -347,7 +347,7 @@ class general_ledger_landscape(rml_parse.rml_parse): return 0.0 self.cr.execute("SELECT sum(debit) "\ "FROM account_move_line l "\ - "WHERE l.account_id =ANY(%s) AND "+self.query,(self.child_ids,)) + "WHERE l.account_id =ANY(%s) AND " + self.query, (self.child_ids,)) sum_debit = self.cr.fetchone()[0] or 0.0 return sum_debit @@ -356,7 +356,7 @@ class general_ledger_landscape(rml_parse.rml_parse): return 0.0 self.cr.execute("SELECT sum(credit) "\ "FROM account_move_line l "\ - "WHERE l.account_id =ANY(%s) AND "+self.query,(self.child_ids,)) + "WHERE l.account_id =ANY(%s) AND " + self.query, (self.child_ids,)) ## Add solde init to the result # sum_credit = self.cr.fetchone()[0] or 0.0 @@ -367,14 +367,14 @@ class general_ledger_landscape(rml_parse.rml_parse): return 0.0 self.cr.execute("SELECT (sum(debit) - sum(credit)) as tot_solde "\ "FROM account_move_line l "\ - "WHERE l.account_id =ANY(%s) AND "+self.query,(self.child_ids,)) + "WHERE l.account_id =ANY(%s) AND " + self.query, (self.child_ids,)) sum_solde = self.cr.fetchone()[0] or 0.0 return sum_solde def _set_get_account_currency_code(self, account_id): self.cr.execute("SELECT c.code as code "\ "FROM res_currency c,account_account as ac "\ - "WHERE ac.id = %s AND ac.currency_id = c.id",(account_id,)) + "WHERE ac.id = %s AND ac.currency_id = c.id", (account_id,)) result = self.cr.fetchone() if result: self.account_currency = result[0] diff --git a/addons/account/report/overdue.py b/addons/account/report/overdue.py index d25432bde24..9098e98e8ec 100644 --- a/addons/account/report/overdue.py +++ b/addons/account/report/overdue.py @@ -29,7 +29,7 @@ import pooler class Overdue(report_sxw.rml_parse): def __init__(self, cr, uid, name, context): super(Overdue, self).__init__(cr, uid, name, context=context) - self.localcontext.update( { + self.localcontext.update({ 'time' : time, 'adr_get' : self._adr_get, 'getLines' : self._lines_get, @@ -51,14 +51,14 @@ class Overdue(report_sxw.rml_parse): 'country_id' : False, } if adr_id: - result = res_partner_address.read(self.cr, self.uid, [adr_id],context=self.context.copy()) + result = res_partner_address.read(self.cr, self.uid, [adr_id], context=self.context.copy()) result[0]['country_id'] = result[0]['country_id'] and result[0]['country_id'][1] or False - return result - + return result + res.append(result) return res - def _tel_get(self,partner): + def _tel_get(self, partner): if not partner: return False res_partner_address = pooler.get_pool(self.cr.dbname).get('res.partner.address') @@ -66,7 +66,7 @@ class Overdue(report_sxw.rml_parse): addresses = res_partner.address_get(self.cr, self.uid, [partner.id], ['invoice']) adr_id = addresses and addresses['invoice'] or False if adr_id: - adr=res_partner_address.read(self.cr, self.uid, [adr_id])[0] + adr = res_partner_address.read(self.cr, self.uid, [adr_id])[0] return adr['phone'] else: return partner.address and partner.address[0].phone or False @@ -80,12 +80,12 @@ class Overdue(report_sxw.rml_parse): ('state', '<>', 'draft'), ('reconcile_id', '=', False)]) movelines = moveline_obj.browse(self.cr, self.uid, movelines) return movelines - + def _message(self, obj, company): company_pool = pooler.get_pool(self.cr.dbname).get('res.company') - message = company_pool.browse(self.cr, self.uid, company.id, {'lang':obj.lang}).overdue_msg + message = company_pool.browse(self.cr, self.uid, company.id, {'lang':obj.lang}).overdue_msg return message - + report_sxw.report_sxw('report.account.overdue', 'res.partner', 'addons/account/report/overdue.rml', parser=Overdue) diff --git a/addons/account/report/partner_balance.py b/addons/account/report/partner_balance.py index a5b746a0bde..20e5dd469fc 100755 --- a/addons/account/report/partner_balance.py +++ b/addons/account/report/partner_balance.py @@ -31,7 +31,7 @@ class partner_balance(report_sxw.rml_parse): self.date_lst = [] self.date_lst_string = '' self.account_ids = '' - self.localcontext.update( { + self.localcontext.update({ 'time': time, 'lines': self.lines, 'sum_debit': self._sum_debit, @@ -49,73 +49,73 @@ class partner_balance(report_sxw.rml_parse): # # Date Management # - def date_range(self,start,end): + def date_range(self, start, end): if not start or not end: return [] - start = datetime.date.fromtimestamp(time.mktime(time.strptime(start,"%Y-%m-%d"))) - end = datetime.date.fromtimestamp(time.mktime(time.strptime(end,"%Y-%m-%d"))) + start = datetime.date.fromtimestamp(time.mktime(time.strptime(start, "%Y-%m-%d"))) + end = datetime.date.fromtimestamp(time.mktime(time.strptime(end, "%Y-%m-%d"))) full_str_date = [] # - r = (end+datetime.timedelta(days=1)-start).days + r = (end + datetime.timedelta(days=1) - start).days # - date_array = [start+datetime.timedelta(days=i) for i in range(r)] + date_array = [start + datetime.timedelta(days=i) for i in range(r)] for date in date_array: full_str_date.append(str(date)) return full_str_date - def transform_period_into_date_array(self,data): + def transform_period_into_date_array(self, data): ## Get All Period Date # # If we have no period we will take all perdio in the FiscalYear. if not data['form']['periods'][0][2] : - periods_id = self.pool.get('account.period').search(self.cr, self.uid, [('fiscalyear_id','=',data['form']['fiscalyear'])]) + periods_id = self.pool.get('account.period').search(self.cr, self.uid, [('fiscalyear_id', '=', data['form']['fiscalyear'])]) else: periods_id = data['form']['periods'][0][2] date_array = [] for period_id in periods_id: period_obj = self.pool.get('account.period').browse(self.cr, self.uid, period_id) - date_array = date_array + self.date_range(period_obj.date_start,period_obj.date_stop) + date_array = date_array + self.date_range(period_obj.date_start, period_obj.date_stop) self.date_lst = date_array self.date_lst.sort() - def transform_date_into_date_array(self,data): - return_array = self.date_range(data['form']['date1'],data['form']['date2']) + def transform_date_into_date_array(self, data): + return_array = self.date_range(data['form']['date1'], data['form']['date2']) self.date_lst = return_array self.date_lst.sort() - def transform_both_into_date_array(self,data): + def transform_both_into_date_array(self, data): if not data['form']['periods'][0][2] : - periods_id = self.pool.get('account.period').search(self.cr, self.uid, [('fiscalyear_id','=',data['form']['fiscalyear'])]) + periods_id = self.pool.get('account.period').search(self.cr, self.uid, [('fiscalyear_id', '=', data['form']['fiscalyear'])]) else: periods_id = data['form']['periods'][0][2] date_array = [] for period_id in periods_id: period_obj = self.pool.get('account.period').browse(self.cr, self.uid, period_id) - date_array = date_array + self.date_range(period_obj.date_start,period_obj.date_stop) + date_array = date_array + self.date_range(period_obj.date_start, period_obj.date_stop) period_start_date = date_array[0] date_start_date = data['form']['date1'] period_stop_date = date_array[-1] date_stop_date = data['form']['date2'] - if period_start_date cleanarray[i-1]['account_id']: + if cleanarray[i]['account_id'] <> cleanarray[i - 1]['account_id']: new_header['debit'] = tot_debit new_header['credit'] = tot_credit @@ -307,7 +307,7 @@ class partner_balance(report_sxw.rml_parse): completearray.append(r) - if cleanarray[i]['account_id'] == cleanarray[i-1]['account_id']: + if cleanarray[i]['account_id'] == cleanarray[i - 1]['account_id']: # we reset the counter new_header['debit'] = tot_debit @@ -344,7 +344,7 @@ class partner_balance(report_sxw.rml_parse): return completearray - def _sum_debit(self,data): + def _sum_debit(self, data): if not self.ids: return 0.0 account_move_line_obj = pooler.get_pool(self.cr.dbname).get('account.move.line') @@ -355,13 +355,13 @@ class partner_balance(report_sxw.rml_parse): "SELECT sum(debit) " \ "FROM account_move_line AS l " \ "WHERE l.account_id =ANY(%s)" \ - "AND l.date IN (" + self.date_lst_string + ")" ,(self.account_ids,)) + "AND l.date IN (" + self.date_lst_string + ")" , (self.account_ids,)) temp_res = float(self.cr.fetchone()[0] or 0.0) result_tmp = result_tmp + temp_res return result_tmp - def _sum_credit(self,data): + def _sum_credit(self, data): if not self.ids: return 0.0 account_move_line_obj = pooler.get_pool(self.cr.dbname).get('account.move.line') @@ -373,13 +373,13 @@ class partner_balance(report_sxw.rml_parse): "SELECT sum(credit) " \ "FROM account_move_line AS l " \ "WHERE l.account_id =ANY(%s)" \ - "AND l.date IN (" + self.date_lst_string + ")" ,(self.account_ids,)) + "AND l.date IN (" + self.date_lst_string + ")" , (self.account_ids,)) temp_res = float(self.cr.fetchone()[0] or 0.0) result_tmp = result_tmp + temp_res return result_tmp - def _sum_litige(self,data): + def _sum_litige(self, data): if not self.ids: return 0.0 account_move_line_obj = pooler.get_pool(self.cr.dbname).get('account.move.line') @@ -391,13 +391,13 @@ class partner_balance(report_sxw.rml_parse): "FROM account_move_line AS l " \ "WHERE l.account_id =ANY(%s)" \ "AND l.date IN (" + self.date_lst_string + ")"\ - "AND l.blocked=TRUE " ,(self.account_ids,)) + "AND l.blocked=TRUE " , (self.account_ids,)) temp_res = float(self.cr.fetchone()[0] or 0.0) result_tmp = result_tmp + temp_res return result_tmp - def _sum_sdebit(self,data): + def _sum_sdebit(self, data): if not self.ids: return 0.0 account_move_line_obj = pooler.get_pool(self.cr.dbname).get('account.move.line') @@ -412,7 +412,7 @@ class partner_balance(report_sxw.rml_parse): "FROM account_move_line AS l " \ "WHERE l.account_id =ANY(%s)" \ "AND l.date IN (" + self.date_lst_string + ")" \ - "GROUP BY l.partner_id",(self.account_ids,)) + "GROUP BY l.partner_id", (self.account_ids,)) a = self.cr.fetchone()[0] if self.cr.fetchone() != None: @@ -422,7 +422,7 @@ class partner_balance(report_sxw.rml_parse): return result_tmp - def _sum_scredit(self,data): + def _sum_scredit(self, data): if not self.ids: return 0.0 @@ -439,7 +439,7 @@ class partner_balance(report_sxw.rml_parse): "FROM account_move_line AS l " \ "WHERE l.account_id =ANY(%s)" \ "AND l.date IN (" + self.date_lst_string + ")" \ - "GROUP BY l.partner_id",(self.account_ids,)) + "GROUP BY l.partner_id", (self.account_ids,)) a = self.cr.fetchone()[0] or 0.0 if self.cr.fetchone() != None: @@ -450,11 +450,11 @@ class partner_balance(report_sxw.rml_parse): return result_tmp - def _solde_balance_debit(self,data): + def _solde_balance_debit(self, data): debit, credit = self._sum_debit(data), self._sum_credit(data) return debit > credit and debit - credit - def _solde_balance_credit(self,data): + def _solde_balance_credit(self, data): debit, credit = self._sum_debit(data), self._sum_credit(data) return credit > debit and credit - debit @@ -465,7 +465,7 @@ class partner_balance(report_sxw.rml_parse): return pooler.get_pool(self.cr.dbname).get('res.company').browse(self.cr, self.uid, form['company_id']).currency_id.name report_sxw.report_sxw('report.account.partner.balance', 'res.partner', - 'account/report/partner_balance.rml',parser=partner_balance, + 'account/report/partner_balance.rml', parser=partner_balance, header=False) # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/account/report/rml_parse.py b/addons/account/report/rml_parse.py index 507599ec999..b7b80eca1f5 100644 --- a/addons/account/report/rml_parse.py +++ b/addons/account/report/rml_parse.py @@ -40,12 +40,12 @@ class rml_parse(report_sxw.rml_parse): 'explode_name' : self._explode_name, }) - def comma_me(self,amount): + def comma_me(self, amount): #print "#" + str(amount) + "#" if not amount: amount = 0.0 if type(amount) is float : - amount = str('%.2f'%amount) + amount = str('%.2f' % amount) else : amount = str(amount) if (amount == '0'): @@ -56,7 +56,7 @@ class rml_parse(report_sxw.rml_parse): return new else: return self.comma_me(new) - def _ellipsis(self, string, maxlen=100, ellipsis = '...'): + def _ellipsis(self, string, maxlen=100, ellipsis='...'): ellipsis = ellipsis or '' try: return string[:maxlen - len(ellipsis) ] + (ellipsis, '')[len(string) < maxlen] @@ -65,20 +65,20 @@ class rml_parse(report_sxw.rml_parse): def _strip_name(self, name, maxlen=50): return self._ellipsis(name, maxlen, '...') - def _get_and_change_date_format_for_swiss (self,date_to_format): - date_formatted='' + def _get_and_change_date_format_for_swiss (self, date_to_format): + date_formatted = '' if date_to_format: - date_formatted = strptime (date_to_format,'%Y-%m-%d').strftime('%d.%m.%Y') + date_formatted = strptime (date_to_format, '%Y-%m-%d').strftime('%d.%m.%Y') return date_formatted - def _explode_name(self,chaine,length): + def _explode_name(self, chaine, length): # We will test if the size is less then account full_string = '' if (len(str(chaine)) <= length): return chaine # else: - chaine = unicode(chaine,'utf8').encode('iso-8859-1') + chaine = unicode(chaine, 'utf8').encode('iso-8859-1') rup = 0 for carac in chaine: rup = rup + 1 @@ -91,7 +91,7 @@ class rml_parse(report_sxw.rml_parse): return full_string - def makeAscii(self,str): + def makeAscii(self, str): try: Stringer = str.encode("utf-8") except UnicodeDecodeError: @@ -105,17 +105,17 @@ class rml_parse(report_sxw.rml_parse): else: return Stringer return Stringer - def explode_this(self,chaine,length): + def explode_this(self, chaine, length): #chaine = self.repair_string(chaine) chaine = rstrip(chaine) ast = list(chaine) i = length while i <= len(ast): - ast.insert(i,'\n') + ast.insert(i, '\n') i = i + length chaine = str("".join(ast)) return chaine - def repair_string(self,chaine): + def repair_string(self, chaine): ast = list(chaine) UnicodeAst = [] _previouslyfound = False @@ -126,11 +126,11 @@ class rml_parse(report_sxw.rml_parse): try: Stringer = elem.encode("utf-8") except UnicodeDecodeError: - to_reencode = elem + ast[i+1] + to_reencode = elem + ast[i + 1] print str(to_reencode) Good_char = to_reencode.decode('utf-8') UnicodeAst.append(Good_char) - i += i +2 + i += i + 2 else: UnicodeAst.append(elem) i += i + 1 @@ -138,7 +138,7 @@ class rml_parse(report_sxw.rml_parse): return "".join(UnicodeAst) - def ReencodeAscii(self,str): + def ReencodeAscii(self, str): print sys.stdin.encoding try: Stringer = str.decode("ascii") diff --git a/addons/account/report/tax_report.py b/addons/account/report/tax_report.py index 3910622ad68..1767466f062 100644 --- a/addons/account/report/tax_report.py +++ b/addons/account/report/tax_report.py @@ -42,19 +42,19 @@ class tax_report(rml_parse.rml_parse): }) - def _get_lines(self, based_on,period_list,company_id=False, parent=False, level=0): - res = self._get_codes(based_on,company_id,parent,level,period_list) + def _get_lines(self, based_on, period_list, company_id=False, parent=False, level=0): + res = self._get_codes(based_on, company_id, parent, level, period_list) if period_list[0][2] : - res = self._add_codes(based_on,res,period_list) + res = self._add_codes(based_on, res, period_list) else : self.cr.execute ("select id from account_fiscalyear") fy = self.cr.fetchall() - self.cr.execute ("select id from account_period where fiscalyear_id = %s",(fy[0][0],)) + self.cr.execute ("select id from account_period where fiscalyear_id = %s", (fy[0][0],)) periods = self.cr.fetchall() for p in periods : period_list[0][2].append(p[0]) - res = self._add_codes(based_on,res,period_list) + res = self._add_codes(based_on, res, period_list) i = 0 top_result = [] @@ -71,15 +71,15 @@ class tax_report(rml_parse.rml_parse): } top_result.append(res_dict) - res_general = self._get_general(res[i][1].id,period_list,company_id,based_on) + res_general = self._get_general(res[i][1].id, period_list, company_id, based_on) ind_general = 0 while ind_general < len(res_general) : res_general[ind_general]['type'] = 2 res_general[ind_general]['pos'] = 0 res_general[ind_general]['level'] = res_dict['level'] top_result.append(res_general[ind_general]) - ind_general+=1 - i+=1 + ind_general += 1 + i += 1 #array_result = self.sort_result(top_result) return top_result #return array_result @@ -87,8 +87,8 @@ class tax_report(rml_parse.rml_parse): def _get_period(self, period_id): return self.pool.get('account.period').browse(self.cr, self.uid, period_id).name - def _get_general(self, tax_code_id,period_list ,company_id, based_on): - res=[] + def _get_general(self, tax_code_id, period_list , company_id, based_on): + res = [] if based_on == 'payments': self.cr.execute('SELECT SUM(line.tax_amount) AS tax_amount, \ SUM(line.debit) AS debit, \ @@ -110,8 +110,8 @@ class tax_report(rml_parse.rml_parse): AND line.period_id =ANY(%s) \ AND ((invoice.state = %s) \ OR (invoice.id IS NULL)) \ - GROUP BY account.id,account.name,account.code', ('draft',tax_code_id, - company_id, period_list[0][2],'paid',)) + GROUP BY account.id,account.name,account.code', ('draft', tax_code_id, + company_id, period_list[0][2], 'paid',)) else : self.cr.execute('SELECT SUM(line.tax_amount) AS tax_amount, \ @@ -129,42 +129,42 @@ class tax_report(rml_parse.rml_parse): AND account.company_id = %s \ AND line.period_id =ANY(%s)\ AND account.active \ - GROUP BY account.id,account.name,account.code', ('draft',tax_code_id, - company_id,period_list[0][2],)) + GROUP BY account.id,account.name,account.code', ('draft', tax_code_id, + company_id, period_list[0][2],)) res = self.cr.dictfetchall() #AND line.period_id IN ('+ period_sql_list +') \ i = 0 - while i= int(accounts[bcl_rup_ind]['level']) and bcl_rup_ind >= 0 ): + while (bcl_current_level >= int(accounts[bcl_rup_ind]['level']) and bcl_rup_ind >= 0): tot_elem = copy.copy(accounts[bcl_rup_ind]) res_tot = { 'code' : accounts[bcl_rup_ind]['code'], 'name' : '', @@ -206,12 +206,12 @@ class tax_report(rml_parse.rml_parse): # on change le type pour afficher le total res_tot['type'] = 2 result_accounts.append(res_tot) - bcl_current_level = accounts[bcl_rup_ind]['level'] + bcl_current_level = accounts[bcl_rup_ind]['level'] bcl_rup_ind -= 1 old_level = account_elem['level'] result_accounts.append(account_elem) - ind+=1 + ind += 1 return result_accounts diff --git a/addons/account/report/third_party_ledger.py b/addons/account/report/third_party_ledger.py index 0ae5bf8ce1a..7ce7eb29ce3 100644 --- a/addons/account/report/third_party_ledger.py +++ b/addons/account/report/third_party_ledger.py @@ -31,7 +31,7 @@ class third_party_ledger(rml_parse.rml_parse): self.date_lst = [] self.date_lst_string = '' super(third_party_ledger, self).__init__(cr, uid, name, context=context) - self.localcontext.update( { + self.localcontext.update({ 'time': time, 'lines': self.lines, 'sum_debit_partner': self._sum_debit_partner, @@ -42,61 +42,61 @@ class third_party_ledger(rml_parse.rml_parse): 'get_currency': self._get_currency, 'comma_me' : self.comma_me, }) - def date_range(self,start,end): + def date_range(self, start, end): if not start or not end: return [] - start = datetime.date.fromtimestamp(time.mktime(time.strptime(start,"%Y-%m-%d"))) - end = datetime.date.fromtimestamp(time.mktime(time.strptime(end,"%Y-%m-%d"))) + start = datetime.date.fromtimestamp(time.mktime(time.strptime(start, "%Y-%m-%d"))) + end = datetime.date.fromtimestamp(time.mktime(time.strptime(end, "%Y-%m-%d"))) full_str_date = [] # - r = (end+datetime.timedelta(days=1)-start).days + r = (end + datetime.timedelta(days=1) - start).days # - date_array = [start+datetime.timedelta(days=i) for i in range(r)] + date_array = [start + datetime.timedelta(days=i) for i in range(r)] for date in date_array: full_str_date.append(str(date)) return full_str_date # - def transform_period_into_date_array(self,data): + def transform_period_into_date_array(self, data): ## Get All Period Date if not data['form']['periods'][0][2] : - periods_id = self.pool.get('account.period').search(self.cr, self.uid, [('fiscalyear_id','=',data['form']['fiscalyear'])]) + periods_id = self.pool.get('account.period').search(self.cr, self.uid, [('fiscalyear_id', '=', data['form']['fiscalyear'])]) else: periods_id = data['form']['periods'][0][2] date_array = [] for period_id in periods_id: period_obj = self.pool.get('account.period').browse(self.cr, self.uid, period_id) - date_array = date_array + self.date_range(period_obj.date_start,period_obj.date_stop) + date_array = date_array + self.date_range(period_obj.date_start, period_obj.date_stop) self.date_lst = date_array self.date_lst.sort() - def transform_date_into_date_array(self,data): - return_array = self.date_range(data['form']['date1'],data['form']['date2']) + def transform_date_into_date_array(self, data): + return_array = self.date_range(data['form']['date1'], data['form']['date2']) self.date_lst = return_array self.date_lst.sort() - def transform_both_into_date_array(self,data): + def transform_both_into_date_array(self, data): if not data['form']['periods'][0][2] : - periods_id = self.pool.get('account.period').search(self.cr, self.uid, [('fiscalyear_id','=',data['form']['fiscalyear'])]) + periods_id = self.pool.get('account.period').search(self.cr, self.uid, [('fiscalyear_id', '=', data['form']['fiscalyear'])]) else: periods_id = data['form']['periods'][0][2] date_array = [] for period_id in periods_id: period_obj = self.pool.get('account.period').browse(self.cr, self.uid, period_id) - date_array = date_array + self.date_range(period_obj.date_start,period_obj.date_stop) + date_array = date_array + self.date_range(period_obj.date_start, period_obj.date_stop) period_start_date = date_array[0] date_start_date = data['form']['date1'] period_stop_date = date_array[-1] date_stop_date = data['form']['date2'] - if period_start_date accounts[a['parent_id'][0]]['parent_left'] assert a['parent_right'] < accounts[a['parent_id'][0]]['parent_right'] assert a['parent_left'] < a['parent_right'] for a2 in account_lists: - assert not ((a2['parent_right']>a['parent_left']) and - (a2['parent_left']a['parent_left']) and (a2['parent_right'] a['parent_left']) and + (a2['parent_left'] < a['parent_left']) and + (a2['parent_right'] < a['parent_right'])) + if a2['parent_id'] == a['id']: + assert (a2['parent_left'] > a['parent_left']) and (a2['parent_right'] < a['parent_right']) print 'Tests Ok' diff --git a/addons/account/wizard/wizard_account_balance_report.py b/addons/account/wizard/wizard_account_balance_report.py index 26538d06b4b..5d4f6679f14 100644 --- a/addons/account/wizard/wizard_account_balance_report.py +++ b/addons/account/wizard/wizard_account_balance_report.py @@ -53,8 +53,8 @@ period_fields = { 'state':{ 'string':"Date/Period Filter", 'type':'selection', - 'selection':[('bydate','By Date'),('byperiod','By Period'),('all','By Date and Period'),('none','No Filter')], - 'default': lambda *a:'none' + 'selection':[('bydate', 'By Date'), ('byperiod', 'By Period'), ('all', 'By Date and Period'), ('none', 'No Filter')], + 'default': lambda * a:'none' }, 'fiscalyear': { 'string':'Fiscal year', @@ -63,9 +63,9 @@ period_fields = { 'help':'Keep empty for all open fiscal year' }, 'periods': {'string': 'Periods', 'type': 'many2many', 'relation': 'account.period', 'help': 'All periods if empty'}, - 'display_account':{'string':"Display accounts ",'type':'selection','selection':[('bal_mouvement','With movements'),('bal_all','All'),('bal_solde','With balance is not equal to 0')]}, - 'date_from': {'string':"Start date",'type':'date','required':True ,'default': lambda *a: time.strftime('%Y-01-01')}, - 'date_to': {'string':"End date",'type':'date','required':True, 'default': lambda *a: time.strftime('%Y-%m-%d')}, + 'display_account':{'string':"Display accounts ", 'type':'selection', 'selection':[('bal_mouvement', 'With movements'), ('bal_all', 'All'), ('bal_solde', 'With balance is not equal to 0')]}, + 'date_from': {'string':"Start date", 'type':'date', 'required':True , 'default': lambda * a: time.strftime('%Y-01-01')}, + 'date_to': {'string':"End date", 'type':'date', 'required':True, 'default': lambda * a: time.strftime('%Y-%m-%d')}, } account_form = ''' @@ -74,7 +74,7 @@ account_form = ''' ''' account_fields = { - 'Account_list': {'string':'Account', 'type':'many2one', 'relation':'account.account', 'required':True ,'domain':[('parent_id','=',False)]}, + 'Account_list': {'string':'Account', 'type':'many2one', 'relation':'account.account', 'required':True , 'domain':[('parent_id', '=', False)]}, } class wizard_report(wizard.interface): @@ -112,29 +112,29 @@ class wizard_report(wizard.interface): def _check_date(self, cr, uid, data, context): sql = """ SELECT f.id, f.date_start, f.date_stop FROM account_fiscalyear f Where %s between f.date_start and f.date_stop """ - cr.execute(sql,(data['form']['date_from'],)) + cr.execute(sql, (data['form']['date_from'],)) res = cr.dictfetchall() if res: if (data['form']['date_to'] > res[0]['date_stop'] or data['form']['date_to'] < res[0]['date_start']): - raise wizard.except_wizard(_('UserError'),_('Date to must be set between %s and %s') % (res[0]['date_start'], res[0]['date_stop'])) + raise wizard.except_wizard(_('UserError'), _('Date to must be set between %s and %s') % (res[0]['date_start'], res[0]['date_stop'])) else: return 'report' else: - raise wizard.except_wizard(_('UserError'),_('Date not in a defined fiscal year')) + raise wizard.except_wizard(_('UserError'), _('Date not in a defined fiscal year')) states = { 'init': { 'actions': [], - 'result': {'type':'choice','next_state':_check_path} + 'result': {'type':'choice', 'next_state':_check_path} }, 'account_selection': { 'actions': [], - 'result': {'type':'form', 'arch':account_form,'fields':account_fields, 'state':[('end','Cancel','gtk-cancel'),('checktype','Next','gtk-go-forward')]} + 'result': {'type':'form', 'arch':account_form, 'fields':account_fields, 'state':[('end', 'Cancel', 'gtk-cancel'), ('checktype', 'Next', 'gtk-go-forward')]} }, 'checktype': { 'actions': [_get_defaults], - 'result': {'type':'form', 'arch':period_form, 'fields':period_fields, 'state':[('end','Cancel','gtk-cancel'),('report','Print','gtk-print')]} + 'result': {'type':'form', 'arch':period_form, 'fields':period_fields, 'state':[('end', 'Cancel', 'gtk-cancel'), ('report', 'Print', 'gtk-print')]} }, 'report': { 'actions': [_check_state], diff --git a/addons/account/wizard/wizard_account_chart.py b/addons/account/wizard/wizard_account_chart.py index ca8153f3ce7..8ff8c497eb2 100644 --- a/addons/account/wizard/wizard_account_chart.py +++ b/addons/account/wizard/wizard_account_chart.py @@ -40,9 +40,9 @@ class wizard_account_chart(wizard.interface): 'target_move': { 'string': 'Target Moves', 'type': 'selection', - 'selection': [('all','All Entries'),('posted','All Posted Entries')], + 'selection': [('all', 'All Entries'), ('posted', 'All Posted Entries')], 'required': True, - 'default': lambda *a:"all", + 'default': lambda * a:"all", }, } @@ -59,9 +59,9 @@ class wizard_account_chart(wizard.interface): result = mod_obj._get_id(cr, uid, 'account', 'action_account_tree') id = mod_obj.read(cr, uid, [result], ['res_id'])[0]['res_id'] result = act_obj.read(cr, uid, [id], context=context)[0] - result['context'] = str({'fiscalyear': data['form']['fiscalyear'],'state':data['form']['target_move']}) + result['context'] = str({'fiscalyear': data['form']['fiscalyear'], 'state':data['form']['target_move']}) if data['form']['fiscalyear']: - result['name']+=':'+pooler.get_pool(cr.dbname).get('account.fiscalyear').read(cr,uid,[data['form']['fiscalyear']])[0]['code'] + result['name'] += ':' + pooler.get_pool(cr.dbname).get('account.fiscalyear').read(cr, uid, [data['form']['fiscalyear']])[0]['code'] return result states = { diff --git a/addons/account/wizard/wizard_aged_trial_balance.py b/addons/account/wizard/wizard_aged_trial_balance.py index 9935811031b..8e1afcaa620 100755 --- a/addons/account/wizard/wizard_aged_trial_balance.py +++ b/addons/account/wizard/wizard_aged_trial_balance.py @@ -41,37 +41,37 @@ _aged_trial_form = """ _aged_trial_fields = { 'company_id': {'string': 'Company', 'type': 'many2one', 'relation': 'res.company', 'required': True}, - 'period_length': {'string': 'Period length (days)', 'type': 'integer', 'required': True, 'default': lambda *a:30}, - 'date1': {'string':'Start of period', 'type':'date', 'required':True, 'default': lambda *a: time.strftime('%Y-%m-%d')}, + 'period_length': {'string': 'Period length (days)', 'type': 'integer', 'required': True, 'default': lambda * a:30}, + 'date1': {'string':'Start of period', 'type':'date', 'required':True, 'default': lambda * a: time.strftime('%Y-%m-%d')}, 'result_selection':{ 'string':"Filter on Partners", 'type':'selection', - 'selection':[('customer','Receivable'),('supplier','Payable'),('all','Receivable and Payable')], + 'selection':[('customer', 'Receivable'), ('supplier', 'Payable'), ('all', 'Receivable and Payable')], 'required':True, - 'default': lambda *a: 'all', + 'default': lambda * a: 'all', }, 'direction_selection':{ 'string':"Analysis Direction", 'type':'selection', - 'selection':[('past','Past'),('future','Future')], + 'selection':[('past', 'Past'), ('future', 'Future')], 'required':True, - 'default': lambda *a: 'past', + 'default': lambda * a: 'past', }, } def _calc_dates(self, cr, uid, data, context): res = {} period_length = data['form']['period_length'] - if period_length<=0: + if period_length <= 0: raise wizard.except_wizard(_('UserError'), _('You must enter a period length that cannot be 0 or below !')) - start = datetime.date.fromtimestamp(time.mktime(time.strptime(data['form']['date1'],"%Y-%m-%d"))) - start = DateTime(int(start.year),int(start.month),int(start.day)) + start = datetime.date.fromtimestamp(time.mktime(time.strptime(data['form']['date1'], "%Y-%m-%d"))) + start = DateTime(int(start.year), int(start.month), int(start.day)) if data['form']['direction_selection'] == 'past': for i in range(5)[::-1]: stop = start - RelativeDateTime(days=period_length) res[str(i)] = { - 'name' : str((5-(i+1))*period_length) + '-' + str((5-i)*period_length), - + 'name' : str((5 - (i + 1)) * period_length) + '-' + str((5 - i) * period_length), + 'stop': start.strftime('%Y-%m-%d'), 'start' : stop.strftime('%Y-%m-%d'), } @@ -79,8 +79,8 @@ def _calc_dates(self, cr, uid, data, context): else: for i in range(5): stop = start + RelativeDateTime(days=period_length) - res[str(5-(i+1))] = { - 'name' : str((i)*period_length)+'-'+str((i+1)*period_length), + res[str(5 - (i + 1))] = { + 'name' : str((i) * period_length) + '-' + str((i + 1) * period_length), 'start': start.strftime('%Y-%m-%d'), 'stop' : stop.strftime('%Y-%m-%d'), } @@ -101,7 +101,7 @@ class wizard_report(wizard.interface): states = { 'init': { 'actions': [_get_defaults], - 'result': {'type':'form', 'arch':_aged_trial_form, 'fields':_aged_trial_fields, 'state':[('end','Cancel'),('print','Print Aged Trial Balance')]}, + 'result': {'type':'form', 'arch':_aged_trial_form, 'fields':_aged_trial_fields, 'state':[('end', 'Cancel'), ('print', 'Print Aged Trial Balance')]}, }, 'print': { 'actions': [_calc_dates], diff --git a/addons/account/wizard/wizard_automatic_reconcile.py b/addons/account/wizard/wizard_automatic_reconcile.py index 7a0f5a8c465..563a90099a3 100644 --- a/addons/account/wizard/wizard_automatic_reconcile.py +++ b/addons/account/wizard/wizard_automatic_reconcile.py @@ -64,7 +64,7 @@ _reconcile_fields = { 'string': 'Account to reconcile', 'type': 'many2many', 'relation': 'account.account', - 'domain': [('reconcile','=',1)], + 'domain': [('reconcile', '=', 1)], 'help': 'If no account is specified, the reconciliation will be made using every accounts that can be reconcilied', }, 'writeoff_acc_id': { @@ -98,20 +98,20 @@ _reconcile_fields = { 'power': { 'string': 'Power', 'type': 'selection', - 'selection': [(p,str(p)) for p in range(2, 10)], + 'selection': [(p, str(p)) for p in range(2, 10)], 'required': True }, 'date1': { 'string': 'Start of period', 'type': 'date', 'required': True, - 'default': lambda *a: time.strftime('%Y-01-01') + 'default': lambda * a: time.strftime('%Y-01-01') }, 'date2': { 'string': 'End of period', 'type': 'date', 'required': True, - 'default': lambda *a: time.strftime('%Y-%m-%d') + 'default': lambda * a: time.strftime('%Y-%m-%d') }, } @@ -150,14 +150,14 @@ def do_reconcile(cr, uid, credits, debits, max_amount, power, writeoff_acc_id, p return [move[0]] else: del move_list[i] - res = check(value - move[1], move_list, power-1) + res = check(value - move[1], move_list, power - 1) move_list[i:i] = [move] if res: res.append(move[0]) return res return False - for p in range(1, power+1): + for p in range(1, power + 1): res = check(value, move_list, p) if res: return res @@ -177,7 +177,7 @@ def do_reconcile(cr, uid, credits, debits, max_amount, power, writeoff_acc_id, p return ([move[0]], res) else: del list1[i] - res = check3(value + move[1], list1, list2, list1power-1, power-1) + res = check3(value + move[1], list1, list2, list1power - 1, power - 1) list1[i:i] = [move] if res: x, y = res @@ -190,9 +190,9 @@ def do_reconcile(cr, uid, credits, debits, max_amount, power, writeoff_acc_id, p if res: return res return False - + def check5(list1, list2, max_power): - for p in range(2, max_power+1): + for p in range(2, max_power + 1): res = check4(list1, list2, p) if res: return res @@ -209,8 +209,8 @@ def do_reconcile(cr, uid, credits, debits, max_amount, power, writeoff_acc_id, p debits = [(id, debit) for (id, debit) in debits if id not in res[1]] else: ok = False - return (reconciled, len(credits)+len(debits)) - + return (reconciled, len(credits) + len(debits)) + def _reconcile(self, cr, uid, data, context): service = netsvc.LocalService("object_proxy") move_line_obj = pooler.get_pool(cr.dbname).get('account.move.line') @@ -221,7 +221,7 @@ def _reconcile(self, cr, uid, data, context): if not form['account_ids'][0][2]: raise wizard.except_wizard(_('UserError'), _('You must select accounts to reconcile')) for account_id in form['account_ids'][0][2]: - + # reconcile automatically all transactions from partners whose balance is 0 cr.execute( "SELECT partner_id " \ @@ -244,11 +244,11 @@ def _reconcile(self, cr, uid, data, context): "AND reconcile_id IS NULL", (account_id, partner_id)) line_ids = [id for (id,) in cr.fetchall()] - + if len(line_ids): move_line_obj.reconcile(cr, uid, line_ids, 'auto', form['writeoff_acc_id'], form['period_id'], form['journal_id'], context) reconciled += len(line_ids) - + # get the list of partners who have more than one unreconciled transaction cr.execute( "SELECT partner_id " \ @@ -274,7 +274,7 @@ def _reconcile(self, cr, uid, data, context): "AND debit > 0", (account_id, partner_id)) debits = cr.fetchall() - + # get the list of unreconciled 'credit transactions' for this partner cr.execute( "SELECT id, credit " \ @@ -286,7 +286,7 @@ def _reconcile(self, cr, uid, data, context): "AND credit > 0", (account_id, partner_id)) credits = cr.fetchall() - + (rec, unrec) = do_reconcile(cr, uid, credits, debits, max_amount, power, form['writeoff_acc_id'], form['period_id'], form['journal_id'], context) reconciled += rec unreconciled += unrec @@ -302,17 +302,17 @@ def _reconcile(self, cr, uid, data, context): "AND state <> 'draft' " + partner_filter, (account_id,)) additional_unrec = cr.fetchone()[0] - return {'reconciled':reconciled, 'unreconciled':unreconciled+additional_unrec} + return {'reconciled':reconciled, 'unreconciled':unreconciled + additional_unrec} class wiz_reconcile(wizard.interface): states = { 'init': { 'actions': [], - 'result': {'type':'form', 'arch':_reconcile_form, 'fields':_reconcile_fields, 'state':[('end','Cancel'),('reconcile','Reconcile')]} + 'result': {'type':'form', 'arch':_reconcile_form, 'fields':_reconcile_fields, 'state':[('end', 'Cancel'), ('reconcile', 'Reconcile')]} }, 'reconcile': { 'actions': [_reconcile], - 'result': {'type':'form', 'arch':_result_form, 'fields':_result_fields, 'state':[('end','OK')]} + 'result': {'type':'form', 'arch':_result_form, 'fields':_result_fields, 'state':[('end', 'OK')]} } } wiz_reconcile('account.automatic.reconcile') diff --git a/addons/account/wizard/wizard_bank_reconcile.py b/addons/account/wizard/wizard_bank_reconcile.py index c081657304a..af8e3354b4b 100644 --- a/addons/account/wizard/wizard_bank_reconcile.py +++ b/addons/account/wizard/wizard_bank_reconcile.py @@ -38,7 +38,7 @@ def _action_open_window(self, cr, uid, data, context): if not account_id: raise wizard.except_wizard(_('Error'), _('You have to define the bank account\nin the journal definition for reconciliation.')) return { - 'domain': "[('journal_id','=',%d), ('account_id','=',%d), ('state','<>','draft')]" % (form['journal_id'],account_id), + 'domain': "[('journal_id','=',%d), ('account_id','=',%d), ('state','<>','draft')]" % (form['journal_id'], account_id), 'name': _('Standard Encoding'), 'view_type': 'form', @@ -53,7 +53,7 @@ class wiz_journal(wizard.interface): states = { 'init': { 'actions': [], - 'result': {'type': 'form', 'arch':_journal_form, 'fields':_journal_fields, 'state':[('end','Cancel'),('open','Open for bank reconciliation')]} + 'result': {'type': 'form', 'arch':_journal_form, 'fields':_journal_fields, 'state':[('end', 'Cancel'), ('open', 'Open for bank reconciliation')]} }, 'open': { 'actions': [], diff --git a/addons/account/wizard/wizard_central_journal.py b/addons/account/wizard/wizard_central_journal.py index 8a6e1645a6f..8c23b299209 100644 --- a/addons/account/wizard/wizard_central_journal.py +++ b/addons/account/wizard/wizard_central_journal.py @@ -37,15 +37,15 @@ fields = { def _check_data(self, cr, uid, data, *args): period_id = data['form']['period_id'][0][2] - journal_id=data['form']['journal_id'][0][2] + journal_id = data['form']['journal_id'][0][2] + + if type(period_id) == type([]): - if type(period_id)==type([]): - ids_final = [] for journal in journal_id: for period in period_id: - ids_journal_period = pooler.get_pool(cr.dbname).get('account.journal.period').search(cr,uid, [('journal_id','=',journal),('period_id','=',period)]) + ids_journal_period = pooler.get_pool(cr.dbname).get('account.journal.period').search(cr, uid, [('journal_id', '=', journal), ('period_id', '=', period)]) if ids_journal_period: ids_final.append(ids_journal_period) diff --git a/addons/account/wizard/wizard_change_currency.py b/addons/account/wizard/wizard_change_currency.py index 69fbd8c85ed..08440ea3f62 100644 --- a/addons/account/wizard/wizard_change_currency.py +++ b/addons/account/wizard/wizard_change_currency.py @@ -30,49 +30,49 @@ class wizard_change_currency(wizard.interface):
''' - + message = '''