Merge lp:~julie-w/unifield-server/US-6527 into lp:unifield-server
- US-6527
- Merge into trunk
Proposed by
jftempo
Status: | Merged |
---|---|
Merged at revision: | 5545 |
Proposed branch: | lp:~julie-w/unifield-server/US-6527 |
Merge into: | lp:unifield-server |
Diff against target: |
61089 lines (+3020/-52079) (has conflicts) 203 files modified
bin/addons/account/__init__.py (+0/-1) bin/addons/account/__openerp__.py (+0/-1) bin/addons/account/account.py (+0/-69) bin/addons/account/account_analytic_line.py (+0/-67) bin/addons/account/account_bank_statement.py (+58/-226) bin/addons/account/account_cash_statement.py (+7/-112) bin/addons/account/account_installer.xml (+0/-130) bin/addons/account/account_invoice_view.xml (+10/-4) bin/addons/account/account_move_line.py (+1/-217) bin/addons/account/invoice.py (+26/-8) bin/addons/account/project/project_view.xml (+3/-43) bin/addons/account/res_currency.py (+0/-47) bin/addons/account/wizard/account_change_currency.py (+1/-0) bin/addons/account_corrections/account_move_line.py (+9/-3) bin/addons/account_corrections/wizard/analytic_distribution_wizard.py (+34/-17) bin/addons/account_hq_entries/wizard/hq_entries_validation.py (+41/-18) bin/addons/account_mcdb/account_analytic_line.py (+19/-10) bin/addons/account_mcdb/account_bank_statement.py (+8/-1) bin/addons/account_mcdb/account_move_line.py (+7/-1) bin/addons/account_mcdb/report/account_mcdb_export.py (+9/-5) bin/addons/account_override/account.py (+2/-0) bin/addons/account_override/account_move_line.py (+2/-0) bin/addons/account_override/invoice.py (+3/-0) bin/addons/account_override/res_company.py (+25/-0) bin/addons/account_override/res_currency.py (+0/-59) bin/addons/account_payment/__init__.py (+2/-6) bin/addons/account_payment/__openerp__.py (+2/-11) bin/addons/account_payment/account_move_line.py (+2/-72) bin/addons/account_payment/account_payment.py (+0/-429) bin/addons/account_payment/account_payment_demo.xml (+0/-25) bin/addons/account_payment/account_payment_report.xml (+0/-6) bin/addons/account_payment/account_payment_sequence.xml (+0/-29) bin/addons/account_payment/account_payment_view.xml (+0/-303) bin/addons/account_payment/account_payment_workflow.xml (+0/-67) bin/addons/account_payment/report/__init__.py (+0/-23) bin/addons/account_payment/report/order.rml (+0/-290) bin/addons/account_payment/report/payment_order.py (+0/-90) bin/addons/account_payment/security/account_payment_security.xml (+0/-17) bin/addons/account_payment/security/ir.model.access.csv (+0/-1) bin/addons/account_payment/wizard/__init__.py (+0/-26) bin/addons/account_payment/wizard/account_payment_create_order_view.xml (+0/-52) bin/addons/account_payment/wizard/account_payment_order.py (+0/-123) bin/addons/account_payment/wizard/account_payment_pay.py (+0/-58) bin/addons/account_payment/wizard/account_payment_pay_view.xml (+0/-33) bin/addons/account_payment/wizard/account_payment_populate_statement.py (+0/-122) bin/addons/account_payment/wizard/account_payment_populate_statement_view.xml (+0/-44) bin/addons/account_period_closing_level/account_year_end_closing.py (+14/-12) bin/addons/account_voucher/__init__.py (+0/-27) bin/addons/account_voucher/__openerp__.py (+0/-60) bin/addons/account_voucher/account_voucher.py (+0/-1022) bin/addons/account_voucher/account_voucher_report.xml (+0/-23) bin/addons/account_voucher/account_voucher_sequence.xml (+0/-90) bin/addons/account_voucher/account_voucher_view.xml (+0/-274) bin/addons/account_voucher/account_voucher_wizard.xml (+0/-5) bin/addons/account_voucher/account_voucher_workflow.xml (+0/-61) bin/addons/account_voucher/i18n/account_voucher.pot (+0/-991) bin/addons/account_voucher/i18n/ar.po (+0/-1019) bin/addons/account_voucher/i18n/bg.po (+0/-1021) bin/addons/account_voucher/i18n/bs.po (+0/-1019) bin/addons/account_voucher/i18n/ca.po (+0/-1057) bin/addons/account_voucher/i18n/cs.po (+0/-1019) bin/addons/account_voucher/i18n/de.po (+0/-1061) bin/addons/account_voucher/i18n/el.po (+0/-1020) bin/addons/account_voucher/i18n/es.po (+0/-1058) bin/addons/account_voucher/i18n/es_AR.po (+0/-1020) bin/addons/account_voucher/i18n/es_EC.po (+0/-1056) bin/addons/account_voucher/i18n/es_PY.po (+0/-1057) bin/addons/account_voucher/i18n/et.po (+0/-1019) bin/addons/account_voucher/i18n/gl.po (+0/-1052) bin/addons/account_voucher/i18n/hi.po (+0/-1020) bin/addons/account_voucher/i18n/hr.po (+0/-1019) bin/addons/account_voucher/i18n/hu.po (+0/-1051) bin/addons/account_voucher/i18n/id.po (+0/-1019) bin/addons/account_voucher/i18n/it.po (+0/-1045) bin/addons/account_voucher/i18n/ko.po (+0/-1020) bin/addons/account_voucher/i18n/lt.po (+0/-1019) bin/addons/account_voucher/i18n/mn.po (+0/-1020) bin/addons/account_voucher/i18n/nl.po (+0/-1032) bin/addons/account_voucher/i18n/nl_BE.po (+0/-1020) bin/addons/account_voucher/i18n/oc.po (+0/-1020) bin/addons/account_voucher/i18n/pl.po (+0/-1029) bin/addons/account_voucher/i18n/pt.po (+0/-1019) bin/addons/account_voucher/i18n/pt_BR.po (+0/-1037) bin/addons/account_voucher/i18n/ro.po (+0/-1021) bin/addons/account_voucher/i18n/ru.po (+0/-1024) bin/addons/account_voucher/i18n/sl.po (+0/-1019) bin/addons/account_voucher/i18n/sq.po (+0/-1020) bin/addons/account_voucher/i18n/sr.po (+0/-1028) bin/addons/account_voucher/i18n/sr@latin.po (+0/-1028) bin/addons/account_voucher/i18n/sv.po (+0/-1025) bin/addons/account_voucher/i18n/tlh.po (+0/-1019) bin/addons/account_voucher/i18n/tr.po (+0/-1051) bin/addons/account_voucher/i18n/uk.po (+0/-1019) bin/addons/account_voucher/i18n/vi.po (+0/-1020) bin/addons/account_voucher/i18n/zh_CN.po (+0/-1028) bin/addons/account_voucher/i18n/zh_TW.po (+0/-1019) bin/addons/account_voucher/invoice.py (+0/-54) bin/addons/account_voucher/report/__init__.py (+0/-26) bin/addons/account_voucher/report/account_voucher.py (+0/-75) bin/addons/account_voucher/report/account_voucher.rml (+0/-446) bin/addons/account_voucher/report/account_voucher_print.py (+0/-96) bin/addons/account_voucher/report/account_voucher_print.rml (+0/-331) bin/addons/account_voucher/report/account_voucher_sales_receipt.py (+0/-131) bin/addons/account_voucher/report/account_voucher_sales_receipt_view.xml (+0/-115) bin/addons/account_voucher/security/account_voucher_security.xml (+0/-17) bin/addons/account_voucher/security/ir.model.access.csv (+0/-1) bin/addons/account_voucher/voucher_payment_receipt_view.xml (+0/-425) bin/addons/account_voucher/voucher_sales_purchase_view.xml (+0/-328) bin/addons/account_voucher/wizard/__init__.py (+0/-25) bin/addons/account_voucher/wizard/account_statement_from_invoice.py (+0/-198) bin/addons/account_voucher/wizard/account_statement_from_invoice_view.xml (+0/-62) bin/addons/account_voucher/wizard/account_voucher_unreconcile.py (+0/-62) bin/addons/account_voucher/wizard/account_voucher_unreconcile_view.xml (+0/-37) bin/addons/analytic/analytic.py (+1/-0) bin/addons/analytic_distribution/account_commitment.py (+14/-8) bin/addons/analytic_distribution/account_move_line.py (+7/-2) bin/addons/analytic_distribution/analytic_line.py (+6/-2) bin/addons/analytic_distribution/wizard/import_commitment_wizard.py (+4/-1) bin/addons/analytic_distribution_supply/invoice.py (+8/-0) bin/addons/analytic_override/analytic_account.py (+1/-0) bin/addons/analytic_override/analytic_distribution.py (+14/-6) bin/addons/analytic_override/analytic_line.py (+6/-2) bin/addons/base/__init__.py (+1/-0) bin/addons/base/__openerp__.py (+1/-1) bin/addons/base/base_data.xml (+9/-4) bin/addons/base/currency_date.py (+56/-0) bin/addons/base/ir/ir_model.py (+7/-0) bin/addons/base/migrations/8.0.1.5/pre-remove_account_voucher.py (+11/-0) bin/addons/base/res/res_currency.py (+548/-23) bin/addons/base_setup/todo.py (+0/-18) bin/addons/delivery_mechanism/delivery_mechanism.py (+4/-1) bin/addons/finance/__init__.py (+0/-1) bin/addons/finance/__openerp__.py (+1/-2) bin/addons/finance/account_invoice_view.xml (+0/-23) bin/addons/finance/account_voucher.py (+0/-39) bin/addons/finance/cash_request.py (+4/-2) bin/addons/financing_contract/contract.py (+0/-53) bin/addons/financing_contract/format_line.py (+3/-1) bin/addons/financing_contract/report/report_project_expenses.py (+4/-23) bin/addons/financing_contract/wizard/__init__.py (+0/-1) bin/addons/financing_contract/wizard/wizard_csv_report.py (+1/-0) bin/addons/financing_contract/wizard/wizard_expense_report.py (+0/-114) bin/addons/msf_accrual/msf_accrual_line.py (+13/-5) bin/addons/msf_budget/msf_budget_line.py (+2/-1) bin/addons/msf_budget/msf_budget_tools.py (+5/-1) bin/addons/msf_budget/report/report_budget_criteria.py (+2/-1) bin/addons/msf_budget/report/report_pdf_engagement.py (+2/-1) bin/addons/msf_currency_revaluation/__init__.py (+0/-1) bin/addons/msf_currency_revaluation/res_currency.py (+0/-50) bin/addons/msf_currency_revaluation/wizard/wizard_currency_revaluation.py (+9/-4) bin/addons/msf_doc_import/account.py (+5/-1) bin/addons/msf_doc_import/wizard/wizard_import_invoice_line.py (+4/-1) bin/addons/msf_homere_interface/wizard/hr_payroll_import.py (+8/-3) bin/addons/msf_homere_interface/wizard/hr_payroll_validation.py (+5/-2) bin/addons/msf_instance/msf_instance_company_configuration.xml (+5/-0) bin/addons/msf_partner/partner.py (+2/-0) bin/addons/msf_profile/i18n/fr_MF.po (+157/-1322) bin/addons/msf_profile/security/ir.model.access.csv (+2/-2) bin/addons/msf_profile/user_rights/ir.actions.act_window.csv (+0/-1) bin/addons/msf_profile/user_rights/ir.model.access.csv (+2/-8) bin/addons/msf_supply_doc_export/msf_supply_doc_export.py (+19/-9) bin/addons/order_types/report/donation_certificate.py (+1/-0) bin/addons/product/pricelist.py (+15/-174) bin/addons/product/product.py (+1/-42) bin/addons/product_attributes/product_attributes.py (+1/-0) bin/addons/purchase/purchase_order_line.py (+1/-0) bin/addons/purchase/purchase_workflow.py (+5/-2) bin/addons/purchase_followup/report/po_track_changes_report.py (+2/-2) bin/addons/purchase_override/wizard/order_change_currency.py (+3/-1) bin/addons/register_accounting/account_bank_statement.py (+18/-47) bin/addons/register_accounting/account_cash_statement.py (+1/-84) bin/addons/register_accounting/account_cheque_register.py (+0/-2) bin/addons/register_accounting/account_move_line.py (+1/-1) bin/addons/register_accounting/wizard/wizard_cash_return.py (+129/-97) bin/addons/register_accounting/wizard/wizard_cash_return.xml (+1/-3) bin/addons/register_accounting/wizard/wizard_register_import.py (+6/-2) bin/addons/res_currency_functional/__init__.py (+0/-1) bin/addons/res_currency_functional/account_bank_statement_line_compute_currency.py (+6/-2) bin/addons/res_currency_functional/account_move_line_compute_currency.py (+31/-16) bin/addons/res_currency_functional/analytic_move_line_compute_currency.py (+9/-5) bin/addons/res_currency_functional/order_line_compute_currency.py (+4/-2) bin/addons/res_currency_functional/res_currency_functional.py (+0/-80) bin/addons/res_currency_functional/res_currency_rate_functional.py (+17/-2) bin/addons/res_currency_tables/__init__.py (+0/-2) bin/addons/res_currency_tables/res_currency.py (+0/-323) bin/addons/res_currency_tables/res_currency_table.py (+0/-70) bin/addons/res_currency_tables/security/ir.model.access.csv (+1/-1) bin/addons/res_currency_tables/wizard/wizard_report_rates_table_view.xml (+2/-2) bin/addons/sale/report/sale_donation_stock_moves_report.py (+2/-1) bin/addons/sale/report/sale_loan_stock_moves_report.py (+2/-1) bin/addons/sale/wizard/order_change_currency.py (+2/-0) bin/addons/sourcing/procurement_order.py (+1/-0) bin/addons/sourcing/sale_order_line.py (+2/-0) bin/addons/stock/report/stock_delivery_report.py (+1/-0) bin/addons/stock/stock.py (+1501/-147) bin/addons/stock_override/report/report_stock_move.py (+2/-1) bin/addons/stock_override/stock.py (+1/-0) bin/addons/supplier_catalogue/product.py (+1/-173) bin/addons/tender_flow/tender_flow.py (+1/-0) bin/addons/unifield_setup/unifield_setup_data.xml (+0/-12) bin/addons/useability_dashboard_and_menu/menu/hidden_menu.xml (+0/-9) bin/release.py (+1/-1) bin/tools/translate.py (+10/-2) Text conflict in bin/addons/stock/stock.py |
To merge this branch: | bzr merge lp:~julie-w/unifield-server/US-6527 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
UniField Reviewer Team | Pending | ||
Review via email: mp+374913@code.launchpad.net |
Commit message
Description of the change
To post a comment you must log in.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'bin/addons/account/__init__.py' | |||
2 | --- bin/addons/account/__init__.py 2011-01-14 00:11:01 +0000 | |||
3 | +++ bin/addons/account/__init__.py 2019-10-30 13:23:20 +0000 | |||
4 | @@ -33,6 +33,5 @@ | |||
5 | 33 | import product | 33 | import product |
6 | 34 | import sequence | 34 | import sequence |
7 | 35 | import company | 35 | import company |
8 | 36 | import res_currency | ||
9 | 37 | 36 | ||
10 | 38 | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: | 37 | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: |
11 | 39 | 38 | ||
12 | === modified file 'bin/addons/account/__openerp__.py' | |||
13 | --- bin/addons/account/__openerp__.py 2019-07-24 14:20:02 +0000 | |||
14 | +++ bin/addons/account/__openerp__.py 2019-10-30 13:23:20 +0000 | |||
15 | @@ -54,7 +54,6 @@ | |||
16 | 54 | 'report/account_analytic_entries_report_view.xml', | 54 | 'report/account_analytic_entries_report_view.xml', |
17 | 55 | 'wizard/account_move_bank_reconcile_view.xml', | 55 | 'wizard/account_move_bank_reconcile_view.xml', |
18 | 56 | 'wizard/account_use_model_view.xml', | 56 | 'wizard/account_use_model_view.xml', |
19 | 57 | 'account_installer.xml', | ||
20 | 58 | 'wizard/account_period_close_view.xml', | 57 | 'wizard/account_period_close_view.xml', |
21 | 59 | 'account_view.xml', | 58 | 'account_view.xml', |
22 | 60 | 'account_report.xml', | 59 | 'account_report.xml', |
23 | 61 | 60 | ||
24 | === modified file 'bin/addons/account/account.py' | |||
25 | --- bin/addons/account/account.py 2019-07-30 09:13:43 +0000 | |||
26 | +++ bin/addons/account/account.py 2019-10-30 13:23:20 +0000 | |||
27 | @@ -2276,75 +2276,6 @@ | |||
28 | 2276 | _defaults = { | 2276 | _defaults = { |
29 | 2277 | 'legend': lambda self, cr, uid, context:_('You can specify year, month and date in the name of the model using the following labels:\n\n%(year)s: To Specify Year \n%(month)s: To Specify Month \n%(date)s: Current Date\n\ne.g. My model on %(date)s'), | 2277 | 'legend': lambda self, cr, uid, context:_('You can specify year, month and date in the name of the model using the following labels:\n\n%(year)s: To Specify Year \n%(month)s: To Specify Month \n%(date)s: Current Date\n\ne.g. My model on %(date)s'), |
30 | 2278 | } | 2278 | } |
31 | 2279 | def generate(self, cr, uid, ids, datas={}, context=None): | ||
32 | 2280 | move_ids = [] | ||
33 | 2281 | entry = {} | ||
34 | 2282 | account_move_obj = self.pool.get('account.move') | ||
35 | 2283 | account_move_line_obj = self.pool.get('account.move.line') | ||
36 | 2284 | pt_obj = self.pool.get('account.payment.term') | ||
37 | 2285 | |||
38 | 2286 | if context is None: | ||
39 | 2287 | context = {} | ||
40 | 2288 | |||
41 | 2289 | if datas.get('date', False): | ||
42 | 2290 | context.update({'date': datas['date']}) | ||
43 | 2291 | |||
44 | 2292 | period_id = self.pool.get('account.period').find(cr, uid, dt=context.get('date', False)) | ||
45 | 2293 | if not period_id: | ||
46 | 2294 | raise osv.except_osv(_('No period found !'), _('Unable to find a valid period !')) | ||
47 | 2295 | period_id = period_id[0] | ||
48 | 2296 | |||
49 | 2297 | for model in self.browse(cr, uid, ids, context=context): | ||
50 | 2298 | entry['name'] = model.name%{'year':time.strftime('%Y'), 'month':time.strftime('%m'), 'date':time.strftime('%Y-%m')} | ||
51 | 2299 | move_id = account_move_obj.create(cr, uid, { | ||
52 | 2300 | 'ref': entry['name'], | ||
53 | 2301 | 'period_id': period_id, | ||
54 | 2302 | 'journal_id': model.journal_id.id, | ||
55 | 2303 | 'date': context.get('date',time.strftime('%Y-%m-%d')) | ||
56 | 2304 | }) | ||
57 | 2305 | move_ids.append(move_id) | ||
58 | 2306 | for line in model.lines_id: | ||
59 | 2307 | analytic_account_id = False | ||
60 | 2308 | if line.analytic_account_id: | ||
61 | 2309 | if not model.journal_id.analytic_journal_id: | ||
62 | 2310 | raise osv.except_osv(_('No Analytic Journal !'),_("You have to define an analytic journal on the '%s' journal!") % (model.journal_id.name,)) | ||
63 | 2311 | analytic_account_id = line.analytic_account_id.id | ||
64 | 2312 | val = { | ||
65 | 2313 | 'move_id': move_id, | ||
66 | 2314 | 'journal_id': model.journal_id.id, | ||
67 | 2315 | 'period_id': period_id, | ||
68 | 2316 | 'analytic_account_id': analytic_account_id | ||
69 | 2317 | } | ||
70 | 2318 | |||
71 | 2319 | date_maturity = time.strftime('%Y-%m-%d') | ||
72 | 2320 | if line.date_maturity == 'partner': | ||
73 | 2321 | if not line.partner_id: | ||
74 | 2322 | raise osv.except_osv(_('Error !'), _("Maturity date of entry line generated by model line '%s' of model '%s' is based on partner payment term!" \ | ||
75 | 2323 | "\nPlease define partner on it!")%(line.name, model.name)) | ||
76 | 2324 | if line.partner_id.property_payment_term: | ||
77 | 2325 | payment_term_id = line.partner_id.property_payment_term.id | ||
78 | 2326 | pterm_list = pt_obj.compute(cr, uid, payment_term_id, value=1, date_ref=date_maturity) | ||
79 | 2327 | if pterm_list: | ||
80 | 2328 | pterm_list = [l[0] for l in pterm_list] | ||
81 | 2329 | pterm_list.sort() | ||
82 | 2330 | date_maturity = pterm_list[-1] | ||
83 | 2331 | |||
84 | 2332 | val.update({ | ||
85 | 2333 | 'name': line.name, | ||
86 | 2334 | 'quantity': line.quantity, | ||
87 | 2335 | 'debit': line.debit, | ||
88 | 2336 | 'credit': line.credit, | ||
89 | 2337 | 'account_id': line.account_id.id, | ||
90 | 2338 | 'move_id': move_id, | ||
91 | 2339 | 'partner_id': line.partner_id.id, | ||
92 | 2340 | 'date': context.get('date',time.strftime('%Y-%m-%d')), | ||
93 | 2341 | 'date_maturity': date_maturity | ||
94 | 2342 | }) | ||
95 | 2343 | c = context.copy() | ||
96 | 2344 | c.update({'journal_id': model.journal_id.id,'period_id': period_id}) | ||
97 | 2345 | account_move_line_obj.create(cr, uid, val, context=c) | ||
98 | 2346 | |||
99 | 2347 | return move_ids | ||
100 | 2348 | 2279 | ||
101 | 2349 | account_model() | 2280 | account_model() |
102 | 2350 | 2281 | ||
103 | 2351 | 2282 | ||
104 | === modified file 'bin/addons/account/account_analytic_line.py' | |||
105 | --- bin/addons/account/account_analytic_line.py 2018-08-31 13:43:37 +0000 | |||
106 | +++ bin/addons/account/account_analytic_line.py 2019-10-30 13:23:20 +0000 | |||
107 | @@ -63,73 +63,6 @@ | |||
108 | 63 | return False | 63 | return False |
109 | 64 | return True | 64 | return True |
110 | 65 | 65 | ||
111 | 66 | # Compute the cost based on the price type define into company | ||
112 | 67 | # property_valuation_price_type property | ||
113 | 68 | def on_change_unit_amount(self, cr, uid, id, prod_id, quantity, company_id, | ||
114 | 69 | unit=False, journal_id=False, context=None): | ||
115 | 70 | if context==None: | ||
116 | 71 | context={} | ||
117 | 72 | if not journal_id: | ||
118 | 73 | j_ids = self.pool.get('account.analytic.journal').search(cr, uid, [('type','=','purchase')]) | ||
119 | 74 | journal_id = j_ids and j_ids[0] or False | ||
120 | 75 | if not journal_id or not prod_id: | ||
121 | 76 | return {} | ||
122 | 77 | product_obj = self.pool.get('product.product') | ||
123 | 78 | analytic_journal_obj =self.pool.get('account.analytic.journal') | ||
124 | 79 | product_price_type_obj = self.pool.get('product.price.type') | ||
125 | 80 | j_id = analytic_journal_obj.browse(cr, uid, journal_id, context=context) | ||
126 | 81 | prod = product_obj.browse(cr, uid, prod_id, context=context) | ||
127 | 82 | result = 0.0 | ||
128 | 83 | |||
129 | 84 | if j_id.type <> 'sale': | ||
130 | 85 | a = prod.product_tmpl_id.property_account_expense.id | ||
131 | 86 | if not a: | ||
132 | 87 | a = prod.categ_id.property_account_expense_categ.id | ||
133 | 88 | if not a: | ||
134 | 89 | raise osv.except_osv(_('Error !'), | ||
135 | 90 | _('There is no expense account defined ' \ | ||
136 | 91 | 'for this product: "%s" (id:%d)') % \ | ||
137 | 92 | (prod.name, prod.id,)) | ||
138 | 93 | else: | ||
139 | 94 | a = prod.product_tmpl_id.property_account_income.id | ||
140 | 95 | if not a: | ||
141 | 96 | a = prod.categ_id.property_account_income_categ.id | ||
142 | 97 | if not a: | ||
143 | 98 | raise osv.except_osv(_('Error !'), | ||
144 | 99 | _('There is no income account defined ' \ | ||
145 | 100 | 'for this product: "%s" (id:%d)') % \ | ||
146 | 101 | (prod.name, prod_id,)) | ||
147 | 102 | |||
148 | 103 | flag = False | ||
149 | 104 | # Compute based on pricetype | ||
150 | 105 | product_price_type_ids = product_price_type_obj.search(cr, uid, [('field','=','standard_price')], context=context) | ||
151 | 106 | pricetype = product_price_type_obj.browse(cr, uid, product_price_type_ids, context=context)[0] | ||
152 | 107 | if journal_id: | ||
153 | 108 | journal = analytic_journal_obj.browse(cr, uid, journal_id, context=context) | ||
154 | 109 | if journal.type == 'sale': | ||
155 | 110 | product_price_type_ids = product_price_type_obj.search(cr, uid, [('field','=','list_price')], context) | ||
156 | 111 | if product_price_type_ids: | ||
157 | 112 | pricetype = product_price_type_obj.browse(cr, uid, product_price_type_ids, context=context)[0] | ||
158 | 113 | # Take the company currency as the reference one | ||
159 | 114 | if pricetype.field == 'list_price': | ||
160 | 115 | flag = True | ||
161 | 116 | ctx = context.copy() | ||
162 | 117 | if unit: | ||
163 | 118 | # price_get() will respect a 'uom' in its context, in order | ||
164 | 119 | # to return a default price for those units | ||
165 | 120 | ctx['uom'] = unit | ||
166 | 121 | amount_unit = prod.price_get(pricetype.field, context=ctx)[prod.id] | ||
167 | 122 | prec = self.pool.get('decimal.precision').precision_get(cr, uid, 'Account') | ||
168 | 123 | amount = amount_unit * quantity or 1.0 | ||
169 | 124 | result = round(amount, prec) | ||
170 | 125 | if not flag: | ||
171 | 126 | result *= -1 | ||
172 | 127 | return {'value': { | ||
173 | 128 | 'amount': result, | ||
174 | 129 | 'general_account_id': a, | ||
175 | 130 | } | ||
176 | 131 | } | ||
177 | 132 | |||
178 | 133 | def view_header_get(self, cr, user, view_id, view_type, context=None): | 66 | def view_header_get(self, cr, user, view_id, view_type, context=None): |
179 | 134 | if context is None: | 67 | if context is None: |
180 | 135 | context = {} | 68 | context = {} |
181 | 136 | 69 | ||
182 | === modified file 'bin/addons/account/account_bank_statement.py' | |||
183 | --- bin/addons/account/account_bank_statement.py 2016-11-17 08:46:41 +0000 | |||
184 | +++ bin/addons/account/account_bank_statement.py 2019-10-30 13:23:20 +0000 | |||
185 | @@ -25,28 +25,43 @@ | |||
186 | 25 | from tools.translate import _ | 25 | from tools.translate import _ |
187 | 26 | import decimal_precision as dp | 26 | import decimal_precision as dp |
188 | 27 | 27 | ||
189 | 28 | |||
190 | 28 | class account_bank_statement(osv.osv): | 29 | class account_bank_statement(osv.osv): |
191 | 29 | 30 | ||
192 | 30 | def create(self, cr, uid, vals, context=None): | ||
193 | 31 | seq = 0 | ||
194 | 32 | if 'line_ids' in vals: | ||
195 | 33 | for line in vals['line_ids']: | ||
196 | 34 | seq += 1 | ||
197 | 35 | line[2]['sequence'] = seq | ||
198 | 36 | vals[seq - 1] = line | ||
199 | 37 | return super(account_bank_statement, self).create(cr, uid, vals, context=context) | ||
200 | 38 | |||
201 | 39 | def write(self, cr, uid, ids, vals, context=None): | 31 | def write(self, cr, uid, ids, vals, context=None): |
202 | 40 | if not ids: | 32 | if not ids: |
203 | 41 | return True | 33 | return True |
212 | 42 | res = super(account_bank_statement, self).write(cr, uid, ids, vals, context=context) | 34 | if context is None: |
213 | 43 | account_bank_statement_line_obj = self.pool.get('account.bank.statement.line') | 35 | context = {} |
214 | 44 | for statement in self.browse(cr, uid, ids, context): | 36 | |
215 | 45 | seq = 0 | 37 | if not context.get('sync_update_execution'): |
216 | 46 | for line in statement.line_ids: | 38 | if 'balance_end_real' in vals: |
217 | 47 | seq += 1 | 39 | new_vals = {'balance_start': vals['balance_end_real']} |
218 | 48 | account_bank_statement_line_obj.write(cr, uid, [line.id], {'sequence': seq}, context=context) | 40 | # US-948/2: carry over end of month balance to next registers if |
219 | 49 | return res | 41 | # the source register is not 'end of month balance' frozen |
220 | 42 | # note: the last carry over is processed via | ||
221 | 43 | # 'button_confirm_closing_bank_balance' button | ||
222 | 44 | to_write_id_list = [] | ||
223 | 45 | for r in self.read(cr, uid, ids, | ||
224 | 46 | [ 'closing_balance_frozen', 'journal_id', ], | ||
225 | 47 | context=context): | ||
226 | 48 | if not r['closing_balance_frozen']: | ||
227 | 49 | if r['journal_id']: | ||
228 | 50 | jtype = self.pool.get('account.journal').read(cr, | ||
229 | 51 | uid, [r['journal_id'][0]], ['type'], | ||
230 | 52 | context=context)[0]['type'] | ||
231 | 53 | if jtype != 'cash': | ||
232 | 54 | args = [('prev_reg_id', '=', r['id'])] | ||
233 | 55 | search_ids = self.search(cr, uid, args, | ||
234 | 56 | context=context) | ||
235 | 57 | if search_ids: | ||
236 | 58 | to_write_id_list.extend(search_ids) | ||
237 | 59 | self.write(cr, uid, to_write_id_list, new_vals, context=context) | ||
238 | 60 | |||
239 | 61 | if not vals: | ||
240 | 62 | return True | ||
241 | 63 | |||
242 | 64 | return super(account_bank_statement, self).write(cr, uid, ids, vals, context=context) | ||
243 | 50 | 65 | ||
244 | 51 | def _default_journal_id(self, cr, uid, context=None): | 66 | def _default_journal_id(self, cr, uid, context=None): |
245 | 52 | if context is None: | 67 | if context is None: |
246 | @@ -60,43 +75,25 @@ | |||
247 | 60 | journal_id = ids[0] | 75 | journal_id = ids[0] |
248 | 61 | return journal_id | 76 | return journal_id |
249 | 62 | 77 | ||
260 | 63 | def _default_balance_start(self, cr, uid, context=None): | 78 | def _end_balance(self, cr, uid, ids, field_name=None, arg=None, context=None): |
261 | 64 | cr.execute('select id from account_bank_statement where journal_id=%s order by date desc limit 1', (1,)) | 79 | """ |
262 | 65 | res = cr.fetchone() | 80 | Calculate register's balance |
263 | 66 | if res: | 81 | """ |
264 | 67 | return self.browse(cr, uid, res[0], context=context).balance_end | 82 | if context is None: |
265 | 68 | return 0.0 | 83 | context = {} |
256 | 69 | |||
257 | 70 | def _end_balance(self, cursor, user, ids, name, attr, context=None): | ||
258 | 71 | res_currency_obj = self.pool.get('res.currency') | ||
259 | 72 | res_users_obj = self.pool.get('res.users') | ||
266 | 73 | res = {} | 84 | res = {} |
267 | 74 | 85 | ||
273 | 75 | company_currency_id = res_users_obj.browse(cursor, user, user, | 86 | # Add this context in order to escape cheque register filter |
274 | 76 | context=context).company_id.currency_id.id | 87 | ctx = context.copy() |
275 | 77 | 88 | ctx.update({'from_end_balance': True}) | |
276 | 78 | statements = self.browse(cursor, user, ids, context=context) | 89 | for statement in self.browse(cr, uid, ids, context=ctx): |
272 | 79 | for statement in statements: | ||
277 | 80 | res[statement.id] = statement.balance_start | 90 | res[statement.id] = statement.balance_start |
297 | 81 | currency_id = statement.currency.id | 91 | for st_line in statement.line_ids: |
298 | 82 | for line in statement.move_line_ids: | 92 | res[statement.id] += st_line.amount or 0.0 |
299 | 83 | if line.debit > 0: | 93 | # UF-425: Add the Open Advances Amount when calculating the "Calculated Balance" value |
300 | 84 | if line.account_id.id == \ | 94 | res[statement.id] -= statement.open_advance_amount or 0.0 |
301 | 85 | statement.journal_id.default_debit_account_id.id: | 95 | # UF-810: Add a "Unrecorded Expenses" when calculating "Calculated Balance" |
302 | 86 | res[statement.id] += res_currency_obj.compute(cursor, | 96 | res[statement.id] -= statement.unrecorded_expenses_amount or 0.0 |
284 | 87 | user, company_currency_id, currency_id, | ||
285 | 88 | line.debit, context=context) | ||
286 | 89 | else: | ||
287 | 90 | if line.account_id.id == \ | ||
288 | 91 | statement.journal_id.default_credit_account_id.id: | ||
289 | 92 | res[statement.id] -= res_currency_obj.compute(cursor, | ||
290 | 93 | user, company_currency_id, currency_id, | ||
291 | 94 | line.credit, context=context) | ||
292 | 95 | if statement.state == 'draft': | ||
293 | 96 | for line in statement.line_ids: | ||
294 | 97 | res[statement.id] += line.amount | ||
295 | 98 | for r in res: | ||
296 | 99 | res[r] = round(res[r], 2) | ||
303 | 100 | return res | 97 | return res |
304 | 101 | 98 | ||
305 | 102 | def _get_period(self, cr, uid, context=None): | 99 | def _get_period(self, cr, uid, context=None): |
306 | @@ -125,21 +122,18 @@ | |||
307 | 125 | res[statement_id] = (currency_id, currency_names[currency_id]) | 122 | res[statement_id] = (currency_id, currency_names[currency_id]) |
308 | 126 | return res | 123 | return res |
309 | 127 | 124 | ||
310 | 128 | _order = "date desc, id desc" | ||
311 | 129 | _name = "account.bank.statement" | 125 | _name = "account.bank.statement" |
312 | 130 | _description = "Bank Statement" | 126 | _description = "Bank Statement" |
313 | 131 | _columns = { | 127 | _columns = { |
315 | 132 | 'name': fields.char('Name', size=64, required=True, help='if you give the Name other then /, its created Accounting Entries Move will be with same name as statement name. This allows the statement entries to have the same references than the statement itself', states={'confirm': [('readonly', True)]}), | 128 | 'name': fields.char('Register Name', size=64, required=False, readonly=True, states={'draft': [('readonly', False)]}), |
316 | 133 | 'date': fields.date('Date', required=True, states={'confirm': [('readonly', True)]}), | 129 | 'date': fields.date('Date', required=True, states={'confirm': [('readonly', True)]}), |
321 | 134 | 'journal_id': fields.many2one('account.journal', 'Journal', required=True, | 130 | 'journal_id': fields.many2one('account.journal', 'Journal', required=True, readonly=True), |
322 | 135 | readonly=True, states={'draft':[('readonly',False)]}), | 131 | 'period_id': fields.many2one('account.period', 'Period', required=True), |
319 | 136 | 'period_id': fields.many2one('account.period', 'Period', required=True, | ||
320 | 137 | states={'confirm':[('readonly', True)]}), | ||
323 | 138 | 'balance_start': fields.float('Starting Balance', digits_compute=dp.get_precision('Account'), | 132 | 'balance_start': fields.float('Starting Balance', digits_compute=dp.get_precision('Account'), |
324 | 139 | states={'confirm':[('readonly',True)]}), | 133 | states={'confirm':[('readonly',True)]}), |
328 | 140 | 'balance_end_real': fields.float('Ending Balance', digits_compute=dp.get_precision('Account'), | 134 | 'balance_end_real': fields.float('Closing Balance', digits_compute=dp.get_precision('Account'), states={'confirm':[('readonly', True)]}, |
329 | 141 | states={'confirm':[('readonly', True)]}), | 135 | help="Please enter manually the end-of-month balance, as per the printed bank statement received. Before confirming closing balance & closing the register, you must make sure that the calculated balance of the bank statement is equal to that amount."), |
330 | 142 | 'balance_end': fields.function(_end_balance, method=True, string='Balance'), | 136 | 'balance_end': fields.function(_end_balance, method=True, store=False, string='Calculated Balance'), |
331 | 143 | 'company_id': fields.related('journal_id', 'company_id', type='many2one', relation='res.company', string='Company', store=True, readonly=True), | 137 | 'company_id': fields.related('journal_id', 'company_id', type='many2one', relation='res.company', string='Company', store=True, readonly=True), |
332 | 144 | 'line_ids': fields.one2many('account.bank.statement.line', | 138 | 'line_ids': fields.one2many('account.bank.statement.line', |
333 | 145 | 'statement_id', 'Statement lines', | 139 | 'statement_id', 'Statement lines', |
334 | @@ -147,21 +141,18 @@ | |||
335 | 147 | 'deleted_line_ids': fields.one2many('account.bank.statement.line.deleted', 'statement_id', 'Statement lines'), | 141 | 'deleted_line_ids': fields.one2many('account.bank.statement.line.deleted', 'statement_id', 'Statement lines'), |
336 | 148 | 'move_line_ids': fields.one2many('account.move.line', 'statement_id', | 142 | 'move_line_ids': fields.one2many('account.move.line', 'statement_id', |
337 | 149 | 'Entry lines', states={'confirm':[('readonly',True)]}), | 143 | 'Entry lines', states={'confirm':[('readonly',True)]}), |
343 | 150 | 'state': fields.selection([('draft', 'Draft'),('confirm', 'Confirmed')], | 144 | 'state': fields.selection((('draft', 'Draft'), ('open', 'Open'), ('partial_close', 'Partial Close'), ('confirm', 'Closed')), |
344 | 151 | 'State', required=True, | 145 | readonly="True", string='State'), |
340 | 152 | states={'confirm': [('readonly', True)]}, readonly="1", | ||
341 | 153 | help='When new statement is created the state will be \'Draft\'. \ | ||
342 | 154 | \n* And after getting confirmation from the bank it will be in \'Confirmed\' state.'), | ||
345 | 155 | 'currency': fields.function(_currency, method=True, string='Currency', | 146 | 'currency': fields.function(_currency, method=True, string='Currency', |
346 | 156 | type='many2one', relation='res.currency'), | 147 | type='many2one', relation='res.currency'), |
347 | 157 | 'account_id': fields.related('journal_id', 'default_debit_account_id', type='many2one', relation='account.account', string='Account used in this journal', readonly=True, help='used in statement reconciliation domain, but shouldn\'t be used elswhere.'), | 148 | 'account_id': fields.related('journal_id', 'default_debit_account_id', type='many2one', relation='account.account', string='Account used in this journal', readonly=True, help='used in statement reconciliation domain, but shouldn\'t be used elswhere.'), |
348 | 158 | } | 149 | } |
349 | 159 | 150 | ||
350 | 160 | _defaults = { | 151 | _defaults = { |
352 | 161 | 'name': "/", | 152 | 'name': False, |
353 | 162 | 'date': lambda *a: time.strftime('%Y-%m-%d'), | 153 | 'date': lambda *a: time.strftime('%Y-%m-%d'), |
354 | 163 | 'state': 'draft', | 154 | 'state': 'draft', |
356 | 164 | 'balance_start': _default_balance_start, | 155 | 'balance_start': lambda *a: 0.0, |
357 | 165 | 'journal_id': _default_journal_id, | 156 | 'journal_id': _default_journal_id, |
358 | 166 | 'period_id': _get_period, | 157 | 'period_id': _get_period, |
359 | 167 | } | 158 | } |
360 | @@ -199,168 +190,9 @@ | |||
361 | 199 | def button_dummy(self, cr, uid, ids, context=None): | 190 | def button_dummy(self, cr, uid, ids, context=None): |
362 | 200 | return self.write(cr, uid, ids, {}, context=context) | 191 | return self.write(cr, uid, ids, {}, context=context) |
363 | 201 | 192 | ||
364 | 202 | def create_move_from_st_line(self, cr, uid, st_line_id, company_currency_id, st_line_number, context=None): | ||
365 | 203 | if context is None: | ||
366 | 204 | context = {} | ||
367 | 205 | res_currency_obj = self.pool.get('res.currency') | ||
368 | 206 | account_move_obj = self.pool.get('account.move') | ||
369 | 207 | account_move_line_obj = self.pool.get('account.move.line') | ||
370 | 208 | account_bank_statement_line_obj = self.pool.get('account.bank.statement.line') | ||
371 | 209 | st_line = account_bank_statement_line_obj.browse(cr, uid, st_line_id, context=context) | ||
372 | 210 | st = st_line.statement_id | ||
373 | 211 | |||
374 | 212 | context.update({'date': st_line.date}) | ||
375 | 213 | |||
376 | 214 | move_id = account_move_obj.create(cr, uid, { | ||
377 | 215 | 'journal_id': st.journal_id.id, | ||
378 | 216 | 'period_id': st.period_id.id, | ||
379 | 217 | 'date': st_line.date, | ||
380 | 218 | 'name': st_line_number, | ||
381 | 219 | }, context=context) | ||
382 | 220 | account_bank_statement_line_obj.write(cr, uid, [st_line.id], { | ||
383 | 221 | 'move_ids': [(4, move_id, False)] | ||
384 | 222 | }) | ||
385 | 223 | |||
386 | 224 | torec = [] | ||
387 | 225 | if st_line.amount >= 0: | ||
388 | 226 | account_id = st.journal_id.default_credit_account_id.id | ||
389 | 227 | else: | ||
390 | 228 | account_id = st.journal_id.default_debit_account_id.id | ||
391 | 229 | |||
392 | 230 | acc_cur = ((st_line.amount<=0) and st.journal_id.default_debit_account_id) or st_line.account_id | ||
393 | 231 | context.update({ | ||
394 | 232 | 'res.currency.compute.account': acc_cur, | ||
395 | 233 | }) | ||
396 | 234 | amount = res_currency_obj.compute(cr, uid, st.currency.id, | ||
397 | 235 | company_currency_id, st_line.amount, context=context) | ||
398 | 236 | |||
399 | 237 | val = { | ||
400 | 238 | 'name': st_line.name, | ||
401 | 239 | 'date': st_line.date, | ||
402 | 240 | 'ref': st_line.ref, | ||
403 | 241 | 'move_id': move_id, | ||
404 | 242 | 'partner_id': ((st_line.partner_id) and st_line.partner_id.id) or False, | ||
405 | 243 | 'account_id': (st_line.account_id) and st_line.account_id.id, | ||
406 | 244 | 'credit': ((amount>0) and amount) or 0.0, | ||
407 | 245 | 'debit': ((amount<0) and -amount) or 0.0, | ||
408 | 246 | 'statement_id': st.id, | ||
409 | 247 | 'journal_id': st.journal_id.id, | ||
410 | 248 | 'period_id': st.period_id.id, | ||
411 | 249 | 'currency_id': st.currency.id, | ||
412 | 250 | 'analytic_account_id': st_line.analytic_account_id and st_line.analytic_account_id.id or False | ||
413 | 251 | } | ||
414 | 252 | |||
415 | 253 | if st.currency.id <> company_currency_id: | ||
416 | 254 | amount_cur = res_currency_obj.compute(cr, uid, company_currency_id, | ||
417 | 255 | st.currency.id, amount, context=context) | ||
418 | 256 | val['amount_currency'] = -amount_cur | ||
419 | 257 | |||
420 | 258 | if st_line.account_id and st_line.account_id.currency_id and st_line.account_id.currency_id.id <> company_currency_id: | ||
421 | 259 | val['currency_id'] = st_line.account_id.currency_id.id | ||
422 | 260 | amount_cur = res_currency_obj.compute(cr, uid, company_currency_id, | ||
423 | 261 | st_line.account_id.currency_id.id, amount, context=context) | ||
424 | 262 | val['amount_currency'] = -amount_cur | ||
425 | 263 | |||
426 | 264 | move_line_id = account_move_line_obj.create(cr, uid, val, context=context) | ||
427 | 265 | torec.append(move_line_id) | ||
428 | 266 | |||
429 | 267 | # Fill the secondary amount/currency | ||
430 | 268 | # if currency is not the same than the company | ||
431 | 269 | amount_currency = False | ||
432 | 270 | currency_id = False | ||
433 | 271 | if st.currency.id <> company_currency_id: | ||
434 | 272 | amount_currency = st_line.amount | ||
435 | 273 | currency_id = st.currency.id | ||
436 | 274 | account_move_line_obj.create(cr, uid, { | ||
437 | 275 | 'name': st_line.name, | ||
438 | 276 | 'date': st_line.date, | ||
439 | 277 | 'ref': st_line.ref, | ||
440 | 278 | 'move_id': move_id, | ||
441 | 279 | 'partner_id': ((st_line.partner_id) and st_line.partner_id.id) or False, | ||
442 | 280 | 'account_id': account_id, | ||
443 | 281 | 'credit': ((amount < 0) and -amount) or 0.0, | ||
444 | 282 | 'debit': ((amount > 0) and amount) or 0.0, | ||
445 | 283 | 'statement_id': st.id, | ||
446 | 284 | 'journal_id': st.journal_id.id, | ||
447 | 285 | 'period_id': st.period_id.id, | ||
448 | 286 | 'amount_currency': amount_currency, | ||
449 | 287 | 'currency_id': currency_id, | ||
450 | 288 | }, context=context) | ||
451 | 289 | |||
452 | 290 | for line in account_move_line_obj.browse(cr, uid, [x.id for x in | ||
453 | 291 | account_move_obj.browse(cr, uid, move_id, | ||
454 | 292 | context=context).line_id], | ||
455 | 293 | context=context): | ||
456 | 294 | if line.state <> 'valid': | ||
457 | 295 | raise osv.except_osv(_('Error !'), | ||
458 | 296 | _('Journal Item "%s" is not valid') % line.name) | ||
459 | 297 | |||
460 | 298 | # Bank statements will not consider boolean on journal entry_posted | ||
461 | 299 | account_move_obj.post(cr, uid, [move_id], context=context) | ||
462 | 300 | return move_id | ||
463 | 301 | |||
464 | 302 | def get_next_st_line_number(self, cr, uid, st_number, st_line, context=None): | ||
465 | 303 | return st_number + '/' + str(st_line.sequence) | ||
466 | 304 | |||
467 | 305 | def balance_check(self, cr, uid, st_id, journal_type='bank', context=None): | ||
468 | 306 | st = self.browse(cr, uid, st_id, context=context) | ||
469 | 307 | if not (abs((st.balance_end or 0.0) - st.balance_end_real) < 0.0001): | ||
470 | 308 | raise osv.except_osv(_('Error !'), | ||
471 | 309 | _('The statement balance is incorrect !\n') + | ||
472 | 310 | _('The expected balance (%.2f) is different than the computed one. (%.2f)') % (st.balance_end_real, st.balance_end)) | ||
473 | 311 | return True | ||
474 | 312 | |||
475 | 313 | def statement_close(self, cr, uid, ids, journal_type='bank', context=None): | 193 | def statement_close(self, cr, uid, ids, journal_type='bank', context=None): |
476 | 314 | return self.write(cr, uid, ids, {'state':'confirm'}, context=context) | 194 | return self.write(cr, uid, ids, {'state':'confirm'}, context=context) |
477 | 315 | 195 | ||
478 | 316 | def check_status_condition(self, cr, uid, state, journal_type='bank'): | ||
479 | 317 | return state=='draft' | ||
480 | 318 | |||
481 | 319 | def button_confirm_bank(self, cr, uid, ids, context=None): | ||
482 | 320 | done = [] | ||
483 | 321 | obj_seq = self.pool.get('ir.sequence') | ||
484 | 322 | if context is None: | ||
485 | 323 | context = {} | ||
486 | 324 | |||
487 | 325 | for st in self.browse(cr, uid, ids, context=context): | ||
488 | 326 | j_type = st.journal_id.type | ||
489 | 327 | company_currency_id = st.journal_id.company_id.currency_id.id | ||
490 | 328 | if not self.check_status_condition(cr, uid, st.state, journal_type=j_type): | ||
491 | 329 | continue | ||
492 | 330 | |||
493 | 331 | self.balance_check(cr, uid, st.id, journal_type=j_type, context=context) | ||
494 | 332 | if (not st.journal_id.default_credit_account_id) \ | ||
495 | 333 | or (not st.journal_id.default_debit_account_id): | ||
496 | 334 | raise osv.except_osv(_('Configuration Error !'), | ||
497 | 335 | _('Please verify that an account is defined in the journal.')) | ||
498 | 336 | |||
499 | 337 | if not st.name == '/': | ||
500 | 338 | st_number = st.name | ||
501 | 339 | else: | ||
502 | 340 | if st.journal_id.sequence_id: | ||
503 | 341 | c = {'fiscalyear_id': st.period_id.fiscalyear_id.id} | ||
504 | 342 | st_number = obj_seq.get_id(cr, uid, st.journal_id.sequence_id.id, context=c) | ||
505 | 343 | else: | ||
506 | 344 | st_number = obj_seq.get(cr, uid, 'account.bank.statement') | ||
507 | 345 | |||
508 | 346 | for line in st.move_line_ids: | ||
509 | 347 | if line.state <> 'valid': | ||
510 | 348 | raise osv.except_osv(_('Error !'), | ||
511 | 349 | _('The account entries lines are not in valid state.')) | ||
512 | 350 | for st_line in st.line_ids: | ||
513 | 351 | if st_line.analytic_account_id: | ||
514 | 352 | if not st.journal_id.analytic_journal_id: | ||
515 | 353 | raise osv.except_osv(_('No Analytic Journal !'),_("You have to define an analytic journal on the '%s' journal!") % (st.journal_id.name,)) | ||
516 | 354 | if not st_line.amount: | ||
517 | 355 | continue | ||
518 | 356 | st_line_number = self.get_next_st_line_number(cr, uid, st_number, st_line, context) | ||
519 | 357 | self.create_move_from_st_line(cr, uid, st_line.id, company_currency_id, st_line_number, context) | ||
520 | 358 | |||
521 | 359 | self.write(cr, uid, [st.id], {'name': st_number}, context=context) | ||
522 | 360 | self.log(cr, uid, st.id, _('Statement %s is confirmed, journal items are created.') % (st_number,)) | ||
523 | 361 | done.append(st.id) | ||
524 | 362 | return self.write(cr, uid, ids, {'state':'confirm'}, context=context) | ||
525 | 363 | |||
526 | 364 | def button_cancel(self, cr, uid, ids, context=None): | 196 | def button_cancel(self, cr, uid, ids, context=None): |
527 | 365 | done = [] | 197 | done = [] |
528 | 366 | account_move_obj = self.pool.get('account.move') | 198 | account_move_obj = self.pool.get('account.move') |
529 | 367 | 199 | ||
530 | === modified file 'bin/addons/account/account_cash_statement.py' | |||
531 | --- bin/addons/account/account_cash_statement.py 2019-07-30 09:13:43 +0000 | |||
532 | +++ bin/addons/account/account_cash_statement.py 2019-10-30 13:23:20 +0000 | |||
533 | @@ -70,7 +70,6 @@ | |||
534 | 70 | _inherit = 'account.bank.statement' | 70 | _inherit = 'account.bank.statement' |
535 | 71 | 71 | ||
536 | 72 | def _get_starting_balance(self, cr, uid, ids, context=None): | 72 | def _get_starting_balance(self, cr, uid, ids, context=None): |
537 | 73 | |||
538 | 74 | """ Find starting balance | 73 | """ Find starting balance |
539 | 75 | @param name: Names of fields. | 74 | @param name: Names of fields. |
540 | 76 | @param arg: User defined arguments | 75 | @param arg: User defined arguments |
541 | @@ -83,13 +82,18 @@ | |||
542 | 83 | if statement.journal_id.type not in('cash'): | 82 | if statement.journal_id.type not in('cash'): |
543 | 84 | continue | 83 | continue |
544 | 85 | 84 | ||
547 | 86 | for line in statement.starting_details_ids: | 85 | if not statement.prev_reg_id: |
548 | 87 | amount_total+= line.pieces * line.number | 86 | for line in statement.starting_details_ids: |
549 | 87 | amount_total+= line.pieces * line.number | ||
550 | 88 | else: | ||
551 | 89 | amount_total = statement.prev_reg_id.msf_calculated_balance | ||
552 | 90 | |||
553 | 88 | res[statement.id] = { | 91 | res[statement.id] = { |
554 | 89 | 'balance_start': amount_total | 92 | 'balance_start': amount_total |
555 | 90 | } | 93 | } |
556 | 91 | return res | 94 | return res |
557 | 92 | 95 | ||
558 | 96 | |||
559 | 93 | def _balance_end_cash(self, cr, uid, ids, name, arg, context=None): | 97 | def _balance_end_cash(self, cr, uid, ids, name, arg, context=None): |
560 | 94 | """ Find ending balance " | 98 | """ Find ending balance " |
561 | 95 | @param name: Names of fields. | 99 | @param name: Names of fields. |
562 | @@ -119,39 +123,6 @@ | |||
563 | 119 | res2[statement.id] = encoding_total | 123 | res2[statement.id] = encoding_total |
564 | 120 | return res2 | 124 | return res2 |
565 | 121 | 125 | ||
566 | 122 | def _end_balance(self, cursor, user, ids, name, attr, context=None): | ||
567 | 123 | res_currency_obj = self.pool.get('res.currency') | ||
568 | 124 | res_users_obj = self.pool.get('res.users') | ||
569 | 125 | res = {} | ||
570 | 126 | |||
571 | 127 | company_currency_id = res_users_obj.browse(cursor, user, user, | ||
572 | 128 | context=context).company_id.currency_id.id | ||
573 | 129 | |||
574 | 130 | statements = self.browse(cursor, user, ids, context=context) | ||
575 | 131 | for statement in statements: | ||
576 | 132 | res[statement.id] = statement.balance_start | ||
577 | 133 | currency_id = statement.currency.id | ||
578 | 134 | for line in statement.move_line_ids: | ||
579 | 135 | if line.debit > 0: | ||
580 | 136 | if line.account_id.id == \ | ||
581 | 137 | statement.journal_id.default_debit_account_id.id: | ||
582 | 138 | res[statement.id] += res_currency_obj.compute(cursor, | ||
583 | 139 | user, company_currency_id, currency_id, | ||
584 | 140 | line.debit, context=context) | ||
585 | 141 | else: | ||
586 | 142 | if line.account_id.id == \ | ||
587 | 143 | statement.journal_id.default_credit_account_id.id: | ||
588 | 144 | res[statement.id] -= res_currency_obj.compute(cursor, | ||
589 | 145 | user, company_currency_id, currency_id, | ||
590 | 146 | line.credit, context=context) | ||
591 | 147 | |||
592 | 148 | if statement.state in ('draft', 'open'): | ||
593 | 149 | for line in statement.line_ids: | ||
594 | 150 | res[statement.id] += line.amount | ||
595 | 151 | for r in res: | ||
596 | 152 | res[r] = round(res[r], 2) | ||
597 | 153 | return res | ||
598 | 154 | |||
599 | 155 | def _get_company(self, cr, uid, context=None): | 126 | def _get_company(self, cr, uid, context=None): |
600 | 156 | user_pool = self.pool.get('res.users') | 127 | user_pool = self.pool.get('res.users') |
601 | 157 | company_pool = self.pool.get('res.company') | 128 | company_pool = self.pool.get('res.company') |
602 | @@ -218,79 +189,19 @@ | |||
603 | 218 | return res | 189 | return res |
604 | 219 | 190 | ||
605 | 220 | _columns = { | 191 | _columns = { |
606 | 221 | 'balance_end_real': fields.float('Closing Balance', digits_compute=dp.get_precision('Account'), states={'confirm': [('readonly', True)]}, help="closing balance entered by the cashbox verifier"), | ||
607 | 222 | 'state': fields.selection( | ||
608 | 223 | [('draft', 'Draft'), | ||
609 | 224 | ('confirm', 'Closed'), | ||
610 | 225 | ('open','Open')], 'State', required=True, states={'confirm': [('readonly', True)]}, readonly="1"), | ||
611 | 226 | 'total_entry_encoding': fields.function(_get_sum_entry_encoding, method=True, store=False, string="Cash Transaction", help="Total cash transactions"), | 192 | 'total_entry_encoding': fields.function(_get_sum_entry_encoding, method=True, store=False, string="Cash Transaction", help="Total cash transactions"), |
612 | 227 | 'balance_end': fields.function(_end_balance, method=True, store=False, string='Balance', help="Closing balance based on Starting Balance and Cash Transactions"), | ||
613 | 228 | 'balance_end_cash': fields.function(_balance_end_cash, method=True, store=False, string='Balance', help="Closing balance based on cashBox"), | 193 | 'balance_end_cash': fields.function(_balance_end_cash, method=True, store=False, string='Balance', help="Closing balance based on cashBox"), |
614 | 229 | 'starting_details_ids': fields.one2many('account.cashbox.line', 'starting_id', string='Opening Cashbox'), | 194 | 'starting_details_ids': fields.one2many('account.cashbox.line', 'starting_id', string='Opening Cashbox'), |
615 | 230 | 'ending_details_ids': fields.one2many('account.cashbox.line', 'ending_id', string='Closing Cashbox'), | 195 | 'ending_details_ids': fields.one2many('account.cashbox.line', 'ending_id', string='Closing Cashbox'), |
616 | 231 | 'name': fields.char('Name', size=64, required=True, states={'draft': [('readonly', False)]}, readonly=True, help='if you give the Name other then /, its created Accounting Entries Move will be with same name as statement name. This allows the statement entries to have the same references than the statement itself'), | ||
617 | 232 | 'user_id': fields.many2one('res.users', 'Responsible', required=False), | 196 | 'user_id': fields.many2one('res.users', 'Responsible', required=False), |
618 | 233 | } | 197 | } |
619 | 234 | _defaults = { | 198 | _defaults = { |
620 | 235 | 'state': 'draft', | ||
621 | 236 | 'date': lambda *a: time.strftime("%Y-%m-%d %H:%M:%S"), | 199 | 'date': lambda *a: time.strftime("%Y-%m-%d %H:%M:%S"), |
622 | 237 | 'user_id': lambda self, cr, uid, context=None: uid, | 200 | 'user_id': lambda self, cr, uid, context=None: uid, |
623 | 238 | 'starting_details_ids': _get_cash_open_box_lines, | 201 | 'starting_details_ids': _get_cash_open_box_lines, |
624 | 239 | 'ending_details_ids': _get_default_cash_close_box_lines | 202 | 'ending_details_ids': _get_default_cash_close_box_lines |
625 | 240 | } | 203 | } |
626 | 241 | 204 | ||
627 | 242 | def create(self, cr, uid, vals, context=None): | ||
628 | 243 | sql = [ | ||
629 | 244 | ('journal_id', '=', vals.get('journal_id', False)), | ||
630 | 245 | ('state', '=', 'open') | ||
631 | 246 | ] | ||
632 | 247 | open_jrnl = self.search(cr, uid, sql) | ||
633 | 248 | if open_jrnl: | ||
634 | 249 | raise osv.except_osv(_('Error'), _('You can not have two open register for the same journal')) | ||
635 | 250 | |||
636 | 251 | if self.pool.get('account.journal').browse(cr, uid, vals['journal_id'], context=context).type == 'cash': | ||
637 | 252 | open_close = self._get_cash_open_close_box_lines(cr, uid, context) | ||
638 | 253 | if vals.get('starting_details_ids', False): | ||
639 | 254 | for start in vals.get('starting_details_ids'): | ||
640 | 255 | dict_val = start[2] | ||
641 | 256 | for end in open_close['end']: | ||
642 | 257 | if end[2]['pieces'] == dict_val['pieces']: | ||
643 | 258 | end[2]['number'] += dict_val['number'] | ||
644 | 259 | vals.update({ | ||
645 | 260 | # 'ending_details_ids': open_close['start'], | ||
646 | 261 | 'starting_details_ids': open_close['end'] | ||
647 | 262 | }) | ||
648 | 263 | else: | ||
649 | 264 | vals.update({ | ||
650 | 265 | 'ending_details_ids': False, | ||
651 | 266 | 'starting_details_ids': False | ||
652 | 267 | }) | ||
653 | 268 | res_id = super(account_cash_statement, self).create(cr, uid, vals, context=context) | ||
654 | 269 | self.write(cr, uid, [res_id], {}) | ||
655 | 270 | return res_id | ||
656 | 271 | |||
657 | 272 | def write(self, cr, uid, ids, vals, context=None): | ||
658 | 273 | """ | ||
659 | 274 | Update redord(s) comes in {ids}, with new value comes as {vals} | ||
660 | 275 | return True on success, False otherwise | ||
661 | 276 | |||
662 | 277 | @param cr: cursor to database | ||
663 | 278 | @param user: id of current user | ||
664 | 279 | @param ids: list of record ids to be update | ||
665 | 280 | @param vals: dict of new values to be set | ||
666 | 281 | @param context: context arguments, like lang, time zone | ||
667 | 282 | |||
668 | 283 | @return: True on success, False otherwise | ||
669 | 284 | """ | ||
670 | 285 | if not ids: | ||
671 | 286 | return True | ||
672 | 287 | |||
673 | 288 | super(account_cash_statement, self).write(cr, uid, ids, vals, context=context) | ||
674 | 289 | res = self._get_starting_balance(cr, uid, ids) | ||
675 | 290 | for rs in res: | ||
676 | 291 | super(account_cash_statement, self).write(cr, uid, [rs], res.get(rs)) | ||
677 | 292 | return True | ||
678 | 293 | |||
679 | 294 | def onchange_journal_id(self, cr, uid, statement_id, journal_id, context=None): | 205 | def onchange_journal_id(self, cr, uid, statement_id, journal_id, context=None): |
680 | 295 | """ Changes balance start and starting details if journal_id changes" | 206 | """ Changes balance start and starting details if journal_id changes" |
681 | 296 | @param statement_id: Changed statement_id | 207 | @param statement_id: Changed statement_id |
682 | @@ -346,13 +257,6 @@ | |||
683 | 346 | self.write(cr, uid, [statement.id], vals, context=context) | 257 | self.write(cr, uid, [statement.id], vals, context=context) |
684 | 347 | return True | 258 | return True |
685 | 348 | 259 | ||
686 | 349 | def balance_check(self, cr, uid, cash_id, journal_type='bank', context=None): | ||
687 | 350 | if journal_type == 'bank': | ||
688 | 351 | return super(account_cash_statement, self).balance_check(cr, uid, cash_id, journal_type, context) | ||
689 | 352 | if not self._equal_balance(cr, uid, cash_id, context): | ||
690 | 353 | raise osv.except_osv(_('Error !'), _('CashBox Balance is not matching with Calculated Balance !')) | ||
691 | 354 | return True | ||
692 | 355 | |||
693 | 356 | def statement_close(self, cr, uid, ids, journal_type='bank', context=None): | 260 | def statement_close(self, cr, uid, ids, journal_type='bank', context=None): |
694 | 357 | if journal_type == 'bank': | 261 | if journal_type == 'bank': |
695 | 358 | return super(account_cash_statement, self).statement_close(cr, uid, ids, journal_type, context) | 262 | return super(account_cash_statement, self).statement_close(cr, uid, ids, journal_type, context) |
696 | @@ -362,15 +266,6 @@ | |||
697 | 362 | } | 266 | } |
698 | 363 | return self.write(cr, uid, ids, vals, context=context) | 267 | return self.write(cr, uid, ids, vals, context=context) |
699 | 364 | 268 | ||
700 | 365 | def check_status_condition(self, cr, uid, state, journal_type='bank'): | ||
701 | 366 | if journal_type == 'bank': | ||
702 | 367 | return super(account_cash_statement, self).check_status_condition(cr, uid, state, journal_type) | ||
703 | 368 | return state=='open' | ||
704 | 369 | |||
705 | 370 | def button_confirm_cash(self, cr, uid, ids, context=None): | ||
706 | 371 | super(account_cash_statement, self).button_confirm_bank(cr, uid, ids, context=context) | ||
707 | 372 | return self.write(cr, uid, ids, {'closing_date': time.strftime("%Y-%m-%d %H:%M:%S")}, context=context) | ||
708 | 373 | |||
709 | 374 | def button_cancel(self, cr, uid, ids, context=None): | 269 | def button_cancel(self, cr, uid, ids, context=None): |
710 | 375 | cash_box_line_pool = self.pool.get('account.cashbox.line') | 270 | cash_box_line_pool = self.pool.get('account.cashbox.line') |
711 | 376 | super(account_cash_statement, self).button_cancel(cr, uid, ids, context=context) | 271 | super(account_cash_statement, self).button_cancel(cr, uid, ids, context=context) |
712 | 377 | 272 | ||
713 | === removed file 'bin/addons/account/account_installer.xml' | |||
714 | --- bin/addons/account/account_installer.xml 2011-01-14 00:11:01 +0000 | |||
715 | +++ bin/addons/account/account_installer.xml 1970-01-01 00:00:00 +0000 | |||
716 | @@ -1,130 +0,0 @@ | |||
717 | 1 | <openerp> | ||
718 | 2 | <data> | ||
719 | 3 | <record id="view_account_configuration_installer" model="ir.ui.view"> | ||
720 | 4 | <field name="name">account.installer.form</field> | ||
721 | 5 | <field name="model">account.installer</field> | ||
722 | 6 | <field name="type">form</field> | ||
723 | 7 | <field name="inherit_id" ref="base.res_config_installer"/> | ||
724 | 8 | <field name="arch" type="xml"> | ||
725 | 9 | <data> | ||
726 | 10 | <form position="attributes"> | ||
727 | 11 | <attribute name="string">Accounting Application Configuration</attribute> | ||
728 | 12 | </form> | ||
729 | 13 | <separator string="title" position="attributes"> | ||
730 | 14 | <attribute name="string">Configure Your Accounting Chart</attribute> | ||
731 | 15 | </separator> | ||
732 | 16 | <xpath expr="//label[@string='description']" position="attributes"> | ||
733 | 17 | <attribute name="string">The default Chart of Accounts is matching your country selection. If no certified Chart of Accounts exists for your specified country, a generic one can be installed and will be selected by default.</attribute> | ||
734 | 18 | </xpath> | ||
735 | 19 | <xpath expr="//button[@string='Install Modules']" position="attributes"> | ||
736 | 20 | <attribute name="string">Configure</attribute> | ||
737 | 21 | </xpath> | ||
738 | 22 | <xpath expr='//separator[@string="vsep"]' position='attributes'> | ||
739 | 23 | <attribute name='rowspan'>23</attribute> | ||
740 | 24 | <attribute name='string'></attribute> | ||
741 | 25 | </xpath> | ||
742 | 26 | <group colspan="8"> | ||
743 | 27 | <group colspan="4" width="600"> | ||
744 | 28 | <field name="charts"/> | ||
745 | 29 | <group colspan="4" groups="base.group_extended"> | ||
746 | 30 | <separator col="4" colspan="4" string="Configure Fiscal Year"/> | ||
747 | 31 | <field name="company_id" colspan="4" widget="selection"/><!-- we assume that this wizard will be run only by administrators and as this field may cause problem if hidden (because of the default company of the user removed from the selection because already configured), we simply choosed to remove the group "multi company" of it --> | ||
748 | 32 | <field name="date_start" on_change="on_change_start_date(date_start)"/> | ||
749 | 33 | <field name="date_stop"/> | ||
750 | 34 | <field name="period" colspan="4"/> | ||
751 | 35 | </group> | ||
752 | 36 | <group colspan="4" attrs="{'invisible':[('charts','!=','configurable')]}"> | ||
753 | 37 | <field name="sale_tax" on_change="on_change_tax(sale_tax)" attrs="{'required':[('charts','=','configurable')]}"/> | ||
754 | 38 | <field name="purchase_tax" groups="base.group_extended"/> | ||
755 | 39 | </group> | ||
756 | 40 | <group colspan="4" attrs="{'invisible':[('charts','!=','configurable')]}"> | ||
757 | 41 | <separator col="4" colspan="4" string="Bank and Cash Accounts"/> | ||
758 | 42 | <field colspan="4" mode="tree" height="200" name="bank_accounts_id" nolabel="1" widget="one2many_list"> | ||
759 | 43 | <form string=""> | ||
760 | 44 | <field name="acc_name"/> | ||
761 | 45 | <field name="account_type"/> | ||
762 | 46 | <field name="currency_id" widget="selection" groups="base.group_extended"/> | ||
763 | 47 | </form> | ||
764 | 48 | <tree editable="bottom" string="Your bank and cash accounts"> | ||
765 | 49 | <field name="acc_name"/> | ||
766 | 50 | <field name="account_type"/> | ||
767 | 51 | <field name="currency_id" widget="selection" groups="base.group_extended"/> | ||
768 | 52 | </tree> | ||
769 | 53 | </field> | ||
770 | 54 | </group> | ||
771 | 55 | </group> | ||
772 | 56 | </group> | ||
773 | 57 | </data> | ||
774 | 58 | </field> | ||
775 | 59 | </record> | ||
776 | 60 | |||
777 | 61 | <record id="view_account_modules_installer" model="ir.ui.view"> | ||
778 | 62 | <field name="name">account.installer.modules.form</field> | ||
779 | 63 | <field name="model">account.installer.modules</field> | ||
780 | 64 | <field name="type">form</field> | ||
781 | 65 | <field name="inherit_id" ref="base.res_config_installer"/> | ||
782 | 66 | <field name="arch" type="xml"> | ||
783 | 67 | <data> | ||
784 | 68 | <form position="attributes"> | ||
785 | 69 | <attribute name="string">Accounting Application Configuration</attribute> | ||
786 | 70 | </form> | ||
787 | 71 | <separator string="title" position="attributes"> | ||
788 | 72 | <attribute name="string">Configure Your Accounting Application</attribute> | ||
789 | 73 | |||
790 | 74 | </separator> | ||
791 | 75 | <xpath expr="//label[@string='description']" position="attributes"> | ||
792 | 76 | <attribute name="string">Add extra Accounting functionalities to the ones already installed.</attribute> | ||
793 | 77 | </xpath> | ||
794 | 78 | <xpath expr="//button[@string='Install Modules']" position="attributes"> | ||
795 | 79 | <attribute name="string">Configure</attribute> | ||
796 | 80 | </xpath> | ||
797 | 81 | <xpath expr='//separator[@string="vsep"]' position='attributes'> | ||
798 | 82 | <attribute name='string'></attribute> | ||
799 | 83 | </xpath> | ||
800 | 84 | <group colspan="8"> | ||
801 | 85 | <field name="account_voucher"/> | ||
802 | 86 | <field name="account_followup"/> | ||
803 | 87 | <field name="account_payment"/> | ||
804 | 88 | <field name="account_analytic_plans"/> | ||
805 | 89 | <field name="account_anglo_saxon"/> | ||
806 | 90 | <!-- <field name="account_voucher_payment"/>--> | ||
807 | 91 | </group> | ||
808 | 92 | </data> | ||
809 | 93 | </field> | ||
810 | 94 | </record> | ||
811 | 95 | |||
812 | 96 | <record id="action_account_configuration_installer" model="ir.actions.act_window"> | ||
813 | 97 | <field name="name">Accounting Chart Configuration</field> | ||
814 | 98 | <field name="type">ir.actions.act_window</field> | ||
815 | 99 | <field name="res_model">account.installer</field> | ||
816 | 100 | <field name="view_id" ref="view_account_configuration_installer"/> | ||
817 | 101 | <field name="view_type">form</field> | ||
818 | 102 | <field name="view_mode">form</field> | ||
819 | 103 | <field name="target">new</field> | ||
820 | 104 | </record> | ||
821 | 105 | |||
822 | 106 | <record id="action_account_installer" model="ir.actions.act_window"> | ||
823 | 107 | <field name="name">Accounting Application Configuration</field> | ||
824 | 108 | <field name="type">ir.actions.act_window</field> | ||
825 | 109 | <field name="res_model">account.installer.modules</field> | ||
826 | 110 | <field name="view_id" ref="view_account_modules_installer"/> | ||
827 | 111 | <field name="view_type">form</field> | ||
828 | 112 | <field name="view_mode">form</field> | ||
829 | 113 | <field name="target">new</field> | ||
830 | 114 | </record> | ||
831 | 115 | |||
832 | 116 | <record id="account_configuration_installer_todo" model="ir.actions.todo"> | ||
833 | 117 | <field name="action_id" ref="action_account_configuration_installer"/> | ||
834 | 118 | <field name="sequence">3</field> | ||
835 | 119 | <field name="restart">onskip</field> | ||
836 | 120 | </record> | ||
837 | 121 | |||
838 | 122 | <record id="account_installer_todo" model="ir.actions.todo"> | ||
839 | 123 | <field name="action_id" ref="action_account_installer"/> | ||
840 | 124 | <field name="sequence">5</field> | ||
841 | 125 | <field name="restart">always</field> | ||
842 | 126 | <field eval="[(6,0,[ref('base.group_extended')])]" name="groups_id"/> | ||
843 | 127 | </record> | ||
844 | 128 | |||
845 | 129 | </data> | ||
846 | 130 | </openerp> | ||
847 | 131 | 0 | ||
848 | === modified file 'bin/addons/account/account_invoice_view.xml' | |||
849 | --- bin/addons/account/account_invoice_view.xml 2019-07-29 15:00:38 +0000 | |||
850 | +++ bin/addons/account/account_invoice_view.xml 2019-10-30 13:23:20 +0000 | |||
851 | @@ -223,8 +223,11 @@ | |||
852 | 223 | domain="[('type', 'not in', ['view', 'consolidation']), | 223 | domain="[('type', 'not in', ['view', 'consolidation']), |
853 | 224 | ('user_type_code', '=', 'tax')]"/> | 224 | ('user_type_code', '=', 'tax')]"/> |
854 | 225 | 225 | ||
857 | 226 | <field name="base" on_change="base_change(base,parent.currency_id,parent.company_id,parent.date_invoice)" readonly="1"/> | 226 | <field name="base" |
858 | 227 | <field name="amount" on_change="amount_change(amount,parent.currency_id,parent.company_id,parent.date_invoice)"/> | 227 | on_change="base_change(base, parent.currency_id, parent.company_id, parent.document_date, parent.date_invoice)" |
859 | 228 | readonly="1"/> | ||
860 | 229 | <field name="amount" | ||
861 | 230 | on_change="amount_change(amount, parent.currency_id, parent.company_id, parent.document_date, parent.date_invoice)"/> | ||
862 | 228 | 231 | ||
863 | 229 | <field invisible="True" name="base_amount"/> | 232 | <field invisible="True" name="base_amount"/> |
864 | 230 | <field invisible="True" name="tax_amount"/> | 233 | <field invisible="True" name="tax_amount"/> |
865 | @@ -339,8 +342,11 @@ | |||
866 | 339 | <tree editable="bottom" string="Taxes"> | 342 | <tree editable="bottom" string="Taxes"> |
867 | 340 | <field name="name"/> | 343 | <field name="name"/> |
868 | 341 | <field name="account_id" groups="account.group_account_invoice"/> | 344 | <field name="account_id" groups="account.group_account_invoice"/> |
871 | 342 | <field name="base" on_change="base_change(base,parent.currency_id,parent.company_id,parent.date_invoice)" readonly="1"/> | 345 | <field name="base" |
872 | 343 | <field name="amount" on_change="amount_change(amount,parent.currency_id,parent.company_id,parent.date_invoice)"/> | 346 | on_change="base_change(base, parent.currency_id, parent.company_id, parent.document_date, parent.date_invoice)" |
873 | 347 | readonly="1"/> | ||
874 | 348 | <field name="amount" | ||
875 | 349 | on_change="amount_change(amount, parent.currency_id, parent.company_id, parent.document_date, parent.date_invoice)"/> | ||
876 | 344 | <field invisible="True" name="base_amount"/> | 350 | <field invisible="True" name="base_amount"/> |
877 | 345 | <field invisible="True" name="tax_amount"/> | 351 | <field invisible="True" name="tax_amount"/> |
878 | 346 | <field name="factor_base" invisible="True"/> | 352 | <field name="factor_base" invisible="True"/> |
879 | 347 | 353 | ||
880 | === modified file 'bin/addons/account/account_move_line.py' | |||
881 | --- bin/addons/account/account_move_line.py 2019-09-17 16:00:23 +0000 | |||
882 | +++ bin/addons/account/account_move_line.py 2019-10-30 13:23:20 +0000 | |||
883 | @@ -21,7 +21,6 @@ | |||
884 | 21 | 21 | ||
885 | 22 | import time | 22 | import time |
886 | 23 | from datetime import datetime | 23 | from datetime import datetime |
887 | 24 | from operator import itemgetter | ||
888 | 25 | 24 | ||
889 | 26 | from osv import fields, osv | 25 | from osv import fields, osv |
890 | 27 | from tools.translate import _ | 26 | from tools.translate import _ |
891 | @@ -29,6 +28,7 @@ | |||
892 | 29 | import tools | 28 | import tools |
893 | 30 | import netsvc | 29 | import netsvc |
894 | 31 | 30 | ||
895 | 31 | |||
896 | 32 | class account_move_line(osv.osv): | 32 | class account_move_line(osv.osv): |
897 | 33 | _name = "account.move.line" | 33 | _name = "account.move.line" |
898 | 34 | _description = "Journal Items" | 34 | _description = "Journal Items" |
899 | @@ -149,57 +149,6 @@ | |||
900 | 149 | query += company_clause | 149 | query += company_clause |
901 | 150 | return query | 150 | return query |
902 | 151 | 151 | ||
903 | 152 | def _amount_residual(self, cr, uid, ids, field_names, args, context=None): | ||
904 | 153 | """ | ||
905 | 154 | This function returns the residual amount on a receivable or payable account.move.line. | ||
906 | 155 | By default, it returns an amount in the currency of this journal entry (maybe different | ||
907 | 156 | of the company currency), but if you pass 'residual_in_company_currency' = True in the | ||
908 | 157 | context then the returned amount will be in company currency. | ||
909 | 158 | """ | ||
910 | 159 | res = {} | ||
911 | 160 | if context is None: | ||
912 | 161 | context = {} | ||
913 | 162 | cur_obj = self.pool.get('res.currency') | ||
914 | 163 | for move_line in self.browse(cr, uid, ids, context=context): | ||
915 | 164 | res[move_line.id] = { | ||
916 | 165 | 'amount_residual': 0.0, | ||
917 | 166 | 'amount_residual_currency': 0.0, | ||
918 | 167 | } | ||
919 | 168 | |||
920 | 169 | if move_line.reconcile_id: | ||
921 | 170 | continue | ||
922 | 171 | if not move_line.account_id.type in ('payable', 'receivable'): | ||
923 | 172 | #this function does not suport to be used on move lines not related to payable or receivable accounts | ||
924 | 173 | continue | ||
925 | 174 | |||
926 | 175 | if move_line.currency_id: | ||
927 | 176 | move_line_total = move_line.amount_currency | ||
928 | 177 | sign = move_line.amount_currency < 0 and -1 or 1 | ||
929 | 178 | else: | ||
930 | 179 | move_line_total = move_line.debit - move_line.credit | ||
931 | 180 | sign = (move_line.debit - move_line.credit) < 0 and -1 or 1 | ||
932 | 181 | line_total_in_company_currency = move_line.debit - move_line.credit | ||
933 | 182 | context_unreconciled = context.copy() | ||
934 | 183 | if move_line.reconcile_partial_id: | ||
935 | 184 | for payment_line in move_line.reconcile_partial_id.line_partial_ids: | ||
936 | 185 | if payment_line.id == move_line.id: | ||
937 | 186 | continue | ||
938 | 187 | if payment_line.currency_id and move_line.currency_id and payment_line.currency_id.id == move_line.currency_id.id: | ||
939 | 188 | move_line_total += payment_line.amount_currency | ||
940 | 189 | else: | ||
941 | 190 | if move_line.currency_id: | ||
942 | 191 | context_unreconciled.update({'date': payment_line.date}) | ||
943 | 192 | amount_in_foreign_currency = cur_obj.compute(cr, uid, move_line.company_id.currency_id.id, move_line.currency_id.id, (payment_line.debit - payment_line.credit), round=False, context=context_unreconciled) | ||
944 | 193 | move_line_total += amount_in_foreign_currency | ||
945 | 194 | else: | ||
946 | 195 | move_line_total += (payment_line.debit - payment_line.credit) | ||
947 | 196 | line_total_in_company_currency += (payment_line.debit - payment_line.credit) | ||
948 | 197 | |||
949 | 198 | result = move_line_total | ||
950 | 199 | res[move_line.id]['amount_residual_currency'] = sign * (move_line.currency_id and self.pool.get('res.currency').round(cr, uid, move_line.currency_id.rounding, result) or result) | ||
951 | 200 | res[move_line.id]['amount_residual'] = sign * line_total_in_company_currency | ||
952 | 201 | return res | ||
953 | 202 | |||
954 | 203 | def default_get(self, cr, uid, fields, context=None): | 152 | def default_get(self, cr, uid, fields, context=None): |
955 | 204 | data = self._default_get(cr, uid, fields, context=context) | 153 | data = self._default_get(cr, uid, fields, context=context) |
956 | 205 | for f in data.keys(): | 154 | for f in data.keys(): |
957 | @@ -387,18 +336,6 @@ | |||
958 | 387 | data['debit'] = s > 0 and s or 0.0 | 336 | data['debit'] = s > 0 and s or 0.0 |
959 | 388 | data['credit'] = s < 0 and -s or 0.0 | 337 | data['credit'] = s < 0 and -s or 0.0 |
960 | 389 | 338 | ||
961 | 390 | if account and account.currency_id: | ||
962 | 391 | data['currency_id'] = account.currency_id.id | ||
963 | 392 | acc = account | ||
964 | 393 | if s>0: | ||
965 | 394 | acc = acc1 | ||
966 | 395 | compute_ctx = context.copy() | ||
967 | 396 | compute_ctx.update({ | ||
968 | 397 | 'res.currency.compute.account': acc, | ||
969 | 398 | 'res.currency.compute.account_invert': True, | ||
970 | 399 | }) | ||
971 | 400 | v = currency_obj.compute(cr, uid, account.company_id.currency_id.id, data['currency_id'], s, context=compute_ctx) | ||
972 | 401 | data['amount_currency'] = v | ||
973 | 402 | return data | 339 | return data |
974 | 403 | 340 | ||
975 | 404 | def on_create_write(self, cr, uid, id, context=None): | 341 | def on_create_write(self, cr, uid, id, context=None): |
976 | @@ -601,8 +538,6 @@ | |||
977 | 601 | 'reconcile_id': fields.many2one('account.move.reconcile', 'Reconcile', readonly=True, ondelete='set null', select=2), | 538 | 'reconcile_id': fields.many2one('account.move.reconcile', 'Reconcile', readonly=True, ondelete='set null', select=2), |
978 | 602 | 'reconcile_partial_id': fields.many2one('account.move.reconcile', 'Partial Reconcile', readonly=True, ondelete='set null', select=2), | 539 | 'reconcile_partial_id': fields.many2one('account.move.reconcile', 'Partial Reconcile', readonly=True, ondelete='set null', select=2), |
979 | 603 | 'amount_currency': fields.float('Amount Currency', help="The amount expressed in an optional other currency if it is a multi-currency entry.", digits_compute=dp.get_precision('Account')), | 540 | 'amount_currency': fields.float('Amount Currency', help="The amount expressed in an optional other currency if it is a multi-currency entry.", digits_compute=dp.get_precision('Account')), |
980 | 604 | 'amount_residual_currency': fields.function(_amount_residual, method=True, string='Residual Amount', multi="residual", help="The residual amount on a receivable or payable of a journal entry expressed in its currency (maybe different of the company currency)."), | ||
981 | 605 | 'amount_residual': fields.function(_amount_residual, method=True, string='Residual Amount', multi="residual", help="The residual amount on a receivable or payable of a journal entry expressed in the company currency."), | ||
982 | 606 | 'currency_id': fields.many2one('res.currency', 'Currency', help="The optional other currency if it is a multi-currency entry."), | 541 | 'currency_id': fields.many2one('res.currency', 'Currency', help="The optional other currency if it is a multi-currency entry."), |
983 | 607 | 'period_id': fields.many2one('account.period', 'Period', required=True, select=2), | 542 | 'period_id': fields.many2one('account.period', 'Period', required=True, select=2), |
984 | 608 | 'fiscalyear_id': fields.related('period_id', 'fiscalyear_id', type='many2one', relation='account.fiscalyear', string='Fiscal Year', store=False), | 543 | 'fiscalyear_id': fields.related('period_id', 'fiscalyear_id', type='many2one', relation='account.fiscalyear', string='Fiscal Year', store=False), |
985 | @@ -737,31 +672,6 @@ | |||
986 | 737 | (_check_company_id, 'Company must be same for its related account and period.',['company_id'] ), | 672 | (_check_company_id, 'Company must be same for its related account and period.',['company_id'] ), |
987 | 738 | ] | 673 | ] |
988 | 739 | 674 | ||
989 | 740 | #TODO: ONCHANGE_ACCOUNT_ID: set account_tax_id | ||
990 | 741 | def onchange_currency(self, cr, uid, ids, account_id, amount, currency_id, date=False, journal=False, context=None): | ||
991 | 742 | if context is None: | ||
992 | 743 | context = {} | ||
993 | 744 | account_obj = self.pool.get('account.account') | ||
994 | 745 | journal_obj = self.pool.get('account.journal') | ||
995 | 746 | currency_obj = self.pool.get('res.currency') | ||
996 | 747 | if (not currency_id) or (not account_id): | ||
997 | 748 | return {} | ||
998 | 749 | result = {} | ||
999 | 750 | acc = account_obj.browse(cr, uid, account_id, context=context) | ||
1000 | 751 | if (amount>0) and journal: | ||
1001 | 752 | x = journal_obj.browse(cr, uid, journal).default_credit_account_id | ||
1002 | 753 | if x: acc = x | ||
1003 | 754 | context.update({ | ||
1004 | 755 | 'date': date, | ||
1005 | 756 | 'res.currency.compute.account': acc, | ||
1006 | 757 | }) | ||
1007 | 758 | v = currency_obj.compute(cr, uid, currency_id, acc.company_id.currency_id.id, amount, context=context) | ||
1008 | 759 | result['value'] = { | ||
1009 | 760 | 'debit': v > 0 and v or 0.0, | ||
1010 | 761 | 'credit': v < 0 and -v or 0.0 | ||
1011 | 762 | } | ||
1012 | 763 | return result | ||
1013 | 764 | |||
1014 | 765 | def onchange_partner_id(self, cr, uid, ids, move_id, partner_id, account_id=None, debit=0, credit=0, date=False, journal=False): | 675 | def onchange_partner_id(self, cr, uid, ids, move_id, partner_id, account_id=None, debit=0, credit=0, date=False, journal=False): |
1015 | 766 | partner_obj = self.pool.get('res.partner') | 676 | partner_obj = self.pool.get('res.partner') |
1016 | 767 | payment_term_obj = self.pool.get('account.payment.term') | 677 | payment_term_obj = self.pool.get('account.payment.term') |
1017 | @@ -901,123 +811,6 @@ | |||
1018 | 901 | 'context':context, | 811 | 'context':context, |
1019 | 902 | } | 812 | } |
1020 | 903 | 813 | ||
1021 | 904 | def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False): | ||
1022 | 905 | journal_pool = self.pool.get('account.journal') | ||
1023 | 906 | if context is None: | ||
1024 | 907 | context = {} | ||
1025 | 908 | result = super(account_move_line, self).fields_view_get(cr, uid, view_id, view_type, context=context, toolbar=toolbar, submenu=submenu) | ||
1026 | 909 | if view_type != 'tree': | ||
1027 | 910 | #Remove the toolbar from the form view | ||
1028 | 911 | if view_type == 'form': | ||
1029 | 912 | if result.get('toolbar', False): | ||
1030 | 913 | result['toolbar']['action'] = [] | ||
1031 | 914 | #Restrict the list of journal view in search view | ||
1032 | 915 | if view_type == 'search' and result['fields'].get('journal_id', False): | ||
1033 | 916 | result['fields']['journal_id']['selection'] = journal_pool.name_search(cr, uid, '', [], context=context) | ||
1034 | 917 | ctx = context.copy() | ||
1035 | 918 | #we add the refunds journal in the selection field of journal | ||
1036 | 919 | if context.get('journal_type', False) == 'sale': | ||
1037 | 920 | ctx.update({'journal_type': 'sale_refund'}) | ||
1038 | 921 | result['fields']['journal_id']['selection'] += journal_pool.name_search(cr, uid, '', [], context=ctx) | ||
1039 | 922 | elif context.get('journal_type', False) == 'purchase': | ||
1040 | 923 | ctx.update({'journal_type': 'purchase_refund'}) | ||
1041 | 924 | result['fields']['journal_id']['selection'] += journal_pool.name_search(cr, uid, '', [], context=ctx) | ||
1042 | 925 | return result | ||
1043 | 926 | if context.get('view_mode', False): | ||
1044 | 927 | return result | ||
1045 | 928 | fld = [] | ||
1046 | 929 | fields = {} | ||
1047 | 930 | flds = [] | ||
1048 | 931 | title = _("Accounting Entries") #self.view_header_get(cr, uid, view_id, view_type, context) | ||
1049 | 932 | xml = '''<?xml version="1.0"?>\n<tree string="%s" editable="top" refresh="5" on_write="on_create_write" colors="red:state==\'draft\';black:state==\'valid\'">\n\t''' % (title) | ||
1050 | 933 | |||
1051 | 934 | ids = journal_pool.search(cr, uid, []) | ||
1052 | 935 | journals = journal_pool.browse(cr, uid, ids, context=context) | ||
1053 | 936 | all_journal = [None] | ||
1054 | 937 | common_fields = {} | ||
1055 | 938 | total = len(journals) | ||
1056 | 939 | for journal in journals: | ||
1057 | 940 | all_journal.append(journal.id) | ||
1058 | 941 | for field in journal.view_id.columns_id: | ||
1059 | 942 | if not field.field in fields: | ||
1060 | 943 | fields[field.field] = [journal.id] | ||
1061 | 944 | fld.append((field.field, field.sequence, field.name)) | ||
1062 | 945 | flds.append(field.field) | ||
1063 | 946 | common_fields[field.field] = 1 | ||
1064 | 947 | else: | ||
1065 | 948 | fields.get(field.field).append(journal.id) | ||
1066 | 949 | common_fields[field.field] = common_fields[field.field] + 1 | ||
1067 | 950 | fld.append(('period_id', 3, _('Period'))) | ||
1068 | 951 | fld.append(('journal_id', 10, _('Journal'))) | ||
1069 | 952 | flds.append('period_id') | ||
1070 | 953 | flds.append('journal_id') | ||
1071 | 954 | fields['period_id'] = all_journal | ||
1072 | 955 | fields['journal_id'] = all_journal | ||
1073 | 956 | fld = sorted(fld, key=itemgetter(1)) | ||
1074 | 957 | widths = { | ||
1075 | 958 | 'statement_id': 50, | ||
1076 | 959 | 'state': 60, | ||
1077 | 960 | 'tax_code_id': 50, | ||
1078 | 961 | 'move_id': 40, | ||
1079 | 962 | } | ||
1080 | 963 | for field_it in fld: | ||
1081 | 964 | field = field_it[0] | ||
1082 | 965 | if common_fields.get(field) == total: | ||
1083 | 966 | fields.get(field).append(None) | ||
1084 | 967 | # if field=='state': | ||
1085 | 968 | # state = 'colors="red:state==\'draft\'"' | ||
1086 | 969 | attrs = [] | ||
1087 | 970 | if field == 'debit': | ||
1088 | 971 | attrs.append('sum = "%s"' % _("Total debit")) | ||
1089 | 972 | |||
1090 | 973 | elif field == 'credit': | ||
1091 | 974 | attrs.append('sum = "%s"' % _("Total credit")) | ||
1092 | 975 | |||
1093 | 976 | elif field == 'move_id': | ||
1094 | 977 | attrs.append('required = "False"') | ||
1095 | 978 | |||
1096 | 979 | elif field == 'account_tax_id': | ||
1097 | 980 | attrs.append('domain="[(\'parent_id\', \'=\' ,False)]"') | ||
1098 | 981 | attrs.append("context=\"{'journal_id': journal_id}\"") | ||
1099 | 982 | |||
1100 | 983 | elif field == 'account_id' and journal.id: | ||
1101 | 984 | attrs.append('domain="[(\'journal_id\', \'=\', '+str(journal.id)+'),(\'type\',\'<>\',\'view\'), (\'type\',\'<>\',\'closed\')]" on_change="onchange_account_id(account_id, partner_id)"') | ||
1102 | 985 | |||
1103 | 986 | elif field == 'partner_id': | ||
1104 | 987 | attrs.append('on_change="onchange_partner_id(move_id, partner_id, account_id, debit, credit, date, journal_id)"') | ||
1105 | 988 | |||
1106 | 989 | elif field == 'journal_id': | ||
1107 | 990 | attrs.append("context=\"{'journal_id': journal_id}\"") | ||
1108 | 991 | |||
1109 | 992 | elif field == 'statement_id': | ||
1110 | 993 | attrs.append("domain=\"[('state', '!=', 'confirm'),('journal_id.type', '=', 'bank')]\"") | ||
1111 | 994 | |||
1112 | 995 | elif field == 'date': | ||
1113 | 996 | attrs.append('on_change="onchange_date(date)"') | ||
1114 | 997 | |||
1115 | 998 | elif field == 'analytic_account_id': | ||
1116 | 999 | attrs.append('''groups="analytic.group_analytic_accounting"''') # Currently it is not working due to framework problem may be .. | ||
1117 | 1000 | |||
1118 | 1001 | if field in ('amount_currency', 'currency_id'): | ||
1119 | 1002 | attrs.append('on_change="onchange_currency(account_id, amount_currency, currency_id, date, journal_id)"') | ||
1120 | 1003 | attrs.append('''attrs="{'readonly': [('state', '=', 'valid')]}"''') | ||
1121 | 1004 | |||
1122 | 1005 | if field in widths: | ||
1123 | 1006 | attrs.append('width="'+str(widths[field])+'"') | ||
1124 | 1007 | |||
1125 | 1008 | if field in ('journal_id',): | ||
1126 | 1009 | attrs.append("invisible=\"context.get('journal_id', False)\"") | ||
1127 | 1010 | elif field in ('period_id',): | ||
1128 | 1011 | attrs.append("invisible=\"context.get('period_id', False)\"") | ||
1129 | 1012 | else: | ||
1130 | 1013 | attrs.append("invisible=\"context.get('visible_id') not in %s\"" % (fields.get(field))) | ||
1131 | 1014 | xml += '''<field name="%s" %s/>\n''' % (field,' '.join(attrs)) | ||
1132 | 1015 | |||
1133 | 1016 | xml += '''</tree>''' | ||
1134 | 1017 | result['arch'] = xml | ||
1135 | 1018 | result['fields'] = self.fields_get(cr, uid, flds, context) | ||
1136 | 1019 | return result | ||
1137 | 1020 | |||
1138 | 1021 | def _check_moves(self, cr, uid, context=None): | 814 | def _check_moves(self, cr, uid, context=None): |
1139 | 1022 | # use the first move ever created for this journal and period | 815 | # use the first move ever created for this journal and period |
1140 | 1023 | if context is None: | 816 | if context is None: |
1141 | @@ -1330,15 +1123,6 @@ | |||
1142 | 1330 | if a.id == vals['account_id']: | 1123 | if a.id == vals['account_id']: |
1143 | 1331 | ok = True | 1124 | ok = True |
1144 | 1332 | break | 1125 | break |
1145 | 1333 | # Automatically convert in the account's secondary currency if there is one and | ||
1146 | 1334 | # the provided values were not already multi-currency | ||
1147 | 1335 | if account.currency_id and 'amount_currency' not in vals and account.currency_id.id != account.company_id.currency_id.id: | ||
1148 | 1336 | vals['currency_id'] = account.currency_id.id | ||
1149 | 1337 | ctx = {} | ||
1150 | 1338 | if 'date' in vals: | ||
1151 | 1339 | ctx['date'] = vals['date'] | ||
1152 | 1340 | vals['amount_currency'] = cur_obj.compute(cr, uid, account.company_id.currency_id.id, | ||
1153 | 1341 | account.currency_id.id, vals.get('debit', 0.0)-vals.get('credit', 0.0), context=ctx) | ||
1154 | 1342 | if not ok: | 1126 | if not ok: |
1155 | 1343 | raise osv.except_osv(_('Bad account !'), _('You can not use this general account in this journal !')) | 1127 | raise osv.except_osv(_('Bad account !'), _('You can not use this general account in this journal !')) |
1156 | 1344 | 1128 | ||
1157 | 1345 | 1129 | ||
1158 | === modified file 'bin/addons/account/invoice.py' | |||
1159 | --- bin/addons/account/invoice.py 2019-07-25 14:58:06 +0000 | |||
1160 | +++ bin/addons/account/invoice.py 2019-10-30 13:23:20 +0000 | |||
1161 | @@ -27,6 +27,7 @@ | |||
1162 | 27 | from osv import fields, osv, orm | 27 | from osv import fields, osv, orm |
1163 | 28 | from tools.translate import _ | 28 | from tools.translate import _ |
1164 | 29 | from msf_partner import PARTNER_TYPE | 29 | from msf_partner import PARTNER_TYPE |
1165 | 30 | from base import currency_date | ||
1166 | 30 | 31 | ||
1167 | 31 | 32 | ||
1168 | 32 | class account_invoice(osv.osv): | 33 | class account_invoice(osv.osv): |
1169 | @@ -1724,6 +1725,7 @@ | |||
1170 | 1724 | return res_final | 1725 | return res_final |
1171 | 1725 | 1726 | ||
1172 | 1726 | company = self.pool.get('res.company').browse(cr, uid, company_id, context=context) | 1727 | company = self.pool.get('res.company').browse(cr, uid, company_id, context=context) |
1173 | 1728 | # DONE: TEST JN => no date in context | ||
1174 | 1727 | currency = self.pool.get('res.currency').browse(cr, uid, currency_id, context=context) | 1729 | currency = self.pool.get('res.currency').browse(cr, uid, currency_id, context=context) |
1175 | 1728 | 1730 | ||
1176 | 1729 | if company.currency_id.id != currency.id: | 1731 | if company.currency_id.id != currency.id: |
1177 | @@ -1918,7 +1920,7 @@ | |||
1178 | 1918 | tax_amount = round(atx.amount * amount_untaxed, 2) | 1920 | tax_amount = round(atx.amount * amount_untaxed, 2) |
1179 | 1919 | return tax_amount | 1921 | return tax_amount |
1180 | 1920 | 1922 | ||
1182 | 1921 | def base_change(self, cr, uid, ids, base, currency_id=False, company_id=False, date_invoice=False): | 1923 | def base_change(self, cr, uid, ids, base, currency_id=False, company_id=False, document_date=False, date_invoice=False): |
1183 | 1922 | cur_obj = self.pool.get('res.currency') | 1924 | cur_obj = self.pool.get('res.currency') |
1184 | 1923 | company_obj = self.pool.get('res.company') | 1925 | company_obj = self.pool.get('res.company') |
1185 | 1924 | company_currency = False | 1926 | company_currency = False |
1186 | @@ -1928,10 +1930,13 @@ | |||
1187 | 1928 | if company_id: | 1930 | if company_id: |
1188 | 1929 | company_currency = company_obj.read(cr, uid, [company_id], ['currency_id'])[0]['currency_id'][0] | 1931 | company_currency = company_obj.read(cr, uid, [company_id], ['currency_id'])[0]['currency_id'][0] |
1189 | 1930 | if currency_id and company_currency: | 1932 | if currency_id and company_currency: |
1191 | 1931 | base = cur_obj.compute(cr, uid, currency_id, company_currency, base*factor, context={'date': date_invoice or time.strftime('%Y-%m-%d')}, round=False) | 1933 | # DONE: TEST JN |
1192 | 1934 | curr_date = currency_date.get_date(self, cr, document_date, date_invoice) | ||
1193 | 1935 | base = cur_obj.compute(cr, uid, currency_id, company_currency, base*factor, | ||
1194 | 1936 | context={'currency_date': curr_date or time.strftime('%Y-%m-%d')}, round=False) | ||
1195 | 1932 | return {'value': {'base_amount':base}} | 1937 | return {'value': {'base_amount':base}} |
1196 | 1933 | 1938 | ||
1198 | 1934 | def amount_change(self, cr, uid, ids, amount, currency_id=False, company_id=False, date_invoice=False): | 1939 | def amount_change(self, cr, uid, ids, amount, currency_id=False, company_id=False, document_date=False, date_invoice=False): |
1199 | 1935 | cur_obj = self.pool.get('res.currency') | 1940 | cur_obj = self.pool.get('res.currency') |
1200 | 1936 | company_obj = self.pool.get('res.company') | 1941 | company_obj = self.pool.get('res.company') |
1201 | 1937 | company_currency = False | 1942 | company_currency = False |
1202 | @@ -1941,7 +1946,10 @@ | |||
1203 | 1941 | if company_id: | 1946 | if company_id: |
1204 | 1942 | company_currency = company_obj.read(cr, uid, [company_id], ['currency_id'])[0]['currency_id'][0] | 1947 | company_currency = company_obj.read(cr, uid, [company_id], ['currency_id'])[0]['currency_id'][0] |
1205 | 1943 | if currency_id and company_currency: | 1948 | if currency_id and company_currency: |
1207 | 1944 | amount = cur_obj.compute(cr, uid, currency_id, company_currency, amount*factor, context={'date': date_invoice or time.strftime('%Y-%m-%d')}, round=False) | 1949 | # DONE: TEST JN |
1208 | 1950 | curr_date = currency_date.get_date(self, cr, document_date, date_invoice) | ||
1209 | 1951 | amount = cur_obj.compute(cr, uid, currency_id, company_currency, amount*factor, | ||
1210 | 1952 | context={'currency_date': curr_date or time.strftime('%Y-%m-%d')}, round=False) | ||
1211 | 1945 | return {'value': {'tax_amount': amount}} | 1953 | return {'value': {'tax_amount': amount}} |
1212 | 1946 | 1954 | ||
1213 | 1947 | _order = 'sequence' | 1955 | _order = 'sequence' |
1214 | @@ -1952,6 +1960,8 @@ | |||
1215 | 1952 | 'sequence': 0, | 1960 | 'sequence': 0, |
1216 | 1953 | } | 1961 | } |
1217 | 1954 | def compute(self, cr, uid, invoice_id, context=None): | 1962 | def compute(self, cr, uid, invoice_id, context=None): |
1218 | 1963 | if context is None: | ||
1219 | 1964 | context = {} | ||
1220 | 1955 | tax_grouped = {} | 1965 | tax_grouped = {} |
1221 | 1956 | tax_obj = self.pool.get('account.tax') | 1966 | tax_obj = self.pool.get('account.tax') |
1222 | 1957 | cur_obj = self.pool.get('res.currency') | 1967 | cur_obj = self.pool.get('res.currency') |
1223 | @@ -1973,14 +1983,22 @@ | |||
1224 | 1973 | if inv.type in ('out_invoice','in_invoice'): | 1983 | if inv.type in ('out_invoice','in_invoice'): |
1225 | 1974 | val['base_code_id'] = tax['base_code_id'] | 1984 | val['base_code_id'] = tax['base_code_id'] |
1226 | 1975 | val['tax_code_id'] = tax['tax_code_id'] | 1985 | val['tax_code_id'] = tax['tax_code_id'] |
1229 | 1976 | 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) | 1986 | # DONE: TEST JN |
1230 | 1977 | val['tax_amount'] = cur_obj.compute(cr, uid, inv.currency_id.id, company_currency, val['amount'] * tax['tax_sign'], context={'date': inv.date_invoice or time.strftime('%Y-%m-%d')}, round=False) | 1987 | curr_date = currency_date.get_date(self, cr, inv.document_date, inv.date_invoice) |
1231 | 1988 | val['base_amount'] = cur_obj.compute(cr, uid, inv.currency_id.id, company_currency, val['base'] * tax['base_sign'], | ||
1232 | 1989 | context={'currency_date': curr_date or time.strftime('%Y-%m-%d')}, round=False) | ||
1233 | 1990 | val['tax_amount'] = cur_obj.compute(cr, uid, inv.currency_id.id, company_currency, val['amount'] * tax['tax_sign'], | ||
1234 | 1991 | context={'currency_date': curr_date or time.strftime('%Y-%m-%d')}, round=False) | ||
1235 | 1978 | val['account_id'] = tax['account_collected_id'] or line.account_id.id | 1992 | val['account_id'] = tax['account_collected_id'] or line.account_id.id |
1236 | 1979 | else: | 1993 | else: |
1237 | 1980 | val['base_code_id'] = tax['ref_base_code_id'] | 1994 | val['base_code_id'] = tax['ref_base_code_id'] |
1238 | 1981 | val['tax_code_id'] = tax['ref_tax_code_id'] | 1995 | val['tax_code_id'] = tax['ref_tax_code_id'] |
1241 | 1982 | val['base_amount'] = cur_obj.compute(cr, uid, inv.currency_id.id, company_currency, val['base'] * tax['ref_base_sign'], context={'date': inv.date_invoice or time.strftime('%Y-%m-%d')}, round=False) | 1996 | # DONE: TEST JN |
1242 | 1983 | val['tax_amount'] = cur_obj.compute(cr, uid, inv.currency_id.id, company_currency, val['amount'] * tax['ref_tax_sign'], context={'date': inv.date_invoice or time.strftime('%Y-%m-%d')}, round=False) | 1997 | curr_date = currency_date.get_date(self, cr, inv.document_date, inv.date_invoice) |
1243 | 1998 | val['base_amount'] = cur_obj.compute(cr, uid, inv.currency_id.id, company_currency, val['base'] * tax['ref_base_sign'], | ||
1244 | 1999 | context={'currency_date': curr_date or time.strftime('%Y-%m-%d')}, round=False) | ||
1245 | 2000 | val['tax_amount'] = cur_obj.compute(cr, uid, inv.currency_id.id, company_currency, val['amount'] * tax['ref_tax_sign'], | ||
1246 | 2001 | context={'currency_date': curr_date or time.strftime('%Y-%m-%d')}, round=False) | ||
1247 | 1984 | val['account_id'] = tax['account_paid_id'] or line.account_id.id | 2002 | val['account_id'] = tax['account_paid_id'] or line.account_id.id |
1248 | 1985 | 2003 | ||
1249 | 1986 | key = tax['id'] # taxes are grouped by id | 2004 | key = tax['id'] # taxes are grouped by id |
1250 | 1987 | 2005 | ||
1251 | === modified file 'bin/addons/account/project/project_view.xml' | |||
1252 | --- bin/addons/account/project/project_view.xml 2018-06-25 13:34:58 +0000 | |||
1253 | +++ bin/addons/account/project/project_view.xml 2019-10-30 13:23:20 +0000 | |||
1254 | @@ -176,24 +176,14 @@ | |||
1255 | 176 | </form> | 176 | </form> |
1256 | 177 | </field> | 177 | </field> |
1257 | 178 | </record> | 178 | </record> |
1258 | 179 | |||
1259 | 180 | <!-- see ./bin/addons/finance/account_analytic_line_view.xml --> | ||
1260 | 179 | <record id="view_account_analytic_line_tree" model="ir.ui.view"> | 181 | <record id="view_account_analytic_line_tree" model="ir.ui.view"> |
1261 | 180 | <field name="name">account.analytic.line.tree</field> | 182 | <field name="name">account.analytic.line.tree</field> |
1262 | 181 | <field name="model">account.analytic.line</field> | 183 | <field name="model">account.analytic.line</field> |
1263 | 182 | <field name="type">tree</field> | 184 | <field name="type">tree</field> |
1264 | 183 | <field name="arch" type="xml"> | 185 | <field name="arch" type="xml"> |
1278 | 184 | <tree editable="top" string="Analytic Entries"> | 186 | <tree /> |
1266 | 185 | <field name="date"/> | ||
1267 | 186 | <field name="ref" invisible="context.get('to_invoice', False)"/> | ||
1268 | 187 | <field name="name"/> | ||
1269 | 188 | <field name="journal_id" invisible="context.get('to_invoice', False)"/> | ||
1270 | 189 | <field name="amount" sum="Total" invisible="context.get('to_invoice', False)"/> | ||
1271 | 190 | <field name="product_id" on_change="on_change_unit_amount(product_id, unit_amount, company_id, product_uom_id, journal_id)" invisible="not context.get('to_invoice', False)"/> | ||
1272 | 191 | <field name="unit_amount" on_change="on_change_unit_amount(product_id, unit_amount, company_id, product_uom_id)" sum="Total Quantity" invisible="not context.get('to_invoice', False)"/> | ||
1273 | 192 | <field name="product_uom_id" on_change="on_change_unit_amount(product_id, unit_amount, company_id, product_uom_id)" invisible="not context.get('to_invoice', False)"/> | ||
1274 | 193 | <field domain="[('type','=','normal')]" name="account_id"/> | ||
1275 | 194 | <field name="general_account_id" invisible="context.get('to_invoice', False)"/> | ||
1276 | 195 | <field name="user_id" invisible="1" /> | ||
1277 | 196 | </tree> | ||
1279 | 197 | </field> | 187 | </field> |
1280 | 198 | </record> | 188 | </record> |
1281 | 199 | 189 | ||
1282 | @@ -294,36 +284,6 @@ | |||
1283 | 294 | <field eval="True" name="object"/> | 284 | <field eval="True" name="object"/> |
1284 | 295 | </record> | 285 | </record> |
1285 | 296 | 286 | ||
1286 | 297 | <record id="account_analytic_line_extended_form" model="ir.ui.view"> | ||
1287 | 298 | <field name="name">account.analytic.line.extended_form</field> | ||
1288 | 299 | <field name="model">account.analytic.line</field> | ||
1289 | 300 | <field name="type">form</field> | ||
1290 | 301 | <field name="priority" eval="18"/> | ||
1291 | 302 | <field name="arch" type="xml"> | ||
1292 | 303 | <form string="Project line"> | ||
1293 | 304 | <field name="name"/> | ||
1294 | 305 | <field name="account_id" groups="base.group_extended"/> | ||
1295 | 306 | <field name="date" on_change="on_change_unit_amount(product_id, unit_amount, company_id, product_uom_id)"/> | ||
1296 | 307 | <field name="journal_id"/> | ||
1297 | 308 | <field name="unit_amount" on_change="on_change_unit_amount(product_id, unit_amount, company_id, product_uom_id)"/> | ||
1298 | 309 | <field name="product_id" on_change="on_change_unit_amount(product_id, unit_amount, company_id, product_uom_id, journal_id)"/> | ||
1299 | 310 | <field name="product_uom_id" on_change="on_change_unit_amount(product_id, unit_amount, company_id, product_uom_id)"/> | ||
1300 | 311 | <field invisible="True" name="general_account_id"/> | ||
1301 | 312 | <field name="amount"/> | ||
1302 | 313 | <field name="currency_id" /> | ||
1303 | 314 | <field name="amount_currency" /> | ||
1304 | 315 | <field name="company_id" on_change="on_change_unit_amount(product_id, unit_amount, company_id, product_uom_id)"/> | ||
1305 | 316 | </form> | ||
1306 | 317 | </field> | ||
1307 | 318 | </record> | ||
1308 | 319 | <record id="action_account_analytic_account_line_extended_form" model="ir.actions.act_window"> | ||
1309 | 320 | <field name="name">account.analytic.line.extended</field> | ||
1310 | 321 | <field name="type">ir.actions.act_window</field> | ||
1311 | 322 | <field name="res_model">account.analytic.line</field> | ||
1312 | 323 | <field name="view_type">form</field> | ||
1313 | 324 | <field name="view_id" ref="account_analytic_line_extended_form"/> | ||
1314 | 325 | </record> | ||
1315 | 326 | |||
1316 | 327 | # | 287 | # |
1317 | 328 | # Analytic Journal | 288 | # Analytic Journal |
1318 | 329 | # | 289 | # |
1319 | 330 | 290 | ||
1320 | === removed file 'bin/addons/account/res_currency.py' | |||
1321 | --- bin/addons/account/res_currency.py 2017-09-29 15:41:58 +0000 | |||
1322 | +++ bin/addons/account/res_currency.py 1970-01-01 00:00:00 +0000 | |||
1323 | @@ -1,47 +0,0 @@ | |||
1324 | 1 | # -*- coding: utf-8 -*- | ||
1325 | 2 | ############################################################################## | ||
1326 | 3 | # | ||
1327 | 4 | # Copyright (C) 2010 OpenERP s.a. (<http://www.openerp.com>). | ||
1328 | 5 | # | ||
1329 | 6 | # This program is free software: you can redistribute it and/or modify | ||
1330 | 7 | # it under the terms of the GNU Affero General Public License as | ||
1331 | 8 | # published by the Free Software Foundation, either version 3 of the | ||
1332 | 9 | # License, or (at your option) any later version. | ||
1333 | 10 | # | ||
1334 | 11 | # This program is distributed in the hope that it will be useful, | ||
1335 | 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1336 | 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1337 | 14 | # GNU Affero General Public License for more details. | ||
1338 | 15 | # | ||
1339 | 16 | # You should have received a copy of the GNU Affero General Public License | ||
1340 | 17 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1341 | 18 | # | ||
1342 | 19 | ############################################################################## | ||
1343 | 20 | |||
1344 | 21 | from osv import osv | ||
1345 | 22 | |||
1346 | 23 | """Inherit res.currency to handle accounting date values when converting currencies""" | ||
1347 | 24 | |||
1348 | 25 | class res_currency_account(osv.osv): | ||
1349 | 26 | _inherit = "res.currency" | ||
1350 | 27 | |||
1351 | 28 | def _get_conversion_rate(self, cr, uid, from_currency, to_currency, context=None): | ||
1352 | 29 | if context is None: | ||
1353 | 30 | context = {} | ||
1354 | 31 | rate = super(res_currency_account, self)._get_conversion_rate(cr, uid, from_currency, to_currency, context=context) | ||
1355 | 32 | account = context.get('res.currency.compute.account') | ||
1356 | 33 | account_invert = context.get('res.currency.compute.account_invert') | ||
1357 | 34 | if account and account.currency_mode == 'average' and account.currency_id: | ||
1358 | 35 | query = self.pool.get('account.move.line')._query_get(cr, uid, context=context) | ||
1359 | 36 | cr.execute('''select sum(debit-credit),sum(amount_currency) from account_move_line l | ||
1360 | 37 | where l.currency_id=%%s and l.account_id=%%s and %s''' % query, (account.currency_id.id,account.id,)) # not_a_user_entry | ||
1361 | 38 | tot1,tot2 = cr.fetchone() | ||
1362 | 39 | if tot2 and not account_invert: | ||
1363 | 40 | rate = float(tot1)/float(tot2) | ||
1364 | 41 | elif tot1 and account_invert: | ||
1365 | 42 | rate = float(tot2)/float(tot1) | ||
1366 | 43 | return rate | ||
1367 | 44 | |||
1368 | 45 | res_currency_account() | ||
1369 | 46 | |||
1370 | 47 | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: | ||
1371 | 48 | 0 | ||
1372 | === modified file 'bin/addons/account/wizard/account_change_currency.py' | |||
1373 | --- bin/addons/account/wizard/account_change_currency.py 2011-04-08 11:23:24 +0000 | |||
1374 | +++ bin/addons/account/wizard/account_change_currency.py 2019-10-30 13:23:20 +0000 | |||
1375 | @@ -50,6 +50,7 @@ | |||
1376 | 50 | invoice = obj_inv.browse(cr, uid, context['active_id'], context=context) | 50 | invoice = obj_inv.browse(cr, uid, context['active_id'], context=context) |
1377 | 51 | if invoice.currency_id.id == new_currency: | 51 | if invoice.currency_id.id == new_currency: |
1378 | 52 | return {} | 52 | return {} |
1379 | 53 | # DONE: TEST JN => cf. comm. Loic on US-5848 we keep using the date of the day here | ||
1380 | 53 | rate = obj_currency.browse(cr, uid, new_currency, context=context).rate | 54 | rate = obj_currency.browse(cr, uid, new_currency, context=context).rate |
1381 | 54 | for line in invoice.invoice_line: | 55 | for line in invoice.invoice_line: |
1382 | 55 | new_price = 0 | 56 | new_price = 0 |
1383 | 56 | 57 | ||
1384 | === modified file 'bin/addons/account_corrections/account_move_line.py' | |||
1385 | --- bin/addons/account_corrections/account_move_line.py 2019-01-28 13:35:47 +0000 | |||
1386 | +++ bin/addons/account_corrections/account_move_line.py 2019-10-30 13:23:20 +0000 | |||
1387 | @@ -26,6 +26,8 @@ | |||
1388 | 26 | from tools.translate import _ | 26 | from tools.translate import _ |
1389 | 27 | from time import strftime | 27 | from time import strftime |
1390 | 28 | from tools.misc import flatten | 28 | from tools.misc import flatten |
1391 | 29 | from base import currency_date | ||
1392 | 30 | |||
1393 | 29 | 31 | ||
1394 | 30 | class account_move_line(osv.osv): | 32 | class account_move_line(osv.osv): |
1395 | 31 | _name = 'account.move.line' | 33 | _name = 'account.move.line' |
1396 | @@ -543,13 +545,15 @@ | |||
1397 | 543 | # update amount on new distribution | 545 | # update amount on new distribution |
1398 | 544 | ana_obj.update_distribution_line_amount(cr, uid, new_distrib_id, (-1 * (ml.debit - ml.credit)), context=context) | 546 | ana_obj.update_distribution_line_amount(cr, uid, new_distrib_id, (-1 * (ml.debit - ml.credit)), context=context) |
1399 | 545 | new_line_id = self.copy(cr, uid, ml.id, {'move_id': new_move_id, 'date': date, 'document_date': ml.document_date, 'period_id': period_ids[0]}, context=context) | 547 | new_line_id = self.copy(cr, uid, ml.id, {'move_id': new_move_id, 'date': date, 'document_date': ml.document_date, 'period_id': period_ids[0]}, context=context) |
1400 | 548 | # DONE: TEST JN | ||
1401 | 549 | curr_date = currency_date.get_date(self, cr, ml.document_date, ml.date, source_date=ml.source_date) | ||
1402 | 546 | vals.update({ | 550 | vals.update({ |
1403 | 547 | 'name': name, | 551 | 'name': name, |
1404 | 548 | 'debit': ml.credit, | 552 | 'debit': ml.credit, |
1405 | 549 | 'credit': ml.debit, | 553 | 'credit': ml.debit, |
1406 | 550 | 'amount_currency': amt, | 554 | 'amount_currency': amt, |
1407 | 551 | 'reversal_line_id': ml.id, | 555 | 'reversal_line_id': ml.id, |
1409 | 552 | 'source_date': ml.source_date or ml.date, | 556 | 'source_date': curr_date, |
1410 | 553 | 'reversal': True, | 557 | 'reversal': True, |
1411 | 554 | 'reference': ml.move_id and ml.move_id.name or '', | 558 | 'reference': ml.move_id and ml.move_id.name or '', |
1412 | 555 | 'ref': ml.move_id and ml.move_id.name or '', | 559 | 'ref': ml.move_id and ml.move_id.name or '', |
1413 | @@ -746,6 +750,8 @@ | |||
1414 | 746 | # Do the reverse | 750 | # Do the reverse |
1415 | 747 | name = self.join_without_redundancy(ml.name, 'REV') | 751 | name = self.join_without_redundancy(ml.name, 'REV') |
1416 | 748 | amt = -1 * ml.amount_currency | 752 | amt = -1 * ml.amount_currency |
1417 | 753 | # DONE: TEST JN | ||
1418 | 754 | curr_date = currency_date.get_date(self, cr, ml.document_date, ml.date, source_date=ml.source_date) | ||
1419 | 749 | vals.update({ | 755 | vals.update({ |
1420 | 750 | 'debit': ml.credit, | 756 | 'debit': ml.credit, |
1421 | 751 | 'credit': ml.debit, | 757 | 'credit': ml.debit, |
1422 | @@ -754,7 +760,7 @@ | |||
1423 | 754 | 'name': name, | 760 | 'name': name, |
1424 | 755 | 'reversal_line_id': ml.id, | 761 | 'reversal_line_id': ml.id, |
1425 | 756 | 'account_id': ml.account_id.id, | 762 | 'account_id': ml.account_id.id, |
1427 | 757 | 'source_date': ml.source_date or ml.date, | 763 | 'source_date': curr_date, |
1428 | 758 | 'reversal': True, | 764 | 'reversal': True, |
1429 | 759 | 'document_date': ml.document_date, | 765 | 'document_date': ml.document_date, |
1430 | 760 | 'reference': ml.move_id and ml.move_id.name or '', | 766 | 'reference': ml.move_id and ml.move_id.name or '', |
1431 | @@ -768,7 +774,7 @@ | |||
1432 | 768 | 'journal_id': journal_id, | 774 | 'journal_id': journal_id, |
1433 | 769 | 'corrected_line_id': ml.id, | 775 | 'corrected_line_id': ml.id, |
1434 | 770 | 'account_id': new_account_id, | 776 | 'account_id': new_account_id, |
1436 | 771 | 'source_date': ml.source_date or ml.date, | 777 | 'source_date': curr_date, |
1437 | 772 | 'have_an_historic': True, | 778 | 'have_an_historic': True, |
1438 | 773 | 'document_date': ml.document_date, | 779 | 'document_date': ml.document_date, |
1439 | 774 | 'reference': ml.move_id and ml.move_id.name or '', | 780 | 'reference': ml.move_id and ml.move_id.name or '', |
1440 | 775 | 781 | ||
1441 | === modified file 'bin/addons/account_corrections/wizard/analytic_distribution_wizard.py' | |||
1442 | --- bin/addons/account_corrections/wizard/analytic_distribution_wizard.py 2019-10-15 16:08:57 +0000 | |||
1443 | +++ bin/addons/account_corrections/wizard/analytic_distribution_wizard.py 2019-10-30 13:23:20 +0000 | |||
1444 | @@ -26,6 +26,8 @@ | |||
1445 | 26 | from tools.translate import _ | 26 | from tools.translate import _ |
1446 | 27 | import time | 27 | import time |
1447 | 28 | from collections import defaultdict | 28 | from collections import defaultdict |
1448 | 29 | from base import currency_date | ||
1449 | 30 | |||
1450 | 29 | 31 | ||
1451 | 30 | class analytic_distribution_wizard(osv.osv_memory): | 32 | class analytic_distribution_wizard(osv.osv_memory): |
1452 | 31 | _inherit = 'analytic.distribution.wizard' | 33 | _inherit = 'analytic.distribution.wizard' |
1453 | @@ -150,9 +152,13 @@ | |||
1454 | 150 | ana_line_obj = self.pool.get('account.analytic.line') | 152 | ana_line_obj = self.pool.get('account.analytic.line') |
1455 | 151 | company_currency_id = self.pool.get('res.users').browse(cr, uid, uid).company_id.currency_id.id | 153 | company_currency_id = self.pool.get('res.users').browse(cr, uid, uid).company_id.currency_id.id |
1456 | 152 | ml = wizard.move_line_id | 154 | ml = wizard.move_line_id |
1458 | 153 | orig_date = ml.source_date or ml.date | 155 | # US-5848: orig_date left unchanged not to break historical behavior, |
1459 | 156 | # but the value set here seems overwritten later in the process if there is a source_date | ||
1460 | 157 | orig_date = ml.source_date or ml.date # DONE: TEST JN | ||
1461 | 154 | orig_document_date = ml.document_date | 158 | orig_document_date = ml.document_date |
1462 | 155 | posting_date = wizard.date | 159 | posting_date = wizard.date |
1463 | 160 | # DONE: TEST JN | ||
1464 | 161 | curr_date = currency_date.get_date(self, cr, ml.document_date, ml.date, source_date=ml.source_date) | ||
1465 | 156 | working_period_id = [] | 162 | working_period_id = [] |
1466 | 157 | new_line_ids = [] | 163 | new_line_ids = [] |
1467 | 158 | entry_seq_data = {} | 164 | entry_seq_data = {} |
1468 | @@ -363,7 +369,10 @@ | |||
1469 | 363 | if keep_seq_and_corrected[4]: | 369 | if keep_seq_and_corrected[4]: |
1470 | 364 | name = ana_line_obj.join_without_redundancy(keep_seq_and_corrected[4], 'COR') | 370 | name = ana_line_obj.join_without_redundancy(keep_seq_and_corrected[4], 'COR') |
1471 | 365 | 371 | ||
1473 | 366 | created_analytic_line_ids = self.pool.get('funding.pool.distribution.line').create_analytic_lines(cr, uid, [new_distrib_line], ml.id, date=create_date, document_date=orig_document_date, source_date=orig_date, name=name, context=context) | 372 | # DONE: TEST JN |
1474 | 373 | created_analytic_line_ids = self.pool.get('funding.pool.distribution.line').\ | ||
1475 | 374 | create_analytic_lines(cr, uid, [new_distrib_line], ml.id, date=create_date, document_date=orig_document_date, | ||
1476 | 375 | source_date=curr_date, name=name, context=context) | ||
1477 | 367 | new_line_ids.extend(created_analytic_line_ids.values()) | 376 | new_line_ids.extend(created_analytic_line_ids.values()) |
1478 | 368 | working_period_id = working_period_id or \ | 377 | working_period_id = working_period_id or \ |
1479 | 369 | self.pool.get('account.period').get_period_from_date(cr, uid, date=create_date, context=context) | 378 | self.pool.get('account.period').get_period_from_date(cr, uid, date=create_date, context=context) |
1480 | @@ -425,8 +434,9 @@ | |||
1481 | 425 | if cp.state != 'draft': | 434 | if cp.state != 'draft': |
1482 | 426 | raise osv.except_osv(_('Error'), _('Period (%s) is not open.') % (cp.name,)) | 435 | raise osv.except_osv(_('Error'), _('Period (%s) is not open.') % (cp.name,)) |
1483 | 427 | # Create the new ana line | 436 | # Create the new ana line |
1484 | 437 | # DONE: TEST JN | ||
1485 | 428 | ret = fp_distrib_obj.create_analytic_lines(cr, uid, line.distribution_line_id.id, ml.id, date=posting_date, | 438 | ret = fp_distrib_obj.create_analytic_lines(cr, uid, line.distribution_line_id.id, ml.id, date=posting_date, |
1487 | 429 | document_date=orig_document_date, source_date=orig_date, name=name, context=context) | 439 | document_date=orig_document_date, source_date=curr_date, name=name, context=context) |
1488 | 430 | new_line_ids.extend(ret.values()) | 440 | new_line_ids.extend(ret.values()) |
1489 | 431 | working_period_id = working_period_id or period_ids | 441 | working_period_id = working_period_id or period_ids |
1490 | 432 | # Add link to first analytic lines | 442 | # Add link to first analytic lines |
1491 | @@ -443,7 +453,8 @@ | |||
1492 | 443 | for line in to_override: | 453 | for line in to_override: |
1493 | 444 | # update the ana line | 454 | # update the ana line |
1494 | 445 | to_override_ids = ana_line_obj.search(cr, uid, [('distrib_line_id', '=', 'funding.pool.distribution.line,%d'%line.distribution_line_id.id), ('is_reversal', '=', False), ('is_reallocated', '=', False)]) | 455 | to_override_ids = ana_line_obj.search(cr, uid, [('distrib_line_id', '=', 'funding.pool.distribution.line,%d'%line.distribution_line_id.id), ('is_reversal', '=', False), ('is_reallocated', '=', False)]) |
1496 | 446 | ctx = {'date': orig_date} | 456 | # DONE: TEST JN |
1497 | 457 | ctx = {'currency_date': curr_date} | ||
1498 | 447 | amount_cur = (ml.credit_currency - ml.debit_currency) * line.percentage / 100 | 458 | amount_cur = (ml.credit_currency - ml.debit_currency) * line.percentage / 100 |
1499 | 448 | amount = self.pool.get('res.currency').compute(cr, uid, ml.currency_id.id, company_currency_id, amount_cur, round=False, context=ctx) | 459 | amount = self.pool.get('res.currency').compute(cr, uid, ml.currency_id.id, company_currency_id, amount_cur, round=False, context=ctx) |
1500 | 449 | 460 | ||
1501 | @@ -479,12 +490,13 @@ | |||
1502 | 479 | has_generated_cor = True | 490 | has_generated_cor = True |
1503 | 480 | # compute the adjustment amount | 491 | # compute the adjustment amount |
1504 | 481 | all_aji_ids = ana_line_obj.search(cr, uid, [ | 492 | all_aji_ids = ana_line_obj.search(cr, uid, [ |
1509 | 482 | ('move_id', '=', ml.id), | 493 | ('move_id', '=', ml.id), |
1510 | 483 | ('is_reversal', '=', False), | 494 | ('is_reversal', '=', False), |
1511 | 484 | ('is_reallocated', '=', False), | 495 | ('is_reallocated', '=', False), |
1512 | 485 | ], order='NO_ORDER', context=context) | 496 | ('account_id.category', '=', 'FUNDING'), # exclude free lines |
1513 | 497 | ], order='NO_ORDER', context=context) | ||
1514 | 486 | max_line = {'amount': 0, 'aji_bro': False} | 498 | max_line = {'amount': 0, 'aji_bro': False} |
1516 | 487 | aji_fields = ['amount_currency', 'period_id', 'currency_id', 'source_date', 'date'] | 499 | aji_fields = ['amount_currency', 'period_id', 'currency_id', 'source_date', 'document_date', 'date'] |
1517 | 488 | for aji in ana_line_obj.browse(cr, uid, all_aji_ids, fields_to_fetch=aji_fields, context=context): | 500 | for aji in ana_line_obj.browse(cr, uid, all_aji_ids, fields_to_fetch=aji_fields, context=context): |
1518 | 489 | total_rounded_amount += round(abs(aji.amount_currency or 0.0), 2) | 501 | total_rounded_amount += round(abs(aji.amount_currency or 0.0), 2) |
1519 | 490 | if has_generated_cor and aji.id in new_line_ids and abs(aji.amount_currency or 0.0) > max_line['amount']: | 502 | if has_generated_cor and aji.id in new_line_ids and abs(aji.amount_currency or 0.0) > max_line['amount']: |
1520 | @@ -511,10 +523,10 @@ | |||
1521 | 511 | # then recompute functional amount | 523 | # then recompute functional amount |
1522 | 512 | if fix_aji_currency_id: | 524 | if fix_aji_currency_id: |
1523 | 513 | new_context = context.copy() | 525 | new_context = context.copy() |
1528 | 514 | if max_line['aji_bro'].source_date: | 526 | # DONE: TEST JN |
1529 | 515 | new_context['date'] = max_line['aji_bro'].source_date | 527 | max_line_curr_date = currency_date.get_date(self, cr, max_line['aji_bro'].document_date, max_line['aji_bro'].date, |
1530 | 516 | else: | 528 | source_date=max_line['aji_bro'].source_date) |
1531 | 517 | new_context['date'] = max_line['aji_bro'].date | 529 | new_context['currency_date'] = max_line_curr_date |
1532 | 518 | aji_fix_vals['amount'] = \ | 530 | aji_fix_vals['amount'] = \ |
1533 | 519 | self.pool.get('res.currency').compute(cr, uid, | 531 | self.pool.get('res.currency').compute(cr, uid, |
1534 | 520 | fix_aji_currency_id, company_currency_id, | 532 | fix_aji_currency_id, company_currency_id, |
1535 | @@ -570,15 +582,17 @@ | |||
1536 | 570 | for line in to_override: | 582 | for line in to_override: |
1537 | 571 | # update the ana line | 583 | # update the ana line |
1538 | 572 | to_override_ids = ana_line_obj.search(cr, uid, [('distrib_line_id', '=', '%s,%d' % (obj_name, line.distribution_line_id.id)), ('is_reversal', '=', False), ('is_reallocated', '=', False)]) | 584 | to_override_ids = ana_line_obj.search(cr, uid, [('distrib_line_id', '=', '%s,%d' % (obj_name, line.distribution_line_id.id)), ('is_reversal', '=', False), ('is_reallocated', '=', False)]) |
1540 | 573 | ctx = {'date': orig_date} | 585 | # DONE: TEST JN |
1541 | 586 | ctx = {'currency_date': curr_date} | ||
1542 | 574 | amount_cur = (ml.credit_currency - ml.debit_currency) * line.percentage / 100 | 587 | amount_cur = (ml.credit_currency - ml.debit_currency) * line.percentage / 100 |
1543 | 575 | amount = self.pool.get('res.currency').compute(cr, uid, ml.currency_id.id, company_currency_id, amount_cur, round=False, context=ctx) | 588 | amount = self.pool.get('res.currency').compute(cr, uid, ml.currency_id.id, company_currency_id, amount_cur, round=False, context=ctx) |
1544 | 589 | # the posting date is the one of the entry corrected | ||
1545 | 576 | ana_line_obj.write(cr, uid, to_override_ids, { | 590 | ana_line_obj.write(cr, uid, to_override_ids, { |
1546 | 577 | 'account_id': line.analytic_id.id, | 591 | 'account_id': line.analytic_id.id, |
1547 | 578 | 'amount_currency': amount_cur, | 592 | 'amount_currency': amount_cur, |
1548 | 579 | 'amount': amount, | 593 | 'amount': amount, |
1551 | 580 | 'date': orig_date, | 594 | 'date': ml.date, # DONE: TEST JN |
1552 | 581 | 'source_date': orig_date, | 595 | 'source_date': curr_date, # DONE: TEST JN |
1553 | 582 | 'document_date': orig_document_date, | 596 | 'document_date': orig_document_date, |
1554 | 583 | }) | 597 | }) |
1555 | 584 | # update the distib line | 598 | # update the distib line |
1556 | @@ -596,7 +610,10 @@ | |||
1557 | 596 | 'currency_id': ml and ml.currency_id and ml.currency_id.id or company_currency_id, | 610 | 'currency_id': ml and ml.currency_id and ml.currency_id.id or company_currency_id, |
1558 | 597 | }) | 611 | }) |
1559 | 598 | # create the ana line | 612 | # create the ana line |
1561 | 599 | self.pool.get(obj_name).create_analytic_lines(cr, uid, [new_distrib_line], ml.id, date=orig_date, document_date=orig_document_date, source_date=orig_date, ref=ml.ref) | 613 | # DONE: TEST JN |
1562 | 614 | # the posting date is the one of the entry corrected | ||
1563 | 615 | self.pool.get(obj_name).create_analytic_lines(cr, uid, [new_distrib_line], ml.id, date=ml.date, | ||
1564 | 616 | document_date=orig_document_date, source_date=curr_date, ref=ml.ref) | ||
1565 | 600 | # Set move line as corrected upstream if needed | 617 | # Set move line as corrected upstream if needed |
1566 | 601 | if to_reverse or to_override or to_create: | 618 | if to_reverse or to_override or to_create: |
1567 | 602 | self.pool.get('account.move.line').corrected_upstream_marker(cr, uid, [ml.id], context=context) | 619 | self.pool.get('account.move.line').corrected_upstream_marker(cr, uid, [ml.id], context=context) |
1568 | 603 | 620 | ||
1569 | === modified file 'bin/addons/account_hq_entries/wizard/hq_entries_validation.py' | |||
1570 | --- bin/addons/account_hq_entries/wizard/hq_entries_validation.py 2019-01-09 12:52:42 +0000 | |||
1571 | +++ bin/addons/account_hq_entries/wizard/hq_entries_validation.py 2019-10-30 13:23:20 +0000 | |||
1572 | @@ -25,6 +25,8 @@ | |||
1573 | 25 | from osv import fields | 25 | from osv import fields |
1574 | 26 | from tools.translate import _ | 26 | from tools.translate import _ |
1575 | 27 | from time import strftime | 27 | from time import strftime |
1576 | 28 | from base import currency_date | ||
1577 | 29 | |||
1578 | 28 | 30 | ||
1579 | 29 | class hq_entries_validation(osv.osv_memory): | 31 | class hq_entries_validation(osv.osv_memory): |
1580 | 30 | _name = 'hq.entries.validation' | 32 | _name = 'hq.entries.validation' |
1581 | @@ -105,11 +107,13 @@ | |||
1582 | 105 | (account.default_destination_id and account.default_destination_id.id) or False | 107 | (account.default_destination_id and account.default_destination_id.id) or False |
1583 | 106 | distrib_id = self.pool.get('analytic.distribution').create(cr, uid, {}) | 108 | distrib_id = self.pool.get('analytic.distribution').create(cr, uid, {}) |
1584 | 107 | if distrib_id: | 109 | if distrib_id: |
1585 | 110 | # DONE: TEST JN | ||
1586 | 111 | curr_date = currency_date.get_date(self, cr, line.document_date or line.date, line.date) | ||
1587 | 108 | common_vals = {'distribution_id':distrib_id, | 112 | common_vals = {'distribution_id':distrib_id, |
1588 | 109 | 'currency_id':currency_id, | 113 | 'currency_id':currency_id, |
1589 | 110 | 'percentage':100.0, | 114 | 'percentage':100.0, |
1590 | 111 | 'date':line.date or current_date, | 115 | 'date':line.date or current_date, |
1592 | 112 | 'source_date':line.date or current_date, | 116 | 'source_date': curr_date or current_date, |
1593 | 113 | 'destination_id':destination_id} | 117 | 'destination_id':destination_id} |
1594 | 114 | common_vals.update({'analytic_id':cc_id}) | 118 | common_vals.update({'analytic_id':cc_id}) |
1595 | 115 | self.pool.get('cost.center.distribution.line').create(cr, uid, common_vals) | 119 | self.pool.get('cost.center.distribution.line').create(cr, uid, common_vals) |
1596 | @@ -126,7 +130,7 @@ | |||
1597 | 126 | return distrib_id | 130 | return distrib_id |
1598 | 127 | 131 | ||
1599 | 128 | def create_move(self, cr, uid, ids, period_id=False, currency_id=False, | 132 | def create_move(self, cr, uid, ids, period_id=False, currency_id=False, |
1601 | 129 | date=None, journal=None, orig_acct=None, doc_date=None, split=False, context=None): | 133 | date=None, journal=None, orig_acct=None, doc_date=None, source_date=None, split=False, context=None): |
1602 | 130 | """ | 134 | """ |
1603 | 131 | Create a move with given hq entries lines | 135 | Create a move with given hq entries lines |
1604 | 132 | Return created lines (except counterpart lines) | 136 | Return created lines (except counterpart lines) |
1605 | @@ -188,7 +192,7 @@ | |||
1606 | 188 | 'journal_id': journal_id, | 192 | 'journal_id': journal_id, |
1607 | 189 | 'date': line.date, | 193 | 'date': line.date, |
1608 | 190 | 'date_maturity': line.date, | 194 | 'date_maturity': line.date, |
1610 | 191 | 'document_date': line.document_date, | 195 | 'document_date': line.document_date or line.date, |
1611 | 192 | 'move_id': move_id, | 196 | 'move_id': move_id, |
1612 | 193 | 'analytic_distribution_id': distrib_id, | 197 | 'analytic_distribution_id': distrib_id, |
1613 | 194 | 'name': line.name or '', | 198 | 'name': line.name or '', |
1614 | @@ -196,6 +200,9 @@ | |||
1615 | 196 | 'partner_txt': line.partner_txt or '', | 200 | 'partner_txt': line.partner_txt or '', |
1616 | 197 | 'reference': line.ref or '' | 201 | 'reference': line.ref or '' |
1617 | 198 | } | 202 | } |
1618 | 203 | # DONE: TEST JN | ||
1619 | 204 | if source_date is not None: | ||
1620 | 205 | vals.update({'source_date': source_date, }) | ||
1621 | 199 | # Fetch debit/credit | 206 | # Fetch debit/credit |
1622 | 200 | debit = 0.0 | 207 | debit = 0.0 |
1623 | 201 | credit = 0.0 | 208 | credit = 0.0 |
1624 | @@ -294,8 +301,10 @@ | |||
1625 | 294 | aml_obj.write(cr, uid, original_move.id, {'corrected': True, 'have_an_historic': True} , context=context) | 301 | aml_obj.write(cr, uid, original_move.id, {'corrected': True, 'have_an_historic': True} , context=context) |
1626 | 295 | original_account_id = original_move.account_id.id | 302 | original_account_id = original_move.account_id.id |
1627 | 296 | 303 | ||
1628 | 304 | # DONE: TEST JN | ||
1629 | 305 | curr_date = currency_date.get_date(self, cr, line.document_date or line.date, line.date) | ||
1630 | 297 | new_res_move = self.create_move(cr, uid, [x.id for x in line.split_ids], line.period_id.id, | 306 | new_res_move = self.create_move(cr, uid, [x.id for x in line.split_ids], line.period_id.id, |
1632 | 298 | line.currency_id.id, date=line.date, doc_date=line.document_date, | 307 | line.currency_id.id, date=line.date, doc_date=line.document_date, source_date=curr_date, |
1633 | 299 | journal=od_journal_id, orig_acct=original_account_id, split=True, context=context) | 308 | journal=od_journal_id, orig_acct=original_account_id, split=True, context=context) |
1634 | 300 | # original move line | 309 | # original move line |
1635 | 301 | original_ml_result = res_move[line.id] | 310 | original_ml_result = res_move[line.id] |
1636 | @@ -329,7 +338,8 @@ | |||
1637 | 329 | 'reversal_line_id': original_move.id, | 338 | 'reversal_line_id': original_move.id, |
1638 | 330 | 'partner_txt': original_move.partner_txt or '', | 339 | 'partner_txt': original_move.partner_txt or '', |
1639 | 331 | 'reference': ji_entry_seq or ' ', # UFTP-342: if HQ entry reference is empty, do not display anything. As a field function exists for account_move_line object, so we add a blank char to avoid this problem | 340 | 'reference': ji_entry_seq or ' ', # UFTP-342: if HQ entry reference is empty, do not display anything. As a field function exists for account_move_line object, so we add a blank char to avoid this problem |
1641 | 332 | 'document_date': line.document_date, # US-1361 | 341 | 'document_date': line.document_date or line.date, |
1642 | 342 | 'source_date': curr_date, # DONE: TEST JN | ||
1643 | 333 | }, context=context, check=False, update_check=False) | 343 | }, context=context, check=False, update_check=False) |
1644 | 334 | 344 | ||
1645 | 335 | # create the analytic lines as a reversed copy of the original | 345 | # create the analytic lines as a reversed copy of the original |
1646 | @@ -453,7 +463,9 @@ | |||
1647 | 453 | split_change.append(line) | 463 | split_change.append(line) |
1648 | 454 | continue | 464 | continue |
1649 | 455 | if not line.user_validated: | 465 | if not line.user_validated: |
1651 | 456 | to_write.setdefault(line.currency_id.id, {}).setdefault(line.period_id.id, {}).setdefault(line.date, []).append(line.id) | 466 | document_date = line.document_date or line.date # posting date is used by default if there is no doc date on the line |
1652 | 467 | to_write.setdefault(line.currency_id.id, {}).setdefault(line.period_id.id, {}).\ | ||
1653 | 468 | setdefault(line.date, {}).setdefault(document_date, []).append(line.id) | ||
1654 | 457 | 469 | ||
1655 | 458 | if line.account_id.id != line.account_id_first_value.id: | 470 | if line.account_id.id != line.account_id_first_value.id: |
1656 | 459 | if line.cost_center_id.id != line.cost_center_id_first_value.id or line.destination_id.id != line.destination_id_first_value.id: | 471 | if line.cost_center_id.id != line.cost_center_id_first_value.id or line.destination_id.id != line.destination_id_first_value.id: |
1657 | @@ -483,20 +495,23 @@ | |||
1658 | 483 | for currency in to_write: | 495 | for currency in to_write: |
1659 | 484 | for period in to_write[currency]: | 496 | for period in to_write[currency]: |
1660 | 485 | for date in to_write[currency][period]: | 497 | for date in to_write[currency][period]: |
1666 | 486 | lines = to_write[currency][period][date] | 498 | for doc_date in to_write[currency][period][date]: |
1667 | 487 | write = self.create_move(cr, uid, lines, period, currency, date) | 499 | lines = to_write[currency][period][date][doc_date] |
1668 | 488 | all_lines.update(write) | 500 | write = self.create_move(cr, uid, lines, period_id=period, currency_id=currency, date=date, doc_date=doc_date) |
1669 | 489 | if write: | 501 | all_lines.update(write) |
1670 | 490 | self.pool.get('hq.entries').write(cr, uid, write.keys(), {'user_validated': True}, context=context) | 502 | if write: |
1671 | 503 | self.pool.get('hq.entries').write(cr, uid, write.keys(), {'user_validated': True}, context=context) | ||
1672 | 491 | 504 | ||
1673 | 492 | for line in account_change: | 505 | for line in account_change: |
1674 | 506 | # DONE: TEST JN | ||
1675 | 507 | curr_date = currency_date.get_date(self, cr, line.document_date or line.date, line.date) | ||
1676 | 493 | corrected_distrib_id = self.pool.get('analytic.distribution').create(cr, uid, { | 508 | corrected_distrib_id = self.pool.get('analytic.distribution').create(cr, uid, { |
1677 | 494 | 'funding_pool_lines': [(0, 0, { | 509 | 'funding_pool_lines': [(0, 0, { |
1678 | 495 | 'percentage': 100, | 510 | 'percentage': 100, |
1679 | 496 | 'analytic_id': line.analytic_id.id, | 511 | 'analytic_id': line.analytic_id.id, |
1680 | 497 | 'cost_center_id': line.cost_center_id.id, | 512 | 'cost_center_id': line.cost_center_id.id, |
1681 | 498 | 'currency_id': line.currency_id.id, | 513 | 'currency_id': line.currency_id.id, |
1683 | 499 | 'source_date': line.date, | 514 | 'source_date': curr_date, |
1684 | 500 | 'destination_id': line.destination_id.id, | 515 | 'destination_id': line.destination_id.id, |
1685 | 501 | })] | 516 | })] |
1686 | 502 | }) | 517 | }) |
1687 | @@ -506,10 +521,14 @@ | |||
1688 | 506 | # actual distrib_id | 521 | # actual distrib_id |
1689 | 507 | distrib_id = self.pool.get('account.move.line').read(cr, uid, all_lines[line.id], ['analytic_distribution_id'])['analytic_distribution_id'][0] | 522 | distrib_id = self.pool.get('account.move.line').read(cr, uid, all_lines[line.id], ['analytic_distribution_id'])['analytic_distribution_id'][0] |
1690 | 508 | # update the distribution | 523 | # update the distribution |
1691 | 524 | # DONE: TEST JN | ||
1692 | 525 | curr_date = currency_date.get_date(self, cr, line.document_date or line.date, line.date) | ||
1693 | 509 | distrib_fp_lines = distrib_fp_line_obj.search(cr, uid, [('cost_center_id', '=', line.cost_center_id_first_value.id), ('distribution_id', '=', distrib_id)]) | 526 | distrib_fp_lines = distrib_fp_line_obj.search(cr, uid, [('cost_center_id', '=', line.cost_center_id_first_value.id), ('distribution_id', '=', distrib_id)]) |
1695 | 510 | distrib_fp_line_obj.write(cr, uid, distrib_fp_lines, {'cost_center_id': line.cost_center_id.id, 'source_date': line.date, 'destination_id': line.destination_id.id}) | 527 | distrib_fp_line_obj.write(cr, uid, distrib_fp_lines, {'cost_center_id': line.cost_center_id.id, |
1696 | 528 | 'source_date': curr_date, 'destination_id': line.destination_id.id}) | ||
1697 | 511 | distrib_cc_lines = distrib_cc_line_obj.search(cr, uid, [('analytic_id', '=', line.cost_center_id_first_value.id), ('distribution_id', '=', distrib_id)]) | 529 | distrib_cc_lines = distrib_cc_line_obj.search(cr, uid, [('analytic_id', '=', line.cost_center_id_first_value.id), ('distribution_id', '=', distrib_id)]) |
1699 | 512 | distrib_cc_line_obj.write(cr, uid, distrib_cc_lines, {'analytic_id': line.cost_center_id.id, 'source_date': line.date, 'destination_id': line.destination_id.id}) | 530 | distrib_cc_line_obj.write(cr, uid, distrib_cc_lines, {'analytic_id': line.cost_center_id.id, |
1700 | 531 | 'source_date': curr_date, 'destination_id': line.destination_id.id}) | ||
1701 | 513 | 532 | ||
1702 | 514 | # reverse ana lines | 533 | # reverse ana lines |
1703 | 515 | fp_old_lines = ana_line_obj.search(cr, uid, [ | 534 | fp_old_lines = ana_line_obj.search(cr, uid, [ |
1704 | @@ -529,8 +548,10 @@ | |||
1705 | 529 | continue | 548 | continue |
1706 | 530 | 549 | ||
1707 | 531 | # UTP-1118: posting date should be those from initial HQ entry line | 550 | # UTP-1118: posting date should be those from initial HQ entry line |
1710 | 532 | vals_cor = {'date':line.date, 'source_date':line.date, 'cost_center_id':line.cost_center_id.id, | 551 | # DONE: TEST JN |
1711 | 533 | 'account_id':line.analytic_id.id, 'destination_id':line.destination_id.id, 'journal_id':acor_journal_id, 'last_correction_id':fp_old_lines[0]} | 552 | vals_cor = {'date': line.date, 'source_date': curr_date, 'cost_center_id': line.cost_center_id.id, |
1712 | 553 | 'account_id': line.analytic_id.id, 'destination_id': line.destination_id.id, | ||
1713 | 554 | 'journal_id': acor_journal_id, 'last_correction_id':fp_old_lines[0]} | ||
1714 | 534 | 555 | ||
1715 | 535 | # US-1347: Use the entry sequence of HQ for reference, not the description | 556 | # US-1347: Use the entry sequence of HQ for reference, not the description |
1716 | 536 | entry_seq = ana_line_obj.read(cr, uid, res_reverse, ['ref'], context=context) | 557 | entry_seq = ana_line_obj.read(cr, uid, res_reverse, ['ref'], context=context) |
1717 | @@ -578,13 +599,15 @@ | |||
1718 | 578 | pure_ad_cor_ji_ids.append(all_lines[line.id]) | 599 | pure_ad_cor_ji_ids.append(all_lines[line.id]) |
1719 | 579 | 600 | ||
1720 | 580 | for line in cc_account_change: | 601 | for line in cc_account_change: |
1721 | 602 | # DONE: TEST JN | ||
1722 | 603 | curr_date = currency_date.get_date(self, cr, line.document_date or line.date, line.date) | ||
1723 | 581 | # call correct_account with a new arg: new_distrib | 604 | # call correct_account with a new arg: new_distrib |
1724 | 582 | corrected_distrib_id = self.pool.get('analytic.distribution').create(cr, uid, { | 605 | corrected_distrib_id = self.pool.get('analytic.distribution').create(cr, uid, { |
1725 | 583 | 'cost_center_lines': [(0, 0, { | 606 | 'cost_center_lines': [(0, 0, { |
1726 | 584 | 'percentage': 100, | 607 | 'percentage': 100, |
1727 | 585 | 'analytic_id': line.cost_center_id.id, | 608 | 'analytic_id': line.cost_center_id.id, |
1728 | 586 | 'currency_id': line.currency_id.id, | 609 | 'currency_id': line.currency_id.id, |
1730 | 587 | 'source_date': line.date, | 610 | 'source_date': curr_date, |
1731 | 588 | 'destination_id': line.destination_id.id, | 611 | 'destination_id': line.destination_id.id, |
1732 | 589 | })], | 612 | })], |
1733 | 590 | 'funding_pool_lines': [(0, 0, { | 613 | 'funding_pool_lines': [(0, 0, { |
1734 | @@ -592,7 +615,7 @@ | |||
1735 | 592 | 'analytic_id': line.analytic_id.id, | 615 | 'analytic_id': line.analytic_id.id, |
1736 | 593 | 'cost_center_id': line.cost_center_id.id, | 616 | 'cost_center_id': line.cost_center_id.id, |
1737 | 594 | 'currency_id': line.currency_id.id, | 617 | 'currency_id': line.currency_id.id, |
1739 | 595 | 'source_date': line.date, | 618 | 'source_date': curr_date, |
1740 | 596 | 'destination_id': line.destination_id.id, | 619 | 'destination_id': line.destination_id.id, |
1741 | 597 | })] | 620 | })] |
1742 | 598 | }) | 621 | }) |
1743 | 599 | 622 | ||
1744 | === modified file 'bin/addons/account_mcdb/account_analytic_line.py' | |||
1745 | --- bin/addons/account_mcdb/account_analytic_line.py 2017-04-19 09:37:05 +0000 | |||
1746 | +++ bin/addons/account_mcdb/account_analytic_line.py 2019-10-30 13:23:20 +0000 | |||
1747 | @@ -26,6 +26,8 @@ | |||
1748 | 26 | from time import strftime | 26 | from time import strftime |
1749 | 27 | from lxml import etree | 27 | from lxml import etree |
1750 | 28 | from tools.translate import _ | 28 | from tools.translate import _ |
1751 | 29 | from base import currency_date | ||
1752 | 30 | |||
1753 | 29 | 31 | ||
1754 | 30 | class account_analytic_line(osv.osv): | 32 | class account_analytic_line(osv.osv): |
1755 | 31 | _name = 'account.analytic.line' | 33 | _name = 'account.analytic.line' |
1756 | @@ -35,6 +37,8 @@ | |||
1757 | 35 | """ | 37 | """ |
1758 | 36 | Get an amount regarding currency in context (from 'output' and 'output_currency_id' values) | 38 | Get an amount regarding currency in context (from 'output' and 'output_currency_id' values) |
1759 | 37 | """ | 39 | """ |
1760 | 40 | if context is None: | ||
1761 | 41 | context = {} | ||
1762 | 38 | # Prepare some value | 42 | # Prepare some value |
1763 | 39 | res = {} | 43 | res = {} |
1764 | 40 | # Some verifications | 44 | # Some verifications |
1765 | @@ -48,27 +52,32 @@ | |||
1766 | 48 | # Retrieve currency | 52 | # Retrieve currency |
1767 | 49 | currency_id = context.get('output_currency_id') | 53 | currency_id = context.get('output_currency_id') |
1768 | 50 | currency_obj = self.pool.get('res.currency') | 54 | currency_obj = self.pool.get('res.currency') |
1769 | 55 | # DONE: TEST JN => the context is not important here | ||
1770 | 51 | rate = currency_obj.read(cr, uid, currency_id, ['rate'], context=context).get('rate', False) | 56 | rate = currency_obj.read(cr, uid, currency_id, ['rate'], context=context).get('rate', False) |
1771 | 52 | # Do calculation | 57 | # Do calculation |
1772 | 53 | if not rate: | 58 | if not rate: |
1773 | 54 | for out_id in ids: | 59 | for out_id in ids: |
1774 | 55 | res[out_id] = {'output_currency': currency_id, 'output_amount': 0.0, 'output_amount_debit': 0.0, 'output_amount_credit': 0.0} | 60 | res[out_id] = {'output_currency': currency_id, 'output_amount': 0.0, 'output_amount_debit': 0.0, 'output_amount_credit': 0.0} |
1775 | 56 | return res | 61 | return res |
1778 | 57 | for ml in self.browse(cr, uid, ids, context=context): | 62 | aal_fields = ['document_date', 'date', 'source_date', 'currency_id', 'amount_currency'] |
1779 | 58 | res[ml.id] = {'output_currency': False, 'output_amount': 0.0, 'output_amount_debit': 0.0, 'output_amount_credit': 0.0} | 63 | for aal in self.browse(cr, uid, ids, fields_to_fetch=aal_fields, context=context): |
1780 | 64 | res[aal.id] = {'output_currency': False, 'output_amount': 0.0, 'output_amount_debit': 0.0, 'output_amount_credit': 0.0} | ||
1781 | 59 | # output_amount field | 65 | # output_amount field |
1782 | 60 | # Update with date | 66 | # Update with date |
1786 | 61 | context.update({'date': ml.source_date or ml.date or strftime('%Y-%m-%d')}) | 67 | # DONE: TEST JN |
1787 | 62 | mnt = self.pool.get('res.currency').compute(cr, uid, ml.currency_id.id, currency_id, ml.amount_currency, round=True, context=context) | 68 | curr_date = currency_date.get_date(self, cr, aal.document_date, aal.date, source_date=aal.source_date) |
1788 | 63 | res[ml.id]['output_amount'] = mnt or 0.0 | 69 | context.update({'currency_date': curr_date or strftime('%Y-%m-%d')}) |
1789 | 70 | mnt = self.pool.get('res.currency').compute(cr, uid, aal.currency_id.id, currency_id, aal.amount_currency, | ||
1790 | 71 | round=True, context=context) | ||
1791 | 72 | res[aal.id]['output_amount'] = mnt or 0.0 | ||
1792 | 64 | if mnt < 0.0: | 73 | if mnt < 0.0: |
1795 | 65 | res[ml.id]['output_amount_debit'] = 0.0 | 74 | res[aal.id]['output_amount_debit'] = 0.0 |
1796 | 66 | res[ml.id]['output_amount_credit'] = abs(mnt) or 0.0 | 75 | res[aal.id]['output_amount_credit'] = abs(mnt) or 0.0 |
1797 | 67 | else: | 76 | else: |
1800 | 68 | res[ml.id]['output_amount_debit'] = abs(mnt) or 0.0 | 77 | res[aal.id]['output_amount_debit'] = abs(mnt) or 0.0 |
1801 | 69 | res[ml.id]['output_amount_credit'] = 0.0 | 78 | res[aal.id]['output_amount_credit'] = 0.0 |
1802 | 70 | # or output_currency field | 79 | # or output_currency field |
1804 | 71 | res[ml.id]['output_currency'] = currency_id | 80 | res[aal.id]['output_currency'] = currency_id |
1805 | 72 | return res | 81 | return res |
1806 | 73 | 82 | ||
1807 | 74 | def _get_cheque_number(self, cr, uid, ids, name, args, context=None): | 83 | def _get_cheque_number(self, cr, uid, ids, name, args, context=None): |
1808 | 75 | 84 | ||
1809 | === modified file 'bin/addons/account_mcdb/account_bank_statement.py' | |||
1810 | --- bin/addons/account_mcdb/account_bank_statement.py 2014-04-15 08:35:03 +0000 | |||
1811 | +++ bin/addons/account_mcdb/account_bank_statement.py 2019-10-30 13:23:20 +0000 | |||
1812 | @@ -25,6 +25,8 @@ | |||
1813 | 25 | from osv import fields | 25 | from osv import fields |
1814 | 26 | from time import strftime | 26 | from time import strftime |
1815 | 27 | from lxml import etree | 27 | from lxml import etree |
1816 | 28 | from base import currency_date | ||
1817 | 29 | |||
1818 | 28 | 30 | ||
1819 | 29 | class account_bank_statement_line(osv.osv): | 31 | class account_bank_statement_line(osv.osv): |
1820 | 30 | _name = 'account.bank.statement.line' | 32 | _name = 'account.bank.statement.line' |
1821 | @@ -34,6 +36,8 @@ | |||
1822 | 34 | """ | 36 | """ |
1823 | 35 | Get an amount regarding currency in context (from 'output' and 'output_currency_id' values) | 37 | Get an amount regarding currency in context (from 'output' and 'output_currency_id' values) |
1824 | 36 | """ | 38 | """ |
1825 | 39 | if context is None: | ||
1826 | 40 | context = {} | ||
1827 | 37 | # Prepare some value | 41 | # Prepare some value |
1828 | 38 | res = {} | 42 | res = {} |
1829 | 39 | # Some verifications | 43 | # Some verifications |
1830 | @@ -47,6 +51,7 @@ | |||
1831 | 47 | # Retrieve currency | 51 | # Retrieve currency |
1832 | 48 | currency_id = context.get('output_currency_id') | 52 | currency_id = context.get('output_currency_id') |
1833 | 49 | currency_obj = self.pool.get('res.currency') | 53 | currency_obj = self.pool.get('res.currency') |
1834 | 54 | # DONE: TEST JN => the context is not important here | ||
1835 | 50 | rate = currency_obj.read(cr, uid, currency_id, ['rate'], context=context).get('rate', False) | 55 | rate = currency_obj.read(cr, uid, currency_id, ['rate'], context=context).get('rate', False) |
1836 | 51 | # Do calculation | 56 | # Do calculation |
1837 | 52 | if not rate: | 57 | if not rate: |
1838 | @@ -57,7 +62,9 @@ | |||
1839 | 57 | res[absl.id] = {'output_currency': False, 'output_amount': 0.0, 'output_amount_debit': 0.0, 'output_amount_credit': 0.0} | 62 | res[absl.id] = {'output_currency': False, 'output_amount': 0.0, 'output_amount_debit': 0.0, 'output_amount_credit': 0.0} |
1840 | 58 | # output_amount field | 63 | # output_amount field |
1841 | 59 | # Update with date | 64 | # Update with date |
1843 | 60 | context.update({'date': absl.date or strftime('%Y-%m-%d')}) | 65 | # DONE: TEST JN |
1844 | 66 | curr_date = currency_date.get_date(self, cr, absl.document_date, absl.date) | ||
1845 | 67 | context.update({'currency_date': curr_date or strftime('%Y-%m-%d')}) | ||
1846 | 61 | mnt = self.pool.get('res.currency').compute(cr, uid, absl.currency_id.id, currency_id, absl.amount, round=True, context=context) | 68 | mnt = self.pool.get('res.currency').compute(cr, uid, absl.currency_id.id, currency_id, absl.amount, round=True, context=context) |
1847 | 62 | res[absl.id]['output_amount'] = mnt or 0.0 | 69 | res[absl.id]['output_amount'] = mnt or 0.0 |
1848 | 63 | if mnt < 0.0: | 70 | if mnt < 0.0: |
1849 | 64 | 71 | ||
1850 | === modified file 'bin/addons/account_mcdb/account_move_line.py' | |||
1851 | --- bin/addons/account_mcdb/account_move_line.py 2019-02-06 10:04:42 +0000 | |||
1852 | +++ bin/addons/account_mcdb/account_move_line.py 2019-10-30 13:23:20 +0000 | |||
1853 | @@ -25,6 +25,8 @@ | |||
1854 | 25 | from osv import fields | 25 | from osv import fields |
1855 | 26 | from time import strftime | 26 | from time import strftime |
1856 | 27 | from lxml import etree | 27 | from lxml import etree |
1857 | 28 | from base import currency_date | ||
1858 | 29 | |||
1859 | 28 | 30 | ||
1860 | 29 | class account_move_line(osv.osv): | 31 | class account_move_line(osv.osv): |
1861 | 30 | _name = 'account.move.line' | 32 | _name = 'account.move.line' |
1862 | @@ -53,6 +55,7 @@ | |||
1863 | 53 | return func_amount | 55 | return func_amount |
1864 | 54 | original_currency = ml.functional_currency_id.id | 56 | original_currency = ml.functional_currency_id.id |
1865 | 55 | # Perform the conversion from original currency to selected currency | 57 | # Perform the conversion from original currency to selected currency |
1866 | 58 | # DONE: TEST JN => there is only a "currency_date" in context (no "date") | ||
1867 | 56 | return currency_obj.compute(cr, uid, original_currency, currency_id, func_amount, round=round, context=context) | 59 | return currency_obj.compute(cr, uid, original_currency, currency_id, func_amount, round=round, context=context) |
1868 | 57 | 60 | ||
1869 | 58 | def _get_output(self, cr, uid, ids, field_name, arg, context=None): | 61 | def _get_output(self, cr, uid, ids, field_name, arg, context=None): |
1870 | @@ -76,6 +79,7 @@ | |||
1871 | 76 | company_currency_id = self.pool.get('res.users').browse(cr, uid, uid, context=context).company_id.currency_id.id | 79 | company_currency_id = self.pool.get('res.users').browse(cr, uid, uid, context=context).company_id.currency_id.id |
1872 | 77 | currency_id = context.get('output_currency_id') | 80 | currency_id = context.get('output_currency_id') |
1873 | 78 | currency_obj = self.pool.get('res.currency') | 81 | currency_obj = self.pool.get('res.currency') |
1874 | 82 | # DONE: TEST JN => the context is not important here | ||
1875 | 79 | rate = currency_obj.read(cr, uid, currency_id, ['rate'], context=context).get('rate', False) | 83 | rate = currency_obj.read(cr, uid, currency_id, ['rate'], context=context).get('rate', False) |
1876 | 80 | # Do calculation | 84 | # Do calculation |
1877 | 81 | if not rate: | 85 | if not rate: |
1878 | @@ -86,7 +90,9 @@ | |||
1879 | 86 | res[ml.id] = {'output_currency': currency_id, 'output_amount': 0.0, 'output_amount_debit': 0.0, 'output_amount_credit': 0.0} | 90 | res[ml.id] = {'output_currency': currency_id, 'output_amount': 0.0, 'output_amount_debit': 0.0, 'output_amount_credit': 0.0} |
1880 | 87 | # output_amount field | 91 | # output_amount field |
1881 | 88 | # Update with date | 92 | # Update with date |
1883 | 89 | context.update({'date': ml.source_date or ml.date or strftime('%Y-%m-%d')}) | 93 | # DONE: TEST JN |
1884 | 94 | curr_date = currency_date.get_date(self, cr, ml.document_date, ml.date, source_date=ml.source_date) | ||
1885 | 95 | context.update({'currency_date': curr_date or strftime('%Y-%m-%d')}) | ||
1886 | 90 | # Now call the common method to calculate the output values | 96 | # Now call the common method to calculate the output values |
1887 | 91 | if currency_id == company_currency_id: | 97 | if currency_id == company_currency_id: |
1888 | 92 | res[ml.id].update({'output_amount': ml.debit - ml.credit, 'output_amount_debit': ml.debit, 'output_amount_credit': ml.credit}) | 98 | res[ml.id].update({'output_amount': ml.debit - ml.credit, 'output_amount_debit': ml.debit, 'output_amount_credit': ml.credit}) |
1889 | 93 | 99 | ||
1890 | === modified file 'bin/addons/account_mcdb/report/account_mcdb_export.py' | |||
1891 | --- bin/addons/account_mcdb/report/account_mcdb_export.py 2017-07-06 14:23:27 +0000 | |||
1892 | +++ bin/addons/account_mcdb/report/account_mcdb_export.py 2019-10-30 13:23:20 +0000 | |||
1893 | @@ -24,6 +24,9 @@ | |||
1894 | 24 | from osv import osv | 24 | from osv import osv |
1895 | 25 | from osv import fields | 25 | from osv import fields |
1896 | 26 | from tools.translate import _ | 26 | from tools.translate import _ |
1897 | 27 | from time import strftime | ||
1898 | 28 | from base import currency_date | ||
1899 | 29 | |||
1900 | 27 | 30 | ||
1901 | 28 | def get_back_browse(self, cr, uid, context): | 31 | def get_back_browse(self, cr, uid, context): |
1902 | 29 | background_id = context.get('background_id') | 32 | background_id = context.get('background_id') |
1903 | @@ -240,11 +243,9 @@ | |||
1904 | 240 | csv_line.append(company_currency.encode('utf-8') or '') | 243 | csv_line.append(company_currency.encode('utf-8') or '') |
1905 | 241 | else: | 244 | else: |
1906 | 242 | #output debit/credit | 245 | #output debit/credit |
1912 | 243 | context['date'] = al.source_date or al.date # uftp-361 [FIX] reversal line: source_date or posting_date | 246 | # DONE: TEST JN |
1913 | 244 | if al.is_reversal == True: | 247 | curr_date = currency_date.get_date(self, cr, al.document_date, al.date, source_date=al.source_date) |
1914 | 245 | context.update({'date': al.document_date}) | 248 | context['currency_date'] = curr_date |
1910 | 246 | if al.last_corrected_id: | ||
1911 | 247 | context.update({'date': al.document_date}) | ||
1915 | 248 | amount = currency_obj.compute(cr, uid, al.currency_id.id, currency_id, al.amount_currency, round=True, context=context) | 249 | amount = currency_obj.compute(cr, uid, al.currency_id.id, currency_id, al.amount_currency, round=True, context=context) |
1916 | 249 | csv_line.append(amount or 0.0) | 250 | csv_line.append(amount or 0.0) |
1917 | 250 | #output currency | 251 | #output currency |
1918 | @@ -313,6 +314,9 @@ | |||
1919 | 313 | csv_line.append(absl.functional_currency_id and absl.functional_currency_id.name and absl.functional_currency_id.name.encode('utf-8') or '') | 314 | csv_line.append(absl.functional_currency_id and absl.functional_currency_id.name and absl.functional_currency_id.name.encode('utf-8') or '') |
1920 | 314 | else: | 315 | else: |
1921 | 315 | #output amount (debit/credit) regarding booking currency | 316 | #output amount (debit/credit) regarding booking currency |
1922 | 317 | # DONE: TEST JN | ||
1923 | 318 | curr_date = currency_date.get_date(self, cr, absl.document_date, absl.date) | ||
1924 | 319 | context.update({'currency_date': curr_date or strftime('%Y-%m-%d')}) | ||
1925 | 316 | amount = currency_obj.compute(cr, uid, absl.currency_id.id, currency_id, absl.amount, round=True, context=context) | 320 | amount = currency_obj.compute(cr, uid, absl.currency_id.id, currency_id, absl.amount, round=True, context=context) |
1926 | 317 | if amount < 0.0: | 321 | if amount < 0.0: |
1927 | 318 | csv_line.append(0.0) | 322 | csv_line.append(0.0) |
1928 | 319 | 323 | ||
1929 | === modified file 'bin/addons/account_override/account.py' | |||
1930 | --- bin/addons/account_override/account.py 2019-09-27 08:59:21 +0000 | |||
1931 | +++ bin/addons/account_override/account.py 2019-10-30 13:23:20 +0000 | |||
1932 | @@ -90,6 +90,7 @@ | |||
1933 | 90 | (__compute will handle their escaping) as a | 90 | (__compute will handle their escaping) as a |
1934 | 91 | tuple | 91 | tuple |
1935 | 92 | """ | 92 | """ |
1936 | 93 | # DONE: TEST JN => there is no "date" in context | ||
1937 | 93 | mapping = { | 94 | mapping = { |
1938 | 94 | 'balance': "COALESCE(SUM(l.debit),0) " \ | 95 | 'balance': "COALESCE(SUM(l.debit),0) " \ |
1939 | 95 | "- COALESCE(SUM(l.credit), 0) as balance", | 96 | "- COALESCE(SUM(l.credit), 0) as balance", |
1940 | @@ -997,6 +998,7 @@ | |||
1941 | 997 | if 'document_date' in vals: | 998 | if 'document_date' in vals: |
1942 | 998 | context['document_date'] = vals.get('document_date') | 999 | context['document_date'] = vals.get('document_date') |
1943 | 999 | if 'date' in vals: | 1000 | if 'date' in vals: |
1944 | 1001 | # DONE: TEST JN => this date isn't used for amount computation | ||
1945 | 1000 | context['date'] = vals.get('date') | 1002 | context['date'] = vals.get('date') |
1946 | 1001 | # UTFTP-262: Make manual_name mandatory | 1003 | # UTFTP-262: Make manual_name mandatory |
1947 | 1002 | if 'manual_name' not in vals or not vals.get('manual_name', False) or vals.get('manual_name') == '': | 1004 | if 'manual_name' not in vals or not vals.get('manual_name', False) or vals.get('manual_name') == '': |
1948 | 1003 | 1005 | ||
1949 | === modified file 'bin/addons/account_override/account_move_line.py' | |||
1950 | --- bin/addons/account_override/account_move_line.py 2018-11-12 17:20:58 +0000 | |||
1951 | +++ bin/addons/account_override/account_move_line.py 2019-10-30 13:23:20 +0000 | |||
1952 | @@ -546,6 +546,7 @@ | |||
1953 | 546 | context.update({'document_date': m.document_date}) | 546 | context.update({'document_date': m.document_date}) |
1954 | 547 | if m and m.date: | 547 | if m and m.date: |
1955 | 548 | vals.update({'date': m.date}) | 548 | vals.update({'date': m.date}) |
1956 | 549 | # DONE: TEST JN => this date isn't used for amount computation | ||
1957 | 549 | context.update({'date': m.date}) | 550 | context.update({'date': m.date}) |
1958 | 550 | # UFTP-262: Add description from the move_id (US-2027) if there is not descr. on the line | 551 | # UFTP-262: Add description from the move_id (US-2027) if there is not descr. on the line |
1959 | 551 | if m and m.manual_name and not vals.get('name'): | 552 | if m and m.manual_name and not vals.get('name'): |
1960 | @@ -600,6 +601,7 @@ | |||
1961 | 600 | context.update({'document_date': m.document_date}) | 601 | context.update({'document_date': m.document_date}) |
1962 | 601 | if m and m.date: | 602 | if m and m.date: |
1963 | 602 | vals.update({'date': m.date}) | 603 | vals.update({'date': m.date}) |
1964 | 604 | # DONE: TEST JN => not sure whether it's still possible to have a move_id in vals at this step but in any cases the date in context here has no effect on amount computation | ||
1965 | 603 | context.update({'date': m.date}) | 605 | context.update({'date': m.date}) |
1966 | 604 | # Note that _check_document_date HAVE TO be BEFORE the super write. If not, some problems appears in ournal entries document/posting date changes at the same time! | 606 | # Note that _check_document_date HAVE TO be BEFORE the super write. If not, some problems appears in ournal entries document/posting date changes at the same time! |
1967 | 605 | self._check_document_date(cr, uid, ids, vals, context=context) | 607 | self._check_document_date(cr, uid, ids, vals, context=context) |
1968 | 606 | 608 | ||
1969 | === modified file 'bin/addons/account_override/invoice.py' | |||
1970 | --- bin/addons/account_override/invoice.py 2019-07-25 15:47:28 +0000 | |||
1971 | +++ bin/addons/account_override/invoice.py 2019-10-30 13:23:20 +0000 | |||
1972 | @@ -973,6 +973,8 @@ | |||
1973 | 973 | Reverse move if this object is a In-kind Donation. Otherwise do normal job: cancellation. | 973 | Reverse move if this object is a In-kind Donation. Otherwise do normal job: cancellation. |
1974 | 974 | Don't delete an invoice that is linked to a PO. This is only for supplier invoices. | 974 | Don't delete an invoice that is linked to a PO. This is only for supplier invoices. |
1975 | 975 | """ | 975 | """ |
1976 | 976 | # Oct. 2019: log if this method is used at least once (cf it may be dead code?) | ||
1977 | 977 | self.pool.get('ir.config_parameter').set_param(cr, 1, 'action_cancel.in_use', True) | ||
1978 | 976 | to_cancel = [] | 978 | to_cancel = [] |
1979 | 977 | for i in self.browse(cr, uid, ids): | 979 | for i in self.browse(cr, uid, ids): |
1980 | 978 | if i.is_inkind_donation: | 980 | if i.is_inkind_donation: |
1981 | @@ -1934,6 +1936,7 @@ | |||
1982 | 1934 | std_price = p_info['standard_price'] | 1936 | std_price = p_info['standard_price'] |
1983 | 1935 | company_curr_id = self.pool.get('res.users').browse(cr, uid, uid).company_id.currency_id.id | 1937 | company_curr_id = self.pool.get('res.users').browse(cr, uid, uid).company_id.currency_id.id |
1984 | 1936 | if company_curr_id and company_curr_id != currency_id: | 1938 | if company_curr_id and company_curr_id != currency_id: |
1985 | 1939 | # DONE: TEST JN => no date in context | ||
1986 | 1937 | std_price = self.pool.get('res.currency').compute(cr, uid, company_curr_id, currency_id, std_price, context=context) | 1940 | std_price = self.pool.get('res.currency').compute(cr, uid, company_curr_id, currency_id, std_price, context=context) |
1987 | 1938 | res['value']['price_unit'] = std_price | 1941 | res['value']['price_unit'] = std_price |
1988 | 1939 | res['value']['price_subtotal'] = (qty or 0) * std_price | 1942 | res['value']['price_subtotal'] = (qty or 0) * std_price |
1989 | 1940 | 1943 | ||
1990 | === modified file 'bin/addons/account_override/res_company.py' | |||
1991 | --- bin/addons/account_override/res_company.py 2019-01-30 10:58:14 +0000 | |||
1992 | +++ bin/addons/account_override/res_company.py 2019-10-30 13:23:20 +0000 | |||
1993 | @@ -23,11 +23,32 @@ | |||
1994 | 23 | 23 | ||
1995 | 24 | from osv import osv | 24 | from osv import osv |
1996 | 25 | from osv import fields | 25 | from osv import fields |
1997 | 26 | from base import currency_date | ||
1998 | 27 | from tools.translate import _ | ||
1999 | 28 | |||
2000 | 26 | 29 | ||
2001 | 27 | class res_company(osv.osv): | 30 | class res_company(osv.osv): |
2002 | 28 | _name = 'res.company' | 31 | _name = 'res.company' |
2003 | 29 | _inherit = 'res.company' | 32 | _inherit = 'res.company' |
2004 | 30 | 33 | ||
2005 | 34 | def _get_currency_date_type(self, cr, uid, ids, name, args, context=None): | ||
2006 | 35 | """ | ||
2007 | 36 | Returns the type of date used for functional amount computation in this instance | ||
2008 | 37 | """ | ||
2009 | 38 | res = {} | ||
2010 | 39 | for c_id in ids: | ||
2011 | 40 | res[c_id] = currency_date.get_date_type(self, cr) == 'document' and _('Document Date') or _('Posting Date') | ||
2012 | 41 | return res | ||
2013 | 42 | |||
2014 | 43 | def _get_currency_date_beginning(self, cr, uid, ids, name, args, context=None): | ||
2015 | 44 | """ | ||
2016 | 45 | Returns the date from when the functional amount computation is based on the document date, if applicable | ||
2017 | 46 | """ | ||
2018 | 47 | res = {} | ||
2019 | 48 | for c_id in ids: | ||
2020 | 49 | res[c_id] = currency_date.get_date_type(self, cr) == 'document' and currency_date.BEGINNING or False | ||
2021 | 50 | return res | ||
2022 | 51 | |||
2023 | 31 | _columns = { | 52 | _columns = { |
2024 | 32 | 'import_invoice_default_account': fields.many2one('account.account', string="Re-billing Inter-section account", | 53 | 'import_invoice_default_account': fields.many2one('account.account', string="Re-billing Inter-section account", |
2025 | 33 | help="Default account for an import invoice on a Debit note"), | 54 | help="Default account for an import invoice on a Debit note"), |
2026 | @@ -36,6 +57,10 @@ | |||
2027 | 36 | 'additional_allocation': fields.boolean('Additional allocation condition?', help="If you check this attribute, analytic allocation will be required for income accounts with an account code starting with \"7\"; if unchecked, the analytic allocation will be required for all income accounts."), | 57 | 'additional_allocation': fields.boolean('Additional allocation condition?', help="If you check this attribute, analytic allocation will be required for income accounts with an account code starting with \"7\"; if unchecked, the analytic allocation will be required for all income accounts."), |
2028 | 37 | 'revaluation_default_account': fields.many2one('account.account', string="Revaluation account", | 58 | 'revaluation_default_account': fields.many2one('account.account', string="Revaluation account", |
2029 | 38 | help="Default account used for revaluation"), | 59 | help="Default account used for revaluation"), |
2030 | 60 | 'currency_date_type': fields.function(_get_currency_date_type, method=True, type='char', | ||
2031 | 61 | string='Date Type Used', store=False, readonly=1), | ||
2032 | 62 | 'currency_date_beginning': fields.function(_get_currency_date_beginning, method=True, type='date', | ||
2033 | 63 | string='Since', store=False, readonly=1), | ||
2034 | 39 | } | 64 | } |
2035 | 40 | 65 | ||
2036 | 41 | 66 | ||
2037 | 42 | 67 | ||
2038 | === modified file 'bin/addons/account_override/res_currency.py' | |||
2039 | --- bin/addons/account_override/res_currency.py 2014-03-06 16:53:18 +0000 | |||
2040 | +++ bin/addons/account_override/res_currency.py 2019-10-30 13:23:20 +0000 | |||
2041 | @@ -33,62 +33,3 @@ | |||
2042 | 33 | 33 | ||
2043 | 34 | res_currency_rate() | 34 | res_currency_rate() |
2044 | 35 | 35 | ||
2045 | 36 | class res_currency(osv.osv): | ||
2046 | 37 | _name = 'res.currency' | ||
2047 | 38 | _inherit = 'res.currency' | ||
2048 | 39 | |||
2049 | 40 | def _check_unicity_currency_name(self, cr, uid, ids, context=None): | ||
2050 | 41 | """ | ||
2051 | 42 | Check that no currency have the same name and the same currency_table_id. | ||
2052 | 43 | Check is non case-sensitive. | ||
2053 | 44 | """ | ||
2054 | 45 | if not context: | ||
2055 | 46 | context = {} | ||
2056 | 47 | for c in self.browse(cr, uid, ids): | ||
2057 | 48 | if not c.currency_name: | ||
2058 | 49 | continue | ||
2059 | 50 | sql = """SELECT id, name | ||
2060 | 51 | FROM res_currency | ||
2061 | 52 | WHERE currency_name ilike %s""" | ||
2062 | 53 | if c.currency_table_id: | ||
2063 | 54 | sql += """\nAND currency_table_id in %s""" | ||
2064 | 55 | cr.execute(sql, (c.currency_name, tuple([c.currency_table_id.id]))) | ||
2065 | 56 | else: | ||
2066 | 57 | sql += """\nAND currency_table_id is Null""" | ||
2067 | 58 | cr.execute(sql, (c.currency_name,)) | ||
2068 | 59 | bad_ids = cr.fetchall() | ||
2069 | 60 | if bad_ids and len(bad_ids) > 1: | ||
2070 | 61 | return False | ||
2071 | 62 | return True | ||
2072 | 63 | |||
2073 | 64 | def _check_unicity_name(self, cr, uid, ids, context=None): | ||
2074 | 65 | """ | ||
2075 | 66 | Check that no currency is the same and have the same currency_table_id. | ||
2076 | 67 | Check is non case-sensitive. | ||
2077 | 68 | """ | ||
2078 | 69 | if not context: | ||
2079 | 70 | context = {} | ||
2080 | 71 | for c in self.browse(cr, uid, ids): | ||
2081 | 72 | if not c.name: | ||
2082 | 73 | continue | ||
2083 | 74 | sql = """SELECT id, name | ||
2084 | 75 | FROM res_currency | ||
2085 | 76 | WHERE name ilike %s""" | ||
2086 | 77 | if c.currency_table_id: | ||
2087 | 78 | sql += """\nAND currency_table_id in %s""" | ||
2088 | 79 | cr.execute(sql, (c.name, tuple([c.currency_table_id.id]))) | ||
2089 | 80 | else: | ||
2090 | 81 | sql += """\nAND currency_table_id is Null""" | ||
2091 | 82 | cr.execute(sql, (c.name,)) | ||
2092 | 83 | bad_ids = cr.fetchall() | ||
2093 | 84 | if bad_ids and len(bad_ids) > 1: | ||
2094 | 85 | return False | ||
2095 | 86 | return True | ||
2096 | 87 | |||
2097 | 88 | _constraints = [ | ||
2098 | 89 | (_check_unicity_currency_name, "Another currency have the same name.", ['currency_name']), | ||
2099 | 90 | (_check_unicity_name, "Same currency exists", ['name']), | ||
2100 | 91 | ] | ||
2101 | 92 | |||
2102 | 93 | res_currency() | ||
2103 | 94 | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: | ||
2104 | 95 | 36 | ||
2105 | === modified file 'bin/addons/account_payment/__init__.py' | |||
2106 | --- bin/addons/account_payment/__init__.py 2011-01-14 00:11:01 +0000 | |||
2107 | +++ bin/addons/account_payment/__init__.py 2019-10-30 13:23:20 +0000 | |||
2108 | @@ -23,10 +23,6 @@ | |||
2109 | 23 | # Init Sales | 23 | # Init Sales |
2110 | 24 | #---------------------------------------------------------- | 24 | #---------------------------------------------------------- |
2111 | 25 | 25 | ||
2114 | 26 | import account_payment | 26 | import account_invoice |
2113 | 27 | import wizard | ||
2115 | 28 | import account_move_line | 27 | import account_move_line |
2116 | 29 | import account_invoice | ||
2117 | 30 | import report | ||
2118 | 31 | |||
2119 | 32 | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: | ||
2120 | 33 | \ No newline at end of file | 28 | \ No newline at end of file |
2121 | 29 | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: | ||
2122 | 34 | 30 | ||
2123 | === modified file 'bin/addons/account_payment/__openerp__.py' | |||
2124 | --- bin/addons/account_payment/__openerp__.py 2017-09-28 14:05:02 +0000 | |||
2125 | +++ bin/addons/account_payment/__openerp__.py 2019-10-30 13:23:20 +0000 | |||
2126 | @@ -31,20 +31,11 @@ | |||
2127 | 31 | * a basic mechanism to easily plug various automated payment. | 31 | * a basic mechanism to easily plug various automated payment. |
2128 | 32 | """, | 32 | """, |
2129 | 33 | 'author': 'OpenERP SA', | 33 | 'author': 'OpenERP SA', |
2131 | 34 | 'depends': ['account_voucher'], | 34 | 'depends': ['account'], |
2132 | 35 | 'update_xml': [ | 35 | 'update_xml': [ |
2133 | 36 | 'security/account_payment_security.xml', | ||
2134 | 37 | 'security/ir.model.access.csv', | ||
2135 | 38 | 'wizard/account_payment_pay_view.xml', | ||
2136 | 39 | 'wizard/account_payment_populate_statement_view.xml', | ||
2137 | 40 | 'wizard/account_payment_create_order_view.xml', | ||
2138 | 41 | 'account_payment_view.xml', | ||
2139 | 42 | 'account_payment_workflow.xml', | ||
2140 | 43 | 'account_payment_sequence.xml', | ||
2141 | 44 | 'account_invoice_view.xml', | 36 | 'account_invoice_view.xml', |
2142 | 45 | 'account_payment_report.xml', | ||
2143 | 46 | ], | 37 | ], |
2145 | 47 | 'demo_xml': ['account_payment_demo.xml'], | 38 | 'demo_xml': [], |
2146 | 48 | 'test': [ | 39 | 'test': [ |
2147 | 49 | ], | 40 | ], |
2148 | 50 | 'installable': True, | 41 | 'installable': True, |
2149 | 51 | 42 | ||
2150 | === modified file 'bin/addons/account_payment/account_move_line.py' | |||
2151 | --- bin/addons/account_payment/account_move_line.py 2018-04-03 10:18:51 +0000 | |||
2152 | +++ bin/addons/account_payment/account_move_line.py 2019-10-30 13:23:20 +0000 | |||
2153 | @@ -19,9 +19,7 @@ | |||
2154 | 19 | # | 19 | # |
2155 | 20 | ############################################################################## | 20 | ############################################################################## |
2156 | 21 | 21 | ||
2157 | 22 | from operator import itemgetter | ||
2158 | 23 | from osv import fields, osv | 22 | from osv import fields, osv |
2159 | 24 | from tools.translate import _ | ||
2160 | 25 | 23 | ||
2161 | 26 | class account_move_line(osv.osv): | 24 | class account_move_line(osv.osv): |
2162 | 27 | _inherit = "account.move.line" | 25 | _inherit = "account.move.line" |
2163 | @@ -35,84 +33,16 @@ | |||
2164 | 35 | CASE WHEN ml.amount_currency < 0 | 33 | CASE WHEN ml.amount_currency < 0 |
2165 | 36 | THEN - ml.amount_currency | 34 | THEN - ml.amount_currency |
2166 | 37 | ELSE ml.credit | 35 | ELSE ml.credit |
2174 | 38 | END - | 36 | END |
2168 | 39 | (SELECT coalesce(sum(amount_currency),0) | ||
2169 | 40 | FROM payment_line pl | ||
2170 | 41 | INNER JOIN payment_order po | ||
2171 | 42 | ON (pl.order_id = po.id) | ||
2172 | 43 | WHERE move_line_id = ml.id | ||
2173 | 44 | AND po.state != 'cancel') AS amount | ||
2175 | 45 | FROM account_move_line ml | 37 | FROM account_move_line ml |
2176 | 46 | WHERE id IN %s""", (tuple(ids),)) | 38 | WHERE id IN %s""", (tuple(ids),)) |
2177 | 47 | r = dict(cr.fetchall()) | 39 | r = dict(cr.fetchall()) |
2178 | 48 | return r | 40 | return r |
2179 | 49 | 41 | ||
2180 | 50 | def _to_pay_search(self, cr, uid, obj, name, args, context=None): | ||
2181 | 51 | if not args: | ||
2182 | 52 | return [] | ||
2183 | 53 | line_obj = self.pool.get('account.move.line') | ||
2184 | 54 | query = line_obj._query_get(cr, uid, context={}) | ||
2185 | 55 | where = ' and '.join(map(lambda x: '''(SELECT | ||
2186 | 56 | CASE WHEN l.amount_currency < 0 | ||
2187 | 57 | THEN - l.amount_currency | ||
2188 | 58 | ELSE l.credit | ||
2189 | 59 | END - coalesce(sum(pl.amount_currency), 0) | ||
2190 | 60 | FROM payment_line pl | ||
2191 | 61 | INNER JOIN payment_order po ON (pl.order_id = po.id) | ||
2192 | 62 | WHERE move_line_id = l.id | ||
2193 | 63 | AND po.state != 'cancel' | ||
2194 | 64 | ) %(operator)s %%s ''' % {'operator': x[1]}, args)) | ||
2195 | 65 | sql_args = tuple(map(itemgetter(2), args)) | ||
2196 | 66 | |||
2197 | 67 | cr.execute(('''SELECT id | ||
2198 | 68 | FROM account_move_line l | ||
2199 | 69 | WHERE account_id IN (select id | ||
2200 | 70 | FROM account_account | ||
2201 | 71 | WHERE type=%s AND active) | ||
2202 | 72 | AND reconcile_id IS null | ||
2203 | 73 | AND credit > 0 | ||
2204 | 74 | AND ''' + where + ' and ' + query), ('payable',)+sql_args ) # not_a_user_entry | ||
2205 | 75 | |||
2206 | 76 | res = cr.fetchall() | ||
2207 | 77 | if not res: | ||
2208 | 78 | return [('id', '=', '0')] | ||
2209 | 79 | return [('id', 'in', map(lambda x:x[0], res))] | ||
2210 | 80 | |||
2211 | 81 | def line2bank(self, cr, uid, ids, payment_type=None, context=None): | ||
2212 | 82 | """ | ||
2213 | 83 | Try to return for each Ledger Posting line a corresponding bank | ||
2214 | 84 | account according to the payment type. This work using one of | ||
2215 | 85 | the bank of the partner defined on the invoice eventually | ||
2216 | 86 | associated to the line. | ||
2217 | 87 | Return the first suitable bank for the corresponding partner. | ||
2218 | 88 | """ | ||
2219 | 89 | payment_mode_obj = self.pool.get('payment.mode') | ||
2220 | 90 | line2bank = {} | ||
2221 | 91 | if not ids: | ||
2222 | 92 | return {} | ||
2223 | 93 | bank_type = payment_mode_obj.suitable_bank_types(cr, uid, payment_type, | ||
2224 | 94 | context=context) | ||
2225 | 95 | for line in self.browse(cr, uid, ids, context=context): | ||
2226 | 96 | line2bank[line.id] = False | ||
2227 | 97 | if line.invoice and line.invoice.partner_bank_id: | ||
2228 | 98 | line2bank[line.id] = line.invoice.partner_bank_id.id | ||
2229 | 99 | elif line.partner_id: | ||
2230 | 100 | if not line.partner_id.bank_ids: | ||
2231 | 101 | line2bank[line.id] = False | ||
2232 | 102 | else: | ||
2233 | 103 | for bank in line.partner_id.bank_ids: | ||
2234 | 104 | if bank.state in bank_type: | ||
2235 | 105 | line2bank[line.id] = bank.id | ||
2236 | 106 | break | ||
2237 | 107 | if not line2bank[line.id] and line.partner_id.bank_ids: | ||
2238 | 108 | line2bank[line.id] = line.partner_id.bank_ids[0].id | ||
2239 | 109 | else: | ||
2240 | 110 | raise osv.except_osv(_('Error !'), _('No partner defined on entry line')) | ||
2241 | 111 | return line2bank | ||
2242 | 112 | 42 | ||
2243 | 113 | _columns = { | 43 | _columns = { |
2244 | 114 | 'amount_to_pay': fields.function(amount_to_pay, method=True, | 44 | 'amount_to_pay': fields.function(amount_to_pay, method=True, |
2246 | 115 | type='float', string='Amount to pay', fnct_search=_to_pay_search), | 45 | type='float', string='Amount to pay'), |
2247 | 116 | } | 46 | } |
2248 | 117 | 47 | ||
2249 | 118 | account_move_line() | 48 | account_move_line() |
2250 | 119 | 49 | ||
2251 | === removed file 'bin/addons/account_payment/account_payment.py' | |||
2252 | --- bin/addons/account_payment/account_payment.py 2018-09-18 12:25:20 +0000 | |||
2253 | +++ bin/addons/account_payment/account_payment.py 1970-01-01 00:00:00 +0000 | |||
2254 | @@ -1,429 +0,0 @@ | |||
2255 | 1 | # -*- coding: utf-8 -*- | ||
2256 | 2 | ############################################################################## | ||
2257 | 3 | # | ||
2258 | 4 | # OpenERP, Open Source Management Solution | ||
2259 | 5 | # Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>). | ||
2260 | 6 | # | ||
2261 | 7 | # This program is free software: you can redistribute it and/or modify | ||
2262 | 8 | # it under the terms of the GNU Affero General Public License as | ||
2263 | 9 | # published by the Free Software Foundation, either version 3 of the | ||
2264 | 10 | # License, or (at your option) any later version. | ||
2265 | 11 | # | ||
2266 | 12 | # This program is distributed in the hope that it will be useful, | ||
2267 | 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
2268 | 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
2269 | 15 | # GNU Affero General Public License for more details. | ||
2270 | 16 | # | ||
2271 | 17 | # You should have received a copy of the GNU Affero General Public License | ||
2272 | 18 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
2273 | 19 | # | ||
2274 | 20 | ############################################################################## | ||
2275 | 21 | |||
2276 | 22 | import time | ||
2277 | 23 | |||
2278 | 24 | from osv import osv, fields | ||
2279 | 25 | import netsvc | ||
2280 | 26 | |||
2281 | 27 | class payment_mode(osv.osv): | ||
2282 | 28 | _name= 'payment.mode' | ||
2283 | 29 | _description= 'Payment Mode' | ||
2284 | 30 | _columns = { | ||
2285 | 31 | 'name': fields.char('Name', size=64, required=True, help='Mode of Payment'), | ||
2286 | 32 | 'bank_id': fields.many2one('res.partner.bank', "Bank account", | ||
2287 | 33 | required=True,help='Bank Account for the Payment Mode'), | ||
2288 | 34 | 'journal': fields.many2one('account.journal', 'Journal', required=True, | ||
2289 | 35 | domain=[('type', 'in', ('bank','cash'))], help='Bank or Cash Journal for the Payment Mode'), | ||
2290 | 36 | 'company_id': fields.many2one('res.company', 'Company', required=True), | ||
2291 | 37 | } | ||
2292 | 38 | _defaults = { | ||
2293 | 39 | 'company_id': lambda self,cr,uid,c: self.pool.get('res.users').browse(cr, uid, uid, c).company_id.id | ||
2294 | 40 | } | ||
2295 | 41 | |||
2296 | 42 | def suitable_bank_types(self, cr, uid, payment_code=None, context=None): | ||
2297 | 43 | """Return the codes of the bank type that are suitable | ||
2298 | 44 | for the given payment type code""" | ||
2299 | 45 | if not payment_code: | ||
2300 | 46 | return [] | ||
2301 | 47 | cr.execute(""" SELECT pb.state | ||
2302 | 48 | FROM res_partner_bank pb | ||
2303 | 49 | JOIN payment_mode pm ON (pm.bank_id = pb.id) | ||
2304 | 50 | WHERE pm.id = %s """, [payment_code]) | ||
2305 | 51 | return [x[0] for x in cr.fetchall()] | ||
2306 | 52 | |||
2307 | 53 | payment_mode() | ||
2308 | 54 | |||
2309 | 55 | class payment_order(osv.osv): | ||
2310 | 56 | _name = 'payment.order' | ||
2311 | 57 | _description = 'Payment Order' | ||
2312 | 58 | _rec_name = 'reference' | ||
2313 | 59 | |||
2314 | 60 | def get_wizard(self, type): | ||
2315 | 61 | logger = netsvc.Logger() | ||
2316 | 62 | logger.notifyChannel("warning", netsvc.LOG_WARNING, | ||
2317 | 63 | "No wizard found for the payment type '%s'." % type) | ||
2318 | 64 | return None | ||
2319 | 65 | |||
2320 | 66 | def _total(self, cursor, user, ids, name, args, context=None): | ||
2321 | 67 | if not ids: | ||
2322 | 68 | return {} | ||
2323 | 69 | res = {} | ||
2324 | 70 | for order in self.browse(cursor, user, ids, context=context): | ||
2325 | 71 | if order.line_ids: | ||
2326 | 72 | res[order.id] = reduce(lambda x, y: x + y.amount, order.line_ids, 0.0) | ||
2327 | 73 | else: | ||
2328 | 74 | res[order.id] = 0.0 | ||
2329 | 75 | return res | ||
2330 | 76 | |||
2331 | 77 | _columns = { | ||
2332 | 78 | 'date_scheduled': fields.date('Scheduled date if fixed', states={'done':[('readonly', True)]}, help='Select a date if you have chosen Preferred Date to be fixed.'), | ||
2333 | 79 | 'reference': fields.char('Reference', size=128, required=1, states={'done': [('readonly', True)]}), | ||
2334 | 80 | 'mode': fields.many2one('payment.mode', 'Payment mode', select=True, required=1, states={'done': [('readonly', True)]}, help='Select the Payment Mode to be applied.'), | ||
2335 | 81 | 'state': fields.selection([ | ||
2336 | 82 | ('draft', 'Draft'), | ||
2337 | 83 | ('open', 'Confirmed'), | ||
2338 | 84 | ('cancel', 'Cancelled'), | ||
2339 | 85 | ('done', 'Done')], 'State', select=True, | ||
2340 | 86 | help='When an order is placed the state is \'Draft\'.\n Once the bank is confirmed the state is set to \'Confirmed\'.\n Then the order is paid the state is \'Done\'.'), | ||
2341 | 87 | 'line_ids': fields.one2many('payment.line', 'order_id', 'Payment lines', states={'done': [('readonly', True)]}), | ||
2342 | 88 | 'total': fields.function(_total, string="Total", method=True, type='float'), | ||
2343 | 89 | 'user_id': fields.many2one('res.users', 'User', required=True, states={'done': [('readonly', True)]}), | ||
2344 | 90 | 'date_prefered': fields.selection([ | ||
2345 | 91 | ('now', 'Directly'), | ||
2346 | 92 | ('due', 'Due date'), | ||
2347 | 93 | ('fixed', 'Fixed date') | ||
2348 | 94 | ], "Preferred date", change_default=True, required=True, states={'done': [('readonly', True)]}, help="Choose an option for the Payment Order:'Fixed' stands for a date specified by you.'Directly' stands for the direct execution.'Due date' stands for the scheduled date of execution."), | ||
2349 | 95 | 'date_created': fields.date('Creation date', readonly=True), | ||
2350 | 96 | 'date_done': fields.date('Execution date', readonly=True), | ||
2351 | 97 | } | ||
2352 | 98 | |||
2353 | 99 | _defaults = { | ||
2354 | 100 | 'user_id': lambda self,cr,uid,context: uid, | ||
2355 | 101 | 'state': 'draft', | ||
2356 | 102 | 'date_prefered': 'due', | ||
2357 | 103 | 'date_created': lambda *a: time.strftime('%Y-%m-%d'), | ||
2358 | 104 | 'reference': lambda self,cr,uid,context: self.pool.get('ir.sequence').get(cr, uid, 'payment.order'), | ||
2359 | 105 | } | ||
2360 | 106 | |||
2361 | 107 | def set_to_draft(self, cr, uid, ids, *args): | ||
2362 | 108 | self.write(cr, uid, ids, {'state': 'draft'}) | ||
2363 | 109 | wf_service = netsvc.LocalService("workflow") | ||
2364 | 110 | for id in ids: | ||
2365 | 111 | wf_service.trg_create(uid, 'payment.order', id, cr) | ||
2366 | 112 | return True | ||
2367 | 113 | |||
2368 | 114 | def action_open(self, cr, uid, ids, *args): | ||
2369 | 115 | ir_seq_obj = self.pool.get('ir.sequence') | ||
2370 | 116 | |||
2371 | 117 | for order in self.read(cr, uid, ids, ['reference']): | ||
2372 | 118 | if not order['reference']: | ||
2373 | 119 | reference = ir_seq_obj.get(cr, uid, 'payment.order') | ||
2374 | 120 | self.write(cr, uid, order['id'], {'reference':reference}) | ||
2375 | 121 | return True | ||
2376 | 122 | |||
2377 | 123 | def set_done(self, cr, uid, ids, *args): | ||
2378 | 124 | wf_service = netsvc.LocalService("workflow") | ||
2379 | 125 | self.write(cr, uid, ids, {'date_done': time.strftime('%Y-%m-%d')}) | ||
2380 | 126 | wf_service.trg_validate(uid, 'payment.order', ids[0], 'done', cr) | ||
2381 | 127 | return True | ||
2382 | 128 | |||
2383 | 129 | def copy(self, cr, uid, id, default={}, context=None): | ||
2384 | 130 | default.update({ | ||
2385 | 131 | 'state': 'draft', | ||
2386 | 132 | 'line_ids': [], | ||
2387 | 133 | 'reference': self.pool.get('ir.sequence').get(cr, uid, 'payment.order') | ||
2388 | 134 | }) | ||
2389 | 135 | return super(payment_order, self).copy(cr, uid, id, default, context=context) | ||
2390 | 136 | |||
2391 | 137 | def write(self, cr, uid, ids, vals, context=None): | ||
2392 | 138 | if not ids: | ||
2393 | 139 | return True | ||
2394 | 140 | if context is None: | ||
2395 | 141 | context = {} | ||
2396 | 142 | payment_line_obj = self.pool.get('payment.line') | ||
2397 | 143 | payment_line_ids = [] | ||
2398 | 144 | |||
2399 | 145 | if (vals.get('date_prefered', False) == 'fixed' and not vals.get('date_scheduled', False)) or vals.get('date_scheduled', False): | ||
2400 | 146 | for order in self.browse(cr, uid, ids, context=context): | ||
2401 | 147 | for line in order.line_ids: | ||
2402 | 148 | payment_line_ids.append(line.id) | ||
2403 | 149 | payment_line_obj.write(cr, uid, payment_line_ids, {'date': vals.get('date_scheduled', False)}, context=context) | ||
2404 | 150 | elif vals.get('date_prefered', False) == 'due': | ||
2405 | 151 | vals.update({'date_scheduled': False}) | ||
2406 | 152 | for order in self.browse(cr, uid, ids, context=context): | ||
2407 | 153 | for line in order.line_ids: | ||
2408 | 154 | payment_line_obj.write(cr, uid, [line.id], {'date': line.ml_maturity_date}, context=context) | ||
2409 | 155 | elif vals.get('date_prefered', False) == 'now': | ||
2410 | 156 | vals.update({'date_scheduled': False}) | ||
2411 | 157 | for order in self.browse(cr, uid, ids, context=context): | ||
2412 | 158 | for line in order.line_ids: | ||
2413 | 159 | payment_line_ids.append(line.id) | ||
2414 | 160 | payment_line_obj.write(cr, uid, payment_line_ids, {'date': False}, context=context) | ||
2415 | 161 | return super(payment_order, self).write(cr, uid, ids, vals, context=context) | ||
2416 | 162 | |||
2417 | 163 | payment_order() | ||
2418 | 164 | |||
2419 | 165 | class payment_line(osv.osv): | ||
2420 | 166 | _name = 'payment.line' | ||
2421 | 167 | _description = 'Payment Line' | ||
2422 | 168 | |||
2423 | 169 | def translate(self, orig): | ||
2424 | 170 | return { | ||
2425 | 171 | "due_date": "date_maturity", | ||
2426 | 172 | "reference": "ref"}.get(orig, orig) | ||
2427 | 173 | |||
2428 | 174 | def info_owner(self, cr, uid, ids, name=None, args=None, context=None): | ||
2429 | 175 | if not ids: return {} | ||
2430 | 176 | partner_zip_obj = self.pool.get('res.partner.zip') | ||
2431 | 177 | |||
2432 | 178 | result = {} | ||
2433 | 179 | info='' | ||
2434 | 180 | for line in self.browse(cr, uid, ids, context=context): | ||
2435 | 181 | owner = line.order_id.mode.bank_id.partner_id | ||
2436 | 182 | result[line.id] = False | ||
2437 | 183 | if owner.address: | ||
2438 | 184 | for ads in owner.address: | ||
2439 | 185 | if ads.type == 'default': | ||
2440 | 186 | st = ads.street and ads.street or '' | ||
2441 | 187 | st1 = ads.street2 and ads.street2 or '' | ||
2442 | 188 | if 'zip_id' in ads: | ||
2443 | 189 | zip_city = ads.zip_id and partner_zip_obj.name_get(cr, uid, [ads.zip_id.id])[0][1] or '' | ||
2444 | 190 | else: | ||
2445 | 191 | zip = ads.zip and ads.zip or '' | ||
2446 | 192 | city = ads.city and ads.city or '' | ||
2447 | 193 | zip_city = zip + ' ' + city | ||
2448 | 194 | cntry = ads.country_id and ads.country_id.name or '' | ||
2449 | 195 | info = owner.name + "\n" + st + " " + st1 + "\n" + zip_city + "\n" +cntry | ||
2450 | 196 | result[line.id] = info | ||
2451 | 197 | break | ||
2452 | 198 | return result | ||
2453 | 199 | |||
2454 | 200 | def info_partner(self, cr, uid, ids, name=None, args=None, context=None): | ||
2455 | 201 | if not ids: return {} | ||
2456 | 202 | partner_zip_obj = self.pool.get('res.partner.zip') | ||
2457 | 203 | result = {} | ||
2458 | 204 | info = '' | ||
2459 | 205 | |||
2460 | 206 | for line in self.browse(cr, uid, ids, context=context): | ||
2461 | 207 | result[line.id] = False | ||
2462 | 208 | if not line.partner_id: | ||
2463 | 209 | break | ||
2464 | 210 | partner = line.partner_id.name or '' | ||
2465 | 211 | if line.partner_id.address: | ||
2466 | 212 | for ads in line.partner_id.address: | ||
2467 | 213 | if ads.type == 'default': | ||
2468 | 214 | st = ads.street and ads.street or '' | ||
2469 | 215 | st1 = ads.street2 and ads.street2 or '' | ||
2470 | 216 | if 'zip_id' in ads: | ||
2471 | 217 | zip_city = ads.zip_id and partner_zip_obj.name_get(cr, uid, [ads.zip_id.id])[0][1] or '' | ||
2472 | 218 | else: | ||
2473 | 219 | zip = ads.zip and ads.zip or '' | ||
2474 | 220 | city = ads.city and ads.city or '' | ||
2475 | 221 | zip_city = zip + ' ' + city | ||
2476 | 222 | cntry = ads.country_id and ads.country_id.name or '' | ||
2477 | 223 | info = partner + "\n" + st + " " + st1 + "\n" + zip_city + "\n" +cntry | ||
2478 | 224 | result[line.id] = info | ||
2479 | 225 | break | ||
2480 | 226 | return result | ||
2481 | 227 | |||
2482 | 228 | def _amount(self, cursor, user, ids, name, args, context=None): | ||
2483 | 229 | if not ids: | ||
2484 | 230 | return {} | ||
2485 | 231 | currency_obj = self.pool.get('res.currency') | ||
2486 | 232 | if context is None: | ||
2487 | 233 | context = {} | ||
2488 | 234 | res = {} | ||
2489 | 235 | |||
2490 | 236 | for line in self.browse(cursor, user, ids, context=context): | ||
2491 | 237 | ctx = context.copy() | ||
2492 | 238 | ctx['date'] = line.order_id.date_done or time.strftime('%Y-%m-%d') | ||
2493 | 239 | res[line.id] = currency_obj.compute(cursor, user, line.currency.id, | ||
2494 | 240 | line.company_currency.id, | ||
2495 | 241 | line.amount_currency, context=ctx) | ||
2496 | 242 | return res | ||
2497 | 243 | |||
2498 | 244 | def _get_currency(self, cr, uid, context=None): | ||
2499 | 245 | user_obj = self.pool.get('res.users') | ||
2500 | 246 | currency_obj = self.pool.get('res.currency') | ||
2501 | 247 | user = user_obj.browse(cr, uid, uid, context=context) | ||
2502 | 248 | |||
2503 | 249 | if user.company_id: | ||
2504 | 250 | return user.company_id.currency_id.id | ||
2505 | 251 | else: | ||
2506 | 252 | return currency_obj.search(cr, uid, [('rate', '=', 1.0)])[0] | ||
2507 | 253 | |||
2508 | 254 | def _get_date(self, cr, uid, context=None): | ||
2509 | 255 | if context is None: | ||
2510 | 256 | context = {} | ||
2511 | 257 | payment_order_obj = self.pool.get('payment.order') | ||
2512 | 258 | date = False | ||
2513 | 259 | |||
2514 | 260 | if context.get('order_id') and context['order_id']: | ||
2515 | 261 | order = payment_order_obj.browse(cr, uid, context['order_id'], context=context) | ||
2516 | 262 | if order.date_prefered == 'fixed': | ||
2517 | 263 | date = order.date_scheduled | ||
2518 | 264 | else: | ||
2519 | 265 | date = time.strftime('%Y-%m-%d') | ||
2520 | 266 | return date | ||
2521 | 267 | |||
2522 | 268 | def _get_ml_inv_ref(self, cr, uid, ids, *a): | ||
2523 | 269 | res = {} | ||
2524 | 270 | for id in self.browse(cr, uid, ids): | ||
2525 | 271 | res[id.id] = False | ||
2526 | 272 | if id.move_line_id: | ||
2527 | 273 | if id.move_line_id.invoice: | ||
2528 | 274 | res[id.id] = id.move_line_id.invoice.id | ||
2529 | 275 | return res | ||
2530 | 276 | |||
2531 | 277 | def _get_ml_maturity_date(self, cr, uid, ids, *a): | ||
2532 | 278 | res = {} | ||
2533 | 279 | for id in self.browse(cr, uid, ids): | ||
2534 | 280 | if id.move_line_id: | ||
2535 | 281 | res[id.id] = id.move_line_id.date_maturity | ||
2536 | 282 | else: | ||
2537 | 283 | res[id.id] = False | ||
2538 | 284 | return res | ||
2539 | 285 | |||
2540 | 286 | def _get_ml_created_date(self, cr, uid, ids, *a): | ||
2541 | 287 | res = {} | ||
2542 | 288 | for id in self.browse(cr, uid, ids): | ||
2543 | 289 | if id.move_line_id: | ||
2544 | 290 | res[id.id] = id.move_line_id.date_created | ||
2545 | 291 | else: | ||
2546 | 292 | res[id.id] = False | ||
2547 | 293 | return res | ||
2548 | 294 | |||
2549 | 295 | _columns = { | ||
2550 | 296 | 'name': fields.char('Your Reference', size=64, required=True), | ||
2551 | 297 | 'communication': fields.char('Communication', size=64, required=True, help="Used as the message between ordering customer and current company. Depicts 'What do you want to say to the recipient about this order ?'"), | ||
2552 | 298 | 'communication2': fields.char('Communication 2', size=64, help='The successor message of Communication.'), | ||
2553 | 299 | 'move_line_id': fields.many2one('account.move.line', 'Entry line', domain=[('reconcile_id', '=', False), ('account_id.type', '=', 'payable')], help='This Entry Line will be referred for the information of the ordering customer.'), | ||
2554 | 300 | 'amount_currency': fields.float('Amount in Partner Currency', digits=(16, 2), | ||
2555 | 301 | required=True, help='Payment amount in the partner currency'), | ||
2556 | 302 | 'currency': fields.many2one('res.currency','Partner Currency', required=True), | ||
2557 | 303 | 'company_currency': fields.many2one('res.currency', 'Company Currency', readonly=True), | ||
2558 | 304 | 'bank_id': fields.many2one('res.partner.bank', 'Destination Bank account'), | ||
2559 | 305 | 'order_id': fields.many2one('payment.order', 'Order', required=True, | ||
2560 | 306 | ondelete='cascade', select=True), | ||
2561 | 307 | 'partner_id': fields.many2one('res.partner', string="Partner", required=True, help='The Ordering Customer'), | ||
2562 | 308 | 'amount': fields.function(_amount, string='Amount in Company Currency', | ||
2563 | 309 | method=True, type='float', | ||
2564 | 310 | help='Payment amount in the company currency'), | ||
2565 | 311 | 'ml_date_created': fields.function(_get_ml_created_date, string="Effective Date", | ||
2566 | 312 | method=True, type='date', help="Invoice Effective Date"), | ||
2567 | 313 | 'ml_maturity_date': fields.function(_get_ml_maturity_date, method=True, type='date', string='Due Date'), | ||
2568 | 314 | 'ml_inv_ref': fields.function(_get_ml_inv_ref, method=True, type='many2one', relation='account.invoice', string='Invoice Ref.'), | ||
2569 | 315 | 'info_owner': fields.function(info_owner, string="Owner Account", method=True, type="text", help='Address of the Main Partner'), | ||
2570 | 316 | 'info_partner': fields.function(info_partner, string="Destination Account", method=True, type="text", help='Address of the Ordering Customer.'), | ||
2571 | 317 | 'date': fields.date('Payment Date', help="If no payment date is specified, the bank will treat this payment line directly"), | ||
2572 | 318 | 'create_date': fields.datetime('Created', readonly=True), | ||
2573 | 319 | 'state': fields.selection([('normal','Free'), ('structured','Structured')], 'Communication Type', required=True), | ||
2574 | 320 | 'bank_statement_line_id': fields.many2one('account.bank.statement.line', 'Bank statement line') | ||
2575 | 321 | } | ||
2576 | 322 | _defaults = { | ||
2577 | 323 | 'name': lambda obj, cursor, user, context: obj.pool.get('ir.sequence' | ||
2578 | 324 | ).get(cursor, user, 'payment.line'), | ||
2579 | 325 | 'state': 'normal', | ||
2580 | 326 | 'currency': _get_currency, | ||
2581 | 327 | 'company_currency': _get_currency, | ||
2582 | 328 | 'date': _get_date, | ||
2583 | 329 | } | ||
2584 | 330 | _sql_constraints = [ | ||
2585 | 331 | ('name_uniq', 'UNIQUE(name)', 'The payment line name must be unique!'), | ||
2586 | 332 | ] | ||
2587 | 333 | |||
2588 | 334 | def onchange_move_line(self, cr, uid, ids, move_line_id, payment_type, date_prefered, date_scheduled, currency=False, company_currency=False, context=None): | ||
2589 | 335 | data = {} | ||
2590 | 336 | move_line_obj = self.pool.get('account.move.line') | ||
2591 | 337 | |||
2592 | 338 | data['amount_currency'] = data['communication'] = data['partner_id'] = data['reference'] = data['date_created'] = data['bank_id'] = data['amount'] = False | ||
2593 | 339 | |||
2594 | 340 | if move_line_id: | ||
2595 | 341 | line = move_line_obj.browse(cr, uid, move_line_id, context=context) | ||
2596 | 342 | data['amount_currency'] = line.amount_to_pay | ||
2597 | 343 | |||
2598 | 344 | res = self.onchange_amount(cr, uid, ids, data['amount_currency'], currency, | ||
2599 | 345 | company_currency, context) | ||
2600 | 346 | if res: | ||
2601 | 347 | data['amount'] = res['value']['amount'] | ||
2602 | 348 | data['partner_id'] = line.partner_id.id | ||
2603 | 349 | temp = line.currency_id and line.currency_id.id or False | ||
2604 | 350 | if not temp: | ||
2605 | 351 | if line.invoice: | ||
2606 | 352 | data['currency'] = line.invoice.currency_id.id | ||
2607 | 353 | else: | ||
2608 | 354 | data['currency'] = temp | ||
2609 | 355 | |||
2610 | 356 | # calling onchange of partner and updating data dictionary | ||
2611 | 357 | temp_dict = self.onchange_partner(cr, uid, ids, line.partner_id.id, payment_type) | ||
2612 | 358 | data.update(temp_dict['value']) | ||
2613 | 359 | |||
2614 | 360 | data['reference'] = line.ref | ||
2615 | 361 | data['date_created'] = line.date_created | ||
2616 | 362 | data['communication'] = line.ref | ||
2617 | 363 | |||
2618 | 364 | if date_prefered == 'now': | ||
2619 | 365 | #no payment date => immediate payment | ||
2620 | 366 | data['date'] = False | ||
2621 | 367 | elif date_prefered == 'due': | ||
2622 | 368 | data['date'] = line.date_maturity | ||
2623 | 369 | elif date_prefered == 'fixed': | ||
2624 | 370 | data['date'] = date_scheduled | ||
2625 | 371 | return {'value': data} | ||
2626 | 372 | |||
2627 | 373 | def onchange_amount(self, cr, uid, ids, amount, currency, cmpny_currency, context=None): | ||
2628 | 374 | if (not amount) or (not cmpny_currency): | ||
2629 | 375 | return {'value': {'amount': False}} | ||
2630 | 376 | res = {} | ||
2631 | 377 | currency_obj = self.pool.get('res.currency') | ||
2632 | 378 | company_amount = currency_obj.compute(cr, uid, currency, cmpny_currency, amount) | ||
2633 | 379 | res['amount'] = company_amount | ||
2634 | 380 | return {'value': res} | ||
2635 | 381 | |||
2636 | 382 | def onchange_partner(self, cr, uid, ids, partner_id, payment_type, context=None): | ||
2637 | 383 | data = {} | ||
2638 | 384 | partner_zip_obj = self.pool.get('res.partner.zip') | ||
2639 | 385 | partner_obj = self.pool.get('res.partner') | ||
2640 | 386 | payment_mode_obj = self.pool.get('payment.mode') | ||
2641 | 387 | data['info_partner'] = data['bank_id'] = False | ||
2642 | 388 | |||
2643 | 389 | if partner_id: | ||
2644 | 390 | part_obj = partner_obj.browse(cr, uid, partner_id, context=context) | ||
2645 | 391 | partner = part_obj.name or '' | ||
2646 | 392 | |||
2647 | 393 | if part_obj.address: | ||
2648 | 394 | for ads in part_obj.address: | ||
2649 | 395 | if ads.type == 'default': | ||
2650 | 396 | st = ads.street and ads.street or '' | ||
2651 | 397 | st1 = ads.street2 and ads.street2 or '' | ||
2652 | 398 | |||
2653 | 399 | if 'zip_id' in ads: | ||
2654 | 400 | zip_city = ads.zip_id and partner_zip_obj.name_get(cr, uid, [ads.zip_id.id])[0][1] or '' | ||
2655 | 401 | else: | ||
2656 | 402 | zip = ads.zip and ads.zip or '' | ||
2657 | 403 | city = ads.city and ads.city or '' | ||
2658 | 404 | zip_city = zip + ' ' + city | ||
2659 | 405 | |||
2660 | 406 | cntry = ads.country_id and ads.country_id.name or '' | ||
2661 | 407 | info = partner + "\n" + st + " " + st1 + "\n" + zip_city + "\n" +cntry | ||
2662 | 408 | |||
2663 | 409 | data['info_partner'] = info | ||
2664 | 410 | |||
2665 | 411 | if part_obj.bank_ids and payment_type: | ||
2666 | 412 | bank_type = payment_mode_obj.suitable_bank_types(cr, uid, payment_type, context=context) | ||
2667 | 413 | for bank in part_obj.bank_ids: | ||
2668 | 414 | if bank.state in bank_type: | ||
2669 | 415 | data['bank_id'] = bank.id | ||
2670 | 416 | break | ||
2671 | 417 | return {'value': data} | ||
2672 | 418 | |||
2673 | 419 | def fields_get(self, cr, uid, fields=None, context=None, with_uom_rounding=False): | ||
2674 | 420 | res = super(payment_line, self).fields_get(cr, uid, fields, context) | ||
2675 | 421 | if 'communication2' in res: | ||
2676 | 422 | res['communication2'].setdefault('states', {}) | ||
2677 | 423 | res['communication2']['states']['structured'] = [('readonly', True)] | ||
2678 | 424 | res['communication2']['states']['normal'] = [('readonly', False)] | ||
2679 | 425 | return res | ||
2680 | 426 | |||
2681 | 427 | payment_line() | ||
2682 | 428 | |||
2683 | 429 | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: | ||
2684 | 430 | 0 | ||
2685 | === removed file 'bin/addons/account_payment/account_payment_demo.xml' | |||
2686 | --- bin/addons/account_payment/account_payment_demo.xml 2011-01-14 00:11:01 +0000 | |||
2687 | +++ bin/addons/account_payment/account_payment_demo.xml 1970-01-01 00:00:00 +0000 | |||
2688 | @@ -1,25 +0,0 @@ | |||
2689 | 1 | <?xml version="1.0" encoding="utf-8"?> | ||
2690 | 2 | <openerp> | ||
2691 | 3 | <data noupdate="1"> | ||
2692 | 4 | <record id="partner_bank_1" model="res.partner.bank"> | ||
2693 | 5 | <field name="name">Reserve Bank</field> | ||
2694 | 6 | <field name="acc_number">00987654321</field> | ||
2695 | 7 | <field name="partner_id" ref="base.res_partner_agrolait"></field> | ||
2696 | 8 | <field name="state">bank</field> | ||
2697 | 9 | <field name="bank" ref="base.res_bank_1"/> | ||
2698 | 10 | </record> | ||
2699 | 11 | <record id="payment_mode_1" model="payment.mode"> | ||
2700 | 12 | <field name="name">Direct Payment</field> | ||
2701 | 13 | <field name="journal" ref="account.sales_journal"/> | ||
2702 | 14 | <field name="bank_id" ref="account_payment.partner_bank_1"/> | ||
2703 | 15 | <field name="company_id" ref="base.main_company"/> | ||
2704 | 16 | </record> | ||
2705 | 17 | <record id="payment_order_1" model="payment.order"> | ||
2706 | 18 | <field name="reference">ORDER1</field> | ||
2707 | 19 | <field name="mode" ref="account_payment.payment_mode_1"/> | ||
2708 | 20 | <field name="user_id" ref="base.user_root"/> | ||
2709 | 21 | <field name="date_prefered">now</field> | ||
2710 | 22 | <field name="state">draft</field> | ||
2711 | 23 | </record> | ||
2712 | 24 | </data> | ||
2713 | 25 | </openerp> | ||
2714 | 26 | 0 | ||
2715 | === removed file 'bin/addons/account_payment/account_payment_report.xml' | |||
2716 | --- bin/addons/account_payment/account_payment_report.xml 2011-01-14 00:11:01 +0000 | |||
2717 | +++ bin/addons/account_payment/account_payment_report.xml 1970-01-01 00:00:00 +0000 | |||
2718 | @@ -1,6 +0,0 @@ | |||
2719 | 1 | <?xml version="1.0" encoding="utf-8"?> | ||
2720 | 2 | <openerp> | ||
2721 | 3 | <data> | ||
2722 | 4 | <report auto="True" id="payment_order1" model="payment.order" name="payment.order" rml="account_payment/report/order.rml" string="Payment Order"/> | ||
2723 | 5 | </data> | ||
2724 | 6 | </openerp> | ||
2725 | 7 | 0 | ||
2726 | === removed file 'bin/addons/account_payment/account_payment_sequence.xml' | |||
2727 | --- bin/addons/account_payment/account_payment_sequence.xml 2011-01-14 00:11:01 +0000 | |||
2728 | +++ bin/addons/account_payment/account_payment_sequence.xml 1970-01-01 00:00:00 +0000 | |||
2729 | @@ -1,29 +0,0 @@ | |||
2730 | 1 | <?xml version="1.0" encoding="utf-8"?> | ||
2731 | 2 | <openerp> | ||
2732 | 3 | <data noupdate="1"> | ||
2733 | 4 | <record forcecreate="1" id="seq_type_payment_order" model="ir.sequence.type"> | ||
2734 | 5 | <field name="name">Payment order</field> | ||
2735 | 6 | <field name="code">payment.order</field> | ||
2736 | 7 | </record> | ||
2737 | 8 | |||
2738 | 9 | <record forcecreate="1" id="seq_payment_order" model="ir.sequence"> | ||
2739 | 10 | <field name="name">Payment order</field> | ||
2740 | 11 | <field name="code">payment.order</field> | ||
2741 | 12 | <field eval="3" name="padding"/> | ||
2742 | 13 | <field name="prefix">%(year)s/</field> | ||
2743 | 14 | </record> | ||
2744 | 15 | |||
2745 | 16 | <record forcecreate="1" id="seq_type_payment_line" model="ir.sequence.type"> | ||
2746 | 17 | <field name="name">Payment Line</field> | ||
2747 | 18 | <field name="code">payment.line</field> | ||
2748 | 19 | </record> | ||
2749 | 20 | |||
2750 | 21 | <record forcecreate="1" id="seq_payment_line" model="ir.sequence"> | ||
2751 | 22 | <field name="name">Payment Line</field> | ||
2752 | 23 | <field name="code">payment.line</field> | ||
2753 | 24 | <field name="prefix"/> | ||
2754 | 25 | <field name="padding">3</field> | ||
2755 | 26 | </record> | ||
2756 | 27 | |||
2757 | 28 | </data> | ||
2758 | 29 | </openerp> | ||
2759 | 30 | 0 | ||
2760 | === modified file 'bin/addons/account_payment/account_payment_view.xml' | |||
2761 | --- bin/addons/account_payment/account_payment_view.xml 2017-10-04 05:23:42 +0000 | |||
2762 | +++ bin/addons/account_payment/account_payment_view.xml 2019-10-30 13:23:20 +0000 | |||
2763 | @@ -15,308 +15,5 @@ | |||
2764 | 15 | </field> | 15 | </field> |
2765 | 16 | </record> | 16 | </record> |
2766 | 17 | 17 | ||
2767 | 18 | <record model="ir.ui.view" id="view_move_line_tree_wiz"> | ||
2768 | 19 | <field name="name">account.move.line.tree</field> | ||
2769 | 20 | <field name="model">account.move.line</field> | ||
2770 | 21 | <field name="type">tree</field> | ||
2771 | 22 | <field name="priority" eval="10"/> | ||
2772 | 23 | <field name="arch" type="xml"> | ||
2773 | 24 | <tree string="Account Entry Line"> | ||
2774 | 25 | <field name="partner_id"/> | ||
2775 | 26 | <field name="ref"/> | ||
2776 | 27 | <field name="name"/> | ||
2777 | 28 | <field name="journal_id"/> | ||
2778 | 29 | <field name="account_id"/> | ||
2779 | 30 | <field name="date_maturity"/> | ||
2780 | 31 | <field name="date"/> | ||
2781 | 32 | <field name="debit" sum="Total debit"/> | ||
2782 | 33 | <field name="credit" sum="Total credit"/> | ||
2783 | 34 | <field name="amount_to_pay"/> | ||
2784 | 35 | <field name="amount_currency"/> | ||
2785 | 36 | <field name="currency_id"/> | ||
2786 | 37 | <field name="period_id" invisible="1"/> | ||
2787 | 38 | </tree> | ||
2788 | 39 | </field> | ||
2789 | 40 | </record> | ||
2790 | 41 | |||
2791 | 42 | <menuitem id="menu_main_payment" name="Payment" parent="account.menu_finance" sequence="7"/> | ||
2792 | 43 | |||
2793 | 44 | <record id="view_payment_mode_search" model="ir.ui.view"> | ||
2794 | 45 | <field name="name">payment.mode.search</field> | ||
2795 | 46 | <field name="model">payment.mode</field> | ||
2796 | 47 | <field name="type">search</field> | ||
2797 | 48 | <field name="arch" type="xml"> | ||
2798 | 49 | <form string="Payment Mode"> | ||
2799 | 50 | <field name="name"/> | ||
2800 | 51 | <field name="journal" widget='selection'/> | ||
2801 | 52 | <field name="company_id" widget='selection' groups="base.group_multi_company"/> | ||
2802 | 53 | <newline/> | ||
2803 | 54 | <group expand="0" string="Group By..."> | ||
2804 | 55 | <filter string="Journal" icon="terp-folder-orange" domain="[]" context="{'group_by':'journal'}"/> | ||
2805 | 56 | </group> | ||
2806 | 57 | </form> | ||
2807 | 58 | </field> | ||
2808 | 59 | </record> | ||
2809 | 60 | |||
2810 | 61 | <record id="view_payment_mode_tree" model="ir.ui.view"> | ||
2811 | 62 | <field name="name">payment.mode.tree</field> | ||
2812 | 63 | <field name="model">payment.mode</field> | ||
2813 | 64 | <field name="type">tree</field> | ||
2814 | 65 | <field name="arch" type="xml"> | ||
2815 | 66 | <tree string="Payment Mode"> | ||
2816 | 67 | <field name="name"/> | ||
2817 | 68 | <field name="journal"/> | ||
2818 | 69 | <field name="company_id" groups="base.group_multi_company"/> | ||
2819 | 70 | </tree> | ||
2820 | 71 | </field> | ||
2821 | 72 | </record> | ||
2822 | 73 | |||
2823 | 74 | <record id="view_payment_mode_form" model="ir.ui.view"> | ||
2824 | 75 | <field name="name">payment.mode.form</field> | ||
2825 | 76 | <field name="model">payment.mode</field> | ||
2826 | 77 | <field name="type">form</field> | ||
2827 | 78 | <field name="arch" type="xml"> | ||
2828 | 79 | <form string="Payment Mode"> | ||
2829 | 80 | <field name="name" select="1"/> | ||
2830 | 81 | <field name="journal" select="1"/> | ||
2831 | 82 | <field name="bank_id"/> | ||
2832 | 83 | <field name="company_id" select="1" widget='selection' groups="base.group_multi_company"/> | ||
2833 | 84 | </form> | ||
2834 | 85 | </field> | ||
2835 | 86 | </record> | ||
2836 | 87 | <record id="action_payment_mode_form" model="ir.actions.act_window"> | ||
2837 | 88 | <field name="name">Payment Mode</field> | ||
2838 | 89 | <field name="res_model">payment.mode</field> | ||
2839 | 90 | <field name="view_type">form</field> | ||
2840 | 91 | <field name="view_mode">tree,form</field> | ||
2841 | 92 | <field name="search_view_id" ref="view_payment_mode_search"/> | ||
2842 | 93 | </record> | ||
2843 | 94 | |||
2844 | 95 | <menuitem action="action_payment_mode_form" id="menu_action_payment_mode_form" parent="account.menu_configuration_misc"/> | ||
2845 | 96 | |||
2846 | 97 | <record id="view_payment_order_form" model="ir.ui.view"> | ||
2847 | 98 | <field name="name">payment.order.form</field> | ||
2848 | 99 | <field name="model">payment.order</field> | ||
2849 | 100 | <field name="type">form</field> | ||
2850 | 101 | <field name="arch" type="xml"> | ||
2851 | 102 | <form string="Payment order"> | ||
2852 | 103 | <group col="6" colspan="4"> | ||
2853 | 104 | <field name="reference"/> | ||
2854 | 105 | <field name="mode" widget='selection'/> | ||
2855 | 106 | <field name="user_id"/> | ||
2856 | 107 | <field name="date_prefered"/> | ||
2857 | 108 | <field name="date_scheduled" select="1" attrs="{'readonly':[('date_prefered','!=','fixed')]}" /> | ||
2858 | 109 | <button colspan="2" name="%(action_create_payment_order)d" string="Select Invoices to Pay" type="action" attrs="{'invisible':[('state','=','done')]}" icon="gtk-find"/> | ||
2859 | 110 | </group> | ||
2860 | 111 | <field name="line_ids" colspan="4" widget="one2many_list" nolabel="1" default_get="{'order_id': active_id or False}" > | ||
2861 | 112 | <form string="Payment Line"> | ||
2862 | 113 | <notebook> | ||
2863 | 114 | <page string="Payment"> | ||
2864 | 115 | <field name="move_line_id" on_change="onchange_move_line(move_line_id,parent.mode,parent.date_prefered,parent.date_scheduled,currency,company_currency)" select="1" domain="[('reconcile_id','=', False), ('credit', '>',0),('amount_to_pay','>',0)] "/> | ||
2865 | 116 | <separator colspan="4" string="Transaction Information"/> | ||
2866 | 117 | <field name="date"/> | ||
2867 | 118 | <group colspan="2"> | ||
2868 | 119 | <field name="amount_currency" on_change="onchange_amount(amount_currency,currency,company_currency)"/> | ||
2869 | 120 | <field name="currency" nolabel="1"/> | ||
2870 | 121 | </group> | ||
2871 | 122 | <field name="partner_id" on_change="onchange_partner(partner_id,parent.mode)" select="1"/> | ||
2872 | 123 | <field domain="[('partner_id','=',partner_id)]" name="bank_id"/> | ||
2873 | 124 | <separator colspan="2" string="Owner Account"/> | ||
2874 | 125 | <separator colspan="2" string="Destination Account"/> | ||
2875 | 126 | <field colspan="2" name="info_owner" nolabel="1"/> | ||
2876 | 127 | <field colspan="2" name="info_partner" nolabel="1"/> | ||
2877 | 128 | <field colspan="4" name="communication"/> | ||
2878 | 129 | <field colspan="4" name="communication2"/> | ||
2879 | 130 | <field name="name"/> | ||
2880 | 131 | <field name="state"/> | ||
2881 | 132 | </page> | ||
2882 | 133 | <page string="Information"> | ||
2883 | 134 | |||
2884 | 135 | <separator colspan="4" string="General Information"/> | ||
2885 | 136 | <group colspan="2"> | ||
2886 | 137 | <field name="amount"/> | ||
2887 | 138 | <field name="company_currency" nolabel="1"/> | ||
2888 | 139 | </group> | ||
2889 | 140 | <separator colspan="4" string="Entry Information"/> | ||
2890 | 141 | <field name="create_date" readonly="1"/> | ||
2891 | 142 | <field name="ml_maturity_date"/> | ||
2892 | 143 | <field name="ml_inv_ref"/> | ||
2893 | 144 | </page> | ||
2894 | 145 | </notebook> | ||
2895 | 146 | </form> | ||
2896 | 147 | <tree string="Payment Line"> | ||
2897 | 148 | <field name="ml_inv_ref" /> | ||
2898 | 149 | <field name="partner_id" select="1"/> | ||
2899 | 150 | <field name="bank_id" domain="[('partner_id', '=', partner_id)]"/> | ||
2900 | 151 | <field name="ml_maturity_date"/> | ||
2901 | 152 | <field name="date"/> | ||
2902 | 153 | <field name="amount_currency" string="Amount"/> | ||
2903 | 154 | <field name="currency"/> | ||
2904 | 155 | <field name="name"/> | ||
2905 | 156 | <field name="amount" sum="Total in Company Currency" invisible="1"/> | ||
2906 | 157 | </tree> | ||
2907 | 158 | </field> | ||
2908 | 159 | <field name="date_created"/> | ||
2909 | 160 | <field name="date_done"/> | ||
2910 | 161 | <field name="state" readonly="1" select="1"/> | ||
2911 | 162 | <group col="4" colspan="2"> | ||
2912 | 163 | <button name="cancel" states="draft,open" string="Cancel" icon="gtk-cancel"/> | ||
2913 | 164 | <button name="open" states="draft" string="Confirm Payments" icon="gtk-apply"/> | ||
2914 | 165 | <button name="set_done" states="open" string="Make Payments" type="object" icon="gtk-execute"/> | ||
2915 | 166 | <button name="set_to_draft" states="cancel" string="Set to draft" type="object" icon="gtk-convert"/> | ||
2916 | 167 | </group> | ||
2917 | 168 | </form> | ||
2918 | 169 | </field> | ||
2919 | 170 | </record> | ||
2920 | 171 | |||
2921 | 172 | <record id="view_payment_order_tree" model="ir.ui.view"> | ||
2922 | 173 | <field name="name">payment.order.tree</field> | ||
2923 | 174 | <field name="model">payment.order</field> | ||
2924 | 175 | <field name="type">tree</field> | ||
2925 | 176 | <field eval="4" name="priority"/> | ||
2926 | 177 | <field name="arch" type="xml"> | ||
2927 | 178 | <tree colors="blue:state in ('draft');gray:state in ('cancel','done');black:state in ('open')" string="Payment order"> | ||
2928 | 179 | <field name="reference"/> | ||
2929 | 180 | <field name="mode"/> | ||
2930 | 181 | <field name="user_id"/> | ||
2931 | 182 | <field name="date_created"/> | ||
2932 | 183 | <field name="date_done"/> | ||
2933 | 184 | <field name="total"/> | ||
2934 | 185 | <field name="state"/> | ||
2935 | 186 | <button name="cancel" states="draft,open" string="Cancel" icon="gtk-cancel"/> | ||
2936 | 187 | <button name="open" states="draft" string="Confirm Payments" icon="gtk-apply"/> | ||
2937 | 188 | <button name="set_done" states="open" string="Make Payments" type ="object" icon="gtk-execute"/> | ||
2938 | 189 | </tree> | ||
2939 | 190 | </field> | ||
2940 | 191 | </record> | ||
2941 | 192 | |||
2942 | 193 | <record id="view_payment_order_search" model="ir.ui.view"> | ||
2943 | 194 | <field name="name">payment.order.tree.search</field> | ||
2944 | 195 | <field name="model">payment.order</field> | ||
2945 | 196 | <field name="type">search</field> | ||
2946 | 197 | <field name="arch" type="xml"> | ||
2947 | 198 | <search string="Search Payment Orders"> | ||
2948 | 199 | <group col="8" colspan="4"> | ||
2949 | 200 | <filter string="Draft" domain="[('state','=','draft')]" icon="terp-document-new"/> | ||
2950 | 201 | <filter string="Confirmed" domain="[('state','=','open')]" icon="terp-camera_test"/> | ||
2951 | 202 | <filter string="Done" domain="[('state','=','done')]" icon="terp-dialog-close"/> | ||
2952 | 203 | <separator orientation="vertical"/> | ||
2953 | 204 | <field name="reference"/> | ||
2954 | 205 | <field name="mode" widget='selection'/> | ||
2955 | 206 | <field name="date_done"/> | ||
2956 | 207 | <field name="state"/> | ||
2957 | 208 | </group> | ||
2958 | 209 | <newline/> | ||
2959 | 210 | <group expand="0" string="Group By..."> | ||
2960 | 211 | <filter string="Payment Mode" context="{'group_by': 'mode'}" icon="terp-dolar"/> | ||
2961 | 212 | <filter string="State" context="{'group_by': 'state'}" icon="terp-stock_effects-object-colorize"/> | ||
2962 | 213 | </group> | ||
2963 | 214 | </search> | ||
2964 | 215 | </field> | ||
2965 | 216 | </record> | ||
2966 | 217 | |||
2967 | 218 | <record id="action_payment_order_tree" model="ir.actions.act_window"> | ||
2968 | 219 | <field name="name">Payment Orders</field> | ||
2969 | 220 | <field name="res_model">payment.order</field> | ||
2970 | 221 | <field name="view_type">form</field> | ||
2971 | 222 | <field name="view_mode">tree,form</field> | ||
2972 | 223 | <field name="search_view_id" ref="view_payment_order_search"/> | ||
2973 | 224 | <field name="help">A payment order is a payment request from your company to pay a supplier invoice or a customer credit note. Here you can register all payment orders that should be done, keep track of all payment orders and mention the invoice reference and the partner the payment should be done for.</field> | ||
2974 | 225 | </record> | ||
2975 | 226 | |||
2976 | 227 | <menuitem action="action_payment_order_tree" id="menu_action_payment_order_form" parent="menu_main_payment" sequence="3"/> | ||
2977 | 228 | |||
2978 | 229 | <record id="action_payment_order_tree_new" model="ir.actions.act_window"> | ||
2979 | 230 | <field name="name">New Payment Order</field> | ||
2980 | 231 | <field name="res_model">payment.order</field> | ||
2981 | 232 | <field name="view_type">form</field> | ||
2982 | 233 | <field name="view_mode">form,tree</field> | ||
2983 | 234 | </record> | ||
2984 | 235 | |||
2985 | 236 | <record id="view_payment_line_form" model="ir.ui.view"> | ||
2986 | 237 | <field name="name">Payment Line</field> | ||
2987 | 238 | <field name="model">payment.line</field> | ||
2988 | 239 | <field name="type">form</field> | ||
2989 | 240 | <field name="arch" type="xml"> | ||
2990 | 241 | <form string="Payment Line"> | ||
2991 | 242 | <notebook> | ||
2992 | 243 | <page string="Payment"> | ||
2993 | 244 | <field name="order_id" select="1"/> | ||
2994 | 245 | <field name="move_line_id" on_change="onchange_move_line(move_line_id, False, currency, company_currency)" select="1" domain="[('reconcile_id','=', False), ('credit', '>',0),('amount_to_pay','>',0)] "/> | ||
2995 | 246 | <separator colspan="4" string="Transaction Information"/> | ||
2996 | 247 | <field name="date"/> | ||
2997 | 248 | <group colspan="2"> | ||
2998 | 249 | <field name="amount_currency" on_change="onchange_amount(amount_currency,currency,comapny_currency)"/> | ||
2999 | 250 | <field name="currency" nolabel="1"/> | ||
3000 | 251 | </group> | ||
3001 | 252 | <field name="partner_id" on_change="onchange_partner(partner_id, False)" select="1"/> | ||
3002 | 253 | <field domain="[('partner_id','=',partner_id)]" name="bank_id"/> | ||
3003 | 254 | <separator colspan="2" string="Owner Account"/> | ||
3004 | 255 | <separator colspan="2" string="Desitination Account"/> | ||
3005 | 256 | <field colspan="2" name="info_owner" nolabel="1"/> | ||
3006 | 257 | <field colspan="2" name="info_partner" nolabel="1"/> | ||
3007 | 258 | |||
3008 | 259 | <field colspan="4" name="communication"/> | ||
3009 | 260 | <field colspan="4" name="communication2"/> | ||
3010 | 261 | <field name="name"/> | ||
3011 | 262 | <field name="state"/> | ||
3012 | 263 | </page> | ||
3013 | 264 | <page string="Information"> | ||
3014 | 265 | <separator colspan="4" string="General Information"/> | ||
3015 | 266 | <group colspan="2"> | ||
3016 | 267 | <field name="amount" select="1"/> | ||
3017 | 268 | <field name="company_currency" nolabel="1"/> | ||
3018 | 269 | </group> | ||
3019 | 270 | <separator colspan="4" string="Entry Information"/> | ||
3020 | 271 | <field name="create_date"/> | ||
3021 | 272 | <field name="ml_maturity_date"/> | ||
3022 | 273 | <field name="ml_inv_ref"/> | ||
3023 | 274 | </page> | ||
3024 | 275 | </notebook> | ||
3025 | 276 | </form> | ||
3026 | 277 | </field> | ||
3027 | 278 | </record> | ||
3028 | 279 | <record id="view_payment_line_tree" model="ir.ui.view"> | ||
3029 | 280 | <field name="name">Payment Lines</field> | ||
3030 | 281 | <field name="model">payment.line</field> | ||
3031 | 282 | <field name="type">tree</field> | ||
3032 | 283 | <field eval="4" name="priority"/> | ||
3033 | 284 | <field name="arch" type="xml"> | ||
3034 | 285 | <tree string="Payment Line"> | ||
3035 | 286 | <field name="order_id"/> | ||
3036 | 287 | <field name="ml_inv_ref" /> | ||
3037 | 288 | <field name="ml_maturity_date"/> | ||
3038 | 289 | <field name="partner_id" select="1"/> | ||
3039 | 290 | <field name="amount" sum="Amount Total"/> | ||
3040 | 291 | <field name="amount_currency" sum="Currency Amount Total"/> | ||
3041 | 292 | <field name="currency"/> | ||
3042 | 293 | <field name="bank_id" domain="[('partner_id', '=', partner_id)]"/> | ||
3043 | 294 | <field name="move_line_id" on_change="onchange_move_line(move_line_id,parent.mode)"/> | ||
3044 | 295 | <field name="create_date"/> | ||
3045 | 296 | <field name="name"/> | ||
3046 | 297 | </tree> | ||
3047 | 298 | </field> | ||
3048 | 299 | </record> | ||
3049 | 300 | <record id="action_payment_line_form" model="ir.actions.act_window"> | ||
3050 | 301 | <field name="name">Payment Line</field> | ||
3051 | 302 | <field name="res_model">payment.line</field> | ||
3052 | 303 | <field name="view_type">tree</field> | ||
3053 | 304 | <field name="view_mode">form,tree</field> | ||
3054 | 305 | </record> | ||
3055 | 306 | |||
3056 | 307 | <record id="view_bank_statement_form" model="ir.ui.view"> | ||
3057 | 308 | <field name="name">account.bank.statement.form.inherit</field> | ||
3058 | 309 | <field name="model">account.bank.statement</field> | ||
3059 | 310 | <field name="type">form</field> | ||
3060 | 311 | <field name="priority">21</field> | ||
3061 | 312 | <field name="inherit_id" ref="account.view_bank_statement_form"/> | ||
3062 | 313 | <field name="arch" type="xml"> | ||
3063 | 314 | <field name="journal_id" position="after"> | ||
3064 | 315 | <button name="%(action_account_populate_statement_confirm)d" attrs="{'invisible':[('state','=','confirm')]}" string="Import payment lines" type="action" icon="gtk-execute"/> | ||
3065 | 316 | </field> | ||
3066 | 317 | </field> | ||
3067 | 318 | </record> | ||
3068 | 319 | |||
3069 | 320 | |||
3070 | 321 | </data> | 18 | </data> |
3071 | 322 | </openerp> | 19 | </openerp> |
3072 | 323 | 20 | ||
3073 | === removed file 'bin/addons/account_payment/account_payment_workflow.xml' | |||
3074 | --- bin/addons/account_payment/account_payment_workflow.xml 2018-09-28 16:12:03 +0000 | |||
3075 | +++ bin/addons/account_payment/account_payment_workflow.xml 1970-01-01 00:00:00 +0000 | |||
3076 | @@ -1,67 +0,0 @@ | |||
3077 | 1 | <?xml version="1.0" encoding="utf-8"?> | ||
3078 | 2 | <openerp> | ||
3079 | 3 | <data> | ||
3080 | 4 | <record id="wkf_payment_order" model="workflow"> | ||
3081 | 5 | <field name="name">Payment Order Workflow</field> | ||
3082 | 6 | <field name="osv">payment.order</field> | ||
3083 | 7 | <field name="on_create">True</field> | ||
3084 | 8 | </record> | ||
3085 | 9 | <!--Activity --> | ||
3086 | 10 | <record id="act_draft" model="workflow.activity"> | ||
3087 | 11 | <field name="name">draft</field> | ||
3088 | 12 | <field name="wkf_id" ref="wkf_payment_order"/> | ||
3089 | 13 | <field name="flow_start">True</field> | ||
3090 | 14 | <field name="action">write({'state':'draft'})</field> | ||
3091 | 15 | <field name="kind">function</field> | ||
3092 | 16 | </record> | ||
3093 | 17 | <record id="act_open" model="workflow.activity"> | ||
3094 | 18 | <field name="name">open</field> | ||
3095 | 19 | <field name="wkf_id" ref="wkf_payment_order"/> | ||
3096 | 20 | <field name="action">action_open() | ||
3097 | 21 | write({'state':'open'})</field> | ||
3098 | 22 | <field name="kind">function</field> | ||
3099 | 23 | </record> | ||
3100 | 24 | <record id="act_done" model="workflow.activity"> | ||
3101 | 25 | <field name="name">done</field> | ||
3102 | 26 | <field name="wkf_id" ref="wkf_payment_order"/> | ||
3103 | 27 | <field name="action">write({'state':'done'})</field> | ||
3104 | 28 | <field name="kind">function</field> | ||
3105 | 29 | <field name="flow_stop">True</field> | ||
3106 | 30 | </record> | ||
3107 | 31 | <record id="act_cancel" model="workflow.activity"> | ||
3108 | 32 | <field name="name">cancel</field> | ||
3109 | 33 | <field name="wkf_id" ref="wkf_payment_order"/> | ||
3110 | 34 | <field name="action">write({'state':'cancel'})</field> | ||
3111 | 35 | <field name="kind">function</field> | ||
3112 | 36 | <field name="flow_stop">True</field> | ||
3113 | 37 | </record> | ||
3114 | 38 | |||
3115 | 39 | <!-- Transition --> | ||
3116 | 40 | <record id="trans_draft_open" model="workflow.transition"> | ||
3117 | 41 | <field name="act_from" ref="act_draft"/> | ||
3118 | 42 | <field name="act_to" ref="act_open"/> | ||
3119 | 43 | <field name="sequence" eval="10" /> | ||
3120 | 44 | <field name="signal">open</field> | ||
3121 | 45 | </record> | ||
3122 | 46 | |||
3123 | 47 | <record id="trans_open_done" model="workflow.transition"> | ||
3124 | 48 | <field name="act_from" ref="act_open"/> | ||
3125 | 49 | <field name="act_to" ref="act_done"/> | ||
3126 | 50 | <field name="sequence" eval="10" /> | ||
3127 | 51 | <field name="signal">done</field> | ||
3128 | 52 | </record> | ||
3129 | 53 | <record id="trans_draft_cancel" model="workflow.transition"> | ||
3130 | 54 | <field name="act_from" ref="act_draft"/> | ||
3131 | 55 | <field name="act_to" ref="act_cancel"/> | ||
3132 | 56 | <field name="sequence" eval="20" /> | ||
3133 | 57 | <field name="signal">cancel</field> | ||
3134 | 58 | </record> | ||
3135 | 59 | <record id="trans_open_cancel" model="workflow.transition"> | ||
3136 | 60 | <field name="act_from" ref="act_open"/> | ||
3137 | 61 | <field name="act_to" ref="act_cancel"/> | ||
3138 | 62 | <field name="sequence" eval="20" /> | ||
3139 | 63 | <field name="signal">cancel</field> | ||
3140 | 64 | </record> | ||
3141 | 65 | |||
3142 | 66 | </data> | ||
3143 | 67 | </openerp> | ||
3144 | 68 | 0 | ||
3145 | === removed directory 'bin/addons/account_payment/report' | |||
3146 | === removed file 'bin/addons/account_payment/report/__init__.py' | |||
3147 | --- bin/addons/account_payment/report/__init__.py 2011-01-14 00:11:01 +0000 | |||
3148 | +++ bin/addons/account_payment/report/__init__.py 1970-01-01 00:00:00 +0000 | |||
3149 | @@ -1,23 +0,0 @@ | |||
3150 | 1 | # -*- coding: utf-8 -*- | ||
3151 | 2 | ############################################################################## | ||
3152 | 3 | # | ||
3153 | 4 | # OpenERP, Open Source Management Solution | ||
3154 | 5 | # Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>). | ||
3155 | 6 | # | ||
3156 | 7 | # This program is free software: you can redistribute it and/or modify | ||
3157 | 8 | # it under the terms of the GNU Affero General Public License as | ||
3158 | 9 | # published by the Free Software Foundation, either version 3 of the | ||
3159 | 10 | # License, or (at your option) any later version. | ||
3160 | 11 | # | ||
3161 | 12 | # This program is distributed in the hope that it will be useful, | ||
3162 | 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
3163 | 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
3164 | 15 | # GNU Affero General Public License for more details. | ||
3165 | 16 | # | ||
3166 | 17 | # You should have received a copy of the GNU Affero General Public License | ||
3167 | 18 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
3168 | 19 | # | ||
3169 | 20 | ############################################################################## | ||
3170 | 21 | |||
3171 | 22 | import payment_order | ||
3172 | 23 | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: | ||
3173 | 24 | \ No newline at end of file | 0 | \ No newline at end of file |
3174 | 25 | 1 | ||
3175 | === removed file 'bin/addons/account_payment/report/order.rml' | |||
3176 | --- bin/addons/account_payment/report/order.rml 2011-01-14 00:11:01 +0000 | |||
3177 | +++ bin/addons/account_payment/report/order.rml 1970-01-01 00:00:00 +0000 | |||
3178 | @@ -1,290 +0,0 @@ | |||
3179 | 1 | <?xml version="1.0"?> | ||
3180 | 2 | <document filename="Payment Order.pdf"> | ||
3181 | 3 | <template pageSize="(595.0,842.0)" title="Payment Order" author="OpenERP S.A. (sales@openerp.com)" allowSplitting="20"> | ||
3182 | 4 | <pageTemplate id="first"> | ||
3183 | 5 | <frame id="first" x1="34.0" y1="34.0" width="527" height="774"/> | ||
3184 | 6 | </pageTemplate> | ||
3185 | 7 | </template> | ||
3186 | 8 | <stylesheet> | ||
3187 | 9 | <blockTableStyle id="Standard_Outline"> | ||
3188 | 10 | <blockAlignment value="LEFT"/> | ||
3189 | 11 | <blockValign value="TOP"/> | ||
3190 | 12 | </blockTableStyle> | ||
3191 | 13 | <blockTableStyle id="Table1"> | ||
3192 | 14 | <blockAlignment value="LEFT"/> | ||
3193 | 15 | <blockValign value="TOP"/> | ||
3194 | 16 | </blockTableStyle> | ||
3195 | 17 | <blockTableStyle id="Table6"> | ||
3196 | 18 | <blockAlignment value="LEFT"/> | ||
3197 | 19 | <blockValign value="TOP"/> | ||
3198 | 20 | <lineStyle kind="LINEBEFORE" colorName="#cccccc" start="0,0" stop="0,-1"/> | ||
3199 | 21 | <lineStyle kind="LINEABOVE" colorName="#cccccc" start="0,0" stop="0,0"/> | ||
3200 | 22 | <lineStyle kind="LINEBELOW" colorName="#cccccc" start="0,-1" stop="0,-1"/> | ||
3201 | 23 | <lineStyle kind="LINEBEFORE" colorName="#cccccc" start="1,0" stop="1,-1"/> | ||
3202 | 24 | <lineStyle kind="LINEABOVE" colorName="#cccccc" start="1,0" stop="1,0"/> | ||
3203 | 25 | <lineStyle kind="LINEBELOW" colorName="#cccccc" start="1,-1" stop="1,-1"/> | ||
3204 | 26 | <lineStyle kind="LINEBEFORE" colorName="#cccccc" start="2,0" stop="2,-1"/> | ||
3205 | 27 | <lineStyle kind="LINEABOVE" colorName="#cccccc" start="2,0" stop="2,0"/> | ||
3206 | 28 | <lineStyle kind="LINEBELOW" colorName="#cccccc" start="2,-1" stop="2,-1"/> | ||
3207 | 29 | <lineStyle kind="LINEBEFORE" colorName="#cccccc" start="3,0" stop="3,-1"/> | ||
3208 | 30 | <lineStyle kind="LINEABOVE" colorName="#cccccc" start="3,0" stop="3,0"/> | ||
3209 | 31 | <lineStyle kind="LINEBELOW" colorName="#cccccc" start="3,-1" stop="3,-1"/> | ||
3210 | 32 | <lineStyle kind="LINEBEFORE" colorName="#cccccc" start="4,0" stop="4,-1"/> | ||
3211 | 33 | <lineStyle kind="LINEAFTER" colorName="#cccccc" start="4,0" stop="4,-1"/> | ||
3212 | 34 | <lineStyle kind="LINEABOVE" colorName="#cccccc" start="4,0" stop="4,0"/> | ||
3213 | 35 | <lineStyle kind="LINEBELOW" colorName="#cccccc" start="4,-1" stop="4,-1"/> | ||
3214 | 36 | </blockTableStyle> | ||
3215 | 37 | <blockTableStyle id="Table7"> | ||
3216 | 38 | <blockAlignment value="LEFT"/> | ||
3217 | 39 | <blockValign value="TOP"/> | ||
3218 | 40 | <lineStyle kind="LINEBEFORE" colorName="#cccccc" start="0,0" stop="0,-1"/> | ||
3219 | 41 | <lineStyle kind="LINEABOVE" colorName="#cccccc" start="0,0" stop="0,0"/> | ||
3220 | 42 | <lineStyle kind="LINEBELOW" colorName="#cccccc" start="0,-1" stop="0,-1"/> | ||
3221 | 43 | <lineStyle kind="LINEBEFORE" colorName="#cccccc" start="1,0" stop="1,-1"/> | ||
3222 | 44 | <lineStyle kind="LINEABOVE" colorName="#cccccc" start="1,0" stop="1,0"/> | ||
3223 | 45 | <lineStyle kind="LINEBELOW" colorName="#cccccc" start="1,-1" stop="1,-1"/> | ||
3224 | 46 | <lineStyle kind="LINEBEFORE" colorName="#cccccc" start="2,0" stop="2,-1"/> | ||
3225 | 47 | <lineStyle kind="LINEABOVE" colorName="#cccccc" start="2,0" stop="2,0"/> | ||
3226 | 48 | <lineStyle kind="LINEBELOW" colorName="#cccccc" start="2,-1" stop="2,-1"/> | ||
3227 | 49 | <lineStyle kind="LINEBEFORE" colorName="#cccccc" start="3,0" stop="3,-1"/> | ||
3228 | 50 | <lineStyle kind="LINEABOVE" colorName="#cccccc" start="3,0" stop="3,0"/> | ||
3229 | 51 | <lineStyle kind="LINEBELOW" colorName="#cccccc" start="3,-1" stop="3,-1"/> | ||
3230 | 52 | <lineStyle kind="LINEBEFORE" colorName="#cccccc" start="4,0" stop="4,-1"/> | ||
3231 | 53 | <lineStyle kind="LINEAFTER" colorName="#cccccc" start="4,0" stop="4,-1"/> | ||
3232 | 54 | <lineStyle kind="LINEABOVE" colorName="#cccccc" start="4,0" stop="4,0"/> | ||
3233 | 55 | <lineStyle kind="LINEBELOW" colorName="#cccccc" start="4,-1" stop="4,-1"/> | ||
3234 | 56 | </blockTableStyle> | ||
3235 | 57 | <blockTableStyle id="Table3"> | ||
3236 | 58 | <blockAlignment value="LEFT"/> | ||
3237 | 59 | <blockValign value="TOP"/> | ||
3238 | 60 | <lineStyle kind="LINEBELOW" colorName="#000000" start="0,-1" stop="0,-1"/> | ||
3239 | 61 | <lineStyle kind="LINEBELOW" colorName="#000000" start="1,-1" stop="1,-1"/> | ||
3240 | 62 | <lineStyle kind="LINEBELOW" colorName="#000000" start="2,-1" stop="2,-1"/> | ||
3241 | 63 | <lineStyle kind="LINEBELOW" colorName="#000000" start="3,-1" stop="3,-1"/> | ||
3242 | 64 | <lineStyle kind="LINEBELOW" colorName="#000000" start="4,-1" stop="4,-1"/> | ||
3243 | 65 | <lineStyle kind="LINEBELOW" colorName="#000000" start="5,-1" stop="5,-1"/> | ||
3244 | 66 | </blockTableStyle> | ||
3245 | 67 | <blockTableStyle id="Table4"> | ||
3246 | 68 | <blockAlignment value="LEFT"/> | ||
3247 | 69 | <blockValign value="TOP"/> | ||
3248 | 70 | <lineStyle kind="LINEBELOW" colorName="#cccccc" start="0,-1" stop="0,-1"/> | ||
3249 | 71 | <lineStyle kind="LINEBELOW" colorName="#cccccc" start="1,-1" stop="1,-1"/> | ||
3250 | 72 | <lineStyle kind="LINEBELOW" colorName="#cccccc" start="2,-1" stop="2,-1"/> | ||
3251 | 73 | <lineStyle kind="LINEBELOW" colorName="#cccccc" start="3,-1" stop="3,-1"/> | ||
3252 | 74 | <lineStyle kind="LINEBELOW" colorName="#cccccc" start="4,-1" stop="4,-1"/> | ||
3253 | 75 | <lineStyle kind="LINEBELOW" colorName="#cccccc" start="5,-1" stop="5,-1"/> | ||
3254 | 76 | </blockTableStyle> | ||
3255 | 77 | <blockTableStyle id="Table5"> | ||
3256 | 78 | <blockAlignment value="LEFT"/> | ||
3257 | 79 | <blockValign value="TOP"/> | ||
3258 | 80 | <lineStyle kind="LINEABOVE" colorName="#ffffff" start="0,0" stop="0,0"/> | ||
3259 | 81 | <lineStyle kind="LINEBELOW" colorName="#ffffff" start="0,-1" stop="0,-1"/> | ||
3260 | 82 | <lineStyle kind="LINEABOVE" colorName="#000000" start="1,0" stop="1,0"/> | ||
3261 | 83 | <lineStyle kind="LINEABOVE" colorName="#000000" start="2,0" stop="2,0"/> | ||
3262 | 84 | <lineStyle kind="LINEABOVE" colorName="#000000" start="3,0" stop="3,0"/> | ||
3263 | 85 | </blockTableStyle> | ||
3264 | 86 | <initialize> | ||
3265 | 87 | <paraStyle name="all" alignment="justify"/> | ||
3266 | 88 | </initialize> | ||
3267 | 89 | <paraStyle name="Standard" fontName="Helvetica"/> | ||
3268 | 90 | <paraStyle name="Heading" fontName="Helvetica" fontSize="12.0" leading="15" spaceBefore="12.0" spaceAfter="6.0"/> | ||
3269 | 91 | <paraStyle name="Text body" fontName="Helvetica" spaceBefore="0.0" spaceAfter="6.0"/> | ||
3270 | 92 | <paraStyle name="List" fontName="Helvetica" spaceBefore="0.0" spaceAfter="6.0"/> | ||
3271 | 93 | <paraStyle name="Caption" fontName="Helvetica" fontSize="12.0" leading="15" spaceBefore="6.0" spaceAfter="6.0"/> | ||
3272 | 94 | <paraStyle name="Index" fontName="Helvetica"/> | ||
3273 | 95 | <paraStyle name="Table Contents" fontName="Helvetica"/> | ||
3274 | 96 | <paraStyle name="Table Heading" fontName="Helvetica" alignment="CENTER"/> | ||
3275 | 97 | <paraStyle name="Footer" fontName="Helvetica"/> | ||
3276 | 98 | <paraStyle name="Horizontal Line" fontName="Helvetica" fontSize="6.0" leading="8" spaceBefore="0.0" spaceAfter="14.0"/> | ||
3277 | 99 | <paraStyle name="terp_header" fontName="Helvetica-Bold" fontSize="12.0" leading="15" alignment="LEFT" spaceBefore="12.0" spaceAfter="6.0"/> | ||
3278 | 100 | <paraStyle name="Heading 9" fontName="Helvetica-Bold" fontSize="75%" leading="NaN" spaceBefore="12.0" spaceAfter="6.0"/> | ||
3279 | 101 | <paraStyle name="terp_tblheader_General" fontName="Helvetica-Bold" fontSize="8.0" leading="10" alignment="LEFT" spaceBefore="6.0" spaceAfter="6.0"/> | ||
3280 | 102 | <paraStyle name="terp_tblheader_Details" fontName="Helvetica-Bold" fontSize="9.0" leading="11" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/> | ||
3281 | 103 | <paraStyle name="terp_default_8" fontName="Helvetica" fontSize="8.0" leading="10" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/> | ||
3282 | 104 | <paraStyle name="terp_default_Bold_8" fontName="Helvetica-Bold" fontSize="8.0" leading="10" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/> | ||
3283 | 105 | <paraStyle name="terp_tblheader_General_Centre" fontName="Helvetica-Bold" fontSize="8.0" leading="10" alignment="CENTER" spaceBefore="6.0" spaceAfter="6.0"/> | ||
3284 | 106 | <paraStyle name="terp_tblheader_General_Right" fontName="Helvetica-Bold" fontSize="8.0" leading="10" alignment="RIGHT" spaceBefore="6.0" spaceAfter="6.0"/> | ||
3285 | 107 | <paraStyle name="terp_tblheader_Details_Centre" fontName="Helvetica-Bold" fontSize="9.0" leading="11" alignment="CENTER" spaceBefore="0.0" spaceAfter="0.0"/> | ||
3286 | 108 | <paraStyle name="terp_tblheader_Details_Right" fontName="Helvetica-Bold" fontSize="9.0" leading="11" alignment="RIGHT" spaceBefore="0.0" spaceAfter="0.0"/> | ||
3287 | 109 | <paraStyle name="terp_default_Right_8" fontName="Helvetica" fontSize="8.0" leading="10" alignment="RIGHT" spaceBefore="0.0" spaceAfter="0.0"/> | ||
3288 | 110 | <paraStyle name="terp_default_Centre_8" fontName="Helvetica" fontSize="8.0" leading="10" alignment="CENTER" spaceBefore="0.0" spaceAfter="0.0"/> | ||
3289 | 111 | <paraStyle name="terp_header_Right" fontName="Helvetica-Bold" fontSize="15.0" leading="19" alignment="LEFT" spaceBefore="12.0" spaceAfter="6.0"/> | ||
3290 | 112 | <paraStyle name="terp_header_Centre" fontName="Helvetica-Bold" fontSize="12.0" leading="15" alignment="CENTER" spaceBefore="12.0" spaceAfter="6.0"/> | ||
3291 | 113 | <paraStyle name="terp_default_address" fontName="Helvetica" fontSize="10.0" leading="13" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/> | ||
3292 | 114 | <paraStyle name="terp_default_9" fontName="Helvetica" fontSize="9.0" leading="11" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/> | ||
3293 | 115 | <paraStyle name="terp_default_Bold_9" fontName="Helvetica-Bold" fontSize="9.0" leading="11" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/> | ||
3294 | 116 | <paraStyle name="terp_default_Centre_9" fontName="Helvetica" fontSize="9.0" leading="11" alignment="CENTER" spaceBefore="0.0" spaceAfter="0.0"/> | ||
3295 | 117 | <paraStyle name="terp_default_Right_9" fontName="Helvetica" fontSize="9.0" leading="11" alignment="RIGHT" spaceBefore="0.0" spaceAfter="0.0"/> | ||
3296 | 118 | <paraStyle name="terp_default_Space" fontName="Helvetica" fontSize="8.0" leading="10" alignment="LEFT" spaceBefore="9.0" spaceAfter="0.0"/> | ||
3297 | 119 | <paraStyle name="terp_default_space_0.2" fontName="Helvetica" fontSize="8.0" leading="10" alignment="LEFT" spaceBefore="6.0" spaceAfter="0.0"/> | ||
3298 | 120 | <paraStyle name="terp_default_2" fontName="Helvetica" fontSize="2.0" leading="3" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/> | ||
3299 | 121 | <images/> | ||
3300 | 122 | </stylesheet> | ||
3301 | 123 | <story> | ||
3302 | 124 | <pto> | ||
3303 | 125 | <pto_header> | ||
3304 | 126 | <blockTable colWidths="112.0,86.0,106.0,63.0,85.0,75.0" style="Table3"> | ||
3305 | 127 | <tr> | ||
3306 | 128 | <td> | ||
3307 | 129 | <para style="terp_tblheader_Details">Partner</para> | ||
3308 | 130 | </td> | ||
3309 | 131 | <td> | ||
3310 | 132 | <para style="terp_tblheader_Details_Centre">Bank Account</para> | ||
3311 | 133 | </td> | ||
3312 | 134 | <td> | ||
3313 | 135 | <para style="terp_tblheader_Details_Centre">Invoice Ref</para> | ||
3314 | 136 | </td> | ||
3315 | 137 | <td> | ||
3316 | 138 | <para style="terp_tblheader_Details_Centre">Value Date</para> | ||
3317 | 139 | </td> | ||
3318 | 140 | <td> | ||
3319 | 141 | <para style="terp_tblheader_Details_Right">Amount</para> | ||
3320 | 142 | </td> | ||
3321 | 143 | <td> | ||
3322 | 144 | <para style="terp_tblheader_Details_Right">Currency</para> | ||
3323 | 145 | </td> | ||
3324 | 146 | </tr> | ||
3325 | 147 | </blockTable> | ||
3326 | 148 | </pto_header> | ||
3327 | 149 | <para style="terp_default_8">[[ repeatIn(objects, 'o') ]]</para> | ||
3328 | 150 | <para style="terp_default_8"> | ||
3329 | 151 | <font color="white"> </font> | ||
3330 | 152 | </para> | ||
3331 | 153 | <blockTable colWidths="318.0,210.0" style="Table1"> | ||
3332 | 154 | <tr> | ||
3333 | 155 | <td> | ||
3334 | 156 | <para style="terp_default_9"> | ||
3335 | 157 | <font color="white"> </font> | ||
3336 | 158 | </para> | ||
3337 | 159 | </td> | ||
3338 | 160 | <td> | ||
3339 | 161 | <para style="terp_default_address">[[ o.mode and o.mode.bank_id.bank and o.mode.bank_id.bank.name or '']]</para> | ||
3340 | 162 | <para style="terp_default_address">[[ o.mode and o.mode.bank_id.bank and o.mode.bank_id.bank.street or '']]</para> | ||
3341 | 163 | <para style="terp_default_address">[[ o.mode and o.mode.bank_id.bank and o.mode.bank_id.bank.street2 or removeParentNode('para')]]</para> | ||
3342 | 164 | <para style="terp_default_address">[[ o.mode and o.mode.bank_id.bank and o.mode.bank_id.bank.zip or '']] [[ o.mode and o.mode.bank_id.bank and o.mode.bank_id.bank.city or '']]</para> | ||
3343 | 165 | <para style="terp_default_address">[[ o.mode and o.mode.bank_id.bank and o.mode.bank_id.bank.state and o.mode.bank_id.bank.state.name or removeParentNode('para') ]]</para> | ||
3344 | 166 | <para style="terp_default_address">[[ o.mode and o.mode.bank_id.bank and o.mode.bank_id.bank.country and o.mode.bank_id.bank.country.name or '']]</para> | ||
3345 | 167 | </td> | ||
3346 | 168 | </tr> | ||
3347 | 169 | </blockTable> | ||
3348 | 170 | <para style="terp_default_8"> | ||
3349 | 171 | <font color="white"> </font> | ||
3350 | 172 | </para> | ||
3351 | 173 | <para style="terp_header">Payment Order / Payment</para> | ||
3352 | 174 | <para style="terp_default_8"> | ||
3353 | 175 | <font color="white"> </font> | ||
3354 | 176 | </para> | ||
3355 | 177 | <blockTable colWidths="106.0,106.0,106.0,106.0,106.0" style="Table6"> | ||
3356 | 178 | <tr> | ||
3357 | 179 | <td> | ||
3358 | 180 | <para style="terp_tblheader_General_Centre">Payment Type</para> | ||
3359 | 181 | </td> | ||
3360 | 182 | <td> | ||
3361 | 183 | <para style="terp_tblheader_General_Centre">Reference</para> | ||
3362 | 184 | </td> | ||
3363 | 185 | <td> | ||
3364 | 186 | <para style="terp_tblheader_General_Centre">Used Account</para> | ||
3365 | 187 | </td> | ||
3366 | 188 | <td> | ||
3367 | 189 | <para style="terp_tblheader_General_Centre">Execution Type</para> | ||
3368 | 190 | </td> | ||
3369 | 191 | <td> | ||
3370 | 192 | <para style="terp_tblheader_General_Centre">Company Currency</para> | ||
3371 | 193 | </td> | ||
3372 | 194 | </tr> | ||
3373 | 195 | </blockTable> | ||
3374 | 196 | <blockTable colWidths="106.0,106.0,106.0,106.0,106.0" style="Table7"> | ||
3375 | 197 | <tr> | ||
3376 | 198 | <td> | ||
3377 | 199 | <para style="terp_default_Centre_8">[[ o.mode and o.mode.name or '-' ]]</para> | ||
3378 | 200 | </td> | ||
3379 | 201 | <td> | ||
3380 | 202 | <para style="terp_default_Centre_8">[[ o.reference or '-' ]]</para> | ||
3381 | 203 | </td> | ||
3382 | 204 | <td> | ||
3383 | 205 | <para style="terp_default_Centre_8">[[get_account_name(o.mode.bank_id.id)]]</para> | ||
3384 | 206 | </td> | ||
3385 | 207 | <td> | ||
3386 | 208 | <para style="terp_default_Centre_8">[[ o.date_prefered == 'now' and 'Now' or removeParentNode('para') ]]</para> | ||
3387 | 209 | <para style="terp_default_Centre_8">[[ o.date_prefered == 'due' and 'Due date' or removeParentNode('para') ]]</para> | ||
3388 | 210 | <para style="terp_default_Centre_8">[[ o.date_prefered == 'fixed' and 'Fixed date' or removeParentNode('para') ]]</para> | ||
3389 | 211 | </td> | ||
3390 | 212 | <td> | ||
3391 | 213 | <para style="terp_default_Centre_8">[[ o.user_id and o.user_id.company_id and o.user_id.company_id.currency_id and o.user_id.company_id.currency_id.name or '' ]]</para> | ||
3392 | 214 | </td> | ||
3393 | 215 | </tr> | ||
3394 | 216 | </blockTable> | ||
3395 | 217 | <para style="terp_default_9"> | ||
3396 | 218 | <font color="white"> </font> | ||
3397 | 219 | </para> | ||
3398 | 220 | <blockTable colWidths="112.0,86.0,106.0,63.0,85.0,75.0" style="Table3"> | ||
3399 | 221 | <tr> | ||
3400 | 222 | <td> | ||
3401 | 223 | <para style="terp_tblheader_Details">Partner</para> | ||
3402 | 224 | </td> | ||
3403 | 225 | <td> | ||
3404 | 226 | <para style="terp_tblheader_Details_Centre">Bank Account</para> | ||
3405 | 227 | </td> | ||
3406 | 228 | <td> | ||
3407 | 229 | <para style="terp_tblheader_Details_Centre">Invoice Ref</para> | ||
3408 | 230 | </td> | ||
3409 | 231 | <td> | ||
3410 | 232 | <para style="terp_tblheader_Details_Centre">Value Date</para> | ||
3411 | 233 | </td> | ||
3412 | 234 | <td> | ||
3413 | 235 | <para style="terp_tblheader_Details_Right">Amount</para> | ||
3414 | 236 | </td> | ||
3415 | 237 | <td> | ||
3416 | 238 | <para style="terp_tblheader_Details_Right">Currency</para> | ||
3417 | 239 | </td> | ||
3418 | 240 | </tr> | ||
3419 | 241 | </blockTable> | ||
3420 | 242 | <section> | ||
3421 | 243 | <para style="terp_default_2">[[repeatIn(o.line_ids, 'line') ]]</para> | ||
3422 | 244 | <blockTable colWidths="112.0,86.0,106.0,64.0,85.0,75.0" style="Table4"> | ||
3423 | 245 | <tr> | ||
3424 | 246 | <td> | ||
3425 | 247 | <para style="terp_default_9">[[line.partner_id and line.partner_id.name or '-' ]]</para> | ||
3426 | 248 | </td> | ||
3427 | 249 | <td> | ||
3428 | 250 | <para style="terp_default_Centre_9">[[get_account_name(line.bank_id.id) or '-']]</para> | ||
3429 | 251 | </td> | ||
3430 | 252 | <td> | ||
3431 | 253 | <para style="terp_default_Centre_9">[[ get_invoice_name(line.ml_inv_ref.id) or '-' ]]</para> | ||
3432 | 254 | </td> | ||
3433 | 255 | <td> | ||
3434 | 256 | <para style="terp_default_Centre_9">[[line.date=='False' and '-' or formatLang(line.date,date=True) ]]</para> | ||
3435 | 257 | </td> | ||
3436 | 258 | <td> | ||
3437 | 259 | <para style="terp_default_Right_9">[[formatLang(line.amount) or '-' ]] [[get_company_currency_symbol()]] </para> | ||
3438 | 260 | </td> | ||
3439 | 261 | <td> | ||
3440 | 262 | <para style="terp_default_Right_9">[[ formatLang(line.amount_currency) ]] [[ line.currency.symbol]] </para> | ||
3441 | 263 | </td> | ||
3442 | 264 | </tr> | ||
3443 | 265 | </blockTable> | ||
3444 | 266 | </section> | ||
3445 | 267 | <blockTable colWidths="335.0,32.0,85.0,75.0" style="Table5"> | ||
3446 | 268 | <tr> | ||
3447 | 269 | <td> | ||
3448 | 270 | <para style="terp_default_9"> | ||
3449 | 271 | <font color="white"> </font> | ||
3450 | 272 | </para> | ||
3451 | 273 | </td> | ||
3452 | 274 | <td> | ||
3453 | 275 | <para style="terp_default_Bold_9">Total:</para> | ||
3454 | 276 | </td> | ||
3455 | 277 | <td> | ||
3456 | 278 | <para style="terp_default_Right_9">[[ formatLang(get_amount_total(o)) or '' ]] [[get_company_currency_symbol()]] </para> | ||
3457 | 279 | </td> | ||
3458 | 280 | <td> | ||
3459 | 281 | <para style="terp_default_Right_9">[[ formatLang(get_amount_total_in_currency(o)) or '' ]] [[get_company_currency_symbol()]] </para> | ||
3460 | 282 | </td> | ||
3461 | 283 | </tr> | ||
3462 | 284 | </blockTable> | ||
3463 | 285 | <para style="terp_default_8"> | ||
3464 | 286 | <font color="white"> </font> | ||
3465 | 287 | </para> | ||
3466 | 288 | </pto> | ||
3467 | 289 | </story> | ||
3468 | 290 | </document> | ||
3469 | 291 | 0 | ||
3470 | === removed file 'bin/addons/account_payment/report/order.sxw' | |||
3471 | 292 | Binary files bin/addons/account_payment/report/order.sxw 2011-01-14 00:11:01 +0000 and bin/addons/account_payment/report/order.sxw 1970-01-01 00:00:00 +0000 differ | 1 | Binary files bin/addons/account_payment/report/order.sxw 2011-01-14 00:11:01 +0000 and bin/addons/account_payment/report/order.sxw 1970-01-01 00:00:00 +0000 differ |
3472 | === removed file 'bin/addons/account_payment/report/payment_order.py' | |||
3473 | --- bin/addons/account_payment/report/payment_order.py 2011-01-14 00:11:01 +0000 | |||
3474 | +++ bin/addons/account_payment/report/payment_order.py 1970-01-01 00:00:00 +0000 | |||
3475 | @@ -1,90 +0,0 @@ | |||
3476 | 1 | # -*- coding: utf-8 -*- | ||
3477 | 2 | ############################################################################## | ||
3478 | 3 | # | ||
3479 | 4 | # OpenERP, Open Source Management Solution | ||
3480 | 5 | # Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>). | ||
3481 | 6 | # | ||
3482 | 7 | # This program is free software: you can redistribute it and/or modify | ||
3483 | 8 | # it under the terms of the GNU Affero General Public License as | ||
3484 | 9 | # published by the Free Software Foundation, either version 3 of the | ||
3485 | 10 | # License, or (at your option) any later version. | ||
3486 | 11 | # | ||
3487 | 12 | # This program is distributed in the hope that it will be useful, | ||
3488 | 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
3489 | 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
3490 | 15 | # GNU Affero General Public License for more details. | ||
3491 | 16 | # | ||
3492 | 17 | # You should have received a copy of the GNU Affero General Public License | ||
3493 | 18 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
3494 | 19 | # | ||
3495 | 20 | ############################################################################## | ||
3496 | 21 | |||
3497 | 22 | import time | ||
3498 | 23 | |||
3499 | 24 | import pooler | ||
3500 | 25 | from report import report_sxw | ||
3501 | 26 | |||
3502 | 27 | class payment_order(report_sxw.rml_parse): | ||
3503 | 28 | |||
3504 | 29 | def __init__(self, cr, uid, name, context=None): | ||
3505 | 30 | super(payment_order, self).__init__(cr, uid, name, context=context) | ||
3506 | 31 | self.localcontext.update( { | ||
3507 | 32 | 'time': time, | ||
3508 | 33 | 'get_invoice_name': self._get_invoice_name, | ||
3509 | 34 | 'get_company_currency': self._get_company_currency, | ||
3510 | 35 | 'get_company_currency_symbol': self._get_company_currency_symbol, | ||
3511 | 36 | 'get_amount_total_in_currency': self._get_amount_total_in_currency, | ||
3512 | 37 | 'get_amount_total': self._get_amount_total, | ||
3513 | 38 | 'get_account_name': self._get_account_name, | ||
3514 | 39 | }) | ||
3515 | 40 | |||
3516 | 41 | def _get_invoice_name(self, invoice_id): | ||
3517 | 42 | if invoice_id: | ||
3518 | 43 | pool = pooler.get_pool(self.cr.dbname) | ||
3519 | 44 | value_name = pool.get('account.invoice').name_get(self.cr, self.uid, [invoice_id]) | ||
3520 | 45 | if value_name: | ||
3521 | 46 | return value_name[0][1] | ||
3522 | 47 | return False | ||
3523 | 48 | |||
3524 | 49 | def _get_amount_total_in_currency(self, payment): | ||
3525 | 50 | total = 0.0 | ||
3526 | 51 | if payment.line_ids: | ||
3527 | 52 | currency_cmp = payment.line_ids[0].currency.id | ||
3528 | 53 | else: | ||
3529 | 54 | return False | ||
3530 | 55 | for line in payment.line_ids: | ||
3531 | 56 | if currency_cmp == line.currency.id: | ||
3532 | 57 | total += line.amount_currency | ||
3533 | 58 | else: | ||
3534 | 59 | return False | ||
3535 | 60 | return total | ||
3536 | 61 | |||
3537 | 62 | def _get_amount_total(self, payment): | ||
3538 | 63 | total = 0.0 | ||
3539 | 64 | if not payment.line_ids: | ||
3540 | 65 | return False | ||
3541 | 66 | for line in payment.line_ids: | ||
3542 | 67 | total += line.amount | ||
3543 | 68 | return total | ||
3544 | 69 | |||
3545 | 70 | def _get_company_currency(self): | ||
3546 | 71 | pool = pooler.get_pool(self.cr.dbname) | ||
3547 | 72 | user = pool.get('res.users').browse(self.cr, self.uid, self.uid) | ||
3548 | 73 | return user.company_id and user.company_id.currency_id and user.company_id.currency_id.symbol or False | ||
3549 | 74 | |||
3550 | 75 | def _get_company_currency_symbol(self): | ||
3551 | 76 | pool = pooler.get_pool(self.cr.dbname) | ||
3552 | 77 | user = pool.get('res.users').browse(self.cr, self.uid, self.uid) | ||
3553 | 78 | return user.company_id and user.company_id.currency_id and user.company_id.currency_id.symbol or False | ||
3554 | 79 | |||
3555 | 80 | def _get_account_name(self,bank_id): | ||
3556 | 81 | if bank_id: | ||
3557 | 82 | pool = pooler.get_pool(self.cr.dbname) | ||
3558 | 83 | value_name = pool.get('res.partner.bank').name_get(self.cr, self.uid, [bank_id]) | ||
3559 | 84 | if value_name: | ||
3560 | 85 | return value_name[0][1] | ||
3561 | 86 | return False | ||
3562 | 87 | |||
3563 | 88 | report_sxw.report_sxw('report.payment.order', 'payment.order', 'addons/account_payment/report/payment_order.rml', parser=payment_order, header="external") | ||
3564 | 89 | |||
3565 | 90 | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: | ||
3566 | 91 | \ No newline at end of file | 0 | \ No newline at end of file |
3567 | 92 | 1 | ||
3568 | === removed directory 'bin/addons/account_payment/security' | |||
3569 | === removed file 'bin/addons/account_payment/security/account_payment_security.xml' | |||
3570 | --- bin/addons/account_payment/security/account_payment_security.xml 2011-02-28 13:57:54 +0000 | |||
3571 | +++ bin/addons/account_payment/security/account_payment_security.xml 1970-01-01 00:00:00 +0000 | |||
3572 | @@ -1,17 +0,0 @@ | |||
3573 | 1 | <?xml version="1.0" encoding="utf-8"?> | ||
3574 | 2 | <openerp> | ||
3575 | 3 | <data noupdate="1"> | ||
3576 | 4 | |||
3577 | 5 | <record id="group_account_payment" model="res.groups"> | ||
3578 | 6 | <field name="name">Accounting / Payments</field> | ||
3579 | 7 | </record> | ||
3580 | 8 | |||
3581 | 9 | <record id="payment_mode_comp_rule" model="ir.rule"> | ||
3582 | 10 | <field name="name">Payment Mode company rule</field> | ||
3583 | 11 | <field model="ir.model" name="model_id" ref="model_payment_mode"/> | ||
3584 | 12 | <field eval="True" name="global"/> | ||
3585 | 13 | <field name="domain_force">['|',('company_id','=',False),('company_id','child_of',[user.company_id.id])]</field> | ||
3586 | 14 | </record> | ||
3587 | 15 | |||
3588 | 16 | </data> | ||
3589 | 17 | </openerp> | ||
3590 | 18 | 0 | ||
3591 | === removed file 'bin/addons/account_payment/security/ir.model.access.csv' | |||
3592 | --- bin/addons/account_payment/security/ir.model.access.csv 2018-10-04 14:32:37 +0000 | |||
3593 | +++ bin/addons/account_payment/security/ir.model.access.csv 1970-01-01 00:00:00 +0000 | |||
3594 | @@ -1,1 +0,0 @@ | |||
3595 | 1 | "id","name","model_id:id","group_id:id","perm_read","perm_write","perm_create","perm_unlink" | ||
3596 | 2 | 0 | ||
3597 | === removed directory 'bin/addons/account_payment/wizard' | |||
3598 | === removed file 'bin/addons/account_payment/wizard/__init__.py' | |||
3599 | --- bin/addons/account_payment/wizard/__init__.py 2011-01-14 00:11:01 +0000 | |||
3600 | +++ bin/addons/account_payment/wizard/__init__.py 1970-01-01 00:00:00 +0000 | |||
3601 | @@ -1,26 +0,0 @@ | |||
3602 | 1 | # -*- coding: utf-8 -*- | ||
3603 | 2 | ############################################################################## | ||
3604 | 3 | # | ||
3605 | 4 | # OpenERP, Open Source Management Solution | ||
3606 | 5 | # Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>). | ||
3607 | 6 | # | ||
3608 | 7 | # This program is free software: you can redistribute it and/or modify | ||
3609 | 8 | # it under the terms of the GNU Affero General Public License as | ||
3610 | 9 | # published by the Free Software Foundation, either version 3 of the | ||
3611 | 10 | # License, or (at your option) any later version. | ||
3612 | 11 | # | ||
3613 | 12 | # This program is distributed in the hope that it will be useful, | ||
3614 | 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
3615 | 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
3616 | 15 | # GNU Affero General Public License for more details. | ||
3617 | 16 | # | ||
3618 | 17 | # You should have received a copy of the GNU Affero General Public License | ||
3619 | 18 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
3620 | 19 | # | ||
3621 | 20 | ############################################################################## | ||
3622 | 21 | |||
3623 | 22 | import account_payment_order | ||
3624 | 23 | import account_payment_populate_statement | ||
3625 | 24 | import account_payment_pay | ||
3626 | 25 | |||
3627 | 26 | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: | ||
3628 | 27 | \ No newline at end of file | 0 | \ No newline at end of file |
3629 | 28 | 1 | ||
3630 | === removed file 'bin/addons/account_payment/wizard/account_payment_create_order_view.xml' | |||
3631 | --- bin/addons/account_payment/wizard/account_payment_create_order_view.xml 2017-05-10 12:47:14 +0000 | |||
3632 | +++ bin/addons/account_payment/wizard/account_payment_create_order_view.xml 1970-01-01 00:00:00 +0000 | |||
3633 | @@ -1,52 +0,0 @@ | |||
3634 | 1 | <?xml version="1.0" encoding="utf-8"?> | ||
3635 | 2 | <openerp> | ||
3636 | 3 | <data> | ||
3637 | 4 | |||
3638 | 5 | <record id="view_create_payment_order" model="ir.ui.view"> | ||
3639 | 6 | <field name="name">payment.order.create.form</field> | ||
3640 | 7 | <field name="model">payment.order.create</field> | ||
3641 | 8 | <field name="type">form</field> | ||
3642 | 9 | <field name="priority">18</field> | ||
3643 | 10 | <field name="arch" type="xml"> | ||
3644 | 11 | <form string="Search Payment lines"> | ||
3645 | 12 | <group col="4" colspan="6"> | ||
3646 | 13 | <field name="duedate" /> | ||
3647 | 14 | </group> | ||
3648 | 15 | <separator colspan="4"/> | ||
3649 | 16 | <group col="2" colspan="4"> | ||
3650 | 17 | <button special="cancel" string="Cancel" icon='gtk-cancel'/> | ||
3651 | 18 | <button name="search_entries" string="Search" colspan="1" type="object" icon="gtk-execute"/> | ||
3652 | 19 | </group> | ||
3653 | 20 | </form> | ||
3654 | 21 | </field> | ||
3655 | 22 | </record> | ||
3656 | 23 | |||
3657 | 24 | <record id="view_create_payment_order_lines" model="ir.ui.view"> | ||
3658 | 25 | <field name="name">payment.order.create.form</field> | ||
3659 | 26 | <field name="model">payment.order.create</field> | ||
3660 | 27 | <field name="type">form</field> | ||
3661 | 28 | <field name="priority">17</field> | ||
3662 | 29 | <field name="arch" type="xml"> | ||
3663 | 30 | <form string="Search Payment lines"> | ||
3664 | 31 | <group col="4" colspan="6"> | ||
3665 | 32 | </group> | ||
3666 | 33 | <separator colspan="4"/> | ||
3667 | 34 | <group col="2" colspan="4"> | ||
3668 | 35 | <button special="cancel" string="Cancel" icon='gtk-cancel'/> | ||
3669 | 36 | <button name="create_payment" string="_Add to payment order" colspan="1" type="object" icon="gtk-execute"/> | ||
3670 | 37 | </group> | ||
3671 | 38 | </form> | ||
3672 | 39 | </field> | ||
3673 | 40 | </record> | ||
3674 | 41 | |||
3675 | 42 | <record id="action_create_payment_order" model="ir.actions.act_window"> | ||
3676 | 43 | <field name="name">Populate Payment</field> | ||
3677 | 44 | <field name="type">ir.actions.act_window</field> | ||
3678 | 45 | <field name="res_model">payment.order.create</field> | ||
3679 | 46 | <field name="view_type">form</field> | ||
3680 | 47 | <field name="view_mode">form</field> | ||
3681 | 48 | <field name="target">new</field> | ||
3682 | 49 | </record> | ||
3683 | 50 | |||
3684 | 51 | </data> | ||
3685 | 52 | </openerp> | ||
3686 | 53 | 0 | ||
3687 | === removed file 'bin/addons/account_payment/wizard/account_payment_order.py' | |||
3688 | --- bin/addons/account_payment/wizard/account_payment_order.py 2011-01-14 00:11:01 +0000 | |||
3689 | +++ bin/addons/account_payment/wizard/account_payment_order.py 1970-01-01 00:00:00 +0000 | |||
3690 | @@ -1,123 +0,0 @@ | |||
3691 | 1 | # -*- coding: utf-8 -*- | ||
3692 | 2 | ############################################################################## | ||
3693 | 3 | # | ||
3694 | 4 | # OpenERP, Open Source Management Solution | ||
3695 | 5 | # Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>). | ||
3696 | 6 | # | ||
3697 | 7 | # This program is free software: you can redistribute it and/or modify | ||
3698 | 8 | # it under the terms of the GNU Affero General Public License as | ||
3699 | 9 | # published by the Free Software Foundation, either version 3 of the | ||
3700 | 10 | # License, or (at your option) any later version. | ||
3701 | 11 | # | ||
3702 | 12 | # This program is distributed in the hope that it will be useful, | ||
3703 | 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
3704 | 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
3705 | 15 | # GNU Affero General Public License for more details. | ||
3706 | 16 | # | ||
3707 | 17 | # You should have received a copy of the GNU Affero General Public License | ||
3708 | 18 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
3709 | 19 | # | ||
3710 | 20 | ############################################################################## | ||
3711 | 21 | |||
3712 | 22 | import time | ||
3713 | 23 | from lxml import etree | ||
3714 | 24 | |||
3715 | 25 | from osv import osv, fields | ||
3716 | 26 | |||
3717 | 27 | class payment_order_create(osv.osv_memory): | ||
3718 | 28 | """ | ||
3719 | 29 | Create a payment object with lines corresponding to the account move line | ||
3720 | 30 | to pay according to the date and the mode provided by the user. | ||
3721 | 31 | Hypothesis: | ||
3722 | 32 | - Small number of non-reconcilied move line, payment mode and bank account type, | ||
3723 | 33 | - Big number of partner and bank account. | ||
3724 | 34 | |||
3725 | 35 | If a type is given, unsuitable account Entry lines are ignored. | ||
3726 | 36 | """ | ||
3727 | 37 | |||
3728 | 38 | _name = 'payment.order.create' | ||
3729 | 39 | _description = 'payment.order.create' | ||
3730 | 40 | _columns = { | ||
3731 | 41 | 'duedate': fields.date('Due Date', required=True), | ||
3732 | 42 | 'entries': fields.many2many('account.move.line', 'line_pay_rel', 'pay_id', 'line_id', 'Entries') | ||
3733 | 43 | } | ||
3734 | 44 | _defaults = { | ||
3735 | 45 | 'duedate': lambda *a: time.strftime('%Y-%m-%d'), | ||
3736 | 46 | } | ||
3737 | 47 | |||
3738 | 48 | def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False): | ||
3739 | 49 | res = super(payment_order_create, self).fields_view_get(cr, uid, view_id=view_id, view_type=view_type, context=context, toolbar=toolbar, submenu=False) | ||
3740 | 50 | if context and 'line_ids' in context: | ||
3741 | 51 | view_obj = etree.XML(res['arch']) | ||
3742 | 52 | child = view_obj.getchildren()[0] | ||
3743 | 53 | domain = '[("id", "in", '+ str(context['line_ids'])+')]' | ||
3744 | 54 | field = etree.Element('field', attrib={'domain': domain, 'name':'entries', 'colspan':'4', 'height':'300', 'width':'800', 'nolabel':"1"}) | ||
3745 | 55 | child.addprevious(field) | ||
3746 | 56 | res['arch'] = etree.tostring(view_obj) | ||
3747 | 57 | return res | ||
3748 | 58 | |||
3749 | 59 | def create_payment(self, cr, uid, ids, context=None): | ||
3750 | 60 | order_obj = self.pool.get('payment.order') | ||
3751 | 61 | line_obj = self.pool.get('account.move.line') | ||
3752 | 62 | payment_obj = self.pool.get('payment.line') | ||
3753 | 63 | if context is None: | ||
3754 | 64 | context = {} | ||
3755 | 65 | data = self.read(cr, uid, ids, [], context=context)[0] | ||
3756 | 66 | line_ids = data['entries'] | ||
3757 | 67 | if not line_ids: | ||
3758 | 68 | return {'type': 'ir.actions.act_window_close'} | ||
3759 | 69 | |||
3760 | 70 | payment = order_obj.browse(cr, uid, context['active_id'], context=context) | ||
3761 | 71 | t = None | ||
3762 | 72 | line2bank = line_obj.line2bank(cr, uid, line_ids, t, context) | ||
3763 | 73 | |||
3764 | 74 | ## Finally populate the current payment with new lines: | ||
3765 | 75 | for line in line_obj.browse(cr, uid, line_ids, context=context): | ||
3766 | 76 | if payment.date_prefered == "now": | ||
3767 | 77 | #no payment date => immediate payment | ||
3768 | 78 | date_to_pay = False | ||
3769 | 79 | elif payment.date_prefered == 'due': | ||
3770 | 80 | date_to_pay = line.date_maturity | ||
3771 | 81 | elif payment.date_prefered == 'fixed': | ||
3772 | 82 | date_to_pay = payment.date_scheduled | ||
3773 | 83 | payment_obj.create(cr, uid,{ | ||
3774 | 84 | 'move_line_id': line.id, | ||
3775 | 85 | 'amount_currency': line.amount_to_pay, | ||
3776 | 86 | 'bank_id': line2bank.get(line.id), | ||
3777 | 87 | 'order_id': payment.id, | ||
3778 | 88 | 'partner_id': line.partner_id and line.partner_id.id or False, | ||
3779 | 89 | 'communication': line.ref or '/', | ||
3780 | 90 | 'date': date_to_pay, | ||
3781 | 91 | 'currency': line.invoice and line.invoice.currency_id.id or False, | ||
3782 | 92 | }, context=context) | ||
3783 | 93 | return {'type': 'ir.actions.act_window_close'} | ||
3784 | 94 | |||
3785 | 95 | def search_entries(self, cr, uid, ids, context=None): | ||
3786 | 96 | line_obj = self.pool.get('account.move.line') | ||
3787 | 97 | mod_obj = self.pool.get('ir.model.data') | ||
3788 | 98 | if context is None: | ||
3789 | 99 | context = {} | ||
3790 | 100 | data = self.read(cr, uid, ids, [], context=context)[0] | ||
3791 | 101 | search_due_date = data['duedate'] | ||
3792 | 102 | # payment = self.pool.get('payment.order').browse(cr, uid, context['active_id'], context=context) | ||
3793 | 103 | |||
3794 | 104 | # Search for move line to pay: | ||
3795 | 105 | domain = [('reconcile_id', '=', False), ('account_id.type', '=', 'payable'), ('amount_to_pay', '>', 0)] | ||
3796 | 106 | domain = domain + ['|', ('date_maturity', '<=', search_due_date), ('date_maturity', '=', False)] | ||
3797 | 107 | line_ids = line_obj.search(cr, uid, domain, context=context) | ||
3798 | 108 | context.update({'line_ids': line_ids}) | ||
3799 | 109 | model_data_ids = mod_obj.search(cr, uid,[('model', '=', 'ir.ui.view'), ('name', '=', 'view_create_payment_order_lines')], context=context) | ||
3800 | 110 | resource_id = mod_obj.read(cr, uid, model_data_ids, fields=['res_id'], context=context)[0]['res_id'] | ||
3801 | 111 | return {'name': ('Entrie Lines'), | ||
3802 | 112 | 'context': context, | ||
3803 | 113 | 'view_type': 'form', | ||
3804 | 114 | 'view_mode': 'form', | ||
3805 | 115 | 'res_model': 'payment.order.create', | ||
3806 | 116 | 'views': [(resource_id,'form')], | ||
3807 | 117 | 'type': 'ir.actions.act_window', | ||
3808 | 118 | 'target': 'new', | ||
3809 | 119 | } | ||
3810 | 120 | |||
3811 | 121 | payment_order_create() | ||
3812 | 122 | |||
3813 | 123 | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: | ||
3814 | 124 | \ No newline at end of file | 0 | \ No newline at end of file |
3815 | 125 | 1 | ||
3816 | === removed file 'bin/addons/account_payment/wizard/account_payment_pay.py' | |||
3817 | --- bin/addons/account_payment/wizard/account_payment_pay.py 2011-01-14 00:11:01 +0000 | |||
3818 | +++ bin/addons/account_payment/wizard/account_payment_pay.py 1970-01-01 00:00:00 +0000 | |||
3819 | @@ -1,58 +0,0 @@ | |||
3820 | 1 | # -*- coding: utf-8 -*- | ||
3821 | 2 | ############################################################################## | ||
3822 | 3 | # | ||
3823 | 4 | # OpenERP, Open Source Management Solution | ||
3824 | 5 | # Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>). | ||
3825 | 6 | # | ||
3826 | 7 | # This program is free software: you can redistribute it and/or modify | ||
3827 | 8 | # it under the terms of the GNU Affero General Public License as | ||
3828 | 9 | # published by the Free Software Foundation, either version 3 of the | ||
3829 | 10 | # License, or (at your option) any later version. | ||
3830 | 11 | # | ||
3831 | 12 | # This program is distributed in the hope that it will be useful, | ||
3832 | 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
3833 | 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
3834 | 15 | # GNU Affero General Public License for more details. | ||
3835 | 16 | # | ||
3836 | 17 | # You should have received a copy of the GNU Affero General Public License | ||
3837 | 18 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
3838 | 19 | # | ||
3839 | 20 | ############################################################################## | ||
3840 | 21 | |||
3841 | 22 | from osv import osv | ||
3842 | 23 | |||
3843 | 24 | class account_payment_make_payment(osv.osv_memory): | ||
3844 | 25 | _name = "account.payment.make.payment" | ||
3845 | 26 | _description = "Account make payment" | ||
3846 | 27 | |||
3847 | 28 | def launch_wizard(self, cr, uid, ids, context=None): | ||
3848 | 29 | """ | ||
3849 | 30 | Search for a wizard to launch according to the type. | ||
3850 | 31 | If type is manual. just confirm the order. | ||
3851 | 32 | """ | ||
3852 | 33 | obj_payment_order = self.pool.get('payment.order') | ||
3853 | 34 | if context is None: | ||
3854 | 35 | context = {} | ||
3855 | 36 | # obj_model = self.pool.get('ir.model.data') | ||
3856 | 37 | # obj_act = self.pool.get('ir.actions.act_window') | ||
3857 | 38 | # order = obj_payment_order.browse(cr, uid, context['active_id'], context) | ||
3858 | 39 | obj_payment_order.set_done(cr, uid, [context['active_id']], context) | ||
3859 | 40 | return {'type': 'ir.actions.act_window_close'} | ||
3860 | 41 | # t = order.mode and order.mode.type.code or 'manual' | ||
3861 | 42 | # if t == 'manual': | ||
3862 | 43 | # obj_payment_order.set_done(cr,uid,context['active_id'],context) | ||
3863 | 44 | # return {} | ||
3864 | 45 | # | ||
3865 | 46 | # gw = obj_payment_order.get_wizard(t) | ||
3866 | 47 | # if not gw: | ||
3867 | 48 | # obj_payment_order.set_done(cr,uid,context['active_id'],context) | ||
3868 | 49 | # return {} | ||
3869 | 50 | # | ||
3870 | 51 | # module, wizard= gw | ||
3871 | 52 | # result = obj_model._get_id(cr, uid, module, wizard) | ||
3872 | 53 | # id = obj_model.read(cr, uid, [result], ['res_id'])[0]['res_id'] | ||
3873 | 54 | # return obj_act.read(cr, uid, [id])[0] | ||
3874 | 55 | |||
3875 | 56 | account_payment_make_payment() | ||
3876 | 57 | |||
3877 | 58 | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: | ||
3878 | 59 | \ No newline at end of file | 0 | \ No newline at end of file |
3879 | 60 | 1 | ||
3880 | === removed file 'bin/addons/account_payment/wizard/account_payment_pay_view.xml' | |||
3881 | --- bin/addons/account_payment/wizard/account_payment_pay_view.xml 2011-01-14 00:11:01 +0000 | |||
3882 | +++ bin/addons/account_payment/wizard/account_payment_pay_view.xml 1970-01-01 00:00:00 +0000 | |||
3883 | @@ -1,33 +0,0 @@ | |||
3884 | 1 | <?xml version="1.0" encoding="utf-8"?> | ||
3885 | 2 | <openerp> | ||
3886 | 3 | <data> | ||
3887 | 4 | |||
3888 | 5 | <record id="account_payment_make_payment_view" model="ir.ui.view"> | ||
3889 | 6 | <field name="name">account.payment.make.payment.form</field> | ||
3890 | 7 | <field name="model">account.payment.make.payment</field> | ||
3891 | 8 | <field name="type">form</field> | ||
3892 | 9 | <field name="arch" type="xml"> | ||
3893 | 10 | <form string="Make Payment"> | ||
3894 | 11 | <separator string="Are you sure you want to make payment?"/> | ||
3895 | 12 | <newline/> | ||
3896 | 13 | <group colspan="2" col="4"> | ||
3897 | 14 | <button special="cancel" string="Cancel" icon="gtk-cancel"/> | ||
3898 | 15 | <button name="launch_wizard" string="Yes" type="object" icon="gtk-ok" default_focus="1"/> | ||
3899 | 16 | </group> | ||
3900 | 17 | </form> | ||
3901 | 18 | </field> | ||
3902 | 19 | </record> | ||
3903 | 20 | |||
3904 | 21 | <record id="action_account_payment_make_payment" model="ir.actions.act_window"> | ||
3905 | 22 | <field name="name">Make Payment</field> | ||
3906 | 23 | <field name="type">ir.actions.act_window</field> | ||
3907 | 24 | <field name="res_model">account.payment.make.payment</field> | ||
3908 | 25 | <field name="view_type">form</field> | ||
3909 | 26 | <field name="view_mode">form</field> | ||
3910 | 27 | <field name="view_id" ref="account_payment_make_payment_view"/> | ||
3911 | 28 | <field name="target">new</field> | ||
3912 | 29 | </record> | ||
3913 | 30 | |||
3914 | 31 | |||
3915 | 32 | </data> | ||
3916 | 33 | </openerp> | ||
3917 | 34 | 0 | ||
3918 | === removed file 'bin/addons/account_payment/wizard/account_payment_populate_statement.py' | |||
3919 | --- bin/addons/account_payment/wizard/account_payment_populate_statement.py 2011-05-16 14:06:09 +0000 | |||
3920 | +++ bin/addons/account_payment/wizard/account_payment_populate_statement.py 1970-01-01 00:00:00 +0000 | |||
3921 | @@ -1,122 +0,0 @@ | |||
3922 | 1 | # -*- coding: utf-8 -*- | ||
3923 | 2 | ############################################################################## | ||
3924 | 3 | # | ||
3925 | 4 | # OpenERP, Open Source Management Solution | ||
3926 | 5 | # Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>). | ||
3927 | 6 | # | ||
3928 | 7 | # This program is free software: you can redistribute it and/or modify | ||
3929 | 8 | # it under the terms of the GNU Affero General Public License as | ||
3930 | 9 | # published by the Free Software Foundation, either version 3 of the | ||
3931 | 10 | # License, or (at your option) any later version. | ||
3932 | 11 | # | ||
3933 | 12 | # This program is distributed in the hope that it will be useful, | ||
3934 | 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
3935 | 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
3936 | 15 | # GNU Affero General Public License for more details. | ||
3937 | 16 | # | ||
3938 | 17 | # You should have received a copy of the GNU Affero General Public License | ||
3939 | 18 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
3940 | 19 | # | ||
3941 | 20 | ############################################################################## | ||
3942 | 21 | |||
3943 | 22 | import time | ||
3944 | 23 | from lxml import etree | ||
3945 | 24 | |||
3946 | 25 | from osv import osv, fields | ||
3947 | 26 | |||
3948 | 27 | class account_payment_populate_statement(osv.osv_memory): | ||
3949 | 28 | _name = "account.payment.populate.statement" | ||
3950 | 29 | _description = "Account Payment Populate Statement" | ||
3951 | 30 | _columns = { | ||
3952 | 31 | 'lines': fields.many2many('payment.line', 'payment_line_rel_', 'payment_id', 'line_id', 'Payment Lines') | ||
3953 | 32 | } | ||
3954 | 33 | |||
3955 | 34 | def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False): | ||
3956 | 35 | line_obj = self.pool.get('payment.line') | ||
3957 | 36 | |||
3958 | 37 | res = super(account_payment_populate_statement, self).fields_view_get(cr, uid, view_id=view_id, view_type=view_type, context=context, toolbar=toolbar, submenu=False) | ||
3959 | 38 | line_ids = line_obj.search(cr, uid, [ | ||
3960 | 39 | ('move_line_id.reconcile_id', '=', False), | ||
3961 | 40 | ('bank_statement_line_id', '=', False), | ||
3962 | 41 | ('move_line_id.state','=','valid')]) | ||
3963 | 42 | line_ids.extend(line_obj.search(cr, uid, [ | ||
3964 | 43 | ('move_line_id.reconcile_id', '=', False), | ||
3965 | 44 | ('order_id.mode', '=', False), | ||
3966 | 45 | ('move_line_id.state','=','valid')])) | ||
3967 | 46 | domain = '[("id", "in", '+ str(line_ids)+')]' | ||
3968 | 47 | doc = etree.XML(res['arch']) | ||
3969 | 48 | nodes = doc.xpath("//field[@name='lines']") | ||
3970 | 49 | for node in nodes: | ||
3971 | 50 | node.set('domain', domain) | ||
3972 | 51 | res['arch'] = etree.tostring(doc) | ||
3973 | 52 | return res | ||
3974 | 53 | |||
3975 | 54 | def populate_statement(self, cr, uid, ids, context=None): | ||
3976 | 55 | line_obj = self.pool.get('payment.line') | ||
3977 | 56 | statement_obj = self.pool.get('account.bank.statement') | ||
3978 | 57 | statement_line_obj = self.pool.get('account.bank.statement.line') | ||
3979 | 58 | currency_obj = self.pool.get('res.currency') | ||
3980 | 59 | voucher_obj = self.pool.get('account.voucher') | ||
3981 | 60 | voucher_line_obj = self.pool.get('account.voucher.line') | ||
3982 | 61 | move_line_obj = self.pool.get('account.move.line') | ||
3983 | 62 | |||
3984 | 63 | if context is None: | ||
3985 | 64 | context = {} | ||
3986 | 65 | data = self.read(cr, uid, ids, [], context=context)[0] | ||
3987 | 66 | line_ids = data['lines'] | ||
3988 | 67 | if not line_ids: | ||
3989 | 68 | return {'type': 'ir.actions.act_window_close'} | ||
3990 | 69 | |||
3991 | 70 | statement = statement_obj.browse(cr, uid, context['active_id'], context=context) | ||
3992 | 71 | |||
3993 | 72 | for line in line_obj.browse(cr, uid, line_ids, context=context): | ||
3994 | 73 | ctx = context.copy() | ||
3995 | 74 | ctx['date'] = line.ml_maturity_date # was value_date earlier,but this field exists no more now | ||
3996 | 75 | amount = currency_obj.compute(cr, uid, line.currency.id, | ||
3997 | 76 | statement.currency.id, line.amount_currency, context=ctx) | ||
3998 | 77 | |||
3999 | 78 | if not line.move_line_id.id: | ||
4000 | 79 | continue | ||
4001 | 80 | context.update({'move_line_ids': [line.move_line_id.id]}) | ||
4002 | 81 | result = voucher_obj.onchange_partner_id(cr, uid, [], partner_id=line.partner_id.id, journal_id=statement.journal_id.id, price=abs(amount), currency_id=statement.currency.id, ttype='payment', date=line.date, context=context) | ||
4003 | 82 | |||
4004 | 83 | voucher_res = { | ||
4005 | 84 | 'type': 'payment', | ||
4006 | 85 | 'name': line.name, | ||
4007 | 86 | 'partner_id': line.partner_id.id, | ||
4008 | 87 | 'journal_id': statement.journal_id.id, | ||
4009 | 88 | 'account_id': result.get('account_id', statement.journal_id.default_credit_account_id.id), | ||
4010 | 89 | 'company_id': statement.company_id.id, | ||
4011 | 90 | 'currency_id': statement.currency.id, | ||
4012 | 91 | 'date': line.date or time.strftime('%Y-%m-%d'), | ||
4013 | 92 | 'amount': abs(amount), | ||
4014 | 93 | 'period_id': statement.period_id.id | ||
4015 | 94 | } | ||
4016 | 95 | voucher_id = voucher_obj.create(cr, uid, voucher_res, context=context) | ||
4017 | 96 | voucher_line_dict = {} | ||
4018 | 97 | if result['value']['line_ids']: | ||
4019 | 98 | for line_dict in result['value']['line_ids']: | ||
4020 | 99 | move_line = move_line_obj.browse(cr, uid, line_dict['move_line_id'], context) | ||
4021 | 100 | if line.move_line_id.move_id.id == move_line.move_id.id: | ||
4022 | 101 | voucher_line_dict = line_dict | ||
4023 | 102 | if voucher_line_dict: | ||
4024 | 103 | voucher_line_dict.update({'voucher_id': voucher_id}) | ||
4025 | 104 | voucher_line_obj.create(cr, uid, voucher_line_dict, context=context) | ||
4026 | 105 | |||
4027 | 106 | st_line_id = statement_line_obj.create(cr, uid, { | ||
4028 | 107 | 'name': line.order_id.reference or '?', | ||
4029 | 108 | 'amount': - amount, | ||
4030 | 109 | 'type': 'supplier', | ||
4031 | 110 | 'partner_id': line.partner_id.id, | ||
4032 | 111 | 'account_id': line.move_line_id.account_id.id, | ||
4033 | 112 | 'statement_id': statement.id, | ||
4034 | 113 | 'ref': line.communication, | ||
4035 | 114 | 'voucher_id': voucher_id, | ||
4036 | 115 | }, context=context) | ||
4037 | 116 | |||
4038 | 117 | line_obj.write(cr, uid, [line.id], {'bank_statement_line_id': st_line_id}) | ||
4039 | 118 | return {'type': 'ir.actions.act_window_close'} | ||
4040 | 119 | |||
4041 | 120 | account_payment_populate_statement() | ||
4042 | 121 | |||
4043 | 122 | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: | ||
4044 | 123 | \ No newline at end of file | 0 | \ No newline at end of file |
4045 | 124 | 1 | ||
4046 | === removed file 'bin/addons/account_payment/wizard/account_payment_populate_statement_view.xml' | |||
4047 | --- bin/addons/account_payment/wizard/account_payment_populate_statement_view.xml 2011-01-14 00:11:01 +0000 | |||
4048 | +++ bin/addons/account_payment/wizard/account_payment_populate_statement_view.xml 1970-01-01 00:00:00 +0000 | |||
4049 | @@ -1,44 +0,0 @@ | |||
4050 | 1 | <?xml version="1.0" encoding="UTF-8"?> | ||
4051 | 2 | <openerp> | ||
4052 | 3 | <data> | ||
4053 | 4 | |||
4054 | 5 | <record id="account_payment_populate_statement_view" model="ir.ui.view"> | ||
4055 | 6 | <field name="name">Payment Populate statement</field> | ||
4056 | 7 | <field name="model">account.payment.populate.statement</field> | ||
4057 | 8 | <field name="type">form</field> | ||
4058 | 9 | <field name="arch" type="xml"> | ||
4059 | 10 | <form string="Populate Statement:"> | ||
4060 | 11 | <group colspan="4" col="6"> | ||
4061 | 12 | <field name="lines" colspan="4" height="300" width="800" nolabel="1" /> | ||
4062 | 13 | <separator colspan="6"/> | ||
4063 | 14 | <button special="cancel" string="Cancel" icon="gtk-cancel"/> | ||
4064 | 15 | <button name="populate_statement" string="ADD" type="object" icon="gtk-ok"/> | ||
4065 | 16 | </group> | ||
4066 | 17 | </form> | ||
4067 | 18 | </field> | ||
4068 | 19 | </record> | ||
4069 | 20 | |||
4070 | 21 | <record id="action_account_populate_statement_confirm" model="ir.actions.act_window"> | ||
4071 | 22 | <field name="name">Payment Populate statement</field> | ||
4072 | 23 | <field name="res_model">account.payment.populate.statement</field> | ||
4073 | 24 | <field name="type">ir.actions.act_window</field> | ||
4074 | 25 | <field name="view_type">form</field> | ||
4075 | 26 | <field name="view_mode">tree,form</field> | ||
4076 | 27 | <field name="view_id" ref="account_payment_populate_statement_view"/> | ||
4077 | 28 | <field name="context">{'record_id':active_id}</field> | ||
4078 | 29 | <field name="target">new</field> | ||
4079 | 30 | </record> | ||
4080 | 31 | |||
4081 | 32 | <record id="action_account_payment_populate_statement" model="ir.actions.act_window"> | ||
4082 | 33 | <field name="name">Payment Populate statement</field> | ||
4083 | 34 | <field name="res_model">account.payment.populate.statement</field> | ||
4084 | 35 | <field name="type">ir.actions.act_window</field> | ||
4085 | 36 | <field name="view_type">form</field> | ||
4086 | 37 | <field name="view_mode">tree,form</field> | ||
4087 | 38 | <field name="view_id" ref="account_payment_populate_statement_view"/> | ||
4088 | 39 | <field name="context">{'record_id':active_id}</field> | ||
4089 | 40 | <field name="target">new</field> | ||
4090 | 41 | </record> | ||
4091 | 42 | |||
4092 | 43 | </data> | ||
4093 | 44 | </openerp> | ||
4094 | 45 | \ No newline at end of file | 0 | \ No newline at end of file |
4095 | 46 | 1 | ||
4096 | === modified file 'bin/addons/account_period_closing_level/account_year_end_closing.py' | |||
4097 | --- bin/addons/account_period_closing_level/account_year_end_closing.py 2018-11-23 14:44:11 +0000 | |||
4098 | +++ bin/addons/account_period_closing_level/account_year_end_closing.py 2019-10-30 13:23:20 +0000 | |||
4099 | @@ -318,8 +318,8 @@ | |||
4100 | 318 | 'block_manual_currency_id': True, | 318 | 'block_manual_currency_id': True, |
4101 | 319 | 'company_id': cpy_rec.id, | 319 | 'company_id': cpy_rec.id, |
4102 | 320 | 'currency_id': ccy_id, | 320 | 'currency_id': ccy_id, |
4105 | 321 | 'date': posting_date, | 321 | 'date': last_day_fy, |
4106 | 322 | 'document_date': posting_date, | 322 | 'document_date': last_day_fy, |
4107 | 323 | 'instance_id': instance_rec.id, | 323 | 'instance_id': instance_rec.id, |
4108 | 324 | 'journal_id': journal_id, | 324 | 'journal_id': journal_id, |
4109 | 325 | 'name': name, | 325 | 'name': name, |
4110 | @@ -335,17 +335,18 @@ | |||
4111 | 335 | """ | 335 | """ |
4112 | 336 | name = 'Balance move to 0' | 336 | name = 'Balance move to 0' |
4113 | 337 | 337 | ||
4114 | 338 | # DONE: TEST JN => behavior unchanged (use of clearer date name for the source date) | ||
4115 | 338 | vals = { | 339 | vals = { |
4116 | 339 | 'account_id': account_id, | 340 | 'account_id': account_id, |
4117 | 340 | 'company_id': cpy_rec.id, | 341 | 'company_id': cpy_rec.id, |
4118 | 341 | 'currency_id': ccy_id, | 342 | 'currency_id': ccy_id, |
4121 | 342 | 'date': posting_date, | 343 | 'date': last_day_fy, |
4122 | 343 | 'document_date': posting_date, | 344 | 'document_date': last_day_fy, |
4123 | 344 | 'instance_id': instance_rec.id, | 345 | 'instance_id': instance_rec.id, |
4124 | 345 | 'journal_id': journal_id, | 346 | 'journal_id': journal_id, |
4125 | 346 | 'name': name, | 347 | 'name': name, |
4126 | 347 | 'period_id': period_id, | 348 | 'period_id': period_id, |
4128 | 348 | 'source_date': posting_date, | 349 | 'source_date': last_day_fy, |
4129 | 349 | 350 | ||
4130 | 350 | 'debit_currency': \ | 351 | 'debit_currency': \ |
4131 | 351 | balance_currency if balance_currency > 0. else 0., | 352 | balance_currency if balance_currency > 0. else 0., |
4132 | @@ -378,7 +379,7 @@ | |||
4133 | 378 | instance_rec.id, context=context) | 379 | instance_rec.id, context=context) |
4134 | 379 | 380 | ||
4135 | 380 | fy_year = self._get_fy_year(cr, uid, fy_rec, context=context) | 381 | fy_year = self._get_fy_year(cr, uid, fy_rec, context=context) |
4137 | 381 | posting_date = "%d-12-31" % (fy_year, ) | 382 | last_day_fy = "%d-12-31" % (fy_year, ) |
4138 | 382 | 383 | ||
4139 | 383 | journal_code = 'EOY' | 384 | journal_code = 'EOY' |
4140 | 384 | journal_id = self._get_journal(cr, uid, journal_code, context=context) | 385 | journal_id = self._get_journal(cr, uid, journal_code, context=context) |
4141 | @@ -593,8 +594,8 @@ | |||
4142 | 593 | 'block_manual_currency_id': True, | 594 | 'block_manual_currency_id': True, |
4143 | 594 | 'company_id': cpy_rec.id, | 595 | 'company_id': cpy_rec.id, |
4144 | 595 | 'currency_id': ccy_id, | 596 | 'currency_id': ccy_id, |
4147 | 596 | 'date': posting_date, | 597 | 'date': first_day_next_fy, |
4148 | 597 | 'document_date': posting_date, | 598 | 'document_date': first_day_next_fy, |
4149 | 598 | 'instance_id': instance_rec.id, | 599 | 'instance_id': instance_rec.id, |
4150 | 599 | 'journal_id': journal_id, | 600 | 'journal_id': journal_id, |
4151 | 600 | 'name': name, | 601 | 'name': name, |
4152 | @@ -611,17 +612,18 @@ | |||
4153 | 611 | """ | 612 | """ |
4154 | 612 | default_name = 'Balance report / Previous Fiscal Year' | 613 | default_name = 'Balance report / Previous Fiscal Year' |
4155 | 613 | 614 | ||
4156 | 615 | # DONE: TEST JN => behavior unchanged (use of clearer date name for the source date) | ||
4157 | 614 | vals = { | 616 | vals = { |
4158 | 615 | 'account_id': account_id, | 617 | 'account_id': account_id, |
4159 | 616 | 'company_id': cpy_rec.id, | 618 | 'company_id': cpy_rec.id, |
4160 | 617 | 'currency_id': ccy_id, | 619 | 'currency_id': ccy_id, |
4163 | 618 | 'date': posting_date, | 620 | 'date': first_day_next_fy, |
4164 | 619 | 'document_date': posting_date, | 621 | 'document_date': first_day_next_fy, |
4165 | 620 | 'instance_id': instance_rec.id, | 622 | 'instance_id': instance_rec.id, |
4166 | 621 | 'journal_id': journal_id, | 623 | 'journal_id': journal_id, |
4167 | 622 | 'name': name or default_name, | 624 | 'name': name or default_name, |
4168 | 623 | 'period_id': period_id, | 625 | 'period_id': period_id, |
4170 | 624 | 'source_date': posting_date, | 626 | 'source_date': first_day_next_fy, |
4171 | 625 | 627 | ||
4172 | 626 | 'debit_currency': \ | 628 | 'debit_currency': \ |
4173 | 627 | balance_currency if balance_currency > 0. else 0., | 629 | balance_currency if balance_currency > 0. else 0., |
4174 | @@ -664,7 +666,7 @@ | |||
4175 | 664 | 666 | ||
4176 | 665 | fy_year = self._get_fy_year(cr, uid, fy_rec, context=context) | 667 | fy_year = self._get_fy_year(cr, uid, fy_rec, context=context) |
4177 | 666 | next_fy_id = self._get_next_fy_id(cr, uid, fy_rec, context=context) | 668 | next_fy_id = self._get_next_fy_id(cr, uid, fy_rec, context=context) |
4179 | 667 | posting_date = "%d-01-01" % (fy_year + 1, ) | 669 | first_day_next_fy = "%d-01-01" % (fy_year + 1, ) |
4180 | 668 | 670 | ||
4181 | 669 | journal_code = 'IB' | 671 | journal_code = 'IB' |
4182 | 670 | journal_id = self._get_journal(cr, uid, journal_code, context=context) | 672 | journal_id = self._get_journal(cr, uid, journal_code, context=context) |
4183 | 671 | 673 | ||
4184 | === removed directory 'bin/addons/account_voucher' | |||
4185 | === removed file 'bin/addons/account_voucher/__init__.py' | |||
4186 | --- bin/addons/account_voucher/__init__.py 2011-01-14 00:11:01 +0000 | |||
4187 | +++ bin/addons/account_voucher/__init__.py 1970-01-01 00:00:00 +0000 | |||
4188 | @@ -1,27 +0,0 @@ | |||
4189 | 1 | # -*- coding: utf-8 -*- | ||
4190 | 2 | ############################################################################## | ||
4191 | 3 | # | ||
4192 | 4 | # OpenERP, Open Source Management Solution | ||
4193 | 5 | # Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>). | ||
4194 | 6 | # | ||
4195 | 7 | # This program is free software: you can redistribute it and/or modify | ||
4196 | 8 | # it under the terms of the GNU Affero General Public License as | ||
4197 | 9 | # published by the Free Software Foundation, either version 3 of the | ||
4198 | 10 | # License, or (at your option) any later version. | ||
4199 | 11 | # | ||
4200 | 12 | # This program is distributed in the hope that it will be useful, | ||
4201 | 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
4202 | 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
4203 | 15 | # GNU Affero General Public License for more details. | ||
4204 | 16 | # | ||
4205 | 17 | # You should have received a copy of the GNU Affero General Public License | ||
4206 | 18 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
4207 | 19 | # | ||
4208 | 20 | ############################################################################## | ||
4209 | 21 | |||
4210 | 22 | import account_voucher | ||
4211 | 23 | import invoice | ||
4212 | 24 | import report | ||
4213 | 25 | import wizard | ||
4214 | 26 | |||
4215 | 27 | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: | ||
4216 | 28 | \ No newline at end of file | 0 | \ No newline at end of file |
4217 | 29 | 1 | ||
4218 | === removed file 'bin/addons/account_voucher/__openerp__.py' | |||
4219 | --- bin/addons/account_voucher/__openerp__.py 2017-10-04 05:23:42 +0000 | |||
4220 | +++ bin/addons/account_voucher/__openerp__.py 1970-01-01 00:00:00 +0000 | |||
4221 | @@ -1,60 +0,0 @@ | |||
4222 | 1 | # -*- coding: utf-8 -*- | ||
4223 | 2 | ############################################################################## | ||
4224 | 3 | # | ||
4225 | 4 | # OpenERP, Open Source Management Solution | ||
4226 | 5 | # Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>). | ||
4227 | 6 | # | ||
4228 | 7 | # This program is free software: you can redistribute it and/or modify | ||
4229 | 8 | # it under the terms of the GNU Affero General Public License as | ||
4230 | 9 | # published by the Free Software Foundation, either version 3 of the | ||
4231 | 10 | # License, or (at your option) any later version. | ||
4232 | 11 | # | ||
4233 | 12 | # This program is distributed in the hope that it will be useful, | ||
4234 | 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
4235 | 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
4236 | 15 | # GNU Affero General Public License for more details. | ||
4237 | 16 | # | ||
4238 | 17 | # You should have received a copy of the GNU Affero General Public License | ||
4239 | 18 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
4240 | 19 | # | ||
4241 | 20 | ############################################################################## | ||
4242 | 21 | |||
4243 | 22 | { | ||
4244 | 23 | "name" : "Accounting Voucher Entries", | ||
4245 | 24 | "version" : "1.0", | ||
4246 | 25 | "author" : 'OpenERP SA', | ||
4247 | 26 | "description": """Account Voucher module includes all the basic requirements of | ||
4248 | 27 | Voucher Entries for Bank, Cash, Sales, Purchase, Expanse, Contra, etc... | ||
4249 | 28 | * Voucher Entry | ||
4250 | 29 | * Voucher Receipt | ||
4251 | 30 | * Cheque Register | ||
4252 | 31 | """, | ||
4253 | 32 | "category" : "Generic Modules/Accounting", | ||
4254 | 33 | "website" : "http://tinyerp.com", | ||
4255 | 34 | "depends" : ["account"], | ||
4256 | 35 | "init_xml" : [], | ||
4257 | 36 | |||
4258 | 37 | "demo_xml" : [], | ||
4259 | 38 | |||
4260 | 39 | "update_xml" : [ | ||
4261 | 40 | "security/ir.model.access.csv", | ||
4262 | 41 | "account_voucher_sequence.xml", | ||
4263 | 42 | "account_voucher_workflow.xml", | ||
4264 | 43 | "account_voucher_report.xml", | ||
4265 | 44 | "wizard/account_voucher_unreconcile_view.xml", | ||
4266 | 45 | "wizard/account_statement_from_invoice_view.xml", | ||
4267 | 46 | "account_voucher_view.xml", | ||
4268 | 47 | "voucher_payment_receipt_view.xml", | ||
4269 | 48 | "voucher_sales_purchase_view.xml", | ||
4270 | 49 | "account_voucher_wizard.xml", | ||
4271 | 50 | "report/account_voucher_sales_receipt_view.xml", | ||
4272 | 51 | "security/account_voucher_security.xml" | ||
4273 | 52 | ], | ||
4274 | 53 | "test" : [ | ||
4275 | 54 | ], | ||
4276 | 55 | 'certificate': '0037580727101', | ||
4277 | 56 | "active": False, | ||
4278 | 57 | "installable": True, | ||
4279 | 58 | } | ||
4280 | 59 | |||
4281 | 60 | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: | ||
4282 | 61 | 0 | ||
4283 | === removed file 'bin/addons/account_voucher/account_voucher.py' | |||
4284 | --- bin/addons/account_voucher/account_voucher.py 2012-06-20 14:19:49 +0000 | |||
4285 | +++ bin/addons/account_voucher/account_voucher.py 1970-01-01 00:00:00 +0000 | |||
4286 | @@ -1,1022 +0,0 @@ | |||
4287 | 1 | # -*- coding: utf-8 -*- | ||
4288 | 2 | ############################################################################## | ||
4289 | 3 | # | ||
4290 | 4 | # OpenERP, Open Source Management Solution | ||
4291 | 5 | # Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>). | ||
4292 | 6 | # | ||
4293 | 7 | # This program is free software: you can redistribute it and/or modify | ||
4294 | 8 | # it under the terms of the GNU Affero General Public License as | ||
4295 | 9 | # published by the Free Software Foundation, either version 3 of the | ||
4296 | 10 | # License, or (at your option) any later version. | ||
4297 | 11 | # | ||
4298 | 12 | # This program is distributed in the hope that it will be useful, | ||
4299 | 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
4300 | 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
4301 | 15 | # GNU Affero General Public License for more details. | ||
4302 | 16 | # | ||
4303 | 17 | # You should have received a copy of the GNU Affero General Public License | ||
4304 | 18 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
4305 | 19 | # | ||
4306 | 20 | ############################################################################## | ||
4307 | 21 | |||
4308 | 22 | import time | ||
4309 | 23 | from lxml import etree | ||
4310 | 24 | |||
4311 | 25 | import netsvc | ||
4312 | 26 | from osv import osv, fields | ||
4313 | 27 | import decimal_precision as dp | ||
4314 | 28 | from tools.translate import _ | ||
4315 | 29 | |||
4316 | 30 | |||
4317 | 31 | class account_voucher(osv.osv): | ||
4318 | 32 | |||
4319 | 33 | def _get_type(self, cr, uid, context=None): | ||
4320 | 34 | if context is None: | ||
4321 | 35 | context = {} | ||
4322 | 36 | return context.get('type', False) | ||
4323 | 37 | |||
4324 | 38 | def _get_period(self, cr, uid, context=None): | ||
4325 | 39 | if context is None: context = {} | ||
4326 | 40 | if context.get('period_id', False): | ||
4327 | 41 | return context.get('period_id') | ||
4328 | 42 | periods = self.pool.get('account.period').find(cr, uid) | ||
4329 | 43 | return periods and periods[0] or False | ||
4330 | 44 | |||
4331 | 45 | def _get_journal(self, cr, uid, context=None): | ||
4332 | 46 | if context is None: context = {} | ||
4333 | 47 | journal_pool = self.pool.get('account.journal') | ||
4334 | 48 | invoice_pool = self.pool.get('account.invoice') | ||
4335 | 49 | if context.get('invoice_id', False): | ||
4336 | 50 | currency_id = invoice_pool.browse(cr, uid, context['invoice_id'], context=context).currency_id.id | ||
4337 | 51 | journal_id = journal_pool.search(cr, uid, [('currency', '=', currency_id)], limit=1) | ||
4338 | 52 | return journal_id and journal_id[0] or False | ||
4339 | 53 | if context.get('journal_id', False): | ||
4340 | 54 | return context.get('journal_id') | ||
4341 | 55 | if not context.get('journal_id', False) and context.get('search_default_journal_id', False): | ||
4342 | 56 | return context.get('search_default_journal_id') | ||
4343 | 57 | |||
4344 | 58 | ttype = context.get('type', 'bank') | ||
4345 | 59 | if ttype in ('payment', 'receipt'): | ||
4346 | 60 | ttype = 'bank' | ||
4347 | 61 | res = journal_pool.search(cr, uid, [('type', '=', ttype)], limit=1) | ||
4348 | 62 | return res and res[0] or False | ||
4349 | 63 | |||
4350 | 64 | def _get_tax(self, cr, uid, context=None): | ||
4351 | 65 | if context is None: context = {} | ||
4352 | 66 | journal_pool = self.pool.get('account.journal') | ||
4353 | 67 | journal_id = context.get('journal_id', False) | ||
4354 | 68 | if not journal_id: | ||
4355 | 69 | ttype = context.get('type', 'bank') | ||
4356 | 70 | res = journal_pool.search(cr, uid, [('type', '=', ttype)], limit=1) | ||
4357 | 71 | if not res: | ||
4358 | 72 | return False | ||
4359 | 73 | journal_id = res[0] | ||
4360 | 74 | |||
4361 | 75 | if not journal_id: | ||
4362 | 76 | return False | ||
4363 | 77 | journal = journal_pool.browse(cr, uid, journal_id, context=context) | ||
4364 | 78 | account_id = journal.default_credit_account_id or journal.default_debit_account_id | ||
4365 | 79 | if account_id and account_id.tax_ids: | ||
4366 | 80 | tax_id = account_id.tax_ids[0].id | ||
4367 | 81 | return tax_id | ||
4368 | 82 | return False | ||
4369 | 83 | |||
4370 | 84 | def _get_currency(self, cr, uid, context=None): | ||
4371 | 85 | if context is None: context = {} | ||
4372 | 86 | journal_pool = self.pool.get('account.journal') | ||
4373 | 87 | journal_id = context.get('journal_id', False) | ||
4374 | 88 | if journal_id: | ||
4375 | 89 | journal = journal_pool.browse(cr, uid, journal_id, context=context) | ||
4376 | 90 | # currency_id = journal.company_id.currency_id.id | ||
4377 | 91 | if journal.currency: | ||
4378 | 92 | return journal.currency.id | ||
4379 | 93 | return False | ||
4380 | 94 | |||
4381 | 95 | def _get_partner(self, cr, uid, context=None): | ||
4382 | 96 | if context is None: context = {} | ||
4383 | 97 | return context.get('partner_id', False) | ||
4384 | 98 | |||
4385 | 99 | def _get_reference(self, cr, uid, context=None): | ||
4386 | 100 | if context is None: context = {} | ||
4387 | 101 | return context.get('reference', False) | ||
4388 | 102 | |||
4389 | 103 | def _get_narration(self, cr, uid, context=None): | ||
4390 | 104 | if context is None: context = {} | ||
4391 | 105 | return context.get('narration', False) | ||
4392 | 106 | |||
4393 | 107 | def _get_amount(self, cr, uid, context=None): | ||
4394 | 108 | if context is None: | ||
4395 | 109 | context= {} | ||
4396 | 110 | return context.get('amount', 0.0) | ||
4397 | 111 | |||
4398 | 112 | def name_get(self, cr, uid, ids, context=None): | ||
4399 | 113 | if not ids: | ||
4400 | 114 | return [] | ||
4401 | 115 | if context is None: context = {} | ||
4402 | 116 | return [(r['id'], (str("%.2f" % r['amount']) or '')) for r in self.read(cr, uid, ids, ['amount'], context, load='_classic_write')] | ||
4403 | 117 | |||
4404 | 118 | def fields_view_get(self, cr, uid, view_id=None, view_type=False, context=None, toolbar=False, submenu=False): | ||
4405 | 119 | mod_obj = self.pool.get('ir.model.data') | ||
4406 | 120 | if context is None: context = {} | ||
4407 | 121 | |||
4408 | 122 | def get_res_id(view_type, condition): | ||
4409 | 123 | result = False | ||
4410 | 124 | if view_type == 'tree': | ||
4411 | 125 | result = mod_obj.get_object_reference(cr, uid, 'account_voucher', 'view_voucher_tree') | ||
4412 | 126 | elif view_type == 'form': | ||
4413 | 127 | if condition: | ||
4414 | 128 | result = mod_obj.get_object_reference(cr, uid, 'account_voucher', 'view_vendor_receipt_form') | ||
4415 | 129 | else: | ||
4416 | 130 | result = mod_obj.get_object_reference(cr, uid, 'account_voucher', 'view_vendor_payment_form') | ||
4417 | 131 | return result and result[1] or False | ||
4418 | 132 | |||
4419 | 133 | if not view_id and context.get('invoice_type', False): | ||
4420 | 134 | view_id = get_res_id(view_type,context.get('invoice_type', False) in ('out_invoice', 'out_refund')) | ||
4421 | 135 | |||
4422 | 136 | if not view_id and context.get('line_type', False): | ||
4423 | 137 | view_id = get_res_id(view_type,context.get('line_type', False) == 'customer') | ||
4424 | 138 | |||
4425 | 139 | res = super(account_voucher, self).fields_view_get(cr, uid, view_id=view_id, view_type=view_type, context=context, toolbar=toolbar, submenu=submenu) | ||
4426 | 140 | doc = etree.XML(res['arch']) | ||
4427 | 141 | nodes = doc.xpath("//field[@name='partner_id']") | ||
4428 | 142 | if context.get('type', 'sale') in ('purchase', 'payment'): | ||
4429 | 143 | for node in nodes: | ||
4430 | 144 | node.set('domain', "[('supplier', '=', True)]") | ||
4431 | 145 | res['arch'] = etree.tostring(doc) | ||
4432 | 146 | return res | ||
4433 | 147 | |||
4434 | 148 | def _compute_writeoff_amount(self, cr, uid, line_dr_ids, line_cr_ids, amount): | ||
4435 | 149 | debit = credit = 0.0 | ||
4436 | 150 | for l in line_dr_ids: | ||
4437 | 151 | debit += l['amount'] | ||
4438 | 152 | for l in line_cr_ids: | ||
4439 | 153 | credit += l['amount'] | ||
4440 | 154 | return abs(amount - abs(credit - debit)) | ||
4441 | 155 | |||
4442 | 156 | def onchange_line_ids(self, cr, uid, ids, line_dr_ids, line_cr_ids, amount): | ||
4443 | 157 | if not line_dr_ids and not line_cr_ids: | ||
4444 | 158 | return {'value':{}} | ||
4445 | 159 | line_dr_ids = [x[2] for x in line_dr_ids] | ||
4446 | 160 | line_cr_ids = [x[2] for x in line_cr_ids] | ||
4447 | 161 | return {'value': {'writeoff_amount': self._compute_writeoff_amount(cr, uid, line_dr_ids, line_cr_ids, amount)}} | ||
4448 | 162 | |||
4449 | 163 | def _get_writeoff_amount(self, cr, uid, ids, name, args, context=None): | ||
4450 | 164 | if not ids: return {} | ||
4451 | 165 | res = {} | ||
4452 | 166 | debit = credit = 0.0 | ||
4453 | 167 | for voucher in self.browse(cr, uid, ids, context=context): | ||
4454 | 168 | for l in voucher.line_dr_ids: | ||
4455 | 169 | debit += l.amount | ||
4456 | 170 | for l in voucher.line_cr_ids: | ||
4457 | 171 | credit += l.amount | ||
4458 | 172 | res[voucher.id] = abs(voucher.amount - abs(credit - debit)) | ||
4459 | 173 | return res | ||
4460 | 174 | |||
4461 | 175 | _name = 'account.voucher' | ||
4462 | 176 | _description = 'Accounting Voucher' | ||
4463 | 177 | _order = "date desc, id desc" | ||
4464 | 178 | # _rec_name = 'number' | ||
4465 | 179 | _columns = { | ||
4466 | 180 | 'type':fields.selection([ | ||
4467 | 181 | ('sale','Sale'), | ||
4468 | 182 | ('purchase','Purchase'), | ||
4469 | 183 | ('payment','Payment'), | ||
4470 | 184 | ('receipt','Receipt'), | ||
4471 | 185 | ],'Default Type', readonly=True, states={'draft':[('readonly',False)]}), | ||
4472 | 186 | 'name':fields.char('Memo', size=256, readonly=True, states={'draft':[('readonly',False)]}), | ||
4473 | 187 | 'date':fields.date('Date', readonly=True, select=True, states={'draft':[('readonly',False)]}, help="Effective date for accounting entries"), | ||
4474 | 188 | 'journal_id':fields.many2one('account.journal', 'Journal', required=True, readonly=True, states={'draft':[('readonly',False)]}), | ||
4475 | 189 | 'account_id':fields.many2one('account.account', 'Account', required=True, readonly=True, states={'draft':[('readonly',False)]}), | ||
4476 | 190 | 'line_ids':fields.one2many('account.voucher.line','voucher_id','Voucher Lines', readonly=True, states={'draft':[('readonly',False)]}), | ||
4477 | 191 | 'line_cr_ids':fields.one2many('account.voucher.line','voucher_id','Credits', | ||
4478 | 192 | domain=[('type','=','cr')], context={'default_type':'cr'}, readonly=True, states={'draft':[('readonly',False)]}), | ||
4479 | 193 | 'line_dr_ids':fields.one2many('account.voucher.line','voucher_id','Debits', | ||
4480 | 194 | domain=[('type','=','dr')], context={'default_type':'dr'}, readonly=True, states={'draft':[('readonly',False)]}), | ||
4481 | 195 | 'period_id': fields.many2one('account.period', 'Period', required=True, readonly=True, states={'draft':[('readonly',False)]}), | ||
4482 | 196 | 'narration':fields.text('Notes', readonly=True, states={'draft':[('readonly',False)]}), | ||
4483 | 197 | 'currency_id':fields.many2one('res.currency', 'Currency', readonly=True, states={'draft':[('readonly',False)]}), | ||
4484 | 198 | # 'currency_id': fields.related('journal_id','currency', type='many2one', relation='res.currency', string='Currency', store=True, readonly=True, states={'draft':[('readonly',False)]}), | ||
4485 | 199 | 'company_id': fields.many2one('res.company', 'Company', required=True, readonly=True, states={'draft':[('readonly',False)]}), | ||
4486 | 200 | 'state':fields.selection( | ||
4487 | 201 | [('draft','Draft'), | ||
4488 | 202 | ('proforma','Pro-forma'), | ||
4489 | 203 | ('posted','Posted'), | ||
4490 | 204 | ('cancel','Cancelled') | ||
4491 | 205 | ], 'State', readonly=True, size=32, | ||
4492 | 206 | help=' * The \'Draft\' state is used when a user is encoding a new and unconfirmed Voucher. \ | ||
4493 | 207 | \n* The \'Pro-forma\' when voucher is in Pro-forma state,voucher does not have an voucher number. \ | ||
4494 | 208 | \n* The \'Posted\' state is used when user create voucher,a voucher number is generated and voucher entries are created in account \ | ||
4495 | 209 | \n* The \'Cancelled\' state is used when user cancel voucher.'), | ||
4496 | 210 | 'amount': fields.float('Total', digits_compute=dp.get_precision('Account'), required=True, readonly=True, states={'draft':[('readonly',False)]}), | ||
4497 | 211 | 'tax_amount':fields.float('Tax Amount', digits_compute=dp.get_precision('Account'), readonly=True, states={'draft':[('readonly',False)]}), | ||
4498 | 212 | 'reference': fields.char('Ref #', size=64, readonly=True, states={'draft':[('readonly',False)]}, help="Transaction reference number."), | ||
4499 | 213 | 'number': fields.char('Number', size=32, readonly=True,), | ||
4500 | 214 | 'move_id':fields.many2one('account.move', 'Account Entry'), | ||
4501 | 215 | 'move_ids': fields.related('move_id','line_id', type='one2many', relation='account.move.line', string='Journal Items', readonly=True), | ||
4502 | 216 | 'partner_id':fields.many2one('res.partner', 'Partner', change_default=1, readonly=True, states={'draft':[('readonly',False)]}), | ||
4503 | 217 | 'audit': fields.related('move_id','to_check', type='boolean', relation='account.move', string='Audit Complete ?'), | ||
4504 | 218 | 'pay_now':fields.selection([ | ||
4505 | 219 | ('pay_now','Pay Directly'), | ||
4506 | 220 | ('pay_later','Pay Later or Group Funds'), | ||
4507 | 221 | ],'Payment', select=True, readonly=True, states={'draft':[('readonly',False)]}), | ||
4508 | 222 | 'tax_id':fields.many2one('account.tax', 'Tax', readonly=True, states={'draft':[('readonly',False)]}), | ||
4509 | 223 | 'pre_line':fields.boolean('Previous Payments ?', required=False), | ||
4510 | 224 | 'date_due': fields.date('Due Date', readonly=True, select=True, states={'draft':[('readonly',False)]}), | ||
4511 | 225 | 'payment_option':fields.selection([ | ||
4512 | 226 | ('without_writeoff', 'Keep Open'), | ||
4513 | 227 | ('with_writeoff', 'Reconcile with Write-Off'), | ||
4514 | 228 | ], 'Payment Difference', required=True, readonly=True, states={'draft': [('readonly', False)]}), | ||
4515 | 229 | 'writeoff_acc_id': fields.many2one('account.account', 'Write-Off account', readonly=True, states={'draft': [('readonly', False)]}), | ||
4516 | 230 | 'comment': fields.char('Write-Off Comment', size=64, required=True, readonly=True, states={'draft': [('readonly', False)]}), | ||
4517 | 231 | 'analytic_id': fields.many2one('account.analytic.account','Write-Off Analytic Account', readonly=True, states={'draft': [('readonly', False)]}), | ||
4518 | 232 | 'writeoff_amount': fields.function(_get_writeoff_amount, method=True, string='Write-Off Amount', type='float', readonly=True), | ||
4519 | 233 | } | ||
4520 | 234 | _defaults = { | ||
4521 | 235 | 'period_id': _get_period, | ||
4522 | 236 | 'partner_id': _get_partner, | ||
4523 | 237 | 'journal_id':_get_journal, | ||
4524 | 238 | 'currency_id': _get_currency, | ||
4525 | 239 | 'reference': _get_reference, | ||
4526 | 240 | 'narration':_get_narration, | ||
4527 | 241 | 'amount': _get_amount, | ||
4528 | 242 | 'type':_get_type, | ||
4529 | 243 | 'state': 'draft', | ||
4530 | 244 | 'pay_now': 'pay_later', | ||
4531 | 245 | 'name': '', | ||
4532 | 246 | 'date': lambda *a: time.strftime('%Y-%m-%d'), | ||
4533 | 247 | 'company_id': lambda self,cr,uid,c: self.pool.get('res.company')._company_default_get(cr, uid, 'account.voucher',context=c), | ||
4534 | 248 | 'tax_id': _get_tax, | ||
4535 | 249 | 'payment_option': 'without_writeoff', | ||
4536 | 250 | 'comment': _('Write-Off'), | ||
4537 | 251 | } | ||
4538 | 252 | |||
4539 | 253 | def compute_tax(self, cr, uid, ids, context=None): | ||
4540 | 254 | tax_pool = self.pool.get('account.tax') | ||
4541 | 255 | partner_pool = self.pool.get('res.partner') | ||
4542 | 256 | position_pool = self.pool.get('account.fiscal.position') | ||
4543 | 257 | voucher_line_pool = self.pool.get('account.voucher.line') | ||
4544 | 258 | voucher_pool = self.pool.get('account.voucher') | ||
4545 | 259 | if context is None: context = {} | ||
4546 | 260 | |||
4547 | 261 | for voucher in voucher_pool.browse(cr, uid, ids, context=context): | ||
4548 | 262 | voucher_amount = 0.0 | ||
4549 | 263 | for line in voucher.line_ids: | ||
4550 | 264 | voucher_amount += line.untax_amount or line.amount | ||
4551 | 265 | line.amount = line.untax_amount or line.amount | ||
4552 | 266 | voucher_line_pool.write(cr, uid, [line.id], {'amount':line.amount, 'untax_amount':line.untax_amount}) | ||
4553 | 267 | |||
4554 | 268 | if not voucher.tax_id: | ||
4555 | 269 | self.write(cr, uid, [voucher.id], {'amount':voucher_amount, 'tax_amount':0.0}) | ||
4556 | 270 | continue | ||
4557 | 271 | |||
4558 | 272 | tax = [tax_pool.browse(cr, uid, voucher.tax_id.id, context=context)] | ||
4559 | 273 | partner = partner_pool.browse(cr, uid, voucher.partner_id.id, context=context) or False | ||
4560 | 274 | taxes = position_pool.map_tax(cr, uid, partner and partner.property_account_position or False, tax) | ||
4561 | 275 | tax = tax_pool.browse(cr, uid, taxes, context=context) | ||
4562 | 276 | |||
4563 | 277 | total = voucher_amount | ||
4564 | 278 | total_tax = 0.0 | ||
4565 | 279 | |||
4566 | 280 | if not tax[0].price_include: | ||
4567 | 281 | for tax_line in tax_pool.compute_all(cr, uid, tax, voucher_amount, 1).get('taxes', []): | ||
4568 | 282 | total_tax += tax_line.get('amount', 0.0) | ||
4569 | 283 | total += total_tax | ||
4570 | 284 | else: | ||
4571 | 285 | for line in voucher.line_ids: | ||
4572 | 286 | line_total = 0.0 | ||
4573 | 287 | line_tax = 0.0 | ||
4574 | 288 | |||
4575 | 289 | for tax_line in tax_pool.compute_all(cr, uid, tax, line.untax_amount or line.amount, 1).get('taxes', []): | ||
4576 | 290 | line_tax += tax_line.get('amount', 0.0) | ||
4577 | 291 | line_total += tax_line.get('price_unit') | ||
4578 | 292 | total_tax += line_tax | ||
4579 | 293 | untax_amount = line.untax_amount or line.amount | ||
4580 | 294 | voucher_line_pool.write(cr, uid, [line.id], {'amount':line_total, 'untax_amount':untax_amount}) | ||
4581 | 295 | |||
4582 | 296 | self.write(cr, uid, [voucher.id], {'amount':total, 'tax_amount':total_tax}) | ||
4583 | 297 | return True | ||
4584 | 298 | |||
4585 | 299 | def onchange_price(self, cr, uid, ids, line_ids, tax_id, partner_id=False, context=None): | ||
4586 | 300 | tax_pool = self.pool.get('account.tax') | ||
4587 | 301 | partner_pool = self.pool.get('res.partner') | ||
4588 | 302 | position_pool = self.pool.get('account.fiscal.position') | ||
4589 | 303 | res = { | ||
4590 | 304 | 'tax_amount': False, | ||
4591 | 305 | 'amount': False, | ||
4592 | 306 | } | ||
4593 | 307 | voucher_total = 0.0 | ||
4594 | 308 | voucher_line_ids = [] | ||
4595 | 309 | |||
4596 | 310 | total = 0.0 | ||
4597 | 311 | total_tax = 0.0 | ||
4598 | 312 | for line in line_ids: | ||
4599 | 313 | line_amount = 0.0 | ||
4600 | 314 | line_amount = line[2] and line[2].get('amount',0.0) or 0.0 | ||
4601 | 315 | voucher_line_ids += [line[1]] | ||
4602 | 316 | voucher_total += line_amount | ||
4603 | 317 | |||
4604 | 318 | total = voucher_total | ||
4605 | 319 | total_tax = 0.0 | ||
4606 | 320 | if tax_id: | ||
4607 | 321 | tax = [tax_pool.browse(cr, uid, tax_id, context=context)] | ||
4608 | 322 | if partner_id: | ||
4609 | 323 | partner = partner_pool.browse(cr, uid, partner_id, context=context) or False | ||
4610 | 324 | taxes = position_pool.map_tax(cr, uid, partner and partner.property_account_position or False, tax) | ||
4611 | 325 | tax = tax_pool.browse(cr, uid, taxes, context=context) | ||
4612 | 326 | |||
4613 | 327 | if not tax[0].price_include: | ||
4614 | 328 | for tax_line in tax_pool.compute_all(cr, uid, tax, voucher_total, 1).get('taxes', []): | ||
4615 | 329 | total_tax += tax_line.get('amount') | ||
4616 | 330 | total += total_tax | ||
4617 | 331 | |||
4618 | 332 | res.update({ | ||
4619 | 333 | 'amount':total or voucher_total, | ||
4620 | 334 | 'tax_amount':total_tax | ||
4621 | 335 | }) | ||
4622 | 336 | return { | ||
4623 | 337 | 'value':res | ||
4624 | 338 | } | ||
4625 | 339 | |||
4626 | 340 | def onchange_term_id(self, cr, uid, ids, term_id, amount): | ||
4627 | 341 | term_pool = self.pool.get('account.payment.term') | ||
4628 | 342 | terms = False | ||
4629 | 343 | due_date = False | ||
4630 | 344 | default = {'date_due':False} | ||
4631 | 345 | if term_id and amount: | ||
4632 | 346 | terms = term_pool.compute(cr, uid, term_id, amount) | ||
4633 | 347 | if terms: | ||
4634 | 348 | due_date = terms[-1][0] | ||
4635 | 349 | default.update({ | ||
4636 | 350 | 'date_due':due_date | ||
4637 | 351 | }) | ||
4638 | 352 | return {'value':default} | ||
4639 | 353 | |||
4640 | 354 | def onchange_journal_voucher(self, cr, uid, ids, line_ids=False, tax_id=False, price=0.0, partner_id=False, journal_id=False, ttype=False, context=None): | ||
4641 | 355 | """price | ||
4642 | 356 | Returns a dict that contains new values and context | ||
4643 | 357 | |||
4644 | 358 | @param partner_id: latest value from user input for field partner_id | ||
4645 | 359 | @param args: other arguments | ||
4646 | 360 | @param context: context arguments, like lang, time zone | ||
4647 | 361 | |||
4648 | 362 | @return: Returns a dict which contains new values, and context | ||
4649 | 363 | """ | ||
4650 | 364 | default = { | ||
4651 | 365 | 'value':{}, | ||
4652 | 366 | } | ||
4653 | 367 | |||
4654 | 368 | if not partner_id or not journal_id: | ||
4655 | 369 | return default | ||
4656 | 370 | |||
4657 | 371 | partner_pool = self.pool.get('res.partner') | ||
4658 | 372 | journal_pool = self.pool.get('account.journal') | ||
4659 | 373 | |||
4660 | 374 | journal = journal_pool.browse(cr, uid, journal_id, context=context) | ||
4661 | 375 | partner = partner_pool.browse(cr, uid, partner_id, context=context) | ||
4662 | 376 | account_id = False | ||
4663 | 377 | tr_type = False | ||
4664 | 378 | if journal.type in ('sale','sale_refund'): | ||
4665 | 379 | account_id = partner.property_account_receivable.id | ||
4666 | 380 | tr_type = 'sale' | ||
4667 | 381 | elif journal.type in ('purchase', 'purchase_refund','expense'): | ||
4668 | 382 | account_id = partner.property_account_payable.id | ||
4669 | 383 | tr_type = 'purchase' | ||
4670 | 384 | else: | ||
4671 | 385 | account_id = journal.default_credit_account_id.id or journal.default_debit_account_id.id | ||
4672 | 386 | tr_type = 'receipt' | ||
4673 | 387 | |||
4674 | 388 | default['value']['account_id'] = account_id | ||
4675 | 389 | default['value']['type'] = ttype or tr_type | ||
4676 | 390 | |||
4677 | 391 | vals = self.onchange_journal(cr, uid, ids, journal_id, line_ids, tax_id, partner_id, context) | ||
4678 | 392 | default['value'].update(vals.get('value')) | ||
4679 | 393 | |||
4680 | 394 | return default | ||
4681 | 395 | |||
4682 | 396 | def onchange_partner_id(self, cr, uid, ids, partner_id, journal_id, price, currency_id, ttype, date, context=None): | ||
4683 | 397 | """price | ||
4684 | 398 | Returns a dict that contains new values and context | ||
4685 | 399 | |||
4686 | 400 | @param partner_id: latest value from user input for field partner_id | ||
4687 | 401 | @param args: other arguments | ||
4688 | 402 | @param context: context arguments, like lang, time zone | ||
4689 | 403 | |||
4690 | 404 | @return: Returns a dict which contains new values, and context | ||
4691 | 405 | """ | ||
4692 | 406 | if context is None: | ||
4693 | 407 | context = {} | ||
4694 | 408 | if not journal_id: | ||
4695 | 409 | return {} | ||
4696 | 410 | context_multi_currency = context.copy() | ||
4697 | 411 | if date: | ||
4698 | 412 | context_multi_currency.update({'date': date}) | ||
4699 | 413 | |||
4700 | 414 | line_pool = self.pool.get('account.voucher.line') | ||
4701 | 415 | line_ids = ids and line_pool.search(cr, uid, [('voucher_id', '=', ids[0])]) or False | ||
4702 | 416 | if line_ids: | ||
4703 | 417 | line_pool.unlink(cr, uid, line_ids) | ||
4704 | 418 | |||
4705 | 419 | currency_pool = self.pool.get('res.currency') | ||
4706 | 420 | move_line_pool = self.pool.get('account.move.line') | ||
4707 | 421 | partner_pool = self.pool.get('res.partner') | ||
4708 | 422 | journal_pool = self.pool.get('account.journal') | ||
4709 | 423 | |||
4710 | 424 | vals = self.onchange_journal(cr, uid, ids, journal_id, [], False, partner_id, context) | ||
4711 | 425 | vals = vals.get('value') | ||
4712 | 426 | currency_id = vals.get('currency_id', currency_id) | ||
4713 | 427 | default = { | ||
4714 | 428 | 'value':{'line_ids':[], 'line_dr_ids':[], 'line_cr_ids':[], 'pre_line': False, 'currency_id':currency_id}, | ||
4715 | 429 | } | ||
4716 | 430 | |||
4717 | 431 | if not partner_id: | ||
4718 | 432 | return default | ||
4719 | 433 | |||
4720 | 434 | if not partner_id and ids: | ||
4721 | 435 | line_ids = line_pool.search(cr, uid, [('voucher_id', '=', ids[0])]) | ||
4722 | 436 | if line_ids: | ||
4723 | 437 | line_pool.unlink(cr, uid, line_ids) | ||
4724 | 438 | return default | ||
4725 | 439 | |||
4726 | 440 | journal = journal_pool.browse(cr, uid, journal_id, context=context) | ||
4727 | 441 | partner = partner_pool.browse(cr, uid, partner_id, context=context) | ||
4728 | 442 | account_id = False | ||
4729 | 443 | if journal.type in ('sale','sale_refund'): | ||
4730 | 444 | account_id = partner.property_account_receivable.id | ||
4731 | 445 | elif journal.type in ('purchase', 'purchase_refund','expense'): | ||
4732 | 446 | account_id = partner.property_account_payable.id | ||
4733 | 447 | else: | ||
4734 | 448 | account_id = journal.default_credit_account_id.id or journal.default_debit_account_id.id | ||
4735 | 449 | |||
4736 | 450 | default['value']['account_id'] = account_id | ||
4737 | 451 | |||
4738 | 452 | if journal.type not in ('cash', 'bank'): | ||
4739 | 453 | return default | ||
4740 | 454 | |||
4741 | 455 | total_credit = 0.0 | ||
4742 | 456 | total_debit = 0.0 | ||
4743 | 457 | account_type = 'receivable' | ||
4744 | 458 | if ttype == 'payment': | ||
4745 | 459 | account_type = 'payable' | ||
4746 | 460 | total_debit = price or 0.0 | ||
4747 | 461 | else: | ||
4748 | 462 | total_credit = price or 0.0 | ||
4749 | 463 | account_type = 'receivable' | ||
4750 | 464 | |||
4751 | 465 | if not context.get('move_line_ids', False): | ||
4752 | 466 | domain = [('state','=','valid'), ('account_id.type', '=', account_type), ('reconcile_id', '=', False), ('partner_id', '=', partner_id)] | ||
4753 | 467 | if context.get('invoice_id', False): | ||
4754 | 468 | domain.append(('invoice', '=', context['invoice_id'])) | ||
4755 | 469 | ids = move_line_pool.search(cr, uid, domain, context=context) | ||
4756 | 470 | else: | ||
4757 | 471 | ids = context['move_line_ids'] | ||
4758 | 472 | ids.reverse() | ||
4759 | 473 | moves = move_line_pool.browse(cr, uid, ids, context=context) | ||
4760 | 474 | |||
4761 | 475 | company_currency = journal.company_id.currency_id.id | ||
4762 | 476 | if company_currency != currency_id and ttype == 'payment': | ||
4763 | 477 | total_debit = currency_pool.compute(cr, uid, currency_id, company_currency, total_debit, context=context_multi_currency) | ||
4764 | 478 | elif company_currency != currency_id and ttype == 'receipt': | ||
4765 | 479 | total_credit = currency_pool.compute(cr, uid, currency_id, company_currency, total_credit, context=context_multi_currency) | ||
4766 | 480 | |||
4767 | 481 | for line in moves: | ||
4768 | 482 | if line.credit and line.reconcile_partial_id and ttype == 'receipt': | ||
4769 | 483 | continue | ||
4770 | 484 | if line.debit and line.reconcile_partial_id and ttype == 'payment': | ||
4771 | 485 | continue | ||
4772 | 486 | total_credit += line.credit or 0.0 | ||
4773 | 487 | total_debit += line.debit or 0.0 | ||
4774 | 488 | for line in moves: | ||
4775 | 489 | if line.credit and line.reconcile_partial_id and ttype == 'receipt': | ||
4776 | 490 | continue | ||
4777 | 491 | if line.debit and line.reconcile_partial_id and ttype == 'payment': | ||
4778 | 492 | continue | ||
4779 | 493 | original_amount = line.credit or line.debit or 0.0 | ||
4780 | 494 | amount_unreconciled = currency_pool.compute(cr, uid, line.currency_id and line.currency_id.id or company_currency, currency_id, abs(line.amount_residual_currency), context=context_multi_currency) | ||
4781 | 495 | rs = { | ||
4782 | 496 | 'name':line.move_id.name, | ||
4783 | 497 | 'type': line.credit and 'dr' or 'cr', | ||
4784 | 498 | 'move_line_id':line.id, | ||
4785 | 499 | 'account_id':line.account_id.id, | ||
4786 | 500 | 'amount_original': currency_pool.compute(cr, uid, line.currency_id and line.currency_id.id or company_currency, currency_id, line.currency_id and abs(line.amount_currency) or original_amount, context=context_multi_currency), | ||
4787 | 501 | 'date_original':line.date, | ||
4788 | 502 | 'date_due':line.date_maturity, | ||
4789 | 503 | 'amount_unreconciled': amount_unreconciled, | ||
4790 | 504 | } | ||
4791 | 505 | |||
4792 | 506 | if line.credit: | ||
4793 | 507 | amount = min(amount_unreconciled, currency_pool.compute(cr, uid, company_currency, currency_id, abs(total_debit), context=context_multi_currency)) | ||
4794 | 508 | rs['amount'] = amount | ||
4795 | 509 | total_debit -= amount | ||
4796 | 510 | else: | ||
4797 | 511 | amount = min(amount_unreconciled, currency_pool.compute(cr, uid, company_currency, currency_id, abs(total_credit), context=context_multi_currency)) | ||
4798 | 512 | rs['amount'] = amount | ||
4799 | 513 | total_credit -= amount | ||
4800 | 514 | |||
4801 | 515 | default['value']['line_ids'].append(rs) | ||
4802 | 516 | if rs['type'] == 'cr': | ||
4803 | 517 | default['value']['line_cr_ids'].append(rs) | ||
4804 | 518 | else: | ||
4805 | 519 | default['value']['line_dr_ids'].append(rs) | ||
4806 | 520 | |||
4807 | 521 | if ttype == 'payment' and len(default['value']['line_cr_ids']) > 0: | ||
4808 | 522 | default['value']['pre_line'] = 1 | ||
4809 | 523 | elif ttype == 'receipt' and len(default['value']['line_dr_ids']) > 0: | ||
4810 | 524 | default['value']['pre_line'] = 1 | ||
4811 | 525 | default['value']['writeoff_amount'] = self._compute_writeoff_amount(cr, uid, default['value']['line_dr_ids'], default['value']['line_cr_ids'], price) | ||
4812 | 526 | |||
4813 | 527 | return default | ||
4814 | 528 | |||
4815 | 529 | def onchange_date(self, cr, uid, ids, partner_id, journal_id, price, currency_id, ttype, date, context=None): | ||
4816 | 530 | """ | ||
4817 | 531 | @param date: latest value from user input for field date | ||
4818 | 532 | @param args: other arguments | ||
4819 | 533 | @param context: context arguments, like lang, time zone | ||
4820 | 534 | @return: Returns a dict which contains new values, and context | ||
4821 | 535 | """ | ||
4822 | 536 | period_pool = self.pool.get('account.period') | ||
4823 | 537 | res = self.onchange_partner_id(cr, uid, ids, partner_id, journal_id, price, currency_id, ttype, date, context=context) | ||
4824 | 538 | pids = period_pool.search(cr, uid, [('date_start', '<=', date), ('date_stop', '>=', date)]) | ||
4825 | 539 | if pids: | ||
4826 | 540 | if not 'value' in res: | ||
4827 | 541 | res['value'] = {} | ||
4828 | 542 | res['value'].update({'period_id':pids[0]}) | ||
4829 | 543 | return res | ||
4830 | 544 | |||
4831 | 545 | def onchange_journal(self, cr, uid, ids, journal_id, line_ids, tax_id, partner_id, context=None): | ||
4832 | 546 | if not journal_id: | ||
4833 | 547 | return False | ||
4834 | 548 | journal_pool = self.pool.get('account.journal') | ||
4835 | 549 | journal = journal_pool.browse(cr, uid, journal_id, context=context) | ||
4836 | 550 | account_id = journal.default_credit_account_id or journal.default_debit_account_id | ||
4837 | 551 | tax_id = False | ||
4838 | 552 | if account_id and account_id.tax_ids: | ||
4839 | 553 | tax_id = account_id.tax_ids[0].id | ||
4840 | 554 | |||
4841 | 555 | vals = self.onchange_price(cr, uid, ids, line_ids, tax_id, partner_id, context) | ||
4842 | 556 | vals['value'].update({'tax_id':tax_id}) | ||
4843 | 557 | currency_id = journal.company_id.currency_id.id | ||
4844 | 558 | if journal.currency: | ||
4845 | 559 | currency_id = journal.currency.id | ||
4846 | 560 | vals['value'].update({'currency_id':currency_id}) | ||
4847 | 561 | return vals | ||
4848 | 562 | |||
4849 | 563 | def proforma_voucher(self, cr, uid, ids, context=None): | ||
4850 | 564 | self.action_move_line_create(cr, uid, ids, context=context) | ||
4851 | 565 | return True | ||
4852 | 566 | |||
4853 | 567 | def action_cancel_draft(self, cr, uid, ids, context=None): | ||
4854 | 568 | wf_service = netsvc.LocalService("workflow") | ||
4855 | 569 | for voucher_id in ids: | ||
4856 | 570 | wf_service.trg_create(uid, 'account.voucher', voucher_id, cr) | ||
4857 | 571 | self.write(cr, uid, ids, {'state':'draft'}) | ||
4858 | 572 | return True | ||
4859 | 573 | |||
4860 | 574 | def cancel_voucher(self, cr, uid, ids, context=None): | ||
4861 | 575 | reconcile_pool = self.pool.get('account.move.reconcile') | ||
4862 | 576 | move_pool = self.pool.get('account.move') | ||
4863 | 577 | |||
4864 | 578 | for voucher in self.browse(cr, uid, ids, context=context): | ||
4865 | 579 | recs = [] | ||
4866 | 580 | for line in voucher.move_ids: | ||
4867 | 581 | if line.reconcile_id: | ||
4868 | 582 | recs += [line.reconcile_id.id] | ||
4869 | 583 | if line.reconcile_partial_id: | ||
4870 | 584 | recs += [line.reconcile_partial_id.id] | ||
4871 | 585 | |||
4872 | 586 | reconcile_pool.unlink(cr, uid, recs) | ||
4873 | 587 | |||
4874 | 588 | if voucher.move_id: | ||
4875 | 589 | move_pool.button_cancel(cr, uid, [voucher.move_id.id]) | ||
4876 | 590 | move_pool.unlink(cr, uid, [voucher.move_id.id]) | ||
4877 | 591 | res = { | ||
4878 | 592 | 'state':'cancel', | ||
4879 | 593 | 'move_id':False, | ||
4880 | 594 | } | ||
4881 | 595 | self.write(cr, uid, ids, res) | ||
4882 | 596 | return True | ||
4883 | 597 | |||
4884 | 598 | def unlink(self, cr, uid, ids, context=None): | ||
4885 | 599 | for t in self.read(cr, uid, ids, ['state'], context=context): | ||
4886 | 600 | if t['state'] not in ('draft', 'cancel'): | ||
4887 | 601 | raise osv.except_osv(_('Invalid action !'), _('Cannot delete Voucher(s) which are already opened or paid !')) | ||
4888 | 602 | return super(account_voucher, self).unlink(cr, uid, ids, context=context) | ||
4889 | 603 | |||
4890 | 604 | # TODO: may be we can remove this method if not used anyware | ||
4891 | 605 | def onchange_payment(self, cr, uid, ids, pay_now, journal_id, partner_id, ttype='sale'): | ||
4892 | 606 | res = {} | ||
4893 | 607 | if not partner_id: | ||
4894 | 608 | return res | ||
4895 | 609 | res = {'account_id':False} | ||
4896 | 610 | partner_pool = self.pool.get('res.partner') | ||
4897 | 611 | journal_pool = self.pool.get('account.journal') | ||
4898 | 612 | if pay_now == 'pay_later': | ||
4899 | 613 | partner = partner_pool.browse(cr, uid, partner_id) | ||
4900 | 614 | journal = journal_pool.browse(cr, uid, journal_id) | ||
4901 | 615 | if journal.type in ('sale','sale_refund'): | ||
4902 | 616 | account_id = partner.property_account_receivable.id | ||
4903 | 617 | elif journal.type in ('purchase', 'purchase_refund','expense'): | ||
4904 | 618 | account_id = partner.property_account_payable.id | ||
4905 | 619 | else: | ||
4906 | 620 | account_id = journal.default_credit_account_id.id or journal.default_debit_account_id.id | ||
4907 | 621 | res['account_id'] = account_id | ||
4908 | 622 | return {'value':res} | ||
4909 | 623 | |||
4910 | 624 | def __hook_move_line_values_before_creation(self, cr, uid, move_line): | ||
4911 | 625 | """ | ||
4912 | 626 | Change move line vals before its creation | ||
4913 | 627 | """ | ||
4914 | 628 | return move_line | ||
4915 | 629 | |||
4916 | 630 | def action_move_line_create(self, cr, uid, ids, context=None): | ||
4917 | 631 | |||
4918 | 632 | def _get_payment_term_lines(term_id, amount): | ||
4919 | 633 | term_pool = self.pool.get('account.payment.term') | ||
4920 | 634 | if term_id and amount: | ||
4921 | 635 | terms = term_pool.compute(cr, uid, term_id, amount) | ||
4922 | 636 | return terms | ||
4923 | 637 | return False | ||
4924 | 638 | if context is None: | ||
4925 | 639 | context = {} | ||
4926 | 640 | move_pool = self.pool.get('account.move') | ||
4927 | 641 | move_line_pool = self.pool.get('account.move.line') | ||
4928 | 642 | currency_pool = self.pool.get('res.currency') | ||
4929 | 643 | tax_obj = self.pool.get('account.tax') | ||
4930 | 644 | seq_obj = self.pool.get('ir.sequence') | ||
4931 | 645 | for inv in self.browse(cr, uid, ids, context=context): | ||
4932 | 646 | if inv.move_id: | ||
4933 | 647 | continue | ||
4934 | 648 | context_multi_currency = context.copy() | ||
4935 | 649 | context_multi_currency.update({'date': inv.date}) | ||
4936 | 650 | |||
4937 | 651 | if inv.number: | ||
4938 | 652 | name = inv.number | ||
4939 | 653 | elif inv.journal_id.sequence_id: | ||
4940 | 654 | name = seq_obj.get_id(cr, uid, inv.journal_id.sequence_id.id) | ||
4941 | 655 | else: | ||
4942 | 656 | raise osv.except_osv(_('Error !'), _('Please define a sequence on the journal !')) | ||
4943 | 657 | if not inv.reference: | ||
4944 | 658 | ref = name.replace('/','') | ||
4945 | 659 | else: | ||
4946 | 660 | ref = inv.reference | ||
4947 | 661 | |||
4948 | 662 | move = { | ||
4949 | 663 | 'name': name, | ||
4950 | 664 | 'journal_id': inv.journal_id.id, | ||
4951 | 665 | 'narration': inv.narration, | ||
4952 | 666 | 'date': inv.date, | ||
4953 | 667 | 'ref': ref, | ||
4954 | 668 | 'period_id': inv.period_id and inv.period_id.id or False | ||
4955 | 669 | } | ||
4956 | 670 | move_id = move_pool.create(cr, uid, move) | ||
4957 | 671 | |||
4958 | 672 | #create the first line manually | ||
4959 | 673 | company_currency = inv.journal_id.company_id.currency_id.id | ||
4960 | 674 | current_currency = inv.currency_id.id | ||
4961 | 675 | debit = 0.0 | ||
4962 | 676 | credit = 0.0 | ||
4963 | 677 | # TODO: is there any other alternative then the voucher type ?? | ||
4964 | 678 | # -for sale, purchase we have but for the payment and receipt we do not have as based on the bank/cash journal we can not know its payment or receipt | ||
4965 | 679 | if inv.type in ('purchase', 'payment'): | ||
4966 | 680 | credit = currency_pool.compute(cr, uid, current_currency, company_currency, inv.amount, context=context_multi_currency) | ||
4967 | 681 | elif inv.type in ('sale', 'receipt'): | ||
4968 | 682 | debit = currency_pool.compute(cr, uid, current_currency, company_currency, inv.amount, context=context_multi_currency) | ||
4969 | 683 | if debit < 0: | ||
4970 | 684 | credit = -debit | ||
4971 | 685 | debit = 0.0 | ||
4972 | 686 | if credit < 0: | ||
4973 | 687 | debit = -credit | ||
4974 | 688 | credit = 0.0 | ||
4975 | 689 | sign = debit - credit < 0 and -1 or 1 | ||
4976 | 690 | #create the first line of the voucher | ||
4977 | 691 | move_line = { | ||
4978 | 692 | 'name': inv.name or '/', | ||
4979 | 693 | 'debit': debit, | ||
4980 | 694 | 'credit': credit, | ||
4981 | 695 | 'account_id': inv.account_id.id, | ||
4982 | 696 | 'move_id': move_id, | ||
4983 | 697 | 'journal_id': inv.journal_id.id, | ||
4984 | 698 | 'period_id': inv.period_id.id, | ||
4985 | 699 | 'partner_id': inv.partner_id.id, | ||
4986 | 700 | 'currency_id': company_currency <> current_currency and current_currency or False, | ||
4987 | 701 | 'amount_currency': company_currency <> current_currency and sign * inv.amount or 0.0, | ||
4988 | 702 | 'date': inv.date, | ||
4989 | 703 | 'date_maturity': inv.date_due | ||
4990 | 704 | } | ||
4991 | 705 | move_line = self.__hook_move_line_values_before_creation(cr, uid, move_line) | ||
4992 | 706 | move_line_pool.create(cr, uid, move_line) | ||
4993 | 707 | rec_list_ids = [] | ||
4994 | 708 | line_total = debit - credit | ||
4995 | 709 | if inv.type == 'sale': | ||
4996 | 710 | line_total = line_total - currency_pool.compute(cr, uid, inv.currency_id.id, company_currency, inv.tax_amount, context=context_multi_currency) | ||
4997 | 711 | elif inv.type == 'purchase': | ||
4998 | 712 | line_total = line_total + currency_pool.compute(cr, uid, inv.currency_id.id, company_currency, inv.tax_amount, context=context_multi_currency) | ||
4999 | 713 | |||
5000 | 714 | for line in inv.line_ids: |
The diff has been truncated for viewing.