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

Proposed by jftempo
Status: Merged
Merged at revision: 5545
Proposed branch: lp:~julie-w/unifield-server/US-6572
Merge into: lp:unifield-server
Diff against target: 59299 lines (+1394/-52071)
202 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 (+27/-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 (+143/-1321)
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 (+15/-46)
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 (+8/-7)
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 (+1/-234)
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)
To merge this branch: bzr merge lp:~julie-w/unifield-server/US-6572
Reviewer Review Type Date Requested Status
UniField Reviewer Team Pending
Review via email: mp+374728@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
1=== modified file 'bin/addons/account/__init__.py'
2--- bin/addons/account/__init__.py 2011-01-14 00:11:01 +0000
3+++ bin/addons/account/__init__.py 2019-10-25 14:10:32 +0000
4@@ -33,6 +33,5 @@
5 import product
6 import sequence
7 import company
8-import res_currency
9
10 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
11
12=== modified file 'bin/addons/account/__openerp__.py'
13--- bin/addons/account/__openerp__.py 2019-07-24 14:20:02 +0000
14+++ bin/addons/account/__openerp__.py 2019-10-25 14:10:32 +0000
15@@ -54,7 +54,6 @@
16 'report/account_analytic_entries_report_view.xml',
17 'wizard/account_move_bank_reconcile_view.xml',
18 'wizard/account_use_model_view.xml',
19- 'account_installer.xml',
20 'wizard/account_period_close_view.xml',
21 'account_view.xml',
22 'account_report.xml',
23
24=== modified file 'bin/addons/account/account.py'
25--- bin/addons/account/account.py 2019-07-30 09:13:43 +0000
26+++ bin/addons/account/account.py 2019-10-25 14:10:32 +0000
27@@ -2276,75 +2276,6 @@
28 _defaults = {
29 'legend': lambda self, cr, uid, context:_('You can specify year, month and date in the name of the model using the following labels:\n\n%(year)s: To Specify Year \n%(month)s: To Specify Month \n%(date)s: Current Date\n\ne.g. My model on %(date)s'),
30 }
31- def generate(self, cr, uid, ids, datas={}, context=None):
32- move_ids = []
33- entry = {}
34- account_move_obj = self.pool.get('account.move')
35- account_move_line_obj = self.pool.get('account.move.line')
36- pt_obj = self.pool.get('account.payment.term')
37-
38- if context is None:
39- context = {}
40-
41- if datas.get('date', False):
42- context.update({'date': datas['date']})
43-
44- period_id = self.pool.get('account.period').find(cr, uid, dt=context.get('date', False))
45- if not period_id:
46- raise osv.except_osv(_('No period found !'), _('Unable to find a valid period !'))
47- period_id = period_id[0]
48-
49- for model in self.browse(cr, uid, ids, context=context):
50- entry['name'] = model.name%{'year':time.strftime('%Y'), 'month':time.strftime('%m'), 'date':time.strftime('%Y-%m')}
51- move_id = account_move_obj.create(cr, uid, {
52- 'ref': entry['name'],
53- 'period_id': period_id,
54- 'journal_id': model.journal_id.id,
55- 'date': context.get('date',time.strftime('%Y-%m-%d'))
56- })
57- move_ids.append(move_id)
58- for line in model.lines_id:
59- analytic_account_id = False
60- if line.analytic_account_id:
61- if not model.journal_id.analytic_journal_id:
62- raise osv.except_osv(_('No Analytic Journal !'),_("You have to define an analytic journal on the '%s' journal!") % (model.journal_id.name,))
63- analytic_account_id = line.analytic_account_id.id
64- val = {
65- 'move_id': move_id,
66- 'journal_id': model.journal_id.id,
67- 'period_id': period_id,
68- 'analytic_account_id': analytic_account_id
69- }
70-
71- date_maturity = time.strftime('%Y-%m-%d')
72- if line.date_maturity == 'partner':
73- if not line.partner_id:
74- raise osv.except_osv(_('Error !'), _("Maturity date of entry line generated by model line '%s' of model '%s' is based on partner payment term!" \
75- "\nPlease define partner on it!")%(line.name, model.name))
76- if line.partner_id.property_payment_term:
77- payment_term_id = line.partner_id.property_payment_term.id
78- pterm_list = pt_obj.compute(cr, uid, payment_term_id, value=1, date_ref=date_maturity)
79- if pterm_list:
80- pterm_list = [l[0] for l in pterm_list]
81- pterm_list.sort()
82- date_maturity = pterm_list[-1]
83-
84- val.update({
85- 'name': line.name,
86- 'quantity': line.quantity,
87- 'debit': line.debit,
88- 'credit': line.credit,
89- 'account_id': line.account_id.id,
90- 'move_id': move_id,
91- 'partner_id': line.partner_id.id,
92- 'date': context.get('date',time.strftime('%Y-%m-%d')),
93- 'date_maturity': date_maturity
94- })
95- c = context.copy()
96- c.update({'journal_id': model.journal_id.id,'period_id': period_id})
97- account_move_line_obj.create(cr, uid, val, context=c)
98-
99- return move_ids
100
101 account_model()
102
103
104=== modified file 'bin/addons/account/account_analytic_line.py'
105--- bin/addons/account/account_analytic_line.py 2018-08-31 13:43:37 +0000
106+++ bin/addons/account/account_analytic_line.py 2019-10-25 14:10:32 +0000
107@@ -63,73 +63,6 @@
108 return False
109 return True
110
111- # Compute the cost based on the price type define into company
112- # property_valuation_price_type property
113- def on_change_unit_amount(self, cr, uid, id, prod_id, quantity, company_id,
114- unit=False, journal_id=False, context=None):
115- if context==None:
116- context={}
117- if not journal_id:
118- j_ids = self.pool.get('account.analytic.journal').search(cr, uid, [('type','=','purchase')])
119- journal_id = j_ids and j_ids[0] or False
120- if not journal_id or not prod_id:
121- return {}
122- product_obj = self.pool.get('product.product')
123- analytic_journal_obj =self.pool.get('account.analytic.journal')
124- product_price_type_obj = self.pool.get('product.price.type')
125- j_id = analytic_journal_obj.browse(cr, uid, journal_id, context=context)
126- prod = product_obj.browse(cr, uid, prod_id, context=context)
127- result = 0.0
128-
129- if j_id.type <> 'sale':
130- a = prod.product_tmpl_id.property_account_expense.id
131- if not a:
132- a = prod.categ_id.property_account_expense_categ.id
133- if not a:
134- raise osv.except_osv(_('Error !'),
135- _('There is no expense account defined ' \
136- 'for this product: "%s" (id:%d)') % \
137- (prod.name, prod.id,))
138- else:
139- a = prod.product_tmpl_id.property_account_income.id
140- if not a:
141- a = prod.categ_id.property_account_income_categ.id
142- if not a:
143- raise osv.except_osv(_('Error !'),
144- _('There is no income account defined ' \
145- 'for this product: "%s" (id:%d)') % \
146- (prod.name, prod_id,))
147-
148- flag = False
149- # Compute based on pricetype
150- product_price_type_ids = product_price_type_obj.search(cr, uid, [('field','=','standard_price')], context=context)
151- pricetype = product_price_type_obj.browse(cr, uid, product_price_type_ids, context=context)[0]
152- if journal_id:
153- journal = analytic_journal_obj.browse(cr, uid, journal_id, context=context)
154- if journal.type == 'sale':
155- product_price_type_ids = product_price_type_obj.search(cr, uid, [('field','=','list_price')], context)
156- if product_price_type_ids:
157- pricetype = product_price_type_obj.browse(cr, uid, product_price_type_ids, context=context)[0]
158- # Take the company currency as the reference one
159- if pricetype.field == 'list_price':
160- flag = True
161- ctx = context.copy()
162- if unit:
163- # price_get() will respect a 'uom' in its context, in order
164- # to return a default price for those units
165- ctx['uom'] = unit
166- amount_unit = prod.price_get(pricetype.field, context=ctx)[prod.id]
167- prec = self.pool.get('decimal.precision').precision_get(cr, uid, 'Account')
168- amount = amount_unit * quantity or 1.0
169- result = round(amount, prec)
170- if not flag:
171- result *= -1
172- return {'value': {
173- 'amount': result,
174- 'general_account_id': a,
175- }
176- }
177-
178 def view_header_get(self, cr, user, view_id, view_type, context=None):
179 if context is None:
180 context = {}
181
182=== modified file 'bin/addons/account/account_bank_statement.py'
183--- bin/addons/account/account_bank_statement.py 2016-11-17 08:46:41 +0000
184+++ bin/addons/account/account_bank_statement.py 2019-10-25 14:10:32 +0000
185@@ -25,28 +25,43 @@
186 from tools.translate import _
187 import decimal_precision as dp
188
189+
190 class account_bank_statement(osv.osv):
191
192- def create(self, cr, uid, vals, context=None):
193- seq = 0
194- if 'line_ids' in vals:
195- for line in vals['line_ids']:
196- seq += 1
197- line[2]['sequence'] = seq
198- vals[seq - 1] = line
199- return super(account_bank_statement, self).create(cr, uid, vals, context=context)
200-
201 def write(self, cr, uid, ids, vals, context=None):
202 if not ids:
203 return True
204- res = super(account_bank_statement, self).write(cr, uid, ids, vals, context=context)
205- account_bank_statement_line_obj = self.pool.get('account.bank.statement.line')
206- for statement in self.browse(cr, uid, ids, context):
207- seq = 0
208- for line in statement.line_ids:
209- seq += 1
210- account_bank_statement_line_obj.write(cr, uid, [line.id], {'sequence': seq}, context=context)
211- return res
212+ if context is None:
213+ context = {}
214+
215+ if not context.get('sync_update_execution'):
216+ if 'balance_end_real' in vals:
217+ new_vals = {'balance_start': vals['balance_end_real']}
218+ # US-948/2: carry over end of month balance to next registers if
219+ # the source register is not 'end of month balance' frozen
220+ # note: the last carry over is processed via
221+ # 'button_confirm_closing_bank_balance' button
222+ to_write_id_list = []
223+ for r in self.read(cr, uid, ids,
224+ [ 'closing_balance_frozen', 'journal_id', ],
225+ context=context):
226+ if not r['closing_balance_frozen']:
227+ if r['journal_id']:
228+ jtype = self.pool.get('account.journal').read(cr,
229+ uid, [r['journal_id'][0]], ['type'],
230+ context=context)[0]['type']
231+ if jtype != 'cash':
232+ args = [('prev_reg_id', '=', r['id'])]
233+ search_ids = self.search(cr, uid, args,
234+ context=context)
235+ if search_ids:
236+ to_write_id_list.extend(search_ids)
237+ self.write(cr, uid, to_write_id_list, new_vals, context=context)
238+
239+ if not vals:
240+ return True
241+
242+ return super(account_bank_statement, self).write(cr, uid, ids, vals, context=context)
243
244 def _default_journal_id(self, cr, uid, context=None):
245 if context is None:
246@@ -60,43 +75,25 @@
247 journal_id = ids[0]
248 return journal_id
249
250- def _default_balance_start(self, cr, uid, context=None):
251- cr.execute('select id from account_bank_statement where journal_id=%s order by date desc limit 1', (1,))
252- res = cr.fetchone()
253- if res:
254- return self.browse(cr, uid, res[0], context=context).balance_end
255- return 0.0
256-
257- def _end_balance(self, cursor, user, ids, name, attr, context=None):
258- res_currency_obj = self.pool.get('res.currency')
259- res_users_obj = self.pool.get('res.users')
260+ def _end_balance(self, cr, uid, ids, field_name=None, arg=None, context=None):
261+ """
262+ Calculate register's balance
263+ """
264+ if context is None:
265+ context = {}
266 res = {}
267
268- company_currency_id = res_users_obj.browse(cursor, user, user,
269- context=context).company_id.currency_id.id
270-
271- statements = self.browse(cursor, user, ids, context=context)
272- for statement in statements:
273+ # Add this context in order to escape cheque register filter
274+ ctx = context.copy()
275+ ctx.update({'from_end_balance': True})
276+ for statement in self.browse(cr, uid, ids, context=ctx):
277 res[statement.id] = statement.balance_start
278- currency_id = statement.currency.id
279- for line in statement.move_line_ids:
280- if line.debit > 0:
281- if line.account_id.id == \
282- statement.journal_id.default_debit_account_id.id:
283- res[statement.id] += res_currency_obj.compute(cursor,
284- user, company_currency_id, currency_id,
285- line.debit, context=context)
286- else:
287- if line.account_id.id == \
288- statement.journal_id.default_credit_account_id.id:
289- res[statement.id] -= res_currency_obj.compute(cursor,
290- user, company_currency_id, currency_id,
291- line.credit, context=context)
292- if statement.state == 'draft':
293- for line in statement.line_ids:
294- res[statement.id] += line.amount
295- for r in res:
296- res[r] = round(res[r], 2)
297+ for st_line in statement.line_ids:
298+ res[statement.id] += st_line.amount or 0.0
299+ # UF-425: Add the Open Advances Amount when calculating the "Calculated Balance" value
300+ res[statement.id] -= statement.open_advance_amount or 0.0
301+ # UF-810: Add a "Unrecorded Expenses" when calculating "Calculated Balance"
302+ res[statement.id] -= statement.unrecorded_expenses_amount or 0.0
303 return res
304
305 def _get_period(self, cr, uid, context=None):
306@@ -125,21 +122,18 @@
307 res[statement_id] = (currency_id, currency_names[currency_id])
308 return res
309
310- _order = "date desc, id desc"
311 _name = "account.bank.statement"
312 _description = "Bank Statement"
313 _columns = {
314- '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)]}),
315+ 'name': fields.char('Register Name', size=64, required=False, readonly=True, states={'draft': [('readonly', False)]}),
316 'date': fields.date('Date', required=True, states={'confirm': [('readonly', True)]}),
317- 'journal_id': fields.many2one('account.journal', 'Journal', required=True,
318- readonly=True, states={'draft':[('readonly',False)]}),
319- 'period_id': fields.many2one('account.period', 'Period', required=True,
320- states={'confirm':[('readonly', True)]}),
321+ 'journal_id': fields.many2one('account.journal', 'Journal', required=True, readonly=True),
322+ 'period_id': fields.many2one('account.period', 'Period', required=True),
323 'balance_start': fields.float('Starting Balance', digits_compute=dp.get_precision('Account'),
324 states={'confirm':[('readonly',True)]}),
325- 'balance_end_real': fields.float('Ending Balance', digits_compute=dp.get_precision('Account'),
326- states={'confirm':[('readonly', True)]}),
327- 'balance_end': fields.function(_end_balance, method=True, string='Balance'),
328+ 'balance_end_real': fields.float('Closing Balance', digits_compute=dp.get_precision('Account'), states={'confirm':[('readonly', True)]},
329+ help="Please enter manually the end-of-month balance, as per the printed bank statement received. Before confirming closing balance & closing the register, you must make sure that the calculated balance of the bank statement is equal to that amount."),
330+ 'balance_end': fields.function(_end_balance, method=True, store=False, string='Calculated Balance'),
331 'company_id': fields.related('journal_id', 'company_id', type='many2one', relation='res.company', string='Company', store=True, readonly=True),
332 'line_ids': fields.one2many('account.bank.statement.line',
333 'statement_id', 'Statement lines',
334@@ -147,21 +141,18 @@
335 'deleted_line_ids': fields.one2many('account.bank.statement.line.deleted', 'statement_id', 'Statement lines'),
336 'move_line_ids': fields.one2many('account.move.line', 'statement_id',
337 'Entry lines', states={'confirm':[('readonly',True)]}),
338- 'state': fields.selection([('draft', 'Draft'),('confirm', 'Confirmed')],
339- 'State', required=True,
340- states={'confirm': [('readonly', True)]}, readonly="1",
341- help='When new statement is created the state will be \'Draft\'. \
342- \n* And after getting confirmation from the bank it will be in \'Confirmed\' state.'),
343+ 'state': fields.selection((('draft', 'Draft'), ('open', 'Open'), ('partial_close', 'Partial Close'), ('confirm', 'Closed')),
344+ readonly="True", string='State'),
345 'currency': fields.function(_currency, method=True, string='Currency',
346 type='many2one', relation='res.currency'),
347 'account_id': fields.related('journal_id', 'default_debit_account_id', type='many2one', relation='account.account', string='Account used in this journal', readonly=True, help='used in statement reconciliation domain, but shouldn\'t be used elswhere.'),
348 }
349
350 _defaults = {
351- 'name': "/",
352+ 'name': False,
353 'date': lambda *a: time.strftime('%Y-%m-%d'),
354 'state': 'draft',
355- 'balance_start': _default_balance_start,
356+ 'balance_start': lambda *a: 0.0,
357 'journal_id': _default_journal_id,
358 'period_id': _get_period,
359 }
360@@ -199,168 +190,9 @@
361 def button_dummy(self, cr, uid, ids, context=None):
362 return self.write(cr, uid, ids, {}, context=context)
363
364- def create_move_from_st_line(self, cr, uid, st_line_id, company_currency_id, st_line_number, context=None):
365- if context is None:
366- context = {}
367- res_currency_obj = self.pool.get('res.currency')
368- account_move_obj = self.pool.get('account.move')
369- account_move_line_obj = self.pool.get('account.move.line')
370- account_bank_statement_line_obj = self.pool.get('account.bank.statement.line')
371- st_line = account_bank_statement_line_obj.browse(cr, uid, st_line_id, context=context)
372- st = st_line.statement_id
373-
374- context.update({'date': st_line.date})
375-
376- move_id = account_move_obj.create(cr, uid, {
377- 'journal_id': st.journal_id.id,
378- 'period_id': st.period_id.id,
379- 'date': st_line.date,
380- 'name': st_line_number,
381- }, context=context)
382- account_bank_statement_line_obj.write(cr, uid, [st_line.id], {
383- 'move_ids': [(4, move_id, False)]
384- })
385-
386- torec = []
387- if st_line.amount >= 0:
388- account_id = st.journal_id.default_credit_account_id.id
389- else:
390- account_id = st.journal_id.default_debit_account_id.id
391-
392- acc_cur = ((st_line.amount<=0) and st.journal_id.default_debit_account_id) or st_line.account_id
393- context.update({
394- 'res.currency.compute.account': acc_cur,
395- })
396- amount = res_currency_obj.compute(cr, uid, st.currency.id,
397- company_currency_id, st_line.amount, context=context)
398-
399- val = {
400- 'name': st_line.name,
401- 'date': st_line.date,
402- 'ref': st_line.ref,
403- 'move_id': move_id,
404- 'partner_id': ((st_line.partner_id) and st_line.partner_id.id) or False,
405- 'account_id': (st_line.account_id) and st_line.account_id.id,
406- 'credit': ((amount>0) and amount) or 0.0,
407- 'debit': ((amount<0) and -amount) or 0.0,
408- 'statement_id': st.id,
409- 'journal_id': st.journal_id.id,
410- 'period_id': st.period_id.id,
411- 'currency_id': st.currency.id,
412- 'analytic_account_id': st_line.analytic_account_id and st_line.analytic_account_id.id or False
413- }
414-
415- if st.currency.id <> company_currency_id:
416- amount_cur = res_currency_obj.compute(cr, uid, company_currency_id,
417- st.currency.id, amount, context=context)
418- val['amount_currency'] = -amount_cur
419-
420- if st_line.account_id and st_line.account_id.currency_id and st_line.account_id.currency_id.id <> company_currency_id:
421- val['currency_id'] = st_line.account_id.currency_id.id
422- amount_cur = res_currency_obj.compute(cr, uid, company_currency_id,
423- st_line.account_id.currency_id.id, amount, context=context)
424- val['amount_currency'] = -amount_cur
425-
426- move_line_id = account_move_line_obj.create(cr, uid, val, context=context)
427- torec.append(move_line_id)
428-
429- # Fill the secondary amount/currency
430- # if currency is not the same than the company
431- amount_currency = False
432- currency_id = False
433- if st.currency.id <> company_currency_id:
434- amount_currency = st_line.amount
435- currency_id = st.currency.id
436- account_move_line_obj.create(cr, uid, {
437- 'name': st_line.name,
438- 'date': st_line.date,
439- 'ref': st_line.ref,
440- 'move_id': move_id,
441- 'partner_id': ((st_line.partner_id) and st_line.partner_id.id) or False,
442- 'account_id': account_id,
443- 'credit': ((amount < 0) and -amount) or 0.0,
444- 'debit': ((amount > 0) and amount) or 0.0,
445- 'statement_id': st.id,
446- 'journal_id': st.journal_id.id,
447- 'period_id': st.period_id.id,
448- 'amount_currency': amount_currency,
449- 'currency_id': currency_id,
450- }, context=context)
451-
452- for line in account_move_line_obj.browse(cr, uid, [x.id for x in
453- account_move_obj.browse(cr, uid, move_id,
454- context=context).line_id],
455- context=context):
456- if line.state <> 'valid':
457- raise osv.except_osv(_('Error !'),
458- _('Journal Item "%s" is not valid') % line.name)
459-
460- # Bank statements will not consider boolean on journal entry_posted
461- account_move_obj.post(cr, uid, [move_id], context=context)
462- return move_id
463-
464- def get_next_st_line_number(self, cr, uid, st_number, st_line, context=None):
465- return st_number + '/' + str(st_line.sequence)
466-
467- def balance_check(self, cr, uid, st_id, journal_type='bank', context=None):
468- st = self.browse(cr, uid, st_id, context=context)
469- if not (abs((st.balance_end or 0.0) - st.balance_end_real) < 0.0001):
470- raise osv.except_osv(_('Error !'),
471- _('The statement balance is incorrect !\n') +
472- _('The expected balance (%.2f) is different than the computed one. (%.2f)') % (st.balance_end_real, st.balance_end))
473- return True
474-
475 def statement_close(self, cr, uid, ids, journal_type='bank', context=None):
476 return self.write(cr, uid, ids, {'state':'confirm'}, context=context)
477
478- def check_status_condition(self, cr, uid, state, journal_type='bank'):
479- return state=='draft'
480-
481- def button_confirm_bank(self, cr, uid, ids, context=None):
482- done = []
483- obj_seq = self.pool.get('ir.sequence')
484- if context is None:
485- context = {}
486-
487- for st in self.browse(cr, uid, ids, context=context):
488- j_type = st.journal_id.type
489- company_currency_id = st.journal_id.company_id.currency_id.id
490- if not self.check_status_condition(cr, uid, st.state, journal_type=j_type):
491- continue
492-
493- self.balance_check(cr, uid, st.id, journal_type=j_type, context=context)
494- if (not st.journal_id.default_credit_account_id) \
495- or (not st.journal_id.default_debit_account_id):
496- raise osv.except_osv(_('Configuration Error !'),
497- _('Please verify that an account is defined in the journal.'))
498-
499- if not st.name == '/':
500- st_number = st.name
501- else:
502- if st.journal_id.sequence_id:
503- c = {'fiscalyear_id': st.period_id.fiscalyear_id.id}
504- st_number = obj_seq.get_id(cr, uid, st.journal_id.sequence_id.id, context=c)
505- else:
506- st_number = obj_seq.get(cr, uid, 'account.bank.statement')
507-
508- for line in st.move_line_ids:
509- if line.state <> 'valid':
510- raise osv.except_osv(_('Error !'),
511- _('The account entries lines are not in valid state.'))
512- for st_line in st.line_ids:
513- if st_line.analytic_account_id:
514- if not st.journal_id.analytic_journal_id:
515- raise osv.except_osv(_('No Analytic Journal !'),_("You have to define an analytic journal on the '%s' journal!") % (st.journal_id.name,))
516- if not st_line.amount:
517- continue
518- st_line_number = self.get_next_st_line_number(cr, uid, st_number, st_line, context)
519- self.create_move_from_st_line(cr, uid, st_line.id, company_currency_id, st_line_number, context)
520-
521- self.write(cr, uid, [st.id], {'name': st_number}, context=context)
522- self.log(cr, uid, st.id, _('Statement %s is confirmed, journal items are created.') % (st_number,))
523- done.append(st.id)
524- return self.write(cr, uid, ids, {'state':'confirm'}, context=context)
525-
526 def button_cancel(self, cr, uid, ids, context=None):
527 done = []
528 account_move_obj = self.pool.get('account.move')
529
530=== modified file 'bin/addons/account/account_cash_statement.py'
531--- bin/addons/account/account_cash_statement.py 2019-07-30 09:13:43 +0000
532+++ bin/addons/account/account_cash_statement.py 2019-10-25 14:10:32 +0000
533@@ -70,7 +70,6 @@
534 _inherit = 'account.bank.statement'
535
536 def _get_starting_balance(self, cr, uid, ids, context=None):
537-
538 """ Find starting balance
539 @param name: Names of fields.
540 @param arg: User defined arguments
541@@ -83,13 +82,18 @@
542 if statement.journal_id.type not in('cash'):
543 continue
544
545- for line in statement.starting_details_ids:
546- amount_total+= line.pieces * line.number
547+ if not statement.prev_reg_id:
548+ for line in statement.starting_details_ids:
549+ amount_total+= line.pieces * line.number
550+ else:
551+ amount_total = statement.prev_reg_id.msf_calculated_balance
552+
553 res[statement.id] = {
554 'balance_start': amount_total
555 }
556 return res
557
558+
559 def _balance_end_cash(self, cr, uid, ids, name, arg, context=None):
560 """ Find ending balance "
561 @param name: Names of fields.
562@@ -119,39 +123,6 @@
563 res2[statement.id] = encoding_total
564 return res2
565
566- def _end_balance(self, cursor, user, ids, name, attr, context=None):
567- res_currency_obj = self.pool.get('res.currency')
568- res_users_obj = self.pool.get('res.users')
569- res = {}
570-
571- company_currency_id = res_users_obj.browse(cursor, user, user,
572- context=context).company_id.currency_id.id
573-
574- statements = self.browse(cursor, user, ids, context=context)
575- for statement in statements:
576- res[statement.id] = statement.balance_start
577- currency_id = statement.currency.id
578- for line in statement.move_line_ids:
579- if line.debit > 0:
580- if line.account_id.id == \
581- statement.journal_id.default_debit_account_id.id:
582- res[statement.id] += res_currency_obj.compute(cursor,
583- user, company_currency_id, currency_id,
584- line.debit, context=context)
585- else:
586- if line.account_id.id == \
587- statement.journal_id.default_credit_account_id.id:
588- res[statement.id] -= res_currency_obj.compute(cursor,
589- user, company_currency_id, currency_id,
590- line.credit, context=context)
591-
592- if statement.state in ('draft', 'open'):
593- for line in statement.line_ids:
594- res[statement.id] += line.amount
595- for r in res:
596- res[r] = round(res[r], 2)
597- return res
598-
599 def _get_company(self, cr, uid, context=None):
600 user_pool = self.pool.get('res.users')
601 company_pool = self.pool.get('res.company')
602@@ -218,79 +189,19 @@
603 return res
604
605 _columns = {
606- 'balance_end_real': fields.float('Closing Balance', digits_compute=dp.get_precision('Account'), states={'confirm': [('readonly', True)]}, help="closing balance entered by the cashbox verifier"),
607- 'state': fields.selection(
608- [('draft', 'Draft'),
609- ('confirm', 'Closed'),
610- ('open','Open')], 'State', required=True, states={'confirm': [('readonly', True)]}, readonly="1"),
611 'total_entry_encoding': fields.function(_get_sum_entry_encoding, method=True, store=False, string="Cash Transaction", help="Total cash transactions"),
612- 'balance_end': fields.function(_end_balance, method=True, store=False, string='Balance', help="Closing balance based on Starting Balance and Cash Transactions"),
613 'balance_end_cash': fields.function(_balance_end_cash, method=True, store=False, string='Balance', help="Closing balance based on cashBox"),
614 'starting_details_ids': fields.one2many('account.cashbox.line', 'starting_id', string='Opening Cashbox'),
615 'ending_details_ids': fields.one2many('account.cashbox.line', 'ending_id', string='Closing Cashbox'),
616- 'name': fields.char('Name', size=64, required=True, states={'draft': [('readonly', False)]}, readonly=True, help='if you give the Name other then /, its created Accounting Entries Move will be with same name as statement name. This allows the statement entries to have the same references than the statement itself'),
617 'user_id': fields.many2one('res.users', 'Responsible', required=False),
618 }
619 _defaults = {
620- 'state': 'draft',
621 'date': lambda *a: time.strftime("%Y-%m-%d %H:%M:%S"),
622 'user_id': lambda self, cr, uid, context=None: uid,
623 'starting_details_ids': _get_cash_open_box_lines,
624 'ending_details_ids': _get_default_cash_close_box_lines
625 }
626
627- def create(self, cr, uid, vals, context=None):
628- sql = [
629- ('journal_id', '=', vals.get('journal_id', False)),
630- ('state', '=', 'open')
631- ]
632- open_jrnl = self.search(cr, uid, sql)
633- if open_jrnl:
634- raise osv.except_osv(_('Error'), _('You can not have two open register for the same journal'))
635-
636- if self.pool.get('account.journal').browse(cr, uid, vals['journal_id'], context=context).type == 'cash':
637- open_close = self._get_cash_open_close_box_lines(cr, uid, context)
638- if vals.get('starting_details_ids', False):
639- for start in vals.get('starting_details_ids'):
640- dict_val = start[2]
641- for end in open_close['end']:
642- if end[2]['pieces'] == dict_val['pieces']:
643- end[2]['number'] += dict_val['number']
644- vals.update({
645- # 'ending_details_ids': open_close['start'],
646- 'starting_details_ids': open_close['end']
647- })
648- else:
649- vals.update({
650- 'ending_details_ids': False,
651- 'starting_details_ids': False
652- })
653- res_id = super(account_cash_statement, self).create(cr, uid, vals, context=context)
654- self.write(cr, uid, [res_id], {})
655- return res_id
656-
657- def write(self, cr, uid, ids, vals, context=None):
658- """
659- Update redord(s) comes in {ids}, with new value comes as {vals}
660- return True on success, False otherwise
661-
662- @param cr: cursor to database
663- @param user: id of current user
664- @param ids: list of record ids to be update
665- @param vals: dict of new values to be set
666- @param context: context arguments, like lang, time zone
667-
668- @return: True on success, False otherwise
669- """
670- if not ids:
671- return True
672-
673- super(account_cash_statement, self).write(cr, uid, ids, vals, context=context)
674- res = self._get_starting_balance(cr, uid, ids)
675- for rs in res:
676- super(account_cash_statement, self).write(cr, uid, [rs], res.get(rs))
677- return True
678-
679 def onchange_journal_id(self, cr, uid, statement_id, journal_id, context=None):
680 """ Changes balance start and starting details if journal_id changes"
681 @param statement_id: Changed statement_id
682@@ -346,13 +257,6 @@
683 self.write(cr, uid, [statement.id], vals, context=context)
684 return True
685
686- def balance_check(self, cr, uid, cash_id, journal_type='bank', context=None):
687- if journal_type == 'bank':
688- return super(account_cash_statement, self).balance_check(cr, uid, cash_id, journal_type, context)
689- if not self._equal_balance(cr, uid, cash_id, context):
690- raise osv.except_osv(_('Error !'), _('CashBox Balance is not matching with Calculated Balance !'))
691- return True
692-
693 def statement_close(self, cr, uid, ids, journal_type='bank', context=None):
694 if journal_type == 'bank':
695 return super(account_cash_statement, self).statement_close(cr, uid, ids, journal_type, context)
696@@ -362,15 +266,6 @@
697 }
698 return self.write(cr, uid, ids, vals, context=context)
699
700- def check_status_condition(self, cr, uid, state, journal_type='bank'):
701- if journal_type == 'bank':
702- return super(account_cash_statement, self).check_status_condition(cr, uid, state, journal_type)
703- return state=='open'
704-
705- def button_confirm_cash(self, cr, uid, ids, context=None):
706- super(account_cash_statement, self).button_confirm_bank(cr, uid, ids, context=context)
707- return self.write(cr, uid, ids, {'closing_date': time.strftime("%Y-%m-%d %H:%M:%S")}, context=context)
708-
709 def button_cancel(self, cr, uid, ids, context=None):
710 cash_box_line_pool = self.pool.get('account.cashbox.line')
711 super(account_cash_statement, self).button_cancel(cr, uid, ids, context=context)
712
713=== removed file 'bin/addons/account/account_installer.xml'
714--- bin/addons/account/account_installer.xml 2011-01-14 00:11:01 +0000
715+++ bin/addons/account/account_installer.xml 1970-01-01 00:00:00 +0000
716@@ -1,130 +0,0 @@
717-<openerp>
718- <data>
719- <record id="view_account_configuration_installer" model="ir.ui.view">
720- <field name="name">account.installer.form</field>
721- <field name="model">account.installer</field>
722- <field name="type">form</field>
723- <field name="inherit_id" ref="base.res_config_installer"/>
724- <field name="arch" type="xml">
725- <data>
726- <form position="attributes">
727- <attribute name="string">Accounting Application Configuration</attribute>
728- </form>
729- <separator string="title" position="attributes">
730- <attribute name="string">Configure Your Accounting Chart</attribute>
731- </separator>
732- <xpath expr="//label[@string='description']" position="attributes">
733- <attribute name="string">The default Chart of Accounts is matching your country selection. If no certified Chart of Accounts exists for your specified country, a generic one can be installed and will be selected by default.</attribute>
734- </xpath>
735- <xpath expr="//button[@string='Install Modules']" position="attributes">
736- <attribute name="string">Configure</attribute>
737- </xpath>
738- <xpath expr='//separator[@string="vsep"]' position='attributes'>
739- <attribute name='rowspan'>23</attribute>
740- <attribute name='string'></attribute>
741- </xpath>
742- <group colspan="8">
743- <group colspan="4" width="600">
744- <field name="charts"/>
745- <group colspan="4" groups="base.group_extended">
746- <separator col="4" colspan="4" string="Configure Fiscal Year"/>
747- <field name="company_id" colspan="4" widget="selection"/><!-- we assume that this wizard will be run only by administrators and as this field may cause problem if hidden (because of the default company of the user removed from the selection because already configured), we simply choosed to remove the group "multi company" of it -->
748- <field name="date_start" on_change="on_change_start_date(date_start)"/>
749- <field name="date_stop"/>
750- <field name="period" colspan="4"/>
751- </group>
752- <group colspan="4" attrs="{'invisible':[('charts','!=','configurable')]}">
753- <field name="sale_tax" on_change="on_change_tax(sale_tax)" attrs="{'required':[('charts','=','configurable')]}"/>
754- <field name="purchase_tax" groups="base.group_extended"/>
755- </group>
756- <group colspan="4" attrs="{'invisible':[('charts','!=','configurable')]}">
757- <separator col="4" colspan="4" string="Bank and Cash Accounts"/>
758- <field colspan="4" mode="tree" height="200" name="bank_accounts_id" nolabel="1" widget="one2many_list">
759- <form string="">
760- <field name="acc_name"/>
761- <field name="account_type"/>
762- <field name="currency_id" widget="selection" groups="base.group_extended"/>
763- </form>
764- <tree editable="bottom" string="Your bank and cash accounts">
765- <field name="acc_name"/>
766- <field name="account_type"/>
767- <field name="currency_id" widget="selection" groups="base.group_extended"/>
768- </tree>
769- </field>
770- </group>
771- </group>
772- </group>
773- </data>
774- </field>
775- </record>
776-
777- <record id="view_account_modules_installer" model="ir.ui.view">
778- <field name="name">account.installer.modules.form</field>
779- <field name="model">account.installer.modules</field>
780- <field name="type">form</field>
781- <field name="inherit_id" ref="base.res_config_installer"/>
782- <field name="arch" type="xml">
783- <data>
784- <form position="attributes">
785- <attribute name="string">Accounting Application Configuration</attribute>
786- </form>
787- <separator string="title" position="attributes">
788- <attribute name="string">Configure Your Accounting Application</attribute>
789-
790- </separator>
791- <xpath expr="//label[@string='description']" position="attributes">
792- <attribute name="string">Add extra Accounting functionalities to the ones already installed.</attribute>
793- </xpath>
794- <xpath expr="//button[@string='Install Modules']" position="attributes">
795- <attribute name="string">Configure</attribute>
796- </xpath>
797- <xpath expr='//separator[@string="vsep"]' position='attributes'>
798- <attribute name='string'></attribute>
799- </xpath>
800- <group colspan="8">
801- <field name="account_voucher"/>
802- <field name="account_followup"/>
803- <field name="account_payment"/>
804- <field name="account_analytic_plans"/>
805- <field name="account_anglo_saxon"/>
806-<!-- <field name="account_voucher_payment"/>-->
807- </group>
808- </data>
809- </field>
810- </record>
811-
812- <record id="action_account_configuration_installer" model="ir.actions.act_window">
813- <field name="name">Accounting Chart Configuration</field>
814- <field name="type">ir.actions.act_window</field>
815- <field name="res_model">account.installer</field>
816- <field name="view_id" ref="view_account_configuration_installer"/>
817- <field name="view_type">form</field>
818- <field name="view_mode">form</field>
819- <field name="target">new</field>
820- </record>
821-
822- <record id="action_account_installer" model="ir.actions.act_window">
823- <field name="name">Accounting Application Configuration</field>
824- <field name="type">ir.actions.act_window</field>
825- <field name="res_model">account.installer.modules</field>
826- <field name="view_id" ref="view_account_modules_installer"/>
827- <field name="view_type">form</field>
828- <field name="view_mode">form</field>
829- <field name="target">new</field>
830- </record>
831-
832- <record id="account_configuration_installer_todo" model="ir.actions.todo">
833- <field name="action_id" ref="action_account_configuration_installer"/>
834- <field name="sequence">3</field>
835- <field name="restart">onskip</field>
836- </record>
837-
838- <record id="account_installer_todo" model="ir.actions.todo">
839- <field name="action_id" ref="action_account_installer"/>
840- <field name="sequence">5</field>
841- <field name="restart">always</field>
842- <field eval="[(6,0,[ref('base.group_extended')])]" name="groups_id"/>
843- </record>
844-
845- </data>
846-</openerp>
847
848=== modified file 'bin/addons/account/account_invoice_view.xml'
849--- bin/addons/account/account_invoice_view.xml 2019-07-29 15:00:38 +0000
850+++ bin/addons/account/account_invoice_view.xml 2019-10-25 14:10:32 +0000
851@@ -223,8 +223,11 @@
852 domain="[('type', 'not in', ['view', 'consolidation']),
853 ('user_type_code', '=', 'tax')]"/>
854
855- <field name="base" on_change="base_change(base,parent.currency_id,parent.company_id,parent.date_invoice)" readonly="1"/>
856- <field name="amount" on_change="amount_change(amount,parent.currency_id,parent.company_id,parent.date_invoice)"/>
857+ <field name="base"
858+ on_change="base_change(base, parent.currency_id, parent.company_id, parent.document_date, parent.date_invoice)"
859+ readonly="1"/>
860+ <field name="amount"
861+ on_change="amount_change(amount, parent.currency_id, parent.company_id, parent.document_date, parent.date_invoice)"/>
862
863 <field invisible="True" name="base_amount"/>
864 <field invisible="True" name="tax_amount"/>
865@@ -339,8 +342,11 @@
866 <tree editable="bottom" string="Taxes">
867 <field name="name"/>
868 <field name="account_id" groups="account.group_account_invoice"/>
869- <field name="base" on_change="base_change(base,parent.currency_id,parent.company_id,parent.date_invoice)" readonly="1"/>
870- <field name="amount" on_change="amount_change(amount,parent.currency_id,parent.company_id,parent.date_invoice)"/>
871+ <field name="base"
872+ on_change="base_change(base, parent.currency_id, parent.company_id, parent.document_date, parent.date_invoice)"
873+ readonly="1"/>
874+ <field name="amount"
875+ on_change="amount_change(amount, parent.currency_id, parent.company_id, parent.document_date, parent.date_invoice)"/>
876 <field invisible="True" name="base_amount"/>
877 <field invisible="True" name="tax_amount"/>
878 <field name="factor_base" invisible="True"/>
879
880=== modified file 'bin/addons/account/account_move_line.py'
881--- bin/addons/account/account_move_line.py 2019-09-17 16:00:23 +0000
882+++ bin/addons/account/account_move_line.py 2019-10-25 14:10:32 +0000
883@@ -21,7 +21,6 @@
884
885 import time
886 from datetime import datetime
887-from operator import itemgetter
888
889 from osv import fields, osv
890 from tools.translate import _
891@@ -29,6 +28,7 @@
892 import tools
893 import netsvc
894
895+
896 class account_move_line(osv.osv):
897 _name = "account.move.line"
898 _description = "Journal Items"
899@@ -149,57 +149,6 @@
900 query += company_clause
901 return query
902
903- def _amount_residual(self, cr, uid, ids, field_names, args, context=None):
904- """
905- This function returns the residual amount on a receivable or payable account.move.line.
906- By default, it returns an amount in the currency of this journal entry (maybe different
907- of the company currency), but if you pass 'residual_in_company_currency' = True in the
908- context then the returned amount will be in company currency.
909- """
910- res = {}
911- if context is None:
912- context = {}
913- cur_obj = self.pool.get('res.currency')
914- for move_line in self.browse(cr, uid, ids, context=context):
915- res[move_line.id] = {
916- 'amount_residual': 0.0,
917- 'amount_residual_currency': 0.0,
918- }
919-
920- if move_line.reconcile_id:
921- continue
922- if not move_line.account_id.type in ('payable', 'receivable'):
923- #this function does not suport to be used on move lines not related to payable or receivable accounts
924- continue
925-
926- if move_line.currency_id:
927- move_line_total = move_line.amount_currency
928- sign = move_line.amount_currency < 0 and -1 or 1
929- else:
930- move_line_total = move_line.debit - move_line.credit
931- sign = (move_line.debit - move_line.credit) < 0 and -1 or 1
932- line_total_in_company_currency = move_line.debit - move_line.credit
933- context_unreconciled = context.copy()
934- if move_line.reconcile_partial_id:
935- for payment_line in move_line.reconcile_partial_id.line_partial_ids:
936- if payment_line.id == move_line.id:
937- continue
938- if payment_line.currency_id and move_line.currency_id and payment_line.currency_id.id == move_line.currency_id.id:
939- move_line_total += payment_line.amount_currency
940- else:
941- if move_line.currency_id:
942- context_unreconciled.update({'date': payment_line.date})
943- amount_in_foreign_currency = cur_obj.compute(cr, uid, move_line.company_id.currency_id.id, move_line.currency_id.id, (payment_line.debit - payment_line.credit), round=False, context=context_unreconciled)
944- move_line_total += amount_in_foreign_currency
945- else:
946- move_line_total += (payment_line.debit - payment_line.credit)
947- line_total_in_company_currency += (payment_line.debit - payment_line.credit)
948-
949- result = move_line_total
950- res[move_line.id]['amount_residual_currency'] = sign * (move_line.currency_id and self.pool.get('res.currency').round(cr, uid, move_line.currency_id.rounding, result) or result)
951- res[move_line.id]['amount_residual'] = sign * line_total_in_company_currency
952- return res
953-
954 def default_get(self, cr, uid, fields, context=None):
955 data = self._default_get(cr, uid, fields, context=context)
956 for f in data.keys():
957@@ -387,18 +336,6 @@
958 data['debit'] = s > 0 and s or 0.0
959 data['credit'] = s < 0 and -s or 0.0
960
961- if account and account.currency_id:
962- data['currency_id'] = account.currency_id.id
963- acc = account
964- if s>0:
965- acc = acc1
966- compute_ctx = context.copy()
967- compute_ctx.update({
968- 'res.currency.compute.account': acc,
969- 'res.currency.compute.account_invert': True,
970- })
971- v = currency_obj.compute(cr, uid, account.company_id.currency_id.id, data['currency_id'], s, context=compute_ctx)
972- data['amount_currency'] = v
973 return data
974
975 def on_create_write(self, cr, uid, id, context=None):
976@@ -601,8 +538,6 @@
977 'reconcile_id': fields.many2one('account.move.reconcile', 'Reconcile', readonly=True, ondelete='set null', select=2),
978 'reconcile_partial_id': fields.many2one('account.move.reconcile', 'Partial Reconcile', readonly=True, ondelete='set null', select=2),
979 'amount_currency': fields.float('Amount Currency', help="The amount expressed in an optional other currency if it is a multi-currency entry.", digits_compute=dp.get_precision('Account')),
980- 'amount_residual_currency': fields.function(_amount_residual, method=True, string='Residual Amount', multi="residual", help="The residual amount on a receivable or payable of a journal entry expressed in its currency (maybe different of the company currency)."),
981- 'amount_residual': fields.function(_amount_residual, method=True, string='Residual Amount', multi="residual", help="The residual amount on a receivable or payable of a journal entry expressed in the company currency."),
982 'currency_id': fields.many2one('res.currency', 'Currency', help="The optional other currency if it is a multi-currency entry."),
983 'period_id': fields.many2one('account.period', 'Period', required=True, select=2),
984 'fiscalyear_id': fields.related('period_id', 'fiscalyear_id', type='many2one', relation='account.fiscalyear', string='Fiscal Year', store=False),
985@@ -737,31 +672,6 @@
986 (_check_company_id, 'Company must be same for its related account and period.',['company_id'] ),
987 ]
988
989- #TODO: ONCHANGE_ACCOUNT_ID: set account_tax_id
990- def onchange_currency(self, cr, uid, ids, account_id, amount, currency_id, date=False, journal=False, context=None):
991- if context is None:
992- context = {}
993- account_obj = self.pool.get('account.account')
994- journal_obj = self.pool.get('account.journal')
995- currency_obj = self.pool.get('res.currency')
996- if (not currency_id) or (not account_id):
997- return {}
998- result = {}
999- acc = account_obj.browse(cr, uid, account_id, context=context)
1000- if (amount>0) and journal:
1001- x = journal_obj.browse(cr, uid, journal).default_credit_account_id
1002- if x: acc = x
1003- context.update({
1004- 'date': date,
1005- 'res.currency.compute.account': acc,
1006- })
1007- v = currency_obj.compute(cr, uid, currency_id, acc.company_id.currency_id.id, amount, context=context)
1008- result['value'] = {
1009- 'debit': v > 0 and v or 0.0,
1010- 'credit': v < 0 and -v or 0.0
1011- }
1012- return result
1013-
1014 def onchange_partner_id(self, cr, uid, ids, move_id, partner_id, account_id=None, debit=0, credit=0, date=False, journal=False):
1015 partner_obj = self.pool.get('res.partner')
1016 payment_term_obj = self.pool.get('account.payment.term')
1017@@ -901,123 +811,6 @@
1018 'context':context,
1019 }
1020
1021- def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False):
1022- journal_pool = self.pool.get('account.journal')
1023- if context is None:
1024- context = {}
1025- result = super(account_move_line, self).fields_view_get(cr, uid, view_id, view_type, context=context, toolbar=toolbar, submenu=submenu)
1026- if view_type != 'tree':
1027- #Remove the toolbar from the form view
1028- if view_type == 'form':
1029- if result.get('toolbar', False):
1030- result['toolbar']['action'] = []
1031- #Restrict the list of journal view in search view
1032- if view_type == 'search' and result['fields'].get('journal_id', False):
1033- result['fields']['journal_id']['selection'] = journal_pool.name_search(cr, uid, '', [], context=context)
1034- ctx = context.copy()
1035- #we add the refunds journal in the selection field of journal
1036- if context.get('journal_type', False) == 'sale':
1037- ctx.update({'journal_type': 'sale_refund'})
1038- result['fields']['journal_id']['selection'] += journal_pool.name_search(cr, uid, '', [], context=ctx)
1039- elif context.get('journal_type', False) == 'purchase':
1040- ctx.update({'journal_type': 'purchase_refund'})
1041- result['fields']['journal_id']['selection'] += journal_pool.name_search(cr, uid, '', [], context=ctx)
1042- return result
1043- if context.get('view_mode', False):
1044- return result
1045- fld = []
1046- fields = {}
1047- flds = []
1048- title = _("Accounting Entries") #self.view_header_get(cr, uid, view_id, view_type, context)
1049- xml = '''<?xml version="1.0"?>\n<tree string="%s" editable="top" refresh="5" on_write="on_create_write" colors="red:state==\'draft\';black:state==\'valid\'">\n\t''' % (title)
1050-
1051- ids = journal_pool.search(cr, uid, [])
1052- journals = journal_pool.browse(cr, uid, ids, context=context)
1053- all_journal = [None]
1054- common_fields = {}
1055- total = len(journals)
1056- for journal in journals:
1057- all_journal.append(journal.id)
1058- for field in journal.view_id.columns_id:
1059- if not field.field in fields:
1060- fields[field.field] = [journal.id]
1061- fld.append((field.field, field.sequence, field.name))
1062- flds.append(field.field)
1063- common_fields[field.field] = 1
1064- else:
1065- fields.get(field.field).append(journal.id)
1066- common_fields[field.field] = common_fields[field.field] + 1
1067- fld.append(('period_id', 3, _('Period')))
1068- fld.append(('journal_id', 10, _('Journal')))
1069- flds.append('period_id')
1070- flds.append('journal_id')
1071- fields['period_id'] = all_journal
1072- fields['journal_id'] = all_journal
1073- fld = sorted(fld, key=itemgetter(1))
1074- widths = {
1075- 'statement_id': 50,
1076- 'state': 60,
1077- 'tax_code_id': 50,
1078- 'move_id': 40,
1079- }
1080- for field_it in fld:
1081- field = field_it[0]
1082- if common_fields.get(field) == total:
1083- fields.get(field).append(None)
1084-# if field=='state':
1085-# state = 'colors="red:state==\'draft\'"'
1086- attrs = []
1087- if field == 'debit':
1088- attrs.append('sum = "%s"' % _("Total debit"))
1089-
1090- elif field == 'credit':
1091- attrs.append('sum = "%s"' % _("Total credit"))
1092-
1093- elif field == 'move_id':
1094- attrs.append('required = "False"')
1095-
1096- elif field == 'account_tax_id':
1097- attrs.append('domain="[(\'parent_id\', \'=\' ,False)]"')
1098- attrs.append("context=\"{'journal_id': journal_id}\"")
1099-
1100- elif field == 'account_id' and journal.id:
1101- 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)"')
1102-
1103- elif field == 'partner_id':
1104- attrs.append('on_change="onchange_partner_id(move_id, partner_id, account_id, debit, credit, date, journal_id)"')
1105-
1106- elif field == 'journal_id':
1107- attrs.append("context=\"{'journal_id': journal_id}\"")
1108-
1109- elif field == 'statement_id':
1110- attrs.append("domain=\"[('state', '!=', 'confirm'),('journal_id.type', '=', 'bank')]\"")
1111-
1112- elif field == 'date':
1113- attrs.append('on_change="onchange_date(date)"')
1114-
1115- elif field == 'analytic_account_id':
1116- attrs.append('''groups="analytic.group_analytic_accounting"''') # Currently it is not working due to framework problem may be ..
1117-
1118- if field in ('amount_currency', 'currency_id'):
1119- attrs.append('on_change="onchange_currency(account_id, amount_currency, currency_id, date, journal_id)"')
1120- attrs.append('''attrs="{'readonly': [('state', '=', 'valid')]}"''')
1121-
1122- if field in widths:
1123- attrs.append('width="'+str(widths[field])+'"')
1124-
1125- if field in ('journal_id',):
1126- attrs.append("invisible=\"context.get('journal_id', False)\"")
1127- elif field in ('period_id',):
1128- attrs.append("invisible=\"context.get('period_id', False)\"")
1129- else:
1130- attrs.append("invisible=\"context.get('visible_id') not in %s\"" % (fields.get(field)))
1131- xml += '''<field name="%s" %s/>\n''' % (field,' '.join(attrs))
1132-
1133- xml += '''</tree>'''
1134- result['arch'] = xml
1135- result['fields'] = self.fields_get(cr, uid, flds, context)
1136- return result
1137-
1138 def _check_moves(self, cr, uid, context=None):
1139 # use the first move ever created for this journal and period
1140 if context is None:
1141@@ -1330,15 +1123,6 @@
1142 if a.id == vals['account_id']:
1143 ok = True
1144 break
1145- # Automatically convert in the account's secondary currency if there is one and
1146- # the provided values were not already multi-currency
1147- if account.currency_id and 'amount_currency' not in vals and account.currency_id.id != account.company_id.currency_id.id:
1148- vals['currency_id'] = account.currency_id.id
1149- ctx = {}
1150- if 'date' in vals:
1151- ctx['date'] = vals['date']
1152- vals['amount_currency'] = cur_obj.compute(cr, uid, account.company_id.currency_id.id,
1153- account.currency_id.id, vals.get('debit', 0.0)-vals.get('credit', 0.0), context=ctx)
1154 if not ok:
1155 raise osv.except_osv(_('Bad account !'), _('You can not use this general account in this journal !'))
1156
1157
1158=== modified file 'bin/addons/account/invoice.py'
1159--- bin/addons/account/invoice.py 2019-07-25 14:58:06 +0000
1160+++ bin/addons/account/invoice.py 2019-10-25 14:10:32 +0000
1161@@ -27,6 +27,7 @@
1162 from osv import fields, osv, orm
1163 from tools.translate import _
1164 from msf_partner import PARTNER_TYPE
1165+from base import currency_date
1166
1167
1168 class account_invoice(osv.osv):
1169@@ -1724,6 +1725,7 @@
1170 return res_final
1171
1172 company = self.pool.get('res.company').browse(cr, uid, company_id, context=context)
1173+ # DONE: TEST JN => no date in context
1174 currency = self.pool.get('res.currency').browse(cr, uid, currency_id, context=context)
1175
1176 if company.currency_id.id != currency.id:
1177@@ -1918,7 +1920,7 @@
1178 tax_amount = round(atx.amount * amount_untaxed, 2)
1179 return tax_amount
1180
1181- def base_change(self, cr, uid, ids, base, currency_id=False, company_id=False, date_invoice=False):
1182+ def base_change(self, cr, uid, ids, base, currency_id=False, company_id=False, document_date=False, date_invoice=False):
1183 cur_obj = self.pool.get('res.currency')
1184 company_obj = self.pool.get('res.company')
1185 company_currency = False
1186@@ -1928,10 +1930,13 @@
1187 if company_id:
1188 company_currency = company_obj.read(cr, uid, [company_id], ['currency_id'])[0]['currency_id'][0]
1189 if currency_id and company_currency:
1190- base = cur_obj.compute(cr, uid, currency_id, company_currency, base*factor, context={'date': date_invoice or time.strftime('%Y-%m-%d')}, round=False)
1191+ # DONE: TEST JN
1192+ curr_date = currency_date.get_date(self, cr, document_date, date_invoice)
1193+ base = cur_obj.compute(cr, uid, currency_id, company_currency, base*factor,
1194+ context={'currency_date': curr_date or time.strftime('%Y-%m-%d')}, round=False)
1195 return {'value': {'base_amount':base}}
1196
1197- def amount_change(self, cr, uid, ids, amount, currency_id=False, company_id=False, date_invoice=False):
1198+ def amount_change(self, cr, uid, ids, amount, currency_id=False, company_id=False, document_date=False, date_invoice=False):
1199 cur_obj = self.pool.get('res.currency')
1200 company_obj = self.pool.get('res.company')
1201 company_currency = False
1202@@ -1941,7 +1946,10 @@
1203 if company_id:
1204 company_currency = company_obj.read(cr, uid, [company_id], ['currency_id'])[0]['currency_id'][0]
1205 if currency_id and company_currency:
1206- amount = cur_obj.compute(cr, uid, currency_id, company_currency, amount*factor, context={'date': date_invoice or time.strftime('%Y-%m-%d')}, round=False)
1207+ # DONE: TEST JN
1208+ curr_date = currency_date.get_date(self, cr, document_date, date_invoice)
1209+ amount = cur_obj.compute(cr, uid, currency_id, company_currency, amount*factor,
1210+ context={'currency_date': curr_date or time.strftime('%Y-%m-%d')}, round=False)
1211 return {'value': {'tax_amount': amount}}
1212
1213 _order = 'sequence'
1214@@ -1952,6 +1960,8 @@
1215 'sequence': 0,
1216 }
1217 def compute(self, cr, uid, invoice_id, context=None):
1218+ if context is None:
1219+ context = {}
1220 tax_grouped = {}
1221 tax_obj = self.pool.get('account.tax')
1222 cur_obj = self.pool.get('res.currency')
1223@@ -1973,14 +1983,22 @@
1224 if inv.type in ('out_invoice','in_invoice'):
1225 val['base_code_id'] = tax['base_code_id']
1226 val['tax_code_id'] = tax['tax_code_id']
1227- 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)
1228- 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)
1229+ # DONE: TEST JN
1230+ curr_date = currency_date.get_date(self, cr, inv.document_date, inv.date_invoice)
1231+ val['base_amount'] = cur_obj.compute(cr, uid, inv.currency_id.id, company_currency, val['base'] * tax['base_sign'],
1232+ context={'currency_date': curr_date or time.strftime('%Y-%m-%d')}, round=False)
1233+ val['tax_amount'] = cur_obj.compute(cr, uid, inv.currency_id.id, company_currency, val['amount'] * tax['tax_sign'],
1234+ context={'currency_date': curr_date or time.strftime('%Y-%m-%d')}, round=False)
1235 val['account_id'] = tax['account_collected_id'] or line.account_id.id
1236 else:
1237 val['base_code_id'] = tax['ref_base_code_id']
1238 val['tax_code_id'] = tax['ref_tax_code_id']
1239- 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)
1240- 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)
1241+ # DONE: TEST JN
1242+ curr_date = currency_date.get_date(self, cr, inv.document_date, inv.date_invoice)
1243+ val['base_amount'] = cur_obj.compute(cr, uid, inv.currency_id.id, company_currency, val['base'] * tax['ref_base_sign'],
1244+ context={'currency_date': curr_date or time.strftime('%Y-%m-%d')}, round=False)
1245+ val['tax_amount'] = cur_obj.compute(cr, uid, inv.currency_id.id, company_currency, val['amount'] * tax['ref_tax_sign'],
1246+ context={'currency_date': curr_date or time.strftime('%Y-%m-%d')}, round=False)
1247 val['account_id'] = tax['account_paid_id'] or line.account_id.id
1248
1249 key = tax['id'] # taxes are grouped by id
1250
1251=== modified file 'bin/addons/account/project/project_view.xml'
1252--- bin/addons/account/project/project_view.xml 2018-06-25 13:34:58 +0000
1253+++ bin/addons/account/project/project_view.xml 2019-10-25 14:10:32 +0000
1254@@ -176,24 +176,14 @@
1255 </form>
1256 </field>
1257 </record>
1258+
1259+ <!-- see ./bin/addons/finance/account_analytic_line_view.xml -->
1260 <record id="view_account_analytic_line_tree" model="ir.ui.view">
1261 <field name="name">account.analytic.line.tree</field>
1262 <field name="model">account.analytic.line</field>
1263 <field name="type">tree</field>
1264 <field name="arch" type="xml">
1265- <tree editable="top" string="Analytic Entries">
1266- <field name="date"/>
1267- <field name="ref" invisible="context.get('to_invoice', False)"/>
1268- <field name="name"/>
1269- <field name="journal_id" invisible="context.get('to_invoice', False)"/>
1270- <field name="amount" sum="Total" invisible="context.get('to_invoice', False)"/>
1271- <field name="product_id" on_change="on_change_unit_amount(product_id, unit_amount, company_id, product_uom_id, journal_id)" invisible="not context.get('to_invoice', False)"/>
1272- <field name="unit_amount" on_change="on_change_unit_amount(product_id, unit_amount, company_id, product_uom_id)" sum="Total Quantity" invisible="not context.get('to_invoice', False)"/>
1273- <field name="product_uom_id" on_change="on_change_unit_amount(product_id, unit_amount, company_id, product_uom_id)" invisible="not context.get('to_invoice', False)"/>
1274- <field domain="[('type','=','normal')]" name="account_id"/>
1275- <field name="general_account_id" invisible="context.get('to_invoice', False)"/>
1276- <field name="user_id" invisible="1" />
1277- </tree>
1278+ <tree />
1279 </field>
1280 </record>
1281
1282@@ -294,36 +284,6 @@
1283 <field eval="True" name="object"/>
1284 </record>
1285
1286- <record id="account_analytic_line_extended_form" model="ir.ui.view">
1287- <field name="name">account.analytic.line.extended_form</field>
1288- <field name="model">account.analytic.line</field>
1289- <field name="type">form</field>
1290- <field name="priority" eval="18"/>
1291- <field name="arch" type="xml">
1292- <form string="Project line">
1293- <field name="name"/>
1294- <field name="account_id" groups="base.group_extended"/>
1295- <field name="date" on_change="on_change_unit_amount(product_id, unit_amount, company_id, product_uom_id)"/>
1296- <field name="journal_id"/>
1297- <field name="unit_amount" on_change="on_change_unit_amount(product_id, unit_amount, company_id, product_uom_id)"/>
1298- <field name="product_id" on_change="on_change_unit_amount(product_id, unit_amount, company_id, product_uom_id, journal_id)"/>
1299- <field name="product_uom_id" on_change="on_change_unit_amount(product_id, unit_amount, company_id, product_uom_id)"/>
1300- <field invisible="True" name="general_account_id"/>
1301- <field name="amount"/>
1302- <field name="currency_id" />
1303- <field name="amount_currency" />
1304- <field name="company_id" on_change="on_change_unit_amount(product_id, unit_amount, company_id, product_uom_id)"/>
1305- </form>
1306- </field>
1307- </record>
1308- <record id="action_account_analytic_account_line_extended_form" model="ir.actions.act_window">
1309- <field name="name">account.analytic.line.extended</field>
1310- <field name="type">ir.actions.act_window</field>
1311- <field name="res_model">account.analytic.line</field>
1312- <field name="view_type">form</field>
1313- <field name="view_id" ref="account_analytic_line_extended_form"/>
1314- </record>
1315-
1316 #
1317 # Analytic Journal
1318 #
1319
1320=== removed file 'bin/addons/account/res_currency.py'
1321--- bin/addons/account/res_currency.py 2017-09-29 15:41:58 +0000
1322+++ bin/addons/account/res_currency.py 1970-01-01 00:00:00 +0000
1323@@ -1,47 +0,0 @@
1324-# -*- coding: utf-8 -*-
1325-##############################################################################
1326-#
1327-# Copyright (C) 2010 OpenERP s.a. (<http://www.openerp.com>).
1328-#
1329-# This program is free software: you can redistribute it and/or modify
1330-# it under the terms of the GNU Affero General Public License as
1331-# published by the Free Software Foundation, either version 3 of the
1332-# License, or (at your option) any later version.
1333-#
1334-# This program is distributed in the hope that it will be useful,
1335-# but WITHOUT ANY WARRANTY; without even the implied warranty of
1336-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1337-# GNU Affero General Public License for more details.
1338-#
1339-# You should have received a copy of the GNU Affero General Public License
1340-# along with this program. If not, see <http://www.gnu.org/licenses/>.
1341-#
1342-##############################################################################
1343-
1344-from osv import osv
1345-
1346-"""Inherit res.currency to handle accounting date values when converting currencies"""
1347-
1348-class res_currency_account(osv.osv):
1349- _inherit = "res.currency"
1350-
1351- def _get_conversion_rate(self, cr, uid, from_currency, to_currency, context=None):
1352- if context is None:
1353- context = {}
1354- rate = super(res_currency_account, self)._get_conversion_rate(cr, uid, from_currency, to_currency, context=context)
1355- account = context.get('res.currency.compute.account')
1356- account_invert = context.get('res.currency.compute.account_invert')
1357- if account and account.currency_mode == 'average' and account.currency_id:
1358- query = self.pool.get('account.move.line')._query_get(cr, uid, context=context)
1359- cr.execute('''select sum(debit-credit),sum(amount_currency) from account_move_line l
1360- where l.currency_id=%%s and l.account_id=%%s and %s''' % query, (account.currency_id.id,account.id,)) # not_a_user_entry
1361- tot1,tot2 = cr.fetchone()
1362- if tot2 and not account_invert:
1363- rate = float(tot1)/float(tot2)
1364- elif tot1 and account_invert:
1365- rate = float(tot2)/float(tot1)
1366- return rate
1367-
1368-res_currency_account()
1369-
1370-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
1371
1372=== modified file 'bin/addons/account/wizard/account_change_currency.py'
1373--- bin/addons/account/wizard/account_change_currency.py 2011-04-08 11:23:24 +0000
1374+++ bin/addons/account/wizard/account_change_currency.py 2019-10-25 14:10:32 +0000
1375@@ -50,6 +50,7 @@
1376 invoice = obj_inv.browse(cr, uid, context['active_id'], context=context)
1377 if invoice.currency_id.id == new_currency:
1378 return {}
1379+ # DONE: TEST JN => cf. comm. Loic on US-5848 we keep using the date of the day here
1380 rate = obj_currency.browse(cr, uid, new_currency, context=context).rate
1381 for line in invoice.invoice_line:
1382 new_price = 0
1383
1384=== modified file 'bin/addons/account_corrections/account_move_line.py'
1385--- bin/addons/account_corrections/account_move_line.py 2019-01-28 13:35:47 +0000
1386+++ bin/addons/account_corrections/account_move_line.py 2019-10-25 14:10:32 +0000
1387@@ -26,6 +26,8 @@
1388 from tools.translate import _
1389 from time import strftime
1390 from tools.misc import flatten
1391+from base import currency_date
1392+
1393
1394 class account_move_line(osv.osv):
1395 _name = 'account.move.line'
1396@@ -543,13 +545,15 @@
1397 # update amount on new distribution
1398 ana_obj.update_distribution_line_amount(cr, uid, new_distrib_id, (-1 * (ml.debit - ml.credit)), context=context)
1399 new_line_id = self.copy(cr, uid, ml.id, {'move_id': new_move_id, 'date': date, 'document_date': ml.document_date, 'period_id': period_ids[0]}, context=context)
1400+ # DONE: TEST JN
1401+ curr_date = currency_date.get_date(self, cr, ml.document_date, ml.date, source_date=ml.source_date)
1402 vals.update({
1403 'name': name,
1404 'debit': ml.credit,
1405 'credit': ml.debit,
1406 'amount_currency': amt,
1407 'reversal_line_id': ml.id,
1408- 'source_date': ml.source_date or ml.date,
1409+ 'source_date': curr_date,
1410 'reversal': True,
1411 'reference': ml.move_id and ml.move_id.name or '',
1412 'ref': ml.move_id and ml.move_id.name or '',
1413@@ -746,6 +750,8 @@
1414 # Do the reverse
1415 name = self.join_without_redundancy(ml.name, 'REV')
1416 amt = -1 * ml.amount_currency
1417+ # DONE: TEST JN
1418+ curr_date = currency_date.get_date(self, cr, ml.document_date, ml.date, source_date=ml.source_date)
1419 vals.update({
1420 'debit': ml.credit,
1421 'credit': ml.debit,
1422@@ -754,7 +760,7 @@
1423 'name': name,
1424 'reversal_line_id': ml.id,
1425 'account_id': ml.account_id.id,
1426- 'source_date': ml.source_date or ml.date,
1427+ 'source_date': curr_date,
1428 'reversal': True,
1429 'document_date': ml.document_date,
1430 'reference': ml.move_id and ml.move_id.name or '',
1431@@ -768,7 +774,7 @@
1432 'journal_id': journal_id,
1433 'corrected_line_id': ml.id,
1434 'account_id': new_account_id,
1435- 'source_date': ml.source_date or ml.date,
1436+ 'source_date': curr_date,
1437 'have_an_historic': True,
1438 'document_date': ml.document_date,
1439 'reference': ml.move_id and ml.move_id.name or '',
1440
1441=== modified file 'bin/addons/account_corrections/wizard/analytic_distribution_wizard.py'
1442--- bin/addons/account_corrections/wizard/analytic_distribution_wizard.py 2019-10-15 16:08:57 +0000
1443+++ bin/addons/account_corrections/wizard/analytic_distribution_wizard.py 2019-10-25 14:10:32 +0000
1444@@ -26,6 +26,8 @@
1445 from tools.translate import _
1446 import time
1447 from collections import defaultdict
1448+from base import currency_date
1449+
1450
1451 class analytic_distribution_wizard(osv.osv_memory):
1452 _inherit = 'analytic.distribution.wizard'
1453@@ -150,9 +152,13 @@
1454 ana_line_obj = self.pool.get('account.analytic.line')
1455 company_currency_id = self.pool.get('res.users').browse(cr, uid, uid).company_id.currency_id.id
1456 ml = wizard.move_line_id
1457- orig_date = ml.source_date or ml.date
1458+ # US-5848: orig_date left unchanged not to break historical behavior,
1459+ # but the value set here seems overwritten later in the process if there is a source_date
1460+ orig_date = ml.source_date or ml.date # DONE: TEST JN
1461 orig_document_date = ml.document_date
1462 posting_date = wizard.date
1463+ # DONE: TEST JN
1464+ curr_date = currency_date.get_date(self, cr, ml.document_date, ml.date, source_date=ml.source_date)
1465 working_period_id = []
1466 new_line_ids = []
1467 entry_seq_data = {}
1468@@ -363,7 +369,10 @@
1469 if keep_seq_and_corrected[4]:
1470 name = ana_line_obj.join_without_redundancy(keep_seq_and_corrected[4], 'COR')
1471
1472- 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)
1473+ # DONE: TEST JN
1474+ created_analytic_line_ids = self.pool.get('funding.pool.distribution.line').\
1475+ create_analytic_lines(cr, uid, [new_distrib_line], ml.id, date=create_date, document_date=orig_document_date,
1476+ source_date=curr_date, name=name, context=context)
1477 new_line_ids.extend(created_analytic_line_ids.values())
1478 working_period_id = working_period_id or \
1479 self.pool.get('account.period').get_period_from_date(cr, uid, date=create_date, context=context)
1480@@ -425,8 +434,9 @@
1481 if cp.state != 'draft':
1482 raise osv.except_osv(_('Error'), _('Period (%s) is not open.') % (cp.name,))
1483 # Create the new ana line
1484+ # DONE: TEST JN
1485 ret = fp_distrib_obj.create_analytic_lines(cr, uid, line.distribution_line_id.id, ml.id, date=posting_date,
1486- document_date=orig_document_date, source_date=orig_date, name=name, context=context)
1487+ document_date=orig_document_date, source_date=curr_date, name=name, context=context)
1488 new_line_ids.extend(ret.values())
1489 working_period_id = working_period_id or period_ids
1490 # Add link to first analytic lines
1491@@ -443,7 +453,8 @@
1492 for line in to_override:
1493 # update the ana line
1494 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)])
1495- ctx = {'date': orig_date}
1496+ # DONE: TEST JN
1497+ ctx = {'currency_date': curr_date}
1498 amount_cur = (ml.credit_currency - ml.debit_currency) * line.percentage / 100
1499 amount = self.pool.get('res.currency').compute(cr, uid, ml.currency_id.id, company_currency_id, amount_cur, round=False, context=ctx)
1500
1501@@ -479,12 +490,13 @@
1502 has_generated_cor = True
1503 # compute the adjustment amount
1504 all_aji_ids = ana_line_obj.search(cr, uid, [
1505- ('move_id', '=', ml.id),
1506- ('is_reversal', '=', False),
1507- ('is_reallocated', '=', False),
1508- ], order='NO_ORDER', context=context)
1509+ ('move_id', '=', ml.id),
1510+ ('is_reversal', '=', False),
1511+ ('is_reallocated', '=', False),
1512+ ('account_id.category', '=', 'FUNDING'), # exclude free lines
1513+ ], order='NO_ORDER', context=context)
1514 max_line = {'amount': 0, 'aji_bro': False}
1515- aji_fields = ['amount_currency', 'period_id', 'currency_id', 'source_date', 'date']
1516+ aji_fields = ['amount_currency', 'period_id', 'currency_id', 'source_date', 'document_date', 'date']
1517 for aji in ana_line_obj.browse(cr, uid, all_aji_ids, fields_to_fetch=aji_fields, context=context):
1518 total_rounded_amount += round(abs(aji.amount_currency or 0.0), 2)
1519 if has_generated_cor and aji.id in new_line_ids and abs(aji.amount_currency or 0.0) > max_line['amount']:
1520@@ -511,10 +523,10 @@
1521 # then recompute functional amount
1522 if fix_aji_currency_id:
1523 new_context = context.copy()
1524- if max_line['aji_bro'].source_date:
1525- new_context['date'] = max_line['aji_bro'].source_date
1526- else:
1527- new_context['date'] = max_line['aji_bro'].date
1528+ # DONE: TEST JN
1529+ max_line_curr_date = currency_date.get_date(self, cr, max_line['aji_bro'].document_date, max_line['aji_bro'].date,
1530+ source_date=max_line['aji_bro'].source_date)
1531+ new_context['currency_date'] = max_line_curr_date
1532 aji_fix_vals['amount'] = \
1533 self.pool.get('res.currency').compute(cr, uid,
1534 fix_aji_currency_id, company_currency_id,
1535@@ -570,15 +582,17 @@
1536 for line in to_override:
1537 # update the ana line
1538 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)])
1539- ctx = {'date': orig_date}
1540+ # DONE: TEST JN
1541+ ctx = {'currency_date': curr_date}
1542 amount_cur = (ml.credit_currency - ml.debit_currency) * line.percentage / 100
1543 amount = self.pool.get('res.currency').compute(cr, uid, ml.currency_id.id, company_currency_id, amount_cur, round=False, context=ctx)
1544+ # the posting date is the one of the entry corrected
1545 ana_line_obj.write(cr, uid, to_override_ids, {
1546 'account_id': line.analytic_id.id,
1547 'amount_currency': amount_cur,
1548 'amount': amount,
1549- 'date': orig_date,
1550- 'source_date': orig_date,
1551+ 'date': ml.date, # DONE: TEST JN
1552+ 'source_date': curr_date, # DONE: TEST JN
1553 'document_date': orig_document_date,
1554 })
1555 # update the distib line
1556@@ -596,7 +610,10 @@
1557 'currency_id': ml and ml.currency_id and ml.currency_id.id or company_currency_id,
1558 })
1559 # create the ana line
1560- 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)
1561+ # DONE: TEST JN
1562+ # the posting date is the one of the entry corrected
1563+ self.pool.get(obj_name).create_analytic_lines(cr, uid, [new_distrib_line], ml.id, date=ml.date,
1564+ document_date=orig_document_date, source_date=curr_date, ref=ml.ref)
1565 # Set move line as corrected upstream if needed
1566 if to_reverse or to_override or to_create:
1567 self.pool.get('account.move.line').corrected_upstream_marker(cr, uid, [ml.id], context=context)
1568
1569=== modified file 'bin/addons/account_hq_entries/wizard/hq_entries_validation.py'
1570--- bin/addons/account_hq_entries/wizard/hq_entries_validation.py 2019-01-09 12:52:42 +0000
1571+++ bin/addons/account_hq_entries/wizard/hq_entries_validation.py 2019-10-25 14:10:32 +0000
1572@@ -25,6 +25,8 @@
1573 from osv import fields
1574 from tools.translate import _
1575 from time import strftime
1576+from base import currency_date
1577+
1578
1579 class hq_entries_validation(osv.osv_memory):
1580 _name = 'hq.entries.validation'
1581@@ -105,11 +107,13 @@
1582 (account.default_destination_id and account.default_destination_id.id) or False
1583 distrib_id = self.pool.get('analytic.distribution').create(cr, uid, {})
1584 if distrib_id:
1585+ # DONE: TEST JN
1586+ curr_date = currency_date.get_date(self, cr, line.document_date or line.date, line.date)
1587 common_vals = {'distribution_id':distrib_id,
1588 'currency_id':currency_id,
1589 'percentage':100.0,
1590 'date':line.date or current_date,
1591- 'source_date':line.date or current_date,
1592+ 'source_date': curr_date or current_date,
1593 'destination_id':destination_id}
1594 common_vals.update({'analytic_id':cc_id})
1595 self.pool.get('cost.center.distribution.line').create(cr, uid, common_vals)
1596@@ -126,7 +130,7 @@
1597 return distrib_id
1598
1599 def create_move(self, cr, uid, ids, period_id=False, currency_id=False,
1600- date=None, journal=None, orig_acct=None, doc_date=None, split=False, context=None):
1601+ date=None, journal=None, orig_acct=None, doc_date=None, source_date=None, split=False, context=None):
1602 """
1603 Create a move with given hq entries lines
1604 Return created lines (except counterpart lines)
1605@@ -188,7 +192,7 @@
1606 'journal_id': journal_id,
1607 'date': line.date,
1608 'date_maturity': line.date,
1609- 'document_date': line.document_date,
1610+ 'document_date': line.document_date or line.date,
1611 'move_id': move_id,
1612 'analytic_distribution_id': distrib_id,
1613 'name': line.name or '',
1614@@ -196,6 +200,9 @@
1615 'partner_txt': line.partner_txt or '',
1616 'reference': line.ref or ''
1617 }
1618+ # DONE: TEST JN
1619+ if source_date is not None:
1620+ vals.update({'source_date': source_date, })
1621 # Fetch debit/credit
1622 debit = 0.0
1623 credit = 0.0
1624@@ -294,8 +301,10 @@
1625 aml_obj.write(cr, uid, original_move.id, {'corrected': True, 'have_an_historic': True} , context=context)
1626 original_account_id = original_move.account_id.id
1627
1628+ # DONE: TEST JN
1629+ curr_date = currency_date.get_date(self, cr, line.document_date or line.date, line.date)
1630 new_res_move = self.create_move(cr, uid, [x.id for x in line.split_ids], line.period_id.id,
1631- line.currency_id.id, date=line.date, doc_date=line.document_date,
1632+ line.currency_id.id, date=line.date, doc_date=line.document_date, source_date=curr_date,
1633 journal=od_journal_id, orig_acct=original_account_id, split=True, context=context)
1634 # original move line
1635 original_ml_result = res_move[line.id]
1636@@ -329,7 +338,8 @@
1637 'reversal_line_id': original_move.id,
1638 'partner_txt': original_move.partner_txt or '',
1639 '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
1640- 'document_date': line.document_date, # US-1361
1641+ 'document_date': line.document_date or line.date,
1642+ 'source_date': curr_date, # DONE: TEST JN
1643 }, context=context, check=False, update_check=False)
1644
1645 # create the analytic lines as a reversed copy of the original
1646@@ -453,7 +463,9 @@
1647 split_change.append(line)
1648 continue
1649 if not line.user_validated:
1650- to_write.setdefault(line.currency_id.id, {}).setdefault(line.period_id.id, {}).setdefault(line.date, []).append(line.id)
1651+ document_date = line.document_date or line.date # posting date is used by default if there is no doc date on the line
1652+ to_write.setdefault(line.currency_id.id, {}).setdefault(line.period_id.id, {}).\
1653+ setdefault(line.date, {}).setdefault(document_date, []).append(line.id)
1654
1655 if line.account_id.id != line.account_id_first_value.id:
1656 if line.cost_center_id.id != line.cost_center_id_first_value.id or line.destination_id.id != line.destination_id_first_value.id:
1657@@ -483,20 +495,23 @@
1658 for currency in to_write:
1659 for period in to_write[currency]:
1660 for date in to_write[currency][period]:
1661- lines = to_write[currency][period][date]
1662- write = self.create_move(cr, uid, lines, period, currency, date)
1663- all_lines.update(write)
1664- if write:
1665- self.pool.get('hq.entries').write(cr, uid, write.keys(), {'user_validated': True}, context=context)
1666+ for doc_date in to_write[currency][period][date]:
1667+ lines = to_write[currency][period][date][doc_date]
1668+ write = self.create_move(cr, uid, lines, period_id=period, currency_id=currency, date=date, doc_date=doc_date)
1669+ all_lines.update(write)
1670+ if write:
1671+ self.pool.get('hq.entries').write(cr, uid, write.keys(), {'user_validated': True}, context=context)
1672
1673 for line in account_change:
1674+ # DONE: TEST JN
1675+ curr_date = currency_date.get_date(self, cr, line.document_date or line.date, line.date)
1676 corrected_distrib_id = self.pool.get('analytic.distribution').create(cr, uid, {
1677 'funding_pool_lines': [(0, 0, {
1678 'percentage': 100,
1679 'analytic_id': line.analytic_id.id,
1680 'cost_center_id': line.cost_center_id.id,
1681 'currency_id': line.currency_id.id,
1682- 'source_date': line.date,
1683+ 'source_date': curr_date,
1684 'destination_id': line.destination_id.id,
1685 })]
1686 })
1687@@ -506,10 +521,14 @@
1688 # actual distrib_id
1689 distrib_id = self.pool.get('account.move.line').read(cr, uid, all_lines[line.id], ['analytic_distribution_id'])['analytic_distribution_id'][0]
1690 # update the distribution
1691+ # DONE: TEST JN
1692+ curr_date = currency_date.get_date(self, cr, line.document_date or line.date, line.date)
1693 distrib_fp_lines = distrib_fp_line_obj.search(cr, uid, [('cost_center_id', '=', line.cost_center_id_first_value.id), ('distribution_id', '=', distrib_id)])
1694- 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})
1695+ distrib_fp_line_obj.write(cr, uid, distrib_fp_lines, {'cost_center_id': line.cost_center_id.id,
1696+ 'source_date': curr_date, 'destination_id': line.destination_id.id})
1697 distrib_cc_lines = distrib_cc_line_obj.search(cr, uid, [('analytic_id', '=', line.cost_center_id_first_value.id), ('distribution_id', '=', distrib_id)])
1698- 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})
1699+ distrib_cc_line_obj.write(cr, uid, distrib_cc_lines, {'analytic_id': line.cost_center_id.id,
1700+ 'source_date': curr_date, 'destination_id': line.destination_id.id})
1701
1702 # reverse ana lines
1703 fp_old_lines = ana_line_obj.search(cr, uid, [
1704@@ -529,8 +548,10 @@
1705 continue
1706
1707 # UTP-1118: posting date should be those from initial HQ entry line
1708- vals_cor = {'date':line.date, 'source_date':line.date, 'cost_center_id':line.cost_center_id.id,
1709- 'account_id':line.analytic_id.id, 'destination_id':line.destination_id.id, 'journal_id':acor_journal_id, 'last_correction_id':fp_old_lines[0]}
1710+ # DONE: TEST JN
1711+ vals_cor = {'date': line.date, 'source_date': curr_date, 'cost_center_id': line.cost_center_id.id,
1712+ 'account_id': line.analytic_id.id, 'destination_id': line.destination_id.id,
1713+ 'journal_id': acor_journal_id, 'last_correction_id':fp_old_lines[0]}
1714
1715 # US-1347: Use the entry sequence of HQ for reference, not the description
1716 entry_seq = ana_line_obj.read(cr, uid, res_reverse, ['ref'], context=context)
1717@@ -578,13 +599,15 @@
1718 pure_ad_cor_ji_ids.append(all_lines[line.id])
1719
1720 for line in cc_account_change:
1721+ # DONE: TEST JN
1722+ curr_date = currency_date.get_date(self, cr, line.document_date or line.date, line.date)
1723 # call correct_account with a new arg: new_distrib
1724 corrected_distrib_id = self.pool.get('analytic.distribution').create(cr, uid, {
1725 'cost_center_lines': [(0, 0, {
1726 'percentage': 100,
1727 'analytic_id': line.cost_center_id.id,
1728 'currency_id': line.currency_id.id,
1729- 'source_date': line.date,
1730+ 'source_date': curr_date,
1731 'destination_id': line.destination_id.id,
1732 })],
1733 'funding_pool_lines': [(0, 0, {
1734@@ -592,7 +615,7 @@
1735 'analytic_id': line.analytic_id.id,
1736 'cost_center_id': line.cost_center_id.id,
1737 'currency_id': line.currency_id.id,
1738- 'source_date': line.date,
1739+ 'source_date': curr_date,
1740 'destination_id': line.destination_id.id,
1741 })]
1742 })
1743
1744=== modified file 'bin/addons/account_mcdb/account_analytic_line.py'
1745--- bin/addons/account_mcdb/account_analytic_line.py 2017-04-19 09:37:05 +0000
1746+++ bin/addons/account_mcdb/account_analytic_line.py 2019-10-25 14:10:32 +0000
1747@@ -26,6 +26,8 @@
1748 from time import strftime
1749 from lxml import etree
1750 from tools.translate import _
1751+from base import currency_date
1752+
1753
1754 class account_analytic_line(osv.osv):
1755 _name = 'account.analytic.line'
1756@@ -35,6 +37,8 @@
1757 """
1758 Get an amount regarding currency in context (from 'output' and 'output_currency_id' values)
1759 """
1760+ if context is None:
1761+ context = {}
1762 # Prepare some value
1763 res = {}
1764 # Some verifications
1765@@ -48,27 +52,32 @@
1766 # Retrieve currency
1767 currency_id = context.get('output_currency_id')
1768 currency_obj = self.pool.get('res.currency')
1769+ # DONE: TEST JN => the context is not important here
1770 rate = currency_obj.read(cr, uid, currency_id, ['rate'], context=context).get('rate', False)
1771 # Do calculation
1772 if not rate:
1773 for out_id in ids:
1774 res[out_id] = {'output_currency': currency_id, 'output_amount': 0.0, 'output_amount_debit': 0.0, 'output_amount_credit': 0.0}
1775 return res
1776- for ml in self.browse(cr, uid, ids, context=context):
1777- res[ml.id] = {'output_currency': False, 'output_amount': 0.0, 'output_amount_debit': 0.0, 'output_amount_credit': 0.0}
1778+ aal_fields = ['document_date', 'date', 'source_date', 'currency_id', 'amount_currency']
1779+ for aal in self.browse(cr, uid, ids, fields_to_fetch=aal_fields, context=context):
1780+ res[aal.id] = {'output_currency': False, 'output_amount': 0.0, 'output_amount_debit': 0.0, 'output_amount_credit': 0.0}
1781 # output_amount field
1782 # Update with date
1783- context.update({'date': ml.source_date or ml.date or strftime('%Y-%m-%d')})
1784- mnt = self.pool.get('res.currency').compute(cr, uid, ml.currency_id.id, currency_id, ml.amount_currency, round=True, context=context)
1785- res[ml.id]['output_amount'] = mnt or 0.0
1786+ # DONE: TEST JN
1787+ curr_date = currency_date.get_date(self, cr, aal.document_date, aal.date, source_date=aal.source_date)
1788+ context.update({'currency_date': curr_date or strftime('%Y-%m-%d')})
1789+ mnt = self.pool.get('res.currency').compute(cr, uid, aal.currency_id.id, currency_id, aal.amount_currency,
1790+ round=True, context=context)
1791+ res[aal.id]['output_amount'] = mnt or 0.0
1792 if mnt < 0.0:
1793- res[ml.id]['output_amount_debit'] = 0.0
1794- res[ml.id]['output_amount_credit'] = abs(mnt) or 0.0
1795+ res[aal.id]['output_amount_debit'] = 0.0
1796+ res[aal.id]['output_amount_credit'] = abs(mnt) or 0.0
1797 else:
1798- res[ml.id]['output_amount_debit'] = abs(mnt) or 0.0
1799- res[ml.id]['output_amount_credit'] = 0.0
1800+ res[aal.id]['output_amount_debit'] = abs(mnt) or 0.0
1801+ res[aal.id]['output_amount_credit'] = 0.0
1802 # or output_currency field
1803- res[ml.id]['output_currency'] = currency_id
1804+ res[aal.id]['output_currency'] = currency_id
1805 return res
1806
1807 def _get_cheque_number(self, cr, uid, ids, name, args, context=None):
1808
1809=== modified file 'bin/addons/account_mcdb/account_bank_statement.py'
1810--- bin/addons/account_mcdb/account_bank_statement.py 2014-04-15 08:35:03 +0000
1811+++ bin/addons/account_mcdb/account_bank_statement.py 2019-10-25 14:10:32 +0000
1812@@ -25,6 +25,8 @@
1813 from osv import fields
1814 from time import strftime
1815 from lxml import etree
1816+from base import currency_date
1817+
1818
1819 class account_bank_statement_line(osv.osv):
1820 _name = 'account.bank.statement.line'
1821@@ -34,6 +36,8 @@
1822 """
1823 Get an amount regarding currency in context (from 'output' and 'output_currency_id' values)
1824 """
1825+ if context is None:
1826+ context = {}
1827 # Prepare some value
1828 res = {}
1829 # Some verifications
1830@@ -47,6 +51,7 @@
1831 # Retrieve currency
1832 currency_id = context.get('output_currency_id')
1833 currency_obj = self.pool.get('res.currency')
1834+ # DONE: TEST JN => the context is not important here
1835 rate = currency_obj.read(cr, uid, currency_id, ['rate'], context=context).get('rate', False)
1836 # Do calculation
1837 if not rate:
1838@@ -57,7 +62,9 @@
1839 res[absl.id] = {'output_currency': False, 'output_amount': 0.0, 'output_amount_debit': 0.0, 'output_amount_credit': 0.0}
1840 # output_amount field
1841 # Update with date
1842- context.update({'date': absl.date or strftime('%Y-%m-%d')})
1843+ # DONE: TEST JN
1844+ curr_date = currency_date.get_date(self, cr, absl.document_date, absl.date)
1845+ context.update({'currency_date': curr_date or strftime('%Y-%m-%d')})
1846 mnt = self.pool.get('res.currency').compute(cr, uid, absl.currency_id.id, currency_id, absl.amount, round=True, context=context)
1847 res[absl.id]['output_amount'] = mnt or 0.0
1848 if mnt < 0.0:
1849
1850=== modified file 'bin/addons/account_mcdb/account_move_line.py'
1851--- bin/addons/account_mcdb/account_move_line.py 2019-02-06 10:04:42 +0000
1852+++ bin/addons/account_mcdb/account_move_line.py 2019-10-25 14:10:32 +0000
1853@@ -25,6 +25,8 @@
1854 from osv import fields
1855 from time import strftime
1856 from lxml import etree
1857+from base import currency_date
1858+
1859
1860 class account_move_line(osv.osv):
1861 _name = 'account.move.line'
1862@@ -53,6 +55,7 @@
1863 return func_amount
1864 original_currency = ml.functional_currency_id.id
1865 # Perform the conversion from original currency to selected currency
1866+ # DONE: TEST JN => there is only a "currency_date" in context (no "date")
1867 return currency_obj.compute(cr, uid, original_currency, currency_id, func_amount, round=round, context=context)
1868
1869 def _get_output(self, cr, uid, ids, field_name, arg, context=None):
1870@@ -76,6 +79,7 @@
1871 company_currency_id = self.pool.get('res.users').browse(cr, uid, uid, context=context).company_id.currency_id.id
1872 currency_id = context.get('output_currency_id')
1873 currency_obj = self.pool.get('res.currency')
1874+ # DONE: TEST JN => the context is not important here
1875 rate = currency_obj.read(cr, uid, currency_id, ['rate'], context=context).get('rate', False)
1876 # Do calculation
1877 if not rate:
1878@@ -86,7 +90,9 @@
1879 res[ml.id] = {'output_currency': currency_id, 'output_amount': 0.0, 'output_amount_debit': 0.0, 'output_amount_credit': 0.0}
1880 # output_amount field
1881 # Update with date
1882- context.update({'date': ml.source_date or ml.date or strftime('%Y-%m-%d')})
1883+ # DONE: TEST JN
1884+ curr_date = currency_date.get_date(self, cr, ml.document_date, ml.date, source_date=ml.source_date)
1885+ context.update({'currency_date': curr_date or strftime('%Y-%m-%d')})
1886 # Now call the common method to calculate the output values
1887 if currency_id == company_currency_id:
1888 res[ml.id].update({'output_amount': ml.debit - ml.credit, 'output_amount_debit': ml.debit, 'output_amount_credit': ml.credit})
1889
1890=== modified file 'bin/addons/account_mcdb/report/account_mcdb_export.py'
1891--- bin/addons/account_mcdb/report/account_mcdb_export.py 2017-07-06 14:23:27 +0000
1892+++ bin/addons/account_mcdb/report/account_mcdb_export.py 2019-10-25 14:10:32 +0000
1893@@ -24,6 +24,9 @@
1894 from osv import osv
1895 from osv import fields
1896 from tools.translate import _
1897+from time import strftime
1898+from base import currency_date
1899+
1900
1901 def get_back_browse(self, cr, uid, context):
1902 background_id = context.get('background_id')
1903@@ -240,11 +243,9 @@
1904 csv_line.append(company_currency.encode('utf-8') or '')
1905 else:
1906 #output debit/credit
1907- context['date'] = al.source_date or al.date # uftp-361 [FIX] reversal line: source_date or posting_date
1908- if al.is_reversal == True:
1909- context.update({'date': al.document_date})
1910- if al.last_corrected_id:
1911- context.update({'date': al.document_date})
1912+ # DONE: TEST JN
1913+ curr_date = currency_date.get_date(self, cr, al.document_date, al.date, source_date=al.source_date)
1914+ context['currency_date'] = curr_date
1915 amount = currency_obj.compute(cr, uid, al.currency_id.id, currency_id, al.amount_currency, round=True, context=context)
1916 csv_line.append(amount or 0.0)
1917 #output currency
1918@@ -313,6 +314,9 @@
1919 csv_line.append(absl.functional_currency_id and absl.functional_currency_id.name and absl.functional_currency_id.name.encode('utf-8') or '')
1920 else:
1921 #output amount (debit/credit) regarding booking currency
1922+ # DONE: TEST JN
1923+ curr_date = currency_date.get_date(self, cr, absl.document_date, absl.date)
1924+ context.update({'currency_date': curr_date or strftime('%Y-%m-%d')})
1925 amount = currency_obj.compute(cr, uid, absl.currency_id.id, currency_id, absl.amount, round=True, context=context)
1926 if amount < 0.0:
1927 csv_line.append(0.0)
1928
1929=== modified file 'bin/addons/account_override/account.py'
1930--- bin/addons/account_override/account.py 2019-09-27 08:59:21 +0000
1931+++ bin/addons/account_override/account.py 2019-10-25 14:10:32 +0000
1932@@ -90,6 +90,7 @@
1933 (__compute will handle their escaping) as a
1934 tuple
1935 """
1936+ # DONE: TEST JN => there is no "date" in context
1937 mapping = {
1938 'balance': "COALESCE(SUM(l.debit),0) " \
1939 "- COALESCE(SUM(l.credit), 0) as balance",
1940@@ -997,6 +998,7 @@
1941 if 'document_date' in vals:
1942 context['document_date'] = vals.get('document_date')
1943 if 'date' in vals:
1944+ # DONE: TEST JN => this date isn't used for amount computation
1945 context['date'] = vals.get('date')
1946 # UTFTP-262: Make manual_name mandatory
1947 if 'manual_name' not in vals or not vals.get('manual_name', False) or vals.get('manual_name') == '':
1948
1949=== modified file 'bin/addons/account_override/account_move_line.py'
1950--- bin/addons/account_override/account_move_line.py 2018-11-12 17:20:58 +0000
1951+++ bin/addons/account_override/account_move_line.py 2019-10-25 14:10:32 +0000
1952@@ -546,6 +546,7 @@
1953 context.update({'document_date': m.document_date})
1954 if m and m.date:
1955 vals.update({'date': m.date})
1956+ # DONE: TEST JN => this date isn't used for amount computation
1957 context.update({'date': m.date})
1958 # UFTP-262: Add description from the move_id (US-2027) if there is not descr. on the line
1959 if m and m.manual_name and not vals.get('name'):
1960@@ -600,6 +601,7 @@
1961 context.update({'document_date': m.document_date})
1962 if m and m.date:
1963 vals.update({'date': m.date})
1964+ # DONE: TEST JN => not sure whether it's still possible to have a move_id in vals at this step but in any cases the date in context here has no effect on amount computation
1965 context.update({'date': m.date})
1966 # Note that _check_document_date HAVE TO be BEFORE the super write. If not, some problems appears in ournal entries document/posting date changes at the same time!
1967 self._check_document_date(cr, uid, ids, vals, context=context)
1968
1969=== modified file 'bin/addons/account_override/invoice.py'
1970--- bin/addons/account_override/invoice.py 2019-07-25 15:47:28 +0000
1971+++ bin/addons/account_override/invoice.py 2019-10-25 14:10:32 +0000
1972@@ -973,6 +973,8 @@
1973 Reverse move if this object is a In-kind Donation. Otherwise do normal job: cancellation.
1974 Don't delete an invoice that is linked to a PO. This is only for supplier invoices.
1975 """
1976+ # Oct. 2019: log if this method is used at least once (cf it may be dead code?)
1977+ self.pool.get('ir.config_parameter').set_param(cr, 1, 'action_cancel.in_use', True)
1978 to_cancel = []
1979 for i in self.browse(cr, uid, ids):
1980 if i.is_inkind_donation:
1981@@ -1934,6 +1936,7 @@
1982 std_price = p_info['standard_price']
1983 company_curr_id = self.pool.get('res.users').browse(cr, uid, uid).company_id.currency_id.id
1984 if company_curr_id and company_curr_id != currency_id:
1985+ # DONE: TEST JN => no date in context
1986 std_price = self.pool.get('res.currency').compute(cr, uid, company_curr_id, currency_id, std_price, context=context)
1987 res['value']['price_unit'] = std_price
1988 res['value']['price_subtotal'] = (qty or 0) * std_price
1989
1990=== modified file 'bin/addons/account_override/res_company.py'
1991--- bin/addons/account_override/res_company.py 2019-01-30 10:58:14 +0000
1992+++ bin/addons/account_override/res_company.py 2019-10-25 14:10:32 +0000
1993@@ -23,11 +23,32 @@
1994
1995 from osv import osv
1996 from osv import fields
1997+from base import currency_date
1998+from tools.translate import _
1999+
2000
2001 class res_company(osv.osv):
2002 _name = 'res.company'
2003 _inherit = 'res.company'
2004
2005+ def _get_currency_date_type(self, cr, uid, ids, name, args, context=None):
2006+ """
2007+ Returns the type of date used for functional amount computation in this instance
2008+ """
2009+ res = {}
2010+ for c_id in ids:
2011+ res[c_id] = currency_date.get_date_type(self, cr) == 'document' and _('Document Date') or _('Posting Date')
2012+ return res
2013+
2014+ def _get_currency_date_beginning(self, cr, uid, ids, name, args, context=None):
2015+ """
2016+ Returns the date from when the functional amount computation is based on the document date, if applicable
2017+ """
2018+ res = {}
2019+ for c_id in ids:
2020+ res[c_id] = currency_date.get_date_type(self, cr) == 'document' and currency_date.BEGINNING or False
2021+ return res
2022+
2023 _columns = {
2024 'import_invoice_default_account': fields.many2one('account.account', string="Re-billing Inter-section account",
2025 help="Default account for an import invoice on a Debit note"),
2026@@ -36,6 +57,10 @@
2027 'additional_allocation': fields.boolean('Additional allocation condition?', help="If you check this attribute, analytic allocation will be required for income accounts with an account code starting with \"7\"; if unchecked, the analytic allocation will be required for all income accounts."),
2028 'revaluation_default_account': fields.many2one('account.account', string="Revaluation account",
2029 help="Default account used for revaluation"),
2030+ 'currency_date_type': fields.function(_get_currency_date_type, method=True, type='char',
2031+ string='Date Type Used', store=False, readonly=1),
2032+ 'currency_date_beginning': fields.function(_get_currency_date_beginning, method=True, type='date',
2033+ string='Since', store=False, readonly=1),
2034 }
2035
2036
2037
2038=== modified file 'bin/addons/account_override/res_currency.py'
2039--- bin/addons/account_override/res_currency.py 2014-03-06 16:53:18 +0000
2040+++ bin/addons/account_override/res_currency.py 2019-10-25 14:10:32 +0000
2041@@ -33,62 +33,3 @@
2042
2043 res_currency_rate()
2044
2045-class res_currency(osv.osv):
2046- _name = 'res.currency'
2047- _inherit = 'res.currency'
2048-
2049- def _check_unicity_currency_name(self, cr, uid, ids, context=None):
2050- """
2051- Check that no currency have the same name and the same currency_table_id.
2052- Check is non case-sensitive.
2053- """
2054- if not context:
2055- context = {}
2056- for c in self.browse(cr, uid, ids):
2057- if not c.currency_name:
2058- continue
2059- sql = """SELECT id, name
2060- FROM res_currency
2061- WHERE currency_name ilike %s"""
2062- if c.currency_table_id:
2063- sql += """\nAND currency_table_id in %s"""
2064- cr.execute(sql, (c.currency_name, tuple([c.currency_table_id.id])))
2065- else:
2066- sql += """\nAND currency_table_id is Null"""
2067- cr.execute(sql, (c.currency_name,))
2068- bad_ids = cr.fetchall()
2069- if bad_ids and len(bad_ids) > 1:
2070- return False
2071- return True
2072-
2073- def _check_unicity_name(self, cr, uid, ids, context=None):
2074- """
2075- Check that no currency is the same and have the same currency_table_id.
2076- Check is non case-sensitive.
2077- """
2078- if not context:
2079- context = {}
2080- for c in self.browse(cr, uid, ids):
2081- if not c.name:
2082- continue
2083- sql = """SELECT id, name
2084- FROM res_currency
2085- WHERE name ilike %s"""
2086- if c.currency_table_id:
2087- sql += """\nAND currency_table_id in %s"""
2088- cr.execute(sql, (c.name, tuple([c.currency_table_id.id])))
2089- else:
2090- sql += """\nAND currency_table_id is Null"""
2091- cr.execute(sql, (c.name,))
2092- bad_ids = cr.fetchall()
2093- if bad_ids and len(bad_ids) > 1:
2094- return False
2095- return True
2096-
2097- _constraints = [
2098- (_check_unicity_currency_name, "Another currency have the same name.", ['currency_name']),
2099- (_check_unicity_name, "Same currency exists", ['name']),
2100- ]
2101-
2102-res_currency()
2103-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
2104
2105=== modified file 'bin/addons/account_payment/__init__.py'
2106--- bin/addons/account_payment/__init__.py 2011-01-14 00:11:01 +0000
2107+++ bin/addons/account_payment/__init__.py 2019-10-25 14:10:32 +0000
2108@@ -23,10 +23,6 @@
2109 # Init Sales
2110 #----------------------------------------------------------
2111
2112-import account_payment
2113-import wizard
2114+import account_invoice
2115 import account_move_line
2116-import account_invoice
2117-import report
2118-
2119-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
2120\ No newline at end of file
2121+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
2122
2123=== modified file 'bin/addons/account_payment/__openerp__.py'
2124--- bin/addons/account_payment/__openerp__.py 2017-09-28 14:05:02 +0000
2125+++ bin/addons/account_payment/__openerp__.py 2019-10-25 14:10:32 +0000
2126@@ -31,20 +31,11 @@
2127 * a basic mechanism to easily plug various automated payment.
2128 """,
2129 'author': 'OpenERP SA',
2130- 'depends': ['account_voucher'],
2131+ 'depends': ['account'],
2132 'update_xml': [
2133- 'security/account_payment_security.xml',
2134- 'security/ir.model.access.csv',
2135- 'wizard/account_payment_pay_view.xml',
2136- 'wizard/account_payment_populate_statement_view.xml',
2137- 'wizard/account_payment_create_order_view.xml',
2138- 'account_payment_view.xml',
2139- 'account_payment_workflow.xml',
2140- 'account_payment_sequence.xml',
2141 'account_invoice_view.xml',
2142- 'account_payment_report.xml',
2143 ],
2144- 'demo_xml': ['account_payment_demo.xml'],
2145+ 'demo_xml': [],
2146 'test': [
2147 ],
2148 'installable': True,
2149
2150=== modified file 'bin/addons/account_payment/account_move_line.py'
2151--- bin/addons/account_payment/account_move_line.py 2018-04-03 10:18:51 +0000
2152+++ bin/addons/account_payment/account_move_line.py 2019-10-25 14:10:32 +0000
2153@@ -19,9 +19,7 @@
2154 #
2155 ##############################################################################
2156
2157-from operator import itemgetter
2158 from osv import fields, osv
2159-from tools.translate import _
2160
2161 class account_move_line(osv.osv):
2162 _inherit = "account.move.line"
2163@@ -35,84 +33,16 @@
2164 CASE WHEN ml.amount_currency < 0
2165 THEN - ml.amount_currency
2166 ELSE ml.credit
2167- END -
2168- (SELECT coalesce(sum(amount_currency),0)
2169- FROM payment_line pl
2170- INNER JOIN payment_order po
2171- ON (pl.order_id = po.id)
2172- WHERE move_line_id = ml.id
2173- AND po.state != 'cancel') AS amount
2174+ END
2175 FROM account_move_line ml
2176 WHERE id IN %s""", (tuple(ids),))
2177 r = dict(cr.fetchall())
2178 return r
2179
2180- def _to_pay_search(self, cr, uid, obj, name, args, context=None):
2181- if not args:
2182- return []
2183- line_obj = self.pool.get('account.move.line')
2184- query = line_obj._query_get(cr, uid, context={})
2185- where = ' and '.join(map(lambda x: '''(SELECT
2186- CASE WHEN l.amount_currency < 0
2187- THEN - l.amount_currency
2188- ELSE l.credit
2189- END - coalesce(sum(pl.amount_currency), 0)
2190- FROM payment_line pl
2191- INNER JOIN payment_order po ON (pl.order_id = po.id)
2192- WHERE move_line_id = l.id
2193- AND po.state != 'cancel'
2194- ) %(operator)s %%s ''' % {'operator': x[1]}, args))
2195- sql_args = tuple(map(itemgetter(2), args))
2196-
2197- cr.execute(('''SELECT id
2198- FROM account_move_line l
2199- WHERE account_id IN (select id
2200- FROM account_account
2201- WHERE type=%s AND active)
2202- AND reconcile_id IS null
2203- AND credit > 0
2204- AND ''' + where + ' and ' + query), ('payable',)+sql_args ) # not_a_user_entry
2205-
2206- res = cr.fetchall()
2207- if not res:
2208- return [('id', '=', '0')]
2209- return [('id', 'in', map(lambda x:x[0], res))]
2210-
2211- def line2bank(self, cr, uid, ids, payment_type=None, context=None):
2212- """
2213- Try to return for each Ledger Posting line a corresponding bank
2214- account according to the payment type. This work using one of
2215- the bank of the partner defined on the invoice eventually
2216- associated to the line.
2217- Return the first suitable bank for the corresponding partner.
2218- """
2219- payment_mode_obj = self.pool.get('payment.mode')
2220- line2bank = {}
2221- if not ids:
2222- return {}
2223- bank_type = payment_mode_obj.suitable_bank_types(cr, uid, payment_type,
2224- context=context)
2225- for line in self.browse(cr, uid, ids, context=context):
2226- line2bank[line.id] = False
2227- if line.invoice and line.invoice.partner_bank_id:
2228- line2bank[line.id] = line.invoice.partner_bank_id.id
2229- elif line.partner_id:
2230- if not line.partner_id.bank_ids:
2231- line2bank[line.id] = False
2232- else:
2233- for bank in line.partner_id.bank_ids:
2234- if bank.state in bank_type:
2235- line2bank[line.id] = bank.id
2236- break
2237- if not line2bank[line.id] and line.partner_id.bank_ids:
2238- line2bank[line.id] = line.partner_id.bank_ids[0].id
2239- else:
2240- raise osv.except_osv(_('Error !'), _('No partner defined on entry line'))
2241- return line2bank
2242
2243 _columns = {
2244 'amount_to_pay': fields.function(amount_to_pay, method=True,
2245- type='float', string='Amount to pay', fnct_search=_to_pay_search),
2246+ type='float', string='Amount to pay'),
2247 }
2248
2249 account_move_line()
2250
2251=== removed file 'bin/addons/account_payment/account_payment.py'
2252--- bin/addons/account_payment/account_payment.py 2018-09-18 12:25:20 +0000
2253+++ bin/addons/account_payment/account_payment.py 1970-01-01 00:00:00 +0000
2254@@ -1,429 +0,0 @@
2255-# -*- coding: utf-8 -*-
2256-##############################################################################
2257-#
2258-# OpenERP, Open Source Management Solution
2259-# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
2260-#
2261-# This program is free software: you can redistribute it and/or modify
2262-# it under the terms of the GNU Affero General Public License as
2263-# published by the Free Software Foundation, either version 3 of the
2264-# License, or (at your option) any later version.
2265-#
2266-# This program is distributed in the hope that it will be useful,
2267-# but WITHOUT ANY WARRANTY; without even the implied warranty of
2268-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2269-# GNU Affero General Public License for more details.
2270-#
2271-# You should have received a copy of the GNU Affero General Public License
2272-# along with this program. If not, see <http://www.gnu.org/licenses/>.
2273-#
2274-##############################################################################
2275-
2276-import time
2277-
2278-from osv import osv, fields
2279-import netsvc
2280-
2281-class payment_mode(osv.osv):
2282- _name= 'payment.mode'
2283- _description= 'Payment Mode'
2284- _columns = {
2285- 'name': fields.char('Name', size=64, required=True, help='Mode of Payment'),
2286- 'bank_id': fields.many2one('res.partner.bank', "Bank account",
2287- required=True,help='Bank Account for the Payment Mode'),
2288- 'journal': fields.many2one('account.journal', 'Journal', required=True,
2289- domain=[('type', 'in', ('bank','cash'))], help='Bank or Cash Journal for the Payment Mode'),
2290- 'company_id': fields.many2one('res.company', 'Company', required=True),
2291- }
2292- _defaults = {
2293- 'company_id': lambda self,cr,uid,c: self.pool.get('res.users').browse(cr, uid, uid, c).company_id.id
2294- }
2295-
2296- def suitable_bank_types(self, cr, uid, payment_code=None, context=None):
2297- """Return the codes of the bank type that are suitable
2298- for the given payment type code"""
2299- if not payment_code:
2300- return []
2301- cr.execute(""" SELECT pb.state
2302- FROM res_partner_bank pb
2303- JOIN payment_mode pm ON (pm.bank_id = pb.id)
2304- WHERE pm.id = %s """, [payment_code])
2305- return [x[0] for x in cr.fetchall()]
2306-
2307-payment_mode()
2308-
2309-class payment_order(osv.osv):
2310- _name = 'payment.order'
2311- _description = 'Payment Order'
2312- _rec_name = 'reference'
2313-
2314- def get_wizard(self, type):
2315- logger = netsvc.Logger()
2316- logger.notifyChannel("warning", netsvc.LOG_WARNING,
2317- "No wizard found for the payment type '%s'." % type)
2318- return None
2319-
2320- def _total(self, cursor, user, ids, name, args, context=None):
2321- if not ids:
2322- return {}
2323- res = {}
2324- for order in self.browse(cursor, user, ids, context=context):
2325- if order.line_ids:
2326- res[order.id] = reduce(lambda x, y: x + y.amount, order.line_ids, 0.0)
2327- else:
2328- res[order.id] = 0.0
2329- return res
2330-
2331- _columns = {
2332- 'date_scheduled': fields.date('Scheduled date if fixed', states={'done':[('readonly', True)]}, help='Select a date if you have chosen Preferred Date to be fixed.'),
2333- 'reference': fields.char('Reference', size=128, required=1, states={'done': [('readonly', True)]}),
2334- 'mode': fields.many2one('payment.mode', 'Payment mode', select=True, required=1, states={'done': [('readonly', True)]}, help='Select the Payment Mode to be applied.'),
2335- 'state': fields.selection([
2336- ('draft', 'Draft'),
2337- ('open', 'Confirmed'),
2338- ('cancel', 'Cancelled'),
2339- ('done', 'Done')], 'State', select=True,
2340- help='When an order is placed the state is \'Draft\'.\n Once the bank is confirmed the state is set to \'Confirmed\'.\n Then the order is paid the state is \'Done\'.'),
2341- 'line_ids': fields.one2many('payment.line', 'order_id', 'Payment lines', states={'done': [('readonly', True)]}),
2342- 'total': fields.function(_total, string="Total", method=True, type='float'),
2343- 'user_id': fields.many2one('res.users', 'User', required=True, states={'done': [('readonly', True)]}),
2344- 'date_prefered': fields.selection([
2345- ('now', 'Directly'),
2346- ('due', 'Due date'),
2347- ('fixed', 'Fixed date')
2348- ], "Preferred date", change_default=True, required=True, states={'done': [('readonly', True)]}, help="Choose an option for the Payment Order:'Fixed' stands for a date specified by you.'Directly' stands for the direct execution.'Due date' stands for the scheduled date of execution."),
2349- 'date_created': fields.date('Creation date', readonly=True),
2350- 'date_done': fields.date('Execution date', readonly=True),
2351- }
2352-
2353- _defaults = {
2354- 'user_id': lambda self,cr,uid,context: uid,
2355- 'state': 'draft',
2356- 'date_prefered': 'due',
2357- 'date_created': lambda *a: time.strftime('%Y-%m-%d'),
2358- 'reference': lambda self,cr,uid,context: self.pool.get('ir.sequence').get(cr, uid, 'payment.order'),
2359- }
2360-
2361- def set_to_draft(self, cr, uid, ids, *args):
2362- self.write(cr, uid, ids, {'state': 'draft'})
2363- wf_service = netsvc.LocalService("workflow")
2364- for id in ids:
2365- wf_service.trg_create(uid, 'payment.order', id, cr)
2366- return True
2367-
2368- def action_open(self, cr, uid, ids, *args):
2369- ir_seq_obj = self.pool.get('ir.sequence')
2370-
2371- for order in self.read(cr, uid, ids, ['reference']):
2372- if not order['reference']:
2373- reference = ir_seq_obj.get(cr, uid, 'payment.order')
2374- self.write(cr, uid, order['id'], {'reference':reference})
2375- return True
2376-
2377- def set_done(self, cr, uid, ids, *args):
2378- wf_service = netsvc.LocalService("workflow")
2379- self.write(cr, uid, ids, {'date_done': time.strftime('%Y-%m-%d')})
2380- wf_service.trg_validate(uid, 'payment.order', ids[0], 'done', cr)
2381- return True
2382-
2383- def copy(self, cr, uid, id, default={}, context=None):
2384- default.update({
2385- 'state': 'draft',
2386- 'line_ids': [],
2387- 'reference': self.pool.get('ir.sequence').get(cr, uid, 'payment.order')
2388- })
2389- return super(payment_order, self).copy(cr, uid, id, default, context=context)
2390-
2391- def write(self, cr, uid, ids, vals, context=None):
2392- if not ids:
2393- return True
2394- if context is None:
2395- context = {}
2396- payment_line_obj = self.pool.get('payment.line')
2397- payment_line_ids = []
2398-
2399- if (vals.get('date_prefered', False) == 'fixed' and not vals.get('date_scheduled', False)) or vals.get('date_scheduled', False):
2400- for order in self.browse(cr, uid, ids, context=context):
2401- for line in order.line_ids:
2402- payment_line_ids.append(line.id)
2403- payment_line_obj.write(cr, uid, payment_line_ids, {'date': vals.get('date_scheduled', False)}, context=context)
2404- elif vals.get('date_prefered', False) == 'due':
2405- vals.update({'date_scheduled': False})
2406- for order in self.browse(cr, uid, ids, context=context):
2407- for line in order.line_ids:
2408- payment_line_obj.write(cr, uid, [line.id], {'date': line.ml_maturity_date}, context=context)
2409- elif vals.get('date_prefered', False) == 'now':
2410- vals.update({'date_scheduled': False})
2411- for order in self.browse(cr, uid, ids, context=context):
2412- for line in order.line_ids:
2413- payment_line_ids.append(line.id)
2414- payment_line_obj.write(cr, uid, payment_line_ids, {'date': False}, context=context)
2415- return super(payment_order, self).write(cr, uid, ids, vals, context=context)
2416-
2417-payment_order()
2418-
2419-class payment_line(osv.osv):
2420- _name = 'payment.line'
2421- _description = 'Payment Line'
2422-
2423- def translate(self, orig):
2424- return {
2425- "due_date": "date_maturity",
2426- "reference": "ref"}.get(orig, orig)
2427-
2428- def info_owner(self, cr, uid, ids, name=None, args=None, context=None):
2429- if not ids: return {}
2430- partner_zip_obj = self.pool.get('res.partner.zip')
2431-
2432- result = {}
2433- info=''
2434- for line in self.browse(cr, uid, ids, context=context):
2435- owner = line.order_id.mode.bank_id.partner_id
2436- result[line.id] = False
2437- if owner.address:
2438- for ads in owner.address:
2439- if ads.type == 'default':
2440- st = ads.street and ads.street or ''
2441- st1 = ads.street2 and ads.street2 or ''
2442- if 'zip_id' in ads:
2443- zip_city = ads.zip_id and partner_zip_obj.name_get(cr, uid, [ads.zip_id.id])[0][1] or ''
2444- else:
2445- zip = ads.zip and ads.zip or ''
2446- city = ads.city and ads.city or ''
2447- zip_city = zip + ' ' + city
2448- cntry = ads.country_id and ads.country_id.name or ''
2449- info = owner.name + "\n" + st + " " + st1 + "\n" + zip_city + "\n" +cntry
2450- result[line.id] = info
2451- break
2452- return result
2453-
2454- def info_partner(self, cr, uid, ids, name=None, args=None, context=None):
2455- if not ids: return {}
2456- partner_zip_obj = self.pool.get('res.partner.zip')
2457- result = {}
2458- info = ''
2459-
2460- for line in self.browse(cr, uid, ids, context=context):
2461- result[line.id] = False
2462- if not line.partner_id:
2463- break
2464- partner = line.partner_id.name or ''
2465- if line.partner_id.address:
2466- for ads in line.partner_id.address:
2467- if ads.type == 'default':
2468- st = ads.street and ads.street or ''
2469- st1 = ads.street2 and ads.street2 or ''
2470- if 'zip_id' in ads:
2471- zip_city = ads.zip_id and partner_zip_obj.name_get(cr, uid, [ads.zip_id.id])[0][1] or ''
2472- else:
2473- zip = ads.zip and ads.zip or ''
2474- city = ads.city and ads.city or ''
2475- zip_city = zip + ' ' + city
2476- cntry = ads.country_id and ads.country_id.name or ''
2477- info = partner + "\n" + st + " " + st1 + "\n" + zip_city + "\n" +cntry
2478- result[line.id] = info
2479- break
2480- return result
2481-
2482- def _amount(self, cursor, user, ids, name, args, context=None):
2483- if not ids:
2484- return {}
2485- currency_obj = self.pool.get('res.currency')
2486- if context is None:
2487- context = {}
2488- res = {}
2489-
2490- for line in self.browse(cursor, user, ids, context=context):
2491- ctx = context.copy()
2492- ctx['date'] = line.order_id.date_done or time.strftime('%Y-%m-%d')
2493- res[line.id] = currency_obj.compute(cursor, user, line.currency.id,
2494- line.company_currency.id,
2495- line.amount_currency, context=ctx)
2496- return res
2497-
2498- def _get_currency(self, cr, uid, context=None):
2499- user_obj = self.pool.get('res.users')
2500- currency_obj = self.pool.get('res.currency')
2501- user = user_obj.browse(cr, uid, uid, context=context)
2502-
2503- if user.company_id:
2504- return user.company_id.currency_id.id
2505- else:
2506- return currency_obj.search(cr, uid, [('rate', '=', 1.0)])[0]
2507-
2508- def _get_date(self, cr, uid, context=None):
2509- if context is None:
2510- context = {}
2511- payment_order_obj = self.pool.get('payment.order')
2512- date = False
2513-
2514- if context.get('order_id') and context['order_id']:
2515- order = payment_order_obj.browse(cr, uid, context['order_id'], context=context)
2516- if order.date_prefered == 'fixed':
2517- date = order.date_scheduled
2518- else:
2519- date = time.strftime('%Y-%m-%d')
2520- return date
2521-
2522- def _get_ml_inv_ref(self, cr, uid, ids, *a):
2523- res = {}
2524- for id in self.browse(cr, uid, ids):
2525- res[id.id] = False
2526- if id.move_line_id:
2527- if id.move_line_id.invoice:
2528- res[id.id] = id.move_line_id.invoice.id
2529- return res
2530-
2531- def _get_ml_maturity_date(self, cr, uid, ids, *a):
2532- res = {}
2533- for id in self.browse(cr, uid, ids):
2534- if id.move_line_id:
2535- res[id.id] = id.move_line_id.date_maturity
2536- else:
2537- res[id.id] = False
2538- return res
2539-
2540- def _get_ml_created_date(self, cr, uid, ids, *a):
2541- res = {}
2542- for id in self.browse(cr, uid, ids):
2543- if id.move_line_id:
2544- res[id.id] = id.move_line_id.date_created
2545- else:
2546- res[id.id] = False
2547- return res
2548-
2549- _columns = {
2550- 'name': fields.char('Your Reference', size=64, required=True),
2551- 'communication': fields.char('Communication', size=64, required=True, help="Used as the message between ordering customer and current company. Depicts 'What do you want to say to the recipient about this order ?'"),
2552- 'communication2': fields.char('Communication 2', size=64, help='The successor message of Communication.'),
2553- 'move_line_id': fields.many2one('account.move.line', 'Entry line', domain=[('reconcile_id', '=', False), ('account_id.type', '=', 'payable')], help='This Entry Line will be referred for the information of the ordering customer.'),
2554- 'amount_currency': fields.float('Amount in Partner Currency', digits=(16, 2),
2555- required=True, help='Payment amount in the partner currency'),
2556- 'currency': fields.many2one('res.currency','Partner Currency', required=True),
2557- 'company_currency': fields.many2one('res.currency', 'Company Currency', readonly=True),
2558- 'bank_id': fields.many2one('res.partner.bank', 'Destination Bank account'),
2559- 'order_id': fields.many2one('payment.order', 'Order', required=True,
2560- ondelete='cascade', select=True),
2561- 'partner_id': fields.many2one('res.partner', string="Partner", required=True, help='The Ordering Customer'),
2562- 'amount': fields.function(_amount, string='Amount in Company Currency',
2563- method=True, type='float',
2564- help='Payment amount in the company currency'),
2565- 'ml_date_created': fields.function(_get_ml_created_date, string="Effective Date",
2566- method=True, type='date', help="Invoice Effective Date"),
2567- 'ml_maturity_date': fields.function(_get_ml_maturity_date, method=True, type='date', string='Due Date'),
2568- 'ml_inv_ref': fields.function(_get_ml_inv_ref, method=True, type='many2one', relation='account.invoice', string='Invoice Ref.'),
2569- 'info_owner': fields.function(info_owner, string="Owner Account", method=True, type="text", help='Address of the Main Partner'),
2570- 'info_partner': fields.function(info_partner, string="Destination Account", method=True, type="text", help='Address of the Ordering Customer.'),
2571- 'date': fields.date('Payment Date', help="If no payment date is specified, the bank will treat this payment line directly"),
2572- 'create_date': fields.datetime('Created', readonly=True),
2573- 'state': fields.selection([('normal','Free'), ('structured','Structured')], 'Communication Type', required=True),
2574- 'bank_statement_line_id': fields.many2one('account.bank.statement.line', 'Bank statement line')
2575- }
2576- _defaults = {
2577- 'name': lambda obj, cursor, user, context: obj.pool.get('ir.sequence'
2578- ).get(cursor, user, 'payment.line'),
2579- 'state': 'normal',
2580- 'currency': _get_currency,
2581- 'company_currency': _get_currency,
2582- 'date': _get_date,
2583- }
2584- _sql_constraints = [
2585- ('name_uniq', 'UNIQUE(name)', 'The payment line name must be unique!'),
2586- ]
2587-
2588- def onchange_move_line(self, cr, uid, ids, move_line_id, payment_type, date_prefered, date_scheduled, currency=False, company_currency=False, context=None):
2589- data = {}
2590- move_line_obj = self.pool.get('account.move.line')
2591-
2592- data['amount_currency'] = data['communication'] = data['partner_id'] = data['reference'] = data['date_created'] = data['bank_id'] = data['amount'] = False
2593-
2594- if move_line_id:
2595- line = move_line_obj.browse(cr, uid, move_line_id, context=context)
2596- data['amount_currency'] = line.amount_to_pay
2597-
2598- res = self.onchange_amount(cr, uid, ids, data['amount_currency'], currency,
2599- company_currency, context)
2600- if res:
2601- data['amount'] = res['value']['amount']
2602- data['partner_id'] = line.partner_id.id
2603- temp = line.currency_id and line.currency_id.id or False
2604- if not temp:
2605- if line.invoice:
2606- data['currency'] = line.invoice.currency_id.id
2607- else:
2608- data['currency'] = temp
2609-
2610- # calling onchange of partner and updating data dictionary
2611- temp_dict = self.onchange_partner(cr, uid, ids, line.partner_id.id, payment_type)
2612- data.update(temp_dict['value'])
2613-
2614- data['reference'] = line.ref
2615- data['date_created'] = line.date_created
2616- data['communication'] = line.ref
2617-
2618- if date_prefered == 'now':
2619- #no payment date => immediate payment
2620- data['date'] = False
2621- elif date_prefered == 'due':
2622- data['date'] = line.date_maturity
2623- elif date_prefered == 'fixed':
2624- data['date'] = date_scheduled
2625- return {'value': data}
2626-
2627- def onchange_amount(self, cr, uid, ids, amount, currency, cmpny_currency, context=None):
2628- if (not amount) or (not cmpny_currency):
2629- return {'value': {'amount': False}}
2630- res = {}
2631- currency_obj = self.pool.get('res.currency')
2632- company_amount = currency_obj.compute(cr, uid, currency, cmpny_currency, amount)
2633- res['amount'] = company_amount
2634- return {'value': res}
2635-
2636- def onchange_partner(self, cr, uid, ids, partner_id, payment_type, context=None):
2637- data = {}
2638- partner_zip_obj = self.pool.get('res.partner.zip')
2639- partner_obj = self.pool.get('res.partner')
2640- payment_mode_obj = self.pool.get('payment.mode')
2641- data['info_partner'] = data['bank_id'] = False
2642-
2643- if partner_id:
2644- part_obj = partner_obj.browse(cr, uid, partner_id, context=context)
2645- partner = part_obj.name or ''
2646-
2647- if part_obj.address:
2648- for ads in part_obj.address:
2649- if ads.type == 'default':
2650- st = ads.street and ads.street or ''
2651- st1 = ads.street2 and ads.street2 or ''
2652-
2653- if 'zip_id' in ads:
2654- zip_city = ads.zip_id and partner_zip_obj.name_get(cr, uid, [ads.zip_id.id])[0][1] or ''
2655- else:
2656- zip = ads.zip and ads.zip or ''
2657- city = ads.city and ads.city or ''
2658- zip_city = zip + ' ' + city
2659-
2660- cntry = ads.country_id and ads.country_id.name or ''
2661- info = partner + "\n" + st + " " + st1 + "\n" + zip_city + "\n" +cntry
2662-
2663- data['info_partner'] = info
2664-
2665- if part_obj.bank_ids and payment_type:
2666- bank_type = payment_mode_obj.suitable_bank_types(cr, uid, payment_type, context=context)
2667- for bank in part_obj.bank_ids:
2668- if bank.state in bank_type:
2669- data['bank_id'] = bank.id
2670- break
2671- return {'value': data}
2672-
2673- def fields_get(self, cr, uid, fields=None, context=None, with_uom_rounding=False):
2674- res = super(payment_line, self).fields_get(cr, uid, fields, context)
2675- if 'communication2' in res:
2676- res['communication2'].setdefault('states', {})
2677- res['communication2']['states']['structured'] = [('readonly', True)]
2678- res['communication2']['states']['normal'] = [('readonly', False)]
2679- return res
2680-
2681-payment_line()
2682-
2683-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
2684
2685=== removed file 'bin/addons/account_payment/account_payment_demo.xml'
2686--- bin/addons/account_payment/account_payment_demo.xml 2011-01-14 00:11:01 +0000
2687+++ bin/addons/account_payment/account_payment_demo.xml 1970-01-01 00:00:00 +0000
2688@@ -1,25 +0,0 @@
2689-<?xml version="1.0" encoding="utf-8"?>
2690-<openerp>
2691- <data noupdate="1">
2692- <record id="partner_bank_1" model="res.partner.bank">
2693- <field name="name">Reserve Bank</field>
2694- <field name="acc_number">00987654321</field>
2695- <field name="partner_id" ref="base.res_partner_agrolait"></field>
2696- <field name="state">bank</field>
2697- <field name="bank" ref="base.res_bank_1"/>
2698- </record>
2699- <record id="payment_mode_1" model="payment.mode">
2700- <field name="name">Direct Payment</field>
2701- <field name="journal" ref="account.sales_journal"/>
2702- <field name="bank_id" ref="account_payment.partner_bank_1"/>
2703- <field name="company_id" ref="base.main_company"/>
2704- </record>
2705- <record id="payment_order_1" model="payment.order">
2706- <field name="reference">ORDER1</field>
2707- <field name="mode" ref="account_payment.payment_mode_1"/>
2708- <field name="user_id" ref="base.user_root"/>
2709- <field name="date_prefered">now</field>
2710- <field name="state">draft</field>
2711- </record>
2712- </data>
2713-</openerp>
2714
2715=== removed file 'bin/addons/account_payment/account_payment_report.xml'
2716--- bin/addons/account_payment/account_payment_report.xml 2011-01-14 00:11:01 +0000
2717+++ bin/addons/account_payment/account_payment_report.xml 1970-01-01 00:00:00 +0000
2718@@ -1,6 +0,0 @@
2719-<?xml version="1.0" encoding="utf-8"?>
2720-<openerp>
2721- <data>
2722- <report auto="True" id="payment_order1" model="payment.order" name="payment.order" rml="account_payment/report/order.rml" string="Payment Order"/>
2723- </data>
2724-</openerp>
2725
2726=== removed file 'bin/addons/account_payment/account_payment_sequence.xml'
2727--- bin/addons/account_payment/account_payment_sequence.xml 2011-01-14 00:11:01 +0000
2728+++ bin/addons/account_payment/account_payment_sequence.xml 1970-01-01 00:00:00 +0000
2729@@ -1,29 +0,0 @@
2730-<?xml version="1.0" encoding="utf-8"?>
2731-<openerp>
2732- <data noupdate="1">
2733- <record forcecreate="1" id="seq_type_payment_order" model="ir.sequence.type">
2734- <field name="name">Payment order</field>
2735- <field name="code">payment.order</field>
2736- </record>
2737-
2738- <record forcecreate="1" id="seq_payment_order" model="ir.sequence">
2739- <field name="name">Payment order</field>
2740- <field name="code">payment.order</field>
2741- <field eval="3" name="padding"/>
2742- <field name="prefix">%(year)s/</field>
2743- </record>
2744-
2745- <record forcecreate="1" id="seq_type_payment_line" model="ir.sequence.type">
2746- <field name="name">Payment Line</field>
2747- <field name="code">payment.line</field>
2748- </record>
2749-
2750- <record forcecreate="1" id="seq_payment_line" model="ir.sequence">
2751- <field name="name">Payment Line</field>
2752- <field name="code">payment.line</field>
2753- <field name="prefix"/>
2754- <field name="padding">3</field>
2755- </record>
2756-
2757- </data>
2758-</openerp>
2759
2760=== modified file 'bin/addons/account_payment/account_payment_view.xml'
2761--- bin/addons/account_payment/account_payment_view.xml 2017-10-04 05:23:42 +0000
2762+++ bin/addons/account_payment/account_payment_view.xml 2019-10-25 14:10:32 +0000
2763@@ -15,308 +15,5 @@
2764 </field>
2765 </record>
2766
2767- <record model="ir.ui.view" id="view_move_line_tree_wiz">
2768- <field name="name">account.move.line.tree</field>
2769- <field name="model">account.move.line</field>
2770- <field name="type">tree</field>
2771- <field name="priority" eval="10"/>
2772- <field name="arch" type="xml">
2773- <tree string="Account Entry Line">
2774- <field name="partner_id"/>
2775- <field name="ref"/>
2776- <field name="name"/>
2777- <field name="journal_id"/>
2778- <field name="account_id"/>
2779- <field name="date_maturity"/>
2780- <field name="date"/>
2781- <field name="debit" sum="Total debit"/>
2782- <field name="credit" sum="Total credit"/>
2783- <field name="amount_to_pay"/>
2784- <field name="amount_currency"/>
2785- <field name="currency_id"/>
2786- <field name="period_id" invisible="1"/>
2787- </tree>
2788- </field>
2789- </record>
2790-
2791- <menuitem id="menu_main_payment" name="Payment" parent="account.menu_finance" sequence="7"/>
2792-
2793- <record id="view_payment_mode_search" model="ir.ui.view">
2794- <field name="name">payment.mode.search</field>
2795- <field name="model">payment.mode</field>
2796- <field name="type">search</field>
2797- <field name="arch" type="xml">
2798- <form string="Payment Mode">
2799- <field name="name"/>
2800- <field name="journal" widget='selection'/>
2801- <field name="company_id" widget='selection' groups="base.group_multi_company"/>
2802- <newline/>
2803- <group expand="0" string="Group By...">
2804- <filter string="Journal" icon="terp-folder-orange" domain="[]" context="{'group_by':'journal'}"/>
2805- </group>
2806- </form>
2807- </field>
2808- </record>
2809-
2810- <record id="view_payment_mode_tree" model="ir.ui.view">
2811- <field name="name">payment.mode.tree</field>
2812- <field name="model">payment.mode</field>
2813- <field name="type">tree</field>
2814- <field name="arch" type="xml">
2815- <tree string="Payment Mode">
2816- <field name="name"/>
2817- <field name="journal"/>
2818- <field name="company_id" groups="base.group_multi_company"/>
2819- </tree>
2820- </field>
2821- </record>
2822-
2823- <record id="view_payment_mode_form" model="ir.ui.view">
2824- <field name="name">payment.mode.form</field>
2825- <field name="model">payment.mode</field>
2826- <field name="type">form</field>
2827- <field name="arch" type="xml">
2828- <form string="Payment Mode">
2829- <field name="name" select="1"/>
2830- <field name="journal" select="1"/>
2831- <field name="bank_id"/>
2832- <field name="company_id" select="1" widget='selection' groups="base.group_multi_company"/>
2833- </form>
2834- </field>
2835- </record>
2836- <record id="action_payment_mode_form" model="ir.actions.act_window">
2837- <field name="name">Payment Mode</field>
2838- <field name="res_model">payment.mode</field>
2839- <field name="view_type">form</field>
2840- <field name="view_mode">tree,form</field>
2841- <field name="search_view_id" ref="view_payment_mode_search"/>
2842- </record>
2843-
2844- <menuitem action="action_payment_mode_form" id="menu_action_payment_mode_form" parent="account.menu_configuration_misc"/>
2845-
2846- <record id="view_payment_order_form" model="ir.ui.view">
2847- <field name="name">payment.order.form</field>
2848- <field name="model">payment.order</field>
2849- <field name="type">form</field>
2850- <field name="arch" type="xml">
2851- <form string="Payment order">
2852- <group col="6" colspan="4">
2853- <field name="reference"/>
2854- <field name="mode" widget='selection'/>
2855- <field name="user_id"/>
2856- <field name="date_prefered"/>
2857- <field name="date_scheduled" select="1" attrs="{'readonly':[('date_prefered','!=','fixed')]}" />
2858- <button colspan="2" name="%(action_create_payment_order)d" string="Select Invoices to Pay" type="action" attrs="{'invisible':[('state','=','done')]}" icon="gtk-find"/>
2859- </group>
2860- <field name="line_ids" colspan="4" widget="one2many_list" nolabel="1" default_get="{'order_id': active_id or False}" >
2861- <form string="Payment Line">
2862- <notebook>
2863- <page string="Payment">
2864- <field name="move_line_id" on_change="onchange_move_line(move_line_id,parent.mode,parent.date_prefered,parent.date_scheduled,currency,company_currency)" select="1" domain="[('reconcile_id','=', False), ('credit', '>',0),('amount_to_pay','>',0)] "/>
2865- <separator colspan="4" string="Transaction Information"/>
2866- <field name="date"/>
2867- <group colspan="2">
2868- <field name="amount_currency" on_change="onchange_amount(amount_currency,currency,company_currency)"/>
2869- <field name="currency" nolabel="1"/>
2870- </group>
2871- <field name="partner_id" on_change="onchange_partner(partner_id,parent.mode)" select="1"/>
2872- <field domain="[('partner_id','=',partner_id)]" name="bank_id"/>
2873- <separator colspan="2" string="Owner Account"/>
2874- <separator colspan="2" string="Destination Account"/>
2875- <field colspan="2" name="info_owner" nolabel="1"/>
2876- <field colspan="2" name="info_partner" nolabel="1"/>
2877- <field colspan="4" name="communication"/>
2878- <field colspan="4" name="communication2"/>
2879- <field name="name"/>
2880- <field name="state"/>
2881- </page>
2882- <page string="Information">
2883-
2884- <separator colspan="4" string="General Information"/>
2885- <group colspan="2">
2886- <field name="amount"/>
2887- <field name="company_currency" nolabel="1"/>
2888- </group>
2889- <separator colspan="4" string="Entry Information"/>
2890- <field name="create_date" readonly="1"/>
2891- <field name="ml_maturity_date"/>
2892- <field name="ml_inv_ref"/>
2893- </page>
2894- </notebook>
2895- </form>
2896- <tree string="Payment Line">
2897- <field name="ml_inv_ref" />
2898- <field name="partner_id" select="1"/>
2899- <field name="bank_id" domain="[('partner_id', '=', partner_id)]"/>
2900- <field name="ml_maturity_date"/>
2901- <field name="date"/>
2902- <field name="amount_currency" string="Amount"/>
2903- <field name="currency"/>
2904- <field name="name"/>
2905- <field name="amount" sum="Total in Company Currency" invisible="1"/>
2906- </tree>
2907- </field>
2908- <field name="date_created"/>
2909- <field name="date_done"/>
2910- <field name="state" readonly="1" select="1"/>
2911- <group col="4" colspan="2">
2912- <button name="cancel" states="draft,open" string="Cancel" icon="gtk-cancel"/>
2913- <button name="open" states="draft" string="Confirm Payments" icon="gtk-apply"/>
2914- <button name="set_done" states="open" string="Make Payments" type="object" icon="gtk-execute"/>
2915- <button name="set_to_draft" states="cancel" string="Set to draft" type="object" icon="gtk-convert"/>
2916- </group>
2917- </form>
2918- </field>
2919- </record>
2920-
2921- <record id="view_payment_order_tree" model="ir.ui.view">
2922- <field name="name">payment.order.tree</field>
2923- <field name="model">payment.order</field>
2924- <field name="type">tree</field>
2925- <field eval="4" name="priority"/>
2926- <field name="arch" type="xml">
2927- <tree colors="blue:state in ('draft');gray:state in ('cancel','done');black:state in ('open')" string="Payment order">
2928- <field name="reference"/>
2929- <field name="mode"/>
2930- <field name="user_id"/>
2931- <field name="date_created"/>
2932- <field name="date_done"/>
2933- <field name="total"/>
2934- <field name="state"/>
2935- <button name="cancel" states="draft,open" string="Cancel" icon="gtk-cancel"/>
2936- <button name="open" states="draft" string="Confirm Payments" icon="gtk-apply"/>
2937- <button name="set_done" states="open" string="Make Payments" type ="object" icon="gtk-execute"/>
2938- </tree>
2939- </field>
2940- </record>
2941-
2942- <record id="view_payment_order_search" model="ir.ui.view">
2943- <field name="name">payment.order.tree.search</field>
2944- <field name="model">payment.order</field>
2945- <field name="type">search</field>
2946- <field name="arch" type="xml">
2947- <search string="Search Payment Orders">
2948- <group col="8" colspan="4">
2949- <filter string="Draft" domain="[('state','=','draft')]" icon="terp-document-new"/>
2950- <filter string="Confirmed" domain="[('state','=','open')]" icon="terp-camera_test"/>
2951- <filter string="Done" domain="[('state','=','done')]" icon="terp-dialog-close"/>
2952- <separator orientation="vertical"/>
2953- <field name="reference"/>
2954- <field name="mode" widget='selection'/>
2955- <field name="date_done"/>
2956- <field name="state"/>
2957- </group>
2958- <newline/>
2959- <group expand="0" string="Group By...">
2960- <filter string="Payment Mode" context="{'group_by': 'mode'}" icon="terp-dolar"/>
2961- <filter string="State" context="{'group_by': 'state'}" icon="terp-stock_effects-object-colorize"/>
2962- </group>
2963- </search>
2964- </field>
2965- </record>
2966-
2967- <record id="action_payment_order_tree" model="ir.actions.act_window">
2968- <field name="name">Payment Orders</field>
2969- <field name="res_model">payment.order</field>
2970- <field name="view_type">form</field>
2971- <field name="view_mode">tree,form</field>
2972- <field name="search_view_id" ref="view_payment_order_search"/>
2973- <field name="help">A payment order is a payment request from your company to pay a supplier invoice or a customer credit note. Here you can register all payment orders that should be done, keep track of all payment orders and mention the invoice reference and the partner the payment should be done for.</field>
2974- </record>
2975-
2976- <menuitem action="action_payment_order_tree" id="menu_action_payment_order_form" parent="menu_main_payment" sequence="3"/>
2977-
2978- <record id="action_payment_order_tree_new" model="ir.actions.act_window">
2979- <field name="name">New Payment Order</field>
2980- <field name="res_model">payment.order</field>
2981- <field name="view_type">form</field>
2982- <field name="view_mode">form,tree</field>
2983- </record>
2984-
2985- <record id="view_payment_line_form" model="ir.ui.view">
2986- <field name="name">Payment Line</field>
2987- <field name="model">payment.line</field>
2988- <field name="type">form</field>
2989- <field name="arch" type="xml">
2990- <form string="Payment Line">
2991- <notebook>
2992- <page string="Payment">
2993- <field name="order_id" select="1"/>
2994- <field name="move_line_id" on_change="onchange_move_line(move_line_id, False, currency, company_currency)" select="1" domain="[('reconcile_id','=', False), ('credit', '>',0),('amount_to_pay','>',0)] "/>
2995- <separator colspan="4" string="Transaction Information"/>
2996- <field name="date"/>
2997- <group colspan="2">
2998- <field name="amount_currency" on_change="onchange_amount(amount_currency,currency,comapny_currency)"/>
2999- <field name="currency" nolabel="1"/>
3000- </group>
3001- <field name="partner_id" on_change="onchange_partner(partner_id, False)" select="1"/>
3002- <field domain="[('partner_id','=',partner_id)]" name="bank_id"/>
3003- <separator colspan="2" string="Owner Account"/>
3004- <separator colspan="2" string="Desitination Account"/>
3005- <field colspan="2" name="info_owner" nolabel="1"/>
3006- <field colspan="2" name="info_partner" nolabel="1"/>
3007-
3008- <field colspan="4" name="communication"/>
3009- <field colspan="4" name="communication2"/>
3010- <field name="name"/>
3011- <field name="state"/>
3012- </page>
3013- <page string="Information">
3014- <separator colspan="4" string="General Information"/>
3015- <group colspan="2">
3016- <field name="amount" select="1"/>
3017- <field name="company_currency" nolabel="1"/>
3018- </group>
3019- <separator colspan="4" string="Entry Information"/>
3020- <field name="create_date"/>
3021- <field name="ml_maturity_date"/>
3022- <field name="ml_inv_ref"/>
3023- </page>
3024- </notebook>
3025- </form>
3026- </field>
3027- </record>
3028- <record id="view_payment_line_tree" model="ir.ui.view">
3029- <field name="name">Payment Lines</field>
3030- <field name="model">payment.line</field>
3031- <field name="type">tree</field>
3032- <field eval="4" name="priority"/>
3033- <field name="arch" type="xml">
3034- <tree string="Payment Line">
3035- <field name="order_id"/>
3036- <field name="ml_inv_ref" />
3037- <field name="ml_maturity_date"/>
3038- <field name="partner_id" select="1"/>
3039- <field name="amount" sum="Amount Total"/>
3040- <field name="amount_currency" sum="Currency Amount Total"/>
3041- <field name="currency"/>
3042- <field name="bank_id" domain="[('partner_id', '=', partner_id)]"/>
3043- <field name="move_line_id" on_change="onchange_move_line(move_line_id,parent.mode)"/>
3044- <field name="create_date"/>
3045- <field name="name"/>
3046- </tree>
3047- </field>
3048- </record>
3049- <record id="action_payment_line_form" model="ir.actions.act_window">
3050- <field name="name">Payment Line</field>
3051- <field name="res_model">payment.line</field>
3052- <field name="view_type">tree</field>
3053- <field name="view_mode">form,tree</field>
3054- </record>
3055-
3056- <record id="view_bank_statement_form" model="ir.ui.view">
3057- <field name="name">account.bank.statement.form.inherit</field>
3058- <field name="model">account.bank.statement</field>
3059- <field name="type">form</field>
3060- <field name="priority">21</field>
3061- <field name="inherit_id" ref="account.view_bank_statement_form"/>
3062- <field name="arch" type="xml">
3063- <field name="journal_id" position="after">
3064- <button name="%(action_account_populate_statement_confirm)d" attrs="{'invisible':[('state','=','confirm')]}" string="Import payment lines" type="action" icon="gtk-execute"/>
3065- </field>
3066- </field>
3067- </record>
3068-
3069-
3070 </data>
3071 </openerp>
3072
3073=== removed file 'bin/addons/account_payment/account_payment_workflow.xml'
3074--- bin/addons/account_payment/account_payment_workflow.xml 2018-09-28 16:12:03 +0000
3075+++ bin/addons/account_payment/account_payment_workflow.xml 1970-01-01 00:00:00 +0000
3076@@ -1,67 +0,0 @@
3077-<?xml version="1.0" encoding="utf-8"?>
3078-<openerp>
3079- <data>
3080- <record id="wkf_payment_order" model="workflow">
3081- <field name="name">Payment Order Workflow</field>
3082- <field name="osv">payment.order</field>
3083- <field name="on_create">True</field>
3084- </record>
3085- <!--Activity -->
3086- <record id="act_draft" model="workflow.activity">
3087- <field name="name">draft</field>
3088- <field name="wkf_id" ref="wkf_payment_order"/>
3089- <field name="flow_start">True</field>
3090- <field name="action">write({'state':'draft'})</field>
3091- <field name="kind">function</field>
3092- </record>
3093- <record id="act_open" model="workflow.activity">
3094- <field name="name">open</field>
3095- <field name="wkf_id" ref="wkf_payment_order"/>
3096- <field name="action">action_open()
3097-write({'state':'open'})</field>
3098- <field name="kind">function</field>
3099- </record>
3100- <record id="act_done" model="workflow.activity">
3101- <field name="name">done</field>
3102- <field name="wkf_id" ref="wkf_payment_order"/>
3103- <field name="action">write({'state':'done'})</field>
3104- <field name="kind">function</field>
3105- <field name="flow_stop">True</field>
3106- </record>
3107- <record id="act_cancel" model="workflow.activity">
3108- <field name="name">cancel</field>
3109- <field name="wkf_id" ref="wkf_payment_order"/>
3110- <field name="action">write({'state':'cancel'})</field>
3111- <field name="kind">function</field>
3112- <field name="flow_stop">True</field>
3113- </record>
3114-
3115- <!-- Transition -->
3116- <record id="trans_draft_open" model="workflow.transition">
3117- <field name="act_from" ref="act_draft"/>
3118- <field name="act_to" ref="act_open"/>
3119- <field name="sequence" eval="10" />
3120- <field name="signal">open</field>
3121- </record>
3122-
3123- <record id="trans_open_done" model="workflow.transition">
3124- <field name="act_from" ref="act_open"/>
3125- <field name="act_to" ref="act_done"/>
3126- <field name="sequence" eval="10" />
3127- <field name="signal">done</field>
3128- </record>
3129- <record id="trans_draft_cancel" model="workflow.transition">
3130- <field name="act_from" ref="act_draft"/>
3131- <field name="act_to" ref="act_cancel"/>
3132- <field name="sequence" eval="20" />
3133- <field name="signal">cancel</field>
3134- </record>
3135- <record id="trans_open_cancel" model="workflow.transition">
3136- <field name="act_from" ref="act_open"/>
3137- <field name="act_to" ref="act_cancel"/>
3138- <field name="sequence" eval="20" />
3139- <field name="signal">cancel</field>
3140- </record>
3141-
3142- </data>
3143-</openerp>
3144
3145=== removed directory 'bin/addons/account_payment/report'
3146=== removed file 'bin/addons/account_payment/report/__init__.py'
3147--- bin/addons/account_payment/report/__init__.py 2011-01-14 00:11:01 +0000
3148+++ bin/addons/account_payment/report/__init__.py 1970-01-01 00:00:00 +0000
3149@@ -1,23 +0,0 @@
3150-# -*- coding: utf-8 -*-
3151-##############################################################################
3152-#
3153-# OpenERP, Open Source Management Solution
3154-# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
3155-#
3156-# This program is free software: you can redistribute it and/or modify
3157-# it under the terms of the GNU Affero General Public License as
3158-# published by the Free Software Foundation, either version 3 of the
3159-# License, or (at your option) any later version.
3160-#
3161-# This program is distributed in the hope that it will be useful,
3162-# but WITHOUT ANY WARRANTY; without even the implied warranty of
3163-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3164-# GNU Affero General Public License for more details.
3165-#
3166-# You should have received a copy of the GNU Affero General Public License
3167-# along with this program. If not, see <http://www.gnu.org/licenses/>.
3168-#
3169-##############################################################################
3170-
3171-import payment_order
3172-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
3173\ No newline at end of file
3174
3175=== removed file 'bin/addons/account_payment/report/order.rml'
3176--- bin/addons/account_payment/report/order.rml 2011-01-14 00:11:01 +0000
3177+++ bin/addons/account_payment/report/order.rml 1970-01-01 00:00:00 +0000
3178@@ -1,290 +0,0 @@
3179-<?xml version="1.0"?>
3180-<document filename="Payment Order.pdf">
3181- <template pageSize="(595.0,842.0)" title="Payment Order" author="OpenERP S.A. (sales@openerp.com)" allowSplitting="20">
3182- <pageTemplate id="first">
3183- <frame id="first" x1="34.0" y1="34.0" width="527" height="774"/>
3184- </pageTemplate>
3185- </template>
3186- <stylesheet>
3187- <blockTableStyle id="Standard_Outline">
3188- <blockAlignment value="LEFT"/>
3189- <blockValign value="TOP"/>
3190- </blockTableStyle>
3191- <blockTableStyle id="Table1">
3192- <blockAlignment value="LEFT"/>
3193- <blockValign value="TOP"/>
3194- </blockTableStyle>
3195- <blockTableStyle id="Table6">
3196- <blockAlignment value="LEFT"/>
3197- <blockValign value="TOP"/>
3198- <lineStyle kind="LINEBEFORE" colorName="#cccccc" start="0,0" stop="0,-1"/>
3199- <lineStyle kind="LINEABOVE" colorName="#cccccc" start="0,0" stop="0,0"/>
3200- <lineStyle kind="LINEBELOW" colorName="#cccccc" start="0,-1" stop="0,-1"/>
3201- <lineStyle kind="LINEBEFORE" colorName="#cccccc" start="1,0" stop="1,-1"/>
3202- <lineStyle kind="LINEABOVE" colorName="#cccccc" start="1,0" stop="1,0"/>
3203- <lineStyle kind="LINEBELOW" colorName="#cccccc" start="1,-1" stop="1,-1"/>
3204- <lineStyle kind="LINEBEFORE" colorName="#cccccc" start="2,0" stop="2,-1"/>
3205- <lineStyle kind="LINEABOVE" colorName="#cccccc" start="2,0" stop="2,0"/>
3206- <lineStyle kind="LINEBELOW" colorName="#cccccc" start="2,-1" stop="2,-1"/>
3207- <lineStyle kind="LINEBEFORE" colorName="#cccccc" start="3,0" stop="3,-1"/>
3208- <lineStyle kind="LINEABOVE" colorName="#cccccc" start="3,0" stop="3,0"/>
3209- <lineStyle kind="LINEBELOW" colorName="#cccccc" start="3,-1" stop="3,-1"/>
3210- <lineStyle kind="LINEBEFORE" colorName="#cccccc" start="4,0" stop="4,-1"/>
3211- <lineStyle kind="LINEAFTER" colorName="#cccccc" start="4,0" stop="4,-1"/>
3212- <lineStyle kind="LINEABOVE" colorName="#cccccc" start="4,0" stop="4,0"/>
3213- <lineStyle kind="LINEBELOW" colorName="#cccccc" start="4,-1" stop="4,-1"/>
3214- </blockTableStyle>
3215- <blockTableStyle id="Table7">
3216- <blockAlignment value="LEFT"/>
3217- <blockValign value="TOP"/>
3218- <lineStyle kind="LINEBEFORE" colorName="#cccccc" start="0,0" stop="0,-1"/>
3219- <lineStyle kind="LINEABOVE" colorName="#cccccc" start="0,0" stop="0,0"/>
3220- <lineStyle kind="LINEBELOW" colorName="#cccccc" start="0,-1" stop="0,-1"/>
3221- <lineStyle kind="LINEBEFORE" colorName="#cccccc" start="1,0" stop="1,-1"/>
3222- <lineStyle kind="LINEABOVE" colorName="#cccccc" start="1,0" stop="1,0"/>
3223- <lineStyle kind="LINEBELOW" colorName="#cccccc" start="1,-1" stop="1,-1"/>
3224- <lineStyle kind="LINEBEFORE" colorName="#cccccc" start="2,0" stop="2,-1"/>
3225- <lineStyle kind="LINEABOVE" colorName="#cccccc" start="2,0" stop="2,0"/>
3226- <lineStyle kind="LINEBELOW" colorName="#cccccc" start="2,-1" stop="2,-1"/>
3227- <lineStyle kind="LINEBEFORE" colorName="#cccccc" start="3,0" stop="3,-1"/>
3228- <lineStyle kind="LINEABOVE" colorName="#cccccc" start="3,0" stop="3,0"/>
3229- <lineStyle kind="LINEBELOW" colorName="#cccccc" start="3,-1" stop="3,-1"/>
3230- <lineStyle kind="LINEBEFORE" colorName="#cccccc" start="4,0" stop="4,-1"/>
3231- <lineStyle kind="LINEAFTER" colorName="#cccccc" start="4,0" stop="4,-1"/>
3232- <lineStyle kind="LINEABOVE" colorName="#cccccc" start="4,0" stop="4,0"/>
3233- <lineStyle kind="LINEBELOW" colorName="#cccccc" start="4,-1" stop="4,-1"/>
3234- </blockTableStyle>
3235- <blockTableStyle id="Table3">
3236- <blockAlignment value="LEFT"/>
3237- <blockValign value="TOP"/>
3238- <lineStyle kind="LINEBELOW" colorName="#000000" start="0,-1" stop="0,-1"/>
3239- <lineStyle kind="LINEBELOW" colorName="#000000" start="1,-1" stop="1,-1"/>
3240- <lineStyle kind="LINEBELOW" colorName="#000000" start="2,-1" stop="2,-1"/>
3241- <lineStyle kind="LINEBELOW" colorName="#000000" start="3,-1" stop="3,-1"/>
3242- <lineStyle kind="LINEBELOW" colorName="#000000" start="4,-1" stop="4,-1"/>
3243- <lineStyle kind="LINEBELOW" colorName="#000000" start="5,-1" stop="5,-1"/>
3244- </blockTableStyle>
3245- <blockTableStyle id="Table4">
3246- <blockAlignment value="LEFT"/>
3247- <blockValign value="TOP"/>
3248- <lineStyle kind="LINEBELOW" colorName="#cccccc" start="0,-1" stop="0,-1"/>
3249- <lineStyle kind="LINEBELOW" colorName="#cccccc" start="1,-1" stop="1,-1"/>
3250- <lineStyle kind="LINEBELOW" colorName="#cccccc" start="2,-1" stop="2,-1"/>
3251- <lineStyle kind="LINEBELOW" colorName="#cccccc" start="3,-1" stop="3,-1"/>
3252- <lineStyle kind="LINEBELOW" colorName="#cccccc" start="4,-1" stop="4,-1"/>
3253- <lineStyle kind="LINEBELOW" colorName="#cccccc" start="5,-1" stop="5,-1"/>
3254- </blockTableStyle>
3255- <blockTableStyle id="Table5">
3256- <blockAlignment value="LEFT"/>
3257- <blockValign value="TOP"/>
3258- <lineStyle kind="LINEABOVE" colorName="#ffffff" start="0,0" stop="0,0"/>
3259- <lineStyle kind="LINEBELOW" colorName="#ffffff" start="0,-1" stop="0,-1"/>
3260- <lineStyle kind="LINEABOVE" colorName="#000000" start="1,0" stop="1,0"/>
3261- <lineStyle kind="LINEABOVE" colorName="#000000" start="2,0" stop="2,0"/>
3262- <lineStyle kind="LINEABOVE" colorName="#000000" start="3,0" stop="3,0"/>
3263- </blockTableStyle>
3264- <initialize>
3265- <paraStyle name="all" alignment="justify"/>
3266- </initialize>
3267- <paraStyle name="Standard" fontName="Helvetica"/>
3268- <paraStyle name="Heading" fontName="Helvetica" fontSize="12.0" leading="15" spaceBefore="12.0" spaceAfter="6.0"/>
3269- <paraStyle name="Text body" fontName="Helvetica" spaceBefore="0.0" spaceAfter="6.0"/>
3270- <paraStyle name="List" fontName="Helvetica" spaceBefore="0.0" spaceAfter="6.0"/>
3271- <paraStyle name="Caption" fontName="Helvetica" fontSize="12.0" leading="15" spaceBefore="6.0" spaceAfter="6.0"/>
3272- <paraStyle name="Index" fontName="Helvetica"/>
3273- <paraStyle name="Table Contents" fontName="Helvetica"/>
3274- <paraStyle name="Table Heading" fontName="Helvetica" alignment="CENTER"/>
3275- <paraStyle name="Footer" fontName="Helvetica"/>
3276- <paraStyle name="Horizontal Line" fontName="Helvetica" fontSize="6.0" leading="8" spaceBefore="0.0" spaceAfter="14.0"/>
3277- <paraStyle name="terp_header" fontName="Helvetica-Bold" fontSize="12.0" leading="15" alignment="LEFT" spaceBefore="12.0" spaceAfter="6.0"/>
3278- <paraStyle name="Heading 9" fontName="Helvetica-Bold" fontSize="75%" leading="NaN" spaceBefore="12.0" spaceAfter="6.0"/>
3279- <paraStyle name="terp_tblheader_General" fontName="Helvetica-Bold" fontSize="8.0" leading="10" alignment="LEFT" spaceBefore="6.0" spaceAfter="6.0"/>
3280- <paraStyle name="terp_tblheader_Details" fontName="Helvetica-Bold" fontSize="9.0" leading="11" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/>
3281- <paraStyle name="terp_default_8" fontName="Helvetica" fontSize="8.0" leading="10" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/>
3282- <paraStyle name="terp_default_Bold_8" fontName="Helvetica-Bold" fontSize="8.0" leading="10" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/>
3283- <paraStyle name="terp_tblheader_General_Centre" fontName="Helvetica-Bold" fontSize="8.0" leading="10" alignment="CENTER" spaceBefore="6.0" spaceAfter="6.0"/>
3284- <paraStyle name="terp_tblheader_General_Right" fontName="Helvetica-Bold" fontSize="8.0" leading="10" alignment="RIGHT" spaceBefore="6.0" spaceAfter="6.0"/>
3285- <paraStyle name="terp_tblheader_Details_Centre" fontName="Helvetica-Bold" fontSize="9.0" leading="11" alignment="CENTER" spaceBefore="0.0" spaceAfter="0.0"/>
3286- <paraStyle name="terp_tblheader_Details_Right" fontName="Helvetica-Bold" fontSize="9.0" leading="11" alignment="RIGHT" spaceBefore="0.0" spaceAfter="0.0"/>
3287- <paraStyle name="terp_default_Right_8" fontName="Helvetica" fontSize="8.0" leading="10" alignment="RIGHT" spaceBefore="0.0" spaceAfter="0.0"/>
3288- <paraStyle name="terp_default_Centre_8" fontName="Helvetica" fontSize="8.0" leading="10" alignment="CENTER" spaceBefore="0.0" spaceAfter="0.0"/>
3289- <paraStyle name="terp_header_Right" fontName="Helvetica-Bold" fontSize="15.0" leading="19" alignment="LEFT" spaceBefore="12.0" spaceAfter="6.0"/>
3290- <paraStyle name="terp_header_Centre" fontName="Helvetica-Bold" fontSize="12.0" leading="15" alignment="CENTER" spaceBefore="12.0" spaceAfter="6.0"/>
3291- <paraStyle name="terp_default_address" fontName="Helvetica" fontSize="10.0" leading="13" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/>
3292- <paraStyle name="terp_default_9" fontName="Helvetica" fontSize="9.0" leading="11" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/>
3293- <paraStyle name="terp_default_Bold_9" fontName="Helvetica-Bold" fontSize="9.0" leading="11" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/>
3294- <paraStyle name="terp_default_Centre_9" fontName="Helvetica" fontSize="9.0" leading="11" alignment="CENTER" spaceBefore="0.0" spaceAfter="0.0"/>
3295- <paraStyle name="terp_default_Right_9" fontName="Helvetica" fontSize="9.0" leading="11" alignment="RIGHT" spaceBefore="0.0" spaceAfter="0.0"/>
3296- <paraStyle name="terp_default_Space" fontName="Helvetica" fontSize="8.0" leading="10" alignment="LEFT" spaceBefore="9.0" spaceAfter="0.0"/>
3297- <paraStyle name="terp_default_space_0.2" fontName="Helvetica" fontSize="8.0" leading="10" alignment="LEFT" spaceBefore="6.0" spaceAfter="0.0"/>
3298- <paraStyle name="terp_default_2" fontName="Helvetica" fontSize="2.0" leading="3" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/>
3299- <images/>
3300- </stylesheet>
3301- <story>
3302- <pto>
3303- <pto_header>
3304- <blockTable colWidths="112.0,86.0,106.0,63.0,85.0,75.0" style="Table3">
3305- <tr>
3306- <td>
3307- <para style="terp_tblheader_Details">Partner</para>
3308- </td>
3309- <td>
3310- <para style="terp_tblheader_Details_Centre">Bank Account</para>
3311- </td>
3312- <td>
3313- <para style="terp_tblheader_Details_Centre">Invoice Ref</para>
3314- </td>
3315- <td>
3316- <para style="terp_tblheader_Details_Centre">Value Date</para>
3317- </td>
3318- <td>
3319- <para style="terp_tblheader_Details_Right">Amount</para>
3320- </td>
3321- <td>
3322- <para style="terp_tblheader_Details_Right">Currency</para>
3323- </td>
3324- </tr>
3325- </blockTable>
3326- </pto_header>
3327- <para style="terp_default_8">[[ repeatIn(objects, 'o') ]]</para>
3328- <para style="terp_default_8">
3329- <font color="white"> </font>
3330- </para>
3331- <blockTable colWidths="318.0,210.0" style="Table1">
3332- <tr>
3333- <td>
3334- <para style="terp_default_9">
3335- <font color="white"> </font>
3336- </para>
3337- </td>
3338- <td>
3339- <para style="terp_default_address">[[ o.mode and o.mode.bank_id.bank and o.mode.bank_id.bank.name or '']]</para>
3340- <para style="terp_default_address">[[ o.mode and o.mode.bank_id.bank and o.mode.bank_id.bank.street or '']]</para>
3341- <para style="terp_default_address">[[ o.mode and o.mode.bank_id.bank and o.mode.bank_id.bank.street2 or removeParentNode('para')]]</para>
3342- <para style="terp_default_address">[[ o.mode and o.mode.bank_id.bank and o.mode.bank_id.bank.zip or '']] [[ o.mode and o.mode.bank_id.bank and o.mode.bank_id.bank.city or '']]</para>
3343- <para style="terp_default_address">[[ o.mode and o.mode.bank_id.bank and o.mode.bank_id.bank.state and o.mode.bank_id.bank.state.name or removeParentNode('para') ]]</para>
3344- <para style="terp_default_address">[[ o.mode and o.mode.bank_id.bank and o.mode.bank_id.bank.country and o.mode.bank_id.bank.country.name or '']]</para>
3345- </td>
3346- </tr>
3347- </blockTable>
3348- <para style="terp_default_8">
3349- <font color="white"> </font>
3350- </para>
3351- <para style="terp_header">Payment Order / Payment</para>
3352- <para style="terp_default_8">
3353- <font color="white"> </font>
3354- </para>
3355- <blockTable colWidths="106.0,106.0,106.0,106.0,106.0" style="Table6">
3356- <tr>
3357- <td>
3358- <para style="terp_tblheader_General_Centre">Payment Type</para>
3359- </td>
3360- <td>
3361- <para style="terp_tblheader_General_Centre">Reference</para>
3362- </td>
3363- <td>
3364- <para style="terp_tblheader_General_Centre">Used Account</para>
3365- </td>
3366- <td>
3367- <para style="terp_tblheader_General_Centre">Execution Type</para>
3368- </td>
3369- <td>
3370- <para style="terp_tblheader_General_Centre">Company Currency</para>
3371- </td>
3372- </tr>
3373- </blockTable>
3374- <blockTable colWidths="106.0,106.0,106.0,106.0,106.0" style="Table7">
3375- <tr>
3376- <td>
3377- <para style="terp_default_Centre_8">[[ o.mode and o.mode.name or '-' ]]</para>
3378- </td>
3379- <td>
3380- <para style="terp_default_Centre_8">[[ o.reference or '-' ]]</para>
3381- </td>
3382- <td>
3383- <para style="terp_default_Centre_8">[[get_account_name(o.mode.bank_id.id)]]</para>
3384- </td>
3385- <td>
3386- <para style="terp_default_Centre_8">[[ o.date_prefered == 'now' and 'Now' or removeParentNode('para') ]]</para>
3387- <para style="terp_default_Centre_8">[[ o.date_prefered == 'due' and 'Due date' or removeParentNode('para') ]]</para>
3388- <para style="terp_default_Centre_8">[[ o.date_prefered == 'fixed' and 'Fixed date' or removeParentNode('para') ]]</para>
3389- </td>
3390- <td>
3391- <para style="terp_default_Centre_8">[[ o.user_id and o.user_id.company_id and o.user_id.company_id.currency_id and o.user_id.company_id.currency_id.name or '' ]]</para>
3392- </td>
3393- </tr>
3394- </blockTable>
3395- <para style="terp_default_9">
3396- <font color="white"> </font>
3397- </para>
3398- <blockTable colWidths="112.0,86.0,106.0,63.0,85.0,75.0" style="Table3">
3399- <tr>
3400- <td>
3401- <para style="terp_tblheader_Details">Partner</para>
3402- </td>
3403- <td>
3404- <para style="terp_tblheader_Details_Centre">Bank Account</para>
3405- </td>
3406- <td>
3407- <para style="terp_tblheader_Details_Centre">Invoice Ref</para>
3408- </td>
3409- <td>
3410- <para style="terp_tblheader_Details_Centre">Value Date</para>
3411- </td>
3412- <td>
3413- <para style="terp_tblheader_Details_Right">Amount</para>
3414- </td>
3415- <td>
3416- <para style="terp_tblheader_Details_Right">Currency</para>
3417- </td>
3418- </tr>
3419- </blockTable>
3420- <section>
3421- <para style="terp_default_2">[[repeatIn(o.line_ids, 'line') ]]</para>
3422- <blockTable colWidths="112.0,86.0,106.0,64.0,85.0,75.0" style="Table4">
3423- <tr>
3424- <td>
3425- <para style="terp_default_9">[[line.partner_id and line.partner_id.name or '-' ]]</para>
3426- </td>
3427- <td>
3428- <para style="terp_default_Centre_9">[[get_account_name(line.bank_id.id) or '-']]</para>
3429- </td>
3430- <td>
3431- <para style="terp_default_Centre_9">[[ get_invoice_name(line.ml_inv_ref.id) or '-' ]]</para>
3432- </td>
3433- <td>
3434- <para style="terp_default_Centre_9">[[line.date=='False' and '-' or formatLang(line.date,date=True) ]]</para>
3435- </td>
3436- <td>
3437- <para style="terp_default_Right_9">[[formatLang(line.amount) or '-' ]] [[get_company_currency_symbol()]] </para>
3438- </td>
3439- <td>
3440- <para style="terp_default_Right_9">[[ formatLang(line.amount_currency) ]] [[ line.currency.symbol]] </para>
3441- </td>
3442- </tr>
3443- </blockTable>
3444- </section>
3445- <blockTable colWidths="335.0,32.0,85.0,75.0" style="Table5">
3446- <tr>
3447- <td>
3448- <para style="terp_default_9">
3449- <font color="white"> </font>
3450- </para>
3451- </td>
3452- <td>
3453- <para style="terp_default_Bold_9">Total:</para>
3454- </td>
3455- <td>
3456- <para style="terp_default_Right_9">[[ formatLang(get_amount_total(o)) or '' ]] [[get_company_currency_symbol()]] </para>
3457- </td>
3458- <td>
3459- <para style="terp_default_Right_9">[[ formatLang(get_amount_total_in_currency(o)) or '' ]] [[get_company_currency_symbol()]] </para>
3460- </td>
3461- </tr>
3462- </blockTable>
3463- <para style="terp_default_8">
3464- <font color="white"> </font>
3465- </para>
3466- </pto>
3467- </story>
3468-</document>
3469
3470=== removed file 'bin/addons/account_payment/report/order.sxw'
3471Binary files bin/addons/account_payment/report/order.sxw 2011-01-14 00:11:01 +0000 and bin/addons/account_payment/report/order.sxw 1970-01-01 00:00:00 +0000 differ
3472=== removed file 'bin/addons/account_payment/report/payment_order.py'
3473--- bin/addons/account_payment/report/payment_order.py 2011-01-14 00:11:01 +0000
3474+++ bin/addons/account_payment/report/payment_order.py 1970-01-01 00:00:00 +0000
3475@@ -1,90 +0,0 @@
3476-# -*- coding: utf-8 -*-
3477-##############################################################################
3478-#
3479-# OpenERP, Open Source Management Solution
3480-# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
3481-#
3482-# This program is free software: you can redistribute it and/or modify
3483-# it under the terms of the GNU Affero General Public License as
3484-# published by the Free Software Foundation, either version 3 of the
3485-# License, or (at your option) any later version.
3486-#
3487-# This program is distributed in the hope that it will be useful,
3488-# but WITHOUT ANY WARRANTY; without even the implied warranty of
3489-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3490-# GNU Affero General Public License for more details.
3491-#
3492-# You should have received a copy of the GNU Affero General Public License
3493-# along with this program. If not, see <http://www.gnu.org/licenses/>.
3494-#
3495-##############################################################################
3496-
3497-import time
3498-
3499-import pooler
3500-from report import report_sxw
3501-
3502-class payment_order(report_sxw.rml_parse):
3503-
3504- def __init__(self, cr, uid, name, context=None):
3505- super(payment_order, self).__init__(cr, uid, name, context=context)
3506- self.localcontext.update( {
3507- 'time': time,
3508- 'get_invoice_name': self._get_invoice_name,
3509- 'get_company_currency': self._get_company_currency,
3510- 'get_company_currency_symbol': self._get_company_currency_symbol,
3511- 'get_amount_total_in_currency': self._get_amount_total_in_currency,
3512- 'get_amount_total': self._get_amount_total,
3513- 'get_account_name': self._get_account_name,
3514- })
3515-
3516- def _get_invoice_name(self, invoice_id):
3517- if invoice_id:
3518- pool = pooler.get_pool(self.cr.dbname)
3519- value_name = pool.get('account.invoice').name_get(self.cr, self.uid, [invoice_id])
3520- if value_name:
3521- return value_name[0][1]
3522- return False
3523-
3524- def _get_amount_total_in_currency(self, payment):
3525- total = 0.0
3526- if payment.line_ids:
3527- currency_cmp = payment.line_ids[0].currency.id
3528- else:
3529- return False
3530- for line in payment.line_ids:
3531- if currency_cmp == line.currency.id:
3532- total += line.amount_currency
3533- else:
3534- return False
3535- return total
3536-
3537- def _get_amount_total(self, payment):
3538- total = 0.0
3539- if not payment.line_ids:
3540- return False
3541- for line in payment.line_ids:
3542- total += line.amount
3543- return total
3544-
3545- def _get_company_currency(self):
3546- pool = pooler.get_pool(self.cr.dbname)
3547- user = pool.get('res.users').browse(self.cr, self.uid, self.uid)
3548- return user.company_id and user.company_id.currency_id and user.company_id.currency_id.symbol or False
3549-
3550- def _get_company_currency_symbol(self):
3551- pool = pooler.get_pool(self.cr.dbname)
3552- user = pool.get('res.users').browse(self.cr, self.uid, self.uid)
3553- return user.company_id and user.company_id.currency_id and user.company_id.currency_id.symbol or False
3554-
3555- def _get_account_name(self,bank_id):
3556- if bank_id:
3557- pool = pooler.get_pool(self.cr.dbname)
3558- value_name = pool.get('res.partner.bank').name_get(self.cr, self.uid, [bank_id])
3559- if value_name:
3560- return value_name[0][1]
3561- return False
3562-
3563-report_sxw.report_sxw('report.payment.order', 'payment.order', 'addons/account_payment/report/payment_order.rml', parser=payment_order, header="external")
3564-
3565-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
3566\ No newline at end of file
3567
3568=== removed directory 'bin/addons/account_payment/security'
3569=== removed file 'bin/addons/account_payment/security/account_payment_security.xml'
3570--- bin/addons/account_payment/security/account_payment_security.xml 2011-02-28 13:57:54 +0000
3571+++ bin/addons/account_payment/security/account_payment_security.xml 1970-01-01 00:00:00 +0000
3572@@ -1,17 +0,0 @@
3573-<?xml version="1.0" encoding="utf-8"?>
3574-<openerp>
3575-<data noupdate="1">
3576-
3577- <record id="group_account_payment" model="res.groups">
3578- <field name="name">Accounting / Payments</field>
3579- </record>
3580-
3581- <record id="payment_mode_comp_rule" model="ir.rule">
3582- <field name="name">Payment Mode company rule</field>
3583- <field model="ir.model" name="model_id" ref="model_payment_mode"/>
3584- <field eval="True" name="global"/>
3585- <field name="domain_force">['|',('company_id','=',False),('company_id','child_of',[user.company_id.id])]</field>
3586- </record>
3587-
3588-</data>
3589-</openerp>
3590
3591=== removed file 'bin/addons/account_payment/security/ir.model.access.csv'
3592--- bin/addons/account_payment/security/ir.model.access.csv 2018-10-04 14:32:37 +0000
3593+++ bin/addons/account_payment/security/ir.model.access.csv 1970-01-01 00:00:00 +0000
3594@@ -1,1 +0,0 @@
3595-"id","name","model_id:id","group_id:id","perm_read","perm_write","perm_create","perm_unlink"
3596
3597=== removed directory 'bin/addons/account_payment/wizard'
3598=== removed file 'bin/addons/account_payment/wizard/__init__.py'
3599--- bin/addons/account_payment/wizard/__init__.py 2011-01-14 00:11:01 +0000
3600+++ bin/addons/account_payment/wizard/__init__.py 1970-01-01 00:00:00 +0000
3601@@ -1,26 +0,0 @@
3602-# -*- coding: utf-8 -*-
3603-##############################################################################
3604-#
3605-# OpenERP, Open Source Management Solution
3606-# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
3607-#
3608-# This program is free software: you can redistribute it and/or modify
3609-# it under the terms of the GNU Affero General Public License as
3610-# published by the Free Software Foundation, either version 3 of the
3611-# License, or (at your option) any later version.
3612-#
3613-# This program is distributed in the hope that it will be useful,
3614-# but WITHOUT ANY WARRANTY; without even the implied warranty of
3615-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3616-# GNU Affero General Public License for more details.
3617-#
3618-# You should have received a copy of the GNU Affero General Public License
3619-# along with this program. If not, see <http://www.gnu.org/licenses/>.
3620-#
3621-##############################################################################
3622-
3623-import account_payment_order
3624-import account_payment_populate_statement
3625-import account_payment_pay
3626-
3627-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
3628\ No newline at end of file
3629
3630=== removed file 'bin/addons/account_payment/wizard/account_payment_create_order_view.xml'
3631--- bin/addons/account_payment/wizard/account_payment_create_order_view.xml 2017-05-10 12:47:14 +0000
3632+++ bin/addons/account_payment/wizard/account_payment_create_order_view.xml 1970-01-01 00:00:00 +0000
3633@@ -1,52 +0,0 @@
3634-<?xml version="1.0" encoding="utf-8"?>
3635-<openerp>
3636- <data>
3637-
3638- <record id="view_create_payment_order" model="ir.ui.view">
3639- <field name="name">payment.order.create.form</field>
3640- <field name="model">payment.order.create</field>
3641- <field name="type">form</field>
3642- <field name="priority">18</field>
3643- <field name="arch" type="xml">
3644- <form string="Search Payment lines">
3645- <group col="4" colspan="6">
3646- <field name="duedate" />
3647- </group>
3648- <separator colspan="4"/>
3649- <group col="2" colspan="4">
3650- <button special="cancel" string="Cancel" icon='gtk-cancel'/>
3651- <button name="search_entries" string="Search" colspan="1" type="object" icon="gtk-execute"/>
3652- </group>
3653- </form>
3654- </field>
3655- </record>
3656-
3657- <record id="view_create_payment_order_lines" model="ir.ui.view">
3658- <field name="name">payment.order.create.form</field>
3659- <field name="model">payment.order.create</field>
3660- <field name="type">form</field>
3661- <field name="priority">17</field>
3662- <field name="arch" type="xml">
3663- <form string="Search Payment lines">
3664- <group col="4" colspan="6">
3665- </group>
3666- <separator colspan="4"/>
3667- <group col="2" colspan="4">
3668- <button special="cancel" string="Cancel" icon='gtk-cancel'/>
3669- <button name="create_payment" string="_Add to payment order" colspan="1" type="object" icon="gtk-execute"/>
3670- </group>
3671- </form>
3672- </field>
3673- </record>
3674-
3675- <record id="action_create_payment_order" model="ir.actions.act_window">
3676- <field name="name">Populate Payment</field>
3677- <field name="type">ir.actions.act_window</field>
3678- <field name="res_model">payment.order.create</field>
3679- <field name="view_type">form</field>
3680- <field name="view_mode">form</field>
3681- <field name="target">new</field>
3682- </record>
3683-
3684- </data>
3685-</openerp>
3686
3687=== removed file 'bin/addons/account_payment/wizard/account_payment_order.py'
3688--- bin/addons/account_payment/wizard/account_payment_order.py 2011-01-14 00:11:01 +0000
3689+++ bin/addons/account_payment/wizard/account_payment_order.py 1970-01-01 00:00:00 +0000
3690@@ -1,123 +0,0 @@
3691-# -*- coding: utf-8 -*-
3692-##############################################################################
3693-#
3694-# OpenERP, Open Source Management Solution
3695-# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
3696-#
3697-# This program is free software: you can redistribute it and/or modify
3698-# it under the terms of the GNU Affero General Public License as
3699-# published by the Free Software Foundation, either version 3 of the
3700-# License, or (at your option) any later version.
3701-#
3702-# This program is distributed in the hope that it will be useful,
3703-# but WITHOUT ANY WARRANTY; without even the implied warranty of
3704-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3705-# GNU Affero General Public License for more details.
3706-#
3707-# You should have received a copy of the GNU Affero General Public License
3708-# along with this program. If not, see <http://www.gnu.org/licenses/>.
3709-#
3710-##############################################################################
3711-
3712-import time
3713-from lxml import etree
3714-
3715-from osv import osv, fields
3716-
3717-class payment_order_create(osv.osv_memory):
3718- """
3719- Create a payment object with lines corresponding to the account move line
3720- to pay according to the date and the mode provided by the user.
3721- Hypothesis:
3722- - Small number of non-reconcilied move line, payment mode and bank account type,
3723- - Big number of partner and bank account.
3724-
3725- If a type is given, unsuitable account Entry lines are ignored.
3726- """
3727-
3728- _name = 'payment.order.create'
3729- _description = 'payment.order.create'
3730- _columns = {
3731- 'duedate': fields.date('Due Date', required=True),
3732- 'entries': fields.many2many('account.move.line', 'line_pay_rel', 'pay_id', 'line_id', 'Entries')
3733- }
3734- _defaults = {
3735- 'duedate': lambda *a: time.strftime('%Y-%m-%d'),
3736- }
3737-
3738- def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False):
3739- res = super(payment_order_create, self).fields_view_get(cr, uid, view_id=view_id, view_type=view_type, context=context, toolbar=toolbar, submenu=False)
3740- if context and 'line_ids' in context:
3741- view_obj = etree.XML(res['arch'])
3742- child = view_obj.getchildren()[0]
3743- domain = '[("id", "in", '+ str(context['line_ids'])+')]'
3744- field = etree.Element('field', attrib={'domain': domain, 'name':'entries', 'colspan':'4', 'height':'300', 'width':'800', 'nolabel':"1"})
3745- child.addprevious(field)
3746- res['arch'] = etree.tostring(view_obj)
3747- return res
3748-
3749- def create_payment(self, cr, uid, ids, context=None):
3750- order_obj = self.pool.get('payment.order')
3751- line_obj = self.pool.get('account.move.line')
3752- payment_obj = self.pool.get('payment.line')
3753- if context is None:
3754- context = {}
3755- data = self.read(cr, uid, ids, [], context=context)[0]
3756- line_ids = data['entries']
3757- if not line_ids:
3758- return {'type': 'ir.actions.act_window_close'}
3759-
3760- payment = order_obj.browse(cr, uid, context['active_id'], context=context)
3761- t = None
3762- line2bank = line_obj.line2bank(cr, uid, line_ids, t, context)
3763-
3764- ## Finally populate the current payment with new lines:
3765- for line in line_obj.browse(cr, uid, line_ids, context=context):
3766- if payment.date_prefered == "now":
3767- #no payment date => immediate payment
3768- date_to_pay = False
3769- elif payment.date_prefered == 'due':
3770- date_to_pay = line.date_maturity
3771- elif payment.date_prefered == 'fixed':
3772- date_to_pay = payment.date_scheduled
3773- payment_obj.create(cr, uid,{
3774- 'move_line_id': line.id,
3775- 'amount_currency': line.amount_to_pay,
3776- 'bank_id': line2bank.get(line.id),
3777- 'order_id': payment.id,
3778- 'partner_id': line.partner_id and line.partner_id.id or False,
3779- 'communication': line.ref or '/',
3780- 'date': date_to_pay,
3781- 'currency': line.invoice and line.invoice.currency_id.id or False,
3782- }, context=context)
3783- return {'type': 'ir.actions.act_window_close'}
3784-
3785- def search_entries(self, cr, uid, ids, context=None):
3786- line_obj = self.pool.get('account.move.line')
3787- mod_obj = self.pool.get('ir.model.data')
3788- if context is None:
3789- context = {}
3790- data = self.read(cr, uid, ids, [], context=context)[0]
3791- search_due_date = data['duedate']
3792-# payment = self.pool.get('payment.order').browse(cr, uid, context['active_id'], context=context)
3793-
3794- # Search for move line to pay:
3795- domain = [('reconcile_id', '=', False), ('account_id.type', '=', 'payable'), ('amount_to_pay', '>', 0)]
3796- domain = domain + ['|', ('date_maturity', '<=', search_due_date), ('date_maturity', '=', False)]
3797- line_ids = line_obj.search(cr, uid, domain, context=context)
3798- context.update({'line_ids': line_ids})
3799- model_data_ids = mod_obj.search(cr, uid,[('model', '=', 'ir.ui.view'), ('name', '=', 'view_create_payment_order_lines')], context=context)
3800- resource_id = mod_obj.read(cr, uid, model_data_ids, fields=['res_id'], context=context)[0]['res_id']
3801- return {'name': ('Entrie Lines'),
3802- 'context': context,
3803- 'view_type': 'form',
3804- 'view_mode': 'form',
3805- 'res_model': 'payment.order.create',
3806- 'views': [(resource_id,'form')],
3807- 'type': 'ir.actions.act_window',
3808- 'target': 'new',
3809- }
3810-
3811-payment_order_create()
3812-
3813-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
3814\ No newline at end of file
3815
3816=== removed file 'bin/addons/account_payment/wizard/account_payment_pay.py'
3817--- bin/addons/account_payment/wizard/account_payment_pay.py 2011-01-14 00:11:01 +0000
3818+++ bin/addons/account_payment/wizard/account_payment_pay.py 1970-01-01 00:00:00 +0000
3819@@ -1,58 +0,0 @@
3820-# -*- coding: utf-8 -*-
3821-##############################################################################
3822-#
3823-# OpenERP, Open Source Management Solution
3824-# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
3825-#
3826-# This program is free software: you can redistribute it and/or modify
3827-# it under the terms of the GNU Affero General Public License as
3828-# published by the Free Software Foundation, either version 3 of the
3829-# License, or (at your option) any later version.
3830-#
3831-# This program is distributed in the hope that it will be useful,
3832-# but WITHOUT ANY WARRANTY; without even the implied warranty of
3833-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3834-# GNU Affero General Public License for more details.
3835-#
3836-# You should have received a copy of the GNU Affero General Public License
3837-# along with this program. If not, see <http://www.gnu.org/licenses/>.
3838-#
3839-##############################################################################
3840-
3841-from osv import osv
3842-
3843-class account_payment_make_payment(osv.osv_memory):
3844- _name = "account.payment.make.payment"
3845- _description = "Account make payment"
3846-
3847- def launch_wizard(self, cr, uid, ids, context=None):
3848- """
3849- Search for a wizard to launch according to the type.
3850- If type is manual. just confirm the order.
3851- """
3852- obj_payment_order = self.pool.get('payment.order')
3853- if context is None:
3854- context = {}
3855-# obj_model = self.pool.get('ir.model.data')
3856-# obj_act = self.pool.get('ir.actions.act_window')
3857-# order = obj_payment_order.browse(cr, uid, context['active_id'], context)
3858- obj_payment_order.set_done(cr, uid, [context['active_id']], context)
3859- return {'type': 'ir.actions.act_window_close'}
3860-# t = order.mode and order.mode.type.code or 'manual'
3861-# if t == 'manual':
3862-# obj_payment_order.set_done(cr,uid,context['active_id'],context)
3863-# return {}
3864-#
3865-# gw = obj_payment_order.get_wizard(t)
3866-# if not gw:
3867-# obj_payment_order.set_done(cr,uid,context['active_id'],context)
3868-# return {}
3869-#
3870-# module, wizard= gw
3871-# result = obj_model._get_id(cr, uid, module, wizard)
3872-# id = obj_model.read(cr, uid, [result], ['res_id'])[0]['res_id']
3873-# return obj_act.read(cr, uid, [id])[0]
3874-
3875-account_payment_make_payment()
3876-
3877-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
3878\ No newline at end of file
3879
3880=== removed file 'bin/addons/account_payment/wizard/account_payment_pay_view.xml'
3881--- bin/addons/account_payment/wizard/account_payment_pay_view.xml 2011-01-14 00:11:01 +0000
3882+++ bin/addons/account_payment/wizard/account_payment_pay_view.xml 1970-01-01 00:00:00 +0000
3883@@ -1,33 +0,0 @@
3884-<?xml version="1.0" encoding="utf-8"?>
3885-<openerp>
3886- <data>
3887-
3888- <record id="account_payment_make_payment_view" model="ir.ui.view">
3889- <field name="name">account.payment.make.payment.form</field>
3890- <field name="model">account.payment.make.payment</field>
3891- <field name="type">form</field>
3892- <field name="arch" type="xml">
3893- <form string="Make Payment">
3894- <separator string="Are you sure you want to make payment?"/>
3895- <newline/>
3896- <group colspan="2" col="4">
3897- <button special="cancel" string="Cancel" icon="gtk-cancel"/>
3898- <button name="launch_wizard" string="Yes" type="object" icon="gtk-ok" default_focus="1"/>
3899- </group>
3900- </form>
3901- </field>
3902- </record>
3903-
3904- <record id="action_account_payment_make_payment" model="ir.actions.act_window">
3905- <field name="name">Make Payment</field>
3906- <field name="type">ir.actions.act_window</field>
3907- <field name="res_model">account.payment.make.payment</field>
3908- <field name="view_type">form</field>
3909- <field name="view_mode">form</field>
3910- <field name="view_id" ref="account_payment_make_payment_view"/>
3911- <field name="target">new</field>
3912- </record>
3913-
3914-
3915- </data>
3916-</openerp>
3917
3918=== removed file 'bin/addons/account_payment/wizard/account_payment_populate_statement.py'
3919--- bin/addons/account_payment/wizard/account_payment_populate_statement.py 2011-05-16 14:06:09 +0000
3920+++ bin/addons/account_payment/wizard/account_payment_populate_statement.py 1970-01-01 00:00:00 +0000
3921@@ -1,122 +0,0 @@
3922-# -*- coding: utf-8 -*-
3923-##############################################################################
3924-#
3925-# OpenERP, Open Source Management Solution
3926-# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
3927-#
3928-# This program is free software: you can redistribute it and/or modify
3929-# it under the terms of the GNU Affero General Public License as
3930-# published by the Free Software Foundation, either version 3 of the
3931-# License, or (at your option) any later version.
3932-#
3933-# This program is distributed in the hope that it will be useful,
3934-# but WITHOUT ANY WARRANTY; without even the implied warranty of
3935-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3936-# GNU Affero General Public License for more details.
3937-#
3938-# You should have received a copy of the GNU Affero General Public License
3939-# along with this program. If not, see <http://www.gnu.org/licenses/>.
3940-#
3941-##############################################################################
3942-
3943-import time
3944-from lxml import etree
3945-
3946-from osv import osv, fields
3947-
3948-class account_payment_populate_statement(osv.osv_memory):
3949- _name = "account.payment.populate.statement"
3950- _description = "Account Payment Populate Statement"
3951- _columns = {
3952- 'lines': fields.many2many('payment.line', 'payment_line_rel_', 'payment_id', 'line_id', 'Payment Lines')
3953- }
3954-
3955- def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False):
3956- line_obj = self.pool.get('payment.line')
3957-
3958- res = super(account_payment_populate_statement, self).fields_view_get(cr, uid, view_id=view_id, view_type=view_type, context=context, toolbar=toolbar, submenu=False)
3959- line_ids = line_obj.search(cr, uid, [
3960- ('move_line_id.reconcile_id', '=', False),
3961- ('bank_statement_line_id', '=', False),
3962- ('move_line_id.state','=','valid')])
3963- line_ids.extend(line_obj.search(cr, uid, [
3964- ('move_line_id.reconcile_id', '=', False),
3965- ('order_id.mode', '=', False),
3966- ('move_line_id.state','=','valid')]))
3967- domain = '[("id", "in", '+ str(line_ids)+')]'
3968- doc = etree.XML(res['arch'])
3969- nodes = doc.xpath("//field[@name='lines']")
3970- for node in nodes:
3971- node.set('domain', domain)
3972- res['arch'] = etree.tostring(doc)
3973- return res
3974-
3975- def populate_statement(self, cr, uid, ids, context=None):
3976- line_obj = self.pool.get('payment.line')
3977- statement_obj = self.pool.get('account.bank.statement')
3978- statement_line_obj = self.pool.get('account.bank.statement.line')
3979- currency_obj = self.pool.get('res.currency')
3980- voucher_obj = self.pool.get('account.voucher')
3981- voucher_line_obj = self.pool.get('account.voucher.line')
3982- move_line_obj = self.pool.get('account.move.line')
3983-
3984- if context is None:
3985- context = {}
3986- data = self.read(cr, uid, ids, [], context=context)[0]
3987- line_ids = data['lines']
3988- if not line_ids:
3989- return {'type': 'ir.actions.act_window_close'}
3990-
3991- statement = statement_obj.browse(cr, uid, context['active_id'], context=context)
3992-
3993- for line in line_obj.browse(cr, uid, line_ids, context=context):
3994- ctx = context.copy()
3995- ctx['date'] = line.ml_maturity_date # was value_date earlier,but this field exists no more now
3996- amount = currency_obj.compute(cr, uid, line.currency.id,
3997- statement.currency.id, line.amount_currency, context=ctx)
3998-
3999- if not line.move_line_id.id:
4000- continue
4001- context.update({'move_line_ids': [line.move_line_id.id]})
4002- result = voucher_obj.onchange_partner_id(cr, uid, [], partner_id=line.partner_id.id, journal_id=statement.journal_id.id, price=abs(amount), currency_id=statement.currency.id, ttype='payment', date=line.date, context=context)
4003-
4004- voucher_res = {
4005- 'type': 'payment',
4006- 'name': line.name,
4007- 'partner_id': line.partner_id.id,
4008- 'journal_id': statement.journal_id.id,
4009- 'account_id': result.get('account_id', statement.journal_id.default_credit_account_id.id),
4010- 'company_id': statement.company_id.id,
4011- 'currency_id': statement.currency.id,
4012- 'date': line.date or time.strftime('%Y-%m-%d'),
4013- 'amount': abs(amount),
4014- 'period_id': statement.period_id.id
4015- }
4016- voucher_id = voucher_obj.create(cr, uid, voucher_res, context=context)
4017- voucher_line_dict = {}
4018- if result['value']['line_ids']:
4019- for line_dict in result['value']['line_ids']:
4020- move_line = move_line_obj.browse(cr, uid, line_dict['move_line_id'], context)
4021- if line.move_line_id.move_id.id == move_line.move_id.id:
4022- voucher_line_dict = line_dict
4023- if voucher_line_dict:
4024- voucher_line_dict.update({'voucher_id': voucher_id})
4025- voucher_line_obj.create(cr, uid, voucher_line_dict, context=context)
4026-
4027- st_line_id = statement_line_obj.create(cr, uid, {
4028- 'name': line.order_id.reference or '?',
4029- 'amount': - amount,
4030- 'type': 'supplier',
4031- 'partner_id': line.partner_id.id,
4032- 'account_id': line.move_line_id.account_id.id,
4033- 'statement_id': statement.id,
4034- 'ref': line.communication,
4035- 'voucher_id': voucher_id,
4036- }, context=context)
4037-
4038- line_obj.write(cr, uid, [line.id], {'bank_statement_line_id': st_line_id})
4039- return {'type': 'ir.actions.act_window_close'}
4040-
4041-account_payment_populate_statement()
4042-
4043-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
4044\ No newline at end of file
4045
4046=== removed file 'bin/addons/account_payment/wizard/account_payment_populate_statement_view.xml'
4047--- bin/addons/account_payment/wizard/account_payment_populate_statement_view.xml 2011-01-14 00:11:01 +0000
4048+++ bin/addons/account_payment/wizard/account_payment_populate_statement_view.xml 1970-01-01 00:00:00 +0000
4049@@ -1,44 +0,0 @@
4050-<?xml version="1.0" encoding="UTF-8"?>
4051-<openerp>
4052- <data>
4053-
4054- <record id="account_payment_populate_statement_view" model="ir.ui.view">
4055- <field name="name">Payment Populate statement</field>
4056- <field name="model">account.payment.populate.statement</field>
4057- <field name="type">form</field>
4058- <field name="arch" type="xml">
4059- <form string="Populate Statement:">
4060- <group colspan="4" col="6">
4061- <field name="lines" colspan="4" height="300" width="800" nolabel="1" />
4062- <separator colspan="6"/>
4063- <button special="cancel" string="Cancel" icon="gtk-cancel"/>
4064- <button name="populate_statement" string="ADD" type="object" icon="gtk-ok"/>
4065- </group>
4066- </form>
4067- </field>
4068- </record>
4069-
4070- <record id="action_account_populate_statement_confirm" model="ir.actions.act_window">
4071- <field name="name">Payment Populate statement</field>
4072- <field name="res_model">account.payment.populate.statement</field>
4073- <field name="type">ir.actions.act_window</field>
4074- <field name="view_type">form</field>
4075- <field name="view_mode">tree,form</field>
4076- <field name="view_id" ref="account_payment_populate_statement_view"/>
4077- <field name="context">{'record_id':active_id}</field>
4078- <field name="target">new</field>
4079- </record>
4080-
4081- <record id="action_account_payment_populate_statement" model="ir.actions.act_window">
4082- <field name="name">Payment Populate statement</field>
4083- <field name="res_model">account.payment.populate.statement</field>
4084- <field name="type">ir.actions.act_window</field>
4085- <field name="view_type">form</field>
4086- <field name="view_mode">tree,form</field>
4087- <field name="view_id" ref="account_payment_populate_statement_view"/>
4088- <field name="context">{'record_id':active_id}</field>
4089- <field name="target">new</field>
4090- </record>
4091-
4092- </data>
4093-</openerp>
4094\ No newline at end of file
4095
4096=== modified file 'bin/addons/account_period_closing_level/account_year_end_closing.py'
4097--- bin/addons/account_period_closing_level/account_year_end_closing.py 2018-11-23 14:44:11 +0000
4098+++ bin/addons/account_period_closing_level/account_year_end_closing.py 2019-10-25 14:10:32 +0000
4099@@ -318,8 +318,8 @@
4100 'block_manual_currency_id': True,
4101 'company_id': cpy_rec.id,
4102 'currency_id': ccy_id,
4103- 'date': posting_date,
4104- 'document_date': posting_date,
4105+ 'date': last_day_fy,
4106+ 'document_date': last_day_fy,
4107 'instance_id': instance_rec.id,
4108 'journal_id': journal_id,
4109 'name': name,
4110@@ -335,17 +335,18 @@
4111 """
4112 name = 'Balance move to 0'
4113
4114+ # DONE: TEST JN => behavior unchanged (use of clearer date name for the source date)
4115 vals = {
4116 'account_id': account_id,
4117 'company_id': cpy_rec.id,
4118 'currency_id': ccy_id,
4119- 'date': posting_date,
4120- 'document_date': posting_date,
4121+ 'date': last_day_fy,
4122+ 'document_date': last_day_fy,
4123 'instance_id': instance_rec.id,
4124 'journal_id': journal_id,
4125 'name': name,
4126 'period_id': period_id,
4127- 'source_date': posting_date,
4128+ 'source_date': last_day_fy,
4129
4130 'debit_currency': \
4131 balance_currency if balance_currency > 0. else 0.,
4132@@ -378,7 +379,7 @@
4133 instance_rec.id, context=context)
4134
4135 fy_year = self._get_fy_year(cr, uid, fy_rec, context=context)
4136- posting_date = "%d-12-31" % (fy_year, )
4137+ last_day_fy = "%d-12-31" % (fy_year, )
4138
4139 journal_code = 'EOY'
4140 journal_id = self._get_journal(cr, uid, journal_code, context=context)
4141@@ -593,8 +594,8 @@
4142 'block_manual_currency_id': True,
4143 'company_id': cpy_rec.id,
4144 'currency_id': ccy_id,
4145- 'date': posting_date,
4146- 'document_date': posting_date,
4147+ 'date': first_day_next_fy,
4148+ 'document_date': first_day_next_fy,
4149 'instance_id': instance_rec.id,
4150 'journal_id': journal_id,
4151 'name': name,
4152@@ -611,17 +612,18 @@
4153 """
4154 default_name = 'Balance report / Previous Fiscal Year'
4155
4156+ # DONE: TEST JN => behavior unchanged (use of clearer date name for the source date)
4157 vals = {
4158 'account_id': account_id,
4159 'company_id': cpy_rec.id,
4160 'currency_id': ccy_id,
4161- 'date': posting_date,
4162- 'document_date': posting_date,
4163+ 'date': first_day_next_fy,
4164+ 'document_date': first_day_next_fy,
4165 'instance_id': instance_rec.id,
4166 'journal_id': journal_id,
4167 'name': name or default_name,
4168 'period_id': period_id,
4169- 'source_date': posting_date,
4170+ 'source_date': first_day_next_fy,
4171
4172 'debit_currency': \
4173 balance_currency if balance_currency > 0. else 0.,
4174@@ -664,7 +666,7 @@
4175
4176 fy_year = self._get_fy_year(cr, uid, fy_rec, context=context)
4177 next_fy_id = self._get_next_fy_id(cr, uid, fy_rec, context=context)
4178- posting_date = "%d-01-01" % (fy_year + 1, )
4179+ first_day_next_fy = "%d-01-01" % (fy_year + 1, )
4180
4181 journal_code = 'IB'
4182 journal_id = self._get_journal(cr, uid, journal_code, context=context)
4183
4184=== removed directory 'bin/addons/account_voucher'
4185=== removed file 'bin/addons/account_voucher/__init__.py'
4186--- bin/addons/account_voucher/__init__.py 2011-01-14 00:11:01 +0000
4187+++ bin/addons/account_voucher/__init__.py 1970-01-01 00:00:00 +0000
4188@@ -1,27 +0,0 @@
4189-# -*- coding: utf-8 -*-
4190-##############################################################################
4191-#
4192-# OpenERP, Open Source Management Solution
4193-# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
4194-#
4195-# This program is free software: you can redistribute it and/or modify
4196-# it under the terms of the GNU Affero General Public License as
4197-# published by the Free Software Foundation, either version 3 of the
4198-# License, or (at your option) any later version.
4199-#
4200-# This program is distributed in the hope that it will be useful,
4201-# but WITHOUT ANY WARRANTY; without even the implied warranty of
4202-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
4203-# GNU Affero General Public License for more details.
4204-#
4205-# You should have received a copy of the GNU Affero General Public License
4206-# along with this program. If not, see <http://www.gnu.org/licenses/>.
4207-#
4208-##############################################################################
4209-
4210-import account_voucher
4211-import invoice
4212-import report
4213-import wizard
4214-
4215-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
4216\ No newline at end of file
4217
4218=== removed file 'bin/addons/account_voucher/__openerp__.py'
4219--- bin/addons/account_voucher/__openerp__.py 2017-10-04 05:23:42 +0000
4220+++ bin/addons/account_voucher/__openerp__.py 1970-01-01 00:00:00 +0000
4221@@ -1,60 +0,0 @@
4222-# -*- coding: utf-8 -*-
4223-##############################################################################
4224-#
4225-# OpenERP, Open Source Management Solution
4226-# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
4227-#
4228-# This program is free software: you can redistribute it and/or modify
4229-# it under the terms of the GNU Affero General Public License as
4230-# published by the Free Software Foundation, either version 3 of the
4231-# License, or (at your option) any later version.
4232-#
4233-# This program is distributed in the hope that it will be useful,
4234-# but WITHOUT ANY WARRANTY; without even the implied warranty of
4235-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
4236-# GNU Affero General Public License for more details.
4237-#
4238-# You should have received a copy of the GNU Affero General Public License
4239-# along with this program. If not, see <http://www.gnu.org/licenses/>.
4240-#
4241-##############################################################################
4242-
4243-{
4244- "name" : "Accounting Voucher Entries",
4245- "version" : "1.0",
4246- "author" : 'OpenERP SA',
4247- "description": """Account Voucher module includes all the basic requirements of
4248- Voucher Entries for Bank, Cash, Sales, Purchase, Expanse, Contra, etc...
4249- * Voucher Entry
4250- * Voucher Receipt
4251- * Cheque Register
4252- """,
4253- "category" : "Generic Modules/Accounting",
4254- "website" : "http://tinyerp.com",
4255- "depends" : ["account"],
4256- "init_xml" : [],
4257-
4258- "demo_xml" : [],
4259-
4260- "update_xml" : [
4261- "security/ir.model.access.csv",
4262- "account_voucher_sequence.xml",
4263- "account_voucher_workflow.xml",
4264- "account_voucher_report.xml",
4265- "wizard/account_voucher_unreconcile_view.xml",
4266- "wizard/account_statement_from_invoice_view.xml",
4267- "account_voucher_view.xml",
4268- "voucher_payment_receipt_view.xml",
4269- "voucher_sales_purchase_view.xml",
4270- "account_voucher_wizard.xml",
4271- "report/account_voucher_sales_receipt_view.xml",
4272- "security/account_voucher_security.xml"
4273- ],
4274- "test" : [
4275- ],
4276- 'certificate': '0037580727101',
4277- "active": False,
4278- "installable": True,
4279-}
4280-
4281-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
4282
4283=== removed file 'bin/addons/account_voucher/account_voucher.py'
4284--- bin/addons/account_voucher/account_voucher.py 2012-06-20 14:19:49 +0000
4285+++ bin/addons/account_voucher/account_voucher.py 1970-01-01 00:00:00 +0000
4286@@ -1,1022 +0,0 @@
4287-# -*- coding: utf-8 -*-
4288-##############################################################################
4289-#
4290-# OpenERP, Open Source Management Solution
4291-# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
4292-#
4293-# This program is free software: you can redistribute it and/or modify
4294-# it under the terms of the GNU Affero General Public License as
4295-# published by the Free Software Foundation, either version 3 of the
4296-# License, or (at your option) any later version.
4297-#
4298-# This program is distributed in the hope that it will be useful,
4299-# but WITHOUT ANY WARRANTY; without even the implied warranty of
4300-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
4301-# GNU Affero General Public License for more details.
4302-#
4303-# You should have received a copy of the GNU Affero General Public License
4304-# along with this program. If not, see <http://www.gnu.org/licenses/>.
4305-#
4306-##############################################################################
4307-
4308-import time
4309-from lxml import etree
4310-
4311-import netsvc
4312-from osv import osv, fields
4313-import decimal_precision as dp
4314-from tools.translate import _
4315-
4316-
4317-class account_voucher(osv.osv):
4318-
4319- def _get_type(self, cr, uid, context=None):
4320- if context is None:
4321- context = {}
4322- return context.get('type', False)
4323-
4324- def _get_period(self, cr, uid, context=None):
4325- if context is None: context = {}
4326- if context.get('period_id', False):
4327- return context.get('period_id')
4328- periods = self.pool.get('account.period').find(cr, uid)
4329- return periods and periods[0] or False
4330-
4331- def _get_journal(self, cr, uid, context=None):
4332- if context is None: context = {}
4333- journal_pool = self.pool.get('account.journal')
4334- invoice_pool = self.pool.get('account.invoice')
4335- if context.get('invoice_id', False):
4336- currency_id = invoice_pool.browse(cr, uid, context['invoice_id'], context=context).currency_id.id
4337- journal_id = journal_pool.search(cr, uid, [('currency', '=', currency_id)], limit=1)
4338- return journal_id and journal_id[0] or False
4339- if context.get('journal_id', False):
4340- return context.get('journal_id')
4341- if not context.get('journal_id', False) and context.get('search_default_journal_id', False):
4342- return context.get('search_default_journal_id')
4343-
4344- ttype = context.get('type', 'bank')
4345- if ttype in ('payment', 'receipt'):
4346- ttype = 'bank'
4347- res = journal_pool.search(cr, uid, [('type', '=', ttype)], limit=1)
4348- return res and res[0] or False
4349-
4350- def _get_tax(self, cr, uid, context=None):
4351- if context is None: context = {}
4352- journal_pool = self.pool.get('account.journal')
4353- journal_id = context.get('journal_id', False)
4354- if not journal_id:
4355- ttype = context.get('type', 'bank')
4356- res = journal_pool.search(cr, uid, [('type', '=', ttype)], limit=1)
4357- if not res:
4358- return False
4359- journal_id = res[0]
4360-
4361- if not journal_id:
4362- return False
4363- journal = journal_pool.browse(cr, uid, journal_id, context=context)
4364- account_id = journal.default_credit_account_id or journal.default_debit_account_id
4365- if account_id and account_id.tax_ids:
4366- tax_id = account_id.tax_ids[0].id
4367- return tax_id
4368- return False
4369-
4370- def _get_currency(self, cr, uid, context=None):
4371- if context is None: context = {}
4372- journal_pool = self.pool.get('account.journal')
4373- journal_id = context.get('journal_id', False)
4374- if journal_id:
4375- journal = journal_pool.browse(cr, uid, journal_id, context=context)
4376-# currency_id = journal.company_id.currency_id.id
4377- if journal.currency:
4378- return journal.currency.id
4379- return False
4380-
4381- def _get_partner(self, cr, uid, context=None):
4382- if context is None: context = {}
4383- return context.get('partner_id', False)
4384-
4385- def _get_reference(self, cr, uid, context=None):
4386- if context is None: context = {}
4387- return context.get('reference', False)
4388-
4389- def _get_narration(self, cr, uid, context=None):
4390- if context is None: context = {}
4391- return context.get('narration', False)
4392-
4393- def _get_amount(self, cr, uid, context=None):
4394- if context is None:
4395- context= {}
4396- return context.get('amount', 0.0)
4397-
4398- def name_get(self, cr, uid, ids, context=None):
4399- if not ids:
4400- return []
4401- if context is None: context = {}
4402- return [(r['id'], (str("%.2f" % r['amount']) or '')) for r in self.read(cr, uid, ids, ['amount'], context, load='_classic_write')]
4403-
4404- def fields_view_get(self, cr, uid, view_id=None, view_type=False, context=None, toolbar=False, submenu=False):
4405- mod_obj = self.pool.get('ir.model.data')
4406- if context is None: context = {}
4407-
4408- def get_res_id(view_type, condition):
4409- result = False
4410- if view_type == 'tree':
4411- result = mod_obj.get_object_reference(cr, uid, 'account_voucher', 'view_voucher_tree')
4412- elif view_type == 'form':
4413- if condition:
4414- result = mod_obj.get_object_reference(cr, uid, 'account_voucher', 'view_vendor_receipt_form')
4415- else:
4416- result = mod_obj.get_object_reference(cr, uid, 'account_voucher', 'view_vendor_payment_form')
4417- return result and result[1] or False
4418-
4419- if not view_id and context.get('invoice_type', False):
4420- view_id = get_res_id(view_type,context.get('invoice_type', False) in ('out_invoice', 'out_refund'))
4421-
4422- if not view_id and context.get('line_type', False):
4423- view_id = get_res_id(view_type,context.get('line_type', False) == 'customer')
4424-
4425- res = super(account_voucher, self).fields_view_get(cr, uid, view_id=view_id, view_type=view_type, context=context, toolbar=toolbar, submenu=submenu)
4426- doc = etree.XML(res['arch'])
4427- nodes = doc.xpath("//field[@name='partner_id']")
4428- if context.get('type', 'sale') in ('purchase', 'payment'):
4429- for node in nodes:
4430- node.set('domain', "[('supplier', '=', True)]")
4431- res['arch'] = etree.tostring(doc)
4432- return res
4433-
4434- def _compute_writeoff_amount(self, cr, uid, line_dr_ids, line_cr_ids, amount):
4435- debit = credit = 0.0
4436- for l in line_dr_ids:
4437- debit += l['amount']
4438- for l in line_cr_ids:
4439- credit += l['amount']
4440- return abs(amount - abs(credit - debit))
4441-
4442- def onchange_line_ids(self, cr, uid, ids, line_dr_ids, line_cr_ids, amount):
4443- if not line_dr_ids and not line_cr_ids:
4444- return {'value':{}}
4445- line_dr_ids = [x[2] for x in line_dr_ids]
4446- line_cr_ids = [x[2] for x in line_cr_ids]
4447- return {'value': {'writeoff_amount': self._compute_writeoff_amount(cr, uid, line_dr_ids, line_cr_ids, amount)}}
4448-
4449- def _get_writeoff_amount(self, cr, uid, ids, name, args, context=None):
4450- if not ids: return {}
4451- res = {}
4452- debit = credit = 0.0
4453- for voucher in self.browse(cr, uid, ids, context=context):
4454- for l in voucher.line_dr_ids:
4455- debit += l.amount
4456- for l in voucher.line_cr_ids:
4457- credit += l.amount
4458- res[voucher.id] = abs(voucher.amount - abs(credit - debit))
4459- return res
4460-
4461- _name = 'account.voucher'
4462- _description = 'Accounting Voucher'
4463- _order = "date desc, id desc"
4464-# _rec_name = 'number'
4465- _columns = {
4466- 'type':fields.selection([
4467- ('sale','Sale'),
4468- ('purchase','Purchase'),
4469- ('payment','Payment'),
4470- ('receipt','Receipt'),
4471- ],'Default Type', readonly=True, states={'draft':[('readonly',False)]}),
4472- 'name':fields.char('Memo', size=256, readonly=True, states={'draft':[('readonly',False)]}),
4473- 'date':fields.date('Date', readonly=True, select=True, states={'draft':[('readonly',False)]}, help="Effective date for accounting entries"),
4474- 'journal_id':fields.many2one('account.journal', 'Journal', required=True, readonly=True, states={'draft':[('readonly',False)]}),
4475- 'account_id':fields.many2one('account.account', 'Account', required=True, readonly=True, states={'draft':[('readonly',False)]}),
4476- 'line_ids':fields.one2many('account.voucher.line','voucher_id','Voucher Lines', readonly=True, states={'draft':[('readonly',False)]}),
4477- 'line_cr_ids':fields.one2many('account.voucher.line','voucher_id','Credits',
4478- domain=[('type','=','cr')], context={'default_type':'cr'}, readonly=True, states={'draft':[('readonly',False)]}),
4479- 'line_dr_ids':fields.one2many('account.voucher.line','voucher_id','Debits',
4480- domain=[('type','=','dr')], context={'default_type':'dr'}, readonly=True, states={'draft':[('readonly',False)]}),
4481- 'period_id': fields.many2one('account.period', 'Period', required=True, readonly=True, states={'draft':[('readonly',False)]}),
4482- 'narration':fields.text('Notes', readonly=True, states={'draft':[('readonly',False)]}),
4483- 'currency_id':fields.many2one('res.currency', 'Currency', readonly=True, states={'draft':[('readonly',False)]}),
4484-# 'currency_id': fields.related('journal_id','currency', type='many2one', relation='res.currency', string='Currency', store=True, readonly=True, states={'draft':[('readonly',False)]}),
4485- 'company_id': fields.many2one('res.company', 'Company', required=True, readonly=True, states={'draft':[('readonly',False)]}),
4486- 'state':fields.selection(
4487- [('draft','Draft'),
4488- ('proforma','Pro-forma'),
4489- ('posted','Posted'),
4490- ('cancel','Cancelled')
4491- ], 'State', readonly=True, size=32,
4492- help=' * The \'Draft\' state is used when a user is encoding a new and unconfirmed Voucher. \
4493- \n* The \'Pro-forma\' when voucher is in Pro-forma state,voucher does not have an voucher number. \
4494- \n* The \'Posted\' state is used when user create voucher,a voucher number is generated and voucher entries are created in account \
4495- \n* The \'Cancelled\' state is used when user cancel voucher.'),
4496- 'amount': fields.float('Total', digits_compute=dp.get_precision('Account'), required=True, readonly=True, states={'draft':[('readonly',False)]}),
4497- 'tax_amount':fields.float('Tax Amount', digits_compute=dp.get_precision('Account'), readonly=True, states={'draft':[('readonly',False)]}),
4498- 'reference': fields.char('Ref #', size=64, readonly=True, states={'draft':[('readonly',False)]}, help="Transaction reference number."),
4499- 'number': fields.char('Number', size=32, readonly=True,),
4500- 'move_id':fields.many2one('account.move', 'Account Entry'),
4501- 'move_ids': fields.related('move_id','line_id', type='one2many', relation='account.move.line', string='Journal Items', readonly=True),
4502- 'partner_id':fields.many2one('res.partner', 'Partner', change_default=1, readonly=True, states={'draft':[('readonly',False)]}),
4503- 'audit': fields.related('move_id','to_check', type='boolean', relation='account.move', string='Audit Complete ?'),
4504- 'pay_now':fields.selection([
4505- ('pay_now','Pay Directly'),
4506- ('pay_later','Pay Later or Group Funds'),
4507- ],'Payment', select=True, readonly=True, states={'draft':[('readonly',False)]}),
4508- 'tax_id':fields.many2one('account.tax', 'Tax', readonly=True, states={'draft':[('readonly',False)]}),
4509- 'pre_line':fields.boolean('Previous Payments ?', required=False),
4510- 'date_due': fields.date('Due Date', readonly=True, select=True, states={'draft':[('readonly',False)]}),
4511- 'payment_option':fields.selection([
4512- ('without_writeoff', 'Keep Open'),
4513- ('with_writeoff', 'Reconcile with Write-Off'),
4514- ], 'Payment Difference', required=True, readonly=True, states={'draft': [('readonly', False)]}),
4515- 'writeoff_acc_id': fields.many2one('account.account', 'Write-Off account', readonly=True, states={'draft': [('readonly', False)]}),
4516- 'comment': fields.char('Write-Off Comment', size=64, required=True, readonly=True, states={'draft': [('readonly', False)]}),
4517- 'analytic_id': fields.many2one('account.analytic.account','Write-Off Analytic Account', readonly=True, states={'draft': [('readonly', False)]}),
4518- 'writeoff_amount': fields.function(_get_writeoff_amount, method=True, string='Write-Off Amount', type='float', readonly=True),
4519- }
4520- _defaults = {
4521- 'period_id': _get_period,
4522- 'partner_id': _get_partner,
4523- 'journal_id':_get_journal,
4524- 'currency_id': _get_currency,
4525- 'reference': _get_reference,
4526- 'narration':_get_narration,
4527- 'amount': _get_amount,
4528- 'type':_get_type,
4529- 'state': 'draft',
4530- 'pay_now': 'pay_later',
4531- 'name': '',
4532- 'date': lambda *a: time.strftime('%Y-%m-%d'),
4533- 'company_id': lambda self,cr,uid,c: self.pool.get('res.company')._company_default_get(cr, uid, 'account.voucher',context=c),
4534- 'tax_id': _get_tax,
4535- 'payment_option': 'without_writeoff',
4536- 'comment': _('Write-Off'),
4537- }
4538-
4539- def compute_tax(self, cr, uid, ids, context=None):
4540- tax_pool = self.pool.get('account.tax')
4541- partner_pool = self.pool.get('res.partner')
4542- position_pool = self.pool.get('account.fiscal.position')
4543- voucher_line_pool = self.pool.get('account.voucher.line')
4544- voucher_pool = self.pool.get('account.voucher')
4545- if context is None: context = {}
4546-
4547- for voucher in voucher_pool.browse(cr, uid, ids, context=context):
4548- voucher_amount = 0.0
4549- for line in voucher.line_ids:
4550- voucher_amount += line.untax_amount or line.amount
4551- line.amount = line.untax_amount or line.amount
4552- voucher_line_pool.write(cr, uid, [line.id], {'amount':line.amount, 'untax_amount':line.untax_amount})
4553-
4554- if not voucher.tax_id:
4555- self.write(cr, uid, [voucher.id], {'amount':voucher_amount, 'tax_amount':0.0})
4556- continue
4557-
4558- tax = [tax_pool.browse(cr, uid, voucher.tax_id.id, context=context)]
4559- partner = partner_pool.browse(cr, uid, voucher.partner_id.id, context=context) or False
4560- taxes = position_pool.map_tax(cr, uid, partner and partner.property_account_position or False, tax)
4561- tax = tax_pool.browse(cr, uid, taxes, context=context)
4562-
4563- total = voucher_amount
4564- total_tax = 0.0
4565-
4566- if not tax[0].price_include:
4567- for tax_line in tax_pool.compute_all(cr, uid, tax, voucher_amount, 1).get('taxes', []):
4568- total_tax += tax_line.get('amount', 0.0)
4569- total += total_tax
4570- else:
4571- for line in voucher.line_ids:
4572- line_total = 0.0
4573- line_tax = 0.0
4574-
4575- for tax_line in tax_pool.compute_all(cr, uid, tax, line.untax_amount or line.amount, 1).get('taxes', []):
4576- line_tax += tax_line.get('amount', 0.0)
4577- line_total += tax_line.get('price_unit')
4578- total_tax += line_tax
4579- untax_amount = line.untax_amount or line.amount
4580- voucher_line_pool.write(cr, uid, [line.id], {'amount':line_total, 'untax_amount':untax_amount})
4581-
4582- self.write(cr, uid, [voucher.id], {'amount':total, 'tax_amount':total_tax})
4583- return True
4584-
4585- def onchange_price(self, cr, uid, ids, line_ids, tax_id, partner_id=False, context=None):
4586- tax_pool = self.pool.get('account.tax')
4587- partner_pool = self.pool.get('res.partner')
4588- position_pool = self.pool.get('account.fiscal.position')
4589- res = {
4590- 'tax_amount': False,
4591- 'amount': False,
4592- }
4593- voucher_total = 0.0
4594- voucher_line_ids = []
4595-
4596- total = 0.0
4597- total_tax = 0.0
4598- for line in line_ids:
4599- line_amount = 0.0
4600- line_amount = line[2] and line[2].get('amount',0.0) or 0.0
4601- voucher_line_ids += [line[1]]
4602- voucher_total += line_amount
4603-
4604- total = voucher_total
4605- total_tax = 0.0
4606- if tax_id:
4607- tax = [tax_pool.browse(cr, uid, tax_id, context=context)]
4608- if partner_id:
4609- partner = partner_pool.browse(cr, uid, partner_id, context=context) or False
4610- taxes = position_pool.map_tax(cr, uid, partner and partner.property_account_position or False, tax)
4611- tax = tax_pool.browse(cr, uid, taxes, context=context)
4612-
4613- if not tax[0].price_include:
4614- for tax_line in tax_pool.compute_all(cr, uid, tax, voucher_total, 1).get('taxes', []):
4615- total_tax += tax_line.get('amount')
4616- total += total_tax
4617-
4618- res.update({
4619- 'amount':total or voucher_total,
4620- 'tax_amount':total_tax
4621- })
4622- return {
4623- 'value':res
4624- }
4625-
4626- def onchange_term_id(self, cr, uid, ids, term_id, amount):
4627- term_pool = self.pool.get('account.payment.term')
4628- terms = False
4629- due_date = False
4630- default = {'date_due':False}
4631- if term_id and amount:
4632- terms = term_pool.compute(cr, uid, term_id, amount)
4633- if terms:
4634- due_date = terms[-1][0]
4635- default.update({
4636- 'date_due':due_date
4637- })
4638- return {'value':default}
4639-
4640- def onchange_journal_voucher(self, cr, uid, ids, line_ids=False, tax_id=False, price=0.0, partner_id=False, journal_id=False, ttype=False, context=None):
4641- """price
4642- Returns a dict that contains new values and context
4643-
4644- @param partner_id: latest value from user input for field partner_id
4645- @param args: other arguments
4646- @param context: context arguments, like lang, time zone
4647-
4648- @return: Returns a dict which contains new values, and context
4649- """
4650- default = {
4651- 'value':{},
4652- }
4653-
4654- if not partner_id or not journal_id:
4655- return default
4656-
4657- partner_pool = self.pool.get('res.partner')
4658- journal_pool = self.pool.get('account.journal')
4659-
4660- journal = journal_pool.browse(cr, uid, journal_id, context=context)
4661- partner = partner_pool.browse(cr, uid, partner_id, context=context)
4662- account_id = False
4663- tr_type = False
4664- if journal.type in ('sale','sale_refund'):
4665- account_id = partner.property_account_receivable.id
4666- tr_type = 'sale'
4667- elif journal.type in ('purchase', 'purchase_refund','expense'):
4668- account_id = partner.property_account_payable.id
4669- tr_type = 'purchase'
4670- else:
4671- account_id = journal.default_credit_account_id.id or journal.default_debit_account_id.id
4672- tr_type = 'receipt'
4673-
4674- default['value']['account_id'] = account_id
4675- default['value']['type'] = ttype or tr_type
4676-
4677- vals = self.onchange_journal(cr, uid, ids, journal_id, line_ids, tax_id, partner_id, context)
4678- default['value'].update(vals.get('value'))
4679-
4680- return default
4681-
4682- def onchange_partner_id(self, cr, uid, ids, partner_id, journal_id, price, currency_id, ttype, date, context=None):
4683- """price
4684- Returns a dict that contains new values and context
4685-
4686- @param partner_id: latest value from user input for field partner_id
4687- @param args: other arguments
4688- @param context: context arguments, like lang, time zone
4689-
4690- @return: Returns a dict which contains new values, and context
4691- """
4692- if context is None:
4693- context = {}
4694- if not journal_id:
4695- return {}
4696- context_multi_currency = context.copy()
4697- if date:
4698- context_multi_currency.update({'date': date})
4699-
4700- line_pool = self.pool.get('account.voucher.line')
4701- line_ids = ids and line_pool.search(cr, uid, [('voucher_id', '=', ids[0])]) or False
4702- if line_ids:
4703- line_pool.unlink(cr, uid, line_ids)
4704-
4705- currency_pool = self.pool.get('res.currency')
4706- move_line_pool = self.pool.get('account.move.line')
4707- partner_pool = self.pool.get('res.partner')
4708- journal_pool = self.pool.get('account.journal')
4709-
4710- vals = self.onchange_journal(cr, uid, ids, journal_id, [], False, partner_id, context)
4711- vals = vals.get('value')
4712- currency_id = vals.get('currency_id', currency_id)
4713- default = {
4714- 'value':{'line_ids':[], 'line_dr_ids':[], 'line_cr_ids':[], 'pre_line': False, 'currency_id':currency_id},
4715- }
4716-
4717- if not partner_id:
4718- return default
4719-
4720- if not partner_id and ids:
4721- line_ids = line_pool.search(cr, uid, [('voucher_id', '=', ids[0])])
4722- if line_ids:
4723- line_pool.unlink(cr, uid, line_ids)
4724- return default
4725-
4726- journal = journal_pool.browse(cr, uid, journal_id, context=context)
4727- partner = partner_pool.browse(cr, uid, partner_id, context=context)
4728- account_id = False
4729- if journal.type in ('sale','sale_refund'):
4730- account_id = partner.property_account_receivable.id
4731- elif journal.type in ('purchase', 'purchase_refund','expense'):
4732- account_id = partner.property_account_payable.id
4733- else:
4734- account_id = journal.default_credit_account_id.id or journal.default_debit_account_id.id
4735-
4736- default['value']['account_id'] = account_id
4737-
4738- if journal.type not in ('cash', 'bank'):
4739- return default
4740-
4741- total_credit = 0.0
4742- total_debit = 0.0
4743- account_type = 'receivable'
4744- if ttype == 'payment':
4745- account_type = 'payable'
4746- total_debit = price or 0.0
4747- else:
4748- total_credit = price or 0.0
4749- account_type = 'receivable'
4750-
4751- if not context.get('move_line_ids', False):
4752- domain = [('state','=','valid'), ('account_id.type', '=', account_type), ('reconcile_id', '=', False), ('partner_id', '=', partner_id)]
4753- if context.get('invoice_id', False):
4754- domain.append(('invoice', '=', context['invoice_id']))
4755- ids = move_line_pool.search(cr, uid, domain, context=context)
4756- else:
4757- ids = context['move_line_ids']
4758- ids.reverse()
4759- moves = move_line_pool.browse(cr, uid, ids, context=context)
4760-
4761- company_currency = journal.company_id.currency_id.id
4762- if company_currency != currency_id and ttype == 'payment':
4763- total_debit = currency_pool.compute(cr, uid, currency_id, company_currency, total_debit, context=context_multi_currency)
4764- elif company_currency != currency_id and ttype == 'receipt':
4765- total_credit = currency_pool.compute(cr, uid, currency_id, company_currency, total_credit, context=context_multi_currency)
4766-
4767- for line in moves:
4768- if line.credit and line.reconcile_partial_id and ttype == 'receipt':
4769- continue
4770- if line.debit and line.reconcile_partial_id and ttype == 'payment':
4771- continue
4772- total_credit += line.credit or 0.0
4773- total_debit += line.debit or 0.0
4774- for line in moves:
4775- if line.credit and line.reconcile_partial_id and ttype == 'receipt':
4776- continue
4777- if line.debit and line.reconcile_partial_id and ttype == 'payment':
4778- continue
4779- original_amount = line.credit or line.debit or 0.0
4780- amount_unreconciled = currency_pool.compute(cr, uid, line.currency_id and line.currency_id.id or company_currency, currency_id, abs(line.amount_residual_currency), context=context_multi_currency)
4781- rs = {
4782- 'name':line.move_id.name,
4783- 'type': line.credit and 'dr' or 'cr',
4784- 'move_line_id':line.id,
4785- 'account_id':line.account_id.id,
4786- 'amount_original': currency_pool.compute(cr, uid, line.currency_id and line.currency_id.id or company_currency, currency_id, line.currency_id and abs(line.amount_currency) or original_amount, context=context_multi_currency),
4787- 'date_original':line.date,
4788- 'date_due':line.date_maturity,
4789- 'amount_unreconciled': amount_unreconciled,
4790- }
4791-
4792- if line.credit:
4793- amount = min(amount_unreconciled, currency_pool.compute(cr, uid, company_currency, currency_id, abs(total_debit), context=context_multi_currency))
4794- rs['amount'] = amount
4795- total_debit -= amount
4796- else:
4797- amount = min(amount_unreconciled, currency_pool.compute(cr, uid, company_currency, currency_id, abs(total_credit), context=context_multi_currency))
4798- rs['amount'] = amount
4799- total_credit -= amount
4800-
4801- default['value']['line_ids'].append(rs)
4802- if rs['type'] == 'cr':
4803- default['value']['line_cr_ids'].append(rs)
4804- else:
4805- default['value']['line_dr_ids'].append(rs)
4806-
4807- if ttype == 'payment' and len(default['value']['line_cr_ids']) > 0:
4808- default['value']['pre_line'] = 1
4809- elif ttype == 'receipt' and len(default['value']['line_dr_ids']) > 0:
4810- default['value']['pre_line'] = 1
4811- default['value']['writeoff_amount'] = self._compute_writeoff_amount(cr, uid, default['value']['line_dr_ids'], default['value']['line_cr_ids'], price)
4812-
4813- return default
4814-
4815- def onchange_date(self, cr, uid, ids, partner_id, journal_id, price, currency_id, ttype, date, context=None):
4816- """
4817- @param date: latest value from user input for field date
4818- @param args: other arguments
4819- @param context: context arguments, like lang, time zone
4820- @return: Returns a dict which contains new values, and context
4821- """
4822- period_pool = self.pool.get('account.period')
4823- res = self.onchange_partner_id(cr, uid, ids, partner_id, journal_id, price, currency_id, ttype, date, context=context)
4824- pids = period_pool.search(cr, uid, [('date_start', '<=', date), ('date_stop', '>=', date)])
4825- if pids:
4826- if not 'value' in res:
4827- res['value'] = {}
4828- res['value'].update({'period_id':pids[0]})
4829- return res
4830-
4831- def onchange_journal(self, cr, uid, ids, journal_id, line_ids, tax_id, partner_id, context=None):
4832- if not journal_id:
4833- return False
4834- journal_pool = self.pool.get('account.journal')
4835- journal = journal_pool.browse(cr, uid, journal_id, context=context)
4836- account_id = journal.default_credit_account_id or journal.default_debit_account_id
4837- tax_id = False
4838- if account_id and account_id.tax_ids:
4839- tax_id = account_id.tax_ids[0].id
4840-
4841- vals = self.onchange_price(cr, uid, ids, line_ids, tax_id, partner_id, context)
4842- vals['value'].update({'tax_id':tax_id})
4843- currency_id = journal.company_id.currency_id.id
4844- if journal.currency:
4845- currency_id = journal.currency.id
4846- vals['value'].update({'currency_id':currency_id})
4847- return vals
4848-
4849- def proforma_voucher(self, cr, uid, ids, context=None):
4850- self.action_move_line_create(cr, uid, ids, context=context)
4851- return True
4852-
4853- def action_cancel_draft(self, cr, uid, ids, context=None):
4854- wf_service = netsvc.LocalService("workflow")
4855- for voucher_id in ids:
4856- wf_service.trg_create(uid, 'account.voucher', voucher_id, cr)
4857- self.write(cr, uid, ids, {'state':'draft'})
4858- return True
4859-
4860- def cancel_voucher(self, cr, uid, ids, context=None):
4861- reconcile_pool = self.pool.get('account.move.reconcile')
4862- move_pool = self.pool.get('account.move')
4863-
4864- for voucher in self.browse(cr, uid, ids, context=context):
4865- recs = []
4866- for line in voucher.move_ids:
4867- if line.reconcile_id:
4868- recs += [line.reconcile_id.id]
4869- if line.reconcile_partial_id:
4870- recs += [line.reconcile_partial_id.id]
4871-
4872- reconcile_pool.unlink(cr, uid, recs)
4873-
4874- if voucher.move_id:
4875- move_pool.button_cancel(cr, uid, [voucher.move_id.id])
4876- move_pool.unlink(cr, uid, [voucher.move_id.id])
4877- res = {
4878- 'state':'cancel',
4879- 'move_id':False,
4880- }
4881- self.write(cr, uid, ids, res)
4882- return True
4883-
4884- def unlink(self, cr, uid, ids, context=None):
4885- for t in self.read(cr, uid, ids, ['state'], context=context):
4886- if t['state'] not in ('draft', 'cancel'):
4887- raise osv.except_osv(_('Invalid action !'), _('Cannot delete Voucher(s) which are already opened or paid !'))
4888- return super(account_voucher, self).unlink(cr, uid, ids, context=context)
4889-
4890- # TODO: may be we can remove this method if not used anyware
4891- def onchange_payment(self, cr, uid, ids, pay_now, journal_id, partner_id, ttype='sale'):
4892- res = {}
4893- if not partner_id:
4894- return res
4895- res = {'account_id':False}
4896- partner_pool = self.pool.get('res.partner')
4897- journal_pool = self.pool.get('account.journal')
4898- if pay_now == 'pay_later':
4899- partner = partner_pool.browse(cr, uid, partner_id)
4900- journal = journal_pool.browse(cr, uid, journal_id)
4901- if journal.type in ('sale','sale_refund'):
4902- account_id = partner.property_account_receivable.id
4903- elif journal.type in ('purchase', 'purchase_refund','expense'):
4904- account_id = partner.property_account_payable.id
4905- else:
4906- account_id = journal.default_credit_account_id.id or journal.default_debit_account_id.id
4907- res['account_id'] = account_id
4908- return {'value':res}
4909-
4910- def __hook_move_line_values_before_creation(self, cr, uid, move_line):
4911- """
4912- Change move line vals before its creation
4913- """
4914- return move_line
4915-
4916- def action_move_line_create(self, cr, uid, ids, context=None):
4917-
4918- def _get_payment_term_lines(term_id, amount):
4919- term_pool = self.pool.get('account.payment.term')
4920- if term_id and amount:
4921- terms = term_pool.compute(cr, uid, term_id, amount)
4922- return terms
4923- return False
4924- if context is None:
4925- context = {}
4926- move_pool = self.pool.get('account.move')
4927- move_line_pool = self.pool.get('account.move.line')
4928- currency_pool = self.pool.get('res.currency')
4929- tax_obj = self.pool.get('account.tax')
4930- seq_obj = self.pool.get('ir.sequence')
4931- for inv in self.browse(cr, uid, ids, context=context):
4932- if inv.move_id:
4933- continue
4934- context_multi_currency = context.copy()
4935- context_multi_currency.update({'date': inv.date})
4936-
4937- if inv.number:
4938- name = inv.number
4939- elif inv.journal_id.sequence_id:
4940- name = seq_obj.get_id(cr, uid, inv.journal_id.sequence_id.id)
4941- else:
4942- raise osv.except_osv(_('Error !'), _('Please define a sequence on the journal !'))
4943- if not inv.reference:
4944- ref = name.replace('/','')
4945- else:
4946- ref = inv.reference
4947-
4948- move = {
4949- 'name': name,
4950- 'journal_id': inv.journal_id.id,
4951- 'narration': inv.narration,
4952- 'date': inv.date,
4953- 'ref': ref,
4954- 'period_id': inv.period_id and inv.period_id.id or False
4955- }
4956- move_id = move_pool.create(cr, uid, move)
4957-
4958- #create the first line manually
4959- company_currency = inv.journal_id.company_id.currency_id.id
4960- current_currency = inv.currency_id.id
4961- debit = 0.0
4962- credit = 0.0
4963- # TODO: is there any other alternative then the voucher type ??
4964- # -for sale, purchase we have but for the payment and receipt we do not have as based on the bank/cash journal we can not know its payment or receipt
4965- if inv.type in ('purchase', 'payment'):
4966- credit = currency_pool.compute(cr, uid, current_currency, company_currency, inv.amount, context=context_multi_currency)
4967- elif inv.type in ('sale', 'receipt'):
4968- debit = currency_pool.compute(cr, uid, current_currency, company_currency, inv.amount, context=context_multi_currency)
4969- if debit < 0:
4970- credit = -debit
4971- debit = 0.0
4972- if credit < 0:
4973- debit = -credit
4974- credit = 0.0
4975- sign = debit - credit < 0 and -1 or 1
4976- #create the first line of the voucher
4977- move_line = {
4978- 'name': inv.name or '/',
4979- 'debit': debit,
4980- 'credit': credit,
4981- 'account_id': inv.account_id.id,
4982- 'move_id': move_id,
4983- 'journal_id': inv.journal_id.id,
4984- 'period_id': inv.period_id.id,
4985- 'partner_id': inv.partner_id.id,
4986- 'currency_id': company_currency <> current_currency and current_currency or False,
4987- 'amount_currency': company_currency <> current_currency and sign * inv.amount or 0.0,
4988- 'date': inv.date,
4989- 'date_maturity': inv.date_due
4990- }
4991- move_line = self.__hook_move_line_values_before_creation(cr, uid, move_line)
4992- move_line_pool.create(cr, uid, move_line)
4993- rec_list_ids = []
4994- line_total = debit - credit
4995- if inv.type == 'sale':
4996- line_total = line_total - currency_pool.compute(cr, uid, inv.currency_id.id, company_currency, inv.tax_amount, context=context_multi_currency)
4997- elif inv.type == 'purchase':
4998- line_total = line_total + currency_pool.compute(cr, uid, inv.currency_id.id, company_currency, inv.tax_amount, context=context_multi_currency)
4999-
5000- for line in inv.line_ids:
The diff has been truncated for viewing.

Subscribers

People subscribed via source and target branches