Merge lp:~julie-w/unifield-server/US-6527 into lp:unifield-server

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
Reviewer Review Type Date Requested Status
UniField Reviewer Team Pending
Review via email: mp+374913@code.launchpad.net
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
=== modified file 'bin/addons/account/__init__.py'
--- bin/addons/account/__init__.py 2011-01-14 00:11:01 +0000
+++ bin/addons/account/__init__.py 2019-10-30 13:23:20 +0000
@@ -33,6 +33,5 @@
33import product33import product
34import sequence34import sequence
35import company35import company
36import res_currency
3736
38# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:37# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
3938
=== modified file 'bin/addons/account/__openerp__.py'
--- bin/addons/account/__openerp__.py 2019-07-24 14:20:02 +0000
+++ bin/addons/account/__openerp__.py 2019-10-30 13:23:20 +0000
@@ -54,7 +54,6 @@
54 'report/account_analytic_entries_report_view.xml',54 'report/account_analytic_entries_report_view.xml',
55 'wizard/account_move_bank_reconcile_view.xml',55 'wizard/account_move_bank_reconcile_view.xml',
56 'wizard/account_use_model_view.xml',56 'wizard/account_use_model_view.xml',
57 'account_installer.xml',
58 'wizard/account_period_close_view.xml',57 'wizard/account_period_close_view.xml',
59 'account_view.xml',58 'account_view.xml',
60 'account_report.xml',59 'account_report.xml',
6160
=== modified file 'bin/addons/account/account.py'
--- bin/addons/account/account.py 2019-07-30 09:13:43 +0000
+++ bin/addons/account/account.py 2019-10-30 13:23:20 +0000
@@ -2276,75 +2276,6 @@
2276 _defaults = {2276 _defaults = {
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'),
2278 }2278 }
2279 def generate(self, cr, uid, ids, datas={}, context=None):
2280 move_ids = []
2281 entry = {}
2282 account_move_obj = self.pool.get('account.move')
2283 account_move_line_obj = self.pool.get('account.move.line')
2284 pt_obj = self.pool.get('account.payment.term')
2285
2286 if context is None:
2287 context = {}
2288
2289 if datas.get('date', False):
2290 context.update({'date': datas['date']})
2291
2292 period_id = self.pool.get('account.period').find(cr, uid, dt=context.get('date', False))
2293 if not period_id:
2294 raise osv.except_osv(_('No period found !'), _('Unable to find a valid period !'))
2295 period_id = period_id[0]
2296
2297 for model in self.browse(cr, uid, ids, context=context):
2298 entry['name'] = model.name%{'year':time.strftime('%Y'), 'month':time.strftime('%m'), 'date':time.strftime('%Y-%m')}
2299 move_id = account_move_obj.create(cr, uid, {
2300 'ref': entry['name'],
2301 'period_id': period_id,
2302 'journal_id': model.journal_id.id,
2303 'date': context.get('date',time.strftime('%Y-%m-%d'))
2304 })
2305 move_ids.append(move_id)
2306 for line in model.lines_id:
2307 analytic_account_id = False
2308 if line.analytic_account_id:
2309 if not model.journal_id.analytic_journal_id:
2310 raise osv.except_osv(_('No Analytic Journal !'),_("You have to define an analytic journal on the '%s' journal!") % (model.journal_id.name,))
2311 analytic_account_id = line.analytic_account_id.id
2312 val = {
2313 'move_id': move_id,
2314 'journal_id': model.journal_id.id,
2315 'period_id': period_id,
2316 'analytic_account_id': analytic_account_id
2317 }
2318
2319 date_maturity = time.strftime('%Y-%m-%d')
2320 if line.date_maturity == 'partner':
2321 if not line.partner_id:
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!" \
2323 "\nPlease define partner on it!")%(line.name, model.name))
2324 if line.partner_id.property_payment_term:
2325 payment_term_id = line.partner_id.property_payment_term.id
2326 pterm_list = pt_obj.compute(cr, uid, payment_term_id, value=1, date_ref=date_maturity)
2327 if pterm_list:
2328 pterm_list = [l[0] for l in pterm_list]
2329 pterm_list.sort()
2330 date_maturity = pterm_list[-1]
2331
2332 val.update({
2333 'name': line.name,
2334 'quantity': line.quantity,
2335 'debit': line.debit,
2336 'credit': line.credit,
2337 'account_id': line.account_id.id,
2338 'move_id': move_id,
2339 'partner_id': line.partner_id.id,
2340 'date': context.get('date',time.strftime('%Y-%m-%d')),
2341 'date_maturity': date_maturity
2342 })
2343 c = context.copy()
2344 c.update({'journal_id': model.journal_id.id,'period_id': period_id})
2345 account_move_line_obj.create(cr, uid, val, context=c)
2346
2347 return move_ids
23482279
2349account_model()2280account_model()
23502281
23512282
=== modified file 'bin/addons/account/account_analytic_line.py'
--- bin/addons/account/account_analytic_line.py 2018-08-31 13:43:37 +0000
+++ bin/addons/account/account_analytic_line.py 2019-10-30 13:23:20 +0000
@@ -63,73 +63,6 @@
63 return False63 return False
64 return True64 return True
6565
66 # Compute the cost based on the price type define into company
67 # property_valuation_price_type property
68 def on_change_unit_amount(self, cr, uid, id, prod_id, quantity, company_id,
69 unit=False, journal_id=False, context=None):
70 if context==None:
71 context={}
72 if not journal_id:
73 j_ids = self.pool.get('account.analytic.journal').search(cr, uid, [('type','=','purchase')])
74 journal_id = j_ids and j_ids[0] or False
75 if not journal_id or not prod_id:
76 return {}
77 product_obj = self.pool.get('product.product')
78 analytic_journal_obj =self.pool.get('account.analytic.journal')
79 product_price_type_obj = self.pool.get('product.price.type')
80 j_id = analytic_journal_obj.browse(cr, uid, journal_id, context=context)
81 prod = product_obj.browse(cr, uid, prod_id, context=context)
82 result = 0.0
83
84 if j_id.type <> 'sale':
85 a = prod.product_tmpl_id.property_account_expense.id
86 if not a:
87 a = prod.categ_id.property_account_expense_categ.id
88 if not a:
89 raise osv.except_osv(_('Error !'),
90 _('There is no expense account defined ' \
91 'for this product: "%s" (id:%d)') % \
92 (prod.name, prod.id,))
93 else:
94 a = prod.product_tmpl_id.property_account_income.id
95 if not a:
96 a = prod.categ_id.property_account_income_categ.id
97 if not a:
98 raise osv.except_osv(_('Error !'),
99 _('There is no income account defined ' \
100 'for this product: "%s" (id:%d)') % \
101 (prod.name, prod_id,))
102
103 flag = False
104 # Compute based on pricetype
105 product_price_type_ids = product_price_type_obj.search(cr, uid, [('field','=','standard_price')], context=context)
106 pricetype = product_price_type_obj.browse(cr, uid, product_price_type_ids, context=context)[0]
107 if journal_id:
108 journal = analytic_journal_obj.browse(cr, uid, journal_id, context=context)
109 if journal.type == 'sale':
110 product_price_type_ids = product_price_type_obj.search(cr, uid, [('field','=','list_price')], context)
111 if product_price_type_ids:
112 pricetype = product_price_type_obj.browse(cr, uid, product_price_type_ids, context=context)[0]
113 # Take the company currency as the reference one
114 if pricetype.field == 'list_price':
115 flag = True
116 ctx = context.copy()
117 if unit:
118 # price_get() will respect a 'uom' in its context, in order
119 # to return a default price for those units
120 ctx['uom'] = unit
121 amount_unit = prod.price_get(pricetype.field, context=ctx)[prod.id]
122 prec = self.pool.get('decimal.precision').precision_get(cr, uid, 'Account')
123 amount = amount_unit * quantity or 1.0
124 result = round(amount, prec)
125 if not flag:
126 result *= -1
127 return {'value': {
128 'amount': result,
129 'general_account_id': a,
130 }
131 }
132
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):
134 if context is None:67 if context is None:
135 context = {}68 context = {}
13669
=== modified file 'bin/addons/account/account_bank_statement.py'
--- bin/addons/account/account_bank_statement.py 2016-11-17 08:46:41 +0000
+++ bin/addons/account/account_bank_statement.py 2019-10-30 13:23:20 +0000
@@ -25,28 +25,43 @@
25from tools.translate import _25from tools.translate import _
26import decimal_precision as dp26import decimal_precision as dp
2727
28
28class account_bank_statement(osv.osv):29class account_bank_statement(osv.osv):
2930
30 def create(self, cr, uid, vals, context=None):
31 seq = 0
32 if 'line_ids' in vals:
33 for line in vals['line_ids']:
34 seq += 1
35 line[2]['sequence'] = seq
36 vals[seq - 1] = line
37 return super(account_bank_statement, self).create(cr, uid, vals, context=context)
38
39 def write(self, cr, uid, ids, vals, context=None):31 def write(self, cr, uid, ids, vals, context=None):
40 if not ids:32 if not ids:
41 return True33 return True
42 res = super(account_bank_statement, self).write(cr, uid, ids, vals, context=context)34 if context is None:
43 account_bank_statement_line_obj = self.pool.get('account.bank.statement.line')35 context = {}
44 for statement in self.browse(cr, uid, ids, context):36
45 seq = 037 if not context.get('sync_update_execution'):
46 for line in statement.line_ids:38 if 'balance_end_real' in vals:
47 seq += 139 new_vals = {'balance_start': vals['balance_end_real']}
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
49 return res41 # the source register is not 'end of month balance' frozen
42 # note: the last carry over is processed via
43 # 'button_confirm_closing_bank_balance' button
44 to_write_id_list = []
45 for r in self.read(cr, uid, ids,
46 [ 'closing_balance_frozen', 'journal_id', ],
47 context=context):
48 if not r['closing_balance_frozen']:
49 if r['journal_id']:
50 jtype = self.pool.get('account.journal').read(cr,
51 uid, [r['journal_id'][0]], ['type'],
52 context=context)[0]['type']
53 if jtype != 'cash':
54 args = [('prev_reg_id', '=', r['id'])]
55 search_ids = self.search(cr, uid, args,
56 context=context)
57 if search_ids:
58 to_write_id_list.extend(search_ids)
59 self.write(cr, uid, to_write_id_list, new_vals, context=context)
60
61 if not vals:
62 return True
63
64 return super(account_bank_statement, self).write(cr, uid, ids, vals, context=context)
5065
51 def _default_journal_id(self, cr, uid, context=None):66 def _default_journal_id(self, cr, uid, context=None):
52 if context is None:67 if context is None:
@@ -60,43 +75,25 @@
60 journal_id = ids[0]75 journal_id = ids[0]
61 return journal_id76 return journal_id
6277
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):
64 cr.execute('select id from account_bank_statement where journal_id=%s order by date desc limit 1', (1,))79 """
65 res = cr.fetchone()80 Calculate register's balance
66 if res:81 """
67 return self.browse(cr, uid, res[0], context=context).balance_end82 if context is None:
68 return 0.083 context = {}
69
70 def _end_balance(self, cursor, user, ids, name, attr, context=None):
71 res_currency_obj = self.pool.get('res.currency')
72 res_users_obj = self.pool.get('res.users')
73 res = {}84 res = {}
7485
75 company_currency_id = res_users_obj.browse(cursor, user, user,86 # Add this context in order to escape cheque register filter
76 context=context).company_id.currency_id.id87 ctx = context.copy()
7788 ctx.update({'from_end_balance': True})
78 statements = self.browse(cursor, user, ids, context=context)89 for statement in self.browse(cr, uid, ids, context=ctx):
79 for statement in statements:
80 res[statement.id] = statement.balance_start90 res[statement.id] = statement.balance_start
81 currency_id = statement.currency.id91 for st_line in statement.line_ids:
82 for line in statement.move_line_ids:92 res[statement.id] += st_line.amount or 0.0
83 if line.debit > 0:93 # UF-425: Add the Open Advances Amount when calculating the "Calculated Balance" value
84 if line.account_id.id == \94 res[statement.id] -= statement.open_advance_amount or 0.0
85 statement.journal_id.default_debit_account_id.id:95 # UF-810: Add a "Unrecorded Expenses" when calculating "Calculated Balance"
86 res[statement.id] += res_currency_obj.compute(cursor,96 res[statement.id] -= statement.unrecorded_expenses_amount or 0.0
87 user, company_currency_id, currency_id,
88 line.debit, context=context)
89 else:
90 if line.account_id.id == \
91 statement.journal_id.default_credit_account_id.id:
92 res[statement.id] -= res_currency_obj.compute(cursor,
93 user, company_currency_id, currency_id,
94 line.credit, context=context)
95 if statement.state == 'draft':
96 for line in statement.line_ids:
97 res[statement.id] += line.amount
98 for r in res:
99 res[r] = round(res[r], 2)
100 return res97 return res
10198
102 def _get_period(self, cr, uid, context=None):99 def _get_period(self, cr, uid, context=None):
@@ -125,21 +122,18 @@
125 res[statement_id] = (currency_id, currency_names[currency_id])122 res[statement_id] = (currency_id, currency_names[currency_id])
126 return res123 return res
127124
128 _order = "date desc, id desc"
129 _name = "account.bank.statement"125 _name = "account.bank.statement"
130 _description = "Bank Statement"126 _description = "Bank Statement"
131 _columns = {127 _columns = {
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)]}),
133 'date': fields.date('Date', required=True, states={'confirm': [('readonly', True)]}),129 'date': fields.date('Date', required=True, states={'confirm': [('readonly', True)]}),
134 'journal_id': fields.many2one('account.journal', 'Journal', required=True,130 'journal_id': fields.many2one('account.journal', 'Journal', required=True, readonly=True),
135 readonly=True, states={'draft':[('readonly',False)]}),131 'period_id': fields.many2one('account.period', 'Period', required=True),
136 'period_id': fields.many2one('account.period', 'Period', required=True,
137 states={'confirm':[('readonly', True)]}),
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'),
139 states={'confirm':[('readonly',True)]}),133 states={'confirm':[('readonly',True)]}),
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)]},
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."),
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'),
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),
144 'line_ids': fields.one2many('account.bank.statement.line',138 'line_ids': fields.one2many('account.bank.statement.line',
145 'statement_id', 'Statement lines',139 'statement_id', 'Statement lines',
@@ -147,21 +141,18 @@
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'),
148 'move_line_ids': fields.one2many('account.move.line', 'statement_id',142 'move_line_ids': fields.one2many('account.move.line', 'statement_id',
149 'Entry lines', states={'confirm':[('readonly',True)]}),143 'Entry lines', states={'confirm':[('readonly',True)]}),
150 'state': fields.selection([('draft', 'Draft'),('confirm', 'Confirmed')],144 'state': fields.selection((('draft', 'Draft'), ('open', 'Open'), ('partial_close', 'Partial Close'), ('confirm', 'Closed')),
151 'State', required=True,145 readonly="True", string='State'),
152 states={'confirm': [('readonly', True)]}, readonly="1",
153 help='When new statement is created the state will be \'Draft\'. \
154 \n* And after getting confirmation from the bank it will be in \'Confirmed\' state.'),
155 'currency': fields.function(_currency, method=True, string='Currency',146 'currency': fields.function(_currency, method=True, string='Currency',
156 type='many2one', relation='res.currency'),147 type='many2one', relation='res.currency'),
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.'),
158 }149 }
159150
160 _defaults = {151 _defaults = {
161 'name': "/",152 'name': False,
162 'date': lambda *a: time.strftime('%Y-%m-%d'),153 'date': lambda *a: time.strftime('%Y-%m-%d'),
163 'state': 'draft',154 'state': 'draft',
164 'balance_start': _default_balance_start,155 'balance_start': lambda *a: 0.0,
165 'journal_id': _default_journal_id,156 'journal_id': _default_journal_id,
166 'period_id': _get_period,157 'period_id': _get_period,
167 }158 }
@@ -199,168 +190,9 @@
199 def button_dummy(self, cr, uid, ids, context=None):190 def button_dummy(self, cr, uid, ids, context=None):
200 return self.write(cr, uid, ids, {}, context=context)191 return self.write(cr, uid, ids, {}, context=context)
201192
202 def create_move_from_st_line(self, cr, uid, st_line_id, company_currency_id, st_line_number, context=None):
203 if context is None:
204 context = {}
205 res_currency_obj = self.pool.get('res.currency')
206 account_move_obj = self.pool.get('account.move')
207 account_move_line_obj = self.pool.get('account.move.line')
208 account_bank_statement_line_obj = self.pool.get('account.bank.statement.line')
209 st_line = account_bank_statement_line_obj.browse(cr, uid, st_line_id, context=context)
210 st = st_line.statement_id
211
212 context.update({'date': st_line.date})
213
214 move_id = account_move_obj.create(cr, uid, {
215 'journal_id': st.journal_id.id,
216 'period_id': st.period_id.id,
217 'date': st_line.date,
218 'name': st_line_number,
219 }, context=context)
220 account_bank_statement_line_obj.write(cr, uid, [st_line.id], {
221 'move_ids': [(4, move_id, False)]
222 })
223
224 torec = []
225 if st_line.amount >= 0:
226 account_id = st.journal_id.default_credit_account_id.id
227 else:
228 account_id = st.journal_id.default_debit_account_id.id
229
230 acc_cur = ((st_line.amount<=0) and st.journal_id.default_debit_account_id) or st_line.account_id
231 context.update({
232 'res.currency.compute.account': acc_cur,
233 })
234 amount = res_currency_obj.compute(cr, uid, st.currency.id,
235 company_currency_id, st_line.amount, context=context)
236
237 val = {
238 'name': st_line.name,
239 'date': st_line.date,
240 'ref': st_line.ref,
241 'move_id': move_id,
242 'partner_id': ((st_line.partner_id) and st_line.partner_id.id) or False,
243 'account_id': (st_line.account_id) and st_line.account_id.id,
244 'credit': ((amount>0) and amount) or 0.0,
245 'debit': ((amount<0) and -amount) or 0.0,
246 'statement_id': st.id,
247 'journal_id': st.journal_id.id,
248 'period_id': st.period_id.id,
249 'currency_id': st.currency.id,
250 'analytic_account_id': st_line.analytic_account_id and st_line.analytic_account_id.id or False
251 }
252
253 if st.currency.id <> company_currency_id:
254 amount_cur = res_currency_obj.compute(cr, uid, company_currency_id,
255 st.currency.id, amount, context=context)
256 val['amount_currency'] = -amount_cur
257
258 if st_line.account_id and st_line.account_id.currency_id and st_line.account_id.currency_id.id <> company_currency_id:
259 val['currency_id'] = st_line.account_id.currency_id.id
260 amount_cur = res_currency_obj.compute(cr, uid, company_currency_id,
261 st_line.account_id.currency_id.id, amount, context=context)
262 val['amount_currency'] = -amount_cur
263
264 move_line_id = account_move_line_obj.create(cr, uid, val, context=context)
265 torec.append(move_line_id)
266
267 # Fill the secondary amount/currency
268 # if currency is not the same than the company
269 amount_currency = False
270 currency_id = False
271 if st.currency.id <> company_currency_id:
272 amount_currency = st_line.amount
273 currency_id = st.currency.id
274 account_move_line_obj.create(cr, uid, {
275 'name': st_line.name,
276 'date': st_line.date,
277 'ref': st_line.ref,
278 'move_id': move_id,
279 'partner_id': ((st_line.partner_id) and st_line.partner_id.id) or False,
280 'account_id': account_id,
281 'credit': ((amount < 0) and -amount) or 0.0,
282 'debit': ((amount > 0) and amount) or 0.0,
283 'statement_id': st.id,
284 'journal_id': st.journal_id.id,
285 'period_id': st.period_id.id,
286 'amount_currency': amount_currency,
287 'currency_id': currency_id,
288 }, context=context)
289
290 for line in account_move_line_obj.browse(cr, uid, [x.id for x in
291 account_move_obj.browse(cr, uid, move_id,
292 context=context).line_id],
293 context=context):
294 if line.state <> 'valid':
295 raise osv.except_osv(_('Error !'),
296 _('Journal Item "%s" is not valid') % line.name)
297
298 # Bank statements will not consider boolean on journal entry_posted
299 account_move_obj.post(cr, uid, [move_id], context=context)
300 return move_id
301
302 def get_next_st_line_number(self, cr, uid, st_number, st_line, context=None):
303 return st_number + '/' + str(st_line.sequence)
304
305 def balance_check(self, cr, uid, st_id, journal_type='bank', context=None):
306 st = self.browse(cr, uid, st_id, context=context)
307 if not (abs((st.balance_end or 0.0) - st.balance_end_real) < 0.0001):
308 raise osv.except_osv(_('Error !'),
309 _('The statement balance is incorrect !\n') +
310 _('The expected balance (%.2f) is different than the computed one. (%.2f)') % (st.balance_end_real, st.balance_end))
311 return True
312
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):
314 return self.write(cr, uid, ids, {'state':'confirm'}, context=context)194 return self.write(cr, uid, ids, {'state':'confirm'}, context=context)
315195
316 def check_status_condition(self, cr, uid, state, journal_type='bank'):
317 return state=='draft'
318
319 def button_confirm_bank(self, cr, uid, ids, context=None):
320 done = []
321 obj_seq = self.pool.get('ir.sequence')
322 if context is None:
323 context = {}
324
325 for st in self.browse(cr, uid, ids, context=context):
326 j_type = st.journal_id.type
327 company_currency_id = st.journal_id.company_id.currency_id.id
328 if not self.check_status_condition(cr, uid, st.state, journal_type=j_type):
329 continue
330
331 self.balance_check(cr, uid, st.id, journal_type=j_type, context=context)
332 if (not st.journal_id.default_credit_account_id) \
333 or (not st.journal_id.default_debit_account_id):
334 raise osv.except_osv(_('Configuration Error !'),
335 _('Please verify that an account is defined in the journal.'))
336
337 if not st.name == '/':
338 st_number = st.name
339 else:
340 if st.journal_id.sequence_id:
341 c = {'fiscalyear_id': st.period_id.fiscalyear_id.id}
342 st_number = obj_seq.get_id(cr, uid, st.journal_id.sequence_id.id, context=c)
343 else:
344 st_number = obj_seq.get(cr, uid, 'account.bank.statement')
345
346 for line in st.move_line_ids:
347 if line.state <> 'valid':
348 raise osv.except_osv(_('Error !'),
349 _('The account entries lines are not in valid state.'))
350 for st_line in st.line_ids:
351 if st_line.analytic_account_id:
352 if not st.journal_id.analytic_journal_id:
353 raise osv.except_osv(_('No Analytic Journal !'),_("You have to define an analytic journal on the '%s' journal!") % (st.journal_id.name,))
354 if not st_line.amount:
355 continue
356 st_line_number = self.get_next_st_line_number(cr, uid, st_number, st_line, context)
357 self.create_move_from_st_line(cr, uid, st_line.id, company_currency_id, st_line_number, context)
358
359 self.write(cr, uid, [st.id], {'name': st_number}, context=context)
360 self.log(cr, uid, st.id, _('Statement %s is confirmed, journal items are created.') % (st_number,))
361 done.append(st.id)
362 return self.write(cr, uid, ids, {'state':'confirm'}, context=context)
363
364 def button_cancel(self, cr, uid, ids, context=None):196 def button_cancel(self, cr, uid, ids, context=None):
365 done = []197 done = []
366 account_move_obj = self.pool.get('account.move')198 account_move_obj = self.pool.get('account.move')
367199
=== modified file 'bin/addons/account/account_cash_statement.py'
--- bin/addons/account/account_cash_statement.py 2019-07-30 09:13:43 +0000
+++ bin/addons/account/account_cash_statement.py 2019-10-30 13:23:20 +0000
@@ -70,7 +70,6 @@
70 _inherit = 'account.bank.statement'70 _inherit = 'account.bank.statement'
7171
72 def _get_starting_balance(self, cr, uid, ids, context=None):72 def _get_starting_balance(self, cr, uid, ids, context=None):
73
74 """ Find starting balance73 """ Find starting balance
75 @param name: Names of fields.74 @param name: Names of fields.
76 @param arg: User defined arguments75 @param arg: User defined arguments
@@ -83,13 +82,18 @@
83 if statement.journal_id.type not in('cash'):82 if statement.journal_id.type not in('cash'):
84 continue83 continue
8584
86 for line in statement.starting_details_ids:85 if not statement.prev_reg_id:
87 amount_total+= line.pieces * line.number86 for line in statement.starting_details_ids:
87 amount_total+= line.pieces * line.number
88 else:
89 amount_total = statement.prev_reg_id.msf_calculated_balance
90
88 res[statement.id] = {91 res[statement.id] = {
89 'balance_start': amount_total92 'balance_start': amount_total
90 }93 }
91 return res94 return res
9295
96
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):
94 """ Find ending balance "98 """ Find ending balance "
95 @param name: Names of fields.99 @param name: Names of fields.
@@ -119,39 +123,6 @@
119 res2[statement.id] = encoding_total123 res2[statement.id] = encoding_total
120 return res2124 return res2
121125
122 def _end_balance(self, cursor, user, ids, name, attr, context=None):
123 res_currency_obj = self.pool.get('res.currency')
124 res_users_obj = self.pool.get('res.users')
125 res = {}
126
127 company_currency_id = res_users_obj.browse(cursor, user, user,
128 context=context).company_id.currency_id.id
129
130 statements = self.browse(cursor, user, ids, context=context)
131 for statement in statements:
132 res[statement.id] = statement.balance_start
133 currency_id = statement.currency.id
134 for line in statement.move_line_ids:
135 if line.debit > 0:
136 if line.account_id.id == \
137 statement.journal_id.default_debit_account_id.id:
138 res[statement.id] += res_currency_obj.compute(cursor,
139 user, company_currency_id, currency_id,
140 line.debit, context=context)
141 else:
142 if line.account_id.id == \
143 statement.journal_id.default_credit_account_id.id:
144 res[statement.id] -= res_currency_obj.compute(cursor,
145 user, company_currency_id, currency_id,
146 line.credit, context=context)
147
148 if statement.state in ('draft', 'open'):
149 for line in statement.line_ids:
150 res[statement.id] += line.amount
151 for r in res:
152 res[r] = round(res[r], 2)
153 return res
154
155 def _get_company(self, cr, uid, context=None):126 def _get_company(self, cr, uid, context=None):
156 user_pool = self.pool.get('res.users')127 user_pool = self.pool.get('res.users')
157 company_pool = self.pool.get('res.company')128 company_pool = self.pool.get('res.company')
@@ -218,79 +189,19 @@
218 return res189 return res
219190
220 _columns = {191 _columns = {
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"),
222 'state': fields.selection(
223 [('draft', 'Draft'),
224 ('confirm', 'Closed'),
225 ('open','Open')], 'State', required=True, states={'confirm': [('readonly', True)]}, readonly="1"),
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"),
227 'balance_end': fields.function(_end_balance, method=True, store=False, string='Balance', help="Closing balance based on Starting Balance and Cash Transactions"),
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"),
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'),
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'),
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'),
232 'user_id': fields.many2one('res.users', 'Responsible', required=False),196 'user_id': fields.many2one('res.users', 'Responsible', required=False),
233 }197 }
234 _defaults = {198 _defaults = {
235 'state': 'draft',
236 'date': lambda *a: time.strftime("%Y-%m-%d %H:%M:%S"),199 'date': lambda *a: time.strftime("%Y-%m-%d %H:%M:%S"),
237 'user_id': lambda self, cr, uid, context=None: uid,200 'user_id': lambda self, cr, uid, context=None: uid,
238 'starting_details_ids': _get_cash_open_box_lines,201 'starting_details_ids': _get_cash_open_box_lines,
239 'ending_details_ids': _get_default_cash_close_box_lines202 'ending_details_ids': _get_default_cash_close_box_lines
240 }203 }
241204
242 def create(self, cr, uid, vals, context=None):
243 sql = [
244 ('journal_id', '=', vals.get('journal_id', False)),
245 ('state', '=', 'open')
246 ]
247 open_jrnl = self.search(cr, uid, sql)
248 if open_jrnl:
249 raise osv.except_osv(_('Error'), _('You can not have two open register for the same journal'))
250
251 if self.pool.get('account.journal').browse(cr, uid, vals['journal_id'], context=context).type == 'cash':
252 open_close = self._get_cash_open_close_box_lines(cr, uid, context)
253 if vals.get('starting_details_ids', False):
254 for start in vals.get('starting_details_ids'):
255 dict_val = start[2]
256 for end in open_close['end']:
257 if end[2]['pieces'] == dict_val['pieces']:
258 end[2]['number'] += dict_val['number']
259 vals.update({
260 # 'ending_details_ids': open_close['start'],
261 'starting_details_ids': open_close['end']
262 })
263 else:
264 vals.update({
265 'ending_details_ids': False,
266 'starting_details_ids': False
267 })
268 res_id = super(account_cash_statement, self).create(cr, uid, vals, context=context)
269 self.write(cr, uid, [res_id], {})
270 return res_id
271
272 def write(self, cr, uid, ids, vals, context=None):
273 """
274 Update redord(s) comes in {ids}, with new value comes as {vals}
275 return True on success, False otherwise
276
277 @param cr: cursor to database
278 @param user: id of current user
279 @param ids: list of record ids to be update
280 @param vals: dict of new values to be set
281 @param context: context arguments, like lang, time zone
282
283 @return: True on success, False otherwise
284 """
285 if not ids:
286 return True
287
288 super(account_cash_statement, self).write(cr, uid, ids, vals, context=context)
289 res = self._get_starting_balance(cr, uid, ids)
290 for rs in res:
291 super(account_cash_statement, self).write(cr, uid, [rs], res.get(rs))
292 return True
293
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):
295 """ Changes balance start and starting details if journal_id changes"206 """ Changes balance start and starting details if journal_id changes"
296 @param statement_id: Changed statement_id207 @param statement_id: Changed statement_id
@@ -346,13 +257,6 @@
346 self.write(cr, uid, [statement.id], vals, context=context)257 self.write(cr, uid, [statement.id], vals, context=context)
347 return True258 return True
348259
349 def balance_check(self, cr, uid, cash_id, journal_type='bank', context=None):
350 if journal_type == 'bank':
351 return super(account_cash_statement, self).balance_check(cr, uid, cash_id, journal_type, context)
352 if not self._equal_balance(cr, uid, cash_id, context):
353 raise osv.except_osv(_('Error !'), _('CashBox Balance is not matching with Calculated Balance !'))
354 return True
355
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):
357 if journal_type == 'bank':261 if journal_type == 'bank':
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)
@@ -362,15 +266,6 @@
362 }266 }
363 return self.write(cr, uid, ids, vals, context=context)267 return self.write(cr, uid, ids, vals, context=context)
364268
365 def check_status_condition(self, cr, uid, state, journal_type='bank'):
366 if journal_type == 'bank':
367 return super(account_cash_statement, self).check_status_condition(cr, uid, state, journal_type)
368 return state=='open'
369
370 def button_confirm_cash(self, cr, uid, ids, context=None):
371 super(account_cash_statement, self).button_confirm_bank(cr, uid, ids, context=context)
372 return self.write(cr, uid, ids, {'closing_date': time.strftime("%Y-%m-%d %H:%M:%S")}, context=context)
373
374 def button_cancel(self, cr, uid, ids, context=None):269 def button_cancel(self, cr, uid, ids, context=None):
375 cash_box_line_pool = self.pool.get('account.cashbox.line')270 cash_box_line_pool = self.pool.get('account.cashbox.line')
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)
377272
=== removed file 'bin/addons/account/account_installer.xml'
--- bin/addons/account/account_installer.xml 2011-01-14 00:11:01 +0000
+++ bin/addons/account/account_installer.xml 1970-01-01 00:00:00 +0000
@@ -1,130 +0,0 @@
1<openerp>
2 <data>
3 <record id="view_account_configuration_installer" model="ir.ui.view">
4 <field name="name">account.installer.form</field>
5 <field name="model">account.installer</field>
6 <field name="type">form</field>
7 <field name="inherit_id" ref="base.res_config_installer"/>
8 <field name="arch" type="xml">
9 <data>
10 <form position="attributes">
11 <attribute name="string">Accounting Application Configuration</attribute>
12 </form>
13 <separator string="title" position="attributes">
14 <attribute name="string">Configure Your Accounting Chart</attribute>
15 </separator>
16 <xpath expr="//label[@string='description']" position="attributes">
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>
18 </xpath>
19 <xpath expr="//button[@string='Install Modules']" position="attributes">
20 <attribute name="string">Configure</attribute>
21 </xpath>
22 <xpath expr='//separator[@string="vsep"]' position='attributes'>
23 <attribute name='rowspan'>23</attribute>
24 <attribute name='string'></attribute>
25 </xpath>
26 <group colspan="8">
27 <group colspan="4" width="600">
28 <field name="charts"/>
29 <group colspan="4" groups="base.group_extended">
30 <separator col="4" colspan="4" string="Configure Fiscal Year"/>
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 -->
32 <field name="date_start" on_change="on_change_start_date(date_start)"/>
33 <field name="date_stop"/>
34 <field name="period" colspan="4"/>
35 </group>
36 <group colspan="4" attrs="{'invisible':[('charts','!=','configurable')]}">
37 <field name="sale_tax" on_change="on_change_tax(sale_tax)" attrs="{'required':[('charts','=','configurable')]}"/>
38 <field name="purchase_tax" groups="base.group_extended"/>
39 </group>
40 <group colspan="4" attrs="{'invisible':[('charts','!=','configurable')]}">
41 <separator col="4" colspan="4" string="Bank and Cash Accounts"/>
42 <field colspan="4" mode="tree" height="200" name="bank_accounts_id" nolabel="1" widget="one2many_list">
43 <form string="">
44 <field name="acc_name"/>
45 <field name="account_type"/>
46 <field name="currency_id" widget="selection" groups="base.group_extended"/>
47 </form>
48 <tree editable="bottom" string="Your bank and cash accounts">
49 <field name="acc_name"/>
50 <field name="account_type"/>
51 <field name="currency_id" widget="selection" groups="base.group_extended"/>
52 </tree>
53 </field>
54 </group>
55 </group>
56 </group>
57 </data>
58 </field>
59 </record>
60
61 <record id="view_account_modules_installer" model="ir.ui.view">
62 <field name="name">account.installer.modules.form</field>
63 <field name="model">account.installer.modules</field>
64 <field name="type">form</field>
65 <field name="inherit_id" ref="base.res_config_installer"/>
66 <field name="arch" type="xml">
67 <data>
68 <form position="attributes">
69 <attribute name="string">Accounting Application Configuration</attribute>
70 </form>
71 <separator string="title" position="attributes">
72 <attribute name="string">Configure Your Accounting Application</attribute>
73
74 </separator>
75 <xpath expr="//label[@string='description']" position="attributes">
76 <attribute name="string">Add extra Accounting functionalities to the ones already installed.</attribute>
77 </xpath>
78 <xpath expr="//button[@string='Install Modules']" position="attributes">
79 <attribute name="string">Configure</attribute>
80 </xpath>
81 <xpath expr='//separator[@string="vsep"]' position='attributes'>
82 <attribute name='string'></attribute>
83 </xpath>
84 <group colspan="8">
85 <field name="account_voucher"/>
86 <field name="account_followup"/>
87 <field name="account_payment"/>
88 <field name="account_analytic_plans"/>
89 <field name="account_anglo_saxon"/>
90<!-- <field name="account_voucher_payment"/>-->
91 </group>
92 </data>
93 </field>
94 </record>
95
96 <record id="action_account_configuration_installer" model="ir.actions.act_window">
97 <field name="name">Accounting Chart Configuration</field>
98 <field name="type">ir.actions.act_window</field>
99 <field name="res_model">account.installer</field>
100 <field name="view_id" ref="view_account_configuration_installer"/>
101 <field name="view_type">form</field>
102 <field name="view_mode">form</field>
103 <field name="target">new</field>
104 </record>
105
106 <record id="action_account_installer" model="ir.actions.act_window">
107 <field name="name">Accounting Application Configuration</field>
108 <field name="type">ir.actions.act_window</field>
109 <field name="res_model">account.installer.modules</field>
110 <field name="view_id" ref="view_account_modules_installer"/>
111 <field name="view_type">form</field>
112 <field name="view_mode">form</field>
113 <field name="target">new</field>
114 </record>
115
116 <record id="account_configuration_installer_todo" model="ir.actions.todo">
117 <field name="action_id" ref="action_account_configuration_installer"/>
118 <field name="sequence">3</field>
119 <field name="restart">onskip</field>
120 </record>
121
122 <record id="account_installer_todo" model="ir.actions.todo">
123 <field name="action_id" ref="action_account_installer"/>
124 <field name="sequence">5</field>
125 <field name="restart">always</field>
126 <field eval="[(6,0,[ref('base.group_extended')])]" name="groups_id"/>
127 </record>
128
129 </data>
130</openerp>
1310
=== modified file 'bin/addons/account/account_invoice_view.xml'
--- bin/addons/account/account_invoice_view.xml 2019-07-29 15:00:38 +0000
+++ bin/addons/account/account_invoice_view.xml 2019-10-30 13:23:20 +0000
@@ -223,8 +223,11 @@
223 domain="[('type', 'not in', ['view', 'consolidation']),223 domain="[('type', 'not in', ['view', 'consolidation']),
224 ('user_type_code', '=', 'tax')]"/>224 ('user_type_code', '=', 'tax')]"/>
225225
226 <field name="base" on_change="base_change(base,parent.currency_id,parent.company_id,parent.date_invoice)" readonly="1"/>226 <field name="base"
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)"
228 readonly="1"/>
229 <field name="amount"
230 on_change="amount_change(amount, parent.currency_id, parent.company_id, parent.document_date, parent.date_invoice)"/>
228231
229 <field invisible="True" name="base_amount"/>232 <field invisible="True" name="base_amount"/>
230 <field invisible="True" name="tax_amount"/>233 <field invisible="True" name="tax_amount"/>
@@ -339,8 +342,11 @@
339 <tree editable="bottom" string="Taxes">342 <tree editable="bottom" string="Taxes">
340 <field name="name"/>343 <field name="name"/>
341 <field name="account_id" groups="account.group_account_invoice"/>344 <field name="account_id" groups="account.group_account_invoice"/>
342 <field name="base" on_change="base_change(base,parent.currency_id,parent.company_id,parent.date_invoice)" readonly="1"/>345 <field name="base"
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)"
347 readonly="1"/>
348 <field name="amount"
349 on_change="amount_change(amount, parent.currency_id, parent.company_id, parent.document_date, parent.date_invoice)"/>
344 <field invisible="True" name="base_amount"/>350 <field invisible="True" name="base_amount"/>
345 <field invisible="True" name="tax_amount"/>351 <field invisible="True" name="tax_amount"/>
346 <field name="factor_base" invisible="True"/>352 <field name="factor_base" invisible="True"/>
347353
=== modified file 'bin/addons/account/account_move_line.py'
--- bin/addons/account/account_move_line.py 2019-09-17 16:00:23 +0000
+++ bin/addons/account/account_move_line.py 2019-10-30 13:23:20 +0000
@@ -21,7 +21,6 @@
2121
22import time22import time
23from datetime import datetime23from datetime import datetime
24from operator import itemgetter
2524
26from osv import fields, osv25from osv import fields, osv
27from tools.translate import _26from tools.translate import _
@@ -29,6 +28,7 @@
29import tools28import tools
30import netsvc29import netsvc
3130
31
32class account_move_line(osv.osv):32class account_move_line(osv.osv):
33 _name = "account.move.line"33 _name = "account.move.line"
34 _description = "Journal Items"34 _description = "Journal Items"
@@ -149,57 +149,6 @@
149 query += company_clause149 query += company_clause
150 return query150 return query
151151
152 def _amount_residual(self, cr, uid, ids, field_names, args, context=None):
153 """
154 This function returns the residual amount on a receivable or payable account.move.line.
155 By default, it returns an amount in the currency of this journal entry (maybe different
156 of the company currency), but if you pass 'residual_in_company_currency' = True in the
157 context then the returned amount will be in company currency.
158 """
159 res = {}
160 if context is None:
161 context = {}
162 cur_obj = self.pool.get('res.currency')
163 for move_line in self.browse(cr, uid, ids, context=context):
164 res[move_line.id] = {
165 'amount_residual': 0.0,
166 'amount_residual_currency': 0.0,
167 }
168
169 if move_line.reconcile_id:
170 continue
171 if not move_line.account_id.type in ('payable', 'receivable'):
172 #this function does not suport to be used on move lines not related to payable or receivable accounts
173 continue
174
175 if move_line.currency_id:
176 move_line_total = move_line.amount_currency
177 sign = move_line.amount_currency < 0 and -1 or 1
178 else:
179 move_line_total = move_line.debit - move_line.credit
180 sign = (move_line.debit - move_line.credit) < 0 and -1 or 1
181 line_total_in_company_currency = move_line.debit - move_line.credit
182 context_unreconciled = context.copy()
183 if move_line.reconcile_partial_id:
184 for payment_line in move_line.reconcile_partial_id.line_partial_ids:
185 if payment_line.id == move_line.id:
186 continue
187 if payment_line.currency_id and move_line.currency_id and payment_line.currency_id.id == move_line.currency_id.id:
188 move_line_total += payment_line.amount_currency
189 else:
190 if move_line.currency_id:
191 context_unreconciled.update({'date': payment_line.date})
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)
193 move_line_total += amount_in_foreign_currency
194 else:
195 move_line_total += (payment_line.debit - payment_line.credit)
196 line_total_in_company_currency += (payment_line.debit - payment_line.credit)
197
198 result = move_line_total
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)
200 res[move_line.id]['amount_residual'] = sign * line_total_in_company_currency
201 return res
202
203 def default_get(self, cr, uid, fields, context=None):152 def default_get(self, cr, uid, fields, context=None):
204 data = self._default_get(cr, uid, fields, context=context)153 data = self._default_get(cr, uid, fields, context=context)
205 for f in data.keys():154 for f in data.keys():
@@ -387,18 +336,6 @@
387 data['debit'] = s > 0 and s or 0.0336 data['debit'] = s > 0 and s or 0.0
388 data['credit'] = s < 0 and -s or 0.0337 data['credit'] = s < 0 and -s or 0.0
389338
390 if account and account.currency_id:
391 data['currency_id'] = account.currency_id.id
392 acc = account
393 if s>0:
394 acc = acc1
395 compute_ctx = context.copy()
396 compute_ctx.update({
397 'res.currency.compute.account': acc,
398 'res.currency.compute.account_invert': True,
399 })
400 v = currency_obj.compute(cr, uid, account.company_id.currency_id.id, data['currency_id'], s, context=compute_ctx)
401 data['amount_currency'] = v
402 return data339 return data
403340
404 def on_create_write(self, cr, uid, id, context=None):341 def on_create_write(self, cr, uid, id, context=None):
@@ -601,8 +538,6 @@
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),
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),
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')),
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)."),
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."),
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."),
607 'period_id': fields.many2one('account.period', 'Period', required=True, select=2),542 'period_id': fields.many2one('account.period', 'Period', required=True, select=2),
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),
@@ -737,31 +672,6 @@
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'] ),
738 ]673 ]
739674
740 #TODO: ONCHANGE_ACCOUNT_ID: set account_tax_id
741 def onchange_currency(self, cr, uid, ids, account_id, amount, currency_id, date=False, journal=False, context=None):
742 if context is None:
743 context = {}
744 account_obj = self.pool.get('account.account')
745 journal_obj = self.pool.get('account.journal')
746 currency_obj = self.pool.get('res.currency')
747 if (not currency_id) or (not account_id):
748 return {}
749 result = {}
750 acc = account_obj.browse(cr, uid, account_id, context=context)
751 if (amount>0) and journal:
752 x = journal_obj.browse(cr, uid, journal).default_credit_account_id
753 if x: acc = x
754 context.update({
755 'date': date,
756 'res.currency.compute.account': acc,
757 })
758 v = currency_obj.compute(cr, uid, currency_id, acc.company_id.currency_id.id, amount, context=context)
759 result['value'] = {
760 'debit': v > 0 and v or 0.0,
761 'credit': v < 0 and -v or 0.0
762 }
763 return result
764
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):
766 partner_obj = self.pool.get('res.partner')676 partner_obj = self.pool.get('res.partner')
767 payment_term_obj = self.pool.get('account.payment.term')677 payment_term_obj = self.pool.get('account.payment.term')
@@ -901,123 +811,6 @@
901 'context':context,811 'context':context,
902 }812 }
903813
904 def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False):
905 journal_pool = self.pool.get('account.journal')
906 if context is None:
907 context = {}
908 result = super(account_move_line, self).fields_view_get(cr, uid, view_id, view_type, context=context, toolbar=toolbar, submenu=submenu)
909 if view_type != 'tree':
910 #Remove the toolbar from the form view
911 if view_type == 'form':
912 if result.get('toolbar', False):
913 result['toolbar']['action'] = []
914 #Restrict the list of journal view in search view
915 if view_type == 'search' and result['fields'].get('journal_id', False):
916 result['fields']['journal_id']['selection'] = journal_pool.name_search(cr, uid, '', [], context=context)
917 ctx = context.copy()
918 #we add the refunds journal in the selection field of journal
919 if context.get('journal_type', False) == 'sale':
920 ctx.update({'journal_type': 'sale_refund'})
921 result['fields']['journal_id']['selection'] += journal_pool.name_search(cr, uid, '', [], context=ctx)
922 elif context.get('journal_type', False) == 'purchase':
923 ctx.update({'journal_type': 'purchase_refund'})
924 result['fields']['journal_id']['selection'] += journal_pool.name_search(cr, uid, '', [], context=ctx)
925 return result
926 if context.get('view_mode', False):
927 return result
928 fld = []
929 fields = {}
930 flds = []
931 title = _("Accounting Entries") #self.view_header_get(cr, uid, view_id, view_type, context)
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)
933
934 ids = journal_pool.search(cr, uid, [])
935 journals = journal_pool.browse(cr, uid, ids, context=context)
936 all_journal = [None]
937 common_fields = {}
938 total = len(journals)
939 for journal in journals:
940 all_journal.append(journal.id)
941 for field in journal.view_id.columns_id:
942 if not field.field in fields:
943 fields[field.field] = [journal.id]
944 fld.append((field.field, field.sequence, field.name))
945 flds.append(field.field)
946 common_fields[field.field] = 1
947 else:
948 fields.get(field.field).append(journal.id)
949 common_fields[field.field] = common_fields[field.field] + 1
950 fld.append(('period_id', 3, _('Period')))
951 fld.append(('journal_id', 10, _('Journal')))
952 flds.append('period_id')
953 flds.append('journal_id')
954 fields['period_id'] = all_journal
955 fields['journal_id'] = all_journal
956 fld = sorted(fld, key=itemgetter(1))
957 widths = {
958 'statement_id': 50,
959 'state': 60,
960 'tax_code_id': 50,
961 'move_id': 40,
962 }
963 for field_it in fld:
964 field = field_it[0]
965 if common_fields.get(field) == total:
966 fields.get(field).append(None)
967# if field=='state':
968# state = 'colors="red:state==\'draft\'"'
969 attrs = []
970 if field == 'debit':
971 attrs.append('sum = "%s"' % _("Total debit"))
972
973 elif field == 'credit':
974 attrs.append('sum = "%s"' % _("Total credit"))
975
976 elif field == 'move_id':
977 attrs.append('required = "False"')
978
979 elif field == 'account_tax_id':
980 attrs.append('domain="[(\'parent_id\', \'=\' ,False)]"')
981 attrs.append("context=\"{'journal_id': journal_id}\"")
982
983 elif field == 'account_id' and journal.id:
984 attrs.append('domain="[(\'journal_id\', \'=\', '+str(journal.id)+'),(\'type\',\'&lt;&gt;\',\'view\'), (\'type\',\'&lt;&gt;\',\'closed\')]" on_change="onchange_account_id(account_id, partner_id)"')
985
986 elif field == 'partner_id':
987 attrs.append('on_change="onchange_partner_id(move_id, partner_id, account_id, debit, credit, date, journal_id)"')
988
989 elif field == 'journal_id':
990 attrs.append("context=\"{'journal_id': journal_id}\"")
991
992 elif field == 'statement_id':
993 attrs.append("domain=\"[('state', '!=', 'confirm'),('journal_id.type', '=', 'bank')]\"")
994
995 elif field == 'date':
996 attrs.append('on_change="onchange_date(date)"')
997
998 elif field == 'analytic_account_id':
999 attrs.append('''groups="analytic.group_analytic_accounting"''') # Currently it is not working due to framework problem may be ..
1000
1001 if field in ('amount_currency', 'currency_id'):
1002 attrs.append('on_change="onchange_currency(account_id, amount_currency, currency_id, date, journal_id)"')
1003 attrs.append('''attrs="{'readonly': [('state', '=', 'valid')]}"''')
1004
1005 if field in widths:
1006 attrs.append('width="'+str(widths[field])+'"')
1007
1008 if field in ('journal_id',):
1009 attrs.append("invisible=\"context.get('journal_id', False)\"")
1010 elif field in ('period_id',):
1011 attrs.append("invisible=\"context.get('period_id', False)\"")
1012 else:
1013 attrs.append("invisible=\"context.get('visible_id') not in %s\"" % (fields.get(field)))
1014 xml += '''<field name="%s" %s/>\n''' % (field,' '.join(attrs))
1015
1016 xml += '''</tree>'''
1017 result['arch'] = xml
1018 result['fields'] = self.fields_get(cr, uid, flds, context)
1019 return result
1020
1021 def _check_moves(self, cr, uid, context=None):814 def _check_moves(self, cr, uid, context=None):
1022 # use the first move ever created for this journal and period815 # use the first move ever created for this journal and period
1023 if context is None:816 if context is None:
@@ -1330,15 +1123,6 @@
1330 if a.id == vals['account_id']:1123 if a.id == vals['account_id']:
1331 ok = True1124 ok = True
1332 break1125 break
1333 # Automatically convert in the account's secondary currency if there is one and
1334 # the provided values were not already multi-currency
1335 if account.currency_id and 'amount_currency' not in vals and account.currency_id.id != account.company_id.currency_id.id:
1336 vals['currency_id'] = account.currency_id.id
1337 ctx = {}
1338 if 'date' in vals:
1339 ctx['date'] = vals['date']
1340 vals['amount_currency'] = cur_obj.compute(cr, uid, account.company_id.currency_id.id,
1341 account.currency_id.id, vals.get('debit', 0.0)-vals.get('credit', 0.0), context=ctx)
1342 if not ok:1126 if not ok:
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 !'))
13441128
13451129
=== modified file 'bin/addons/account/invoice.py'
--- bin/addons/account/invoice.py 2019-07-25 14:58:06 +0000
+++ bin/addons/account/invoice.py 2019-10-30 13:23:20 +0000
@@ -27,6 +27,7 @@
27from osv import fields, osv, orm27from osv import fields, osv, orm
28from tools.translate import _28from tools.translate import _
29from msf_partner import PARTNER_TYPE29from msf_partner import PARTNER_TYPE
30from base import currency_date
3031
3132
32class account_invoice(osv.osv):33class account_invoice(osv.osv):
@@ -1724,6 +1725,7 @@
1724 return res_final1725 return res_final
17251726
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)
1728 # DONE: TEST JN => no date in context
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)
17281730
1729 if company.currency_id.id != currency.id:1731 if company.currency_id.id != currency.id:
@@ -1918,7 +1920,7 @@
1918 tax_amount = round(atx.amount * amount_untaxed, 2)1920 tax_amount = round(atx.amount * amount_untaxed, 2)
1919 return tax_amount1921 return tax_amount
19201922
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):
1922 cur_obj = self.pool.get('res.currency')1924 cur_obj = self.pool.get('res.currency')
1923 company_obj = self.pool.get('res.company')1925 company_obj = self.pool.get('res.company')
1924 company_currency = False1926 company_currency = False
@@ -1928,10 +1930,13 @@
1928 if company_id:1930 if company_id:
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]
1930 if currency_id and company_currency:1932 if currency_id and company_currency:
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
1934 curr_date = currency_date.get_date(self, cr, document_date, date_invoice)
1935 base = cur_obj.compute(cr, uid, currency_id, company_currency, base*factor,
1936 context={'currency_date': curr_date or time.strftime('%Y-%m-%d')}, round=False)
1932 return {'value': {'base_amount':base}}1937 return {'value': {'base_amount':base}}
19331938
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):
1935 cur_obj = self.pool.get('res.currency')1940 cur_obj = self.pool.get('res.currency')
1936 company_obj = self.pool.get('res.company')1941 company_obj = self.pool.get('res.company')
1937 company_currency = False1942 company_currency = False
@@ -1941,7 +1946,10 @@
1941 if company_id:1946 if company_id:
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]
1943 if currency_id and company_currency:1948 if currency_id and company_currency:
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
1950 curr_date = currency_date.get_date(self, cr, document_date, date_invoice)
1951 amount = cur_obj.compute(cr, uid, currency_id, company_currency, amount*factor,
1952 context={'currency_date': curr_date or time.strftime('%Y-%m-%d')}, round=False)
1945 return {'value': {'tax_amount': amount}}1953 return {'value': {'tax_amount': amount}}
19461954
1947 _order = 'sequence'1955 _order = 'sequence'
@@ -1952,6 +1960,8 @@
1952 'sequence': 0,1960 'sequence': 0,
1953 }1961 }
1954 def compute(self, cr, uid, invoice_id, context=None):1962 def compute(self, cr, uid, invoice_id, context=None):
1963 if context is None:
1964 context = {}
1955 tax_grouped = {}1965 tax_grouped = {}
1956 tax_obj = self.pool.get('account.tax')1966 tax_obj = self.pool.get('account.tax')
1957 cur_obj = self.pool.get('res.currency')1967 cur_obj = self.pool.get('res.currency')
@@ -1973,14 +1983,22 @@
1973 if inv.type in ('out_invoice','in_invoice'):1983 if inv.type in ('out_invoice','in_invoice'):
1974 val['base_code_id'] = tax['base_code_id']1984 val['base_code_id'] = tax['base_code_id']
1975 val['tax_code_id'] = tax['tax_code_id']1985 val['tax_code_id'] = tax['tax_code_id']
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
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)
1988 val['base_amount'] = cur_obj.compute(cr, uid, inv.currency_id.id, company_currency, val['base'] * tax['base_sign'],
1989 context={'currency_date': curr_date or time.strftime('%Y-%m-%d')}, round=False)
1990 val['tax_amount'] = cur_obj.compute(cr, uid, inv.currency_id.id, company_currency, val['amount'] * tax['tax_sign'],
1991 context={'currency_date': curr_date or time.strftime('%Y-%m-%d')}, round=False)
1978 val['account_id'] = tax['account_collected_id'] or line.account_id.id1992 val['account_id'] = tax['account_collected_id'] or line.account_id.id
1979 else:1993 else:
1980 val['base_code_id'] = tax['ref_base_code_id']1994 val['base_code_id'] = tax['ref_base_code_id']
1981 val['tax_code_id'] = tax['ref_tax_code_id']1995 val['tax_code_id'] = tax['ref_tax_code_id']
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
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)
1998 val['base_amount'] = cur_obj.compute(cr, uid, inv.currency_id.id, company_currency, val['base'] * tax['ref_base_sign'],
1999 context={'currency_date': curr_date or time.strftime('%Y-%m-%d')}, round=False)
2000 val['tax_amount'] = cur_obj.compute(cr, uid, inv.currency_id.id, company_currency, val['amount'] * tax['ref_tax_sign'],
2001 context={'currency_date': curr_date or time.strftime('%Y-%m-%d')}, round=False)
1984 val['account_id'] = tax['account_paid_id'] or line.account_id.id2002 val['account_id'] = tax['account_paid_id'] or line.account_id.id
19852003
1986 key = tax['id'] # taxes are grouped by id2004 key = tax['id'] # taxes are grouped by id
19872005
=== modified file 'bin/addons/account/project/project_view.xml'
--- bin/addons/account/project/project_view.xml 2018-06-25 13:34:58 +0000
+++ bin/addons/account/project/project_view.xml 2019-10-30 13:23:20 +0000
@@ -176,24 +176,14 @@
176 </form>176 </form>
177 </field>177 </field>
178 </record>178 </record>
179
180 <!-- see ./bin/addons/finance/account_analytic_line_view.xml -->
179 <record id="view_account_analytic_line_tree" model="ir.ui.view">181 <record id="view_account_analytic_line_tree" model="ir.ui.view">
180 <field name="name">account.analytic.line.tree</field>182 <field name="name">account.analytic.line.tree</field>
181 <field name="model">account.analytic.line</field>183 <field name="model">account.analytic.line</field>
182 <field name="type">tree</field>184 <field name="type">tree</field>
183 <field name="arch" type="xml">185 <field name="arch" type="xml">
184 <tree editable="top" string="Analytic Entries">186 <tree />
185 <field name="date"/>
186 <field name="ref" invisible="context.get('to_invoice', False)"/>
187 <field name="name"/>
188 <field name="journal_id" invisible="context.get('to_invoice', False)"/>
189 <field name="amount" sum="Total" invisible="context.get('to_invoice', False)"/>
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)"/>
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)"/>
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)"/>
193 <field domain="[('type','=','normal')]" name="account_id"/>
194 <field name="general_account_id" invisible="context.get('to_invoice', False)"/>
195 <field name="user_id" invisible="1" />
196 </tree>
197 </field>187 </field>
198 </record>188 </record>
199189
@@ -294,36 +284,6 @@
294 <field eval="True" name="object"/>284 <field eval="True" name="object"/>
295 </record>285 </record>
296286
297 <record id="account_analytic_line_extended_form" model="ir.ui.view">
298 <field name="name">account.analytic.line.extended_form</field>
299 <field name="model">account.analytic.line</field>
300 <field name="type">form</field>
301 <field name="priority" eval="18"/>
302 <field name="arch" type="xml">
303 <form string="Project line">
304 <field name="name"/>
305 <field name="account_id" groups="base.group_extended"/>
306 <field name="date" on_change="on_change_unit_amount(product_id, unit_amount, company_id, product_uom_id)"/>
307 <field name="journal_id"/>
308 <field name="unit_amount" on_change="on_change_unit_amount(product_id, unit_amount, company_id, product_uom_id)"/>
309 <field name="product_id" on_change="on_change_unit_amount(product_id, unit_amount, company_id, product_uom_id, journal_id)"/>
310 <field name="product_uom_id" on_change="on_change_unit_amount(product_id, unit_amount, company_id, product_uom_id)"/>
311 <field invisible="True" name="general_account_id"/>
312 <field name="amount"/>
313 <field name="currency_id" />
314 <field name="amount_currency" />
315 <field name="company_id" on_change="on_change_unit_amount(product_id, unit_amount, company_id, product_uom_id)"/>
316 </form>
317 </field>
318 </record>
319 <record id="action_account_analytic_account_line_extended_form" model="ir.actions.act_window">
320 <field name="name">account.analytic.line.extended</field>
321 <field name="type">ir.actions.act_window</field>
322 <field name="res_model">account.analytic.line</field>
323 <field name="view_type">form</field>
324 <field name="view_id" ref="account_analytic_line_extended_form"/>
325 </record>
326
327 #287 #
328 # Analytic Journal288 # Analytic Journal
329 #289 #
330290
=== removed file 'bin/addons/account/res_currency.py'
--- bin/addons/account/res_currency.py 2017-09-29 15:41:58 +0000
+++ bin/addons/account/res_currency.py 1970-01-01 00:00:00 +0000
@@ -1,47 +0,0 @@
1# -*- coding: utf-8 -*-
2##############################################################################
3#
4# Copyright (C) 2010 OpenERP s.a. (<http://www.openerp.com>).
5#
6# This program is free software: you can redistribute it and/or modify
7# it under the terms of the GNU Affero General Public License as
8# published by the Free Software Foundation, either version 3 of the
9# License, or (at your option) any later version.
10#
11# This program is distributed in the hope that it will be useful,
12# but WITHOUT ANY WARRANTY; without even the implied warranty of
13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14# GNU Affero General Public License for more details.
15#
16# You should have received a copy of the GNU Affero General Public License
17# along with this program. If not, see <http://www.gnu.org/licenses/>.
18#
19##############################################################################
20
21from osv import osv
22
23"""Inherit res.currency to handle accounting date values when converting currencies"""
24
25class res_currency_account(osv.osv):
26 _inherit = "res.currency"
27
28 def _get_conversion_rate(self, cr, uid, from_currency, to_currency, context=None):
29 if context is None:
30 context = {}
31 rate = super(res_currency_account, self)._get_conversion_rate(cr, uid, from_currency, to_currency, context=context)
32 account = context.get('res.currency.compute.account')
33 account_invert = context.get('res.currency.compute.account_invert')
34 if account and account.currency_mode == 'average' and account.currency_id:
35 query = self.pool.get('account.move.line')._query_get(cr, uid, context=context)
36 cr.execute('''select sum(debit-credit),sum(amount_currency) from account_move_line l
37 where l.currency_id=%%s and l.account_id=%%s and %s''' % query, (account.currency_id.id,account.id,)) # not_a_user_entry
38 tot1,tot2 = cr.fetchone()
39 if tot2 and not account_invert:
40 rate = float(tot1)/float(tot2)
41 elif tot1 and account_invert:
42 rate = float(tot2)/float(tot1)
43 return rate
44
45res_currency_account()
46
47# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
480
=== modified file 'bin/addons/account/wizard/account_change_currency.py'
--- bin/addons/account/wizard/account_change_currency.py 2011-04-08 11:23:24 +0000
+++ bin/addons/account/wizard/account_change_currency.py 2019-10-30 13:23:20 +0000
@@ -50,6 +50,7 @@
50 invoice = obj_inv.browse(cr, uid, context['active_id'], context=context)50 invoice = obj_inv.browse(cr, uid, context['active_id'], context=context)
51 if invoice.currency_id.id == new_currency:51 if invoice.currency_id.id == new_currency:
52 return {}52 return {}
53 # DONE: TEST JN => cf. comm. Loic on US-5848 we keep using the date of the day here
53 rate = obj_currency.browse(cr, uid, new_currency, context=context).rate54 rate = obj_currency.browse(cr, uid, new_currency, context=context).rate
54 for line in invoice.invoice_line:55 for line in invoice.invoice_line:
55 new_price = 056 new_price = 0
5657
=== modified file 'bin/addons/account_corrections/account_move_line.py'
--- bin/addons/account_corrections/account_move_line.py 2019-01-28 13:35:47 +0000
+++ bin/addons/account_corrections/account_move_line.py 2019-10-30 13:23:20 +0000
@@ -26,6 +26,8 @@
26from tools.translate import _26from tools.translate import _
27from time import strftime27from time import strftime
28from tools.misc import flatten28from tools.misc import flatten
29from base import currency_date
30
2931
30class account_move_line(osv.osv):32class account_move_line(osv.osv):
31 _name = 'account.move.line'33 _name = 'account.move.line'
@@ -543,13 +545,15 @@
543 # update amount on new distribution545 # update amount on new distribution
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)
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)
548 # DONE: TEST JN
549 curr_date = currency_date.get_date(self, cr, ml.document_date, ml.date, source_date=ml.source_date)
546 vals.update({550 vals.update({
547 'name': name,551 'name': name,
548 'debit': ml.credit,552 'debit': ml.credit,
549 'credit': ml.debit,553 'credit': ml.debit,
550 'amount_currency': amt,554 'amount_currency': amt,
551 'reversal_line_id': ml.id,555 'reversal_line_id': ml.id,
552 'source_date': ml.source_date or ml.date,556 'source_date': curr_date,
553 'reversal': True,557 'reversal': True,
554 'reference': ml.move_id and ml.move_id.name or '',558 'reference': ml.move_id and ml.move_id.name or '',
555 'ref': ml.move_id and ml.move_id.name or '',559 'ref': ml.move_id and ml.move_id.name or '',
@@ -746,6 +750,8 @@
746 # Do the reverse750 # Do the reverse
747 name = self.join_without_redundancy(ml.name, 'REV')751 name = self.join_without_redundancy(ml.name, 'REV')
748 amt = -1 * ml.amount_currency752 amt = -1 * ml.amount_currency
753 # DONE: TEST JN
754 curr_date = currency_date.get_date(self, cr, ml.document_date, ml.date, source_date=ml.source_date)
749 vals.update({755 vals.update({
750 'debit': ml.credit,756 'debit': ml.credit,
751 'credit': ml.debit,757 'credit': ml.debit,
@@ -754,7 +760,7 @@
754 'name': name,760 'name': name,
755 'reversal_line_id': ml.id,761 'reversal_line_id': ml.id,
756 'account_id': ml.account_id.id,762 'account_id': ml.account_id.id,
757 'source_date': ml.source_date or ml.date,763 'source_date': curr_date,
758 'reversal': True,764 'reversal': True,
759 'document_date': ml.document_date,765 'document_date': ml.document_date,
760 'reference': ml.move_id and ml.move_id.name or '',766 'reference': ml.move_id and ml.move_id.name or '',
@@ -768,7 +774,7 @@
768 'journal_id': journal_id,774 'journal_id': journal_id,
769 'corrected_line_id': ml.id,775 'corrected_line_id': ml.id,
770 'account_id': new_account_id,776 'account_id': new_account_id,
771 'source_date': ml.source_date or ml.date,777 'source_date': curr_date,
772 'have_an_historic': True,778 'have_an_historic': True,
773 'document_date': ml.document_date,779 'document_date': ml.document_date,
774 'reference': ml.move_id and ml.move_id.name or '',780 'reference': ml.move_id and ml.move_id.name or '',
775781
=== modified file 'bin/addons/account_corrections/wizard/analytic_distribution_wizard.py'
--- bin/addons/account_corrections/wizard/analytic_distribution_wizard.py 2019-10-15 16:08:57 +0000
+++ bin/addons/account_corrections/wizard/analytic_distribution_wizard.py 2019-10-30 13:23:20 +0000
@@ -26,6 +26,8 @@
26from tools.translate import _26from tools.translate import _
27import time27import time
28from collections import defaultdict28from collections import defaultdict
29from base import currency_date
30
2931
30class analytic_distribution_wizard(osv.osv_memory):32class analytic_distribution_wizard(osv.osv_memory):
31 _inherit = 'analytic.distribution.wizard'33 _inherit = 'analytic.distribution.wizard'
@@ -150,9 +152,13 @@
150 ana_line_obj = self.pool.get('account.analytic.line')152 ana_line_obj = self.pool.get('account.analytic.line')
151 company_currency_id = self.pool.get('res.users').browse(cr, uid, uid).company_id.currency_id.id153 company_currency_id = self.pool.get('res.users').browse(cr, uid, uid).company_id.currency_id.id
152 ml = wizard.move_line_id154 ml = wizard.move_line_id
153 orig_date = ml.source_date or ml.date155 # US-5848: orig_date left unchanged not to break historical behavior,
156 # but the value set here seems overwritten later in the process if there is a source_date
157 orig_date = ml.source_date or ml.date # DONE: TEST JN
154 orig_document_date = ml.document_date158 orig_document_date = ml.document_date
155 posting_date = wizard.date159 posting_date = wizard.date
160 # DONE: TEST JN
161 curr_date = currency_date.get_date(self, cr, ml.document_date, ml.date, source_date=ml.source_date)
156 working_period_id = []162 working_period_id = []
157 new_line_ids = []163 new_line_ids = []
158 entry_seq_data = {}164 entry_seq_data = {}
@@ -363,7 +369,10 @@
363 if keep_seq_and_corrected[4]:369 if keep_seq_and_corrected[4]:
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')
365371
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
373 created_analytic_line_ids = self.pool.get('funding.pool.distribution.line').\
374 create_analytic_lines(cr, uid, [new_distrib_line], ml.id, date=create_date, document_date=orig_document_date,
375 source_date=curr_date, name=name, context=context)
367 new_line_ids.extend(created_analytic_line_ids.values())376 new_line_ids.extend(created_analytic_line_ids.values())
368 working_period_id = working_period_id or \377 working_period_id = working_period_id or \
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)
@@ -425,8 +434,9 @@
425 if cp.state != 'draft':434 if cp.state != 'draft':
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,))
427 # Create the new ana line436 # Create the new ana line
437 # DONE: TEST JN
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,
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)
430 new_line_ids.extend(ret.values())440 new_line_ids.extend(ret.values())
431 working_period_id = working_period_id or period_ids441 working_period_id = working_period_id or period_ids
432 # Add link to first analytic lines442 # Add link to first analytic lines
@@ -443,7 +453,8 @@
443 for line in to_override:453 for line in to_override:
444 # update the ana line454 # update the ana line
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)])
446 ctx = {'date': orig_date}456 # DONE: TEST JN
457 ctx = {'currency_date': curr_date}
447 amount_cur = (ml.credit_currency - ml.debit_currency) * line.percentage / 100458 amount_cur = (ml.credit_currency - ml.debit_currency) * line.percentage / 100
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)
449460
@@ -479,12 +490,13 @@
479 has_generated_cor = True490 has_generated_cor = True
480 # compute the adjustment amount491 # compute the adjustment amount
481 all_aji_ids = ana_line_obj.search(cr, uid, [492 all_aji_ids = ana_line_obj.search(cr, uid, [
482 ('move_id', '=', ml.id),493 ('move_id', '=', ml.id),
483 ('is_reversal', '=', False),494 ('is_reversal', '=', False),
484 ('is_reallocated', '=', False),495 ('is_reallocated', '=', False),
485 ], order='NO_ORDER', context=context)496 ('account_id.category', '=', 'FUNDING'), # exclude free lines
497 ], order='NO_ORDER', context=context)
486 max_line = {'amount': 0, 'aji_bro': False}498 max_line = {'amount': 0, 'aji_bro': False}
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']
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):
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)
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']:
@@ -511,10 +523,10 @@
511 # then recompute functional amount523 # then recompute functional amount
512 if fix_aji_currency_id:524 if fix_aji_currency_id:
513 new_context = context.copy()525 new_context = context.copy()
514 if max_line['aji_bro'].source_date:526 # DONE: TEST JN
515 new_context['date'] = max_line['aji_bro'].source_date527 max_line_curr_date = currency_date.get_date(self, cr, max_line['aji_bro'].document_date, max_line['aji_bro'].date,
516 else:528 source_date=max_line['aji_bro'].source_date)
517 new_context['date'] = max_line['aji_bro'].date529 new_context['currency_date'] = max_line_curr_date
518 aji_fix_vals['amount'] = \530 aji_fix_vals['amount'] = \
519 self.pool.get('res.currency').compute(cr, uid,531 self.pool.get('res.currency').compute(cr, uid,
520 fix_aji_currency_id, company_currency_id,532 fix_aji_currency_id, company_currency_id,
@@ -570,15 +582,17 @@
570 for line in to_override:582 for line in to_override:
571 # update the ana line583 # update the ana line
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)])
573 ctx = {'date': orig_date}585 # DONE: TEST JN
586 ctx = {'currency_date': curr_date}
574 amount_cur = (ml.credit_currency - ml.debit_currency) * line.percentage / 100587 amount_cur = (ml.credit_currency - ml.debit_currency) * line.percentage / 100
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)
589 # the posting date is the one of the entry corrected
576 ana_line_obj.write(cr, uid, to_override_ids, {590 ana_line_obj.write(cr, uid, to_override_ids, {
577 'account_id': line.analytic_id.id,591 'account_id': line.analytic_id.id,
578 'amount_currency': amount_cur,592 'amount_currency': amount_cur,
579 'amount': amount,593 'amount': amount,
580 'date': orig_date,594 'date': ml.date, # DONE: TEST JN
581 'source_date': orig_date,595 'source_date': curr_date, # DONE: TEST JN
582 'document_date': orig_document_date,596 'document_date': orig_document_date,
583 })597 })
584 # update the distib line598 # update the distib line
@@ -596,7 +610,10 @@
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,
597 })611 })
598 # create the ana line612 # create the ana line
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
614 # the posting date is the one of the entry corrected
615 self.pool.get(obj_name).create_analytic_lines(cr, uid, [new_distrib_line], ml.id, date=ml.date,
616 document_date=orig_document_date, source_date=curr_date, ref=ml.ref)
600 # Set move line as corrected upstream if needed617 # Set move line as corrected upstream if needed
601 if to_reverse or to_override or to_create:618 if to_reverse or to_override or to_create:
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)
603620
=== modified file 'bin/addons/account_hq_entries/wizard/hq_entries_validation.py'
--- bin/addons/account_hq_entries/wizard/hq_entries_validation.py 2019-01-09 12:52:42 +0000
+++ bin/addons/account_hq_entries/wizard/hq_entries_validation.py 2019-10-30 13:23:20 +0000
@@ -25,6 +25,8 @@
25from osv import fields25from osv import fields
26from tools.translate import _26from tools.translate import _
27from time import strftime27from time import strftime
28from base import currency_date
29
2830
29class hq_entries_validation(osv.osv_memory):31class hq_entries_validation(osv.osv_memory):
30 _name = 'hq.entries.validation'32 _name = 'hq.entries.validation'
@@ -105,11 +107,13 @@
105 (account.default_destination_id and account.default_destination_id.id) or False107 (account.default_destination_id and account.default_destination_id.id) or False
106 distrib_id = self.pool.get('analytic.distribution').create(cr, uid, {})108 distrib_id = self.pool.get('analytic.distribution').create(cr, uid, {})
107 if distrib_id:109 if distrib_id:
110 # DONE: TEST JN
111 curr_date = currency_date.get_date(self, cr, line.document_date or line.date, line.date)
108 common_vals = {'distribution_id':distrib_id,112 common_vals = {'distribution_id':distrib_id,
109 'currency_id':currency_id,113 'currency_id':currency_id,
110 'percentage':100.0,114 'percentage':100.0,
111 'date':line.date or current_date,115 'date':line.date or current_date,
112 'source_date':line.date or current_date,116 'source_date': curr_date or current_date,
113 'destination_id':destination_id}117 'destination_id':destination_id}
114 common_vals.update({'analytic_id':cc_id})118 common_vals.update({'analytic_id':cc_id})
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)
@@ -126,7 +130,7 @@
126 return distrib_id130 return distrib_id
127131
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,
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):
130 """134 """
131 Create a move with given hq entries lines135 Create a move with given hq entries lines
132 Return created lines (except counterpart lines)136 Return created lines (except counterpart lines)
@@ -188,7 +192,7 @@
188 'journal_id': journal_id,192 'journal_id': journal_id,
189 'date': line.date,193 'date': line.date,
190 'date_maturity': line.date,194 'date_maturity': line.date,
191 'document_date': line.document_date,195 'document_date': line.document_date or line.date,
192 'move_id': move_id,196 'move_id': move_id,
193 'analytic_distribution_id': distrib_id,197 'analytic_distribution_id': distrib_id,
194 'name': line.name or '',198 'name': line.name or '',
@@ -196,6 +200,9 @@
196 'partner_txt': line.partner_txt or '',200 'partner_txt': line.partner_txt or '',
197 'reference': line.ref or ''201 'reference': line.ref or ''
198 }202 }
203 # DONE: TEST JN
204 if source_date is not None:
205 vals.update({'source_date': source_date, })
199 # Fetch debit/credit206 # Fetch debit/credit
200 debit = 0.0207 debit = 0.0
201 credit = 0.0208 credit = 0.0
@@ -294,8 +301,10 @@
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)
295 original_account_id = original_move.account_id.id302 original_account_id = original_move.account_id.id
296303
304 # DONE: TEST JN
305 curr_date = currency_date.get_date(self, cr, line.document_date or line.date, line.date)
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,
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,
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)
300 # original move line309 # original move line
301 original_ml_result = res_move[line.id]310 original_ml_result = res_move[line.id]
@@ -329,7 +338,8 @@
329 'reversal_line_id': original_move.id,338 'reversal_line_id': original_move.id,
330 'partner_txt': original_move.partner_txt or '',339 'partner_txt': original_move.partner_txt or '',
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 problem340 '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
332 'document_date': line.document_date, # US-1361341 'document_date': line.document_date or line.date,
342 'source_date': curr_date, # DONE: TEST JN
333 }, context=context, check=False, update_check=False)343 }, context=context, check=False, update_check=False)
334344
335 # create the analytic lines as a reversed copy of the original345 # create the analytic lines as a reversed copy of the original
@@ -453,7 +463,9 @@
453 split_change.append(line)463 split_change.append(line)
454 continue464 continue
455 if not line.user_validated:465 if not line.user_validated:
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
467 to_write.setdefault(line.currency_id.id, {}).setdefault(line.period_id.id, {}).\
468 setdefault(line.date, {}).setdefault(document_date, []).append(line.id)
457469
458 if line.account_id.id != line.account_id_first_value.id:470 if line.account_id.id != line.account_id_first_value.id:
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:
@@ -483,20 +495,23 @@
483 for currency in to_write:495 for currency in to_write:
484 for period in to_write[currency]:496 for period in to_write[currency]:
485 for date in to_write[currency][period]:497 for date in to_write[currency][period]:
486 lines = to_write[currency][period][date]498 for doc_date in to_write[currency][period][date]:
487 write = self.create_move(cr, uid, lines, period, currency, date)499 lines = to_write[currency][period][date][doc_date]
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)
489 if write:501 all_lines.update(write)
490 self.pool.get('hq.entries').write(cr, uid, write.keys(), {'user_validated': True}, context=context)502 if write:
503 self.pool.get('hq.entries').write(cr, uid, write.keys(), {'user_validated': True}, context=context)
491504
492 for line in account_change:505 for line in account_change:
506 # DONE: TEST JN
507 curr_date = currency_date.get_date(self, cr, line.document_date or line.date, line.date)
493 corrected_distrib_id = self.pool.get('analytic.distribution').create(cr, uid, {508 corrected_distrib_id = self.pool.get('analytic.distribution').create(cr, uid, {
494 'funding_pool_lines': [(0, 0, {509 'funding_pool_lines': [(0, 0, {
495 'percentage': 100,510 'percentage': 100,
496 'analytic_id': line.analytic_id.id,511 'analytic_id': line.analytic_id.id,
497 'cost_center_id': line.cost_center_id.id,512 'cost_center_id': line.cost_center_id.id,
498 'currency_id': line.currency_id.id,513 'currency_id': line.currency_id.id,
499 'source_date': line.date,514 'source_date': curr_date,
500 'destination_id': line.destination_id.id,515 'destination_id': line.destination_id.id,
501 })]516 })]
502 })517 })
@@ -506,10 +521,14 @@
506 # actual distrib_id521 # actual distrib_id
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]
508 # update the distribution523 # update the distribution
524 # DONE: TEST JN
525 curr_date = currency_date.get_date(self, cr, line.document_date or line.date, line.date)
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)])
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,
528 'source_date': curr_date, 'destination_id': line.destination_id.id})
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)])
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,
531 'source_date': curr_date, 'destination_id': line.destination_id.id})
513532
514 # reverse ana lines533 # reverse ana lines
515 fp_old_lines = ana_line_obj.search(cr, uid, [534 fp_old_lines = ana_line_obj.search(cr, uid, [
@@ -529,8 +548,10 @@
529 continue548 continue
530549
531 # UTP-1118: posting date should be those from initial HQ entry line550 # UTP-1118: posting date should be those from initial HQ entry line
532 vals_cor = {'date':line.date, 'source_date':line.date, 'cost_center_id':line.cost_center_id.id,551 # DONE: TEST JN
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,
553 'account_id': line.analytic_id.id, 'destination_id': line.destination_id.id,
554 'journal_id': acor_journal_id, 'last_correction_id':fp_old_lines[0]}
534555
535 # US-1347: Use the entry sequence of HQ for reference, not the description556 # US-1347: Use the entry sequence of HQ for reference, not the description
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)
@@ -578,13 +599,15 @@
578 pure_ad_cor_ji_ids.append(all_lines[line.id])599 pure_ad_cor_ji_ids.append(all_lines[line.id])
579600
580 for line in cc_account_change:601 for line in cc_account_change:
602 # DONE: TEST JN
603 curr_date = currency_date.get_date(self, cr, line.document_date or line.date, line.date)
581 # call correct_account with a new arg: new_distrib604 # call correct_account with a new arg: new_distrib
582 corrected_distrib_id = self.pool.get('analytic.distribution').create(cr, uid, {605 corrected_distrib_id = self.pool.get('analytic.distribution').create(cr, uid, {
583 'cost_center_lines': [(0, 0, {606 'cost_center_lines': [(0, 0, {
584 'percentage': 100,607 'percentage': 100,
585 'analytic_id': line.cost_center_id.id,608 'analytic_id': line.cost_center_id.id,
586 'currency_id': line.currency_id.id,609 'currency_id': line.currency_id.id,
587 'source_date': line.date,610 'source_date': curr_date,
588 'destination_id': line.destination_id.id,611 'destination_id': line.destination_id.id,
589 })],612 })],
590 'funding_pool_lines': [(0, 0, {613 'funding_pool_lines': [(0, 0, {
@@ -592,7 +615,7 @@
592 'analytic_id': line.analytic_id.id,615 'analytic_id': line.analytic_id.id,
593 'cost_center_id': line.cost_center_id.id,616 'cost_center_id': line.cost_center_id.id,
594 'currency_id': line.currency_id.id,617 'currency_id': line.currency_id.id,
595 'source_date': line.date,618 'source_date': curr_date,
596 'destination_id': line.destination_id.id,619 'destination_id': line.destination_id.id,
597 })]620 })]
598 })621 })
599622
=== modified file 'bin/addons/account_mcdb/account_analytic_line.py'
--- bin/addons/account_mcdb/account_analytic_line.py 2017-04-19 09:37:05 +0000
+++ bin/addons/account_mcdb/account_analytic_line.py 2019-10-30 13:23:20 +0000
@@ -26,6 +26,8 @@
26from time import strftime26from time import strftime
27from lxml import etree27from lxml import etree
28from tools.translate import _28from tools.translate import _
29from base import currency_date
30
2931
30class account_analytic_line(osv.osv):32class account_analytic_line(osv.osv):
31 _name = 'account.analytic.line'33 _name = 'account.analytic.line'
@@ -35,6 +37,8 @@
35 """37 """
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)
37 """39 """
40 if context is None:
41 context = {}
38 # Prepare some value42 # Prepare some value
39 res = {}43 res = {}
40 # Some verifications44 # Some verifications
@@ -48,27 +52,32 @@
48 # Retrieve currency52 # Retrieve currency
49 currency_id = context.get('output_currency_id')53 currency_id = context.get('output_currency_id')
50 currency_obj = self.pool.get('res.currency')54 currency_obj = self.pool.get('res.currency')
55 # DONE: TEST JN => the context is not important here
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)
52 # Do calculation57 # Do calculation
53 if not rate:58 if not rate:
54 for out_id in ids:59 for out_id in ids:
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}
56 return res61 return res
57 for ml in self.browse(cr, uid, ids, context=context):62 aal_fields = ['document_date', 'date', 'source_date', 'currency_id', 'amount_currency']
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):
64 res[aal.id] = {'output_currency': False, 'output_amount': 0.0, 'output_amount_debit': 0.0, 'output_amount_credit': 0.0}
59 # output_amount field65 # output_amount field
60 # Update with date66 # Update with date
61 context.update({'date': ml.source_date or ml.date or strftime('%Y-%m-%d')})67 # DONE: TEST JN
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)
63 res[ml.id]['output_amount'] = mnt or 0.069 context.update({'currency_date': curr_date or strftime('%Y-%m-%d')})
70 mnt = self.pool.get('res.currency').compute(cr, uid, aal.currency_id.id, currency_id, aal.amount_currency,
71 round=True, context=context)
72 res[aal.id]['output_amount'] = mnt or 0.0
64 if mnt < 0.0:73 if mnt < 0.0:
65 res[ml.id]['output_amount_debit'] = 0.074 res[aal.id]['output_amount_debit'] = 0.0
66 res[ml.id]['output_amount_credit'] = abs(mnt) or 0.075 res[aal.id]['output_amount_credit'] = abs(mnt) or 0.0
67 else:76 else:
68 res[ml.id]['output_amount_debit'] = abs(mnt) or 0.077 res[aal.id]['output_amount_debit'] = abs(mnt) or 0.0
69 res[ml.id]['output_amount_credit'] = 0.078 res[aal.id]['output_amount_credit'] = 0.0
70 # or output_currency field79 # or output_currency field
71 res[ml.id]['output_currency'] = currency_id80 res[aal.id]['output_currency'] = currency_id
72 return res81 return res
7382
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):
7584
=== modified file 'bin/addons/account_mcdb/account_bank_statement.py'
--- bin/addons/account_mcdb/account_bank_statement.py 2014-04-15 08:35:03 +0000
+++ bin/addons/account_mcdb/account_bank_statement.py 2019-10-30 13:23:20 +0000
@@ -25,6 +25,8 @@
25from osv import fields25from osv import fields
26from time import strftime26from time import strftime
27from lxml import etree27from lxml import etree
28from base import currency_date
29
2830
29class account_bank_statement_line(osv.osv):31class account_bank_statement_line(osv.osv):
30 _name = 'account.bank.statement.line'32 _name = 'account.bank.statement.line'
@@ -34,6 +36,8 @@
34 """36 """
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)
36 """38 """
39 if context is None:
40 context = {}
37 # Prepare some value41 # Prepare some value
38 res = {}42 res = {}
39 # Some verifications43 # Some verifications
@@ -47,6 +51,7 @@
47 # Retrieve currency51 # Retrieve currency
48 currency_id = context.get('output_currency_id')52 currency_id = context.get('output_currency_id')
49 currency_obj = self.pool.get('res.currency')53 currency_obj = self.pool.get('res.currency')
54 # DONE: TEST JN => the context is not important here
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)
51 # Do calculation56 # Do calculation
52 if not rate:57 if not rate:
@@ -57,7 +62,9 @@
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}
58 # output_amount field63 # output_amount field
59 # Update with date64 # Update with date
60 context.update({'date': absl.date or strftime('%Y-%m-%d')})65 # DONE: TEST JN
66 curr_date = currency_date.get_date(self, cr, absl.document_date, absl.date)
67 context.update({'currency_date': curr_date or strftime('%Y-%m-%d')})
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)
62 res[absl.id]['output_amount'] = mnt or 0.069 res[absl.id]['output_amount'] = mnt or 0.0
63 if mnt < 0.0:70 if mnt < 0.0:
6471
=== modified file 'bin/addons/account_mcdb/account_move_line.py'
--- bin/addons/account_mcdb/account_move_line.py 2019-02-06 10:04:42 +0000
+++ bin/addons/account_mcdb/account_move_line.py 2019-10-30 13:23:20 +0000
@@ -25,6 +25,8 @@
25from osv import fields25from osv import fields
26from time import strftime26from time import strftime
27from lxml import etree27from lxml import etree
28from base import currency_date
29
2830
29class account_move_line(osv.osv):31class account_move_line(osv.osv):
30 _name = 'account.move.line'32 _name = 'account.move.line'
@@ -53,6 +55,7 @@
53 return func_amount55 return func_amount
54 original_currency = ml.functional_currency_id.id56 original_currency = ml.functional_currency_id.id
55 # Perform the conversion from original currency to selected currency57 # Perform the conversion from original currency to selected currency
58 # DONE: TEST JN => there is only a "currency_date" in context (no "date")
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)
5760
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):
@@ -76,6 +79,7 @@
76 company_currency_id = self.pool.get('res.users').browse(cr, uid, uid, context=context).company_id.currency_id.id79 company_currency_id = self.pool.get('res.users').browse(cr, uid, uid, context=context).company_id.currency_id.id
77 currency_id = context.get('output_currency_id')80 currency_id = context.get('output_currency_id')
78 currency_obj = self.pool.get('res.currency')81 currency_obj = self.pool.get('res.currency')
82 # DONE: TEST JN => the context is not important here
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)
80 # Do calculation84 # Do calculation
81 if not rate:85 if not rate:
@@ -86,7 +90,9 @@
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}
87 # output_amount field91 # output_amount field
88 # Update with date92 # Update with date
89 context.update({'date': ml.source_date or ml.date or strftime('%Y-%m-%d')})93 # DONE: TEST JN
94 curr_date = currency_date.get_date(self, cr, ml.document_date, ml.date, source_date=ml.source_date)
95 context.update({'currency_date': curr_date or strftime('%Y-%m-%d')})
90 # Now call the common method to calculate the output values96 # Now call the common method to calculate the output values
91 if currency_id == company_currency_id:97 if currency_id == company_currency_id:
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})
9399
=== modified file 'bin/addons/account_mcdb/report/account_mcdb_export.py'
--- bin/addons/account_mcdb/report/account_mcdb_export.py 2017-07-06 14:23:27 +0000
+++ bin/addons/account_mcdb/report/account_mcdb_export.py 2019-10-30 13:23:20 +0000
@@ -24,6 +24,9 @@
24from osv import osv24from osv import osv
25from osv import fields25from osv import fields
26from tools.translate import _26from tools.translate import _
27from time import strftime
28from base import currency_date
29
2730
28def get_back_browse(self, cr, uid, context):31def get_back_browse(self, cr, uid, context):
29 background_id = context.get('background_id')32 background_id = context.get('background_id')
@@ -240,11 +243,9 @@
240 csv_line.append(company_currency.encode('utf-8') or '')243 csv_line.append(company_currency.encode('utf-8') or '')
241 else:244 else:
242 #output debit/credit245 #output debit/credit
243 context['date'] = al.source_date or al.date # uftp-361 [FIX] reversal line: source_date or posting_date246 # DONE: TEST JN
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)
245 context.update({'date': al.document_date})248 context['currency_date'] = curr_date
246 if al.last_corrected_id:
247 context.update({'date': al.document_date})
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)
249 csv_line.append(amount or 0.0)250 csv_line.append(amount or 0.0)
250 #output currency251 #output currency
@@ -313,6 +314,9 @@
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 '')
314 else:315 else:
315 #output amount (debit/credit) regarding booking currency316 #output amount (debit/credit) regarding booking currency
317 # DONE: TEST JN
318 curr_date = currency_date.get_date(self, cr, absl.document_date, absl.date)
319 context.update({'currency_date': curr_date or strftime('%Y-%m-%d')})
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)
317 if amount < 0.0:321 if amount < 0.0:
318 csv_line.append(0.0)322 csv_line.append(0.0)
319323
=== modified file 'bin/addons/account_override/account.py'
--- bin/addons/account_override/account.py 2019-09-27 08:59:21 +0000
+++ bin/addons/account_override/account.py 2019-10-30 13:23:20 +0000
@@ -90,6 +90,7 @@
90 (__compute will handle their escaping) as a90 (__compute will handle their escaping) as a
91 tuple91 tuple
92 """92 """
93 # DONE: TEST JN => there is no "date" in context
93 mapping = {94 mapping = {
94 'balance': "COALESCE(SUM(l.debit),0) " \95 'balance': "COALESCE(SUM(l.debit),0) " \
95 "- COALESCE(SUM(l.credit), 0) as balance",96 "- COALESCE(SUM(l.credit), 0) as balance",
@@ -997,6 +998,7 @@
997 if 'document_date' in vals:998 if 'document_date' in vals:
998 context['document_date'] = vals.get('document_date')999 context['document_date'] = vals.get('document_date')
999 if 'date' in vals:1000 if 'date' in vals:
1001 # DONE: TEST JN => this date isn't used for amount computation
1000 context['date'] = vals.get('date')1002 context['date'] = vals.get('date')
1001 # UTFTP-262: Make manual_name mandatory1003 # UTFTP-262: Make manual_name mandatory
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') == '':
10031005
=== modified file 'bin/addons/account_override/account_move_line.py'
--- bin/addons/account_override/account_move_line.py 2018-11-12 17:20:58 +0000
+++ bin/addons/account_override/account_move_line.py 2019-10-30 13:23:20 +0000
@@ -546,6 +546,7 @@
546 context.update({'document_date': m.document_date})546 context.update({'document_date': m.document_date})
547 if m and m.date:547 if m and m.date:
548 vals.update({'date': m.date})548 vals.update({'date': m.date})
549 # DONE: TEST JN => this date isn't used for amount computation
549 context.update({'date': m.date})550 context.update({'date': m.date})
550 # UFTP-262: Add description from the move_id (US-2027) if there is not descr. on the line551 # UFTP-262: Add description from the move_id (US-2027) if there is not descr. on the line
551 if m and m.manual_name and not vals.get('name'):552 if m and m.manual_name and not vals.get('name'):
@@ -600,6 +601,7 @@
600 context.update({'document_date': m.document_date})601 context.update({'document_date': m.document_date})
601 if m and m.date:602 if m and m.date:
602 vals.update({'date': m.date})603 vals.update({'date': m.date})
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
603 context.update({'date': m.date})605 context.update({'date': m.date})
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!
605 self._check_document_date(cr, uid, ids, vals, context=context)607 self._check_document_date(cr, uid, ids, vals, context=context)
606608
=== modified file 'bin/addons/account_override/invoice.py'
--- bin/addons/account_override/invoice.py 2019-07-25 15:47:28 +0000
+++ bin/addons/account_override/invoice.py 2019-10-30 13:23:20 +0000
@@ -973,6 +973,8 @@
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.
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.
975 """975 """
976 # Oct. 2019: log if this method is used at least once (cf it may be dead code?)
977 self.pool.get('ir.config_parameter').set_param(cr, 1, 'action_cancel.in_use', True)
976 to_cancel = []978 to_cancel = []
977 for i in self.browse(cr, uid, ids):979 for i in self.browse(cr, uid, ids):
978 if i.is_inkind_donation:980 if i.is_inkind_donation:
@@ -1934,6 +1936,7 @@
1934 std_price = p_info['standard_price']1936 std_price = p_info['standard_price']
1935 company_curr_id = self.pool.get('res.users').browse(cr, uid, uid).company_id.currency_id.id1937 company_curr_id = self.pool.get('res.users').browse(cr, uid, uid).company_id.currency_id.id
1936 if company_curr_id and company_curr_id != currency_id:1938 if company_curr_id and company_curr_id != currency_id:
1939 # DONE: TEST JN => no date in context
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)
1938 res['value']['price_unit'] = std_price1941 res['value']['price_unit'] = std_price
1939 res['value']['price_subtotal'] = (qty or 0) * std_price1942 res['value']['price_subtotal'] = (qty or 0) * std_price
19401943
=== modified file 'bin/addons/account_override/res_company.py'
--- bin/addons/account_override/res_company.py 2019-01-30 10:58:14 +0000
+++ bin/addons/account_override/res_company.py 2019-10-30 13:23:20 +0000
@@ -23,11 +23,32 @@
2323
24from osv import osv24from osv import osv
25from osv import fields25from osv import fields
26from base import currency_date
27from tools.translate import _
28
2629
27class res_company(osv.osv):30class res_company(osv.osv):
28 _name = 'res.company'31 _name = 'res.company'
29 _inherit = 'res.company'32 _inherit = 'res.company'
3033
34 def _get_currency_date_type(self, cr, uid, ids, name, args, context=None):
35 """
36 Returns the type of date used for functional amount computation in this instance
37 """
38 res = {}
39 for c_id in ids:
40 res[c_id] = currency_date.get_date_type(self, cr) == 'document' and _('Document Date') or _('Posting Date')
41 return res
42
43 def _get_currency_date_beginning(self, cr, uid, ids, name, args, context=None):
44 """
45 Returns the date from when the functional amount computation is based on the document date, if applicable
46 """
47 res = {}
48 for c_id in ids:
49 res[c_id] = currency_date.get_date_type(self, cr) == 'document' and currency_date.BEGINNING or False
50 return res
51
31 _columns = {52 _columns = {
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",
33 help="Default account for an import invoice on a Debit note"),54 help="Default account for an import invoice on a Debit note"),
@@ -36,6 +57,10 @@
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."),
37 'revaluation_default_account': fields.many2one('account.account', string="Revaluation account",58 'revaluation_default_account': fields.many2one('account.account', string="Revaluation account",
38 help="Default account used for revaluation"),59 help="Default account used for revaluation"),
60 'currency_date_type': fields.function(_get_currency_date_type, method=True, type='char',
61 string='Date Type Used', store=False, readonly=1),
62 'currency_date_beginning': fields.function(_get_currency_date_beginning, method=True, type='date',
63 string='Since', store=False, readonly=1),
39 }64 }
4065
4166
4267
=== modified file 'bin/addons/account_override/res_currency.py'
--- bin/addons/account_override/res_currency.py 2014-03-06 16:53:18 +0000
+++ bin/addons/account_override/res_currency.py 2019-10-30 13:23:20 +0000
@@ -33,62 +33,3 @@
3333
34res_currency_rate()34res_currency_rate()
3535
36class res_currency(osv.osv):
37 _name = 'res.currency'
38 _inherit = 'res.currency'
39
40 def _check_unicity_currency_name(self, cr, uid, ids, context=None):
41 """
42 Check that no currency have the same name and the same currency_table_id.
43 Check is non case-sensitive.
44 """
45 if not context:
46 context = {}
47 for c in self.browse(cr, uid, ids):
48 if not c.currency_name:
49 continue
50 sql = """SELECT id, name
51 FROM res_currency
52 WHERE currency_name ilike %s"""
53 if c.currency_table_id:
54 sql += """\nAND currency_table_id in %s"""
55 cr.execute(sql, (c.currency_name, tuple([c.currency_table_id.id])))
56 else:
57 sql += """\nAND currency_table_id is Null"""
58 cr.execute(sql, (c.currency_name,))
59 bad_ids = cr.fetchall()
60 if bad_ids and len(bad_ids) > 1:
61 return False
62 return True
63
64 def _check_unicity_name(self, cr, uid, ids, context=None):
65 """
66 Check that no currency is the same and have the same currency_table_id.
67 Check is non case-sensitive.
68 """
69 if not context:
70 context = {}
71 for c in self.browse(cr, uid, ids):
72 if not c.name:
73 continue
74 sql = """SELECT id, name
75 FROM res_currency
76 WHERE name ilike %s"""
77 if c.currency_table_id:
78 sql += """\nAND currency_table_id in %s"""
79 cr.execute(sql, (c.name, tuple([c.currency_table_id.id])))
80 else:
81 sql += """\nAND currency_table_id is Null"""
82 cr.execute(sql, (c.name,))
83 bad_ids = cr.fetchall()
84 if bad_ids and len(bad_ids) > 1:
85 return False
86 return True
87
88 _constraints = [
89 (_check_unicity_currency_name, "Another currency have the same name.", ['currency_name']),
90 (_check_unicity_name, "Same currency exists", ['name']),
91 ]
92
93res_currency()
94# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
9536
=== modified file 'bin/addons/account_payment/__init__.py'
--- bin/addons/account_payment/__init__.py 2011-01-14 00:11:01 +0000
+++ bin/addons/account_payment/__init__.py 2019-10-30 13:23:20 +0000
@@ -23,10 +23,6 @@
23# Init Sales23# Init Sales
24#----------------------------------------------------------24#----------------------------------------------------------
2525
26import account_payment26import account_invoice
27import wizard
28import account_move_line27import account_move_line
29import account_invoice
30import report
31
32# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
33\ No newline at end of file28\ No newline at end of file
29# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
3430
=== modified file 'bin/addons/account_payment/__openerp__.py'
--- bin/addons/account_payment/__openerp__.py 2017-09-28 14:05:02 +0000
+++ bin/addons/account_payment/__openerp__.py 2019-10-30 13:23:20 +0000
@@ -31,20 +31,11 @@
31* a basic mechanism to easily plug various automated payment.31* a basic mechanism to easily plug various automated payment.
32 """,32 """,
33 'author': 'OpenERP SA',33 'author': 'OpenERP SA',
34 'depends': ['account_voucher'],34 'depends': ['account'],
35 'update_xml': [35 'update_xml': [
36 'security/account_payment_security.xml',
37 'security/ir.model.access.csv',
38 'wizard/account_payment_pay_view.xml',
39 'wizard/account_payment_populate_statement_view.xml',
40 'wizard/account_payment_create_order_view.xml',
41 'account_payment_view.xml',
42 'account_payment_workflow.xml',
43 'account_payment_sequence.xml',
44 'account_invoice_view.xml',36 'account_invoice_view.xml',
45 'account_payment_report.xml',
46 ],37 ],
47 'demo_xml': ['account_payment_demo.xml'],38 'demo_xml': [],
48 'test': [39 'test': [
49 ],40 ],
50 'installable': True,41 'installable': True,
5142
=== modified file 'bin/addons/account_payment/account_move_line.py'
--- bin/addons/account_payment/account_move_line.py 2018-04-03 10:18:51 +0000
+++ bin/addons/account_payment/account_move_line.py 2019-10-30 13:23:20 +0000
@@ -19,9 +19,7 @@
19#19#
20##############################################################################20##############################################################################
2121
22from operator import itemgetter
23from osv import fields, osv22from osv import fields, osv
24from tools.translate import _
2523
26class account_move_line(osv.osv):24class account_move_line(osv.osv):
27 _inherit = "account.move.line"25 _inherit = "account.move.line"
@@ -35,84 +33,16 @@
35 CASE WHEN ml.amount_currency < 033 CASE WHEN ml.amount_currency < 0
36 THEN - ml.amount_currency34 THEN - ml.amount_currency
37 ELSE ml.credit35 ELSE ml.credit
38 END -36 END
39 (SELECT coalesce(sum(amount_currency),0)
40 FROM payment_line pl
41 INNER JOIN payment_order po
42 ON (pl.order_id = po.id)
43 WHERE move_line_id = ml.id
44 AND po.state != 'cancel') AS amount
45 FROM account_move_line ml37 FROM account_move_line ml
46 WHERE id IN %s""", (tuple(ids),))38 WHERE id IN %s""", (tuple(ids),))
47 r = dict(cr.fetchall())39 r = dict(cr.fetchall())
48 return r40 return r
4941
50 def _to_pay_search(self, cr, uid, obj, name, args, context=None):
51 if not args:
52 return []
53 line_obj = self.pool.get('account.move.line')
54 query = line_obj._query_get(cr, uid, context={})
55 where = ' and '.join(map(lambda x: '''(SELECT
56 CASE WHEN l.amount_currency < 0
57 THEN - l.amount_currency
58 ELSE l.credit
59 END - coalesce(sum(pl.amount_currency), 0)
60 FROM payment_line pl
61 INNER JOIN payment_order po ON (pl.order_id = po.id)
62 WHERE move_line_id = l.id
63 AND po.state != 'cancel'
64 ) %(operator)s %%s ''' % {'operator': x[1]}, args))
65 sql_args = tuple(map(itemgetter(2), args))
66
67 cr.execute(('''SELECT id
68 FROM account_move_line l
69 WHERE account_id IN (select id
70 FROM account_account
71 WHERE type=%s AND active)
72 AND reconcile_id IS null
73 AND credit > 0
74 AND ''' + where + ' and ' + query), ('payable',)+sql_args ) # not_a_user_entry
75
76 res = cr.fetchall()
77 if not res:
78 return [('id', '=', '0')]
79 return [('id', 'in', map(lambda x:x[0], res))]
80
81 def line2bank(self, cr, uid, ids, payment_type=None, context=None):
82 """
83 Try to return for each Ledger Posting line a corresponding bank
84 account according to the payment type. This work using one of
85 the bank of the partner defined on the invoice eventually
86 associated to the line.
87 Return the first suitable bank for the corresponding partner.
88 """
89 payment_mode_obj = self.pool.get('payment.mode')
90 line2bank = {}
91 if not ids:
92 return {}
93 bank_type = payment_mode_obj.suitable_bank_types(cr, uid, payment_type,
94 context=context)
95 for line in self.browse(cr, uid, ids, context=context):
96 line2bank[line.id] = False
97 if line.invoice and line.invoice.partner_bank_id:
98 line2bank[line.id] = line.invoice.partner_bank_id.id
99 elif line.partner_id:
100 if not line.partner_id.bank_ids:
101 line2bank[line.id] = False
102 else:
103 for bank in line.partner_id.bank_ids:
104 if bank.state in bank_type:
105 line2bank[line.id] = bank.id
106 break
107 if not line2bank[line.id] and line.partner_id.bank_ids:
108 line2bank[line.id] = line.partner_id.bank_ids[0].id
109 else:
110 raise osv.except_osv(_('Error !'), _('No partner defined on entry line'))
111 return line2bank
11242
113 _columns = {43 _columns = {
114 'amount_to_pay': fields.function(amount_to_pay, method=True,44 'amount_to_pay': fields.function(amount_to_pay, method=True,
115 type='float', string='Amount to pay', fnct_search=_to_pay_search),45 type='float', string='Amount to pay'),
116 }46 }
11747
118account_move_line()48account_move_line()
11949
=== removed file 'bin/addons/account_payment/account_payment.py'
--- bin/addons/account_payment/account_payment.py 2018-09-18 12:25:20 +0000
+++ bin/addons/account_payment/account_payment.py 1970-01-01 00:00:00 +0000
@@ -1,429 +0,0 @@
1# -*- coding: utf-8 -*-
2##############################################################################
3#
4# OpenERP, Open Source Management Solution
5# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
6#
7# This program is free software: you can redistribute it and/or modify
8# it under the terms of the GNU Affero General Public License as
9# published by the Free Software Foundation, either version 3 of the
10# License, or (at your option) any later version.
11#
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU Affero General Public License for more details.
16#
17# You should have received a copy of the GNU Affero General Public License
18# along with this program. If not, see <http://www.gnu.org/licenses/>.
19#
20##############################################################################
21
22import time
23
24from osv import osv, fields
25import netsvc
26
27class payment_mode(osv.osv):
28 _name= 'payment.mode'
29 _description= 'Payment Mode'
30 _columns = {
31 'name': fields.char('Name', size=64, required=True, help='Mode of Payment'),
32 'bank_id': fields.many2one('res.partner.bank', "Bank account",
33 required=True,help='Bank Account for the Payment Mode'),
34 'journal': fields.many2one('account.journal', 'Journal', required=True,
35 domain=[('type', 'in', ('bank','cash'))], help='Bank or Cash Journal for the Payment Mode'),
36 'company_id': fields.many2one('res.company', 'Company', required=True),
37 }
38 _defaults = {
39 'company_id': lambda self,cr,uid,c: self.pool.get('res.users').browse(cr, uid, uid, c).company_id.id
40 }
41
42 def suitable_bank_types(self, cr, uid, payment_code=None, context=None):
43 """Return the codes of the bank type that are suitable
44 for the given payment type code"""
45 if not payment_code:
46 return []
47 cr.execute(""" SELECT pb.state
48 FROM res_partner_bank pb
49 JOIN payment_mode pm ON (pm.bank_id = pb.id)
50 WHERE pm.id = %s """, [payment_code])
51 return [x[0] for x in cr.fetchall()]
52
53payment_mode()
54
55class payment_order(osv.osv):
56 _name = 'payment.order'
57 _description = 'Payment Order'
58 _rec_name = 'reference'
59
60 def get_wizard(self, type):
61 logger = netsvc.Logger()
62 logger.notifyChannel("warning", netsvc.LOG_WARNING,
63 "No wizard found for the payment type '%s'." % type)
64 return None
65
66 def _total(self, cursor, user, ids, name, args, context=None):
67 if not ids:
68 return {}
69 res = {}
70 for order in self.browse(cursor, user, ids, context=context):
71 if order.line_ids:
72 res[order.id] = reduce(lambda x, y: x + y.amount, order.line_ids, 0.0)
73 else:
74 res[order.id] = 0.0
75 return res
76
77 _columns = {
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.'),
79 'reference': fields.char('Reference', size=128, required=1, states={'done': [('readonly', True)]}),
80 'mode': fields.many2one('payment.mode', 'Payment mode', select=True, required=1, states={'done': [('readonly', True)]}, help='Select the Payment Mode to be applied.'),
81 'state': fields.selection([
82 ('draft', 'Draft'),
83 ('open', 'Confirmed'),
84 ('cancel', 'Cancelled'),
85 ('done', 'Done')], 'State', select=True,
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\'.'),
87 'line_ids': fields.one2many('payment.line', 'order_id', 'Payment lines', states={'done': [('readonly', True)]}),
88 'total': fields.function(_total, string="Total", method=True, type='float'),
89 'user_id': fields.many2one('res.users', 'User', required=True, states={'done': [('readonly', True)]}),
90 'date_prefered': fields.selection([
91 ('now', 'Directly'),
92 ('due', 'Due date'),
93 ('fixed', 'Fixed date')
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."),
95 'date_created': fields.date('Creation date', readonly=True),
96 'date_done': fields.date('Execution date', readonly=True),
97 }
98
99 _defaults = {
100 'user_id': lambda self,cr,uid,context: uid,
101 'state': 'draft',
102 'date_prefered': 'due',
103 'date_created': lambda *a: time.strftime('%Y-%m-%d'),
104 'reference': lambda self,cr,uid,context: self.pool.get('ir.sequence').get(cr, uid, 'payment.order'),
105 }
106
107 def set_to_draft(self, cr, uid, ids, *args):
108 self.write(cr, uid, ids, {'state': 'draft'})
109 wf_service = netsvc.LocalService("workflow")
110 for id in ids:
111 wf_service.trg_create(uid, 'payment.order', id, cr)
112 return True
113
114 def action_open(self, cr, uid, ids, *args):
115 ir_seq_obj = self.pool.get('ir.sequence')
116
117 for order in self.read(cr, uid, ids, ['reference']):
118 if not order['reference']:
119 reference = ir_seq_obj.get(cr, uid, 'payment.order')
120 self.write(cr, uid, order['id'], {'reference':reference})
121 return True
122
123 def set_done(self, cr, uid, ids, *args):
124 wf_service = netsvc.LocalService("workflow")
125 self.write(cr, uid, ids, {'date_done': time.strftime('%Y-%m-%d')})
126 wf_service.trg_validate(uid, 'payment.order', ids[0], 'done', cr)
127 return True
128
129 def copy(self, cr, uid, id, default={}, context=None):
130 default.update({
131 'state': 'draft',
132 'line_ids': [],
133 'reference': self.pool.get('ir.sequence').get(cr, uid, 'payment.order')
134 })
135 return super(payment_order, self).copy(cr, uid, id, default, context=context)
136
137 def write(self, cr, uid, ids, vals, context=None):
138 if not ids:
139 return True
140 if context is None:
141 context = {}
142 payment_line_obj = self.pool.get('payment.line')
143 payment_line_ids = []
144
145 if (vals.get('date_prefered', False) == 'fixed' and not vals.get('date_scheduled', False)) or vals.get('date_scheduled', False):
146 for order in self.browse(cr, uid, ids, context=context):
147 for line in order.line_ids:
148 payment_line_ids.append(line.id)
149 payment_line_obj.write(cr, uid, payment_line_ids, {'date': vals.get('date_scheduled', False)}, context=context)
150 elif vals.get('date_prefered', False) == 'due':
151 vals.update({'date_scheduled': False})
152 for order in self.browse(cr, uid, ids, context=context):
153 for line in order.line_ids:
154 payment_line_obj.write(cr, uid, [line.id], {'date': line.ml_maturity_date}, context=context)
155 elif vals.get('date_prefered', False) == 'now':
156 vals.update({'date_scheduled': False})
157 for order in self.browse(cr, uid, ids, context=context):
158 for line in order.line_ids:
159 payment_line_ids.append(line.id)
160 payment_line_obj.write(cr, uid, payment_line_ids, {'date': False}, context=context)
161 return super(payment_order, self).write(cr, uid, ids, vals, context=context)
162
163payment_order()
164
165class payment_line(osv.osv):
166 _name = 'payment.line'
167 _description = 'Payment Line'
168
169 def translate(self, orig):
170 return {
171 "due_date": "date_maturity",
172 "reference": "ref"}.get(orig, orig)
173
174 def info_owner(self, cr, uid, ids, name=None, args=None, context=None):
175 if not ids: return {}
176 partner_zip_obj = self.pool.get('res.partner.zip')
177
178 result = {}
179 info=''
180 for line in self.browse(cr, uid, ids, context=context):
181 owner = line.order_id.mode.bank_id.partner_id
182 result[line.id] = False
183 if owner.address:
184 for ads in owner.address:
185 if ads.type == 'default':
186 st = ads.street and ads.street or ''
187 st1 = ads.street2 and ads.street2 or ''
188 if 'zip_id' in ads:
189 zip_city = ads.zip_id and partner_zip_obj.name_get(cr, uid, [ads.zip_id.id])[0][1] or ''
190 else:
191 zip = ads.zip and ads.zip or ''
192 city = ads.city and ads.city or ''
193 zip_city = zip + ' ' + city
194 cntry = ads.country_id and ads.country_id.name or ''
195 info = owner.name + "\n" + st + " " + st1 + "\n" + zip_city + "\n" +cntry
196 result[line.id] = info
197 break
198 return result
199
200 def info_partner(self, cr, uid, ids, name=None, args=None, context=None):
201 if not ids: return {}
202 partner_zip_obj = self.pool.get('res.partner.zip')
203 result = {}
204 info = ''
205
206 for line in self.browse(cr, uid, ids, context=context):
207 result[line.id] = False
208 if not line.partner_id:
209 break
210 partner = line.partner_id.name or ''
211 if line.partner_id.address:
212 for ads in line.partner_id.address:
213 if ads.type == 'default':
214 st = ads.street and ads.street or ''
215 st1 = ads.street2 and ads.street2 or ''
216 if 'zip_id' in ads:
217 zip_city = ads.zip_id and partner_zip_obj.name_get(cr, uid, [ads.zip_id.id])[0][1] or ''
218 else:
219 zip = ads.zip and ads.zip or ''
220 city = ads.city and ads.city or ''
221 zip_city = zip + ' ' + city
222 cntry = ads.country_id and ads.country_id.name or ''
223 info = partner + "\n" + st + " " + st1 + "\n" + zip_city + "\n" +cntry
224 result[line.id] = info
225 break
226 return result
227
228 def _amount(self, cursor, user, ids, name, args, context=None):
229 if not ids:
230 return {}
231 currency_obj = self.pool.get('res.currency')
232 if context is None:
233 context = {}
234 res = {}
235
236 for line in self.browse(cursor, user, ids, context=context):
237 ctx = context.copy()
238 ctx['date'] = line.order_id.date_done or time.strftime('%Y-%m-%d')
239 res[line.id] = currency_obj.compute(cursor, user, line.currency.id,
240 line.company_currency.id,
241 line.amount_currency, context=ctx)
242 return res
243
244 def _get_currency(self, cr, uid, context=None):
245 user_obj = self.pool.get('res.users')
246 currency_obj = self.pool.get('res.currency')
247 user = user_obj.browse(cr, uid, uid, context=context)
248
249 if user.company_id:
250 return user.company_id.currency_id.id
251 else:
252 return currency_obj.search(cr, uid, [('rate', '=', 1.0)])[0]
253
254 def _get_date(self, cr, uid, context=None):
255 if context is None:
256 context = {}
257 payment_order_obj = self.pool.get('payment.order')
258 date = False
259
260 if context.get('order_id') and context['order_id']:
261 order = payment_order_obj.browse(cr, uid, context['order_id'], context=context)
262 if order.date_prefered == 'fixed':
263 date = order.date_scheduled
264 else:
265 date = time.strftime('%Y-%m-%d')
266 return date
267
268 def _get_ml_inv_ref(self, cr, uid, ids, *a):
269 res = {}
270 for id in self.browse(cr, uid, ids):
271 res[id.id] = False
272 if id.move_line_id:
273 if id.move_line_id.invoice:
274 res[id.id] = id.move_line_id.invoice.id
275 return res
276
277 def _get_ml_maturity_date(self, cr, uid, ids, *a):
278 res = {}
279 for id in self.browse(cr, uid, ids):
280 if id.move_line_id:
281 res[id.id] = id.move_line_id.date_maturity
282 else:
283 res[id.id] = False
284 return res
285
286 def _get_ml_created_date(self, cr, uid, ids, *a):
287 res = {}
288 for id in self.browse(cr, uid, ids):
289 if id.move_line_id:
290 res[id.id] = id.move_line_id.date_created
291 else:
292 res[id.id] = False
293 return res
294
295 _columns = {
296 'name': fields.char('Your Reference', size=64, required=True),
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 ?'"),
298 'communication2': fields.char('Communication 2', size=64, help='The successor message of Communication.'),
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.'),
300 'amount_currency': fields.float('Amount in Partner Currency', digits=(16, 2),
301 required=True, help='Payment amount in the partner currency'),
302 'currency': fields.many2one('res.currency','Partner Currency', required=True),
303 'company_currency': fields.many2one('res.currency', 'Company Currency', readonly=True),
304 'bank_id': fields.many2one('res.partner.bank', 'Destination Bank account'),
305 'order_id': fields.many2one('payment.order', 'Order', required=True,
306 ondelete='cascade', select=True),
307 'partner_id': fields.many2one('res.partner', string="Partner", required=True, help='The Ordering Customer'),
308 'amount': fields.function(_amount, string='Amount in Company Currency',
309 method=True, type='float',
310 help='Payment amount in the company currency'),
311 'ml_date_created': fields.function(_get_ml_created_date, string="Effective Date",
312 method=True, type='date', help="Invoice Effective Date"),
313 'ml_maturity_date': fields.function(_get_ml_maturity_date, method=True, type='date', string='Due Date'),
314 'ml_inv_ref': fields.function(_get_ml_inv_ref, method=True, type='many2one', relation='account.invoice', string='Invoice Ref.'),
315 'info_owner': fields.function(info_owner, string="Owner Account", method=True, type="text", help='Address of the Main Partner'),
316 'info_partner': fields.function(info_partner, string="Destination Account", method=True, type="text", help='Address of the Ordering Customer.'),
317 'date': fields.date('Payment Date', help="If no payment date is specified, the bank will treat this payment line directly"),
318 'create_date': fields.datetime('Created', readonly=True),
319 'state': fields.selection([('normal','Free'), ('structured','Structured')], 'Communication Type', required=True),
320 'bank_statement_line_id': fields.many2one('account.bank.statement.line', 'Bank statement line')
321 }
322 _defaults = {
323 'name': lambda obj, cursor, user, context: obj.pool.get('ir.sequence'
324 ).get(cursor, user, 'payment.line'),
325 'state': 'normal',
326 'currency': _get_currency,
327 'company_currency': _get_currency,
328 'date': _get_date,
329 }
330 _sql_constraints = [
331 ('name_uniq', 'UNIQUE(name)', 'The payment line name must be unique!'),
332 ]
333
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):
335 data = {}
336 move_line_obj = self.pool.get('account.move.line')
337
338 data['amount_currency'] = data['communication'] = data['partner_id'] = data['reference'] = data['date_created'] = data['bank_id'] = data['amount'] = False
339
340 if move_line_id:
341 line = move_line_obj.browse(cr, uid, move_line_id, context=context)
342 data['amount_currency'] = line.amount_to_pay
343
344 res = self.onchange_amount(cr, uid, ids, data['amount_currency'], currency,
345 company_currency, context)
346 if res:
347 data['amount'] = res['value']['amount']
348 data['partner_id'] = line.partner_id.id
349 temp = line.currency_id and line.currency_id.id or False
350 if not temp:
351 if line.invoice:
352 data['currency'] = line.invoice.currency_id.id
353 else:
354 data['currency'] = temp
355
356 # calling onchange of partner and updating data dictionary
357 temp_dict = self.onchange_partner(cr, uid, ids, line.partner_id.id, payment_type)
358 data.update(temp_dict['value'])
359
360 data['reference'] = line.ref
361 data['date_created'] = line.date_created
362 data['communication'] = line.ref
363
364 if date_prefered == 'now':
365 #no payment date => immediate payment
366 data['date'] = False
367 elif date_prefered == 'due':
368 data['date'] = line.date_maturity
369 elif date_prefered == 'fixed':
370 data['date'] = date_scheduled
371 return {'value': data}
372
373 def onchange_amount(self, cr, uid, ids, amount, currency, cmpny_currency, context=None):
374 if (not amount) or (not cmpny_currency):
375 return {'value': {'amount': False}}
376 res = {}
377 currency_obj = self.pool.get('res.currency')
378 company_amount = currency_obj.compute(cr, uid, currency, cmpny_currency, amount)
379 res['amount'] = company_amount
380 return {'value': res}
381
382 def onchange_partner(self, cr, uid, ids, partner_id, payment_type, context=None):
383 data = {}
384 partner_zip_obj = self.pool.get('res.partner.zip')
385 partner_obj = self.pool.get('res.partner')
386 payment_mode_obj = self.pool.get('payment.mode')
387 data['info_partner'] = data['bank_id'] = False
388
389 if partner_id:
390 part_obj = partner_obj.browse(cr, uid, partner_id, context=context)
391 partner = part_obj.name or ''
392
393 if part_obj.address:
394 for ads in part_obj.address:
395 if ads.type == 'default':
396 st = ads.street and ads.street or ''
397 st1 = ads.street2 and ads.street2 or ''
398
399 if 'zip_id' in ads:
400 zip_city = ads.zip_id and partner_zip_obj.name_get(cr, uid, [ads.zip_id.id])[0][1] or ''
401 else:
402 zip = ads.zip and ads.zip or ''
403 city = ads.city and ads.city or ''
404 zip_city = zip + ' ' + city
405
406 cntry = ads.country_id and ads.country_id.name or ''
407 info = partner + "\n" + st + " " + st1 + "\n" + zip_city + "\n" +cntry
408
409 data['info_partner'] = info
410
411 if part_obj.bank_ids and payment_type:
412 bank_type = payment_mode_obj.suitable_bank_types(cr, uid, payment_type, context=context)
413 for bank in part_obj.bank_ids:
414 if bank.state in bank_type:
415 data['bank_id'] = bank.id
416 break
417 return {'value': data}
418
419 def fields_get(self, cr, uid, fields=None, context=None, with_uom_rounding=False):
420 res = super(payment_line, self).fields_get(cr, uid, fields, context)
421 if 'communication2' in res:
422 res['communication2'].setdefault('states', {})
423 res['communication2']['states']['structured'] = [('readonly', True)]
424 res['communication2']['states']['normal'] = [('readonly', False)]
425 return res
426
427payment_line()
428
429# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
4300
=== removed file 'bin/addons/account_payment/account_payment_demo.xml'
--- bin/addons/account_payment/account_payment_demo.xml 2011-01-14 00:11:01 +0000
+++ bin/addons/account_payment/account_payment_demo.xml 1970-01-01 00:00:00 +0000
@@ -1,25 +0,0 @@
1<?xml version="1.0" encoding="utf-8"?>
2<openerp>
3 <data noupdate="1">
4 <record id="partner_bank_1" model="res.partner.bank">
5 <field name="name">Reserve Bank</field>
6 <field name="acc_number">00987654321</field>
7 <field name="partner_id" ref="base.res_partner_agrolait"></field>
8 <field name="state">bank</field>
9 <field name="bank" ref="base.res_bank_1"/>
10 </record>
11 <record id="payment_mode_1" model="payment.mode">
12 <field name="name">Direct Payment</field>
13 <field name="journal" ref="account.sales_journal"/>
14 <field name="bank_id" ref="account_payment.partner_bank_1"/>
15 <field name="company_id" ref="base.main_company"/>
16 </record>
17 <record id="payment_order_1" model="payment.order">
18 <field name="reference">ORDER1</field>
19 <field name="mode" ref="account_payment.payment_mode_1"/>
20 <field name="user_id" ref="base.user_root"/>
21 <field name="date_prefered">now</field>
22 <field name="state">draft</field>
23 </record>
24 </data>
25</openerp>
260
=== removed file 'bin/addons/account_payment/account_payment_report.xml'
--- bin/addons/account_payment/account_payment_report.xml 2011-01-14 00:11:01 +0000
+++ bin/addons/account_payment/account_payment_report.xml 1970-01-01 00:00:00 +0000
@@ -1,6 +0,0 @@
1<?xml version="1.0" encoding="utf-8"?>
2<openerp>
3 <data>
4 <report auto="True" id="payment_order1" model="payment.order" name="payment.order" rml="account_payment/report/order.rml" string="Payment Order"/>
5 </data>
6</openerp>
70
=== removed file 'bin/addons/account_payment/account_payment_sequence.xml'
--- bin/addons/account_payment/account_payment_sequence.xml 2011-01-14 00:11:01 +0000
+++ bin/addons/account_payment/account_payment_sequence.xml 1970-01-01 00:00:00 +0000
@@ -1,29 +0,0 @@
1<?xml version="1.0" encoding="utf-8"?>
2<openerp>
3 <data noupdate="1">
4 <record forcecreate="1" id="seq_type_payment_order" model="ir.sequence.type">
5 <field name="name">Payment order</field>
6 <field name="code">payment.order</field>
7 </record>
8
9 <record forcecreate="1" id="seq_payment_order" model="ir.sequence">
10 <field name="name">Payment order</field>
11 <field name="code">payment.order</field>
12 <field eval="3" name="padding"/>
13 <field name="prefix">%(year)s/</field>
14 </record>
15
16 <record forcecreate="1" id="seq_type_payment_line" model="ir.sequence.type">
17 <field name="name">Payment Line</field>
18 <field name="code">payment.line</field>
19 </record>
20
21 <record forcecreate="1" id="seq_payment_line" model="ir.sequence">
22 <field name="name">Payment Line</field>
23 <field name="code">payment.line</field>
24 <field name="prefix"/>
25 <field name="padding">3</field>
26 </record>
27
28 </data>
29</openerp>
300
=== modified file 'bin/addons/account_payment/account_payment_view.xml'
--- bin/addons/account_payment/account_payment_view.xml 2017-10-04 05:23:42 +0000
+++ bin/addons/account_payment/account_payment_view.xml 2019-10-30 13:23:20 +0000
@@ -15,308 +15,5 @@
15 </field>15 </field>
16 </record>16 </record>
1717
18 <record model="ir.ui.view" id="view_move_line_tree_wiz">
19 <field name="name">account.move.line.tree</field>
20 <field name="model">account.move.line</field>
21 <field name="type">tree</field>
22 <field name="priority" eval="10"/>
23 <field name="arch" type="xml">
24 <tree string="Account Entry Line">
25 <field name="partner_id"/>
26 <field name="ref"/>
27 <field name="name"/>
28 <field name="journal_id"/>
29 <field name="account_id"/>
30 <field name="date_maturity"/>
31 <field name="date"/>
32 <field name="debit" sum="Total debit"/>
33 <field name="credit" sum="Total credit"/>
34 <field name="amount_to_pay"/>
35 <field name="amount_currency"/>
36 <field name="currency_id"/>
37 <field name="period_id" invisible="1"/>
38 </tree>
39 </field>
40 </record>
41
42 <menuitem id="menu_main_payment" name="Payment" parent="account.menu_finance" sequence="7"/>
43
44 <record id="view_payment_mode_search" model="ir.ui.view">
45 <field name="name">payment.mode.search</field>
46 <field name="model">payment.mode</field>
47 <field name="type">search</field>
48 <field name="arch" type="xml">
49 <form string="Payment Mode">
50 <field name="name"/>
51 <field name="journal" widget='selection'/>
52 <field name="company_id" widget='selection' groups="base.group_multi_company"/>
53 <newline/>
54 <group expand="0" string="Group By...">
55 <filter string="Journal" icon="terp-folder-orange" domain="[]" context="{'group_by':'journal'}"/>
56 </group>
57 </form>
58 </field>
59 </record>
60
61 <record id="view_payment_mode_tree" model="ir.ui.view">
62 <field name="name">payment.mode.tree</field>
63 <field name="model">payment.mode</field>
64 <field name="type">tree</field>
65 <field name="arch" type="xml">
66 <tree string="Payment Mode">
67 <field name="name"/>
68 <field name="journal"/>
69 <field name="company_id" groups="base.group_multi_company"/>
70 </tree>
71 </field>
72 </record>
73
74 <record id="view_payment_mode_form" model="ir.ui.view">
75 <field name="name">payment.mode.form</field>
76 <field name="model">payment.mode</field>
77 <field name="type">form</field>
78 <field name="arch" type="xml">
79 <form string="Payment Mode">
80 <field name="name" select="1"/>
81 <field name="journal" select="1"/>
82 <field name="bank_id"/>
83 <field name="company_id" select="1" widget='selection' groups="base.group_multi_company"/>
84 </form>
85 </field>
86 </record>
87 <record id="action_payment_mode_form" model="ir.actions.act_window">
88 <field name="name">Payment Mode</field>
89 <field name="res_model">payment.mode</field>
90 <field name="view_type">form</field>
91 <field name="view_mode">tree,form</field>
92 <field name="search_view_id" ref="view_payment_mode_search"/>
93 </record>
94
95 <menuitem action="action_payment_mode_form" id="menu_action_payment_mode_form" parent="account.menu_configuration_misc"/>
96
97 <record id="view_payment_order_form" model="ir.ui.view">
98 <field name="name">payment.order.form</field>
99 <field name="model">payment.order</field>
100 <field name="type">form</field>
101 <field name="arch" type="xml">
102 <form string="Payment order">
103 <group col="6" colspan="4">
104 <field name="reference"/>
105 <field name="mode" widget='selection'/>
106 <field name="user_id"/>
107 <field name="date_prefered"/>
108 <field name="date_scheduled" select="1" attrs="{'readonly':[('date_prefered','!=','fixed')]}" />
109 <button colspan="2" name="%(action_create_payment_order)d" string="Select Invoices to Pay" type="action" attrs="{'invisible':[('state','=','done')]}" icon="gtk-find"/>
110 </group>
111 <field name="line_ids" colspan="4" widget="one2many_list" nolabel="1" default_get="{'order_id': active_id or False}" >
112 <form string="Payment Line">
113 <notebook>
114 <page string="Payment">
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)] "/>
116 <separator colspan="4" string="Transaction Information"/>
117 <field name="date"/>
118 <group colspan="2">
119 <field name="amount_currency" on_change="onchange_amount(amount_currency,currency,company_currency)"/>
120 <field name="currency" nolabel="1"/>
121 </group>
122 <field name="partner_id" on_change="onchange_partner(partner_id,parent.mode)" select="1"/>
123 <field domain="[('partner_id','=',partner_id)]" name="bank_id"/>
124 <separator colspan="2" string="Owner Account"/>
125 <separator colspan="2" string="Destination Account"/>
126 <field colspan="2" name="info_owner" nolabel="1"/>
127 <field colspan="2" name="info_partner" nolabel="1"/>
128 <field colspan="4" name="communication"/>
129 <field colspan="4" name="communication2"/>
130 <field name="name"/>
131 <field name="state"/>
132 </page>
133 <page string="Information">
134
135 <separator colspan="4" string="General Information"/>
136 <group colspan="2">
137 <field name="amount"/>
138 <field name="company_currency" nolabel="1"/>
139 </group>
140 <separator colspan="4" string="Entry Information"/>
141 <field name="create_date" readonly="1"/>
142 <field name="ml_maturity_date"/>
143 <field name="ml_inv_ref"/>
144 </page>
145 </notebook>
146 </form>
147 <tree string="Payment Line">
148 <field name="ml_inv_ref" />
149 <field name="partner_id" select="1"/>
150 <field name="bank_id" domain="[('partner_id', '=', partner_id)]"/>
151 <field name="ml_maturity_date"/>
152 <field name="date"/>
153 <field name="amount_currency" string="Amount"/>
154 <field name="currency"/>
155 <field name="name"/>
156 <field name="amount" sum="Total in Company Currency" invisible="1"/>
157 </tree>
158 </field>
159 <field name="date_created"/>
160 <field name="date_done"/>
161 <field name="state" readonly="1" select="1"/>
162 <group col="4" colspan="2">
163 <button name="cancel" states="draft,open" string="Cancel" icon="gtk-cancel"/>
164 <button name="open" states="draft" string="Confirm Payments" icon="gtk-apply"/>
165 <button name="set_done" states="open" string="Make Payments" type="object" icon="gtk-execute"/>
166 <button name="set_to_draft" states="cancel" string="Set to draft" type="object" icon="gtk-convert"/>
167 </group>
168 </form>
169 </field>
170 </record>
171
172 <record id="view_payment_order_tree" model="ir.ui.view">
173 <field name="name">payment.order.tree</field>
174 <field name="model">payment.order</field>
175 <field name="type">tree</field>
176 <field eval="4" name="priority"/>
177 <field name="arch" type="xml">
178 <tree colors="blue:state in ('draft');gray:state in ('cancel','done');black:state in ('open')" string="Payment order">
179 <field name="reference"/>
180 <field name="mode"/>
181 <field name="user_id"/>
182 <field name="date_created"/>
183 <field name="date_done"/>
184 <field name="total"/>
185 <field name="state"/>
186 <button name="cancel" states="draft,open" string="Cancel" icon="gtk-cancel"/>
187 <button name="open" states="draft" string="Confirm Payments" icon="gtk-apply"/>
188 <button name="set_done" states="open" string="Make Payments" type ="object" icon="gtk-execute"/>
189 </tree>
190 </field>
191 </record>
192
193 <record id="view_payment_order_search" model="ir.ui.view">
194 <field name="name">payment.order.tree.search</field>
195 <field name="model">payment.order</field>
196 <field name="type">search</field>
197 <field name="arch" type="xml">
198 <search string="Search Payment Orders">
199 <group col="8" colspan="4">
200 <filter string="Draft" domain="[('state','=','draft')]" icon="terp-document-new"/>
201 <filter string="Confirmed" domain="[('state','=','open')]" icon="terp-camera_test"/>
202 <filter string="Done" domain="[('state','=','done')]" icon="terp-dialog-close"/>
203 <separator orientation="vertical"/>
204 <field name="reference"/>
205 <field name="mode" widget='selection'/>
206 <field name="date_done"/>
207 <field name="state"/>
208 </group>
209 <newline/>
210 <group expand="0" string="Group By...">
211 <filter string="Payment Mode" context="{'group_by': 'mode'}" icon="terp-dolar"/>
212 <filter string="State" context="{'group_by': 'state'}" icon="terp-stock_effects-object-colorize"/>
213 </group>
214 </search>
215 </field>
216 </record>
217
218 <record id="action_payment_order_tree" model="ir.actions.act_window">
219 <field name="name">Payment Orders</field>
220 <field name="res_model">payment.order</field>
221 <field name="view_type">form</field>
222 <field name="view_mode">tree,form</field>
223 <field name="search_view_id" ref="view_payment_order_search"/>
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>
225 </record>
226
227 <menuitem action="action_payment_order_tree" id="menu_action_payment_order_form" parent="menu_main_payment" sequence="3"/>
228
229 <record id="action_payment_order_tree_new" model="ir.actions.act_window">
230 <field name="name">New Payment Order</field>
231 <field name="res_model">payment.order</field>
232 <field name="view_type">form</field>
233 <field name="view_mode">form,tree</field>
234 </record>
235
236 <record id="view_payment_line_form" model="ir.ui.view">
237 <field name="name">Payment Line</field>
238 <field name="model">payment.line</field>
239 <field name="type">form</field>
240 <field name="arch" type="xml">
241 <form string="Payment Line">
242 <notebook>
243 <page string="Payment">
244 <field name="order_id" select="1"/>
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)] "/>
246 <separator colspan="4" string="Transaction Information"/>
247 <field name="date"/>
248 <group colspan="2">
249 <field name="amount_currency" on_change="onchange_amount(amount_currency,currency,comapny_currency)"/>
250 <field name="currency" nolabel="1"/>
251 </group>
252 <field name="partner_id" on_change="onchange_partner(partner_id, False)" select="1"/>
253 <field domain="[('partner_id','=',partner_id)]" name="bank_id"/>
254 <separator colspan="2" string="Owner Account"/>
255 <separator colspan="2" string="Desitination Account"/>
256 <field colspan="2" name="info_owner" nolabel="1"/>
257 <field colspan="2" name="info_partner" nolabel="1"/>
258
259 <field colspan="4" name="communication"/>
260 <field colspan="4" name="communication2"/>
261 <field name="name"/>
262 <field name="state"/>
263 </page>
264 <page string="Information">
265 <separator colspan="4" string="General Information"/>
266 <group colspan="2">
267 <field name="amount" select="1"/>
268 <field name="company_currency" nolabel="1"/>
269 </group>
270 <separator colspan="4" string="Entry Information"/>
271 <field name="create_date"/>
272 <field name="ml_maturity_date"/>
273 <field name="ml_inv_ref"/>
274 </page>
275 </notebook>
276 </form>
277 </field>
278 </record>
279 <record id="view_payment_line_tree" model="ir.ui.view">
280 <field name="name">Payment Lines</field>
281 <field name="model">payment.line</field>
282 <field name="type">tree</field>
283 <field eval="4" name="priority"/>
284 <field name="arch" type="xml">
285 <tree string="Payment Line">
286 <field name="order_id"/>
287 <field name="ml_inv_ref" />
288 <field name="ml_maturity_date"/>
289 <field name="partner_id" select="1"/>
290 <field name="amount" sum="Amount Total"/>
291 <field name="amount_currency" sum="Currency Amount Total"/>
292 <field name="currency"/>
293 <field name="bank_id" domain="[('partner_id', '=', partner_id)]"/>
294 <field name="move_line_id" on_change="onchange_move_line(move_line_id,parent.mode)"/>
295 <field name="create_date"/>
296 <field name="name"/>
297 </tree>
298 </field>
299 </record>
300 <record id="action_payment_line_form" model="ir.actions.act_window">
301 <field name="name">Payment Line</field>
302 <field name="res_model">payment.line</field>
303 <field name="view_type">tree</field>
304 <field name="view_mode">form,tree</field>
305 </record>
306
307 <record id="view_bank_statement_form" model="ir.ui.view">
308 <field name="name">account.bank.statement.form.inherit</field>
309 <field name="model">account.bank.statement</field>
310 <field name="type">form</field>
311 <field name="priority">21</field>
312 <field name="inherit_id" ref="account.view_bank_statement_form"/>
313 <field name="arch" type="xml">
314 <field name="journal_id" position="after">
315 <button name="%(action_account_populate_statement_confirm)d" attrs="{'invisible':[('state','=','confirm')]}" string="Import payment lines" type="action" icon="gtk-execute"/>
316 </field>
317 </field>
318 </record>
319
320
321 </data>18 </data>
322</openerp>19</openerp>
32320
=== removed file 'bin/addons/account_payment/account_payment_workflow.xml'
--- bin/addons/account_payment/account_payment_workflow.xml 2018-09-28 16:12:03 +0000
+++ bin/addons/account_payment/account_payment_workflow.xml 1970-01-01 00:00:00 +0000
@@ -1,67 +0,0 @@
1<?xml version="1.0" encoding="utf-8"?>
2<openerp>
3 <data>
4 <record id="wkf_payment_order" model="workflow">
5 <field name="name">Payment Order Workflow</field>
6 <field name="osv">payment.order</field>
7 <field name="on_create">True</field>
8 </record>
9 <!--Activity -->
10 <record id="act_draft" model="workflow.activity">
11 <field name="name">draft</field>
12 <field name="wkf_id" ref="wkf_payment_order"/>
13 <field name="flow_start">True</field>
14 <field name="action">write({'state':'draft'})</field>
15 <field name="kind">function</field>
16 </record>
17 <record id="act_open" model="workflow.activity">
18 <field name="name">open</field>
19 <field name="wkf_id" ref="wkf_payment_order"/>
20 <field name="action">action_open()
21write({'state':'open'})</field>
22 <field name="kind">function</field>
23 </record>
24 <record id="act_done" model="workflow.activity">
25 <field name="name">done</field>
26 <field name="wkf_id" ref="wkf_payment_order"/>
27 <field name="action">write({'state':'done'})</field>
28 <field name="kind">function</field>
29 <field name="flow_stop">True</field>
30 </record>
31 <record id="act_cancel" model="workflow.activity">
32 <field name="name">cancel</field>
33 <field name="wkf_id" ref="wkf_payment_order"/>
34 <field name="action">write({'state':'cancel'})</field>
35 <field name="kind">function</field>
36 <field name="flow_stop">True</field>
37 </record>
38
39 <!-- Transition -->
40 <record id="trans_draft_open" model="workflow.transition">
41 <field name="act_from" ref="act_draft"/>
42 <field name="act_to" ref="act_open"/>
43 <field name="sequence" eval="10" />
44 <field name="signal">open</field>
45 </record>
46
47 <record id="trans_open_done" model="workflow.transition">
48 <field name="act_from" ref="act_open"/>
49 <field name="act_to" ref="act_done"/>
50 <field name="sequence" eval="10" />
51 <field name="signal">done</field>
52 </record>
53 <record id="trans_draft_cancel" model="workflow.transition">
54 <field name="act_from" ref="act_draft"/>
55 <field name="act_to" ref="act_cancel"/>
56 <field name="sequence" eval="20" />
57 <field name="signal">cancel</field>
58 </record>
59 <record id="trans_open_cancel" model="workflow.transition">
60 <field name="act_from" ref="act_open"/>
61 <field name="act_to" ref="act_cancel"/>
62 <field name="sequence" eval="20" />
63 <field name="signal">cancel</field>
64 </record>
65
66 </data>
67</openerp>
680
=== removed directory 'bin/addons/account_payment/report'
=== removed file 'bin/addons/account_payment/report/__init__.py'
--- bin/addons/account_payment/report/__init__.py 2011-01-14 00:11:01 +0000
+++ bin/addons/account_payment/report/__init__.py 1970-01-01 00:00:00 +0000
@@ -1,23 +0,0 @@
1# -*- coding: utf-8 -*-
2##############################################################################
3#
4# OpenERP, Open Source Management Solution
5# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
6#
7# This program is free software: you can redistribute it and/or modify
8# it under the terms of the GNU Affero General Public License as
9# published by the Free Software Foundation, either version 3 of the
10# License, or (at your option) any later version.
11#
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU Affero General Public License for more details.
16#
17# You should have received a copy of the GNU Affero General Public License
18# along with this program. If not, see <http://www.gnu.org/licenses/>.
19#
20##############################################################################
21
22import payment_order
23# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
24\ No newline at end of file0\ No newline at end of file
251
=== removed file 'bin/addons/account_payment/report/order.rml'
--- bin/addons/account_payment/report/order.rml 2011-01-14 00:11:01 +0000
+++ bin/addons/account_payment/report/order.rml 1970-01-01 00:00:00 +0000
@@ -1,290 +0,0 @@
1<?xml version="1.0"?>
2<document filename="Payment Order.pdf">
3 <template pageSize="(595.0,842.0)" title="Payment Order" author="OpenERP S.A. (sales@openerp.com)" allowSplitting="20">
4 <pageTemplate id="first">
5 <frame id="first" x1="34.0" y1="34.0" width="527" height="774"/>
6 </pageTemplate>
7 </template>
8 <stylesheet>
9 <blockTableStyle id="Standard_Outline">
10 <blockAlignment value="LEFT"/>
11 <blockValign value="TOP"/>
12 </blockTableStyle>
13 <blockTableStyle id="Table1">
14 <blockAlignment value="LEFT"/>
15 <blockValign value="TOP"/>
16 </blockTableStyle>
17 <blockTableStyle id="Table6">
18 <blockAlignment value="LEFT"/>
19 <blockValign value="TOP"/>
20 <lineStyle kind="LINEBEFORE" colorName="#cccccc" start="0,0" stop="0,-1"/>
21 <lineStyle kind="LINEABOVE" colorName="#cccccc" start="0,0" stop="0,0"/>
22 <lineStyle kind="LINEBELOW" colorName="#cccccc" start="0,-1" stop="0,-1"/>
23 <lineStyle kind="LINEBEFORE" colorName="#cccccc" start="1,0" stop="1,-1"/>
24 <lineStyle kind="LINEABOVE" colorName="#cccccc" start="1,0" stop="1,0"/>
25 <lineStyle kind="LINEBELOW" colorName="#cccccc" start="1,-1" stop="1,-1"/>
26 <lineStyle kind="LINEBEFORE" colorName="#cccccc" start="2,0" stop="2,-1"/>
27 <lineStyle kind="LINEABOVE" colorName="#cccccc" start="2,0" stop="2,0"/>
28 <lineStyle kind="LINEBELOW" colorName="#cccccc" start="2,-1" stop="2,-1"/>
29 <lineStyle kind="LINEBEFORE" colorName="#cccccc" start="3,0" stop="3,-1"/>
30 <lineStyle kind="LINEABOVE" colorName="#cccccc" start="3,0" stop="3,0"/>
31 <lineStyle kind="LINEBELOW" colorName="#cccccc" start="3,-1" stop="3,-1"/>
32 <lineStyle kind="LINEBEFORE" colorName="#cccccc" start="4,0" stop="4,-1"/>
33 <lineStyle kind="LINEAFTER" colorName="#cccccc" start="4,0" stop="4,-1"/>
34 <lineStyle kind="LINEABOVE" colorName="#cccccc" start="4,0" stop="4,0"/>
35 <lineStyle kind="LINEBELOW" colorName="#cccccc" start="4,-1" stop="4,-1"/>
36 </blockTableStyle>
37 <blockTableStyle id="Table7">
38 <blockAlignment value="LEFT"/>
39 <blockValign value="TOP"/>
40 <lineStyle kind="LINEBEFORE" colorName="#cccccc" start="0,0" stop="0,-1"/>
41 <lineStyle kind="LINEABOVE" colorName="#cccccc" start="0,0" stop="0,0"/>
42 <lineStyle kind="LINEBELOW" colorName="#cccccc" start="0,-1" stop="0,-1"/>
43 <lineStyle kind="LINEBEFORE" colorName="#cccccc" start="1,0" stop="1,-1"/>
44 <lineStyle kind="LINEABOVE" colorName="#cccccc" start="1,0" stop="1,0"/>
45 <lineStyle kind="LINEBELOW" colorName="#cccccc" start="1,-1" stop="1,-1"/>
46 <lineStyle kind="LINEBEFORE" colorName="#cccccc" start="2,0" stop="2,-1"/>
47 <lineStyle kind="LINEABOVE" colorName="#cccccc" start="2,0" stop="2,0"/>
48 <lineStyle kind="LINEBELOW" colorName="#cccccc" start="2,-1" stop="2,-1"/>
49 <lineStyle kind="LINEBEFORE" colorName="#cccccc" start="3,0" stop="3,-1"/>
50 <lineStyle kind="LINEABOVE" colorName="#cccccc" start="3,0" stop="3,0"/>
51 <lineStyle kind="LINEBELOW" colorName="#cccccc" start="3,-1" stop="3,-1"/>
52 <lineStyle kind="LINEBEFORE" colorName="#cccccc" start="4,0" stop="4,-1"/>
53 <lineStyle kind="LINEAFTER" colorName="#cccccc" start="4,0" stop="4,-1"/>
54 <lineStyle kind="LINEABOVE" colorName="#cccccc" start="4,0" stop="4,0"/>
55 <lineStyle kind="LINEBELOW" colorName="#cccccc" start="4,-1" stop="4,-1"/>
56 </blockTableStyle>
57 <blockTableStyle id="Table3">
58 <blockAlignment value="LEFT"/>
59 <blockValign value="TOP"/>
60 <lineStyle kind="LINEBELOW" colorName="#000000" start="0,-1" stop="0,-1"/>
61 <lineStyle kind="LINEBELOW" colorName="#000000" start="1,-1" stop="1,-1"/>
62 <lineStyle kind="LINEBELOW" colorName="#000000" start="2,-1" stop="2,-1"/>
63 <lineStyle kind="LINEBELOW" colorName="#000000" start="3,-1" stop="3,-1"/>
64 <lineStyle kind="LINEBELOW" colorName="#000000" start="4,-1" stop="4,-1"/>
65 <lineStyle kind="LINEBELOW" colorName="#000000" start="5,-1" stop="5,-1"/>
66 </blockTableStyle>
67 <blockTableStyle id="Table4">
68 <blockAlignment value="LEFT"/>
69 <blockValign value="TOP"/>
70 <lineStyle kind="LINEBELOW" colorName="#cccccc" start="0,-1" stop="0,-1"/>
71 <lineStyle kind="LINEBELOW" colorName="#cccccc" start="1,-1" stop="1,-1"/>
72 <lineStyle kind="LINEBELOW" colorName="#cccccc" start="2,-1" stop="2,-1"/>
73 <lineStyle kind="LINEBELOW" colorName="#cccccc" start="3,-1" stop="3,-1"/>
74 <lineStyle kind="LINEBELOW" colorName="#cccccc" start="4,-1" stop="4,-1"/>
75 <lineStyle kind="LINEBELOW" colorName="#cccccc" start="5,-1" stop="5,-1"/>
76 </blockTableStyle>
77 <blockTableStyle id="Table5">
78 <blockAlignment value="LEFT"/>
79 <blockValign value="TOP"/>
80 <lineStyle kind="LINEABOVE" colorName="#ffffff" start="0,0" stop="0,0"/>
81 <lineStyle kind="LINEBELOW" colorName="#ffffff" start="0,-1" stop="0,-1"/>
82 <lineStyle kind="LINEABOVE" colorName="#000000" start="1,0" stop="1,0"/>
83 <lineStyle kind="LINEABOVE" colorName="#000000" start="2,0" stop="2,0"/>
84 <lineStyle kind="LINEABOVE" colorName="#000000" start="3,0" stop="3,0"/>
85 </blockTableStyle>
86 <initialize>
87 <paraStyle name="all" alignment="justify"/>
88 </initialize>
89 <paraStyle name="Standard" fontName="Helvetica"/>
90 <paraStyle name="Heading" fontName="Helvetica" fontSize="12.0" leading="15" spaceBefore="12.0" spaceAfter="6.0"/>
91 <paraStyle name="Text body" fontName="Helvetica" spaceBefore="0.0" spaceAfter="6.0"/>
92 <paraStyle name="List" fontName="Helvetica" spaceBefore="0.0" spaceAfter="6.0"/>
93 <paraStyle name="Caption" fontName="Helvetica" fontSize="12.0" leading="15" spaceBefore="6.0" spaceAfter="6.0"/>
94 <paraStyle name="Index" fontName="Helvetica"/>
95 <paraStyle name="Table Contents" fontName="Helvetica"/>
96 <paraStyle name="Table Heading" fontName="Helvetica" alignment="CENTER"/>
97 <paraStyle name="Footer" fontName="Helvetica"/>
98 <paraStyle name="Horizontal Line" fontName="Helvetica" fontSize="6.0" leading="8" spaceBefore="0.0" spaceAfter="14.0"/>
99 <paraStyle name="terp_header" fontName="Helvetica-Bold" fontSize="12.0" leading="15" alignment="LEFT" spaceBefore="12.0" spaceAfter="6.0"/>
100 <paraStyle name="Heading 9" fontName="Helvetica-Bold" fontSize="75%" leading="NaN" spaceBefore="12.0" spaceAfter="6.0"/>
101 <paraStyle name="terp_tblheader_General" fontName="Helvetica-Bold" fontSize="8.0" leading="10" alignment="LEFT" spaceBefore="6.0" spaceAfter="6.0"/>
102 <paraStyle name="terp_tblheader_Details" fontName="Helvetica-Bold" fontSize="9.0" leading="11" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/>
103 <paraStyle name="terp_default_8" fontName="Helvetica" fontSize="8.0" leading="10" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/>
104 <paraStyle name="terp_default_Bold_8" fontName="Helvetica-Bold" fontSize="8.0" leading="10" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/>
105 <paraStyle name="terp_tblheader_General_Centre" fontName="Helvetica-Bold" fontSize="8.0" leading="10" alignment="CENTER" spaceBefore="6.0" spaceAfter="6.0"/>
106 <paraStyle name="terp_tblheader_General_Right" fontName="Helvetica-Bold" fontSize="8.0" leading="10" alignment="RIGHT" spaceBefore="6.0" spaceAfter="6.0"/>
107 <paraStyle name="terp_tblheader_Details_Centre" fontName="Helvetica-Bold" fontSize="9.0" leading="11" alignment="CENTER" spaceBefore="0.0" spaceAfter="0.0"/>
108 <paraStyle name="terp_tblheader_Details_Right" fontName="Helvetica-Bold" fontSize="9.0" leading="11" alignment="RIGHT" spaceBefore="0.0" spaceAfter="0.0"/>
109 <paraStyle name="terp_default_Right_8" fontName="Helvetica" fontSize="8.0" leading="10" alignment="RIGHT" spaceBefore="0.0" spaceAfter="0.0"/>
110 <paraStyle name="terp_default_Centre_8" fontName="Helvetica" fontSize="8.0" leading="10" alignment="CENTER" spaceBefore="0.0" spaceAfter="0.0"/>
111 <paraStyle name="terp_header_Right" fontName="Helvetica-Bold" fontSize="15.0" leading="19" alignment="LEFT" spaceBefore="12.0" spaceAfter="6.0"/>
112 <paraStyle name="terp_header_Centre" fontName="Helvetica-Bold" fontSize="12.0" leading="15" alignment="CENTER" spaceBefore="12.0" spaceAfter="6.0"/>
113 <paraStyle name="terp_default_address" fontName="Helvetica" fontSize="10.0" leading="13" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/>
114 <paraStyle name="terp_default_9" fontName="Helvetica" fontSize="9.0" leading="11" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/>
115 <paraStyle name="terp_default_Bold_9" fontName="Helvetica-Bold" fontSize="9.0" leading="11" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/>
116 <paraStyle name="terp_default_Centre_9" fontName="Helvetica" fontSize="9.0" leading="11" alignment="CENTER" spaceBefore="0.0" spaceAfter="0.0"/>
117 <paraStyle name="terp_default_Right_9" fontName="Helvetica" fontSize="9.0" leading="11" alignment="RIGHT" spaceBefore="0.0" spaceAfter="0.0"/>
118 <paraStyle name="terp_default_Space" fontName="Helvetica" fontSize="8.0" leading="10" alignment="LEFT" spaceBefore="9.0" spaceAfter="0.0"/>
119 <paraStyle name="terp_default_space_0.2" fontName="Helvetica" fontSize="8.0" leading="10" alignment="LEFT" spaceBefore="6.0" spaceAfter="0.0"/>
120 <paraStyle name="terp_default_2" fontName="Helvetica" fontSize="2.0" leading="3" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/>
121 <images/>
122 </stylesheet>
123 <story>
124 <pto>
125 <pto_header>
126 <blockTable colWidths="112.0,86.0,106.0,63.0,85.0,75.0" style="Table3">
127 <tr>
128 <td>
129 <para style="terp_tblheader_Details">Partner</para>
130 </td>
131 <td>
132 <para style="terp_tblheader_Details_Centre">Bank Account</para>
133 </td>
134 <td>
135 <para style="terp_tblheader_Details_Centre">Invoice Ref</para>
136 </td>
137 <td>
138 <para style="terp_tblheader_Details_Centre">Value Date</para>
139 </td>
140 <td>
141 <para style="terp_tblheader_Details_Right">Amount</para>
142 </td>
143 <td>
144 <para style="terp_tblheader_Details_Right">Currency</para>
145 </td>
146 </tr>
147 </blockTable>
148 </pto_header>
149 <para style="terp_default_8">[[ repeatIn(objects, 'o') ]]</para>
150 <para style="terp_default_8">
151 <font color="white"> </font>
152 </para>
153 <blockTable colWidths="318.0,210.0" style="Table1">
154 <tr>
155 <td>
156 <para style="terp_default_9">
157 <font color="white"> </font>
158 </para>
159 </td>
160 <td>
161 <para style="terp_default_address">[[ o.mode and o.mode.bank_id.bank and o.mode.bank_id.bank.name or '']]</para>
162 <para style="terp_default_address">[[ o.mode and o.mode.bank_id.bank and o.mode.bank_id.bank.street or '']]</para>
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>
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>
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>
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>
167 </td>
168 </tr>
169 </blockTable>
170 <para style="terp_default_8">
171 <font color="white"> </font>
172 </para>
173 <para style="terp_header">Payment Order / Payment</para>
174 <para style="terp_default_8">
175 <font color="white"> </font>
176 </para>
177 <blockTable colWidths="106.0,106.0,106.0,106.0,106.0" style="Table6">
178 <tr>
179 <td>
180 <para style="terp_tblheader_General_Centre">Payment Type</para>
181 </td>
182 <td>
183 <para style="terp_tblheader_General_Centre">Reference</para>
184 </td>
185 <td>
186 <para style="terp_tblheader_General_Centre">Used Account</para>
187 </td>
188 <td>
189 <para style="terp_tblheader_General_Centre">Execution Type</para>
190 </td>
191 <td>
192 <para style="terp_tblheader_General_Centre">Company Currency</para>
193 </td>
194 </tr>
195 </blockTable>
196 <blockTable colWidths="106.0,106.0,106.0,106.0,106.0" style="Table7">
197 <tr>
198 <td>
199 <para style="terp_default_Centre_8">[[ o.mode and o.mode.name or '-' ]]</para>
200 </td>
201 <td>
202 <para style="terp_default_Centre_8">[[ o.reference or '-' ]]</para>
203 </td>
204 <td>
205 <para style="terp_default_Centre_8">[[get_account_name(o.mode.bank_id.id)]]</para>
206 </td>
207 <td>
208 <para style="terp_default_Centre_8">[[ o.date_prefered == 'now' and 'Now' or removeParentNode('para') ]]</para>
209 <para style="terp_default_Centre_8">[[ o.date_prefered == 'due' and 'Due date' or removeParentNode('para') ]]</para>
210 <para style="terp_default_Centre_8">[[ o.date_prefered == 'fixed' and 'Fixed date' or removeParentNode('para') ]]</para>
211 </td>
212 <td>
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>
214 </td>
215 </tr>
216 </blockTable>
217 <para style="terp_default_9">
218 <font color="white"> </font>
219 </para>
220 <blockTable colWidths="112.0,86.0,106.0,63.0,85.0,75.0" style="Table3">
221 <tr>
222 <td>
223 <para style="terp_tblheader_Details">Partner</para>
224 </td>
225 <td>
226 <para style="terp_tblheader_Details_Centre">Bank Account</para>
227 </td>
228 <td>
229 <para style="terp_tblheader_Details_Centre">Invoice Ref</para>
230 </td>
231 <td>
232 <para style="terp_tblheader_Details_Centre">Value Date</para>
233 </td>
234 <td>
235 <para style="terp_tblheader_Details_Right">Amount</para>
236 </td>
237 <td>
238 <para style="terp_tblheader_Details_Right">Currency</para>
239 </td>
240 </tr>
241 </blockTable>
242 <section>
243 <para style="terp_default_2">[[repeatIn(o.line_ids, 'line') ]]</para>
244 <blockTable colWidths="112.0,86.0,106.0,64.0,85.0,75.0" style="Table4">
245 <tr>
246 <td>
247 <para style="terp_default_9">[[line.partner_id and line.partner_id.name or '-' ]]</para>
248 </td>
249 <td>
250 <para style="terp_default_Centre_9">[[get_account_name(line.bank_id.id) or '-']]</para>
251 </td>
252 <td>
253 <para style="terp_default_Centre_9">[[ get_invoice_name(line.ml_inv_ref.id) or '-' ]]</para>
254 </td>
255 <td>
256 <para style="terp_default_Centre_9">[[line.date=='False' and '-' or formatLang(line.date,date=True) ]]</para>
257 </td>
258 <td>
259 <para style="terp_default_Right_9">[[formatLang(line.amount) or '-' ]] [[get_company_currency_symbol()]] </para>
260 </td>
261 <td>
262 <para style="terp_default_Right_9">[[ formatLang(line.amount_currency) ]] [[ line.currency.symbol]] </para>
263 </td>
264 </tr>
265 </blockTable>
266 </section>
267 <blockTable colWidths="335.0,32.0,85.0,75.0" style="Table5">
268 <tr>
269 <td>
270 <para style="terp_default_9">
271 <font color="white"> </font>
272 </para>
273 </td>
274 <td>
275 <para style="terp_default_Bold_9">Total:</para>
276 </td>
277 <td>
278 <para style="terp_default_Right_9">[[ formatLang(get_amount_total(o)) or '' ]] [[get_company_currency_symbol()]] </para>
279 </td>
280 <td>
281 <para style="terp_default_Right_9">[[ formatLang(get_amount_total_in_currency(o)) or '' ]] [[get_company_currency_symbol()]] </para>
282 </td>
283 </tr>
284 </blockTable>
285 <para style="terp_default_8">
286 <font color="white"> </font>
287 </para>
288 </pto>
289 </story>
290</document>
2910
=== removed file 'bin/addons/account_payment/report/order.sxw'
292Binary 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 differ1Binary 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
=== removed file 'bin/addons/account_payment/report/payment_order.py'
--- bin/addons/account_payment/report/payment_order.py 2011-01-14 00:11:01 +0000
+++ bin/addons/account_payment/report/payment_order.py 1970-01-01 00:00:00 +0000
@@ -1,90 +0,0 @@
1# -*- coding: utf-8 -*-
2##############################################################################
3#
4# OpenERP, Open Source Management Solution
5# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
6#
7# This program is free software: you can redistribute it and/or modify
8# it under the terms of the GNU Affero General Public License as
9# published by the Free Software Foundation, either version 3 of the
10# License, or (at your option) any later version.
11#
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU Affero General Public License for more details.
16#
17# You should have received a copy of the GNU Affero General Public License
18# along with this program. If not, see <http://www.gnu.org/licenses/>.
19#
20##############################################################################
21
22import time
23
24import pooler
25from report import report_sxw
26
27class payment_order(report_sxw.rml_parse):
28
29 def __init__(self, cr, uid, name, context=None):
30 super(payment_order, self).__init__(cr, uid, name, context=context)
31 self.localcontext.update( {
32 'time': time,
33 'get_invoice_name': self._get_invoice_name,
34 'get_company_currency': self._get_company_currency,
35 'get_company_currency_symbol': self._get_company_currency_symbol,
36 'get_amount_total_in_currency': self._get_amount_total_in_currency,
37 'get_amount_total': self._get_amount_total,
38 'get_account_name': self._get_account_name,
39 })
40
41 def _get_invoice_name(self, invoice_id):
42 if invoice_id:
43 pool = pooler.get_pool(self.cr.dbname)
44 value_name = pool.get('account.invoice').name_get(self.cr, self.uid, [invoice_id])
45 if value_name:
46 return value_name[0][1]
47 return False
48
49 def _get_amount_total_in_currency(self, payment):
50 total = 0.0
51 if payment.line_ids:
52 currency_cmp = payment.line_ids[0].currency.id
53 else:
54 return False
55 for line in payment.line_ids:
56 if currency_cmp == line.currency.id:
57 total += line.amount_currency
58 else:
59 return False
60 return total
61
62 def _get_amount_total(self, payment):
63 total = 0.0
64 if not payment.line_ids:
65 return False
66 for line in payment.line_ids:
67 total += line.amount
68 return total
69
70 def _get_company_currency(self):
71 pool = pooler.get_pool(self.cr.dbname)
72 user = pool.get('res.users').browse(self.cr, self.uid, self.uid)
73 return user.company_id and user.company_id.currency_id and user.company_id.currency_id.symbol or False
74
75 def _get_company_currency_symbol(self):
76 pool = pooler.get_pool(self.cr.dbname)
77 user = pool.get('res.users').browse(self.cr, self.uid, self.uid)
78 return user.company_id and user.company_id.currency_id and user.company_id.currency_id.symbol or False
79
80 def _get_account_name(self,bank_id):
81 if bank_id:
82 pool = pooler.get_pool(self.cr.dbname)
83 value_name = pool.get('res.partner.bank').name_get(self.cr, self.uid, [bank_id])
84 if value_name:
85 return value_name[0][1]
86 return False
87
88report_sxw.report_sxw('report.payment.order', 'payment.order', 'addons/account_payment/report/payment_order.rml', parser=payment_order, header="external")
89
90# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
91\ No newline at end of file0\ No newline at end of file
921
=== removed directory 'bin/addons/account_payment/security'
=== removed file 'bin/addons/account_payment/security/account_payment_security.xml'
--- bin/addons/account_payment/security/account_payment_security.xml 2011-02-28 13:57:54 +0000
+++ bin/addons/account_payment/security/account_payment_security.xml 1970-01-01 00:00:00 +0000
@@ -1,17 +0,0 @@
1<?xml version="1.0" encoding="utf-8"?>
2<openerp>
3<data noupdate="1">
4
5 <record id="group_account_payment" model="res.groups">
6 <field name="name">Accounting / Payments</field>
7 </record>
8
9 <record id="payment_mode_comp_rule" model="ir.rule">
10 <field name="name">Payment Mode company rule</field>
11 <field model="ir.model" name="model_id" ref="model_payment_mode"/>
12 <field eval="True" name="global"/>
13 <field name="domain_force">['|',('company_id','=',False),('company_id','child_of',[user.company_id.id])]</field>
14 </record>
15
16</data>
17</openerp>
180
=== removed file 'bin/addons/account_payment/security/ir.model.access.csv'
--- bin/addons/account_payment/security/ir.model.access.csv 2018-10-04 14:32:37 +0000
+++ bin/addons/account_payment/security/ir.model.access.csv 1970-01-01 00:00:00 +0000
@@ -1,1 +0,0 @@
1"id","name","model_id:id","group_id:id","perm_read","perm_write","perm_create","perm_unlink"
20
=== removed directory 'bin/addons/account_payment/wizard'
=== removed file 'bin/addons/account_payment/wizard/__init__.py'
--- bin/addons/account_payment/wizard/__init__.py 2011-01-14 00:11:01 +0000
+++ bin/addons/account_payment/wizard/__init__.py 1970-01-01 00:00:00 +0000
@@ -1,26 +0,0 @@
1# -*- coding: utf-8 -*-
2##############################################################################
3#
4# OpenERP, Open Source Management Solution
5# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
6#
7# This program is free software: you can redistribute it and/or modify
8# it under the terms of the GNU Affero General Public License as
9# published by the Free Software Foundation, either version 3 of the
10# License, or (at your option) any later version.
11#
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU Affero General Public License for more details.
16#
17# You should have received a copy of the GNU Affero General Public License
18# along with this program. If not, see <http://www.gnu.org/licenses/>.
19#
20##############################################################################
21
22import account_payment_order
23import account_payment_populate_statement
24import account_payment_pay
25
26# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
27\ No newline at end of file0\ No newline at end of file
281
=== removed file 'bin/addons/account_payment/wizard/account_payment_create_order_view.xml'
--- bin/addons/account_payment/wizard/account_payment_create_order_view.xml 2017-05-10 12:47:14 +0000
+++ bin/addons/account_payment/wizard/account_payment_create_order_view.xml 1970-01-01 00:00:00 +0000
@@ -1,52 +0,0 @@
1<?xml version="1.0" encoding="utf-8"?>
2<openerp>
3 <data>
4
5 <record id="view_create_payment_order" model="ir.ui.view">
6 <field name="name">payment.order.create.form</field>
7 <field name="model">payment.order.create</field>
8 <field name="type">form</field>
9 <field name="priority">18</field>
10 <field name="arch" type="xml">
11 <form string="Search Payment lines">
12 <group col="4" colspan="6">
13 <field name="duedate" />
14 </group>
15 <separator colspan="4"/>
16 <group col="2" colspan="4">
17 <button special="cancel" string="Cancel" icon='gtk-cancel'/>
18 <button name="search_entries" string="Search" colspan="1" type="object" icon="gtk-execute"/>
19 </group>
20 </form>
21 </field>
22 </record>
23
24 <record id="view_create_payment_order_lines" model="ir.ui.view">
25 <field name="name">payment.order.create.form</field>
26 <field name="model">payment.order.create</field>
27 <field name="type">form</field>
28 <field name="priority">17</field>
29 <field name="arch" type="xml">
30 <form string="Search Payment lines">
31 <group col="4" colspan="6">
32 </group>
33 <separator colspan="4"/>
34 <group col="2" colspan="4">
35 <button special="cancel" string="Cancel" icon='gtk-cancel'/>
36 <button name="create_payment" string="_Add to payment order" colspan="1" type="object" icon="gtk-execute"/>
37 </group>
38 </form>
39 </field>
40 </record>
41
42 <record id="action_create_payment_order" model="ir.actions.act_window">
43 <field name="name">Populate Payment</field>
44 <field name="type">ir.actions.act_window</field>
45 <field name="res_model">payment.order.create</field>
46 <field name="view_type">form</field>
47 <field name="view_mode">form</field>
48 <field name="target">new</field>
49 </record>
50
51 </data>
52</openerp>
530
=== removed file 'bin/addons/account_payment/wizard/account_payment_order.py'
--- bin/addons/account_payment/wizard/account_payment_order.py 2011-01-14 00:11:01 +0000
+++ bin/addons/account_payment/wizard/account_payment_order.py 1970-01-01 00:00:00 +0000
@@ -1,123 +0,0 @@
1# -*- coding: utf-8 -*-
2##############################################################################
3#
4# OpenERP, Open Source Management Solution
5# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
6#
7# This program is free software: you can redistribute it and/or modify
8# it under the terms of the GNU Affero General Public License as
9# published by the Free Software Foundation, either version 3 of the
10# License, or (at your option) any later version.
11#
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU Affero General Public License for more details.
16#
17# You should have received a copy of the GNU Affero General Public License
18# along with this program. If not, see <http://www.gnu.org/licenses/>.
19#
20##############################################################################
21
22import time
23from lxml import etree
24
25from osv import osv, fields
26
27class payment_order_create(osv.osv_memory):
28 """
29 Create a payment object with lines corresponding to the account move line
30 to pay according to the date and the mode provided by the user.
31 Hypothesis:
32 - Small number of non-reconcilied move line, payment mode and bank account type,
33 - Big number of partner and bank account.
34
35 If a type is given, unsuitable account Entry lines are ignored.
36 """
37
38 _name = 'payment.order.create'
39 _description = 'payment.order.create'
40 _columns = {
41 'duedate': fields.date('Due Date', required=True),
42 'entries': fields.many2many('account.move.line', 'line_pay_rel', 'pay_id', 'line_id', 'Entries')
43 }
44 _defaults = {
45 'duedate': lambda *a: time.strftime('%Y-%m-%d'),
46 }
47
48 def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False):
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)
50 if context and 'line_ids' in context:
51 view_obj = etree.XML(res['arch'])
52 child = view_obj.getchildren()[0]
53 domain = '[("id", "in", '+ str(context['line_ids'])+')]'
54 field = etree.Element('field', attrib={'domain': domain, 'name':'entries', 'colspan':'4', 'height':'300', 'width':'800', 'nolabel':"1"})
55 child.addprevious(field)
56 res['arch'] = etree.tostring(view_obj)
57 return res
58
59 def create_payment(self, cr, uid, ids, context=None):
60 order_obj = self.pool.get('payment.order')
61 line_obj = self.pool.get('account.move.line')
62 payment_obj = self.pool.get('payment.line')
63 if context is None:
64 context = {}
65 data = self.read(cr, uid, ids, [], context=context)[0]
66 line_ids = data['entries']
67 if not line_ids:
68 return {'type': 'ir.actions.act_window_close'}
69
70 payment = order_obj.browse(cr, uid, context['active_id'], context=context)
71 t = None
72 line2bank = line_obj.line2bank(cr, uid, line_ids, t, context)
73
74 ## Finally populate the current payment with new lines:
75 for line in line_obj.browse(cr, uid, line_ids, context=context):
76 if payment.date_prefered == "now":
77 #no payment date => immediate payment
78 date_to_pay = False
79 elif payment.date_prefered == 'due':
80 date_to_pay = line.date_maturity
81 elif payment.date_prefered == 'fixed':
82 date_to_pay = payment.date_scheduled
83 payment_obj.create(cr, uid,{
84 'move_line_id': line.id,
85 'amount_currency': line.amount_to_pay,
86 'bank_id': line2bank.get(line.id),
87 'order_id': payment.id,
88 'partner_id': line.partner_id and line.partner_id.id or False,
89 'communication': line.ref or '/',
90 'date': date_to_pay,
91 'currency': line.invoice and line.invoice.currency_id.id or False,
92 }, context=context)
93 return {'type': 'ir.actions.act_window_close'}
94
95 def search_entries(self, cr, uid, ids, context=None):
96 line_obj = self.pool.get('account.move.line')
97 mod_obj = self.pool.get('ir.model.data')
98 if context is None:
99 context = {}
100 data = self.read(cr, uid, ids, [], context=context)[0]
101 search_due_date = data['duedate']
102# payment = self.pool.get('payment.order').browse(cr, uid, context['active_id'], context=context)
103
104 # Search for move line to pay:
105 domain = [('reconcile_id', '=', False), ('account_id.type', '=', 'payable'), ('amount_to_pay', '>', 0)]
106 domain = domain + ['|', ('date_maturity', '<=', search_due_date), ('date_maturity', '=', False)]
107 line_ids = line_obj.search(cr, uid, domain, context=context)
108 context.update({'line_ids': line_ids})
109 model_data_ids = mod_obj.search(cr, uid,[('model', '=', 'ir.ui.view'), ('name', '=', 'view_create_payment_order_lines')], context=context)
110 resource_id = mod_obj.read(cr, uid, model_data_ids, fields=['res_id'], context=context)[0]['res_id']
111 return {'name': ('Entrie Lines'),
112 'context': context,
113 'view_type': 'form',
114 'view_mode': 'form',
115 'res_model': 'payment.order.create',
116 'views': [(resource_id,'form')],
117 'type': 'ir.actions.act_window',
118 'target': 'new',
119 }
120
121payment_order_create()
122
123# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
124\ No newline at end of file0\ No newline at end of file
1251
=== removed file 'bin/addons/account_payment/wizard/account_payment_pay.py'
--- bin/addons/account_payment/wizard/account_payment_pay.py 2011-01-14 00:11:01 +0000
+++ bin/addons/account_payment/wizard/account_payment_pay.py 1970-01-01 00:00:00 +0000
@@ -1,58 +0,0 @@
1# -*- coding: utf-8 -*-
2##############################################################################
3#
4# OpenERP, Open Source Management Solution
5# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
6#
7# This program is free software: you can redistribute it and/or modify
8# it under the terms of the GNU Affero General Public License as
9# published by the Free Software Foundation, either version 3 of the
10# License, or (at your option) any later version.
11#
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU Affero General Public License for more details.
16#
17# You should have received a copy of the GNU Affero General Public License
18# along with this program. If not, see <http://www.gnu.org/licenses/>.
19#
20##############################################################################
21
22from osv import osv
23
24class account_payment_make_payment(osv.osv_memory):
25 _name = "account.payment.make.payment"
26 _description = "Account make payment"
27
28 def launch_wizard(self, cr, uid, ids, context=None):
29 """
30 Search for a wizard to launch according to the type.
31 If type is manual. just confirm the order.
32 """
33 obj_payment_order = self.pool.get('payment.order')
34 if context is None:
35 context = {}
36# obj_model = self.pool.get('ir.model.data')
37# obj_act = self.pool.get('ir.actions.act_window')
38# order = obj_payment_order.browse(cr, uid, context['active_id'], context)
39 obj_payment_order.set_done(cr, uid, [context['active_id']], context)
40 return {'type': 'ir.actions.act_window_close'}
41# t = order.mode and order.mode.type.code or 'manual'
42# if t == 'manual':
43# obj_payment_order.set_done(cr,uid,context['active_id'],context)
44# return {}
45#
46# gw = obj_payment_order.get_wizard(t)
47# if not gw:
48# obj_payment_order.set_done(cr,uid,context['active_id'],context)
49# return {}
50#
51# module, wizard= gw
52# result = obj_model._get_id(cr, uid, module, wizard)
53# id = obj_model.read(cr, uid, [result], ['res_id'])[0]['res_id']
54# return obj_act.read(cr, uid, [id])[0]
55
56account_payment_make_payment()
57
58# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
59\ No newline at end of file0\ No newline at end of file
601
=== removed file 'bin/addons/account_payment/wizard/account_payment_pay_view.xml'
--- bin/addons/account_payment/wizard/account_payment_pay_view.xml 2011-01-14 00:11:01 +0000
+++ bin/addons/account_payment/wizard/account_payment_pay_view.xml 1970-01-01 00:00:00 +0000
@@ -1,33 +0,0 @@
1<?xml version="1.0" encoding="utf-8"?>
2<openerp>
3 <data>
4
5 <record id="account_payment_make_payment_view" model="ir.ui.view">
6 <field name="name">account.payment.make.payment.form</field>
7 <field name="model">account.payment.make.payment</field>
8 <field name="type">form</field>
9 <field name="arch" type="xml">
10 <form string="Make Payment">
11 <separator string="Are you sure you want to make payment?"/>
12 <newline/>
13 <group colspan="2" col="4">
14 <button special="cancel" string="Cancel" icon="gtk-cancel"/>
15 <button name="launch_wizard" string="Yes" type="object" icon="gtk-ok" default_focus="1"/>
16 </group>
17 </form>
18 </field>
19 </record>
20
21 <record id="action_account_payment_make_payment" model="ir.actions.act_window">
22 <field name="name">Make Payment</field>
23 <field name="type">ir.actions.act_window</field>
24 <field name="res_model">account.payment.make.payment</field>
25 <field name="view_type">form</field>
26 <field name="view_mode">form</field>
27 <field name="view_id" ref="account_payment_make_payment_view"/>
28 <field name="target">new</field>
29 </record>
30
31
32 </data>
33</openerp>
340
=== removed file 'bin/addons/account_payment/wizard/account_payment_populate_statement.py'
--- bin/addons/account_payment/wizard/account_payment_populate_statement.py 2011-05-16 14:06:09 +0000
+++ bin/addons/account_payment/wizard/account_payment_populate_statement.py 1970-01-01 00:00:00 +0000
@@ -1,122 +0,0 @@
1# -*- coding: utf-8 -*-
2##############################################################################
3#
4# OpenERP, Open Source Management Solution
5# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
6#
7# This program is free software: you can redistribute it and/or modify
8# it under the terms of the GNU Affero General Public License as
9# published by the Free Software Foundation, either version 3 of the
10# License, or (at your option) any later version.
11#
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU Affero General Public License for more details.
16#
17# You should have received a copy of the GNU Affero General Public License
18# along with this program. If not, see <http://www.gnu.org/licenses/>.
19#
20##############################################################################
21
22import time
23from lxml import etree
24
25from osv import osv, fields
26
27class account_payment_populate_statement(osv.osv_memory):
28 _name = "account.payment.populate.statement"
29 _description = "Account Payment Populate Statement"
30 _columns = {
31 'lines': fields.many2many('payment.line', 'payment_line_rel_', 'payment_id', 'line_id', 'Payment Lines')
32 }
33
34 def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False):
35 line_obj = self.pool.get('payment.line')
36
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)
38 line_ids = line_obj.search(cr, uid, [
39 ('move_line_id.reconcile_id', '=', False),
40 ('bank_statement_line_id', '=', False),
41 ('move_line_id.state','=','valid')])
42 line_ids.extend(line_obj.search(cr, uid, [
43 ('move_line_id.reconcile_id', '=', False),
44 ('order_id.mode', '=', False),
45 ('move_line_id.state','=','valid')]))
46 domain = '[("id", "in", '+ str(line_ids)+')]'
47 doc = etree.XML(res['arch'])
48 nodes = doc.xpath("//field[@name='lines']")
49 for node in nodes:
50 node.set('domain', domain)
51 res['arch'] = etree.tostring(doc)
52 return res
53
54 def populate_statement(self, cr, uid, ids, context=None):
55 line_obj = self.pool.get('payment.line')
56 statement_obj = self.pool.get('account.bank.statement')
57 statement_line_obj = self.pool.get('account.bank.statement.line')
58 currency_obj = self.pool.get('res.currency')
59 voucher_obj = self.pool.get('account.voucher')
60 voucher_line_obj = self.pool.get('account.voucher.line')
61 move_line_obj = self.pool.get('account.move.line')
62
63 if context is None:
64 context = {}
65 data = self.read(cr, uid, ids, [], context=context)[0]
66 line_ids = data['lines']
67 if not line_ids:
68 return {'type': 'ir.actions.act_window_close'}
69
70 statement = statement_obj.browse(cr, uid, context['active_id'], context=context)
71
72 for line in line_obj.browse(cr, uid, line_ids, context=context):
73 ctx = context.copy()
74 ctx['date'] = line.ml_maturity_date # was value_date earlier,but this field exists no more now
75 amount = currency_obj.compute(cr, uid, line.currency.id,
76 statement.currency.id, line.amount_currency, context=ctx)
77
78 if not line.move_line_id.id:
79 continue
80 context.update({'move_line_ids': [line.move_line_id.id]})
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)
82
83 voucher_res = {
84 'type': 'payment',
85 'name': line.name,
86 'partner_id': line.partner_id.id,
87 'journal_id': statement.journal_id.id,
88 'account_id': result.get('account_id', statement.journal_id.default_credit_account_id.id),
89 'company_id': statement.company_id.id,
90 'currency_id': statement.currency.id,
91 'date': line.date or time.strftime('%Y-%m-%d'),
92 'amount': abs(amount),
93 'period_id': statement.period_id.id
94 }
95 voucher_id = voucher_obj.create(cr, uid, voucher_res, context=context)
96 voucher_line_dict = {}
97 if result['value']['line_ids']:
98 for line_dict in result['value']['line_ids']:
99 move_line = move_line_obj.browse(cr, uid, line_dict['move_line_id'], context)
100 if line.move_line_id.move_id.id == move_line.move_id.id:
101 voucher_line_dict = line_dict
102 if voucher_line_dict:
103 voucher_line_dict.update({'voucher_id': voucher_id})
104 voucher_line_obj.create(cr, uid, voucher_line_dict, context=context)
105
106 st_line_id = statement_line_obj.create(cr, uid, {
107 'name': line.order_id.reference or '?',
108 'amount': - amount,
109 'type': 'supplier',
110 'partner_id': line.partner_id.id,
111 'account_id': line.move_line_id.account_id.id,
112 'statement_id': statement.id,
113 'ref': line.communication,
114 'voucher_id': voucher_id,
115 }, context=context)
116
117 line_obj.write(cr, uid, [line.id], {'bank_statement_line_id': st_line_id})
118 return {'type': 'ir.actions.act_window_close'}
119
120account_payment_populate_statement()
121
122# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
123\ No newline at end of file0\ No newline at end of file
1241
=== removed file 'bin/addons/account_payment/wizard/account_payment_populate_statement_view.xml'
--- bin/addons/account_payment/wizard/account_payment_populate_statement_view.xml 2011-01-14 00:11:01 +0000
+++ bin/addons/account_payment/wizard/account_payment_populate_statement_view.xml 1970-01-01 00:00:00 +0000
@@ -1,44 +0,0 @@
1<?xml version="1.0" encoding="UTF-8"?>
2<openerp>
3 <data>
4
5 <record id="account_payment_populate_statement_view" model="ir.ui.view">
6 <field name="name">Payment Populate statement</field>
7 <field name="model">account.payment.populate.statement</field>
8 <field name="type">form</field>
9 <field name="arch" type="xml">
10 <form string="Populate Statement:">
11 <group colspan="4" col="6">
12 <field name="lines" colspan="4" height="300" width="800" nolabel="1" />
13 <separator colspan="6"/>
14 <button special="cancel" string="Cancel" icon="gtk-cancel"/>
15 <button name="populate_statement" string="ADD" type="object" icon="gtk-ok"/>
16 </group>
17 </form>
18 </field>
19 </record>
20
21 <record id="action_account_populate_statement_confirm" model="ir.actions.act_window">
22 <field name="name">Payment Populate statement</field>
23 <field name="res_model">account.payment.populate.statement</field>
24 <field name="type">ir.actions.act_window</field>
25 <field name="view_type">form</field>
26 <field name="view_mode">tree,form</field>
27 <field name="view_id" ref="account_payment_populate_statement_view"/>
28 <field name="context">{'record_id':active_id}</field>
29 <field name="target">new</field>
30 </record>
31
32 <record id="action_account_payment_populate_statement" model="ir.actions.act_window">
33 <field name="name">Payment Populate statement</field>
34 <field name="res_model">account.payment.populate.statement</field>
35 <field name="type">ir.actions.act_window</field>
36 <field name="view_type">form</field>
37 <field name="view_mode">tree,form</field>
38 <field name="view_id" ref="account_payment_populate_statement_view"/>
39 <field name="context">{'record_id':active_id}</field>
40 <field name="target">new</field>
41 </record>
42
43 </data>
44</openerp>
45\ No newline at end of file0\ No newline at end of file
461
=== modified file 'bin/addons/account_period_closing_level/account_year_end_closing.py'
--- bin/addons/account_period_closing_level/account_year_end_closing.py 2018-11-23 14:44:11 +0000
+++ bin/addons/account_period_closing_level/account_year_end_closing.py 2019-10-30 13:23:20 +0000
@@ -318,8 +318,8 @@
318 'block_manual_currency_id': True,318 'block_manual_currency_id': True,
319 'company_id': cpy_rec.id,319 'company_id': cpy_rec.id,
320 'currency_id': ccy_id,320 'currency_id': ccy_id,
321 'date': posting_date,321 'date': last_day_fy,
322 'document_date': posting_date,322 'document_date': last_day_fy,
323 'instance_id': instance_rec.id,323 'instance_id': instance_rec.id,
324 'journal_id': journal_id,324 'journal_id': journal_id,
325 'name': name,325 'name': name,
@@ -335,17 +335,18 @@
335 """335 """
336 name = 'Balance move to 0'336 name = 'Balance move to 0'
337337
338 # DONE: TEST JN => behavior unchanged (use of clearer date name for the source date)
338 vals = {339 vals = {
339 'account_id': account_id,340 'account_id': account_id,
340 'company_id': cpy_rec.id,341 'company_id': cpy_rec.id,
341 'currency_id': ccy_id,342 'currency_id': ccy_id,
342 'date': posting_date,343 'date': last_day_fy,
343 'document_date': posting_date,344 'document_date': last_day_fy,
344 'instance_id': instance_rec.id,345 'instance_id': instance_rec.id,
345 'journal_id': journal_id,346 'journal_id': journal_id,
346 'name': name,347 'name': name,
347 'period_id': period_id,348 'period_id': period_id,
348 'source_date': posting_date,349 'source_date': last_day_fy,
349350
350 'debit_currency': \351 'debit_currency': \
351 balance_currency if balance_currency > 0. else 0.,352 balance_currency if balance_currency > 0. else 0.,
@@ -378,7 +379,7 @@
378 instance_rec.id, context=context)379 instance_rec.id, context=context)
379380
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)
381 posting_date = "%d-12-31" % (fy_year, )382 last_day_fy = "%d-12-31" % (fy_year, )
382383
383 journal_code = 'EOY'384 journal_code = 'EOY'
384 journal_id = self._get_journal(cr, uid, journal_code, context=context)385 journal_id = self._get_journal(cr, uid, journal_code, context=context)
@@ -593,8 +594,8 @@
593 'block_manual_currency_id': True,594 'block_manual_currency_id': True,
594 'company_id': cpy_rec.id,595 'company_id': cpy_rec.id,
595 'currency_id': ccy_id,596 'currency_id': ccy_id,
596 'date': posting_date,597 'date': first_day_next_fy,
597 'document_date': posting_date,598 'document_date': first_day_next_fy,
598 'instance_id': instance_rec.id,599 'instance_id': instance_rec.id,
599 'journal_id': journal_id,600 'journal_id': journal_id,
600 'name': name,601 'name': name,
@@ -611,17 +612,18 @@
611 """612 """
612 default_name = 'Balance report / Previous Fiscal Year'613 default_name = 'Balance report / Previous Fiscal Year'
613614
615 # DONE: TEST JN => behavior unchanged (use of clearer date name for the source date)
614 vals = {616 vals = {
615 'account_id': account_id,617 'account_id': account_id,
616 'company_id': cpy_rec.id,618 'company_id': cpy_rec.id,
617 'currency_id': ccy_id,619 'currency_id': ccy_id,
618 'date': posting_date,620 'date': first_day_next_fy,
619 'document_date': posting_date,621 'document_date': first_day_next_fy,
620 'instance_id': instance_rec.id,622 'instance_id': instance_rec.id,
621 'journal_id': journal_id,623 'journal_id': journal_id,
622 'name': name or default_name,624 'name': name or default_name,
623 'period_id': period_id,625 'period_id': period_id,
624 'source_date': posting_date,626 'source_date': first_day_next_fy,
625627
626 'debit_currency': \628 'debit_currency': \
627 balance_currency if balance_currency > 0. else 0.,629 balance_currency if balance_currency > 0. else 0.,
@@ -664,7 +666,7 @@
664666
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)
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)
667 posting_date = "%d-01-01" % (fy_year + 1, )669 first_day_next_fy = "%d-01-01" % (fy_year + 1, )
668670
669 journal_code = 'IB'671 journal_code = 'IB'
670 journal_id = self._get_journal(cr, uid, journal_code, context=context)672 journal_id = self._get_journal(cr, uid, journal_code, context=context)
671673
=== removed directory 'bin/addons/account_voucher'
=== removed file 'bin/addons/account_voucher/__init__.py'
--- bin/addons/account_voucher/__init__.py 2011-01-14 00:11:01 +0000
+++ bin/addons/account_voucher/__init__.py 1970-01-01 00:00:00 +0000
@@ -1,27 +0,0 @@
1# -*- coding: utf-8 -*-
2##############################################################################
3#
4# OpenERP, Open Source Management Solution
5# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
6#
7# This program is free software: you can redistribute it and/or modify
8# it under the terms of the GNU Affero General Public License as
9# published by the Free Software Foundation, either version 3 of the
10# License, or (at your option) any later version.
11#
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU Affero General Public License for more details.
16#
17# You should have received a copy of the GNU Affero General Public License
18# along with this program. If not, see <http://www.gnu.org/licenses/>.
19#
20##############################################################################
21
22import account_voucher
23import invoice
24import report
25import wizard
26
27# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
28\ No newline at end of file0\ No newline at end of file
291
=== removed file 'bin/addons/account_voucher/__openerp__.py'
--- bin/addons/account_voucher/__openerp__.py 2017-10-04 05:23:42 +0000
+++ bin/addons/account_voucher/__openerp__.py 1970-01-01 00:00:00 +0000
@@ -1,60 +0,0 @@
1# -*- coding: utf-8 -*-
2##############################################################################
3#
4# OpenERP, Open Source Management Solution
5# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
6#
7# This program is free software: you can redistribute it and/or modify
8# it under the terms of the GNU Affero General Public License as
9# published by the Free Software Foundation, either version 3 of the
10# License, or (at your option) any later version.
11#
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU Affero General Public License for more details.
16#
17# You should have received a copy of the GNU Affero General Public License
18# along with this program. If not, see <http://www.gnu.org/licenses/>.
19#
20##############################################################################
21
22{
23 "name" : "Accounting Voucher Entries",
24 "version" : "1.0",
25 "author" : 'OpenERP SA',
26 "description": """Account Voucher module includes all the basic requirements of
27 Voucher Entries for Bank, Cash, Sales, Purchase, Expanse, Contra, etc...
28 * Voucher Entry
29 * Voucher Receipt
30 * Cheque Register
31 """,
32 "category" : "Generic Modules/Accounting",
33 "website" : "http://tinyerp.com",
34 "depends" : ["account"],
35 "init_xml" : [],
36
37 "demo_xml" : [],
38
39 "update_xml" : [
40 "security/ir.model.access.csv",
41 "account_voucher_sequence.xml",
42 "account_voucher_workflow.xml",
43 "account_voucher_report.xml",
44 "wizard/account_voucher_unreconcile_view.xml",
45 "wizard/account_statement_from_invoice_view.xml",
46 "account_voucher_view.xml",
47 "voucher_payment_receipt_view.xml",
48 "voucher_sales_purchase_view.xml",
49 "account_voucher_wizard.xml",
50 "report/account_voucher_sales_receipt_view.xml",
51 "security/account_voucher_security.xml"
52 ],
53 "test" : [
54 ],
55 'certificate': '0037580727101',
56 "active": False,
57 "installable": True,
58}
59
60# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
610
=== removed file 'bin/addons/account_voucher/account_voucher.py'
--- bin/addons/account_voucher/account_voucher.py 2012-06-20 14:19:49 +0000
+++ bin/addons/account_voucher/account_voucher.py 1970-01-01 00:00:00 +0000
@@ -1,1022 +0,0 @@
1# -*- coding: utf-8 -*-
2##############################################################################
3#
4# OpenERP, Open Source Management Solution
5# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
6#
7# This program is free software: you can redistribute it and/or modify
8# it under the terms of the GNU Affero General Public License as
9# published by the Free Software Foundation, either version 3 of the
10# License, or (at your option) any later version.
11#
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU Affero General Public License for more details.
16#
17# You should have received a copy of the GNU Affero General Public License
18# along with this program. If not, see <http://www.gnu.org/licenses/>.
19#
20##############################################################################
21
22import time
23from lxml import etree
24
25import netsvc
26from osv import osv, fields
27import decimal_precision as dp
28from tools.translate import _
29
30
31class account_voucher(osv.osv):
32
33 def _get_type(self, cr, uid, context=None):
34 if context is None:
35 context = {}
36 return context.get('type', False)
37
38 def _get_period(self, cr, uid, context=None):
39 if context is None: context = {}
40 if context.get('period_id', False):
41 return context.get('period_id')
42 periods = self.pool.get('account.period').find(cr, uid)
43 return periods and periods[0] or False
44
45 def _get_journal(self, cr, uid, context=None):
46 if context is None: context = {}
47 journal_pool = self.pool.get('account.journal')
48 invoice_pool = self.pool.get('account.invoice')
49 if context.get('invoice_id', False):
50 currency_id = invoice_pool.browse(cr, uid, context['invoice_id'], context=context).currency_id.id
51 journal_id = journal_pool.search(cr, uid, [('currency', '=', currency_id)], limit=1)
52 return journal_id and journal_id[0] or False
53 if context.get('journal_id', False):
54 return context.get('journal_id')
55 if not context.get('journal_id', False) and context.get('search_default_journal_id', False):
56 return context.get('search_default_journal_id')
57
58 ttype = context.get('type', 'bank')
59 if ttype in ('payment', 'receipt'):
60 ttype = 'bank'
61 res = journal_pool.search(cr, uid, [('type', '=', ttype)], limit=1)
62 return res and res[0] or False
63
64 def _get_tax(self, cr, uid, context=None):
65 if context is None: context = {}
66 journal_pool = self.pool.get('account.journal')
67 journal_id = context.get('journal_id', False)
68 if not journal_id:
69 ttype = context.get('type', 'bank')
70 res = journal_pool.search(cr, uid, [('type', '=', ttype)], limit=1)
71 if not res:
72 return False
73 journal_id = res[0]
74
75 if not journal_id:
76 return False
77 journal = journal_pool.browse(cr, uid, journal_id, context=context)
78 account_id = journal.default_credit_account_id or journal.default_debit_account_id
79 if account_id and account_id.tax_ids:
80 tax_id = account_id.tax_ids[0].id
81 return tax_id
82 return False
83
84 def _get_currency(self, cr, uid, context=None):
85 if context is None: context = {}
86 journal_pool = self.pool.get('account.journal')
87 journal_id = context.get('journal_id', False)
88 if journal_id:
89 journal = journal_pool.browse(cr, uid, journal_id, context=context)
90# currency_id = journal.company_id.currency_id.id
91 if journal.currency:
92 return journal.currency.id
93 return False
94
95 def _get_partner(self, cr, uid, context=None):
96 if context is None: context = {}
97 return context.get('partner_id', False)
98
99 def _get_reference(self, cr, uid, context=None):
100 if context is None: context = {}
101 return context.get('reference', False)
102
103 def _get_narration(self, cr, uid, context=None):
104 if context is None: context = {}
105 return context.get('narration', False)
106
107 def _get_amount(self, cr, uid, context=None):
108 if context is None:
109 context= {}
110 return context.get('amount', 0.0)
111
112 def name_get(self, cr, uid, ids, context=None):
113 if not ids:
114 return []
115 if context is None: context = {}
116 return [(r['id'], (str("%.2f" % r['amount']) or '')) for r in self.read(cr, uid, ids, ['amount'], context, load='_classic_write')]
117
118 def fields_view_get(self, cr, uid, view_id=None, view_type=False, context=None, toolbar=False, submenu=False):
119 mod_obj = self.pool.get('ir.model.data')
120 if context is None: context = {}
121
122 def get_res_id(view_type, condition):
123 result = False
124 if view_type == 'tree':
125 result = mod_obj.get_object_reference(cr, uid, 'account_voucher', 'view_voucher_tree')
126 elif view_type == 'form':
127 if condition:
128 result = mod_obj.get_object_reference(cr, uid, 'account_voucher', 'view_vendor_receipt_form')
129 else:
130 result = mod_obj.get_object_reference(cr, uid, 'account_voucher', 'view_vendor_payment_form')
131 return result and result[1] or False
132
133 if not view_id and context.get('invoice_type', False):
134 view_id = get_res_id(view_type,context.get('invoice_type', False) in ('out_invoice', 'out_refund'))
135
136 if not view_id and context.get('line_type', False):
137 view_id = get_res_id(view_type,context.get('line_type', False) == 'customer')
138
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)
140 doc = etree.XML(res['arch'])
141 nodes = doc.xpath("//field[@name='partner_id']")
142 if context.get('type', 'sale') in ('purchase', 'payment'):
143 for node in nodes:
144 node.set('domain', "[('supplier', '=', True)]")
145 res['arch'] = etree.tostring(doc)
146 return res
147
148 def _compute_writeoff_amount(self, cr, uid, line_dr_ids, line_cr_ids, amount):
149 debit = credit = 0.0
150 for l in line_dr_ids:
151 debit += l['amount']
152 for l in line_cr_ids:
153 credit += l['amount']
154 return abs(amount - abs(credit - debit))
155
156 def onchange_line_ids(self, cr, uid, ids, line_dr_ids, line_cr_ids, amount):
157 if not line_dr_ids and not line_cr_ids:
158 return {'value':{}}
159 line_dr_ids = [x[2] for x in line_dr_ids]
160 line_cr_ids = [x[2] for x in line_cr_ids]
161 return {'value': {'writeoff_amount': self._compute_writeoff_amount(cr, uid, line_dr_ids, line_cr_ids, amount)}}
162
163 def _get_writeoff_amount(self, cr, uid, ids, name, args, context=None):
164 if not ids: return {}
165 res = {}
166 debit = credit = 0.0
167 for voucher in self.browse(cr, uid, ids, context=context):
168 for l in voucher.line_dr_ids:
169 debit += l.amount
170 for l in voucher.line_cr_ids:
171 credit += l.amount
172 res[voucher.id] = abs(voucher.amount - abs(credit - debit))
173 return res
174
175 _name = 'account.voucher'
176 _description = 'Accounting Voucher'
177 _order = "date desc, id desc"
178# _rec_name = 'number'
179 _columns = {
180 'type':fields.selection([
181 ('sale','Sale'),
182 ('purchase','Purchase'),
183 ('payment','Payment'),
184 ('receipt','Receipt'),
185 ],'Default Type', readonly=True, states={'draft':[('readonly',False)]}),
186 'name':fields.char('Memo', size=256, readonly=True, states={'draft':[('readonly',False)]}),
187 'date':fields.date('Date', readonly=True, select=True, states={'draft':[('readonly',False)]}, help="Effective date for accounting entries"),
188 'journal_id':fields.many2one('account.journal', 'Journal', required=True, readonly=True, states={'draft':[('readonly',False)]}),
189 'account_id':fields.many2one('account.account', 'Account', required=True, readonly=True, states={'draft':[('readonly',False)]}),
190 'line_ids':fields.one2many('account.voucher.line','voucher_id','Voucher Lines', readonly=True, states={'draft':[('readonly',False)]}),
191 'line_cr_ids':fields.one2many('account.voucher.line','voucher_id','Credits',
192 domain=[('type','=','cr')], context={'default_type':'cr'}, readonly=True, states={'draft':[('readonly',False)]}),
193 'line_dr_ids':fields.one2many('account.voucher.line','voucher_id','Debits',
194 domain=[('type','=','dr')], context={'default_type':'dr'}, readonly=True, states={'draft':[('readonly',False)]}),
195 'period_id': fields.many2one('account.period', 'Period', required=True, readonly=True, states={'draft':[('readonly',False)]}),
196 'narration':fields.text('Notes', readonly=True, states={'draft':[('readonly',False)]}),
197 'currency_id':fields.many2one('res.currency', 'Currency', readonly=True, states={'draft':[('readonly',False)]}),
198# 'currency_id': fields.related('journal_id','currency', type='many2one', relation='res.currency', string='Currency', store=True, readonly=True, states={'draft':[('readonly',False)]}),
199 'company_id': fields.many2one('res.company', 'Company', required=True, readonly=True, states={'draft':[('readonly',False)]}),
200 'state':fields.selection(
201 [('draft','Draft'),
202 ('proforma','Pro-forma'),
203 ('posted','Posted'),
204 ('cancel','Cancelled')
205 ], 'State', readonly=True, size=32,
206 help=' * The \'Draft\' state is used when a user is encoding a new and unconfirmed Voucher. \
207 \n* The \'Pro-forma\' when voucher is in Pro-forma state,voucher does not have an voucher number. \
208 \n* The \'Posted\' state is used when user create voucher,a voucher number is generated and voucher entries are created in account \
209 \n* The \'Cancelled\' state is used when user cancel voucher.'),
210 'amount': fields.float('Total', digits_compute=dp.get_precision('Account'), required=True, readonly=True, states={'draft':[('readonly',False)]}),
211 'tax_amount':fields.float('Tax Amount', digits_compute=dp.get_precision('Account'), readonly=True, states={'draft':[('readonly',False)]}),
212 'reference': fields.char('Ref #', size=64, readonly=True, states={'draft':[('readonly',False)]}, help="Transaction reference number."),
213 'number': fields.char('Number', size=32, readonly=True,),
214 'move_id':fields.many2one('account.move', 'Account Entry'),
215 'move_ids': fields.related('move_id','line_id', type='one2many', relation='account.move.line', string='Journal Items', readonly=True),
216 'partner_id':fields.many2one('res.partner', 'Partner', change_default=1, readonly=True, states={'draft':[('readonly',False)]}),
217 'audit': fields.related('move_id','to_check', type='boolean', relation='account.move', string='Audit Complete ?'),
218 'pay_now':fields.selection([
219 ('pay_now','Pay Directly'),
220 ('pay_later','Pay Later or Group Funds'),
221 ],'Payment', select=True, readonly=True, states={'draft':[('readonly',False)]}),
222 'tax_id':fields.many2one('account.tax', 'Tax', readonly=True, states={'draft':[('readonly',False)]}),
223 'pre_line':fields.boolean('Previous Payments ?', required=False),
224 'date_due': fields.date('Due Date', readonly=True, select=True, states={'draft':[('readonly',False)]}),
225 'payment_option':fields.selection([
226 ('without_writeoff', 'Keep Open'),
227 ('with_writeoff', 'Reconcile with Write-Off'),
228 ], 'Payment Difference', required=True, readonly=True, states={'draft': [('readonly', False)]}),
229 'writeoff_acc_id': fields.many2one('account.account', 'Write-Off account', readonly=True, states={'draft': [('readonly', False)]}),
230 'comment': fields.char('Write-Off Comment', size=64, required=True, readonly=True, states={'draft': [('readonly', False)]}),
231 'analytic_id': fields.many2one('account.analytic.account','Write-Off Analytic Account', readonly=True, states={'draft': [('readonly', False)]}),
232 'writeoff_amount': fields.function(_get_writeoff_amount, method=True, string='Write-Off Amount', type='float', readonly=True),
233 }
234 _defaults = {
235 'period_id': _get_period,
236 'partner_id': _get_partner,
237 'journal_id':_get_journal,
238 'currency_id': _get_currency,
239 'reference': _get_reference,
240 'narration':_get_narration,
241 'amount': _get_amount,
242 'type':_get_type,
243 'state': 'draft',
244 'pay_now': 'pay_later',
245 'name': '',
246 'date': lambda *a: time.strftime('%Y-%m-%d'),
247 'company_id': lambda self,cr,uid,c: self.pool.get('res.company')._company_default_get(cr, uid, 'account.voucher',context=c),
248 'tax_id': _get_tax,
249 'payment_option': 'without_writeoff',
250 'comment': _('Write-Off'),
251 }
252
253 def compute_tax(self, cr, uid, ids, context=None):
254 tax_pool = self.pool.get('account.tax')
255 partner_pool = self.pool.get('res.partner')
256 position_pool = self.pool.get('account.fiscal.position')
257 voucher_line_pool = self.pool.get('account.voucher.line')
258 voucher_pool = self.pool.get('account.voucher')
259 if context is None: context = {}
260
261 for voucher in voucher_pool.browse(cr, uid, ids, context=context):
262 voucher_amount = 0.0
263 for line in voucher.line_ids:
264 voucher_amount += line.untax_amount or line.amount
265 line.amount = line.untax_amount or line.amount
266 voucher_line_pool.write(cr, uid, [line.id], {'amount':line.amount, 'untax_amount':line.untax_amount})
267
268 if not voucher.tax_id:
269 self.write(cr, uid, [voucher.id], {'amount':voucher_amount, 'tax_amount':0.0})
270 continue
271
272 tax = [tax_pool.browse(cr, uid, voucher.tax_id.id, context=context)]
273 partner = partner_pool.browse(cr, uid, voucher.partner_id.id, context=context) or False
274 taxes = position_pool.map_tax(cr, uid, partner and partner.property_account_position or False, tax)
275 tax = tax_pool.browse(cr, uid, taxes, context=context)
276
277 total = voucher_amount
278 total_tax = 0.0
279
280 if not tax[0].price_include:
281 for tax_line in tax_pool.compute_all(cr, uid, tax, voucher_amount, 1).get('taxes', []):
282 total_tax += tax_line.get('amount', 0.0)
283 total += total_tax
284 else:
285 for line in voucher.line_ids:
286 line_total = 0.0
287 line_tax = 0.0
288
289 for tax_line in tax_pool.compute_all(cr, uid, tax, line.untax_amount or line.amount, 1).get('taxes', []):
290 line_tax += tax_line.get('amount', 0.0)
291 line_total += tax_line.get('price_unit')
292 total_tax += line_tax
293 untax_amount = line.untax_amount or line.amount
294 voucher_line_pool.write(cr, uid, [line.id], {'amount':line_total, 'untax_amount':untax_amount})
295
296 self.write(cr, uid, [voucher.id], {'amount':total, 'tax_amount':total_tax})
297 return True
298
299 def onchange_price(self, cr, uid, ids, line_ids, tax_id, partner_id=False, context=None):
300 tax_pool = self.pool.get('account.tax')
301 partner_pool = self.pool.get('res.partner')
302 position_pool = self.pool.get('account.fiscal.position')
303 res = {
304 'tax_amount': False,
305 'amount': False,
306 }
307 voucher_total = 0.0
308 voucher_line_ids = []
309
310 total = 0.0
311 total_tax = 0.0
312 for line in line_ids:
313 line_amount = 0.0
314 line_amount = line[2] and line[2].get('amount',0.0) or 0.0
315 voucher_line_ids += [line[1]]
316 voucher_total += line_amount
317
318 total = voucher_total
319 total_tax = 0.0
320 if tax_id:
321 tax = [tax_pool.browse(cr, uid, tax_id, context=context)]
322 if partner_id:
323 partner = partner_pool.browse(cr, uid, partner_id, context=context) or False
324 taxes = position_pool.map_tax(cr, uid, partner and partner.property_account_position or False, tax)
325 tax = tax_pool.browse(cr, uid, taxes, context=context)
326
327 if not tax[0].price_include:
328 for tax_line in tax_pool.compute_all(cr, uid, tax, voucher_total, 1).get('taxes', []):
329 total_tax += tax_line.get('amount')
330 total += total_tax
331
332 res.update({
333 'amount':total or voucher_total,
334 'tax_amount':total_tax
335 })
336 return {
337 'value':res
338 }
339
340 def onchange_term_id(self, cr, uid, ids, term_id, amount):
341 term_pool = self.pool.get('account.payment.term')
342 terms = False
343 due_date = False
344 default = {'date_due':False}
345 if term_id and amount:
346 terms = term_pool.compute(cr, uid, term_id, amount)
347 if terms:
348 due_date = terms[-1][0]
349 default.update({
350 'date_due':due_date
351 })
352 return {'value':default}
353
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):
355 """price
356 Returns a dict that contains new values and context
357
358 @param partner_id: latest value from user input for field partner_id
359 @param args: other arguments
360 @param context: context arguments, like lang, time zone
361
362 @return: Returns a dict which contains new values, and context
363 """
364 default = {
365 'value':{},
366 }
367
368 if not partner_id or not journal_id:
369 return default
370
371 partner_pool = self.pool.get('res.partner')
372 journal_pool = self.pool.get('account.journal')
373
374 journal = journal_pool.browse(cr, uid, journal_id, context=context)
375 partner = partner_pool.browse(cr, uid, partner_id, context=context)
376 account_id = False
377 tr_type = False
378 if journal.type in ('sale','sale_refund'):
379 account_id = partner.property_account_receivable.id
380 tr_type = 'sale'
381 elif journal.type in ('purchase', 'purchase_refund','expense'):
382 account_id = partner.property_account_payable.id
383 tr_type = 'purchase'
384 else:
385 account_id = journal.default_credit_account_id.id or journal.default_debit_account_id.id
386 tr_type = 'receipt'
387
388 default['value']['account_id'] = account_id
389 default['value']['type'] = ttype or tr_type
390
391 vals = self.onchange_journal(cr, uid, ids, journal_id, line_ids, tax_id, partner_id, context)
392 default['value'].update(vals.get('value'))
393
394 return default
395
396 def onchange_partner_id(self, cr, uid, ids, partner_id, journal_id, price, currency_id, ttype, date, context=None):
397 """price
398 Returns a dict that contains new values and context
399
400 @param partner_id: latest value from user input for field partner_id
401 @param args: other arguments
402 @param context: context arguments, like lang, time zone
403
404 @return: Returns a dict which contains new values, and context
405 """
406 if context is None:
407 context = {}
408 if not journal_id:
409 return {}
410 context_multi_currency = context.copy()
411 if date:
412 context_multi_currency.update({'date': date})
413
414 line_pool = self.pool.get('account.voucher.line')
415 line_ids = ids and line_pool.search(cr, uid, [('voucher_id', '=', ids[0])]) or False
416 if line_ids:
417 line_pool.unlink(cr, uid, line_ids)
418
419 currency_pool = self.pool.get('res.currency')
420 move_line_pool = self.pool.get('account.move.line')
421 partner_pool = self.pool.get('res.partner')
422 journal_pool = self.pool.get('account.journal')
423
424 vals = self.onchange_journal(cr, uid, ids, journal_id, [], False, partner_id, context)
425 vals = vals.get('value')
426 currency_id = vals.get('currency_id', currency_id)
427 default = {
428 'value':{'line_ids':[], 'line_dr_ids':[], 'line_cr_ids':[], 'pre_line': False, 'currency_id':currency_id},
429 }
430
431 if not partner_id:
432 return default
433
434 if not partner_id and ids:
435 line_ids = line_pool.search(cr, uid, [('voucher_id', '=', ids[0])])
436 if line_ids:
437 line_pool.unlink(cr, uid, line_ids)
438 return default
439
440 journal = journal_pool.browse(cr, uid, journal_id, context=context)
441 partner = partner_pool.browse(cr, uid, partner_id, context=context)
442 account_id = False
443 if journal.type in ('sale','sale_refund'):
444 account_id = partner.property_account_receivable.id
445 elif journal.type in ('purchase', 'purchase_refund','expense'):
446 account_id = partner.property_account_payable.id
447 else:
448 account_id = journal.default_credit_account_id.id or journal.default_debit_account_id.id
449
450 default['value']['account_id'] = account_id
451
452 if journal.type not in ('cash', 'bank'):
453 return default
454
455 total_credit = 0.0
456 total_debit = 0.0
457 account_type = 'receivable'
458 if ttype == 'payment':
459 account_type = 'payable'
460 total_debit = price or 0.0
461 else:
462 total_credit = price or 0.0
463 account_type = 'receivable'
464
465 if not context.get('move_line_ids', False):
466 domain = [('state','=','valid'), ('account_id.type', '=', account_type), ('reconcile_id', '=', False), ('partner_id', '=', partner_id)]
467 if context.get('invoice_id', False):
468 domain.append(('invoice', '=', context['invoice_id']))
469 ids = move_line_pool.search(cr, uid, domain, context=context)
470 else:
471 ids = context['move_line_ids']
472 ids.reverse()
473 moves = move_line_pool.browse(cr, uid, ids, context=context)
474
475 company_currency = journal.company_id.currency_id.id
476 if company_currency != currency_id and ttype == 'payment':
477 total_debit = currency_pool.compute(cr, uid, currency_id, company_currency, total_debit, context=context_multi_currency)
478 elif company_currency != currency_id and ttype == 'receipt':
479 total_credit = currency_pool.compute(cr, uid, currency_id, company_currency, total_credit, context=context_multi_currency)
480
481 for line in moves:
482 if line.credit and line.reconcile_partial_id and ttype == 'receipt':
483 continue
484 if line.debit and line.reconcile_partial_id and ttype == 'payment':
485 continue
486 total_credit += line.credit or 0.0
487 total_debit += line.debit or 0.0
488 for line in moves:
489 if line.credit and line.reconcile_partial_id and ttype == 'receipt':
490 continue
491 if line.debit and line.reconcile_partial_id and ttype == 'payment':
492 continue
493 original_amount = line.credit or line.debit or 0.0
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)
495 rs = {
496 'name':line.move_id.name,
497 'type': line.credit and 'dr' or 'cr',
498 'move_line_id':line.id,
499 'account_id':line.account_id.id,
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),
501 'date_original':line.date,
502 'date_due':line.date_maturity,
503 'amount_unreconciled': amount_unreconciled,
504 }
505
506 if line.credit:
507 amount = min(amount_unreconciled, currency_pool.compute(cr, uid, company_currency, currency_id, abs(total_debit), context=context_multi_currency))
508 rs['amount'] = amount
509 total_debit -= amount
510 else:
511 amount = min(amount_unreconciled, currency_pool.compute(cr, uid, company_currency, currency_id, abs(total_credit), context=context_multi_currency))
512 rs['amount'] = amount
513 total_credit -= amount
514
515 default['value']['line_ids'].append(rs)
516 if rs['type'] == 'cr':
517 default['value']['line_cr_ids'].append(rs)
518 else:
519 default['value']['line_dr_ids'].append(rs)
520
521 if ttype == 'payment' and len(default['value']['line_cr_ids']) > 0:
522 default['value']['pre_line'] = 1
523 elif ttype == 'receipt' and len(default['value']['line_dr_ids']) > 0:
524 default['value']['pre_line'] = 1
525 default['value']['writeoff_amount'] = self._compute_writeoff_amount(cr, uid, default['value']['line_dr_ids'], default['value']['line_cr_ids'], price)
526
527 return default
528
529 def onchange_date(self, cr, uid, ids, partner_id, journal_id, price, currency_id, ttype, date, context=None):
530 """
531 @param date: latest value from user input for field date
532 @param args: other arguments
533 @param context: context arguments, like lang, time zone
534 @return: Returns a dict which contains new values, and context
535 """
536 period_pool = self.pool.get('account.period')
537 res = self.onchange_partner_id(cr, uid, ids, partner_id, journal_id, price, currency_id, ttype, date, context=context)
538 pids = period_pool.search(cr, uid, [('date_start', '<=', date), ('date_stop', '>=', date)])
539 if pids:
540 if not 'value' in res:
541 res['value'] = {}
542 res['value'].update({'period_id':pids[0]})
543 return res
544
545 def onchange_journal(self, cr, uid, ids, journal_id, line_ids, tax_id, partner_id, context=None):
546 if not journal_id:
547 return False
548 journal_pool = self.pool.get('account.journal')
549 journal = journal_pool.browse(cr, uid, journal_id, context=context)
550 account_id = journal.default_credit_account_id or journal.default_debit_account_id
551 tax_id = False
552 if account_id and account_id.tax_ids:
553 tax_id = account_id.tax_ids[0].id
554
555 vals = self.onchange_price(cr, uid, ids, line_ids, tax_id, partner_id, context)
556 vals['value'].update({'tax_id':tax_id})
557 currency_id = journal.company_id.currency_id.id
558 if journal.currency:
559 currency_id = journal.currency.id
560 vals['value'].update({'currency_id':currency_id})
561 return vals
562
563 def proforma_voucher(self, cr, uid, ids, context=None):
564 self.action_move_line_create(cr, uid, ids, context=context)
565 return True
566
567 def action_cancel_draft(self, cr, uid, ids, context=None):
568 wf_service = netsvc.LocalService("workflow")
569 for voucher_id in ids:
570 wf_service.trg_create(uid, 'account.voucher', voucher_id, cr)
571 self.write(cr, uid, ids, {'state':'draft'})
572 return True
573
574 def cancel_voucher(self, cr, uid, ids, context=None):
575 reconcile_pool = self.pool.get('account.move.reconcile')
576 move_pool = self.pool.get('account.move')
577
578 for voucher in self.browse(cr, uid, ids, context=context):
579 recs = []
580 for line in voucher.move_ids:
581 if line.reconcile_id:
582 recs += [line.reconcile_id.id]
583 if line.reconcile_partial_id:
584 recs += [line.reconcile_partial_id.id]
585
586 reconcile_pool.unlink(cr, uid, recs)
587
588 if voucher.move_id:
589 move_pool.button_cancel(cr, uid, [voucher.move_id.id])
590 move_pool.unlink(cr, uid, [voucher.move_id.id])
591 res = {
592 'state':'cancel',
593 'move_id':False,
594 }
595 self.write(cr, uid, ids, res)
596 return True
597
598 def unlink(self, cr, uid, ids, context=None):
599 for t in self.read(cr, uid, ids, ['state'], context=context):
600 if t['state'] not in ('draft', 'cancel'):
601 raise osv.except_osv(_('Invalid action !'), _('Cannot delete Voucher(s) which are already opened or paid !'))
602 return super(account_voucher, self).unlink(cr, uid, ids, context=context)
603
604 # TODO: may be we can remove this method if not used anyware
605 def onchange_payment(self, cr, uid, ids, pay_now, journal_id, partner_id, ttype='sale'):
606 res = {}
607 if not partner_id:
608 return res
609 res = {'account_id':False}
610 partner_pool = self.pool.get('res.partner')
611 journal_pool = self.pool.get('account.journal')
612 if pay_now == 'pay_later':
613 partner = partner_pool.browse(cr, uid, partner_id)
614 journal = journal_pool.browse(cr, uid, journal_id)
615 if journal.type in ('sale','sale_refund'):
616 account_id = partner.property_account_receivable.id
617 elif journal.type in ('purchase', 'purchase_refund','expense'):
618 account_id = partner.property_account_payable.id
619 else:
620 account_id = journal.default_credit_account_id.id or journal.default_debit_account_id.id
621 res['account_id'] = account_id
622 return {'value':res}
623
624 def __hook_move_line_values_before_creation(self, cr, uid, move_line):
625 """
626 Change move line vals before its creation
627 """
628 return move_line
629
630 def action_move_line_create(self, cr, uid, ids, context=None):
631
632 def _get_payment_term_lines(term_id, amount):
633 term_pool = self.pool.get('account.payment.term')
634 if term_id and amount:
635 terms = term_pool.compute(cr, uid, term_id, amount)
636 return terms
637 return False
638 if context is None:
639 context = {}
640 move_pool = self.pool.get('account.move')
641 move_line_pool = self.pool.get('account.move.line')
642 currency_pool = self.pool.get('res.currency')
643 tax_obj = self.pool.get('account.tax')
644 seq_obj = self.pool.get('ir.sequence')
645 for inv in self.browse(cr, uid, ids, context=context):
646 if inv.move_id:
647 continue
648 context_multi_currency = context.copy()
649 context_multi_currency.update({'date': inv.date})
650
651 if inv.number:
652 name = inv.number
653 elif inv.journal_id.sequence_id:
654 name = seq_obj.get_id(cr, uid, inv.journal_id.sequence_id.id)
655 else:
656 raise osv.except_osv(_('Error !'), _('Please define a sequence on the journal !'))
657 if not inv.reference:
658 ref = name.replace('/','')
659 else:
660 ref = inv.reference
661
662 move = {
663 'name': name,
664 'journal_id': inv.journal_id.id,
665 'narration': inv.narration,
666 'date': inv.date,
667 'ref': ref,
668 'period_id': inv.period_id and inv.period_id.id or False
669 }
670 move_id = move_pool.create(cr, uid, move)
671
672 #create the first line manually
673 company_currency = inv.journal_id.company_id.currency_id.id
674 current_currency = inv.currency_id.id
675 debit = 0.0
676 credit = 0.0
677 # TODO: is there any other alternative then the voucher type ??
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
679 if inv.type in ('purchase', 'payment'):
680 credit = currency_pool.compute(cr, uid, current_currency, company_currency, inv.amount, context=context_multi_currency)
681 elif inv.type in ('sale', 'receipt'):
682 debit = currency_pool.compute(cr, uid, current_currency, company_currency, inv.amount, context=context_multi_currency)
683 if debit < 0:
684 credit = -debit
685 debit = 0.0
686 if credit < 0:
687 debit = -credit
688 credit = 0.0
689 sign = debit - credit < 0 and -1 or 1
690 #create the first line of the voucher
691 move_line = {
692 'name': inv.name or '/',
693 'debit': debit,
694 'credit': credit,
695 'account_id': inv.account_id.id,
696 'move_id': move_id,
697 'journal_id': inv.journal_id.id,
698 'period_id': inv.period_id.id,
699 'partner_id': inv.partner_id.id,
700 'currency_id': company_currency <> current_currency and current_currency or False,
701 'amount_currency': company_currency <> current_currency and sign * inv.amount or 0.0,
702 'date': inv.date,
703 'date_maturity': inv.date_due
704 }
705 move_line = self.__hook_move_line_values_before_creation(cr, uid, move_line)
706 move_line_pool.create(cr, uid, move_line)
707 rec_list_ids = []
708 line_total = debit - credit
709 if inv.type == 'sale':
710 line_total = line_total - currency_pool.compute(cr, uid, inv.currency_id.id, company_currency, inv.tax_amount, context=context_multi_currency)
711 elif inv.type == 'purchase':
712 line_total = line_total + currency_pool.compute(cr, uid, inv.currency_id.id, company_currency, inv.tax_amount, context=context_multi_currency)
713
714 for line in inv.line_ids:
The diff has been truncated for viewing.

Subscribers

People subscribed via source and target branches