Skip to content

Commit

Permalink
[IMP] Allow to use the storage either from the payment mode or from t…
Browse files Browse the repository at this point in the history
…he payment method
  • Loading branch information
lmarion-source committed May 31, 2024
1 parent 297eebf commit c984316
Show file tree
Hide file tree
Showing 30 changed files with 286 additions and 282 deletions.

This file was deleted.

84 changes: 0 additions & 84 deletions account_payment_method_fs_storage/i18n/es.po

This file was deleted.

84 changes: 0 additions & 84 deletions account_payment_method_fs_storage/i18n/it.po

This file was deleted.

1 change: 0 additions & 1 deletion account_payment_method_fs_storage/tests/__init__.py

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
=================================
Account Payment Method Fs Storage
=================================
=========================================
Account Payment Method Or Mode Fs Storage
=========================================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Expand All @@ -17,10 +17,10 @@ Account Payment Method Fs Storage
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fbank--payment-lightgray.png?logo=github
:target: https://github.com/OCA/bank-payment/tree/16.0/account_payment_method_fs_storage
:target: https://github.com/OCA/bank-payment/tree/16.0/account_payment_method_or_mode_fs_storage
:alt: OCA/bank-payment
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/bank-payment-16-0/bank-payment-16-0-account_payment_method_fs_storage
:target: https://translation.odoo-community.org/projects/bank-payment-16-0/bank-payment-16-0-account_payment_method_or_mode_fs_storage
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/builds?repo=OCA/bank-payment&target_branch=16.0
Expand Down Expand Up @@ -52,7 +52,7 @@ Configuration

For setting the Storage:

#. Activate "Use On Payment Method" on storage (boolean on form of Storage)
#. Activate "Use On Payment Method/Mode" on storage (boolean on form of Storage)
#. Go to Invoicing/Accounting > Configuration > Payment Methods
#. You can specify your storage on the payment method

Expand All @@ -68,7 +68,7 @@ Bug Tracker
Bugs are tracked on `GitHub Issues <https://github.com/OCA/bank-payment/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
`feedback <https://github.com/OCA/bank-payment/issues/new?body=module:%20account_payment_method_fs_storage%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
`feedback <https://github.com/OCA/bank-payment/issues/new?body=module:%20account_payment_method_or_mode_fs_storage%0Aversion:%2016.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.

Expand Down Expand Up @@ -99,6 +99,6 @@ 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/bank-payment <https://github.com/OCA/bank-payment/tree/16.0/account_payment_method_fs_storage>`_ project on GitHub.
This module is part of the `OCA/bank-payment <https://github.com/OCA/bank-payment/tree/16.0/account_payment_method_or_mode_fs_storage>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

{
"name": "Account Payment Method Fs Storage",
"name": "Account Payment Method Or Mode Fs Storage",
"summary": """
Add the possibility to specify on the payment method,
Add the possibility to specify on the payment method or on the
payment mode depending on the company,
a storage where files generated will be pushed to upon payment
""",
"version": "16.0.1.0.2",
Expand All @@ -14,8 +15,11 @@
"depends": [
"account_banking_sepa_credit_transfer",
"fs_storage",
"account_payment_mode",
],
"data": [
"views/res_config_settings.xml",
"views/account_payment_mode.xml",
"views/fs_storage.xml",
"views/account_payment_method.xml",
],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
from . import account_payment_order
from . import account_payment_method
from . import fs_storage
from . import account_payment_mode
from . import res_config_settings
from . import res_company
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Copyright 2024 ACSONE SA/NV
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import fields, models


class AccountPaymentMode(models.Model):

_inherit = "account.payment.mode"

storage = fields.Selection(
selection="_get_selection_storage",
help="Storage where to put the file after generation",
)

def _get_selection_storage(self):
"""
This is to avoid giving access to the model fs.storage
at groups other than base.group_system
"""
storages = (
self.env["fs.storage"].sudo().search([("use_on_payment_mode", "=", True)])
)

return [(str(r.id), r.display_name) for r in storages]
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,17 @@ class AccountPaymentOrder(models.Model):

_inherit = "account.payment.order"

def _get_storage(self):
if self.env.company.fs_storage_source_payment == "mode":
return self.payment_mode_id.storage
return self.payment_method_id.storage

def _must_be_exported_to_storage(self):
self.ensure_one()
return bool(self.payment_method_id.storage)
return bool(self._get_storage())

def _export_to_storage(self, file_content, filename):
storage_id = int(self.payment_method_id.storage)
storage_id = int(self._get_storage())
# user that confirms order may not have access to storage
export_storage = self.env["fs.storage"].sudo().search([("id", "=", storage_id)])
try:
Expand Down
Loading

0 comments on commit c984316

Please sign in to comment.