Merge lp:~therp-nl/account-banking/upgrade-6.0 into lp:account-banking
- upgrade-6.0
- Merge into trunk
Status: | Needs review | ||||||||
---|---|---|---|---|---|---|---|---|---|
Proposed branch: | lp:~therp-nl/account-banking/upgrade-6.0 | ||||||||
Merge into: | lp:account-banking | ||||||||
Diff against target: |
3078 lines (+1102/-1099) (has conflicts) 32 files modified
THIS_BRANCH_IS_DEPRECATED.txt (+3/-0) account_banking/__terp__.py (+3/-55) account_banking/account_banking.py (+260/-269) account_banking/account_banking_import_wizard.xml (+0/-15) account_banking/account_banking_payment_wizard.xml (+0/-22) account_banking/account_banking_view.xml (+106/-18) account_banking/data/account_banking_data.xml (+2/-2) account_banking/security/ir.model.access.csv (+2/-0) account_banking/wizard/__init__.py (+1/-1) account_banking/wizard/account_payment_order.py (+113/-0) account_banking/wizard/bank_import.py (+149/-137) account_banking/wizard/bank_import_view.xml (+52/-0) account_banking/wizard/banktools.py (+24/-16) account_banking/wizard/wizard_payment_order.py (+0/-212) account_banking_fi_patu/__terp__.py (+2/-3) account_banking_nl_abnamro/__openerp__.py (+2/-8) account_banking_nl_abnamro/__terp__.py (+2/-8) account_banking_nl_clieop/__terp__.py (+8/-6) account_banking_nl_clieop/account_banking_export_wizard.xml (+0/-15) account_banking_nl_clieop/account_banking_nl_clieop.py (+7/-13) account_banking_nl_clieop/account_banking_nl_clieop.xml (+36/-13) account_banking_nl_clieop/data/banking_export_clieop.xml (+9/-3) account_banking_nl_clieop/migrations/0.63/post-fill-ir_model_id.py (+44/-0) account_banking_nl_clieop/security/ir.model.access.csv (+2/-0) account_banking_nl_clieop/wizard/clieop.py (+2/-2) account_banking_nl_clieop/wizard/export_clieop.py (+204/-249) account_banking_nl_clieop/wizard/export_clieop_view.xml (+58/-0) account_banking_nl_girotel/__terp__.py (+2/-3) account_banking_nl_multibank/__terp__.py (+2/-3) account_banking_nl_triodos/__openerp__.py (+2/-13) account_banking_nl_triodos/__terp__.py (+2/-13) account_banking_nl_triodos/triodos.py (+3/-0) Text conflict in account_banking/account_banking.py Text conflict in account_banking/account_banking_view.xml Text conflict in account_banking/wizard/bank_import.py Text conflict in account_banking_nl_clieop/__terp__.py |
||||||||
To merge this branch: | bzr merge lp:~therp-nl/account-banking/upgrade-6.0 | ||||||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Stefan Rijnhart (Opener) (community) | Needs Resubmitting | ||
Pieter J. Kersten (EduSense BV) | Needs Fixing | ||
Review via email: mp+59146@code.launchpad.net |
Commit message
Description of the change
Hi Pieter,
this branch is a migration of account_banking to OpenERP 6.0. Below is a short description of the modifications. Given the size of the update, I suspect we will be in touch about this merge.
Regards,
Stefan.
* Account Banking
Migration to OpenERP 6.0
---
Adapt to changes in models of account and account_payment
Adapt to changes in xml view definitions
Restore payment.type functionality from version 5 as payment.mode.type
Restore launch_wizard functionality from version 5
Migrate changes from button_confirm() in v5 to create_
Store reference to reconciliation on transaction line
Make old style wizards work properly in GTK and web client
Change journal domains to type=bank
Additional changes:
- Fixes incomplete reconciliations being generated due to account.move.line "line_id" vs. "line_ids' confusion
- Fix bug where a matching invoice is "found" as many times as the number of addresses a partner has
- Fix error in German BBAN format (does not have a trailing check digit)
* Clieop module
Migration to OpenERP 6.0
---
Adapt payment.typea to payment.mode.type
Make old style wizards work properly in GTK and web client
Additional changes:
---
Payment order status now remains unchanged when a test clieop is generated
To avoid confusion between saving the clieop file and finishing the wizard,
the 'Save' button and label have been changed to 'OK/Finish'.
Pieter J. Kersten (EduSense BV) (pieterj) wrote : | # |
Pieter J. Kersten (EduSense BV) (pieterj) wrote : | # |
BTW, if that wasn't obvious to you already, great job!
Stefan Rijnhart (Opener) (stefan-opener) wrote : | # |
Hi Pieter,
again, thank you for your fast and perceptive response! I agree with
most of your remarks. Please find some additional comments below.
On 27-04-11 12:30, Pieter J. Kersten (EduSense BV) wrote:
> Generic:
> I can see a lot of technical improvements for v6. However, there were
> more changes than just the technical ones. For starters, v6 introduced
> the voucher layer between account and account_payment. I'm missing
> this in your proposal. Is this code used in production? If so,
> what are the experiences? How does it coexist/cooperate with the
> payment/voucher system?
This code is used in a couple of small setups. We knowingly ignored
account_voucher for this version in order to simplify verification of
the operation of the migrated code. The process of payments (through
payment orders) and bank reconciliation works fine without it, but a
logical next step would be looking at integrating account_voucher.
> account_
> Not sure if this is an improvement. I'll leave it for now.
>
We felt the error was a bit too harsh on the account number, given the
poor performance of the online iban service for Dutch bank accounts. It
is a matter of taste. We will be looking at integrating a paid service
for iban/bic lookups.
> account_
> This change is not conform specs. Any sources I can check for this?
> Will leave it untill more info arrives.
This change was triggered by a real transaction. We looked to Wikipedia
for confirmation
(http://
German bbank as 18n, no check digit). Ecbs has the length listed as 18!n
as well (http://
> account_
> This is unneeded. You don't use it anywhere. Won't take it.
>
No, it is used in line 931, although I did not introduce it.
> account_
> Can't see any value in this change. Just make sure that
> isinstance(
> which must be done in the import parsers.
In the ABNAmro filter the remote owner, but not the remote_account is
retrieved in case of a payment terminal transaction. I would rather
check here than having to initialize remote_account as an empty string.
> account_
> Ok, backporting the unique construct to v5.
> Having some difficulties with the defensive field resolving code.
> Is this really needed? Never faced any problems with it.
Yes, if we take requiredness into account, some checks are superfluous.
I would suggest to just keep
user.
user.company_
> account_
> What is the purpose of these changes?
> I can't see a semantic value for a catch-all 'UNKNOWN' bank.
> Problem is, when the bank gets known, chances are it won't be
> the same as "the other" accounts with UNKNOWN tied to it.
> Better leave ...
Pieter J. Kersten (EduSense BV) (pieterj) wrote : | # |
Hi Stefan,
Thanks for your answers. I've adapted some changes to ABF in order to
address some of your remarks.
Most notably:
1. Adapted German localized BBAN format
2. Changed model members to default to str (makes
isinstance(
3. Reactivated apparently untested path in wizard.
4. Added more remarks to parser template regarding numbering issues
(prevent future discussions)
Can you please pull these, remove your visual/style changes and create a
new merge proposal?
One question remains: What is your definition of "poor performance"
regarding the online Dutch IBAN/BIC convertor?
BTW, I'm not sure if paying will enhance the data quality. Most paid
services simply calculate their responses.
With your new proposal, I will check ABF's cooperation with
vouchers/payments. I'm interested to see how it behaves.
I was already planning on updating ABF to face the new semantics. This
looks like a welcome jump start.
BTW, I'll start a new branch for this, in order to allow backports to v5.
TIA,
--
Pieter J. Kersten
*T:* +31 630 230208
*KvK:* 08178777
Logo EduSense B.V. <http://
Op 28-04-11 08:55 schreef Stefan Rijnhart (Therp):
> Hi Pieter,
>
> again, thank you for your fast and perceptive response! I agree with
> most of your remarks. Please find some additional comments below.
>
>
> On 27-04-11 12:30, Pieter J. Kersten (EduSense BV) wrote:
>> Generic:
>> I can see a lot of technical improvements for v6. However, there were
>> more changes than just the technical ones. For starters, v6 introduced
>> the voucher layer between account and account_payment. I'm missing
>> this in your proposal. Is this code used in production? If so,
>> what are the experiences? How does it coexist/cooperate with the
>> payment/voucher system?
> This code is used in a couple of small setups. We knowingly ignored
> account_voucher for this version in order to simplify verification of
> the operation of the migrated code. The process of payments (through
> payment orders) and bank reconciliation works fine without it, but a
> logical next step would be looking at integrating account_voucher.
>
>> account_
>> Not sure if this is an improvement. I'll leave it for now.
>>
> We felt the error was a bit too harsh on the account number, given the
> poor performance of the online iban service for Dutch bank accounts. It
> is a matter of taste. We will be looking at integrating a paid service
> for iban/bic lookups.
>
>> account_
>> This change is not conform specs. Any sources I can check for this?
>> Will leave it untill more info arrives.
> This change was triggered by a real transaction. We looked to Wikipedia
> for confirmation
> (http://
> German bbank as 18n, no check digit). Ecbs has the length listed as 18!n
> as well (http://
>
>> account_
>> This is unneeded. You don't use it anywhere. Won't take it.
>>
> N...
Stefan Rijnhart (Opener) (stefan-opener) wrote : | # |
On 28-04-11 10:13, Pieter J. Kersten (EduSense BV) wrote:
> One question remains: What is your definition of "poor performance"
> regarding the online Dutch IBAN/BIC convertor?
We encountered a number of unrecognized bank accounts, most notably the
bank account of the Chamber of Commerce in our region as well as some of
the customers' Triodos accounts. The prominence of these accounts
naturally influenced our appreciation of the online service's performance.
Regards,
Stefan.
--
Therp - Maatwerk in open ontwikkeling
Stefan Rijnhart - Ontwerp en implementatie
mail: <email address hidden>
tel: +31 (0) 614478606
web: http://
Jan Verlaan (jan-verlaan) wrote : | # |
Hope to see 2 versions in future, one for V5 and one for V6.
Merging only the upgrade to V6 would leave only a version for V6, while several users will stay on V5 for the next years.
Pieter J. Kersten (EduSense BV) (pieterj) wrote : | # |
This will be the case.
--
Pieter J. Kersten
Op 29-04-11 15:38 schreef Jan Verlaan (Veritos):
> Hope to see 2 versions in future, one for V5 and one for V6.
> Merging only the upgrade to V6 would leave only a version for V6, while several users will stay on V5 for the next years.
- 60. By Stefan Rijnhart (Opener)
-
[MRG] backports from previous merge request
- 61. By Stefan Rijnhart (Opener)
-
Undo style changes and changes in error messages
- 62. By Stefan Rijnhart (Opener)
-
[FIX] Cannot use storage trigger on field 'id'
Stefan Rijnhart (Opener) (stefan-opener) wrote : | # |
Hi Pieter,
Your backports have been merged in this branch.
I have kept assigning code 'UNKNOW' to unknown banks. The reference to res_bank is required for res_partner_banks in 6.0. Without this modification a multitude of unknown banks can get accumulated.
You might still want to look at the following changes for backporting to v5:
account_
account_
Regards,
Stefan.
Pieter J. Kersten (EduSense BV) (pieterj) wrote : | # |
Hi Stefan,
Thanks for the two typos I left open during v5 backport.
I've reviewed the patch for v6. There are a few issues I can see for now.
1. The domains in the forms are too restrictive in its current form. The 'suitable_
2. I can see how changing state on payment orders during testing of ClieOp can mess things up, but not being able to save it at all is a bit too restrictive for me. Preventing switching states when saving test batches should do just fine.
3. Instead of using a catch all bank, I prefer to have an optional relationship between res_partner_bank and res_bank. This way you can relax requirements. The current layout of res_bank is too biased for Belgian and German usage anyway - a bank code is required, which is not even known in some countries, including the Netherlands. You could add a constraint to require a valid bank when code is filled in order to prevent regression for bankcode-users.
BTW, I've reserved trunk for v6.0 development from now on.
Stefan Rijnhart (Opener) (stefan-opener) wrote : | # |
Hi Pieter,
Thank you for your comments. I hope you will accept the clarifications
below.
On 05-05-11 17:11, Pieter J. Kersten (EduSense BV) wrote:
> 1. The domains in the forms are too restrictive in its current form. The 'suitable_
My notion here is that you may be mislead by the domains for journals
which I have modified. OpenERP 6 separated cash and bank journals by
introducing a new type 'bank' in addition to 'cash'. I have modified the
code accordingly.
As for suitable bank types, I took a shortcut and had done away with
them at all as I was trying to find out the current status of the
payment_order module. It seemed to be blocking all payment orders
because its method suitable_
under any condition. I modified it to always return all bank types,
which seemed to solve the problem that no bank account was ever selected
for the payment order lines. Having another look now, the real cause
appears to be the pretty awful implementation of line2bank() in the
original payment_order module which initializes all keys in the
dictionary to False and then only provides a meaningful value if a key
is not in the dictionary.
That insight gives me with the key to implement the notion of suitable
bank types in this branch after all. I will have a go at that in the
next couple of weeks.
> 2. I can see how changing state on payment orders during testing of ClieOp can mess things up, but not being able to save it at all is a bit too restrictive for me. Preventing switching states when saving test batches should do just fine.
That was exactly my intent, and if I am not mistaken the code does just
that. Files are available for download in the wizard and afterwards in
the list of generated clieop files.
> 3. Instead of using a catch all bank, I prefer to have an optional relationship between res_partner_bank and res_bank. This way you can relax requirements. The current layout of res_bank is too biased for Belgian and German usage anyway - a bank code is required, which is not even known in some countries, including the Netherlands. You could add a constraint to require a valid bank when code is filled in order to prevent regression for bankcode-users.
As the res.bank on res.partner.bank is required in the base module, it
is reasonable for developers to expect this field to be defined on the
object. Such code already lives in the module l10n_ch. I would hate to
introduce instability by creating resources of type res.partner.bank
without a res.bank. Note that, in a previous mail, we ourselves agreed
to apply defensive object browsing only to complement requiredness of
fields. As such, I would rather not follow your suggestion.
Kind regards,
Stefan.
--
Therp - Maatwerk in open ontwikkeling
Stefan Rijnhart - Ontwerp en imple...
- 63. By Stefan Rijnhart (Opener)
-
[MRG] fixes from parent branch already included in this branch
- 64. By Stefan Rijnhart (Opener)
-
[IMP] Restores suitable bank types functionality similar to V5
Stefan Rijnhart (Opener) (stefan-opener) wrote : | # |
Hi Pieter,
the branch has been updated with functionality for suitable bank type matching when filling payment orders. Support for this in account_payment is derelict, so I had to include some adaptations to the code in this module.
Cheers,
Stefan.
Stefan Rijnhart (Opener) (stefan-opener) wrote : | # |
Hi Pieter,
it has been a month since my last resubmit. Have you had a chance to review?
Cheers,
Stefan.
- 65. By Stefan Rijnhart (Opener)
-
[REF] Import wizard is now a new style (osv_memory) wizard
- 66. By Stefan Rijnhart (Opener)
-
[REF] Payment wizards are now new style (osv_memory) wizards
[FIX] Allow for ClieOp export with empty reference - 67. By Stefan Rijnhart (Opener)
-
[IMP] Provide upgrade path for the previously pushed revision
[FIX] Layout change in the Triodos CSV format (account numbers)
Stefan Rijnhart (Opener) (stefan-opener) wrote : | # |
Hi Pieter,
the wizards have now been migrated to osv_memory. As a side effect, this makes dynamically selecting the payment wizard much more transparent.
An upgrade path for early adopters of this branch is provided (in nl_clieop/
Regards,
Stefan.
Stefan Rijnhart (Opener) (stefan-opener) wrote : | # |
Forgot to mention that a small functional change has been made in the latest revisions: the field 'payment_order_ids' on banking.
- 68. By Stefan Rijnhart (Opener)
-
[FIX] Take moves from new refund journal types into account when matching transactions
Chris Halls (halls) wrote : | # |
credativ is working on porting this to 6.1. I have already been in contact with Stefan to check we are not duplicating existing work.
Erwin van der Linde (erwin-7) wrote : | # |
> credativ is working on porting this to 6.1. I have already been in contact
> with Stefan to check we are not duplicating existing work.
Dear Chris / Stefan,
Is there any update info on the porting matter?
Thanks in advance!
Cheers,
Erwin
Chris Halls (halls) wrote : | # |
> Is there any update info on the porting matter?
Hi Erwin
We've had to revert back to 6.0 because of the delayed 6.1 release, but we do already have a number of changes. As far as I remember, we haven't yet completely sorted out how to specify bank accounts using the new combined account number + IBAN format. Would you like us to put the changes we have so far somewhere for you to look at?
Chris
Stefanr (stefan-stefanlinux) wrote : | # |
On 10/25/2011 11:09 AM, Chris Halls (credativ) wrote:
>> Is there any update info on the porting matter?
> Hi Erwin
>
> We've had to revert back to 6.0 because of the delayed 6.1 release, but we do already have a number of changes. As far as I remember, we haven't yet completely sorted out how to specify bank accounts using the new combined account number + IBAN format. Would you like us to put the changes we have so far somewhere for you to look at?
>
Hi Chris,
it would be a good idea to put your changes on Launchpad.
Cheers,
Stefan.
- 69. By Stefan Rijnhart (Opener)
-
[FIX] iban read method to accept a single item or a list (Dmitrijs Ledkovs)
- 70. By Stefan Rijnhart (Opener)
-
[FIX] UnboundLocalError: local variable 'payment_lines' referenced before assignment (Dmitrijs Ledkovs)
Dimitri John Ledkov (ex-credativ) (dle-credativ) wrote : | # |
Heya all,
Changes we did for 6.1 are pending to be uploaded to launchpad. I will do it, when I have spare capacity.
For two clients we deployed to we totally ignore vouchers, and it works fine.
Ideally we want a 6.0 & 6.1 branches started and merged as soon as possible preferably as series targets, e.g. lp:account-banking/6.0
I've submitted two bug-fixes which apply to v5 and upgrade-6.0 (merged into upgrade-6.0 already). And we are maintaining our own ~credativ/
Please note that there is a non-working version of account_banking in addons-extra/6.0
Please note that account_banking should conflict with account_
Do any of you have commit access to addons-extra?
Regards,
Dmitrijs.
Stefan Rijnhart (Opener) (stefan-opener) wrote : | # |
>
> Please note that there is a non-working version of account_banking in addons-
> extra/6.0
>
> Do any of you have commit access to addons-extra?
Hi Dmitrijs,
as it turned out, other people have now duplicated some of our work because of these obsolete versions in the extra addons branches, which also turn up on http://
I think the extra addons branches should be obsolete now that you can add any branch on that site, so I removed the account_banking modules from extra-6.0 and extra-trunk completely.
Cheers,
Stefan.
Stefan Rijnhart (Opener) (stefan-opener) wrote : | # |
This branch has been abandoned. Please go to https:/
- 71. By Stefan Rijnhart (Opener)
-
[ADD] Announce deprecation of this branch
Unmerged revisions
- 71. By Stefan Rijnhart (Opener)
-
[ADD] Announce deprecation of this branch
- 70. By Stefan Rijnhart (Opener)
-
[FIX] UnboundLocalError: local variable 'payment_lines' referenced before assignment (Dmitrijs Ledkovs)
- 69. By Stefan Rijnhart (Opener)
-
[FIX] iban read method to accept a single item or a list (Dmitrijs Ledkovs)
- 68. By Stefan Rijnhart (Opener)
-
[FIX] Take moves from new refund journal types into account when matching transactions
- 67. By Stefan Rijnhart (Opener)
-
[IMP] Provide upgrade path for the previously pushed revision
[FIX] Layout change in the Triodos CSV format (account numbers) - 66. By Stefan Rijnhart (Opener)
-
[REF] Payment wizards are now new style (osv_memory) wizards
[FIX] Allow for ClieOp export with empty reference - 65. By Stefan Rijnhart (Opener)
-
[REF] Import wizard is now a new style (osv_memory) wizard
- 64. By Stefan Rijnhart (Opener)
-
[IMP] Restores suitable bank types functionality similar to V5
- 63. By Stefan Rijnhart (Opener)
-
[MRG] fixes from parent branch already included in this branch
- 62. By Stefan Rijnhart (Opener)
-
[FIX] Cannot use storage trigger on field 'id'
Preview Diff
1 | === added file 'THIS_BRANCH_IS_DEPRECATED.txt' | |||
2 | --- THIS_BRANCH_IS_DEPRECATED.txt 1970-01-01 00:00:00 +0000 | |||
3 | +++ THIS_BRANCH_IS_DEPRECATED.txt 2011-11-23 10:40:16 +0000 | |||
4 | @@ -0,0 +1,3 @@ | |||
5 | 1 | This branch has been replaced by lp:banking-addons/6.0 | ||
6 | 2 | |||
7 | 3 | See https://launchpad.net/banking-addons | ||
8 | 0 | 4 | ||
9 | === modified file 'account_banking/__terp__.py' | |||
10 | --- account_banking/__terp__.py 2011-11-08 13:10:34 +0000 | |||
11 | +++ account_banking/__terp__.py 2011-11-23 10:40:16 +0000 | |||
12 | @@ -35,66 +35,14 @@ | |||
13 | 35 | 'update_xml': [ | 35 | 'update_xml': [ |
14 | 36 | 'security/ir.model.access.csv', | 36 | 'security/ir.model.access.csv', |
15 | 37 | 'data/account_banking_data.xml', | 37 | 'data/account_banking_data.xml', |
18 | 38 | 'account_banking_import_wizard.xml', | 38 | 'wizard/bank_import_view.xml', |
17 | 39 | 'account_banking_payment_wizard.xml', | ||
19 | 40 | 'account_banking_view.xml', | 39 | 'account_banking_view.xml', |
20 | 41 | 'account_banking_workflow.xml', | 40 | 'account_banking_workflow.xml', |
21 | 42 | ], | 41 | ], |
22 | 43 | 'demo_xml': [], | 42 | 'demo_xml': [], |
23 | 44 | 'description': ''' | 43 | 'description': ''' |
77 | 45 | Module to do banking. | 44 | Do not install this module. This branch has been replaced by lp:banking-addons/6.0 |
78 | 46 | 45 | See https://launchpad.net/banking-addons | |
26 | 47 | Note: This module is depending on BeautifulSoup. | ||
27 | 48 | |||
28 | 49 | This modules tries to combine all current banking import and export | ||
29 | 50 | schemes. Rationale for this is that it is quite common to have foreign | ||
30 | 51 | bank account numbers next to national bank account numbers. The current | ||
31 | 52 | approach, which hides the national banking interface schemes in the | ||
32 | 53 | l10n_xxx modules, makes it very difficult to use these simultanious. | ||
33 | 54 | A more banking oriented approach seems more logical and cleaner. | ||
34 | 55 | |||
35 | 56 | Changes to default OpenERP: | ||
36 | 57 | |||
37 | 58 | * Puts focus on the real life messaging with banks: | ||
38 | 59 | + Bank statement lines upgraded to independent bank transactions. | ||
39 | 60 | + Banking statements have no special accountancy meaning, they're just | ||
40 | 61 | message envelopes for a number of bank transactions. | ||
41 | 62 | + Bank statements can be either encoded by hand to reflect the document | ||
42 | 63 | version of Bank Statements, or created as an optional side effect of | ||
43 | 64 | importing Bank Transactions. | ||
44 | 65 | |||
45 | 66 | * Preparations for SEPA: | ||
46 | 67 | + IBAN accounts are the standard in the SEPA countries | ||
47 | 68 | + local accounts are derived from SEPA (excluding Turkey) but are | ||
48 | 69 | considered to be identical to the corresponding SEPA account. | ||
49 | 70 | + Banks are identified with either Country + Bank code + Branch code or BIC | ||
50 | 71 | + Each bank can have its own pace in introducing SEPA into their | ||
51 | 72 | communication with their customers. | ||
52 | 73 | + National online databases can be used to convert BBAN's to IBAN's. | ||
53 | 74 | + The SWIFT database is consulted for bank information. | ||
54 | 75 | |||
55 | 76 | * Adds dropin extensible import facility for bank communication in: | ||
56 | 77 | - Drop-in input parser development. | ||
57 | 78 | - MultiBank (NL) format transaction files available as | ||
58 | 79 | account_banking_nl_multibank, | ||
59 | 80 | |||
60 | 81 | * Extends payments for digital banking: | ||
61 | 82 | + Adapted workflow in payments to reflect banking operations | ||
62 | 83 | + Relies on account_payment mechanics to extend with export generators. | ||
63 | 84 | - ClieOp3 (NL) payment and direct debit orders files available as | ||
64 | 85 | account_banking_nl_clieop | ||
65 | 86 | |||
66 | 87 | * Additional features for the import/export mechanism: | ||
67 | 88 | + Automatic matching and creation of bank accounts, banks and partners, | ||
68 | 89 | during import of statements. | ||
69 | 90 | + Automatic matching with invoices and payments. | ||
70 | 91 | + Sound import mechanism, allowing multiple imports of the same | ||
71 | 92 | transactions repeated over multiple files. | ||
72 | 93 | + Journal configuration per bank account. | ||
73 | 94 | + Business logic and format parsing strictly separated to ease the | ||
74 | 95 | development of new parsers. | ||
75 | 96 | + No special configuration needed for the parsers, new parsers are | ||
76 | 97 | recognized and made available at server (re)start. | ||
79 | 98 | ''', | 46 | ''', |
80 | 99 | 'active': False, | 47 | 'active': False, |
81 | 100 | 'installable': True, | 48 | 'installable': True, |
82 | 101 | 49 | ||
83 | === modified file 'account_banking/account_banking.py' | |||
84 | --- account_banking/account_banking.py 2011-11-08 13:10:34 +0000 | |||
85 | +++ account_banking/account_banking.py 2011-11-23 10:40:16 +0000 | |||
86 | @@ -63,6 +63,7 @@ | |||
87 | 63 | from osv import osv, fields | 63 | from osv import osv, fields |
88 | 64 | from tools.translate import _ | 64 | from tools.translate import _ |
89 | 65 | from wizard.banktools import get_or_create_bank | 65 | from wizard.banktools import get_or_create_bank |
90 | 66 | import decimal_precision as dp | ||
91 | 66 | import pooler | 67 | import pooler |
92 | 67 | import netsvc | 68 | import netsvc |
93 | 68 | from tools import config | 69 | from tools import config |
94 | @@ -184,6 +185,60 @@ | |||
95 | 184 | } | 185 | } |
96 | 185 | account_banking_imported_file() | 186 | account_banking_imported_file() |
97 | 186 | 187 | ||
98 | 188 | class payment_mode_type(osv.osv): | ||
99 | 189 | _name= 'payment.mode.type' | ||
100 | 190 | _description= 'Payment Mode Type' | ||
101 | 191 | _columns= { | ||
102 | 192 | 'name': fields.char( | ||
103 | 193 | 'Name', size=64, required=True, | ||
104 | 194 | help='Payment Type' | ||
105 | 195 | ), | ||
106 | 196 | 'code': fields.char( | ||
107 | 197 | 'Code', size=64, required=True, | ||
108 | 198 | help='Specify the Code for Payment Type' | ||
109 | 199 | ), | ||
110 | 200 | # Setting suitable_bank_types to required pending | ||
111 | 201 | # https://bugs.launchpad.net/openobject-addons/+bug/786845 | ||
112 | 202 | 'suitable_bank_types': fields.many2many( | ||
113 | 203 | 'res.partner.bank.type', | ||
114 | 204 | 'bank_type_payment_type_rel', | ||
115 | 205 | 'pay_type_id','bank_type_id', | ||
116 | 206 | 'Suitable bank types', required=True), | ||
117 | 207 | 'ir_model_id': fields.many2one( | ||
118 | 208 | 'ir.model', 'Payment wizard', | ||
119 | 209 | help=('Select the Payment Wizard for payments of this type. ' | ||
120 | 210 | 'Leave empty for manual processing'), | ||
121 | 211 | domain=[('osv_memory', '=', True)], | ||
122 | 212 | ), | ||
123 | 213 | } | ||
124 | 214 | |||
125 | 215 | payment_mode_type() | ||
126 | 216 | |||
127 | 217 | class payment_mode(osv.osv): | ||
128 | 218 | ''' Restoring the payment type from version 5, | ||
129 | 219 | used to select the export wizard (if any) ''' | ||
130 | 220 | _inherit = "payment.mode" | ||
131 | 221 | |||
132 | 222 | def suitable_bank_types(self, cr, uid, payment_mode_id=None, context=None): | ||
133 | 223 | """ Reinstates functional code for suitable bank type filtering. | ||
134 | 224 | Current code in account_payment is disfunctional. | ||
135 | 225 | """ | ||
136 | 226 | res = [] | ||
137 | 227 | payment_mode = self.browse( | ||
138 | 228 | cr, uid, payment_mode_id, context) | ||
139 | 229 | if (payment_mode and payment_mode.type and | ||
140 | 230 | payment_mode.type.suitable_bank_types): | ||
141 | 231 | res = [type.code for type in payment_mode.type.suitable_bank_types] | ||
142 | 232 | return res | ||
143 | 233 | |||
144 | 234 | _columns = { | ||
145 | 235 | 'type': fields.many2one( | ||
146 | 236 | 'payment.mode.type', 'Payment type', | ||
147 | 237 | help='Select the Payment Type for the Payment Mode.' | ||
148 | 238 | ), | ||
149 | 239 | } | ||
150 | 240 | payment_mode() | ||
151 | 241 | |||
152 | 187 | class account_bank_statement(osv.osv): | 242 | class account_bank_statement(osv.osv): |
153 | 188 | ''' | 243 | ''' |
154 | 189 | Extensions from account_bank_statement: | 244 | Extensions from account_bank_statement: |
155 | @@ -265,228 +320,139 @@ | |||
156 | 265 | # ''' | 320 | # ''' |
157 | 266 | # return None | 321 | # return None |
158 | 267 | 322 | ||
181 | 268 | def button_confirm(self, cursor, uid, ids, context=None): | 323 | def create_move_from_st_line(self, cr, uid, st_line_id, |
182 | 269 | ''' | 324 | company_currency_id, st_line_number, |
183 | 270 | Trigger function for button 'Confirm' | 325 | context=None): |
162 | 271 | As this function completely replaces the old one in account, other | ||
163 | 272 | modules who wish to alter behavior of this function but want to | ||
164 | 273 | cooperate with account_banking, should move their functionality to | ||
165 | 274 | |||
166 | 275 | on_button_confirm(self, cursor, uid, ids, context=None) | ||
167 | 276 | |||
168 | 277 | and drop any calls to super() herein. | ||
169 | 278 | In order to allow usage with and without account_banking, one could | ||
170 | 279 | use | ||
171 | 280 | |||
172 | 281 | def on_button_confirm(...): | ||
173 | 282 | # Your code here | ||
174 | 283 | |||
175 | 284 | def button_confirm(...): | ||
176 | 285 | super(my_class, self).button_confirm(...) | ||
177 | 286 | self.on_button_confirm(...) | ||
178 | 287 | |||
179 | 288 | This way, code duplication is minimized. | ||
180 | 289 | ''' | ||
184 | 290 | # This is largely a copy of the original code in account | 326 | # This is largely a copy of the original code in account |
185 | 327 | # Modifications are marked with AB | ||
186 | 291 | # As there is no valid inheritance mechanism for large actions, this | 328 | # As there is no valid inheritance mechanism for large actions, this |
187 | 292 | # is the only option to add functionality to existing actions. | 329 | # is the only option to add functionality to existing actions. |
188 | 293 | # WARNING: when the original code changes, this trigger has to be | 330 | # WARNING: when the original code changes, this trigger has to be |
189 | 294 | # updated in sync. | 331 | # updated in sync. |
191 | 295 | done = [] | 332 | if context is None: |
192 | 333 | context = {} | ||
193 | 296 | res_currency_obj = self.pool.get('res.currency') | 334 | res_currency_obj = self.pool.get('res.currency') |
194 | 297 | res_users_obj = self.pool.get('res.users') | ||
195 | 298 | account_move_obj = self.pool.get('account.move') | 335 | account_move_obj = self.pool.get('account.move') |
196 | 299 | account_move_line_obj = self.pool.get('account.move.line') | 336 | account_move_line_obj = self.pool.get('account.move.line') |
210 | 300 | account_bank_statement_line_obj = \ | 337 | account_bank_statement_line_obj = self.pool.get( |
211 | 301 | self.pool.get('account.bank.statement.line') | 338 | 'account.bank.statement.line') |
212 | 302 | 339 | st_line = account_bank_statement_line_obj.browse(cr, uid, st_line_id, | |
213 | 303 | company_currency_id = res_users_obj.browse(cursor, uid, uid, | 340 | context=context) |
214 | 304 | context=context).company_id.currency_id.id | 341 | st = st_line.statement_id |
215 | 305 | 342 | ||
216 | 306 | for st in self.browse(cursor, uid, ids, context): | 343 | context.update({'date': st_line.date}) |
217 | 307 | if not st.state=='draft': | 344 | period_id = self._get_period( |
218 | 308 | continue | 345 | cr, uid, st_line.date, context=context) # AB |
219 | 309 | 346 | ||
220 | 310 | # Calculate statement balance from the contained lines | 347 | move_id = account_move_obj.create(cr, uid, { |
221 | 311 | end_bal = st.balance_end or 0.0 | 348 | 'journal_id': st.journal_id.id, |
222 | 312 | if not (abs(end_bal - st.balance_end_real) < 0.0001): | 349 | 'period_id': period_id, # AB |
223 | 350 | 'date': st_line.date, | ||
224 | 351 | 'name': st_line_number, | ||
225 | 352 | }, context=context) | ||
226 | 353 | account_bank_statement_line_obj.write(cr, uid, [st_line.id], { | ||
227 | 354 | 'move_ids': [(4, move_id, False)] | ||
228 | 355 | }) | ||
229 | 356 | |||
230 | 357 | if st_line.amount >= 0: | ||
231 | 358 | account_id = st.journal_id.default_credit_account_id.id | ||
232 | 359 | else: | ||
233 | 360 | account_id = st.journal_id.default_debit_account_id.id | ||
234 | 361 | |||
235 | 362 | acc_cur = ((st_line.amount <= 0 and | ||
236 | 363 | st.journal_id.default_debit_account_id) or | ||
237 | 364 | st_line.account_id) | ||
238 | 365 | context.update({ | ||
239 | 366 | 'res.currency.compute.account': acc_cur, | ||
240 | 367 | }) | ||
241 | 368 | amount = res_currency_obj.compute(cr, uid, st.currency.id, | ||
242 | 369 | company_currency_id, st_line.amount, context=context) | ||
243 | 370 | |||
244 | 371 | val = { | ||
245 | 372 | 'name': st_line.name, | ||
246 | 373 | 'date': st_line.date, | ||
247 | 374 | 'ref': st_line.ref, | ||
248 | 375 | 'move_id': move_id, | ||
249 | 376 | 'partner_id': (((st_line.partner_id) and st_line.partner_id.id) or | ||
250 | 377 | False), | ||
251 | 378 | 'account_id': (st_line.account_id) and st_line.account_id.id, | ||
252 | 379 | 'credit': ((amount>0) and amount) or 0.0, | ||
253 | 380 | 'debit': ((amount<0) and -amount) or 0.0, | ||
254 | 381 | 'statement_id': st.id, | ||
255 | 382 | 'journal_id': st.journal_id.id, | ||
256 | 383 | 'period_id': period_id, # AB | ||
257 | 384 | 'currency_id': st.currency.id, | ||
258 | 385 | 'analytic_account_id': (st_line.analytic_account_id and | ||
259 | 386 | st_line.analytic_account_id.id or | ||
260 | 387 | False), | ||
261 | 388 | } | ||
262 | 389 | |||
263 | 390 | if st.currency.id <> company_currency_id: | ||
264 | 391 | amount_cur = res_currency_obj.compute(cr, uid, company_currency_id, | ||
265 | 392 | st.currency.id, amount, context=context) | ||
266 | 393 | val['amount_currency'] = -amount_cur | ||
267 | 394 | |||
268 | 395 | if (st_line.account_id and st_line.account_id.currency_id and | ||
269 | 396 | st_line.account_id.currency_id.id <> company_currency_id): | ||
270 | 397 | val['currency_id'] = st_line.account_id.currency_id.id | ||
271 | 398 | amount_cur = res_currency_obj.compute(cr, uid, company_currency_id, | ||
272 | 399 | st_line.account_id.currency_id.id, amount, context=context) | ||
273 | 400 | val['amount_currency'] = -amount_cur | ||
274 | 401 | |||
275 | 402 | move_line_id = account_move_line_obj.create( | ||
276 | 403 | cr, uid, val, context=context) | ||
277 | 404 | torec = move_line_id | ||
278 | 405 | |||
279 | 406 | # Fill the secondary amount/currency | ||
280 | 407 | # if currency is not the same than the company | ||
281 | 408 | amount_currency = False | ||
282 | 409 | currency_id = False | ||
283 | 410 | if st.currency.id <> company_currency_id: | ||
284 | 411 | amount_currency = st_line.amount | ||
285 | 412 | currency_id = st.currency.id | ||
286 | 413 | account_move_line_obj.create(cr, uid, { | ||
287 | 414 | 'name': st_line.name, | ||
288 | 415 | 'date': st_line.date, | ||
289 | 416 | 'ref': st_line.ref, | ||
290 | 417 | 'move_id': move_id, | ||
291 | 418 | 'partner_id': (((st_line.partner_id) and st_line.partner_id.id) or | ||
292 | 419 | False), | ||
293 | 420 | 'account_id': account_id, | ||
294 | 421 | 'credit': ((amount < 0) and -amount) or 0.0, | ||
295 | 422 | 'debit': ((amount > 0) and amount) or 0.0, | ||
296 | 423 | 'statement_id': st.id, | ||
297 | 424 | 'journal_id': st.journal_id.id, | ||
298 | 425 | 'period_id': period_id, # AB | ||
299 | 426 | 'amount_currency': amount_currency, | ||
300 | 427 | 'currency_id': currency_id, | ||
301 | 428 | }, context=context) | ||
302 | 429 | |||
303 | 430 | for line in account_move_line_obj.browse(cr, uid, [x.id for x in | ||
304 | 431 | account_move_obj.browse(cr, uid, move_id, | ||
305 | 432 | context=context).line_id], | ||
306 | 433 | context=context): | ||
307 | 434 | if line.state <> 'valid': | ||
308 | 313 | raise osv.except_osv(_('Error !'), | 435 | raise osv.except_osv(_('Error !'), |
485 | 314 | _('The statement balance is incorrect !\n') + | 436 | _('Journal Item "%s" is not valid') % line.name) |
486 | 315 | _('The expected balance (%.2f) is different ' | 437 | |
487 | 316 | 'than the computed one. (%.2f)') % ( | 438 | # Bank statements will not consider boolean on journal entry_posted |
488 | 317 | st.balance_end_real, st.balance_end | 439 | account_move_obj.post(cr, uid, [move_id], context=context) |
489 | 318 | )) | 440 | |
490 | 319 | if (not st.journal_id.default_credit_account_id) \ | 441 | """ |
491 | 320 | or (not st.journal_id.default_debit_account_id): | 442 | Account-banking: |
492 | 321 | raise osv.except_osv(_('Configration Error !'), | 443 | - Write stored reconcile_id |
493 | 322 | _('Please verify that an account is defined in the journal.')) | 444 | - Pay invoices through workflow |
494 | 323 | 445 | """ | |
495 | 324 | for line in st.move_line_ids: | 446 | if st_line.reconcile_id: |
496 | 325 | if line.state != 'valid': | 447 | account_move_line_obj.write(cr, uid, [torec], { |
497 | 326 | raise osv.except_osv(_('Error !'), | 448 | 'reconcile_id': st_line.reconcile_id.id }, context=context) |
498 | 327 | _('The account entries lines are not in valid state.')) | 449 | for move_line in (st_line.reconcile_id.line_id or []) + ( |
499 | 328 | 450 | st_line.reconcile_id.line_partial_ids or []): | |
500 | 329 | for move in st.line_ids: | 451 | netsvc.LocalService("workflow").trg_trigger( |
501 | 330 | context.update({'date':move.date}) | 452 | uid, 'account.move.line', move_line.id, cr) |
502 | 331 | # Essence of the change is here... | 453 | """ End account-banking """ |
503 | 332 | period_id = self._get_period(cursor, uid, move.date, context=context) | 454 | |
504 | 333 | move_id = account_move_obj.create(cursor, uid, { | 455 | return move_id |
329 | 334 | 'journal_id': st.journal_id.id, | ||
330 | 335 | # .. and here | ||
331 | 336 | 'period_id': period_id, | ||
332 | 337 | 'date': move.date, | ||
333 | 338 | }, context=context) | ||
334 | 339 | account_bank_statement_line_obj.write(cursor, uid, [move.id], { | ||
335 | 340 | 'move_ids': [(4, move_id, False)] | ||
336 | 341 | }) | ||
337 | 342 | if not move.amount: | ||
338 | 343 | continue | ||
339 | 344 | |||
340 | 345 | torec = [] | ||
341 | 346 | if move.amount >= 0: | ||
342 | 347 | account_id = st.journal_id.default_credit_account_id.id | ||
343 | 348 | else: | ||
344 | 349 | account_id = st.journal_id.default_debit_account_id.id | ||
345 | 350 | acc_cur = ((move.amount<=0) and st.journal_id.default_debit_account_id) \ | ||
346 | 351 | or move.account_id | ||
347 | 352 | amount = res_currency_obj.compute(cursor, uid, st.currency.id, | ||
348 | 353 | company_currency_id, move.amount, context=context, | ||
349 | 354 | account=acc_cur) | ||
350 | 355 | if move.reconcile_id and move.reconcile_id.line_new_ids: | ||
351 | 356 | for newline in move.reconcile_id.line_new_ids: | ||
352 | 357 | amount += newline.amount | ||
353 | 358 | |||
354 | 359 | val = { | ||
355 | 360 | 'name': move.name, | ||
356 | 361 | 'date': move.date, | ||
357 | 362 | 'ref': move.ref, | ||
358 | 363 | 'move_id': move_id, | ||
359 | 364 | 'partner_id': ((move.partner_id) and move.partner_id.id) or False, | ||
360 | 365 | 'account_id': (move.account_id) and move.account_id.id, | ||
361 | 366 | 'credit': ((amount>0) and amount) or 0.0, | ||
362 | 367 | 'debit': ((amount<0) and -amount) or 0.0, | ||
363 | 368 | 'statement_id': st.id, | ||
364 | 369 | 'journal_id': st.journal_id.id, | ||
365 | 370 | 'period_id': period_id, | ||
366 | 371 | 'currency_id': st.currency.id, | ||
367 | 372 | } | ||
368 | 373 | |||
369 | 374 | amount = res_currency_obj.compute(cursor, uid, st.currency.id, | ||
370 | 375 | company_currency_id, move.amount, context=context, | ||
371 | 376 | account=acc_cur) | ||
372 | 377 | if st.currency.id != company_currency_id: | ||
373 | 378 | amount_cur = res_currency_obj.compute(cr, uid, company_currency_id, | ||
374 | 379 | st.currency.id, amount, context=context, | ||
375 | 380 | account=acc_cur) | ||
376 | 381 | val['amount_currency'] = -amount_cur | ||
377 | 382 | |||
378 | 383 | if move.account_id and move.account_id.currency_id and move.account_id.currency_id.id != company_currency_id: | ||
379 | 384 | val['currency_id'] = move.account_id.currency_id.id | ||
380 | 385 | amount_cur = res_currency_obj.compute(cursor, uid, company_currency_id, | ||
381 | 386 | move.account_id.currency_id.id, amount, context=context, | ||
382 | 387 | account=acc_cur) | ||
383 | 388 | val['amount_currency'] = -amount_cur | ||
384 | 389 | |||
385 | 390 | torec.append(account_move_line_obj.create(cursor, uid, val , context=context)) | ||
386 | 391 | |||
387 | 392 | if move.reconcile_id and move.reconcile_id.line_new_ids: | ||
388 | 393 | for newline in move.reconcile_id.line_new_ids: | ||
389 | 394 | account_move_line_obj.create(cursor, uid, { | ||
390 | 395 | 'name': newline.name or move.name, | ||
391 | 396 | 'date': move.date, | ||
392 | 397 | 'ref': move.ref, | ||
393 | 398 | 'move_id': move_id, | ||
394 | 399 | 'partner_id': ((move.partner_id) and move.partner_id.id) or False, | ||
395 | 400 | 'account_id': (newline.account_id) and newline.account_id.id, | ||
396 | 401 | 'debit': newline.amount>0 and newline.amount or 0.0, | ||
397 | 402 | 'credit': newline.amount<0 and -newline.amount or 0.0, | ||
398 | 403 | 'statement_id': st.id, | ||
399 | 404 | 'journal_id': st.journal_id.id, | ||
400 | 405 | 'period_id': period_id, | ||
401 | 406 | }, context=context) | ||
402 | 407 | |||
403 | 408 | # Fill the secondary amount/currency | ||
404 | 409 | # if currency is not the same than the company | ||
405 | 410 | amount_currency = False | ||
406 | 411 | currency_id = False | ||
407 | 412 | if st.currency.id <> company_currency_id: | ||
408 | 413 | amount_currency = move.amount | ||
409 | 414 | currency_id = st.currency.id | ||
410 | 415 | |||
411 | 416 | account_move_line_obj.create(cursor, uid, { | ||
412 | 417 | 'name': move.name, | ||
413 | 418 | 'date': move.date, | ||
414 | 419 | 'ref': move.ref, | ||
415 | 420 | 'move_id': move_id, | ||
416 | 421 | 'partner_id': ((move.partner_id) and move.partner_id.id) or False, | ||
417 | 422 | 'account_id': account_id, | ||
418 | 423 | 'credit': ((amount < 0) and -amount) or 0.0, | ||
419 | 424 | 'debit': ((amount > 0) and amount) or 0.0, | ||
420 | 425 | 'statement_id': st.id, | ||
421 | 426 | 'journal_id': st.journal_id.id, | ||
422 | 427 | 'period_id': period_id, | ||
423 | 428 | 'amount_currency': amount_currency, | ||
424 | 429 | 'currency_id': currency_id, | ||
425 | 430 | }, context=context) | ||
426 | 431 | |||
427 | 432 | for line in account_move_line_obj.browse(cursor, uid, [x.id for x in | ||
428 | 433 | account_move_obj.browse(cursor, uid, move_id, context=context).line_id | ||
429 | 434 | ], context=context): | ||
430 | 435 | if line.state != 'valid': | ||
431 | 436 | raise osv.except_osv( | ||
432 | 437 | _('Error !'), | ||
433 | 438 | _('Account move line "%s" is not valid') | ||
434 | 439 | % line.name | ||
435 | 440 | ) | ||
436 | 441 | |||
437 | 442 | if move.reconcile_id and move.reconcile_id.line_ids: | ||
438 | 443 | ## Search if move has already a partial reconciliation | ||
439 | 444 | previous_partial = False | ||
440 | 445 | for line_reconcile_move in move.reconcile_id.line_ids: | ||
441 | 446 | if line_reconcile_move.reconcile_partial_id: | ||
442 | 447 | previous_partial = True | ||
443 | 448 | break | ||
444 | 449 | ## | ||
445 | 450 | torec += map(lambda x: x.id, move.reconcile_id.line_ids) | ||
446 | 451 | #try: | ||
447 | 452 | if abs(move.reconcile_amount-move.amount)<0.0001: | ||
448 | 453 | |||
449 | 454 | writeoff_acc_id = False | ||
450 | 455 | #There should only be one write-off account! | ||
451 | 456 | for entry in move.reconcile_id.line_new_ids: | ||
452 | 457 | writeoff_acc_id = entry.account_id.id | ||
453 | 458 | break | ||
454 | 459 | ## If we have already a partial reconciliation | ||
455 | 460 | ## We need to make a partial reconciliation | ||
456 | 461 | ## To add this amount to previous paid amount | ||
457 | 462 | if previous_partial: | ||
458 | 463 | account_move_line_obj.reconcile_partial(cr, uid, torec, 'statement', context) | ||
459 | 464 | ## If it's the first reconciliation, we do a full reconciliation as regular | ||
460 | 465 | else: | ||
461 | 466 | account_move_line_obj.reconcile( | ||
462 | 467 | cursor, uid, torec, 'statement', | ||
463 | 468 | writeoff_acc_id=writeoff_acc_id, | ||
464 | 469 | writeoff_period_id=st.period_id.id, | ||
465 | 470 | writeoff_journal_id=st.journal_id.id, | ||
466 | 471 | context=context | ||
467 | 472 | ) | ||
468 | 473 | else: | ||
469 | 474 | account_move_line_obj.reconcile_partial( | ||
470 | 475 | cursor, uid, torec, 'statement', context | ||
471 | 476 | ) | ||
472 | 477 | |||
473 | 478 | if st.journal_id.entry_posted: | ||
474 | 479 | account_move_obj.write(cursor, uid, [move_id], {'state':'posted'}) | ||
475 | 480 | done.append(st.id) | ||
476 | 481 | self.write(cursor, uid, done, {'state':'confirm'}, context=context) | ||
477 | 482 | |||
478 | 483 | # Be nice to other modules as well, relay button_confirm calls to | ||
479 | 484 | # on_button_confirm calls. | ||
480 | 485 | for other in self._abf_others: | ||
481 | 486 | if hasattr(other, 'on_button_confirm'): | ||
482 | 487 | other.on_button_confirm(self, cursor, uid, ids, context=context) | ||
483 | 488 | |||
484 | 489 | return True | ||
505 | 490 | 456 | ||
506 | 491 | account_bank_statement() | 457 | account_bank_statement() |
507 | 492 | 458 | ||
508 | @@ -564,9 +530,23 @@ | |||
509 | 564 | # res[line.id] = 0.0 | 530 | # res[line.id] = 0.0 |
510 | 565 | # return res | 531 | # return res |
511 | 566 | 532 | ||
512 | 533 | def _get_invoice_id(self, cr, uid, ids, name, args, context=None): | ||
513 | 534 | res = {} | ||
514 | 535 | for st_line in self.browse(cr, uid, ids, context): | ||
515 | 536 | res[st_line.id] = False | ||
516 | 537 | for move_line in (st_line.reconcile_id and | ||
517 | 538 | (st_line.reconcile_id.line_id or []) + | ||
518 | 539 | (st_line.reconcile_id.line_partial_ids or []) or | ||
519 | 540 | []): | ||
520 | 541 | if move_line.invoice: | ||
521 | 542 | res[st_line.id] = move_line.invoice.id | ||
522 | 543 | continue | ||
523 | 544 | return res | ||
524 | 545 | |||
525 | 567 | _columns = { | 546 | _columns = { |
526 | 568 | # Redefines | 547 | # Redefines |
527 | 569 | 'amount': fields.float('Amount', readonly=True, | 548 | 'amount': fields.float('Amount', readonly=True, |
528 | 549 | digits_compute=dp.get_precision('Account'), | ||
529 | 570 | states={'draft': [('readonly', False)]}), | 550 | states={'draft': [('readonly', False)]}), |
530 | 571 | 'ref': fields.char('Ref.', size=32, readonly=True, | 551 | 'ref': fields.char('Ref.', size=32, readonly=True, |
531 | 572 | states={'draft': [('readonly', False)]}), | 552 | states={'draft': [('readonly', False)]}), |
532 | @@ -596,6 +576,13 @@ | |||
533 | 596 | required=False, | 576 | required=False, |
534 | 597 | states={'confirm': [('readonly', True)]}, | 577 | states={'confirm': [('readonly', True)]}, |
535 | 598 | ), | 578 | ), |
536 | 579 | 'reconcile_id': fields.many2one( | ||
537 | 580 | 'account.move.reconcile', 'Reconciliation', readonly=True | ||
538 | 581 | ), | ||
539 | 582 | 'invoice_id': fields.function( | ||
540 | 583 | _get_invoice_id, method=True, string='Linked Invoice', | ||
541 | 584 | type='many2one', relation='account.invoice' | ||
542 | 585 | ), | ||
543 | 599 | } | 586 | } |
544 | 600 | 587 | ||
545 | 601 | _defaults = { | 588 | _defaults = { |
546 | @@ -604,57 +591,8 @@ | |||
547 | 604 | 'currency': _get_currency, | 591 | 'currency': _get_currency, |
548 | 605 | } | 592 | } |
549 | 606 | 593 | ||
550 | 607 | def onchange_partner_id(self, cursor, uid, line_id, partner_id, type, | ||
551 | 608 | currency_id, context=None | ||
552 | 609 | ): | ||
553 | 610 | ''' | ||
554 | 611 | Find default accounts when encoding statements by hand | ||
555 | 612 | ''' | ||
556 | 613 | if not partner_id: | ||
557 | 614 | return {} | ||
558 | 615 | |||
559 | 616 | result = {} | ||
560 | 617 | if not currency_id: | ||
561 | 618 | users_obj = self.pool.get('res.users') | ||
562 | 619 | currency_id = users_obj.browse( | ||
563 | 620 | cursor, uid, uid, context=context | ||
564 | 621 | ).company_id.currency_id.id | ||
565 | 622 | result['currency_id'] = currency_id | ||
566 | 623 | |||
567 | 624 | partner_obj = self.pool.get('res.partner') | ||
568 | 625 | partner = partner_obj.browse(cursor, uid, partner_id, context=context) | ||
569 | 626 | if partner.supplier and not partner.customer: | ||
570 | 627 | if partner.property_account_payable.id: | ||
571 | 628 | result['account_id'] = partner.property_account_payable.id | ||
572 | 629 | result['type'] = 'supplier' | ||
573 | 630 | elif partner.customer and not partner.supplier: | ||
574 | 631 | if partner.property_account_receivable.id: | ||
575 | 632 | result['account_id'] = partner.property_account_receivable.id | ||
576 | 633 | result['type'] = 'customer' | ||
577 | 634 | |||
578 | 635 | return result and {'value': result} or {} | ||
579 | 636 | |||
580 | 637 | account_bank_statement_line() | 594 | account_bank_statement_line() |
581 | 638 | 595 | ||
582 | 639 | class payment_type(osv.osv): | ||
583 | 640 | ''' | ||
584 | 641 | Make description field translatable #, add country context | ||
585 | 642 | ''' | ||
586 | 643 | _inherit = 'payment.type' | ||
587 | 644 | _columns = { | ||
588 | 645 | 'name': fields.char('Name', size=64, required=True, translate=True, | ||
589 | 646 | help='Payment Type' | ||
590 | 647 | ), | ||
591 | 648 | #'country_id': fields.many2one('res.country', 'Country', | ||
592 | 649 | # required=False, | ||
593 | 650 | # help='Use this to limit this type to a specific country' | ||
594 | 651 | # ), | ||
595 | 652 | } | ||
596 | 653 | #_defaults = { | ||
597 | 654 | # 'country_id': lambda *a: False, | ||
598 | 655 | #} | ||
599 | 656 | payment_type() | ||
600 | 657 | |||
601 | 658 | class payment_line(osv.osv): | 596 | class payment_line(osv.osv): |
602 | 659 | ''' | 597 | ''' |
603 | 660 | Add extra export_state and date_done fields; make destination bank account | 598 | Add extra export_state and date_done fields; make destination bank account |
604 | @@ -814,6 +752,7 @@ | |||
605 | 814 | Enable extra states for payment exports and add extra functionality. | 752 | Enable extra states for payment exports and add extra functionality. |
606 | 815 | ''' | 753 | ''' |
607 | 816 | _inherit = 'payment.order' | 754 | _inherit = 'payment.order' |
608 | 755 | <<<<<<< TREE | ||
609 | 817 | 756 | ||
610 | 818 | def __no_transactions(self, cursor, uid, ids, field_name, arg=None, | 757 | def __no_transactions(self, cursor, uid, ids, field_name, arg=None, |
611 | 819 | context=None): | 758 | context=None): |
612 | @@ -862,8 +801,11 @@ | |||
613 | 862 | cursor.execute(query) | 801 | cursor.execute(query) |
614 | 863 | return dict(cursor.fetchall()) | 802 | return dict(cursor.fetchall()) |
615 | 864 | 803 | ||
616 | 804 | ======= | ||
617 | 805 | |||
618 | 806 | >>>>>>> MERGE-SOURCE | ||
619 | 865 | _columns = { | 807 | _columns = { |
621 | 866 | 'date_planned': fields.date( | 808 | 'date_scheduled': fields.date( |
622 | 867 | 'Scheduled date if fixed', | 809 | 'Scheduled date if fixed', |
623 | 868 | states={ | 810 | states={ |
624 | 869 | 'sent': [('readonly', True)], | 811 | 'sent': [('readonly', True)], |
625 | @@ -941,6 +883,47 @@ | |||
626 | 941 | ), | 883 | ), |
627 | 942 | } | 884 | } |
628 | 943 | 885 | ||
629 | 886 | def launch_wizard(self, cr, uid, ids, context=None): | ||
630 | 887 | """ | ||
631 | 888 | Search for a wizard to launch according to the type. | ||
632 | 889 | If type is manual. just confirm the order. | ||
633 | 890 | Previously (pre-v6) in account_payment/wizard/wizard_pay.py | ||
634 | 891 | """ | ||
635 | 892 | if context == None: | ||
636 | 893 | context={} | ||
637 | 894 | result = {} | ||
638 | 895 | orders = self.browse(cr, uid, ids, context) | ||
639 | 896 | order = orders[0] | ||
640 | 897 | # check if a wizard is defined for the first order | ||
641 | 898 | if order.mode.type and order.mode.type.ir_model_id: | ||
642 | 899 | context['active_ids'] = ids | ||
643 | 900 | wizard_model = order.mode.type.ir_model_id.model | ||
644 | 901 | wizard_obj = self.pool.get(wizard_model) | ||
645 | 902 | wizard_id = wizard_obj.create(cr, uid, {}, context) | ||
646 | 903 | result = { | ||
647 | 904 | 'name': wizard_obj._description or 'Payment Order Export', | ||
648 | 905 | 'view_type': 'form', | ||
649 | 906 | 'view_mode': 'form', | ||
650 | 907 | 'res_model': wizard_model, | ||
651 | 908 | 'domain': [], | ||
652 | 909 | 'context': context, | ||
653 | 910 | 'type': 'ir.actions.act_window', | ||
654 | 911 | 'target': 'new', | ||
655 | 912 | 'res_id': wizard_id, | ||
656 | 913 | 'nodestroy': True, | ||
657 | 914 | } | ||
658 | 915 | else: | ||
659 | 916 | # should all be manual orders without type or wizard model | ||
660 | 917 | for order in orders[1:]: | ||
661 | 918 | if order.mode.type and order.mode.type.ir_model_id: | ||
662 | 919 | raise osv.except_osv( | ||
663 | 920 | _('Error'), | ||
664 | 921 | _('You can only combine payment orders of the same type') | ||
665 | 922 | ) | ||
666 | 923 | # process manual payments | ||
667 | 924 | self.action_sent(cr, uid, ids, context) | ||
668 | 925 | return result | ||
669 | 926 | |||
670 | 944 | def _write_payment_lines(self, cursor, uid, ids, **kwargs): | 927 | def _write_payment_lines(self, cursor, uid, ids, **kwargs): |
671 | 945 | ''' | 928 | ''' |
672 | 946 | ORM method for setting attributes of corresponding payment.line objects. | 929 | ORM method for setting attributes of corresponding payment.line objects. |
673 | @@ -1180,8 +1163,13 @@ | |||
674 | 1180 | Convert IBAN electronic format to IBAN display format | 1163 | Convert IBAN electronic format to IBAN display format |
675 | 1181 | ''' | 1164 | ''' |
676 | 1182 | records = self._founder.read(self, *args, **kwargs) | 1165 | records = self._founder.read(self, *args, **kwargs) |
677 | 1166 | <<<<<<< TREE | ||
678 | 1183 | if not hasattr(records, '__iter__'): | 1167 | if not hasattr(records, '__iter__'): |
679 | 1184 | records = [records] | 1168 | records = [records] |
680 | 1169 | ======= | ||
681 | 1170 | if not isinstance(records, list): | ||
682 | 1171 | records = [records,] | ||
683 | 1172 | >>>>>>> MERGE-SOURCE | ||
684 | 1185 | for record in records: | 1173 | for record in records: |
685 | 1186 | if 'iban' in record and record['iban']: | 1174 | if 'iban' in record and record['iban']: |
686 | 1187 | record['iban'] = unicode(sepa.IBAN(record['iban'])) | 1175 | record['iban'] = unicode(sepa.IBAN(record['iban'])) |
687 | @@ -1268,12 +1256,15 @@ | |||
688 | 1268 | ): | 1256 | ): |
689 | 1269 | country_ids = [user.company_id.partner_id.country.id] | 1257 | country_ids = [user.company_id.partner_id.country.id] |
690 | 1270 | else: | 1258 | else: |
697 | 1271 | # Ok, tried everything, give up and leave it to the user | 1259 | if (user.company_id and user.company_id.partner_id and |
698 | 1272 | return warning(_('Insufficient data'), | 1260 | user.company_id.partner_id.country): |
699 | 1273 | _('Insufficient data to select online ' | 1261 | country_ids = [user.company_id.partner_id.country.id] |
700 | 1274 | 'conversion database') | 1262 | else: |
701 | 1275 | ) | 1263 | # Ok, tried everything, give up and leave it to the user |
702 | 1276 | 1264 | return warning(_('Insufficient data'), | |
703 | 1265 | _('Insufficient data to select online ' | ||
704 | 1266 | 'conversion database') | ||
705 | 1267 | ) | ||
706 | 1277 | result = {'value': values} | 1268 | result = {'value': values} |
707 | 1278 | # Complete data with online database when available | 1269 | # Complete data with online database when available |
708 | 1279 | if country.code in sepa.IBAN.countries: | 1270 | if country.code in sepa.IBAN.countries: |
709 | 1280 | 1271 | ||
710 | === removed file 'account_banking/account_banking_import_wizard.xml' | |||
711 | --- account_banking/account_banking_import_wizard.xml 2010-01-26 20:55:24 +0000 | |||
712 | +++ account_banking/account_banking_import_wizard.xml 1970-01-01 00:00:00 +0000 | |||
713 | @@ -1,15 +0,0 @@ | |||
714 | 1 | <?xml version="1.0" encoding="utf-8"?> | ||
715 | 2 | <!-- | ||
716 | 3 | Copyright (C) EduSense BV <http://www.edusense.nl> | ||
717 | 4 | All rights reserved. | ||
718 | 5 | The licence is in the file __terp__.py | ||
719 | 6 | --> | ||
720 | 7 | <openerp> | ||
721 | 8 | <data> | ||
722 | 9 | <wizard id="wizard_account_banking_import_file" | ||
723 | 10 | string="Import Bank Statements File" | ||
724 | 11 | model="account.bank.statement" | ||
725 | 12 | name="account_banking.banking_import" | ||
726 | 13 | /> | ||
727 | 14 | </data> | ||
728 | 15 | </openerp> | ||
729 | 16 | 0 | ||
730 | === removed file 'account_banking/account_banking_payment_wizard.xml' | |||
731 | --- account_banking/account_banking_payment_wizard.xml 2011-02-12 13:37:09 +0000 | |||
732 | +++ account_banking/account_banking_payment_wizard.xml 1970-01-01 00:00:00 +0000 | |||
733 | @@ -1,22 +0,0 @@ | |||
734 | 1 | <?xml version="1.0" encoding="utf-8"?> | ||
735 | 2 | <!-- | ||
736 | 3 | Copyright (C) EduSense BV <http://www.edusense.nl> | ||
737 | 4 | All rights reserved. | ||
738 | 5 | The licence is in the file __terp__.py | ||
739 | 6 | --> | ||
740 | 7 | <openerp> | ||
741 | 8 | <data> | ||
742 | 9 | <wizard id="wizard_account_banking_payment_manual" | ||
743 | 10 | menu="False" | ||
744 | 11 | string="Manual Bank Payment" | ||
745 | 12 | model="account_payment.payment.order" | ||
746 | 13 | name="account_banking.payment_manual" | ||
747 | 14 | /> | ||
748 | 15 | <wizard id="account_payment.wizard_populate_payment" | ||
749 | 16 | menu="False" | ||
750 | 17 | string="Populate payment" | ||
751 | 18 | model="payment.order" | ||
752 | 19 | name="account_payment.populate_payment" | ||
753 | 20 | /> | ||
754 | 21 | </data> | ||
755 | 22 | </openerp> | ||
756 | 23 | 0 | ||
757 | === modified file 'account_banking/account_banking_view.xml' | |||
758 | --- account_banking/account_banking_view.xml 2011-11-07 12:34:48 +0000 | |||
759 | +++ account_banking/account_banking_view.xml 2011-11-23 10:40:16 +0000 | |||
760 | @@ -42,7 +42,7 @@ | |||
761 | 42 | <field name="company_id" /> | 42 | <field name="company_id" /> |
762 | 43 | <separator string="Bank Account Details" colspan="4" /> | 43 | <separator string="Bank Account Details" colspan="4" /> |
763 | 44 | <field name="partner_bank_id" /> <!-- Needs domain for used companies /--> | 44 | <field name="partner_bank_id" /> <!-- Needs domain for used companies /--> |
765 | 45 | <field name="journal_id" domain="[('type','=','cash')]" /> | 45 | <field name="journal_id" domain="[('type','=','bank')]" /> |
766 | 46 | <separator string="Default Accounts for Unknown Movements" colspan="4" /> | 46 | <separator string="Default Accounts for Unknown Movements" colspan="4" /> |
767 | 47 | <field name="default_credit_account_id" /> | 47 | <field name="default_credit_account_id" /> |
768 | 48 | <field name="default_debit_account_id" /> | 48 | <field name="default_debit_account_id" /> |
769 | @@ -61,7 +61,7 @@ | |||
770 | 61 | <tree string="Default Import Settings for Bank Account"> | 61 | <tree string="Default Import Settings for Bank Account"> |
771 | 62 | <field name="company_id" /> | 62 | <field name="company_id" /> |
772 | 63 | <field name="partner_bank_id" /> <!-- Needs domain for used companies /--> | 63 | <field name="partner_bank_id" /> <!-- Needs domain for used companies /--> |
774 | 64 | <field name="journal_id" domain="[('type','=','cash')]" /> | 64 | <field name="journal_id" domain="[('type','=','bank')]" /> |
775 | 65 | </tree> | 65 | </tree> |
776 | 66 | </field> | 66 | </field> |
777 | 67 | </record> | 67 | </record> |
778 | @@ -140,10 +140,18 @@ | |||
779 | 140 | <menuitem name="Import Bank Statements File" | 140 | <menuitem name="Import Bank Statements File" |
780 | 141 | id="menu_account_banking_import_wizard" | 141 | id="menu_account_banking_import_wizard" |
781 | 142 | parent="account_banking.menu_finance_banking_actions" | 142 | parent="account_banking.menu_finance_banking_actions" |
782 | 143 | type="wizard" | ||
783 | 144 | action="wizard_account_banking_import_file" | 143 | action="wizard_account_banking_import_file" |
784 | 145 | sequence="15"/> | 144 | sequence="15"/> |
785 | 146 | 145 | ||
786 | 146 | <!-- Add the import wizard to the statement's right menu --> | ||
787 | 147 | <act_window name="Import Bank Statements File" | ||
788 | 148 | res_model="account.banking.bank.import" | ||
789 | 149 | src_model="account.bank.statement" | ||
790 | 150 | view_mode="form" | ||
791 | 151 | target="new" | ||
792 | 152 | key2="client_action_multi" | ||
793 | 153 | id="act_account_banking_import_wizard"/> | ||
794 | 154 | |||
795 | 147 | <!-- Create right menu entry to see statements --> | 155 | <!-- Create right menu entry to see statements --> |
796 | 148 | <act_window name="Bank Statements File" | 156 | <act_window name="Bank Statements File" |
797 | 149 | domain="[('id','=',banking_id)]" | 157 | domain="[('id','=',banking_id)]" |
798 | @@ -170,7 +178,15 @@ | |||
799 | 170 | <field name="model">account.bank.statement</field> | 178 | <field name="model">account.bank.statement</field> |
800 | 171 | <field name="type">form</field> | 179 | <field name="type">form</field> |
801 | 172 | <field name="arch" type="xml"> | 180 | <field name="arch" type="xml"> |
803 | 173 | <field name="period_id" position="replace"/> | 181 | <data> |
804 | 182 | <field name="period_id" position="replace"/> | ||
805 | 183 | <xpath expr="/form/notebook/page[@string='Transaction']/field/tree/field[@name='name']" position="replace"> | ||
806 | 184 | <field name="name" required="1"/> | ||
807 | 185 | </xpath> | ||
808 | 186 | <xpath expr="/form/notebook/page[@string='Transaction']/field/form/field[@name='name']" position="replace"> | ||
809 | 187 | <field name="name" required="1"/> | ||
810 | 188 | </xpath> | ||
811 | 189 | </data> | ||
812 | 174 | </field> | 190 | </field> |
813 | 175 | </record> | 191 | </record> |
814 | 176 | <record id="view_banking_bank_statement_form_2" model="ir.ui.view"> | 192 | <record id="view_banking_bank_statement_form_2" model="ir.ui.view"> |
815 | @@ -179,7 +195,7 @@ | |||
816 | 179 | <field name="model">account.bank.statement</field> | 195 | <field name="model">account.bank.statement</field> |
817 | 180 | <field name="type">form</field> | 196 | <field name="type">form</field> |
818 | 181 | <field name="arch" type="xml"> | 197 | <field name="arch" type="xml"> |
820 | 182 | <xpath expr="/form/notebook/page[@string='Entry encoding']/field/tree/field[@name='type']" position="after"> | 198 | <xpath expr="/form/notebook/page[@string='Transaction']/field/tree/field[@name='ref']" position="after"> |
821 | 183 | <field name="period_id"/> | 199 | <field name="period_id"/> |
822 | 184 | </xpath> | 200 | </xpath> |
823 | 185 | </field> | 201 | </field> |
824 | @@ -190,7 +206,7 @@ | |||
825 | 190 | <field name="model">account.bank.statement</field> | 206 | <field name="model">account.bank.statement</field> |
826 | 191 | <field name="type">form</field> | 207 | <field name="type">form</field> |
827 | 192 | <field name="arch" type="xml"> | 208 | <field name="arch" type="xml"> |
829 | 193 | <xpath expr="/form/notebook/page[@string='Entry encoding']/field/form/field[@name='type']" position="after"> | 209 | <xpath expr="/form/notebook/page[@string='Transaction']/field/form/field[@name='ref']" position="after"> |
830 | 194 | <field name="period_id"/> | 210 | <field name="period_id"/> |
831 | 195 | </xpath> | 211 | </xpath> |
832 | 196 | </field> | 212 | </field> |
833 | @@ -235,9 +251,19 @@ | |||
834 | 235 | <field name="model">account.bank.statement</field> | 251 | <field name="model">account.bank.statement</field> |
835 | 236 | <field name="type">form</field> | 252 | <field name="type">form</field> |
836 | 237 | <field name="arch" type="xml"> | 253 | <field name="arch" type="xml"> |
840 | 238 | <xpath expr="/form/notebook/page/field[@name='line_ids']/tree/field[@name='partner_id']" position="after"> | 254 | <data> |
841 | 239 | <field name="partner_bank_id"/> | 255 | <xpath expr="/form/notebook/page/field[@name='line_ids']/tree/field[@name='partner_id']" position="after"> |
842 | 240 | </xpath> | 256 | <field name="partner_bank_id"/> |
843 | 257 | </xpath> | ||
844 | 258 | <xpath expr="/form/notebook/page/field[@name='line_ids']/tree/field[@name='amount']" position="after"> | ||
845 | 259 | <field name="invoice_id"/> | ||
846 | 260 | <field name="reconcile_id"/> | ||
847 | 261 | </xpath> | ||
848 | 262 | <xpath expr="/form/notebook/page/field[@name='line_ids']/form/field[@name='amount']" position="after"> | ||
849 | 263 | <field name="invoice_id"/> | ||
850 | 264 | <field name="reconcile_id"/> | ||
851 | 265 | </xpath> | ||
852 | 266 | </data> | ||
853 | 241 | </field> | 267 | </field> |
854 | 242 | </record> | 268 | </record> |
855 | 243 | <record id="view_banking_bank_statement_form_6" model="ir.ui.view"> | 269 | <record id="view_banking_bank_statement_form_6" model="ir.ui.view"> |
856 | @@ -252,6 +278,7 @@ | |||
857 | 252 | </field> | 278 | </field> |
858 | 253 | </record> | 279 | </record> |
859 | 254 | 280 | ||
860 | 281 | <<<<<<< TREE | ||
861 | 255 | <!-- Reset trigger on button_confirm to the trigger code in this module --> | 282 | <!-- Reset trigger on button_confirm to the trigger code in this module --> |
862 | 256 | <record id="view_banking_bank_statement_form_7" model="ir.ui.view"> | 283 | <record id="view_banking_bank_statement_form_7" model="ir.ui.view"> |
863 | 257 | <field name="name">account.bank.statement.form.banking-7</field> | 284 | <field name="name">account.bank.statement.form.banking-7</field> |
864 | @@ -264,21 +291,44 @@ | |||
865 | 264 | </button> | 291 | </button> |
866 | 265 | </field> | 292 | </field> |
867 | 266 | </record> | 293 | </record> |
868 | 294 | ======= | ||
869 | 295 | <!-- Make buttons on payment order sensitive for extra states, | ||
870 | 296 | restore wizard functionality when making payments | ||
871 | 297 | --> | ||
872 | 298 | >>>>>>> MERGE-SOURCE | ||
873 | 267 | 299 | ||
874 | 268 | <!-- Make buttons on payment order sensitive for extra states --> | ||
875 | 269 | <record id="view_banking_payment_order_form_1" model="ir.ui.view"> | 300 | <record id="view_banking_payment_order_form_1" model="ir.ui.view"> |
876 | 270 | <field name="name">account.payment.order.form.banking-1</field> | 301 | <field name="name">account.payment.order.form.banking-1</field> |
877 | 271 | <field name="inherit_id" ref="account_payment.view_payment_order_form" /> | 302 | <field name="inherit_id" ref="account_payment.view_payment_order_form" /> |
878 | 272 | <field name="model">payment.order</field> | 303 | <field name="model">payment.order</field> |
879 | 273 | <field name="type">form</field> | 304 | <field name="type">form</field> |
880 | 274 | <field name="arch" type="xml"> | 305 | <field name="arch" type="xml"> |
888 | 275 | <xpath expr="/form/button[@string='Select Invoices to Pay']" | 306 | <data> |
889 | 276 | position="replace"> | 307 | <xpath expr="/form/group/button[@string='Select Invoices to Pay']" |
890 | 277 | <button name="%(account_payment.wizard_populate_payment)s" | 308 | position="replace"> |
891 | 278 | colspan="2" type="action" states="draft,open" | 309 | <button colspan="2" name="%(account_payment.action_create_payment_order)s" |
892 | 279 | string="Select Invoices to Pay" | 310 | string="Select Invoices to Pay" type="action" |
893 | 280 | /> | 311 | attrs="{'invisible':[('state','!=','draft')]}" |
894 | 281 | </xpath> | 312 | icon="gtk-find" |
895 | 313 | /> | ||
896 | 314 | </xpath> | ||
897 | 315 | <xpath expr="/form/group/button[@string='Make Payments']" | ||
898 | 316 | position="replace"> | ||
899 | 317 | <button name="launch_wizard" states="open" string="Make Payments" type="object" icon="gtk-execute"/> | ||
900 | 318 | <newline/> | ||
901 | 319 | </xpath> | ||
902 | 320 | </data> | ||
903 | 321 | </field> | ||
904 | 322 | </record> | ||
905 | 323 | <record id="view_banking_payment_order_tree_1" model="ir.ui.view"> | ||
906 | 324 | <field name="name">account.payment.order.tree.banking-1</field> | ||
907 | 325 | <field name="inherit_id" ref="account_payment.view_payment_order_tree" /> | ||
908 | 326 | <field name="model">payment.order</field> | ||
909 | 327 | <field name="type">tree</field> | ||
910 | 328 | <field name="arch" type="xml"> | ||
911 | 329 | <button string="Make Payments" position="replace"> | ||
912 | 330 | <button name="launch_wizard" states="open" string="Make Payments" type="object" icon="gtk-execute"/> | ||
913 | 331 | </button> | ||
914 | 282 | </field> | 332 | </field> |
915 | 283 | </record> | 333 | </record> |
916 | 284 | 334 | ||
917 | @@ -353,7 +403,7 @@ | |||
918 | 353 | <field name="type">form</field> | 403 | <field name="type">form</field> |
919 | 354 | <field name="arch" type="xml"> | 404 | <field name="arch" type="xml"> |
920 | 355 | <xpath expr="/form/notebook/page/field[@name='bank_ids']/tree/field[@name='acc_number']" position="replace"> | 405 | <xpath expr="/form/notebook/page/field[@name='bank_ids']/tree/field[@name='acc_number']" position="replace"> |
922 | 356 | <field name="acc_number" on_change="onchange_acc_number(acc_number, parent.id, country_id)" /> | 406 | <field name="acc_number" on_change="onchange_acc_number(acc_number, parent.id, country_id)" select="1" /> |
923 | 357 | </xpath> | 407 | </xpath> |
924 | 358 | </field> | 408 | </field> |
925 | 359 | </record> | 409 | </record> |
926 | @@ -371,5 +421,43 @@ | |||
927 | 371 | </field> | 421 | </field> |
928 | 372 | </record> | 422 | </record> |
929 | 373 | 423 | ||
930 | 424 | <!-- Insert payment_mode.type --> | ||
931 | 425 | <record id="view_payment_mode_form_inherit" model="ir.ui.view"> | ||
932 | 426 | <field name="name">payment.mode.form.inherit</field> | ||
933 | 427 | <field name="model">payment.mode</field> | ||
934 | 428 | <field name="inherit_id" ref="account_payment.view_payment_mode_form"/> | ||
935 | 429 | <field name="type">form</field> | ||
936 | 430 | <field name="arch" type="xml"> | ||
937 | 431 | <field name="company_id" position="after"> | ||
938 | 432 | <field name="type"/> | ||
939 | 433 | </field> | ||
940 | 434 | </field> | ||
941 | 435 | </record> | ||
942 | 436 | <record id="view_payment_mode_tree_inherit" model="ir.ui.view"> | ||
943 | 437 | <field name="name">payment.mode.tree.inherit</field> | ||
944 | 438 | <field name="model">payment.mode</field> | ||
945 | 439 | <field name="inherit_id" ref="account_payment.view_payment_mode_tree"/> | ||
946 | 440 | <field name="type">tree</field> | ||
947 | 441 | <field name="arch" type="xml"> | ||
948 | 442 | <field name="company_id" position="after"> | ||
949 | 443 | <field name="type"/> | ||
950 | 444 | </field> | ||
951 | 445 | </field> | ||
952 | 446 | </record> | ||
953 | 447 | |||
954 | 448 | <!-- basic view for payment mode type --> | ||
955 | 449 | <record model="ir.ui.view" id="view_payment_mode_type_form"> | ||
956 | 450 | <field name="name">view.payment.mode.type.form</field> | ||
957 | 451 | <field name="model">payment.mode.type</field> | ||
958 | 452 | <field name="type">form</field> | ||
959 | 453 | <field name="arch" type="xml"> | ||
960 | 454 | <form> | ||
961 | 455 | <field name="name" /> | ||
962 | 456 | <field name="code" /> | ||
963 | 457 | <field name="suitable_bank_types"/> | ||
964 | 458 | <field name="ir_model_id"/> | ||
965 | 459 | </form> | ||
966 | 460 | </field> | ||
967 | 461 | </record> | ||
968 | 374 | </data> | 462 | </data> |
969 | 375 | </openerp> | 463 | </openerp> |
970 | 376 | 464 | ||
971 | === modified file 'account_banking/data/account_banking_data.xml' | |||
972 | --- account_banking/data/account_banking_data.xml 2010-12-20 10:58:51 +0000 | |||
973 | +++ account_banking/data/account_banking_data.xml 2011-11-23 10:40:16 +0000 | |||
974 | @@ -17,14 +17,14 @@ | |||
975 | 17 | Ratio: one can have bank accounts in foreign banks. Foreign | 17 | Ratio: one can have bank accounts in foreign banks. Foreign |
976 | 18 | addresses not automatically involve international banking. | 18 | addresses not automatically involve international banking. |
977 | 19 | --> | 19 | --> |
979 | 20 | <record id="bank_normal_field_contry" model="res.partner.bank.type.field"> | 20 | <record id="base.bank_normal_field_contry" model="res.partner.bank.type.field"> |
980 | 21 | <field name="name">country_id</field> | 21 | <field name="name">country_id</field> |
981 | 22 | <field name="bank_type_id" ref="base.bank_normal"/> | 22 | <field name="bank_type_id" ref="base.bank_normal"/> |
982 | 23 | <field eval="False" name="required"/> | 23 | <field eval="False" name="required"/> |
983 | 24 | <field eval="False" name="readonly"/> | 24 | <field eval="False" name="readonly"/> |
984 | 25 | </record> | 25 | </record> |
985 | 26 | <!-- Add manual bank transfer as default payment option --> | 26 | <!-- Add manual bank transfer as default payment option --> |
987 | 27 | <record model="payment.type" id="account_banking.manual_bank_tranfer"> | 27 | <record model="payment.mode.type" id="account_banking.manual_bank_tranfer"> |
988 | 28 | <field name="name">Manual Bank Transfer</field> | 28 | <field name="name">Manual Bank Transfer</field> |
989 | 29 | <field name="code">BANKMAN</field> | 29 | <field name="code">BANKMAN</field> |
990 | 30 | <field name="suitable_bank_types" | 30 | <field name="suitable_bank_types" |
991 | 31 | 31 | ||
992 | === modified file 'account_banking/security/ir.model.access.csv' | |||
993 | --- account_banking/security/ir.model.access.csv 2010-12-20 10:58:51 +0000 | |||
994 | +++ account_banking/security/ir.model.access.csv 2011-11-23 10:40:16 +0000 | |||
995 | @@ -1,3 +1,5 @@ | |||
996 | 1 | "id","name","model_id:id","group_id:id","perm_read","perm_write","perm_create","perm_unlink" | 1 | "id","name","model_id:id","group_id:id","perm_read","perm_write","perm_create","perm_unlink" |
997 | 2 | "access_account_banking_settings","account.banking.account.settings","model_account_banking_account_settings","account.group_account_manager",1,1,1,1 | 2 | "access_account_banking_settings","account.banking.account.settings","model_account_banking_account_settings","account.group_account_manager",1,1,1,1 |
998 | 3 | "access_account_banking_settings_user","account.banking.account.settings user","model_account_banking_account_settings","account.group_account_user",1,0,0,0 | ||
999 | 3 | "access_account_banking_import","account.bankimport","model_account_banking_imported_file","account.group_account_user",1,1,1,1 | 4 | "access_account_banking_import","account.bankimport","model_account_banking_imported_file","account.group_account_user",1,1,1,1 |
1000 | 5 | "access_payment_mode_type","payment.mode.type","model_payment_mode_type","account_payment.group_account_payment",1,1,1,1 | ||
1001 | 4 | 6 | ||
1002 | === modified file 'account_banking/wizard/__init__.py' | |||
1003 | --- account_banking/wizard/__init__.py 2011-02-12 13:37:09 +0000 | |||
1004 | +++ account_banking/wizard/__init__.py 2011-11-23 10:40:16 +0000 | |||
1005 | @@ -20,6 +20,6 @@ | |||
1006 | 20 | ############################################################################## | 20 | ############################################################################## |
1007 | 21 | import bank_import | 21 | import bank_import |
1008 | 22 | import bank_payment_manual | 22 | import bank_payment_manual |
1010 | 23 | import wizard_payment_order | 23 | import account_payment_order |
1011 | 24 | 24 | ||
1012 | 25 | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: | 25 | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: |
1013 | 26 | 26 | ||
1014 | === added file 'account_banking/wizard/account_payment_order.py' | |||
1015 | --- account_banking/wizard/account_payment_order.py 1970-01-01 00:00:00 +0000 | |||
1016 | +++ account_banking/wizard/account_payment_order.py 2011-11-23 10:40:16 +0000 | |||
1017 | @@ -0,0 +1,113 @@ | |||
1018 | 1 | # -*- coding: utf-8 -*- | ||
1019 | 2 | ############################################################################## | ||
1020 | 3 | # | ||
1021 | 4 | # Copyright (C) 2009 EduSense BV (<http://www.edusense.nl>). | ||
1022 | 5 | # All Rights Reserved | ||
1023 | 6 | # | ||
1024 | 7 | # This program is free software: you can redistribute it and/or modify | ||
1025 | 8 | # it under the terms of the GNU General Public License as published by | ||
1026 | 9 | # the Free Software Foundation, either version 3 of the License, or | ||
1027 | 10 | # (at your option) any later version. | ||
1028 | 11 | # | ||
1029 | 12 | # This program is distributed in the hope that it will be useful, | ||
1030 | 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1031 | 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1032 | 15 | # GNU General Public License for more details. | ||
1033 | 16 | # | ||
1034 | 17 | # You should have received a copy of the GNU General Public License | ||
1035 | 18 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1036 | 19 | # | ||
1037 | 20 | ############################################################################## | ||
1038 | 21 | |||
1039 | 22 | import datetime | ||
1040 | 23 | from osv import osv | ||
1041 | 24 | from account_banking.struct import struct | ||
1042 | 25 | from account_banking.parsers import convert | ||
1043 | 26 | |||
1044 | 27 | today = datetime.date.today | ||
1045 | 28 | |||
1046 | 29 | def str2date(str): | ||
1047 | 30 | dt = convert.str2date(str, '%Y-%m-%d') | ||
1048 | 31 | return datetime.date(dt.year, dt.month, dt.day) | ||
1049 | 32 | |||
1050 | 33 | class payment_order_create(osv.osv_memory): | ||
1051 | 34 | _inherit = 'payment.order.create' | ||
1052 | 35 | |||
1053 | 36 | def create_payment(self, cr, uid, ids, context=None): | ||
1054 | 37 | ''' | ||
1055 | 38 | This method is a slightly modified version of the existing method on this | ||
1056 | 39 | model in account_payment. | ||
1057 | 40 | - pass the payment mode to line2bank() | ||
1058 | 41 | - allow invoices to create influence on the payment process: not only 'Free' | ||
1059 | 42 | references are allowed, but others as well | ||
1060 | 43 | - check date_to_pay is not in the past. | ||
1061 | 44 | ''' | ||
1062 | 45 | |||
1063 | 46 | order_obj = self.pool.get('payment.order') | ||
1064 | 47 | line_obj = self.pool.get('account.move.line') | ||
1065 | 48 | payment_obj = self.pool.get('payment.line') | ||
1066 | 49 | if context is None: | ||
1067 | 50 | context = {} | ||
1068 | 51 | data = self.read(cr, uid, ids, [], context=context)[0] | ||
1069 | 52 | line_ids = data['entries'] | ||
1070 | 53 | if not line_ids: | ||
1071 | 54 | return {'type': 'ir.actions.act_window_close'} | ||
1072 | 55 | |||
1073 | 56 | payment = order_obj.browse(cr, uid, context['active_id'], context=context) | ||
1074 | 57 | ### account banking | ||
1075 | 58 | # t = None | ||
1076 | 59 | # line2bank = line_obj.line2bank(cr, uid, line_ids, t, context) | ||
1077 | 60 | line2bank = line_obj.line2bank(cr, uid, line_ids, payment.mode.id, context) | ||
1078 | 61 | _today = today() | ||
1079 | 62 | ### end account banking | ||
1080 | 63 | |||
1081 | 64 | ## Finally populate the current payment with new lines: | ||
1082 | 65 | for line in line_obj.browse(cr, uid, line_ids, context=context): | ||
1083 | 66 | if payment.date_prefered == "now": | ||
1084 | 67 | #no payment date => immediate payment | ||
1085 | 68 | date_to_pay = False | ||
1086 | 69 | elif payment.date_prefered == 'due': | ||
1087 | 70 | ### account_banking | ||
1088 | 71 | # date_to_pay = line.date_maturity | ||
1089 | 72 | date_to_pay = line.date_maturity and \ | ||
1090 | 73 | str2date(line.date_maturity) > _today\ | ||
1091 | 74 | and line.date_maturity or False | ||
1092 | 75 | ### end account banking | ||
1093 | 76 | elif payment.date_prefered == 'fixed': | ||
1094 | 77 | ### account_banking | ||
1095 | 78 | # date_to_pay = payment.date_planned | ||
1096 | 79 | date_to_pay = payment.date_planned and \ | ||
1097 | 80 | str2date(payment.date_planned) > _today\ | ||
1098 | 81 | and payment.date_planned or False | ||
1099 | 82 | ### end account banking | ||
1100 | 83 | |||
1101 | 84 | ### account_banking | ||
1102 | 85 | state = communication2 = False | ||
1103 | 86 | communication = line.ref or '/' | ||
1104 | 87 | if line.invoice: | ||
1105 | 88 | if line.invoice.reference_type == 'structured': | ||
1106 | 89 | state = 'structured' | ||
1107 | 90 | communication = line.invoice.reference | ||
1108 | 91 | else: | ||
1109 | 92 | state = 'normal' | ||
1110 | 93 | communication2 = line.invoice.reference | ||
1111 | 94 | ### end account_banking | ||
1112 | 95 | |||
1113 | 96 | payment_obj.create(cr, uid,{ | ||
1114 | 97 | 'move_line_id': line.id, | ||
1115 | 98 | 'amount_currency': line.amount_to_pay, | ||
1116 | 99 | 'bank_id': line2bank.get(line.id), | ||
1117 | 100 | 'order_id': payment.id, | ||
1118 | 101 | 'partner_id': line.partner_id and line.partner_id.id or False, | ||
1119 | 102 | ### account banking | ||
1120 | 103 | # 'communication': line.ref or '/' | ||
1121 | 104 | 'communication': communication, | ||
1122 | 105 | 'communication2': communication2, | ||
1123 | 106 | 'state': state, | ||
1124 | 107 | ### end account banking | ||
1125 | 108 | 'date': date_to_pay, | ||
1126 | 109 | 'currency': line.invoice and line.invoice.currency_id.id or False, | ||
1127 | 110 | }, context=context) | ||
1128 | 111 | return {'type': 'ir.actions.act_window_close'} | ||
1129 | 112 | |||
1130 | 113 | payment_order_create() | ||
1131 | 0 | 114 | ||
1132 | === modified file 'account_banking/wizard/bank_import.py' | |||
1133 | --- account_banking/wizard/bank_import.py 2011-11-07 22:23:48 +0000 | |||
1134 | +++ account_banking/wizard/bank_import.py 2011-11-23 10:40:16 +0000 | |||
1135 | @@ -28,9 +28,8 @@ | |||
1136 | 28 | The parsing is done in the parser modules. Every parser module is required to | 28 | The parsing is done in the parser modules. Every parser module is required to |
1137 | 29 | use parser.models as a mean of communication with the business logic. | 29 | use parser.models as a mean of communication with the business logic. |
1138 | 30 | ''' | 30 | ''' |
1140 | 31 | import pooler | 31 | from osv import osv, fields |
1141 | 32 | import time | 32 | import time |
1142 | 33 | import wizard | ||
1143 | 34 | import netsvc | 33 | import netsvc |
1144 | 35 | import base64 | 34 | import base64 |
1145 | 36 | import datetime | 35 | import datetime |
1146 | @@ -41,6 +40,7 @@ | |||
1147 | 41 | from account_banking.struct import struct | 40 | from account_banking.struct import struct |
1148 | 42 | from account_banking import sepa | 41 | from account_banking import sepa |
1149 | 43 | from banktools import * | 42 | from banktools import * |
1150 | 43 | import decimal_precision as dp | ||
1151 | 44 | 44 | ||
1152 | 45 | bt = models.mem_bank_transaction | 45 | bt = models.mem_bank_transaction |
1153 | 46 | 46 | ||
1154 | @@ -55,6 +55,7 @@ | |||
1155 | 55 | ''' | 55 | ''' |
1156 | 56 | return models.parser_type.get_parser_types() | 56 | return models.parser_type.get_parser_types() |
1157 | 57 | 57 | ||
1158 | 58 | <<<<<<< TREE | ||
1159 | 58 | class banking_import(wizard.interface): | 59 | class banking_import(wizard.interface): |
1160 | 59 | ''' | 60 | ''' |
1161 | 60 | Wizard to import bank statements. Generic code, parsing is done in the | 61 | Wizard to import bank statements. Generic code, parsing is done in the |
1162 | @@ -130,10 +131,14 @@ | |||
1163 | 130 | 131 | ||
1164 | 131 | def _fill_results(self, *args, **kwargs): | 132 | def _fill_results(self, *args, **kwargs): |
1165 | 132 | return {'log': self._log} | 133 | return {'log': self._log} |
1166 | 134 | ======= | ||
1167 | 135 | class banking_import(osv.osv_memory): | ||
1168 | 136 | _name = 'account.banking.bank.import' | ||
1169 | 137 | >>>>>>> MERGE-SOURCE | ||
1170 | 133 | 138 | ||
1171 | 134 | def _get_move_info(self, cursor, uid, move_line, partner_bank_id=False, | 139 | def _get_move_info(self, cursor, uid, move_line, partner_bank_id=False, |
1172 | 135 | partial=False): | 140 | partial=False): |
1174 | 136 | reconcile_obj = self.pool.get('account.bank.statement.reconcile') | 141 | reconcile_obj = self.pool.get('account.move.reconcile') |
1175 | 137 | type_map = { | 142 | type_map = { |
1176 | 138 | 'out_invoice': 'customer', | 143 | 'out_invoice': 'customer', |
1177 | 139 | 'in_invoice': 'supplier', | 144 | 'in_invoice': 'supplier', |
1178 | @@ -153,7 +158,14 @@ | |||
1179 | 153 | 158 | ||
1180 | 154 | if partial: | 159 | if partial: |
1181 | 155 | move_line.reconcile_partial_id = reconcile_obj.create( | 160 | move_line.reconcile_partial_id = reconcile_obj.create( |
1182 | 161 | <<<<<<< TREE | ||
1183 | 156 | cursor, uid, {'line_partial_ids': [(6, 0, [move_line.id])]} | 162 | cursor, uid, {'line_partial_ids': [(6, 0, [move_line.id])]} |
1184 | 163 | ======= | ||
1185 | 164 | cursor, uid, { | ||
1186 | 165 | 'type': 'auto', | ||
1187 | 166 | 'line_partial_ids': [(4, 0, [move_line.id])] | ||
1188 | 167 | } | ||
1189 | 168 | >>>>>>> MERGE-SOURCE | ||
1190 | 157 | ) | 169 | ) |
1191 | 158 | else: | 170 | else: |
1192 | 159 | if move_line.reconcile_partial_id: | 171 | if move_line.reconcile_partial_id: |
1193 | @@ -164,7 +176,12 @@ | |||
1194 | 164 | partial_ids = [] | 176 | partial_ids = [] |
1195 | 165 | move_line.reconcile_id = reconcile_obj.create( | 177 | move_line.reconcile_id = reconcile_obj.create( |
1196 | 166 | cursor, uid, { | 178 | cursor, uid, { |
1197 | 179 | <<<<<<< TREE | ||
1198 | 167 | 'line_ids': [ | 180 | 'line_ids': [ |
1199 | 181 | ======= | ||
1200 | 182 | 'type': 'auto', | ||
1201 | 183 | 'line_id': [ | ||
1202 | 184 | >>>>>>> MERGE-SOURCE | ||
1203 | 168 | (4, x, False) for x in [move_line.id] + partial_ids | 185 | (4, x, False) for x in [move_line.id] + partial_ids |
1204 | 169 | ], | 186 | ], |
1205 | 170 | 'line_partial_ids': [ | 187 | 'line_partial_ids': [ |
1206 | @@ -228,12 +245,13 @@ | |||
1207 | 228 | return [] | 245 | return [] |
1208 | 229 | 246 | ||
1209 | 230 | def _link_payment(self, cursor, uid, trans, payment_lines, | 247 | def _link_payment(self, cursor, uid, trans, payment_lines, |
1211 | 231 | partner_ids, bank_account_ids, log): | 248 | partner_ids, bank_account_ids, log, linked_payments): |
1212 | 232 | ''' | 249 | ''' |
1213 | 233 | Find the payment order belonging to this reference - if there is one | 250 | Find the payment order belonging to this reference - if there is one |
1214 | 234 | When sending payments, the returned bank info should be identical to | 251 | When sending payments, the returned bank info should be identical to |
1215 | 235 | ours. | 252 | ours. |
1216 | 236 | ''' | 253 | ''' |
1217 | 254 | <<<<<<< TREE | ||
1218 | 237 | # TODO: | 255 | # TODO: |
1219 | 238 | # 1. Not sure what side effects are created when payments are done | 256 | # 1. Not sure what side effects are created when payments are done |
1220 | 239 | # for credited customer invoices, which will be matched later on | 257 | # for credited customer invoices, which will be matched later on |
1221 | @@ -247,6 +265,11 @@ | |||
1222 | 247 | # intertwined. Ignoring this causes double processing of the same | 265 | # intertwined. Ignoring this causes double processing of the same |
1223 | 248 | # payment line. | 266 | # payment line. |
1224 | 249 | 267 | ||
1225 | 268 | ======= | ||
1226 | 269 | # TODO: Not sure what side effects are created when payments are done | ||
1227 | 270 | # for credited customer invoices, which will be matched later on too. | ||
1228 | 271 | digits = dp.get_precision('Account')(cursor)[1] | ||
1229 | 272 | >>>>>>> MERGE-SOURCE | ||
1230 | 250 | candidates = [x for x in payment_lines | 273 | candidates = [x for x in payment_lines |
1231 | 251 | if x.id not in self.__linked_payments and | 274 | if x.id not in self.__linked_payments and |
1232 | 252 | (not self._cached(x.move_line_id)) and | 275 | (not self._cached(x.move_line_id)) and |
1233 | @@ -260,6 +283,7 @@ | |||
1234 | 260 | ] | 283 | ] |
1235 | 261 | if len(candidates) == 1: | 284 | if len(candidates) == 1: |
1236 | 262 | candidate = candidates[0] | 285 | candidate = candidates[0] |
1237 | 286 | <<<<<<< TREE | ||
1238 | 263 | self.__linked_payments[candidate.id] = True | 287 | self.__linked_payments[candidate.id] = True |
1239 | 264 | self._cache(candidate.move_line_id) | 288 | self._cache(candidate.move_line_id) |
1240 | 265 | payment_line_obj = self.pool.get('payment.line') | 289 | payment_line_obj = self.pool.get('payment.line') |
1241 | @@ -271,12 +295,21 @@ | |||
1242 | 271 | cursor, uid, candidate.move_line_id, | 295 | cursor, uid, candidate.move_line_id, |
1243 | 272 | partner_bank_id=\ | 296 | partner_bank_id=\ |
1244 | 273 | bank_account_ids and bank_account_ids[0].id or False | 297 | bank_account_ids and bank_account_ids[0].id or False |
1245 | 298 | ======= | ||
1246 | 299 | # Check cache to prevent multiple matching of a single payment | ||
1247 | 300 | if candidate.id not in linked_payments: | ||
1248 | 301 | linked_payments[candidate.id] = True | ||
1249 | 302 | payment_line_obj = self.pool.get('payment.line') | ||
1250 | 303 | payment_line_obj.write(cursor, uid, [candidate.id], { | ||
1251 | 304 | 'export_state': 'done', | ||
1252 | 305 | 'date_done': trans.effective_date.strftime('%Y-%m-%d')} | ||
1253 | 306 | >>>>>>> MERGE-SOURCE | ||
1254 | 274 | ) | 307 | ) |
1255 | 275 | 308 | ||
1256 | 276 | return False | 309 | return False |
1257 | 277 | 310 | ||
1258 | 278 | def _link_invoice(self, cursor, uid, trans, move_lines, | 311 | def _link_invoice(self, cursor, uid, trans, move_lines, |
1260 | 279 | partner_ids, bank_account_ids, log): | 312 | partner_ids, bank_account_ids, log, linked_invoices): |
1261 | 280 | ''' | 313 | ''' |
1262 | 281 | Find the invoice belonging to this reference - if there is one | 314 | Find the invoice belonging to this reference - if there is one |
1263 | 282 | Use the sales journal to check. | 315 | Use the sales journal to check. |
1264 | @@ -360,6 +393,22 @@ | |||
1265 | 360 | 393 | ||
1266 | 361 | return False | 394 | return False |
1267 | 362 | 395 | ||
1268 | 396 | <<<<<<< TREE | ||
1269 | 397 | ======= | ||
1270 | 398 | def _cached(move_line): | ||
1271 | 399 | '''Check if the move_line has been cached''' | ||
1272 | 400 | return move_line.id in linked_invoices | ||
1273 | 401 | |||
1274 | 402 | def _cache(move_line, remaining=0.0): | ||
1275 | 403 | '''Cache the move_line''' | ||
1276 | 404 | linked_invoices[move_line.id] = remaining | ||
1277 | 405 | |||
1278 | 406 | def _remaining(move_line): | ||
1279 | 407 | '''Return the remaining amount for a previously matched move_line | ||
1280 | 408 | ''' | ||
1281 | 409 | return linked_invoices[move_line.id] | ||
1282 | 410 | |||
1283 | 411 | >>>>>>> MERGE-SOURCE | ||
1284 | 363 | def _sign(invoice): | 412 | def _sign(invoice): |
1285 | 364 | '''Return the direction of an invoice''' | 413 | '''Return the direction of an invoice''' |
1286 | 365 | return {'in_invoice': -1, | 414 | return {'in_invoice': -1, |
1287 | @@ -368,7 +417,7 @@ | |||
1288 | 368 | 'out_refund': -1 | 417 | 'out_refund': -1 |
1289 | 369 | }[invoice.type] | 418 | }[invoice.type] |
1290 | 370 | 419 | ||
1292 | 371 | digits = int(config['price_accuracy']) | 420 | digits = dp.get_precision('Account')(cursor)[1] |
1293 | 372 | partial = False | 421 | partial = False |
1294 | 373 | 422 | ||
1295 | 374 | # Search invoice on partner | 423 | # Search invoice on partner |
1296 | @@ -465,8 +514,6 @@ | |||
1297 | 465 | for x in best or candidates | 514 | for x in best or candidates |
1298 | 466 | ]) | 515 | ]) |
1299 | 467 | }) | 516 | }) |
1300 | 468 | self.__multiple_matches.append((trans, best or | ||
1301 | 469 | candidates)) | ||
1302 | 470 | move_line = False | 517 | move_line = False |
1303 | 471 | partial = False | 518 | partial = False |
1304 | 472 | 519 | ||
1305 | @@ -543,7 +590,7 @@ | |||
1306 | 543 | if not account_info.costs_account_id: | 590 | if not account_info.costs_account_id: |
1307 | 544 | return [] | 591 | return [] |
1308 | 545 | 592 | ||
1310 | 546 | digits = int(config['price_accuracy']) | 593 | digits = dp.get_precision('Account')(cursor)[1] |
1311 | 547 | amount = round(abs(trans.transferred_amount), digits) | 594 | amount = round(abs(trans.transferred_amount), digits) |
1312 | 548 | # Make sure to be able to pinpoint our costs invoice for later | 595 | # Make sure to be able to pinpoint our costs invoice for later |
1313 | 549 | # matching | 596 | # matching |
1314 | @@ -591,14 +638,10 @@ | |||
1315 | 591 | invoice_line = invoice_lines, | 638 | invoice_line = invoice_lines, |
1316 | 592 | )) | 639 | )) |
1317 | 593 | invoice = invoice_obj.browse(cursor, uid, invoice_id) | 640 | invoice = invoice_obj.browse(cursor, uid, invoice_id) |
1318 | 594 | # Set number | ||
1319 | 595 | invoice.action_number(cursor, uid, [invoice_id]) | ||
1320 | 596 | # Create moves | ||
1321 | 597 | invoice.action_move_create(cursor, uid, [invoice_id]) | ||
1322 | 598 | # Create workflow | 641 | # Create workflow |
1323 | 642 | invoice_obj.button_compute(cursor, uid, [invoice_id], | ||
1324 | 643 | {'type': 'in_invoice'}, set_total=True) | ||
1325 | 599 | wf_service = netsvc.LocalService('workflow') | 644 | wf_service = netsvc.LocalService('workflow') |
1326 | 600 | res = wf_service.trg_create(uid, 'account.invoice', invoice.id, | ||
1327 | 601 | cursor) | ||
1328 | 602 | # Move to state 'open' | 645 | # Move to state 'open' |
1329 | 603 | wf_service.trg_validate(uid, 'account.invoice', invoice.id, | 646 | wf_service.trg_validate(uid, 'account.invoice', invoice.id, |
1330 | 604 | 'invoice_open', cursor) | 647 | 'invoice_open', cursor) |
1331 | @@ -606,17 +649,16 @@ | |||
1332 | 606 | # return move_lines to mix with the rest | 649 | # return move_lines to mix with the rest |
1333 | 607 | return [x for x in invoice.move_id.line_id if x.account_id.reconcile] | 650 | return [x for x in invoice.move_id.line_id if x.account_id.reconcile] |
1334 | 608 | 651 | ||
1336 | 609 | def _import_statements_file(self, cursor, uid, data, context): | 652 | def import_statements_file(self, cursor, uid, ids, context): |
1337 | 610 | ''' | 653 | ''' |
1338 | 611 | Import bank statements / bank transactions file. | 654 | Import bank statements / bank transactions file. |
1339 | 612 | This method represents the business logic, the parser modules | 655 | This method represents the business logic, the parser modules |
1340 | 613 | represent the decoding logic. | 656 | represent the decoding logic. |
1341 | 614 | ''' | 657 | ''' |
1344 | 615 | form = data['form'] | 658 | banking_import = self.browse(cursor, uid, ids, context)[0] |
1345 | 616 | statements_file = form['file'] | 659 | statements_file = banking_import.file |
1346 | 617 | data = base64.decodestring(statements_file) | 660 | data = base64.decodestring(statements_file) |
1347 | 618 | 661 | ||
1348 | 619 | self.pool = pooler.get_pool(cursor.dbname) | ||
1349 | 620 | company_obj = self.pool.get('res.company') | 662 | company_obj = self.pool.get('res.company') |
1350 | 621 | user_obj = self.pool.get('res.user') | 663 | user_obj = self.pool.get('res.user') |
1351 | 622 | partner_obj = self.pool.get('res.partner') | 664 | partner_obj = self.pool.get('res.partner') |
1352 | @@ -632,28 +674,24 @@ | |||
1353 | 632 | digits = int(config['price_accuracy']) | 674 | digits = int(config['price_accuracy']) |
1354 | 633 | 675 | ||
1355 | 634 | # get the parser to parse the file | 676 | # get the parser to parse the file |
1357 | 635 | parser_code = form['parser'] | 677 | parser_code = banking_import.parser |
1358 | 636 | parser = models.create_parser(parser_code) | 678 | parser = models.create_parser(parser_code) |
1359 | 637 | if not parser: | 679 | if not parser: |
1361 | 638 | raise wizard.except_wizard( | 680 | raise osv.except_osv( |
1362 | 639 | _('ERROR!'), | 681 | _('ERROR!'), |
1363 | 640 | _('Unable to import parser %(parser)s. Parser class not found.') % | 682 | _('Unable to import parser %(parser)s. Parser class not found.') % |
1365 | 641 | {'parser':parser_code} | 683 | {'parser': parser_code} |
1366 | 642 | ) | 684 | ) |
1367 | 643 | 685 | ||
1368 | 644 | # Get the company | 686 | # Get the company |
1375 | 645 | company = form['company'] | 687 | company = (banking_import.company or |
1376 | 646 | if not company: | 688 | user_obj.browse(cursor, uid, uid, context).company_id) |
1371 | 647 | user_data = user_obj.browse(cursor, uid, uid, context) | ||
1372 | 648 | company = company_obj.browse( | ||
1373 | 649 | cursor, uid, company or user_data.company_id.id, context | ||
1374 | 650 | ) | ||
1377 | 651 | 689 | ||
1378 | 652 | # Parse the file | 690 | # Parse the file |
1379 | 653 | statements = parser.parse(data) | 691 | statements = parser.parse(data) |
1380 | 654 | 692 | ||
1381 | 655 | if any([x for x in statements if not x.is_valid()]): | 693 | if any([x for x in statements if not x.is_valid()]): |
1383 | 656 | raise wizard.except_wizard( | 694 | raise osv.except_osv( |
1384 | 657 | _('ERROR!'), | 695 | _('ERROR!'), |
1385 | 658 | _('The imported statements appear to be invalid! Check your file.') | 696 | _('The imported statements appear to be invalid! Check your file.') |
1386 | 659 | ) | 697 | ) |
1387 | @@ -682,6 +720,9 @@ | |||
1388 | 682 | error_accounts = {} | 720 | error_accounts = {} |
1389 | 683 | info = {} | 721 | info = {} |
1390 | 684 | imported_statement_ids = [] | 722 | imported_statement_ids = [] |
1391 | 723 | linked_payments = {} | ||
1392 | 724 | linked_invoices = {} | ||
1393 | 725 | payment_lines = [] | ||
1394 | 685 | 726 | ||
1395 | 686 | if statements: | 727 | if statements: |
1396 | 687 | # Get default defaults | 728 | # Get default defaults |
1397 | @@ -690,7 +731,8 @@ | |||
1398 | 690 | 731 | ||
1399 | 691 | # Get interesting journals once | 732 | # Get interesting journals once |
1400 | 692 | journal_ids = journal_obj.search(cursor, uid, [ | 733 | journal_ids = journal_obj.search(cursor, uid, [ |
1402 | 693 | ('type', 'in', ('sale','purchase')), | 734 | ('type', 'in', ('sale','purchase', |
1403 | 735 | 'purchase_refund','sale_refund')), | ||
1404 | 694 | ('company_id', '=', company.id), | 736 | ('company_id', '=', company.id), |
1405 | 695 | ]) | 737 | ]) |
1406 | 696 | # Get all unreconciled moves predating the last statement in one big | 738 | # Get all unreconciled moves predating the last statement in one big |
1407 | @@ -718,6 +760,7 @@ | |||
1408 | 718 | "o.state = 'sent' AND " | 760 | "o.state = 'sent' AND " |
1409 | 719 | "l.date_done IS NULL" | 761 | "l.date_done IS NULL" |
1410 | 720 | ) | 762 | ) |
1411 | 763 | <<<<<<< TREE | ||
1412 | 721 | line_ids = [x[0] for x in cursor.fetchall()] | 764 | line_ids = [x[0] for x in cursor.fetchall()] |
1413 | 722 | if line_ids: | 765 | if line_ids: |
1414 | 723 | # Get payment_orders and calculated total amounts as well in | 766 | # Get payment_orders and calculated total amounts as well in |
1415 | @@ -740,6 +783,11 @@ | |||
1416 | 740 | order_totals.keys() | 783 | order_totals.keys() |
1417 | 741 | )) | 784 | )) |
1418 | 742 | ] | 785 | ] |
1419 | 786 | ======= | ||
1420 | 787 | payment_line_ids = [x[0] for x in cursor.fetchall()] | ||
1421 | 788 | if payment_line_ids: | ||
1422 | 789 | payment_lines = payment_line_obj.browse(cursor, uid, payment_line_ids) | ||
1423 | 790 | >>>>>>> MERGE-SOURCE | ||
1424 | 743 | 791 | ||
1425 | 744 | for statement in statements: | 792 | for statement in statements: |
1426 | 745 | if statement.local_account in error_accounts: | 793 | if statement.local_account in error_accounts: |
1427 | @@ -749,7 +797,7 @@ | |||
1428 | 749 | continue | 797 | continue |
1429 | 750 | 798 | ||
1430 | 751 | # Create fallback currency code | 799 | # Create fallback currency code |
1432 | 752 | currency_code = statement.local_currency or company.currency_id.code | 800 | currency_code = statement.local_currency or company.currency_id.name |
1433 | 753 | 801 | ||
1434 | 754 | # Check cache for account info/currency | 802 | # Check cache for account info/currency |
1435 | 755 | if statement.local_account in info and \ | 803 | if statement.local_account in info and \ |
1436 | @@ -781,7 +829,7 @@ | |||
1437 | 781 | continue | 829 | continue |
1438 | 782 | 830 | ||
1439 | 783 | # Get required currency code | 831 | # Get required currency code |
1441 | 784 | currency_code = account_info.currency_id.code | 832 | currency_code = account_info.currency_id.name |
1442 | 785 | 833 | ||
1443 | 786 | # Cache results | 834 | # Cache results |
1444 | 787 | if not statement.local_account in info: | 835 | if not statement.local_account in info: |
1445 | @@ -793,7 +841,7 @@ | |||
1446 | 793 | 841 | ||
1447 | 794 | # Final check: no coercion of currencies! | 842 | # Final check: no coercion of currencies! |
1448 | 795 | if statement.local_currency \ | 843 | if statement.local_currency \ |
1450 | 796 | and account_info.currency_id.code != statement.local_currency: | 844 | and account_info.currency_id.name != statement.local_currency: |
1451 | 797 | # TODO: convert currencies? | 845 | # TODO: convert currencies? |
1452 | 798 | results.log.append( | 846 | results.log.append( |
1453 | 799 | _('Statement %(statement_id)s for account %(bank_account)s' | 847 | _('Statement %(statement_id)s for account %(bank_account)s' |
1454 | @@ -970,7 +1018,7 @@ | |||
1455 | 970 | move_info = self._link_payment( | 1018 | move_info = self._link_payment( |
1456 | 971 | cursor, uid, transaction, | 1019 | cursor, uid, transaction, |
1457 | 972 | payment_lines, partner_ids, | 1020 | payment_lines, partner_ids, |
1459 | 973 | partner_banks, results.log | 1021 | partner_banks, results.log, linked_payments, |
1460 | 974 | ) | 1022 | ) |
1461 | 975 | 1023 | ||
1462 | 976 | # Second guess, invoice -> may split transaction, so beware | 1024 | # Second guess, invoice -> may split transaction, so beware |
1463 | @@ -980,7 +1028,7 @@ | |||
1464 | 980 | # these, and invoice matching still has to be done. | 1028 | # these, and invoice matching still has to be done. |
1465 | 981 | move_info, remainder = self._link_invoice( | 1029 | move_info, remainder = self._link_invoice( |
1466 | 982 | cursor, uid, transaction, move_lines, partner_ids, | 1030 | cursor, uid, transaction, move_lines, partner_ids, |
1468 | 983 | partner_banks, results.log | 1031 | partner_banks, results.log, linked_invoices, |
1469 | 984 | ) | 1032 | ) |
1470 | 985 | if remainder: | 1033 | if remainder: |
1471 | 986 | injected.append(remainder) | 1034 | injected.append(remainder) |
1472 | @@ -1087,107 +1135,71 @@ | |||
1473 | 1087 | state = results.error_cnt and 'error' or 'ready' | 1135 | state = results.error_cnt and 'error' or 'ready' |
1474 | 1088 | statement_file_obj.write(cursor, uid, import_id, dict( | 1136 | statement_file_obj.write(cursor, uid, import_id, dict( |
1475 | 1089 | state = state, log = text_log, | 1137 | state = state, log = text_log, |
1578 | 1090 | )) | 1138 | ), context) |
1579 | 1091 | if results.error_cnt or not imported_statement_ids: | 1139 | if not imported_statement_ids: |
1580 | 1092 | self._nextstate = 'view_error' | 1140 | # file state can be 'ready' while import state is 'error' |
1581 | 1093 | else: | 1141 | state = 'error' |
1582 | 1094 | self._nextstate = 'view_statements' | 1142 | self.write(cursor, uid, [ids[0]], dict( |
1583 | 1095 | self._import_id = import_id | 1143 | import_id = import_id, log = text_log, state = state, |
1584 | 1096 | self._log = text_log | 1144 | statement_ids = [[6, 0, imported_statement_ids]], |
1585 | 1097 | self._statement_ids = imported_statement_ids | 1145 | ), context) |
1586 | 1098 | return {} | 1146 | return { |
1587 | 1099 | 1147 | 'name': _('Import Bank Transactions File'), | |
1588 | 1100 | def _action_open_window(self, cursor, uid, data, context): | 1148 | 'view_type': 'form', |
1589 | 1101 | ''' | 1149 | 'view_mode': 'form', |
1590 | 1102 | Open a window with the resulting bank statements | 1150 | 'view_id': False, |
1591 | 1103 | ''' | 1151 | 'res_model': self._name, |
1592 | 1104 | # TODO: this needs fiddling. The resulting window is informative, | 1152 | 'domain': [], |
1593 | 1105 | # but not very usefull... | 1153 | 'context': dict(context, active_ids=ids), |
1594 | 1106 | module_obj = self.pool.get('ir.model.data') | 1154 | 'type': 'ir.actions.act_window', |
1595 | 1107 | action_obj = self.pool.get('ir.actions.act_window') | 1155 | 'target': 'new', |
1596 | 1108 | result = module_obj._get_id( | 1156 | 'res_id': ids[0] or False, |
1597 | 1109 | cursor, uid, 'account', 'action_bank_statement_tree' | 1157 | } |
1598 | 1110 | ) | 1158 | |
1599 | 1111 | id = module_obj.read(cursor, uid, [result], ['res_id'])[0]['res_id'] | 1159 | _columns = { |
1600 | 1112 | result = action_obj.read(cursor, uid, [id])[0] | 1160 | 'company': fields.many2one( |
1601 | 1113 | result['context'] = str({'banking_id': self._import_id}) | 1161 | 'res.company', 'Company', required=True, |
1602 | 1114 | return result | 1162 | states={ |
1603 | 1115 | 1163 | 'ready': [('readonly', True)], | |
1604 | 1116 | def _action_open_import(self, cursor, uid, data, context): | 1164 | 'error': [('readonly', True)], |
1605 | 1117 | ''' | 1165 | }, |
1606 | 1118 | Open a window with the resulting import in error | 1166 | ), |
1607 | 1119 | ''' | 1167 | 'file': fields.binary( |
1608 | 1120 | return dict( | 1168 | 'Statements File', required=True, |
1609 | 1121 | view_type = 'form', | 1169 | help = ('The Transactions File to import. Please note that while it is ' |
1610 | 1122 | view_mode = 'form,tree', | 1170 | 'perfectly safe to reload the same file multiple times or to load in ' |
1611 | 1123 | res_model = 'account.banking.imported.file', | 1171 | 'timeframe overlapping statements files, there are formats that may ' |
1612 | 1124 | view_id = False, | 1172 | 'introduce different sequencing, which may create double entries.\n\n' |
1613 | 1125 | type = 'ir.actions.act_window', | 1173 | 'To stay on the safe side, always load bank statements files using the ' |
1614 | 1126 | res_id = self._import_id | 1174 | 'same format.'), |
1615 | 1127 | ) | 1175 | states={ |
1616 | 1128 | 1176 | 'ready': [('readonly', True)], | |
1617 | 1129 | def _check_next_state(self, cursor, uid, data, context): | 1177 | 'error': [('readonly', True)], |
1618 | 1130 | return self._nextstate | 1178 | }, |
1619 | 1131 | 1179 | ), | |
1620 | 1132 | states = { | 1180 | 'parser': fields.selection( |
1621 | 1133 | 'init' : { | 1181 | parser_types, 'File Format', required=True, |
1622 | 1134 | 'actions' : [], | 1182 | states={ |
1623 | 1135 | 'result' : { | 1183 | 'ready': [('readonly', True)], |
1624 | 1136 | 'type' : 'form', | 1184 | 'error': [('readonly', True)], |
1625 | 1137 | 'arch' : import_form, | 1185 | }, |
1626 | 1138 | 'fields': import_fields, | 1186 | ), |
1627 | 1139 | 'state': [('end', '_Cancel', 'gtk-cancel'), | 1187 | 'log': fields.text('Log', readonly=True), |
1628 | 1140 | ('import', '_Ok', 'gtk-ok'), | 1188 | 'state': fields.selection( |
1629 | 1141 | ] | 1189 | [('init', 'init'), ('ready', 'ready'), |
1630 | 1142 | } | 1190 | ('error', 'error')], |
1631 | 1143 | }, | 1191 | 'State', readonly=True), |
1632 | 1144 | 'import': { | 1192 | 'import_id': fields.many2one( |
1633 | 1145 | 'actions': [_import_statements_file], | 1193 | 'account.banking.imported.file', 'Import File'), |
1634 | 1146 | 'result': { | 1194 | # osv_memory does not seem to support one2many |
1635 | 1147 | 'type': 'choice', | 1195 | 'statement_ids': fields.many2many( |
1636 | 1148 | 'next_state': _check_next_state, | 1196 | 'account.bank.statement', 'rel_wiz_statements', 'wizard_id', |
1637 | 1149 | } | 1197 | 'statement_id', 'Imported Bank Statements'), |
1638 | 1150 | }, | 1198 | } |
1639 | 1151 | 'view_statements' : { | 1199 | |
1640 | 1152 | 'actions': [_fill_results], | 1200 | _defaults = { |
1641 | 1153 | 'result': { | 1201 | 'state': 'init', |
1642 | 1154 | 'type': 'form', | 1202 | } |
1643 | 1155 | 'arch': result_form, | 1203 | banking_import() |
1542 | 1156 | 'fields': result_fields, | ||
1543 | 1157 | 'state': [('end', '_Close', 'gtk-close'), | ||
1544 | 1158 | ('open_statements', '_View Statements', 'gtk-ok'), | ||
1545 | 1159 | ] | ||
1546 | 1160 | } | ||
1547 | 1161 | }, | ||
1548 | 1162 | 'view_error': { | ||
1549 | 1163 | 'actions': [_fill_results], | ||
1550 | 1164 | 'result': { | ||
1551 | 1165 | 'type': 'form', | ||
1552 | 1166 | 'arch': result_form, | ||
1553 | 1167 | 'fields': result_fields, | ||
1554 | 1168 | 'state': [('end', '_Close', 'gtk-close'), | ||
1555 | 1169 | ('open_import', '_View Imported File', 'gtk-ok'), | ||
1556 | 1170 | ] | ||
1557 | 1171 | } | ||
1558 | 1172 | }, | ||
1559 | 1173 | 'open_import': { | ||
1560 | 1174 | 'actions': [], | ||
1561 | 1175 | 'result': { | ||
1562 | 1176 | 'type': 'action', | ||
1563 | 1177 | 'action': _action_open_import, | ||
1564 | 1178 | 'state': 'end' | ||
1565 | 1179 | } | ||
1566 | 1180 | }, | ||
1567 | 1181 | 'open_statements': { | ||
1568 | 1182 | 'actions': [], | ||
1569 | 1183 | 'result': { | ||
1570 | 1184 | 'type': 'action', | ||
1571 | 1185 | 'action': _action_open_window, | ||
1572 | 1186 | 'state': 'end' | ||
1573 | 1187 | } | ||
1574 | 1188 | }, | ||
1575 | 1189 | } | ||
1576 | 1190 | |||
1577 | 1191 | banking_import('account_banking.banking_import') | ||
1644 | 1192 | 1204 | ||
1645 | 1193 | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: | 1205 | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: |
1646 | 1194 | 1206 | ||
1647 | === added file 'account_banking/wizard/bank_import_view.xml' | |||
1648 | --- account_banking/wizard/bank_import_view.xml 1970-01-01 00:00:00 +0000 | |||
1649 | +++ account_banking/wizard/bank_import_view.xml 2011-11-23 10:40:16 +0000 | |||
1650 | @@ -0,0 +1,52 @@ | |||
1651 | 1 | <?xml version="1.0" encoding="utf-8"?> | ||
1652 | 2 | <openerp> | ||
1653 | 3 | <data> | ||
1654 | 4 | <record id="view_banking_import" model="ir.ui.view"> | ||
1655 | 5 | <field name="name">account.banking.bank.import</field> | ||
1656 | 6 | <field name="model">account.banking.bank.import</field> | ||
1657 | 7 | <field name="type">form</field> | ||
1658 | 8 | <field name="arch" type="xml"> | ||
1659 | 9 | <form string="Import Bank Transactions File"> | ||
1660 | 10 | <group colspan="4"> | ||
1661 | 11 | <separator colspan="4" string="Select the processing details:"/> | ||
1662 | 12 | <field name="company" colspan="1"/> | ||
1663 | 13 | <field name="file"/> | ||
1664 | 14 | <newline /> | ||
1665 | 15 | <field name="parser"/> | ||
1666 | 16 | <field name="state" invisible="1"/> | ||
1667 | 17 | </group> | ||
1668 | 18 | <group colspan="4" states="ready,error"> | ||
1669 | 19 | <separator colspan="4" string="Results:"/> | ||
1670 | 20 | <field name="log" colspan="4" nolabel="1" width="500"/> | ||
1671 | 21 | </group> | ||
1672 | 22 | <group colspan="4" states="ready"> | ||
1673 | 23 | <field name="statement_ids" colspan="4" nolabel="1"/> | ||
1674 | 24 | </group> | ||
1675 | 25 | <group colspan="2" states="init"> | ||
1676 | 26 | <button icon="gtk-cancel" | ||
1677 | 27 | special="cancel" | ||
1678 | 28 | string="Cancel"/> | ||
1679 | 29 | <button icon="gtk-ok" | ||
1680 | 30 | string="Import" | ||
1681 | 31 | name="import_statements_file" | ||
1682 | 32 | type="object"/> | ||
1683 | 33 | </group> | ||
1684 | 34 | <button icon="gtk-close" | ||
1685 | 35 | special="cancel" | ||
1686 | 36 | string="Close" | ||
1687 | 37 | states="ready,error"/> | ||
1688 | 38 | </form> | ||
1689 | 39 | </field> | ||
1690 | 40 | </record> | ||
1691 | 41 | |||
1692 | 42 | <record id="wizard_account_banking_import_file" model="ir.actions.act_window"> | ||
1693 | 43 | <field name="name">Import Bank Statements File</field> | ||
1694 | 44 | <field name="type">ir.actions.act_window</field> | ||
1695 | 45 | <field name="res_model">account.banking.bank.import</field> | ||
1696 | 46 | <field name="view_type">form</field> | ||
1697 | 47 | <field name="view_mode">tree,form</field> | ||
1698 | 48 | <field name="view_id" ref="view_banking_import"/> | ||
1699 | 49 | <field name="target">new</field> | ||
1700 | 50 | </record> | ||
1701 | 51 | </data> | ||
1702 | 52 | </openerp> | ||
1703 | 0 | 53 | ||
1704 | === modified file 'account_banking/wizard/banktools.py' | |||
1705 | --- account_banking/wizard/banktools.py 2011-04-27 11:42:52 +0000 | |||
1706 | +++ account_banking/wizard/banktools.py 2011-11-23 10:40:16 +0000 | |||
1707 | @@ -216,12 +216,12 @@ | |||
1708 | 216 | # Find matching journal for currency | 216 | # Find matching journal for currency |
1709 | 217 | journal_obj = pool.get('account.journal') | 217 | journal_obj = pool.get('account.journal') |
1710 | 218 | journal_ids = journal_obj.search(cursor, uid, [ | 218 | journal_ids = journal_obj.search(cursor, uid, [ |
1713 | 219 | ('type', '=', 'cash'), | 219 | ('type', '=', 'bank'), |
1714 | 220 | ('currency', '=', currency or company.currency_id.code) | 220 | ('currency', '=', currency or company.currency_id.name) |
1715 | 221 | ]) | 221 | ]) |
1717 | 222 | if not journal_ids and currency == company.currency_id.code: | 222 | if not journal_ids and currency == company.currency_id.name: |
1718 | 223 | journal_ids = journal_obj.search(cursor, uid, [ | 223 | journal_ids = journal_obj.search(cursor, uid, [ |
1720 | 224 | ('type', '=', 'cash'), ('currency', '=', False) | 224 | ('type', '=', 'bank'), ('currency', '=', False) |
1721 | 225 | ]) | 225 | ]) |
1722 | 226 | if journal_ids: | 226 | if journal_ids: |
1723 | 227 | criteria.append(('journal_id', 'in', journal_ids)) | 227 | criteria.append(('journal_id', 'in', journal_ids)) |
1724 | @@ -302,9 +302,9 @@ | |||
1725 | 302 | else: | 302 | else: |
1726 | 303 | info = struct(name=name, code=code) | 303 | info = struct(name=name, code=code) |
1727 | 304 | 304 | ||
1729 | 305 | if info.code and ((not online) or not bank_id): | 305 | if not online or not bank_id: |
1730 | 306 | bank_id = bank_obj.create(cursor, uid, dict( | 306 | bank_id = bank_obj.create(cursor, uid, dict( |
1732 | 307 | code = info.code, | 307 | code = info.code or 'UNKNOW', |
1733 | 308 | name = info.name or _('Unknown Bank'), | 308 | name = info.name or _('Unknown Bank'), |
1734 | 309 | country = country_id, | 309 | country = country_id, |
1735 | 310 | bic = bic, | 310 | bic = bic, |
1736 | @@ -341,12 +341,18 @@ | |||
1737 | 341 | cursor, uid, partner_id).country | 341 | cursor, uid, partner_id).country |
1738 | 342 | country_code = country.code | 342 | country_code = country.code |
1739 | 343 | country_id = country.id | 343 | country_id = country.id |
1744 | 344 | elif iban.valid: | 344 | else: |
1745 | 345 | country_ids = country_obj.search(cursor, uid, | 345 | if iban.valid: |
1746 | 346 | [('code', '=', iban.countrycode)] | 346 | country_ids = country_obj.search(cursor, uid, |
1747 | 347 | ) | 347 | [('code', '=', iban.countrycode)] |
1748 | 348 | ) | ||
1749 | 349 | else: | ||
1750 | 350 | country_ids = country_obj.search(cursor, uid, | ||
1751 | 351 | [('code', '=', country_code)] | ||
1752 | 352 | ) | ||
1753 | 348 | country_id = country_ids[0] | 353 | country_id = country_ids[0] |
1754 | 349 | 354 | ||
1755 | 355 | account_info = False | ||
1756 | 350 | if not iban.valid: | 356 | if not iban.valid: |
1757 | 351 | # No, try to convert to IBAN | 357 | # No, try to convert to IBAN |
1758 | 352 | values.state = 'bank' | 358 | values.state = 'bank' |
1759 | @@ -362,9 +368,11 @@ | |||
1760 | 362 | bic = account_info.bic | 368 | bic = account_info.bic |
1761 | 363 | 369 | ||
1762 | 364 | if bic: | 370 | if bic: |
1764 | 365 | values.bank_id = get_or_create_bank(pool, cursor, uid, bic) | 371 | values.bank = get_or_create_bank(pool, cursor, uid, bic)[0] |
1765 | 366 | 372 | ||
1767 | 367 | elif bankcode: | 373 | else: |
1768 | 374 | if not bankcode: | ||
1769 | 375 | bankcode = "UNKNOW" | ||
1770 | 368 | # Try to link bank | 376 | # Try to link bank |
1771 | 369 | bank_obj = pool.get('res.bank') | 377 | bank_obj = pool.get('res.bank') |
1772 | 370 | bank_ids = bank_obj.search(cursor, uid, [ | 378 | bank_ids = bank_obj.search(cursor, uid, [ |
1773 | @@ -372,10 +380,10 @@ | |||
1774 | 372 | ]) | 380 | ]) |
1775 | 373 | if bank_ids: | 381 | if bank_ids: |
1776 | 374 | # Check BIC on existing banks | 382 | # Check BIC on existing banks |
1779 | 375 | values.bank_id = bank_ids[0] | 383 | values.bank = bank_ids[0] |
1780 | 376 | bank = bank_obj.browse(cursor, uid, values.bank_id) | 384 | bank = bank_obj.browse(cursor, uid, values.bank) |
1781 | 377 | if not bank.bic: | 385 | if not bank.bic: |
1783 | 378 | bank_obj.write(cursor, uid, values.bank_id, dict(bic=bic)) | 386 | bank_obj.write(cursor, uid, values.bank, dict(bic=bic)) |
1784 | 379 | else: | 387 | else: |
1785 | 380 | # New bank - create | 388 | # New bank - create |
1786 | 381 | res = struct(country_id=country_id) | 389 | res = struct(country_id=country_id) |
1787 | @@ -389,7 +397,7 @@ | |||
1788 | 389 | res.code = bankcode | 397 | res.code = bankcode |
1789 | 390 | res.name = _('Unknown Bank') | 398 | res.name = _('Unknown Bank') |
1790 | 391 | 399 | ||
1792 | 392 | values.bank_id = bank_obj.create(cursor, uid, res) | 400 | values.bank = bank_obj.create(cursor, uid, res) |
1793 | 393 | 401 | ||
1794 | 394 | # Create bank account and return | 402 | # Create bank account and return |
1795 | 395 | return pool.get('res.partner.bank').create(cursor, uid, values) | 403 | return pool.get('res.partner.bank').create(cursor, uid, values) |
1796 | 396 | 404 | ||
1797 | === removed file 'account_banking/wizard/wizard_payment_order.py' | |||
1798 | --- account_banking/wizard/wizard_payment_order.py 2011-02-13 09:28:59 +0000 | |||
1799 | +++ account_banking/wizard/wizard_payment_order.py 1970-01-01 00:00:00 +0000 | |||
1800 | @@ -1,212 +0,0 @@ | |||
1801 | 1 | # -*- encoding: utf-8 -*- | ||
1802 | 2 | ############################################################################## | ||
1803 | 3 | # | ||
1804 | 4 | # Copyright (C) EduSense BV (<http://www.edusense.nl>). | ||
1805 | 5 | # All Rights Reserved. | ||
1806 | 6 | # | ||
1807 | 7 | # OpenERP, Open Source Management Solution | ||
1808 | 8 | # Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). All Rights Reserved | ||
1809 | 9 | # | ||
1810 | 10 | # This program is free software: you can redistribute it and/or modify | ||
1811 | 11 | # it under the terms of the GNU General Public License as published by | ||
1812 | 12 | # the Free Software Foundation, either version 3 of the License, or | ||
1813 | 13 | # (at your option) any later version. | ||
1814 | 14 | # | ||
1815 | 15 | # This program is distributed in the hope that it will be useful, | ||
1816 | 16 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1817 | 17 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1818 | 18 | # GNU General Public License for more details. | ||
1819 | 19 | # | ||
1820 | 20 | # You should have received a copy of the GNU General Public License | ||
1821 | 21 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1822 | 22 | # | ||
1823 | 23 | ############################################################################## | ||
1824 | 24 | import datetime | ||
1825 | 25 | import wizard | ||
1826 | 26 | import pooler | ||
1827 | 27 | from tools.misc import UpdateableStr | ||
1828 | 28 | from tools.translate import _ | ||
1829 | 29 | from account_banking.struct import struct | ||
1830 | 30 | from account_banking.parsers import convert | ||
1831 | 31 | |||
1832 | 32 | __doc__ = ''' | ||
1833 | 33 | This module is a slightly modified version of the identical named payment | ||
1834 | 34 | order wizard in account_payment. The rationale for this bulk copy is the | ||
1835 | 35 | inability to inherit wizards in OpenERP versions prior to version 6. | ||
1836 | 36 | The modifications in this wizard allows invoices to create influence on the | ||
1837 | 37 | payment process: not only 'Free' references are allowed, but others as well. | ||
1838 | 38 | |||
1839 | 39 | In order to allow further projects based on account_banking to inherit from | ||
1840 | 40 | this wizard, the complete wizard is made object oriented, as is should have | ||
1841 | 41 | been from the start. | ||
1842 | 42 | ''' | ||
1843 | 43 | |||
1844 | 44 | today = datetime.date.today | ||
1845 | 45 | |||
1846 | 46 | def str2date(str): | ||
1847 | 47 | dt = convert.str2date(str, '%Y-%m-%d') | ||
1848 | 48 | return datetime.date(dt.year, dt.month, dt.day) | ||
1849 | 49 | |||
1850 | 50 | class wizard_payment_order(wizard.interface): | ||
1851 | 51 | ''' | ||
1852 | 52 | Create a payment object with lines corresponding to the account move line | ||
1853 | 53 | to pay according to the date and the mode provided by the user. | ||
1854 | 54 | Hypothesis: | ||
1855 | 55 | - Small number of non-reconcilied move line , payment mode and bank account type, | ||
1856 | 56 | - Big number of partner and bank account. | ||
1857 | 57 | |||
1858 | 58 | If a type is given, unsuitable account move lines are ignored. | ||
1859 | 59 | ''' | ||
1860 | 60 | |||
1861 | 61 | FORM = UpdateableStr() | ||
1862 | 62 | FIELDS = { | ||
1863 | 63 | 'entries': { | ||
1864 | 64 | 'string':'Entries', | ||
1865 | 65 | 'type':'many2many', | ||
1866 | 66 | 'relation': 'account.move.line', | ||
1867 | 67 | }, | ||
1868 | 68 | } | ||
1869 | 69 | field_duedate = { | ||
1870 | 70 | 'duedate': { | ||
1871 | 71 | 'string': 'Due Date', | ||
1872 | 72 | 'type': 'date', | ||
1873 | 73 | 'required': True, | ||
1874 | 74 | 'default': lambda *a: convert.date2str(today()), | ||
1875 | 75 | }, | ||
1876 | 76 | } | ||
1877 | 77 | arch_duedate='''<?xml version="1.0"?> | ||
1878 | 78 | <form string="Search Payment lines"> | ||
1879 | 79 | <field name="duedate" /> | ||
1880 | 80 | </form>''' | ||
1881 | 81 | |||
1882 | 82 | |||
1883 | 83 | def search_entries(self, cursor, uid, data, context): | ||
1884 | 84 | ''' | ||
1885 | 85 | Search for invoices that can be paid | ||
1886 | 86 | ''' | ||
1887 | 87 | search_due_date = data['form']['duedate'] | ||
1888 | 88 | |||
1889 | 89 | pool = pooler.get_pool(cursor.dbname) | ||
1890 | 90 | order_obj = pool.get('payment.order') | ||
1891 | 91 | move_line_obj = pool.get('account.move.line') | ||
1892 | 92 | |||
1893 | 93 | payment = order_obj.browse(cursor, uid, data['id'], context=context) | ||
1894 | 94 | if payment.mode: | ||
1895 | 95 | ctx = '''context="{'journal_id': %d}"''' % payment.mode.journal.id | ||
1896 | 96 | else: | ||
1897 | 97 | ctx = '' | ||
1898 | 98 | |||
1899 | 99 | # Search account.move.line to pay: | ||
1900 | 100 | domain = [ | ||
1901 | 101 | ('reconcile_id', '=', False), | ||
1902 | 102 | ('account_id.type', '=', 'payable'), | ||
1903 | 103 | ('amount_to_pay', '>', 0), | ||
1904 | 104 | '|', ('date_maturity','<=',search_due_date), | ||
1905 | 105 | ('date_maturity','=',False) | ||
1906 | 106 | ] | ||
1907 | 107 | line_ids = move_line_obj.search(cursor, uid, domain, context=context) | ||
1908 | 108 | self.FORM.string = '''<?xml version="1.0"?> | ||
1909 | 109 | <form string="Populate Payment:"> | ||
1910 | 110 | <field name="entries" colspan="4" height="300" width="800" nolabel="1" | ||
1911 | 111 | domain="[('id', 'in', [%s])]" %s | ||
1912 | 112 | /> | ||
1913 | 113 | </form>''' % (','.join([str(x) for x in line_ids]), ctx) | ||
1914 | 114 | return {} | ||
1915 | 115 | |||
1916 | 116 | def get_communication(self, line): | ||
1917 | 117 | ''' | ||
1918 | 118 | Method to fill the communication and communication2 lines of a payment | ||
1919 | 119 | line. Returns (state, comm1, comm2). | ||
1920 | 120 | ''' | ||
1921 | 121 | if line.invoice.reference_type == 'structured': | ||
1922 | 122 | return ('structured', line.invoice.reference, '') | ||
1923 | 123 | return ('normal', '', line.invoice.reference) | ||
1924 | 124 | |||
1925 | 125 | def create_payment(self, cursor, uid, data, context): | ||
1926 | 126 | ''' | ||
1927 | 127 | Create payment lines from the data of previously created payable | ||
1928 | 128 | invoices | ||
1929 | 129 | ''' | ||
1930 | 130 | ids = data['form']['entries'][0][2] | ||
1931 | 131 | if not ids: | ||
1932 | 132 | return {} | ||
1933 | 133 | |||
1934 | 134 | pool = pooler.get_pool(cursor.dbname) | ||
1935 | 135 | order_obj = pool.get('payment.order') | ||
1936 | 136 | move_line_obj = pool.get('account.move.line') | ||
1937 | 137 | payment_line_obj = pool.get('payment.line') | ||
1938 | 138 | |||
1939 | 139 | payment = order_obj.browse(cursor, uid, data['id'], context=context) | ||
1940 | 140 | ptype = payment.mode and payment.mode.type.id or None | ||
1941 | 141 | line2bank = move_line_obj.line2bank(cursor, uid, ids, ptype, context) | ||
1942 | 142 | _today = today() | ||
1943 | 143 | retval = struct() | ||
1944 | 144 | |||
1945 | 145 | # Populate the current payment with new lines | ||
1946 | 146 | for line in move_line_obj.browse(cursor, uid, ids, context=context): | ||
1947 | 147 | if payment.date_prefered == 'now': | ||
1948 | 148 | # no payment date means immediate payment | ||
1949 | 149 | date_to_pay = False | ||
1950 | 150 | elif payment.date_prefered == 'due': | ||
1951 | 151 | date_to_pay = line.date_maturity and \ | ||
1952 | 152 | str2date(line.date_maturity) > _today\ | ||
1953 | 153 | and line.date_maturity or False | ||
1954 | 154 | elif payment.date_prefered == 'fixed': | ||
1955 | 155 | date_to_pay = payment.date_planned and \ | ||
1956 | 156 | str2date(payment.date_planned) > _today\ | ||
1957 | 157 | and payment.date_planned or False | ||
1958 | 158 | values = struct( | ||
1959 | 159 | move_line_id = line.id, | ||
1960 | 160 | amount_currency = line.amount_to_pay, | ||
1961 | 161 | bank_id = line2bank.get(line.id), | ||
1962 | 162 | order_id = payment.id, | ||
1963 | 163 | partner_id = line.partner_id and line.partner_id.id or False, | ||
1964 | 164 | date = date_to_pay, | ||
1965 | 165 | currency = False, | ||
1966 | 166 | ) | ||
1967 | 167 | if line.invoice: | ||
1968 | 168 | values.state, values.communication, values.communication2 = \ | ||
1969 | 169 | self.get_communication(line) | ||
1970 | 170 | values.currency = line.invoice.currency_id.id, | ||
1971 | 171 | payment_line_obj.create(cursor, uid, values, context=context) | ||
1972 | 172 | |||
1973 | 173 | return {} | ||
1974 | 174 | |||
1975 | 175 | states = { | ||
1976 | 176 | 'init': { | ||
1977 | 177 | 'actions': [], | ||
1978 | 178 | 'result': { | ||
1979 | 179 | 'type': 'form', | ||
1980 | 180 | 'arch': arch_duedate, | ||
1981 | 181 | 'fields': field_duedate, | ||
1982 | 182 | 'state': [ | ||
1983 | 183 | ('end','_Cancel'), | ||
1984 | 184 | ('search','_Search', '', True) | ||
1985 | 185 | ] | ||
1986 | 186 | }, | ||
1987 | 187 | }, | ||
1988 | 188 | 'search': { | ||
1989 | 189 | 'actions': [search_entries], | ||
1990 | 190 | 'result': { | ||
1991 | 191 | 'type': 'form', | ||
1992 | 192 | 'arch': FORM, | ||
1993 | 193 | 'fields': FIELDS, | ||
1994 | 194 | 'state': [ | ||
1995 | 195 | ('end','_Cancel'), | ||
1996 | 196 | ('create','_Add to payment order', '', True) | ||
1997 | 197 | ] | ||
1998 | 198 | }, | ||
1999 | 199 | }, | ||
2000 | 200 | 'create': { | ||
2001 | 201 | 'actions': [], | ||
2002 | 202 | 'result': { | ||
2003 | 203 | 'type': 'action', | ||
2004 | 204 | 'action': create_payment, | ||
2005 | 205 | 'state': 'end' | ||
2006 | 206 | } | ||
2007 | 207 | }, | ||
2008 | 208 | } | ||
2009 | 209 | |||
2010 | 210 | wizard_payment_order('account_payment.populate_payment') | ||
2011 | 211 | |||
2012 | 212 | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: | ||
2013 | 213 | 0 | ||
2014 | === modified file 'account_banking_fi_patu/__terp__.py' | |||
2015 | --- account_banking_fi_patu/__terp__.py 2011-11-08 13:10:34 +0000 | |||
2016 | +++ account_banking_fi_patu/__terp__.py 2011-11-23 10:40:16 +0000 | |||
2017 | @@ -33,9 +33,8 @@ | |||
2018 | 33 | 'category': 'Account Banking', | 33 | 'category': 'Account Banking', |
2019 | 34 | 'depends': ['account_banking'], | 34 | 'depends': ['account_banking'], |
2020 | 35 | 'description': ''' | 35 | 'description': ''' |
2024 | 36 | Module to import Finnish PATU format transation files. | 36 | Do not install this module. This branch has been replaced by lp:banking-addons/6.0 |
2025 | 37 | 37 | See https://launchpad.net/banking-addons | |
2023 | 38 | This modules contains no logic, just an import filter for account_banking. | ||
2026 | 39 | ''', | 38 | ''', |
2027 | 40 | 'active': False, | 39 | 'active': False, |
2028 | 41 | 'installable': True, | 40 | 'installable': True, |
2029 | 42 | 41 | ||
2030 | === modified file 'account_banking_nl_abnamro/__openerp__.py' | |||
2031 | --- account_banking_nl_abnamro/__openerp__.py 2011-04-26 21:00:12 +0000 | |||
2032 | +++ account_banking_nl_abnamro/__openerp__.py 2011-11-23 10:40:16 +0000 | |||
2033 | @@ -39,14 +39,8 @@ | |||
2034 | 39 | ], | 39 | ], |
2035 | 40 | 'demo_xml': [], | 40 | 'demo_xml': [], |
2036 | 41 | 'description': ''' | 41 | 'description': ''' |
2045 | 42 | Import filter for abnamro (NL) bank transaction files (txt/tab format). | 42 | Do not install this module. This branch has been replaced by lp:banking-addons/6.0 |
2046 | 43 | 43 | See https://launchpad.net/banking-addons | |
2039 | 44 | No formal specifications of the file layout are released by abnamro. You can | ||
2040 | 45 | help improve the performance of this import filter on | ||
2041 | 46 | https://launchpad.net/account-banking. | ||
2042 | 47 | |||
2043 | 48 | Imported bank transfers are organized in statements covering periods of one week, | ||
2044 | 49 | even if the imported files cover a different period. | ||
2047 | 50 | ''', | 44 | ''', |
2048 | 51 | 'active': False, | 45 | 'active': False, |
2049 | 52 | 'installable': True, | 46 | 'installable': True, |
2050 | 53 | 47 | ||
2051 | === modified file 'account_banking_nl_abnamro/__terp__.py' | |||
2052 | --- account_banking_nl_abnamro/__terp__.py 2011-11-08 13:10:34 +0000 | |||
2053 | +++ account_banking_nl_abnamro/__terp__.py 2011-11-23 10:40:16 +0000 | |||
2054 | @@ -39,14 +39,8 @@ | |||
2055 | 39 | ], | 39 | ], |
2056 | 40 | 'demo_xml': [], | 40 | 'demo_xml': [], |
2057 | 41 | 'description': ''' | 41 | 'description': ''' |
2066 | 42 | Import filter for abnamro (NL) bank transaction files (txt/tab format). | 42 | Do not install this module. This branch has been replaced by lp:banking-addons/6.0 |
2067 | 43 | 43 | See https://launchpad.net/banking-addons | |
2060 | 44 | No formal specifications of the file layout are released by abnamro. You can | ||
2061 | 45 | help improve the performance of this import filter on | ||
2062 | 46 | https://launchpad.net/account-banking. | ||
2063 | 47 | |||
2064 | 48 | Imported bank transfers are organized in statements covering periods of one week, | ||
2065 | 49 | even if the imported files cover a different period. | ||
2068 | 50 | ''', | 44 | ''', |
2069 | 51 | 'active': False, | 45 | 'active': False, |
2070 | 52 | 'installable': True, | 46 | 'installable': True, |
2071 | 53 | 47 | ||
2072 | === modified file 'account_banking_nl_clieop/__terp__.py' | |||
2073 | --- account_banking_nl_clieop/__terp__.py 2011-11-08 13:10:34 +0000 | |||
2074 | +++ account_banking_nl_clieop/__terp__.py 2011-11-23 10:40:16 +0000 | |||
2075 | @@ -25,7 +25,11 @@ | |||
2076 | 25 | ############################################################################## | 25 | ############################################################################## |
2077 | 26 | { | 26 | { |
2078 | 27 | 'name': 'Account Banking NL ClieOp', | 27 | 'name': 'Account Banking NL ClieOp', |
2079 | 28 | <<<<<<< TREE | ||
2080 | 28 | 'version': '0.67', | 29 | 'version': '0.67', |
2081 | 30 | ======= | ||
2082 | 31 | 'version': '0.63', | ||
2083 | 32 | >>>>>>> MERGE-SOURCE | ||
2084 | 29 | 'license': 'GPL-3', | 33 | 'license': 'GPL-3', |
2085 | 30 | 'author': 'EduSense BV', | 34 | 'author': 'EduSense BV', |
2086 | 31 | 'website': 'http://www.edusense.nl', | 35 | 'website': 'http://www.edusense.nl', |
2087 | @@ -33,17 +37,15 @@ | |||
2088 | 33 | 'depends': ['account_banking'], | 37 | 'depends': ['account_banking'], |
2089 | 34 | 'init_xml': [], | 38 | 'init_xml': [], |
2090 | 35 | 'update_xml': [ | 39 | 'update_xml': [ |
2091 | 36 | #'security/ir.model.access.csv', | ||
2092 | 37 | 'account_banking_nl_clieop.xml', | 40 | 'account_banking_nl_clieop.xml', |
2094 | 38 | 'account_banking_export_wizard.xml', | 41 | 'wizard/export_clieop_view.xml', |
2095 | 39 | 'data/banking_export_clieop.xml', | 42 | 'data/banking_export_clieop.xml', |
2096 | 43 | 'security/ir.model.access.csv', | ||
2097 | 40 | ], | 44 | ], |
2098 | 41 | 'demo_xml': [], | 45 | 'demo_xml': [], |
2099 | 42 | 'description': ''' | 46 | 'description': ''' |
2104 | 43 | Module to export payment orders in ClieOp format. | 47 | Do not install this module. This branch has been replaced by lp:banking-addons/6.0 |
2105 | 44 | 48 | See https://launchpad.net/banking-addons | |
2102 | 45 | ClieOp format is used by Dutch banks to batch national bank transfers. | ||
2103 | 46 | This module uses the account_banking logic. | ||
2106 | 47 | ''', | 49 | ''', |
2107 | 48 | 'active': False, | 50 | 'active': False, |
2108 | 49 | 'installable': True, | 51 | 'installable': True, |
2109 | 50 | 52 | ||
2110 | === removed file 'account_banking_nl_clieop/account_banking_export_wizard.xml' | |||
2111 | --- account_banking_nl_clieop/account_banking_export_wizard.xml 2010-01-26 20:55:24 +0000 | |||
2112 | +++ account_banking_nl_clieop/account_banking_export_wizard.xml 1970-01-01 00:00:00 +0000 | |||
2113 | @@ -1,15 +0,0 @@ | |||
2114 | 1 | <?xml version="1.0" encoding="utf-8"?> | ||
2115 | 2 | <!-- | ||
2116 | 3 | Copyright (C) EduSense BV <http://www.edusense.nl> | ||
2117 | 4 | All rights reserved. | ||
2118 | 5 | The licence is in the file __terp__.py | ||
2119 | 6 | --> | ||
2120 | 7 | <openerp> | ||
2121 | 8 | <data> | ||
2122 | 9 | <wizard id="wizard_account_banking_export_clieop" | ||
2123 | 10 | string="Export ClieOp File" | ||
2124 | 11 | model="payment.order" | ||
2125 | 12 | name="account_banking_nl_clieop.banking_export_clieop" | ||
2126 | 13 | /> | ||
2127 | 14 | </data> | ||
2128 | 15 | </openerp> | ||
2129 | 16 | 0 | ||
2130 | === modified file 'account_banking_nl_clieop/account_banking_nl_clieop.py' | |||
2131 | --- account_banking_nl_clieop/account_banking_nl_clieop.py 2010-01-26 20:55:24 +0000 | |||
2132 | +++ account_banking_nl_clieop/account_banking_nl_clieop.py 2011-11-23 10:40:16 +0000 | |||
2133 | @@ -22,25 +22,19 @@ | |||
2134 | 22 | from datetime import date | 22 | from datetime import date |
2135 | 23 | from tools.translate import _ | 23 | from tools.translate import _ |
2136 | 24 | 24 | ||
2137 | 25 | class payment_order(osv.osv): | ||
2138 | 26 | ''' | ||
2139 | 27 | Attach export_clieop wizard to payment order and allow traceability | ||
2140 | 28 | ''' | ||
2141 | 29 | _inherit = 'payment.order' | ||
2142 | 30 | def get_wizard(self, type): | ||
2143 | 31 | if type in ['CLIEOPPAY', 'CLIEOPINC', 'CLIEOPSAL']: | ||
2144 | 32 | return self._module, 'wizard_account_banking_export_clieop' | ||
2145 | 33 | return super(payment_order, self).get_wizard(type) | ||
2146 | 34 | payment_order() | ||
2147 | 35 | |||
2148 | 36 | class clieop_export(osv.osv): | 25 | class clieop_export(osv.osv): |
2149 | 37 | '''ClieOp3 Export''' | 26 | '''ClieOp3 Export''' |
2150 | 38 | _name = 'banking.export.clieop' | 27 | _name = 'banking.export.clieop' |
2151 | 39 | _description = __doc__ | 28 | _description = __doc__ |
2152 | 29 | _rec_name = 'identification' | ||
2153 | 40 | 30 | ||
2154 | 41 | _columns = { | 31 | _columns = { |
2157 | 42 | 'payment_order_ids': | 32 | 'payment_order_ids': fields.many2many( |
2158 | 43 | fields.text('Payment Orders'), | 33 | 'payment.order', |
2159 | 34 | 'account_payment_order_clieop_rel', | ||
2160 | 35 | 'banking_export_clieop_id', 'account_order_id', | ||
2161 | 36 | 'Payment Orders', | ||
2162 | 37 | readonly=True), | ||
2163 | 44 | 'testcode': | 38 | 'testcode': |
2164 | 45 | fields.selection([('T', _('Yes')), ('P', _('No'))], | 39 | fields.selection([('T', _('Yes')), ('P', _('No'))], |
2165 | 46 | 'Test Run', readonly=True), | 40 | 'Test Run', readonly=True), |
2166 | 47 | 41 | ||
2167 | === modified file 'account_banking_nl_clieop/account_banking_nl_clieop.xml' | |||
2168 | --- account_banking_nl_clieop/account_banking_nl_clieop.xml 2010-01-28 10:59:35 +0000 | |||
2169 | +++ account_banking_nl_clieop/account_banking_nl_clieop.xml 2011-11-23 10:40:16 +0000 | |||
2170 | @@ -14,19 +14,33 @@ | |||
2171 | 14 | <field name="type">form</field> | 14 | <field name="type">form</field> |
2172 | 15 | <field name="arch" type="xml"> | 15 | <field name="arch" type="xml"> |
2173 | 16 | <form string="Client Opdrachten Export"> | 16 | <form string="Client Opdrachten Export"> |
2187 | 17 | <separator string="General Information" colspan="4" /> | 17 | <notebook> |
2188 | 18 | <field name="filetype" /> | 18 | <page string="General Information"> |
2189 | 19 | <field name="identification" /> | 19 | <field name="filetype" /> |
2190 | 20 | <separator string="ClieOp Information" colspan="4" /> | 20 | <field name="identification" /> |
2191 | 21 | <field name="total_amount" /> | 21 | <separator string="ClieOp Information" colspan="4" /> |
2192 | 22 | <field name="check_no_accounts" /> | 22 | <field name="total_amount" /> |
2193 | 23 | <field name="no_transactions" /> | 23 | <field name="check_no_accounts" /> |
2194 | 24 | <separator string="Processing Information" colspan="4" /> | 24 | <field name="no_transactions" /> |
2195 | 25 | <field name="prefered_date" /> | 25 | <separator string="Processing Information" colspan="4" /> |
2196 | 26 | <field name="date_generated" /> | 26 | <field name="prefered_date" /> |
2197 | 27 | <field name="testcode" /> | 27 | <field name="date_generated" /> |
2198 | 28 | <newline /> | 28 | <field name="testcode" /> |
2199 | 29 | <field name="file" colspan="4" /> | 29 | <newline /> |
2200 | 30 | <field name="file" colspan="4" /> | ||
2201 | 31 | </page> | ||
2202 | 32 | <page string="Payment Orders"> | ||
2203 | 33 | <field name="payment_order_ids" colspan="4" nolabel="1"> | ||
2204 | 34 | <tree colors="blue:state in ('draft');gray:state in ('cancel','done');black:state in ('open')" string="Payment order"> | ||
2205 | 35 | <field name="reference"/> | ||
2206 | 36 | <field name="date_created"/> | ||
2207 | 37 | <field name="date_done"/> | ||
2208 | 38 | <field name="total"/> | ||
2209 | 39 | <field name="state"/> | ||
2210 | 40 | </tree> | ||
2211 | 41 | </field> | ||
2212 | 42 | </page> | ||
2213 | 43 | </notebook> | ||
2214 | 30 | </form> | 44 | </form> |
2215 | 31 | </field> | 45 | </field> |
2216 | 32 | </record> | 46 | </record> |
2217 | @@ -59,5 +73,14 @@ | |||
2218 | 59 | sequence="12" | 73 | sequence="12" |
2219 | 60 | /> | 74 | /> |
2220 | 61 | 75 | ||
2221 | 76 | <!-- Create right menu entry to see generated files --> | ||
2222 | 77 | <act_window name="Generated ClieOp3 Files" | ||
2223 | 78 | domain="[('payment_order_ids', '=', active_id)]" | ||
2224 | 79 | res_model="banking.export.clieop" | ||
2225 | 80 | src_model="payment.order" | ||
2226 | 81 | view_type="form" | ||
2227 | 82 | view_mode="tree,form" | ||
2228 | 83 | id="act_banking_export_clieop_payment_order"/> | ||
2229 | 84 | |||
2230 | 62 | </data> | 85 | </data> |
2231 | 63 | </openerp> | 86 | </openerp> |
2232 | 64 | 87 | ||
2233 | === modified file 'account_banking_nl_clieop/data/banking_export_clieop.xml' | |||
2234 | --- account_banking_nl_clieop/data/banking_export_clieop.xml 2010-12-20 10:58:51 +0000 | |||
2235 | +++ account_banking_nl_clieop/data/banking_export_clieop.xml 2011-11-23 10:40:16 +0000 | |||
2236 | @@ -1,25 +1,31 @@ | |||
2237 | 1 | <?xml version="1.0" encoding="utf-8"?> | 1 | <?xml version="1.0" encoding="utf-8"?> |
2238 | 2 | <openerp> | 2 | <openerp> |
2239 | 3 | <data noupdate="1"> | 3 | <data noupdate="1"> |
2241 | 4 | <record model="payment.type" id="account_banking_nl_clieop.export_clieop_inc"> | 4 | <record model="payment.mode.type" id="account_banking_nl_clieop.export_clieop_inc"> |
2242 | 5 | <field name="name">ClieOp3 Direct Debit Batch</field> | 5 | <field name="name">ClieOp3 Direct Debit Batch</field> |
2243 | 6 | <field name="code">CLIEOPINC</field> | 6 | <field name="code">CLIEOPINC</field> |
2244 | 7 | <field name="suitable_bank_types" | 7 | <field name="suitable_bank_types" |
2245 | 8 | eval="[(6,0,[ref('base_iban.bank_iban'),ref('base.bank_normal'),])]" /> | 8 | eval="[(6,0,[ref('base_iban.bank_iban'),ref('base.bank_normal'),])]" /> |
2246 | 9 | <field name="ir_model_id" | ||
2247 | 10 | ref="account_banking_nl_clieop.model_banking_export_clieop_wizard"/> | ||
2248 | 9 | </record> | 11 | </record> |
2249 | 10 | 12 | ||
2251 | 11 | <record model="payment.type" id="account_banking_nl_clieop.export_clieop_pay"> | 13 | <record model="payment.mode.type" id="account_banking_nl_clieop.export_clieop_pay"> |
2252 | 12 | <field name="name">ClieOp3 Payment Batch</field> | 14 | <field name="name">ClieOp3 Payment Batch</field> |
2253 | 13 | <field name="code">CLIEOPPAY</field> | 15 | <field name="code">CLIEOPPAY</field> |
2254 | 14 | <field name="suitable_bank_types" | 16 | <field name="suitable_bank_types" |
2255 | 15 | eval="[(6,0,[ref('base_iban.bank_iban'),ref('base.bank_normal'),])]" /> | 17 | eval="[(6,0,[ref('base_iban.bank_iban'),ref('base.bank_normal'),])]" /> |
2256 | 18 | <field name="ir_model_id" | ||
2257 | 19 | ref="account_banking_nl_clieop.model_banking_export_clieop_wizard"/> | ||
2258 | 16 | </record> | 20 | </record> |
2259 | 17 | 21 | ||
2261 | 18 | <record model="payment.type" id="account_banking_nl_clieop.export_clieop_sal"> | 22 | <record model="payment.mode.type" id="account_banking_nl_clieop.export_clieop_sal"> |
2262 | 19 | <field name="name">ClieOp3 Salary Payment Batch</field> | 23 | <field name="name">ClieOp3 Salary Payment Batch</field> |
2263 | 20 | <field name="code">CLIEOPSAL</field> | 24 | <field name="code">CLIEOPSAL</field> |
2264 | 21 | <field name="suitable_bank_types" | 25 | <field name="suitable_bank_types" |
2265 | 22 | eval="[(6,0,[ref('base_iban.bank_iban'),ref('base.bank_normal'),])]" /> | 26 | eval="[(6,0,[ref('base_iban.bank_iban'),ref('base.bank_normal'),])]" /> |
2266 | 27 | <field name="ir_model_id" | ||
2267 | 28 | ref="account_banking_nl_clieop.model_banking_export_clieop_wizard"/> | ||
2268 | 23 | </record> | 29 | </record> |
2269 | 24 | </data> | 30 | </data> |
2270 | 25 | </openerp> | 31 | </openerp> |
2271 | 26 | 32 | ||
2272 | === added directory 'account_banking_nl_clieop/migrations' | |||
2273 | === added directory 'account_banking_nl_clieop/migrations/0.63' | |||
2274 | === added file 'account_banking_nl_clieop/migrations/0.63/post-fill-ir_model_id.py' | |||
2275 | --- account_banking_nl_clieop/migrations/0.63/post-fill-ir_model_id.py 1970-01-01 00:00:00 +0000 | |||
2276 | +++ account_banking_nl_clieop/migrations/0.63/post-fill-ir_model_id.py 2011-11-23 10:40:16 +0000 | |||
2277 | @@ -0,0 +1,44 @@ | |||
2278 | 1 | # -*- coding: utf-8 -*- | ||
2279 | 2 | ############################################################################## | ||
2280 | 3 | # | ||
2281 | 4 | # Copyright (C) 2011 Therp BV (<http://therp.nl>) | ||
2282 | 5 | # | ||
2283 | 6 | # This program is free software: you can redistribute it and/or modify | ||
2284 | 7 | # it under the terms of the GNU General Public License as published by | ||
2285 | 8 | # the Free Software Foundation, either version 3 of the License, or | ||
2286 | 9 | # (at your option) any later version. | ||
2287 | 10 | # | ||
2288 | 11 | # This program is distributed in the hope that it will be useful, | ||
2289 | 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
2290 | 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
2291 | 14 | # GNU General Public License for more details. | ||
2292 | 15 | # | ||
2293 | 16 | # You should have received a copy of the GNU General Public License | ||
2294 | 17 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
2295 | 18 | # | ||
2296 | 19 | ############################################################################## | ||
2297 | 20 | |||
2298 | 21 | """ This script covers the migration of the payment wizards from old style to | ||
2299 | 22 | new style (osv_memory). It guarantees an easy upgrade for early adopters | ||
2300 | 23 | of the 6.0 branch of this OpenERP module. Note that a migration from OpenERP | ||
2301 | 24 | 5.0 to OpenERP 6.0 with respect to this module is not covered by this script. | ||
2302 | 25 | """ | ||
2303 | 26 | |||
2304 | 27 | __name__ = "payment.mode.type:: Add new style payment wizards to existing payment mode types" | ||
2305 | 28 | |||
2306 | 29 | def migrate(cr, version): | ||
2307 | 30 | cr.execute ("UPDATE payment_mode_type" | ||
2308 | 31 | " SET ir_model_id = data1.res_id" | ||
2309 | 32 | " FROM ir_model_data data1," | ||
2310 | 33 | " ir_model_data data2" | ||
2311 | 34 | " WHERE data2.res_id = payment_mode_type.id" | ||
2312 | 35 | " AND data1.module = 'account_banking_nl_clieop'" | ||
2313 | 36 | " AND data1.model = 'ir.model'" | ||
2314 | 37 | " AND data1.name = 'model_banking_export_clieop_wizard'" | ||
2315 | 38 | " AND data2.module = 'account_banking_nl_clieop'" | ||
2316 | 39 | " AND data2.model = 'payment.mode.type'" | ||
2317 | 40 | " AND data2.name IN ('export_clieop_inc'," | ||
2318 | 41 | " 'export_clieop_pay'," | ||
2319 | 42 | " 'export_clieop_sal'" | ||
2320 | 43 | " )" | ||
2321 | 44 | ) | ||
2322 | 0 | 45 | ||
2323 | === added directory 'account_banking_nl_clieop/security' | |||
2324 | === added file 'account_banking_nl_clieop/security/ir.model.access.csv' | |||
2325 | --- account_banking_nl_clieop/security/ir.model.access.csv 1970-01-01 00:00:00 +0000 | |||
2326 | +++ account_banking_nl_clieop/security/ir.model.access.csv 2011-11-23 10:40:16 +0000 | |||
2327 | @@ -0,0 +1,2 @@ | |||
2328 | 1 | "id","name","model_id:id","group_id:id","perm_read","perm_write","perm_create","perm_unlink" | ||
2329 | 2 | "access_banking_export_clieop","banking.export.clieop","model_banking_export_clieop","account_payment.group_account_payment",1,1,1,1 | ||
2330 | 0 | 3 | ||
2331 | === modified file 'account_banking_nl_clieop/wizard/clieop.py' | |||
2332 | --- account_banking_nl_clieop/wizard/clieop.py 2011-03-10 15:25:05 +0000 | |||
2333 | +++ account_banking_nl_clieop/wizard/clieop.py 2011-11-23 10:40:16 +0000 | |||
2334 | @@ -76,7 +76,7 @@ | |||
2335 | 76 | 76 | ||
2336 | 77 | def __init__(self, id='1', seqno=1, duplicate=False): | 77 | def __init__(self, id='1', seqno=1, duplicate=False): |
2337 | 78 | super(HeaderRecord, self).__init__() | 78 | super(HeaderRecord, self).__init__() |
2339 | 79 | self.sender_id = id | 79 | self.sender_id = id or '' |
2340 | 80 | self.file_id = '%02d%02d' % (self.creation_date.day, seqno) | 80 | self.file_id = '%02d%02d' % (self.creation_date.day, seqno) |
2341 | 81 | self.duplicatecode = duplicate and '2' or '1' | 81 | self.duplicatecode = duplicate and '2' or '1' |
2342 | 82 | #}}} | 82 | #}}} |
2343 | @@ -362,7 +362,7 @@ | |||
2344 | 362 | self.header.variantcode = batch_id and 'C' or 'B' | 362 | self.header.variantcode = batch_id and 'C' or 'B' |
2345 | 363 | self.header.transactiongroup = transactiongroup | 363 | self.header.transactiongroup = transactiongroup |
2346 | 364 | self.header.batch_tracer = batch_tracer | 364 | self.header.batch_tracer = batch_tracer |
2348 | 365 | self.header.batch_id = batch_id | 365 | self.header.batch_id = batch_id or '' |
2349 | 366 | self.header.accountno_sender = rekeningnr | 366 | self.header.accountno_sender = rekeningnr |
2350 | 367 | self.sender.name_sender = sender | 367 | self.sender.name_sender = sender |
2351 | 368 | self.sender.preferred_execution_date = execution_date | 368 | self.sender.preferred_execution_date = execution_date |
2352 | 369 | 369 | ||
2353 | === modified file 'account_banking_nl_clieop/wizard/export_clieop.py' | |||
2354 | --- account_banking_nl_clieop/wizard/export_clieop.py 2011-02-12 13:37:09 +0000 | |||
2355 | +++ account_banking_nl_clieop/wizard/export_clieop.py 2011-11-23 10:40:16 +0000 | |||
2356 | @@ -19,12 +19,11 @@ | |||
2357 | 19 | # | 19 | # |
2358 | 20 | ############################################################################## | 20 | ############################################################################## |
2359 | 21 | 21 | ||
2360 | 22 | import wizard | ||
2361 | 23 | import pooler | ||
2362 | 24 | import base64 | 22 | import base64 |
2363 | 25 | from datetime import datetime, date, timedelta | 23 | from datetime import datetime, date, timedelta |
2364 | 24 | from osv import osv, fields | ||
2365 | 25 | from tools.translate import _ | ||
2366 | 26 | from account_banking import sepa | 26 | from account_banking import sepa |
2367 | 27 | from tools.translate import _ | ||
2368 | 28 | import clieop | 27 | import clieop |
2369 | 29 | 28 | ||
2370 | 30 | def strpdate(arg, format='%Y-%m-%d'): | 29 | def strpdate(arg, format='%Y-%m-%d'): |
2371 | @@ -35,151 +34,131 @@ | |||
2372 | 35 | '''shortcut''' | 34 | '''shortcut''' |
2373 | 36 | return arg.strftime(format) | 35 | return arg.strftime(format) |
2374 | 37 | 36 | ||
2402 | 38 | class wizard_banking_export_clieop(wizard.interface): | 37 | class banking_export_clieop_wizard(osv.osv_memory): |
2403 | 39 | form = '''<?xml version="1.0"?> | 38 | _name = 'banking.export.clieop.wizard' |
2404 | 40 | <form string="Client Opdrachten Export"> | 39 | _description = 'Client Opdrachten Export' |
2405 | 41 | <separator colspan="4" string="Processing Details" /> | 40 | _columns = { |
2406 | 42 | <field name="batchtype" /> | 41 | 'state': fields.selection( |
2407 | 43 | <field name="execution_date" /> | 42 | [ |
2408 | 44 | <field name="test" /> | 43 | ('create', 'Create'), |
2409 | 45 | <separator colspan="4" string="Reference for further communication" /> | 44 | ('finish', 'Finish') |
2410 | 46 | <field name="reference" colspan="2" /> | 45 | ], |
2411 | 47 | <separator colspan="4" string="Additional message for all transactions" /> | 46 | 'State', |
2412 | 48 | <field name="fixed_message" /> | 47 | readonly=True, |
2413 | 49 | </form>''' | 48 | ), |
2414 | 50 | 49 | 'reference': fields.char( | |
2415 | 51 | fields = { | 50 | 'Reference', size=5, |
2416 | 52 | 'reference' : { | 51 | help=('The bank will use this reference in feedback communication ' |
2417 | 53 | 'string': 'Reference', | 52 | 'to refer to this run. Only five characters are available.' |
2418 | 54 | 'type': 'char', | 53 | ), |
2419 | 55 | 'size': 5, | 54 | ), |
2420 | 56 | 'required': False, | 55 | 'batchtype': fields.selection( |
2421 | 57 | 'help': ('The bank will use this reference in feedback communication ' | 56 | [ |
2395 | 58 | 'to refer to this run. Only five characters are available.' | ||
2396 | 59 | ) | ||
2397 | 60 | }, | ||
2398 | 61 | 'batchtype': { | ||
2399 | 62 | 'string': 'Type', | ||
2400 | 63 | 'type': 'selection', | ||
2401 | 64 | 'selection': [ | ||
2422 | 65 | ('CLIEOPPAY', 'Payments'), | 57 | ('CLIEOPPAY', 'Payments'), |
2423 | 66 | ('CLIEOPSAL', 'Salary Payments'), | 58 | ('CLIEOPSAL', 'Salary Payments'), |
2424 | 67 | ('CLIEOPINC', 'Direct Debits'), | 59 | ('CLIEOPINC', 'Direct Debits'), |
2519 | 68 | ], | 60 | ], 'Type', readonly=True, |
2520 | 69 | 'readonly': True, | 61 | ), |
2521 | 70 | }, | 62 | 'execution_date': fields.date( |
2522 | 71 | 'execution_date': { | 63 | 'Execution Date', |
2523 | 72 | 'string': 'Execution Date', | 64 | help=('This is the date the file should be processed by the bank. ' |
2524 | 73 | 'type': 'date', | 65 | 'Don\'t choose a date beyond the nearest date in your ' |
2525 | 74 | 'required': False, | 66 | 'payments. The latest allowed date is 30 days from now.\n' |
2526 | 75 | 'help': ('This is the date the file should be processed by the bank. ' | 67 | 'Please keep in mind that banks only execute on working days ' |
2527 | 76 | 'Don\'t choose a date beyond the nearest date in your ' | 68 | 'and typically use a delay of two days between execution date ' |
2528 | 77 | 'payments. The latest allowed date is 30 days from now.\n' | 69 | 'and effective transfer date.' |
2529 | 78 | 'Please keep in mind that banks only execute on working days ' | 70 | ), |
2530 | 79 | 'and typically use a delay of two days between execution date ' | 71 | ), |
2531 | 80 | 'and effective transfer date.' | 72 | 'test': fields.boolean( |
2532 | 81 | ), | 73 | 'Test Run', |
2533 | 82 | }, | 74 | help=('Select this if you want your bank to run a test process ' |
2534 | 83 | 'test': { | 75 | 'rather then execute your orders for real.' |
2535 | 84 | 'string': 'Test Run', | 76 | ), |
2536 | 85 | 'type': 'boolean', | 77 | ), |
2537 | 86 | 'required': True, | 78 | 'fixed_message': fields.char( |
2538 | 87 | 'default': True, | 79 | 'Fixed Message', size=32, |
2539 | 88 | 'help': ('Select this if you want your bank to run a test process ' | 80 | help=('A fixed message to apply to all transactions in addition to ' |
2540 | 89 | 'rather then execute your orders for real.' | 81 | 'the individual messages.' |
2541 | 90 | ) | 82 | ), |
2542 | 91 | }, | 83 | ), |
2543 | 92 | 'fixed_message': { | 84 | # file fields |
2544 | 93 | 'string': 'Fixed Message', | 85 | 'file_id': fields.many2one( |
2545 | 94 | 'type': 'char', | 86 | 'banking.export.clieop', |
2546 | 95 | 'size': 32, | 87 | 'ClieOp File', |
2547 | 96 | 'required': False, | 88 | readonly=True |
2548 | 97 | 'default': '', | 89 | ), |
2549 | 98 | 'help': ('A fixed message to apply to all transactions in addition to ' | 90 | # fields.related does not seem to support |
2550 | 99 | 'the individual messages.' | 91 | # fields of type selection |
2551 | 100 | ), | 92 | 'testcode': fields.selection( |
2552 | 101 | }, | 93 | [('T', _('Yes')), ('P', _('No'))], |
2553 | 102 | } | 94 | 'Test Run', readonly=True, |
2554 | 103 | 95 | ), | |
2555 | 104 | file_form = '''<?xml version="1.0"?> | 96 | 'filetype': fields.selection( |
2556 | 105 | <form string="Client Opdrachten Export"> | 97 | [ |
2463 | 106 | <field name="filetype" /> | ||
2464 | 107 | <field name="identification" /> | ||
2465 | 108 | <field name="total_amount" /> | ||
2466 | 109 | <field name="check_no_accounts" /> | ||
2467 | 110 | <field name="no_transactions" /> | ||
2468 | 111 | <field name="prefered_date" /> | ||
2469 | 112 | <field name="testcode" /> | ||
2470 | 113 | <newline/> | ||
2471 | 114 | <field name="file" /> | ||
2472 | 115 | <field name="log" colspan="4" nolabel="1" /> | ||
2473 | 116 | </form>''' | ||
2474 | 117 | |||
2475 | 118 | file_fields = { | ||
2476 | 119 | 'testcode': { | ||
2477 | 120 | 'string': 'Test Run', | ||
2478 | 121 | 'type': 'selection', | ||
2479 | 122 | 'selection': [('T', _('Yes')), ('P', _('No'))], | ||
2480 | 123 | 'required': False, | ||
2481 | 124 | 'readonly': True, | ||
2482 | 125 | }, | ||
2483 | 126 | 'prefered_date': { | ||
2484 | 127 | 'string': 'Prefered Processing Date', | ||
2485 | 128 | 'type': 'date', | ||
2486 | 129 | 'required': False, | ||
2487 | 130 | 'readonly': True, | ||
2488 | 131 | }, | ||
2489 | 132 | 'no_transactions': { | ||
2490 | 133 | 'string': 'Number of Transactions', | ||
2491 | 134 | 'type': 'int', | ||
2492 | 135 | 'required': False, | ||
2493 | 136 | 'readonly': True, | ||
2494 | 137 | }, | ||
2495 | 138 | 'check_no_accounts': { | ||
2496 | 139 | 'string': 'Check Number Accounts', | ||
2497 | 140 | 'type': 'char', | ||
2498 | 141 | 'size': 5, | ||
2499 | 142 | 'required': False, | ||
2500 | 143 | 'readonly': True, | ||
2501 | 144 | }, | ||
2502 | 145 | 'total_amount': { | ||
2503 | 146 | 'string': 'Total Amount', | ||
2504 | 147 | 'type': 'float', | ||
2505 | 148 | 'required': False, | ||
2506 | 149 | 'readonly': True, | ||
2507 | 150 | }, | ||
2508 | 151 | 'identification': { | ||
2509 | 152 | 'string': 'Identification', | ||
2510 | 153 | 'type': 'char', | ||
2511 | 154 | 'size': 6, | ||
2512 | 155 | 'required': False, | ||
2513 | 156 | 'readonly': True, | ||
2514 | 157 | }, | ||
2515 | 158 | 'filetype': { | ||
2516 | 159 | 'string': 'File Type', | ||
2517 | 160 | 'type': 'selection', | ||
2518 | 161 | 'selection': [ | ||
2557 | 162 | ('CREDBET', 'Payment Batch'), | 98 | ('CREDBET', 'Payment Batch'), |
2558 | 163 | ('SALARIS', 'Salary Payment Batch'), | 99 | ('SALARIS', 'Salary Payment Batch'), |
2559 | 164 | ('INCASSO', 'Direct Debit Batch'), | 100 | ('INCASSO', 'Direct Debit Batch'), |
2578 | 165 | ], | 101 | ], |
2579 | 166 | 'required': False, | 102 | 'File Type', |
2580 | 167 | 'readonly': True, | 103 | readonly=True, |
2581 | 168 | }, | 104 | ), |
2582 | 169 | 'file': { | 105 | 'prefered_date': fields.related( |
2583 | 170 | 'string': 'ClieOp File', | 106 | 'file_id', 'prefered_date', |
2584 | 171 | 'type': 'binary', | 107 | type='date', |
2585 | 172 | 'required': False, | 108 | string='Prefered Processing Date', |
2586 | 173 | 'readonly': True, | 109 | readonly=True, |
2587 | 174 | }, | 110 | ), |
2588 | 175 | 'log': { | 111 | 'no_transactions': fields.related( |
2589 | 176 | 'string': 'Log', | 112 | 'file_id', 'no_transactions', |
2590 | 177 | 'type': 'text', | 113 | type ='integer', |
2591 | 178 | 'readonly': True, | 114 | string='Number of Transactions', |
2592 | 179 | }, | 115 | readonly=True, |
2593 | 180 | } | 116 | ), |
2594 | 181 | 117 | 'check_no_accounts': fields.related( | |
2595 | 182 | def _check_orders(self, cursor, uid, data, context): | 118 | 'file_id', 'check_no_accounts', |
2596 | 119 | type='char', size=5, | ||
2597 | 120 | string='Check Number Accounts', | ||
2598 | 121 | readonly=True, | ||
2599 | 122 | ), | ||
2600 | 123 | 'total_amount': fields.related( | ||
2601 | 124 | 'file_id', 'total_amount', | ||
2602 | 125 | type='float', | ||
2603 | 126 | string='Total Amount', | ||
2604 | 127 | readonly=True, | ||
2605 | 128 | ), | ||
2606 | 129 | 'identification': fields.related( | ||
2607 | 130 | 'file_id', 'identification', | ||
2608 | 131 | type='char', size=6, | ||
2609 | 132 | string='Identification', | ||
2610 | 133 | readonly=True, | ||
2611 | 134 | ), | ||
2612 | 135 | 'file': fields.related( | ||
2613 | 136 | 'file_id', 'file', type='binary', | ||
2614 | 137 | readonly=True, | ||
2615 | 138 | string='File', | ||
2616 | 139 | ), | ||
2617 | 140 | 'payment_order_ids': fields.many2many( | ||
2618 | 141 | 'payment.order', 'rel_wiz_payorders', 'wizard_id', | ||
2619 | 142 | 'payment_order_id', 'Payment Orders', | ||
2620 | 143 | readonly=True, | ||
2621 | 144 | ), | ||
2622 | 145 | } | ||
2623 | 146 | |||
2624 | 147 | _defaults = { | ||
2625 | 148 | 'test': True, | ||
2626 | 149 | } | ||
2627 | 150 | |||
2628 | 151 | def create(self, cursor, uid, vals, context=None): | ||
2629 | 152 | ''' | ||
2630 | 153 | Retrieve a sane set of default values based on the payment orders | ||
2631 | 154 | from the context. | ||
2632 | 155 | ''' | ||
2633 | 156 | if 'batchtype' not in vals: | ||
2634 | 157 | self.check_orders(cursor, uid, vals, context) | ||
2635 | 158 | return super(banking_export_clieop_wizard, self).create( | ||
2636 | 159 | cursor, uid, vals, context) | ||
2637 | 160 | |||
2638 | 161 | def check_orders(self, cursor, uid, vals, context): | ||
2639 | 183 | ''' | 162 | ''' |
2640 | 184 | Check payment type for all orders. | 163 | Check payment type for all orders. |
2641 | 185 | 164 | ||
2642 | @@ -191,14 +170,14 @@ | |||
2643 | 191 | Also mind that rates for batches are way higher than those for | 170 | Also mind that rates for batches are way higher than those for |
2644 | 192 | transactions. It pays to limit the number of batches. | 171 | transactions. It pays to limit the number of batches. |
2645 | 193 | ''' | 172 | ''' |
2646 | 194 | form = data['form'] | ||
2647 | 195 | today = date.today() | 173 | today = date.today() |
2650 | 196 | pool = pooler.get_pool(cursor.dbname) | 174 | payment_order_obj = self.pool.get('payment.order') |
2649 | 197 | payment_order_obj = pool.get('payment.order') | ||
2651 | 198 | 175 | ||
2652 | 176 | # Payment order ids are provided in the context | ||
2653 | 177 | payment_order_ids = context.get('active_ids', []) | ||
2654 | 199 | runs = {} | 178 | runs = {} |
2655 | 200 | # Only orders of same type can be combined | 179 | # Only orders of same type can be combined |
2657 | 201 | payment_orders = payment_order_obj.browse(cursor, uid, data['ids']) | 180 | payment_orders = payment_order_obj.browse(cursor, uid, payment_order_ids) |
2658 | 202 | for payment_order in payment_orders: | 181 | for payment_order in payment_orders: |
2659 | 203 | 182 | ||
2660 | 204 | payment_type = payment_order.mode.type.code | 183 | payment_type = payment_order.mode.type.code |
2661 | @@ -226,34 +205,33 @@ | |||
2662 | 226 | else: | 205 | else: |
2663 | 227 | execution_date = today | 206 | execution_date = today |
2664 | 228 | if execution_date and execution_date >= max_date: | 207 | if execution_date and execution_date >= max_date: |
2666 | 229 | raise wizard.except_wizard( | 208 | raise osv.except_osv( |
2667 | 230 | _('Error'), | 209 | _('Error'), |
2668 | 231 | _('You can\'t create ClieOp orders more than 30 days in advance.') | 210 | _('You can\'t create ClieOp orders more than 30 days in advance.') |
2669 | 232 | ) | 211 | ) |
2670 | 233 | # Sanity check: can't process in the past | ||
2671 | 234 | form['execution_date'] = strfdate(max(execution_date, today)) | ||
2672 | 235 | |||
2673 | 236 | if len(runs) != 1: | 212 | if len(runs) != 1: |
2675 | 237 | raise wizard.except_wizard( | 213 | raise osv.except_osv( |
2676 | 238 | _('Error'), | 214 | _('Error'), |
2677 | 239 | _('You can only combine payment orders of the same type') | 215 | _('You can only combine payment orders of the same type') |
2678 | 240 | ) | 216 | ) |
2679 | 241 | 217 | ||
2683 | 242 | form['batchtype'] = type = runs.keys()[0] | 218 | type = runs.keys()[0] |
2684 | 243 | form['reference'] = runs[type][0].reference[-5:] | 219 | vals.update({ |
2685 | 244 | return form | 220 | 'execution_date': strfdate(max(execution_date, today)), |
2686 | 221 | 'batchtype': type, | ||
2687 | 222 | 'reference': runs[type][0].reference[-5:], | ||
2688 | 223 | 'payment_order_ids': [[6, 0, payment_order_ids]], | ||
2689 | 224 | 'state': 'create', | ||
2690 | 225 | }) | ||
2691 | 245 | 226 | ||
2693 | 246 | def _create_clieop(self, cursor, uid, data, context): | 227 | def create_clieop(self, cursor, uid, ids, context): |
2694 | 247 | ''' | 228 | ''' |
2695 | 248 | Wizard to actually create the ClieOp3 file | 229 | Wizard to actually create the ClieOp3 file |
2696 | 249 | ''' | 230 | ''' |
2701 | 250 | pool = pooler.get_pool(cursor.dbname) | 231 | payment_order_obj = self.pool.get('payment.order') |
2702 | 251 | payment_order_obj = pool.get('payment.order') | 232 | clieop_export = self.browse(cursor, uid, ids, context)[0] |
2699 | 252 | form = data['form'] | ||
2700 | 253 | |||
2703 | 254 | clieopfile = None | 233 | clieopfile = None |
2706 | 255 | payment_orders = payment_order_obj.browse(cursor, uid, data['ids']) | 234 | for payment_order in clieop_export.payment_order_ids: |
2705 | 256 | for payment_order in payment_orders: | ||
2707 | 257 | if not clieopfile: | 235 | if not clieopfile: |
2708 | 258 | # Just once: create clieop file | 236 | # Just once: create clieop file |
2709 | 259 | our_account_owner = payment_order.mode.bank_id.owner_name \ | 237 | our_account_owner = payment_order.mode.bank_id.owner_name \ |
2710 | @@ -264,19 +242,19 @@ | |||
2711 | 264 | payment_order.mode.bank_id.iban | 242 | payment_order.mode.bank_id.iban |
2712 | 265 | ).localized_BBAN | 243 | ).localized_BBAN |
2713 | 266 | if not our_account_nr: | 244 | if not our_account_nr: |
2715 | 267 | raise wizard.except_wizard( | 245 | raise osv.except_osv( |
2716 | 268 | _('Error'), | 246 | _('Error'), |
2717 | 269 | _('Your bank account has to have a valid account number') | 247 | _('Your bank account has to have a valid account number') |
2718 | 270 | ) | 248 | ) |
2719 | 271 | clieopfile = {'CLIEOPPAY': clieop.PaymentsFile, | 249 | clieopfile = {'CLIEOPPAY': clieop.PaymentsFile, |
2720 | 272 | 'CLIEOPINC': clieop.DirectDebitFile, | 250 | 'CLIEOPINC': clieop.DirectDebitFile, |
2721 | 273 | 'CLIEOPSAL': clieop.SalaryPaymentsFile, | 251 | 'CLIEOPSAL': clieop.SalaryPaymentsFile, |
2725 | 274 | }[form['batchtype']]( | 252 | }[clieop_export['batchtype']]( |
2726 | 275 | identification = form['reference'], | 253 | identification = clieop_export['reference'], |
2727 | 276 | execution_date = form['execution_date'], | 254 | execution_date = clieop_export['execution_date'], |
2728 | 277 | name_sender = our_account_owner, | 255 | name_sender = our_account_owner, |
2729 | 278 | accountno_sender = our_account_nr, | 256 | accountno_sender = our_account_nr, |
2731 | 279 | test = form['test'] | 257 | test = clieop_export['test'] |
2732 | 280 | ) | 258 | ) |
2733 | 281 | 259 | ||
2734 | 282 | # ClieOp3 files can contain multiple batches, but we put all | 260 | # ClieOp3 files can contain multiple batches, but we put all |
2735 | @@ -285,21 +263,21 @@ | |||
2736 | 285 | # cheaper to combine than it is to split. As we split out all | 263 | # cheaper to combine than it is to split. As we split out all |
2737 | 286 | # reported errors afterwards, there is no additional gain in | 264 | # reported errors afterwards, there is no additional gain in |
2738 | 287 | # using multiple batches. | 265 | # using multiple batches. |
2741 | 288 | if form['fixed_message']: | 266 | if clieop_export['fixed_message']: |
2742 | 289 | messages = [form['fixed_message']] | 267 | messages = [clieop_export['fixed_message']] |
2743 | 290 | else: | 268 | else: |
2744 | 291 | messages = [] | 269 | messages = [] |
2745 | 292 | # The first payment order processed sets the reference of the | 270 | # The first payment order processed sets the reference of the |
2746 | 293 | # batch. | 271 | # batch. |
2747 | 294 | batch = clieopfile.batch( | 272 | batch = clieopfile.batch( |
2748 | 295 | messages = messages, | 273 | messages = messages, |
2750 | 296 | batch_id = payment_order.reference | 274 | batch_id = clieop_export['reference'] |
2751 | 297 | ) | 275 | ) |
2752 | 298 | 276 | ||
2753 | 299 | for line in payment_order.line_ids: | 277 | for line in payment_order.line_ids: |
2754 | 300 | # Check on missing partner of bank account (this can happen!) | 278 | # Check on missing partner of bank account (this can happen!) |
2755 | 301 | if not line.bank_id or not line.bank_id.partner_id: | 279 | if not line.bank_id or not line.bank_id.partner_id: |
2757 | 302 | raise wizard.except_wizard( | 280 | raise osv.except_osv( |
2758 | 303 | _('Error'), | 281 | _('Error'), |
2759 | 304 | _('There is insufficient information.\r\n' | 282 | _('There is insufficient information.\r\n' |
2760 | 305 | 'Both destination address and account ' | 283 | 'Both destination address and account ' |
2761 | @@ -318,13 +296,13 @@ | |||
2762 | 318 | # Is this an IBAN account? | 296 | # Is this an IBAN account? |
2763 | 319 | if iban.valid: | 297 | if iban.valid: |
2764 | 320 | if iban.countrycode != 'NL': | 298 | if iban.countrycode != 'NL': |
2766 | 321 | raise wizard.except_wizard( | 299 | raise osv.except_osv( |
2767 | 322 | _('Error'), | 300 | _('Error'), |
2768 | 323 | _('You cannot send international bank transfers ' | 301 | _('You cannot send international bank transfers ' |
2769 | 324 | 'through ClieOp3!') | 302 | 'through ClieOp3!') |
2770 | 325 | ) | 303 | ) |
2771 | 326 | other_account_nr = iban.localized_BBAN | 304 | other_account_nr = iban.localized_BBAN |
2773 | 327 | if form['batchtype'] == 'CLIEOPINC': | 305 | if clieop_export['batchtype'] == 'CLIEOPINC': |
2774 | 328 | kwargs['accountno_beneficiary'] = our_account_nr | 306 | kwargs['accountno_beneficiary'] = our_account_nr |
2775 | 329 | kwargs['accountno_payer'] = other_account_nr | 307 | kwargs['accountno_payer'] = other_account_nr |
2776 | 330 | else: | 308 | else: |
2777 | @@ -334,86 +312,63 @@ | |||
2778 | 334 | 312 | ||
2779 | 335 | # Generate the specifics of this clieopfile | 313 | # Generate the specifics of this clieopfile |
2780 | 336 | order = clieopfile.order | 314 | order = clieopfile.order |
2798 | 337 | values = dict( | 315 | file_id = self.pool.get('banking.export.clieop').create( |
2799 | 338 | filetype = order.name_transactioncode, | 316 | cursor, uid, dict( |
2800 | 339 | identification = order.identification, | 317 | filetype = order.name_transactioncode, |
2801 | 340 | prefered_date = strfdate(order.preferred_execution_date), | 318 | identification = order.identification, |
2802 | 341 | total_amount = int(order.total_amount) / 100.0, | 319 | prefered_date = strfdate(order.preferred_execution_date), |
2803 | 342 | check_no_accounts = order.total_accountnos, | 320 | total_amount = int(order.total_amount) / 100.0, |
2804 | 343 | no_transactions = order.nr_posts, | 321 | check_no_accounts = order.total_accountnos, |
2805 | 344 | testcode = order.testcode, | 322 | no_transactions = order.nr_posts, |
2806 | 345 | file = base64.encodestring(clieopfile.rawdata), | 323 | testcode = order.testcode, |
2807 | 346 | ) | 324 | file = base64.encodestring(clieopfile.rawdata), |
2808 | 347 | form.update(values) | 325 | daynumber = int(clieopfile.header.file_id[2:]), |
2809 | 348 | values['daynumber'] = int(clieopfile.header.file_id[2:]) | 326 | payment_order_ids = [ |
2810 | 349 | values['payment_order_ids'] = ','.join(map(str, data['ids'])) | 327 | [6, 0, [x.id for x in clieop_export['payment_order_ids']]] |
2811 | 350 | data['file_id'] = pool.get('banking.export.clieop').create(cursor, uid, values) | 328 | ], |
2812 | 351 | data['clieop'] = clieopfile | 329 | ), context) |
2813 | 352 | form['log'] = '' | 330 | self.write(cursor, uid, [ids[0]], dict( |
2814 | 353 | return form | 331 | filetype = order.name_transactioncode, |
2815 | 332 | testcode = order.testcode, | ||
2816 | 333 | file_id = file_id, | ||
2817 | 334 | state = 'finish', | ||
2818 | 335 | ), context) | ||
2819 | 336 | return { | ||
2820 | 337 | 'name': _('Client Opdrachten Export'), | ||
2821 | 338 | 'view_type': 'form', | ||
2822 | 339 | 'view_mode': 'form', | ||
2823 | 340 | 'res_model': self._name, | ||
2824 | 341 | 'domain': [], | ||
2825 | 342 | 'context': dict(context, active_ids=ids), | ||
2826 | 343 | 'type': 'ir.actions.act_window', | ||
2827 | 344 | 'target': 'new', | ||
2828 | 345 | 'res_id': ids[0] or False, | ||
2829 | 346 | } | ||
2830 | 354 | 347 | ||
2832 | 355 | def _cancel_clieop(self, cursor, uid, data, context): | 348 | def cancel_clieop(self, cursor, uid, ids, context): |
2833 | 356 | ''' | 349 | ''' |
2834 | 357 | Cancel the ClieOp: just drop the file | 350 | Cancel the ClieOp: just drop the file |
2835 | 358 | ''' | 351 | ''' |
2895 | 359 | pool = pooler.get_pool(cursor.dbname) | 352 | clieop_export = self.read(cursor, uid, ids, ['file_id'], context)[0] |
2896 | 360 | pool.get('banking.export.clieop').unlink(cursor, uid, data['file_id']) | 353 | self.pool.get('banking.export.clieop').unlink(cursor, uid, clieop_export['file_id']) |
2897 | 361 | return {'state': 'end'} | 354 | return {'type': 'ir.actions.act_window_close'} |
2898 | 362 | 355 | ||
2899 | 363 | def _save_clieop(self, cursor, uid, data, context): | 356 | def save_clieop(self, cursor, uid, ids, context): |
2900 | 364 | ''' | 357 | ''' |
2901 | 365 | Save the ClieOp: mark all payments in the file as 'sent'. | 358 | Save the ClieOp: mark all payments in the file as 'sent', if not a test |
2902 | 366 | ''' | 359 | ''' |
2903 | 367 | pool = pooler.get_pool(cursor.dbname) | 360 | clieop_export = self.browse( |
2904 | 368 | clieop_obj = pool.get('banking.export.clieop') | 361 | cursor, uid, ids, context)[0] |
2905 | 369 | payment_order_obj = pool.get('payment.order') | 362 | if not clieop_export['test']: |
2906 | 370 | clieop_file = clieop_obj.write( | 363 | clieop_obj = self.pool.get('banking.export.clieop') |
2907 | 371 | cursor, uid, data['file_id'], {'state':'sent'} | 364 | payment_order_obj = self.pool.get('payment.order') |
2908 | 372 | ) | 365 | clieop_file = clieop_obj.write( |
2909 | 373 | payment_order_obj.write(cursor, uid, data['ids'], {'state': 'sent'}) | 366 | cursor, uid, clieop_export['file_id'].id, {'state':'sent'} |
2910 | 374 | return {'state': 'end'} | 367 | ) |
2911 | 375 | 368 | payment_order_obj.action_sent( | |
2912 | 376 | states = { | 369 | cursor, uid, [x.id for x in clieop_export['payment_order_ids']]) |
2913 | 377 | 'init': { | 370 | return {'type': 'ir.actions.act_window_close'} |
2914 | 378 | 'actions': [_check_orders], | 371 | |
2915 | 379 | 'result': { | 372 | banking_export_clieop_wizard() |
2857 | 380 | 'type': 'form', | ||
2858 | 381 | 'arch': form, | ||
2859 | 382 | 'fields' : fields, | ||
2860 | 383 | 'state': [ | ||
2861 | 384 | ('end', 'Cancel', 'gtk-cancel'), | ||
2862 | 385 | ('create', 'Create', 'gtk-ok'), | ||
2863 | 386 | ] | ||
2864 | 387 | } | ||
2865 | 388 | }, | ||
2866 | 389 | 'create': { | ||
2867 | 390 | 'actions': [_create_clieop], | ||
2868 | 391 | 'result': { | ||
2869 | 392 | 'type': 'form', | ||
2870 | 393 | 'arch': file_form, | ||
2871 | 394 | 'fields': file_fields, | ||
2872 | 395 | 'state': [ | ||
2873 | 396 | ('cancel', 'Cancel', 'gtk-cancel'), | ||
2874 | 397 | ('save', 'Save', 'gtk-save'), | ||
2875 | 398 | ] | ||
2876 | 399 | }, | ||
2877 | 400 | }, | ||
2878 | 401 | 'cancel': { | ||
2879 | 402 | 'actions': [_cancel_clieop], | ||
2880 | 403 | 'result': { | ||
2881 | 404 | 'type': 'state', | ||
2882 | 405 | 'state': 'end' | ||
2883 | 406 | } | ||
2884 | 407 | }, | ||
2885 | 408 | 'save': { | ||
2886 | 409 | 'actions': [_save_clieop], | ||
2887 | 410 | 'result': { | ||
2888 | 411 | 'type': 'state', | ||
2889 | 412 | 'state': 'end' | ||
2890 | 413 | }, | ||
2891 | 414 | } | ||
2892 | 415 | } | ||
2893 | 416 | |||
2894 | 417 | wizard_banking_export_clieop('account_banking_nl_clieop.banking_export_clieop') | ||
2916 | 418 | 373 | ||
2917 | 419 | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: | 374 | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: |
2918 | 420 | 375 | ||
2919 | === added file 'account_banking_nl_clieop/wizard/export_clieop_view.xml' | |||
2920 | --- account_banking_nl_clieop/wizard/export_clieop_view.xml 1970-01-01 00:00:00 +0000 | |||
2921 | +++ account_banking_nl_clieop/wizard/export_clieop_view.xml 2011-11-23 10:40:16 +0000 | |||
2922 | @@ -0,0 +1,58 @@ | |||
2923 | 1 | <?xml version="1.0" encoding="utf-8"?> | ||
2924 | 2 | <openerp> | ||
2925 | 3 | <data> | ||
2926 | 4 | <record id="banking_export_clieop_wizard_view" model="ir.ui.view"> | ||
2927 | 5 | <field name="name">banking.export.clieop.wizard.view</field> | ||
2928 | 6 | <field name="model">banking.export.clieop.wizard</field> | ||
2929 | 7 | <field name="type">form</field> | ||
2930 | 8 | <field name="arch" type="xml"> | ||
2931 | 9 | <form string="Client Opdrachten Export"> | ||
2932 | 10 | <field name="state" invisible="True"/> | ||
2933 | 11 | <group states="create"> | ||
2934 | 12 | <separator colspan="4" string="Processing Details" /> | ||
2935 | 13 | <field name="batchtype" /> | ||
2936 | 14 | <field name="execution_date" /> | ||
2937 | 15 | <field name="test" /> | ||
2938 | 16 | <separator colspan="4" string="Reference for further communication" /> | ||
2939 | 17 | <field name="reference" colspan="2" /> | ||
2940 | 18 | <separator colspan="4" string="Additional message for all transactions" /> | ||
2941 | 19 | <field name="fixed_message" /> | ||
2942 | 20 | <newline/> | ||
2943 | 21 | <button icon="gtk-close" | ||
2944 | 22 | special="cancel" | ||
2945 | 23 | string="Cancel" | ||
2946 | 24 | /> | ||
2947 | 25 | <button icon="gtk-ok" | ||
2948 | 26 | string="Create" | ||
2949 | 27 | name="create_clieop" | ||
2950 | 28 | type="object" | ||
2951 | 29 | /> | ||
2952 | 30 | </group> | ||
2953 | 31 | <group states="finish"> | ||
2954 | 32 | <field name="filetype" /> | ||
2955 | 33 | <field name="identification" /> | ||
2956 | 34 | <field name="total_amount" /> | ||
2957 | 35 | <field name="check_no_accounts" /> | ||
2958 | 36 | <field name="no_transactions" /> | ||
2959 | 37 | <field name="prefered_date" /> | ||
2960 | 38 | <field name="testcode" /> | ||
2961 | 39 | <newline/> | ||
2962 | 40 | <field name="file_id" /> | ||
2963 | 41 | <field name="file" /> | ||
2964 | 42 | <newline/> | ||
2965 | 43 | <button icon="gtk-close" | ||
2966 | 44 | string="Cancel" | ||
2967 | 45 | name="cancel_clieop" | ||
2968 | 46 | type="object" | ||
2969 | 47 | /> | ||
2970 | 48 | <button icon="gtk-ok" | ||
2971 | 49 | string="Finish" | ||
2972 | 50 | name="save_clieop" | ||
2973 | 51 | type="object" | ||
2974 | 52 | /> | ||
2975 | 53 | </group> | ||
2976 | 54 | </form> | ||
2977 | 55 | </field> | ||
2978 | 56 | </record> | ||
2979 | 57 | </data> | ||
2980 | 58 | </openerp> | ||
2981 | 0 | 59 | ||
2982 | === modified file 'account_banking_nl_girotel/__terp__.py' | |||
2983 | --- account_banking_nl_girotel/__terp__.py 2011-11-08 13:10:34 +0000 | |||
2984 | +++ account_banking_nl_girotel/__terp__.py 2011-11-23 10:40:16 +0000 | |||
2985 | @@ -37,9 +37,8 @@ | |||
2986 | 37 | ], | 37 | ], |
2987 | 38 | 'demo_xml': [], | 38 | 'demo_xml': [], |
2988 | 39 | 'description': ''' | 39 | 'description': ''' |
2992 | 40 | Module to import Dutch Girotel format transation files. | 40 | Do not install this module. This branch has been replaced by lp:banking-addons/6.0 |
2993 | 41 | 41 | See https://launchpad.net/banking-addons | |
2991 | 42 | This modules contains no logic, just an import filter for account_banking. | ||
2994 | 43 | ''', | 42 | ''', |
2995 | 44 | 'active': False, | 43 | 'active': False, |
2996 | 45 | 'installable': True, | 44 | 'installable': True, |
2997 | 46 | 45 | ||
2998 | === modified file 'account_banking_nl_multibank/__terp__.py' | |||
2999 | --- account_banking_nl_multibank/__terp__.py 2011-11-08 13:10:34 +0000 | |||
3000 | +++ account_banking_nl_multibank/__terp__.py 2011-11-23 10:40:16 +0000 | |||
3001 | @@ -37,9 +37,8 @@ | |||
3002 | 37 | ], | 37 | ], |
3003 | 38 | 'demo_xml': [], | 38 | 'demo_xml': [], |
3004 | 39 | 'description': ''' | 39 | 'description': ''' |
3008 | 40 | Module to import Dutch Multibank format transation files. | 40 | Do not install this module. This branch has been replaced by lp:banking-addons/6.0 |
3009 | 41 | 41 | See https://launchpad.net/banking-addons | |
3007 | 42 | This modules contains no logic, just an import filter for account_banking. | ||
3010 | 43 | ''', | 42 | ''', |
3011 | 44 | 'active': False, | 43 | 'active': False, |
3012 | 45 | 'installable': True, | 44 | 'installable': True, |
3013 | 46 | 45 | ||
3014 | === modified file 'account_banking_nl_triodos/__openerp__.py' | |||
3015 | --- account_banking_nl_triodos/__openerp__.py 2011-04-26 21:00:12 +0000 | |||
3016 | +++ account_banking_nl_triodos/__openerp__.py 2011-11-23 10:40:16 +0000 | |||
3017 | @@ -39,19 +39,8 @@ | |||
3018 | 39 | ], | 39 | ], |
3019 | 40 | 'demo_xml': [], | 40 | 'demo_xml': [], |
3020 | 41 | 'description': ''' | 41 | 'description': ''' |
3034 | 42 | Module to import Dutch Triodos bank format transation files (CSV format). | 42 | Do not install this module. This branch has been replaced by lp:banking-addons/6.0 |
3035 | 43 | 43 | See https://launchpad.net/banking-addons | |
3023 | 44 | As the Triodos bank does not provide detailed specification concerning possible | ||
3024 | 45 | values and their meaning for the fields in the CSV file format, the statements | ||
3025 | 46 | are parsed according to an educated guess based on incomplete information. | ||
3026 | 47 | You can contact the account-banking developers through their launchpad page and | ||
3027 | 48 | help improve the performance of this import filter on | ||
3028 | 49 | https://launchpad.net/account-banking. | ||
3029 | 50 | |||
3030 | 51 | Note that imported bank transfers are organized in statements covering periods | ||
3031 | 52 | of one week, even if the imported files cover a different period. | ||
3032 | 53 | |||
3033 | 54 | This modules contains no logic, just an import filter for account_banking. | ||
3036 | 55 | ''', | 44 | ''', |
3037 | 56 | 'active': False, | 45 | 'active': False, |
3038 | 57 | 'installable': True, | 46 | 'installable': True, |
3039 | 58 | 47 | ||
3040 | === modified file 'account_banking_nl_triodos/__terp__.py' | |||
3041 | --- account_banking_nl_triodos/__terp__.py 2011-11-08 13:10:34 +0000 | |||
3042 | +++ account_banking_nl_triodos/__terp__.py 2011-11-23 10:40:16 +0000 | |||
3043 | @@ -39,19 +39,8 @@ | |||
3044 | 39 | ], | 39 | ], |
3045 | 40 | 'demo_xml': [], | 40 | 'demo_xml': [], |
3046 | 41 | 'description': ''' | 41 | 'description': ''' |
3060 | 42 | Module to import Dutch Triodos bank format transation files (CSV format). | 42 | Do not install this module. This branch has been replaced by lp:banking-addons/6.0 |
3061 | 43 | 43 | See https://launchpad.net/banking-addons | |
3049 | 44 | As the Triodos bank does not provide detailed specification concerning possible | ||
3050 | 45 | values and their meaning for the fields in the CSV file format, the statements | ||
3051 | 46 | are parsed according to an educated guess based on incomplete information. | ||
3052 | 47 | You can contact the account-banking developers through their launchpad page and | ||
3053 | 48 | help improve the performance of this import filter on | ||
3054 | 49 | https://launchpad.net/account-banking. | ||
3055 | 50 | |||
3056 | 51 | Note that imported bank transfers are organized in statements covering periods | ||
3057 | 52 | of one week, even if the imported files cover a different period. | ||
3058 | 53 | |||
3059 | 54 | This modules contains no logic, just an import filter for account_banking. | ||
3062 | 55 | ''', | 44 | ''', |
3063 | 56 | 'active': False, | 45 | 'active': False, |
3064 | 57 | 'installable': True, | 46 | 'installable': True, |
3065 | 58 | 47 | ||
3066 | === modified file 'account_banking_nl_triodos/triodos.py' | |||
3067 | --- account_banking_nl_triodos/triodos.py 2011-04-27 10:16:40 +0000 | |||
3068 | +++ account_banking_nl_triodos/triodos.py 2011-11-23 10:40:16 +0000 | |||
3069 | @@ -68,6 +68,9 @@ | |||
3070 | 68 | # Set statement_id based on week number | 68 | # Set statement_id based on week number |
3071 | 69 | self.statement_id = self.effective_date.strftime('%Yw%W') | 69 | self.statement_id = self.effective_date.strftime('%Yw%W') |
3072 | 70 | self.id = str(subno).zfill(4) | 70 | self.id = str(subno).zfill(4) |
3073 | 71 | # Normalize basic account numbers | ||
3074 | 72 | self.remote_account = self.remote_account.replace('.', '').zfill(10) | ||
3075 | 73 | self.local_account = self.local_account.replace('.', '').zfill(10) | ||
3076 | 71 | 74 | ||
3077 | 72 | class transaction(models.mem_bank_transaction): | 75 | class transaction(models.mem_bank_transaction): |
3078 | 73 | ''' | 76 | ''' |
Generic:
I can see a lot of technical improvements for v6. However, there were
more changes than just the technical ones. For starters, v6 introduced
the voucher layer between account and account_payment. I'm missing
this in your proposal. Is this code used in production? If so,
what are the experiences? How does it coexist/cooperate with the
payment/voucher system?
I can see you tried to stay as close to the v5 version as possible. bank.statement to account. bank.statement. line. Thanks to voucher, it creates more trouble than its worth it. I'm planning
However, I'm second guessing some of the changes for v5, due to the
semantic changes in v6. One is the move of the period_id on
account.
account_
to change the statement generation code to fold around the current
limitations of v6. This would simplify ABF's dependancies greatly.
Many changes seem to me not v6 specific. I will backport these to v5. See my
remarks below.
account_ banking/ account_ banking. py: @-890,+878:
I will backport this modified to v5. Testing on iterator capabilities is
more extendable IMO than testing on simple types.
account_ banking/ account_ banking. py: @-911,+901 -922,911:
Oops, left some lingering code. Thanks for noting.
Backporting to v5, excluding the style change.
account_ banking/ account_ banking. py: @-1188,+1177:
Ok, backporting to v5.
account_ banking/ account_ banking. py: @-1197,+1186:
You managed to come up with yet another source. Nice.
I'll add it to v5.
account_ banking/ account_ banking. py: @-1218,+1210 -1239,+1231:
Not sure if this is an improvement. I'll leave it for now.
Won't take the style change.
account_ banking/ sepa/iban. py:
This change is not conform specs. Any sources I can check for this?
Will leave it untill more info arrives.
account_ banking/ sepa/online. py/BBAN_ is_IBAN:
See your point. Using slightly improved version for v5.
account_ banking/ wizard/ bank_import/ @@ -544,+545:
This is unneeded. You don't use it anywhere. Won't take it.
account_ banking/ wizard/ bank_import/ @@ -567,+568, -730,+730 and -743,+743:
These are just style changes. Wont take these.
account_ banking/ wizard/ bank_import/ @@ -753,+753:
See your point. Your solution is however not always correct.
Backporting improved version to v5.
account_ banking/ wizard/ bank_import/ @@ -795,+798:
isinstance( transaction. remote_ account, (str, unicode)) is True
Can't see any value in this change. Just make sure that
which must be done in the import parsers.
account_ banking/ wizard/ bank_import/ @@ -922,+918:
Ok, see your point. Backporting to v5
account_ banking/ wizard/ banktools/ get_or_ create_ partner:
Ok, backporting the unique construct to v5.
Having some difficulties with the defensive field resolving code.
Is this really needed? Never faced any problems with it.
account_ banking/ wizard/ banktools/ create_ bank_account:
What is the purpose of these changes?
I can't see a semantic value for a catch-all 'UNKNOWN' bank.
Problem is, when the bank gets known, chances are it won't be
the same as "the other" accounts with UNKNOWN tied to it.
...