forked from OCA/l10n-usa
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[IMP] account_banking_ach_base: Improved code.
- Loading branch information
1 parent
9f242cf
commit d9e5e8b
Showing
19 changed files
with
596 additions
and
112 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,36 @@ | ||
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg | ||
:alt: License: AGPL-3 | ||
===================================================== | ||
Localizations for North American Banking & Financials | ||
===================================================== | ||
|
||
======================= | ||
Counting House ACH Base | ||
======================= | ||
.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! This file is generated by oca-gen-addon-readme !! | ||
!! changes will be overwritten. !! | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
Add fields to Bank, Partner and Company required for ACH transactions in USA. | ||
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png | ||
:target: https://odoo-community.org/page/development-status | ||
:alt: Beta | ||
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png | ||
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html | ||
:alt: License: AGPL-3 | ||
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fl10n--usa-lightgray.png?logo=github | ||
:target: https://github.com/OCA/l10n-usa/tree/12.0/account_banking_ach_base | ||
:alt: OCA/l10n-usa | ||
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png | ||
:target: https://translation.odoo-community.org/projects/l10n-usa-12-0/l10n-usa-12-0-account_banking_ach_base | ||
:alt: Translate me on Weblate | ||
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png | ||
:target: https://runbot.odoo-community.org/runbot/203/12.0 | ||
:alt: Try me on Runbot | ||
|
||
Installation | ||
============ | ||
|badge1| |badge2| |badge3| |badge4| |badge5| | ||
|
||
This module depends on : | ||
Add fields to Bank, Partner and Company required for ACH transactions in USA. | ||
|
||
* stdnum | ||
**Table of contents** | ||
|
||
.. contents:: | ||
:local: | ||
|
||
Usage | ||
===== | ||
|
@@ -25,15 +42,44 @@ Add Legal ID on Partner and Company records. | |
Add Mandate URL field to Company record. Use in email templates to provide customer with an easy | ||
way to access your Mandate Authorization form to streamline ACH authorizations. | ||
|
||
Known issues / Roadmap | ||
====================== | ||
|
||
* Add support for EFT 1464 byte payment files required in Canada | ||
|
||
Bug Tracker | ||
=========== | ||
|
||
Bugs are tracked on `GitHub Issues | ||
<https://github.com/thinkwelltwd/countinghouse>`_. In case of trouble, please | ||
check there if your issue has already been reported. If you spotted it first, | ||
help us smashing it by providing a detailed and welcomed feedback. | ||
Bugs are tracked on `GitHub Issues <https://github.com/OCA/l10n-usa/issues>`_. | ||
In case of trouble, please check there if your issue has already been reported. | ||
If you spotted it first, help us smashing it by providing a detailed and welcomed | ||
`feedback <https://github.com/OCA/l10n-usa/issues/new?body=module:%20account_banking_ach_base%0Aversion:%2012.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_. | ||
|
||
Do not contact contributors directly about support or help with technical issues. | ||
|
||
Credits | ||
======= | ||
|
||
Authors | ||
~~~~~~~ | ||
|
||
* Thinkwell Designs | ||
|
||
Contributors | ||
~~~~~~~~~~~~ | ||
|
||
* Dave Burkholder <[email protected]> | ||
* Maxime Chambreuil <[email protected]> | ||
* Serpent Consulting Services Pvt. Ltd. <[email protected]> | ||
|
||
Maintainers | ||
~~~~~~~~~~~ | ||
|
||
This module is maintained by the OCA. | ||
|
||
.. image:: https://odoo-community.org/logo.png | ||
:alt: Odoo Community Association | ||
:target: https://odoo-community.org | ||
|
||
OCA, or the Odoo Community Association, is a nonprofit organization whose | ||
mission is to support the collaborative development of Odoo features and | ||
promote its widespread use. | ||
|
||
This module is part of the `OCA/l10n-usa <https://github.com/OCA/l10n-usa/tree/12.0/account_banking_ach_base>`_ project on GitHub. | ||
|
||
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
|
||
from . import models |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 13 additions & 12 deletions
25
account_banking_ach_base/models/account_banking_mandate.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,49 @@ | ||
from odoo import api, fields, models | ||
from odoo import api, fields, models, _ | ||
from odoo.exceptions import UserError | ||
|
||
|
||
class AccountBankingMandate(models.Model): | ||
_inherit = 'account.banking.mandate' | ||
|
||
delay_days = fields.Integer(string='Delay Days', required=True, default=10, | ||
help='Number of days to wait after invoice date before ' | ||
'including an invoice in Payment Order for processing.', | ||
) | ||
delay_days = fields.Integer(string='Delay Days', required=True, | ||
default=10, | ||
help='''Number of days to wait after invoice | ||
date before including an invoice in Payment | ||
Order for processing.''') | ||
|
||
def validate(self): | ||
for mandate in self: | ||
if not mandate.delay_days: | ||
raise UserError('Delay days must be specified, and greater than 0.') | ||
|
||
raise UserError(_('''Delay days must be specified, and | ||
greater than 0.''')) | ||
super(AccountBankingMandate, self).validate() | ||
|
||
def set_payment_modes_on_partner(self): | ||
""" | ||
Set the payment modes on the Partner if they don't already exist. | ||
""" | ||
payment_modes = {} | ||
|
||
if self.partner_id.customer and not self.partner_id.customer_payment_mode_id: | ||
if self.partner_id.customer and not \ | ||
self.partner_id.customer_payment_mode_id: | ||
customer_mode = self.env['account.payment.mode'].search([ | ||
('payment_type', '=', 'inbound'), | ||
('company_id', '=', self.company_id.id), | ||
], limit=1) | ||
if customer_mode: | ||
payment_modes['customer_payment_mode_id'] = customer_mode.id | ||
if self.partner_id.supplier and not self.partner_id.supplier_payment_mode_id: | ||
if self.partner_id.supplier and not \ | ||
self.partner_id.supplier_payment_mode_id: | ||
supplier_mode = self.env['account.payment.mode'].search([ | ||
('payment_type', '=', 'outbound'), | ||
('company_id', '=', self.company_id.id), | ||
], limit=1) | ||
if supplier_mode: | ||
payment_modes['supplier_payment_mode_id'] = supplier_mode.id | ||
|
||
if payment_modes: | ||
self.partner_id.write(payment_modes) | ||
|
||
@api.model | ||
def create(self, vals): | ||
mandate = super(AccountBankingMandate, self).create(vals) | ||
self.set_payment_modes_on_partner() | ||
mandate.set_payment_modes_on_partner() | ||
return mandate |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.