Skip to content

Commit 4201b8b

Browse files
committed
[IMP] New module academic_payment_portal
If active, portal users will only see the pay button on the oldest due date invoice X-original-commit: 8cb7892
1 parent cf3cf6c commit 4201b8b

9 files changed

+103
-0
lines changed

academic_payment_portal/__init__.py

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
from . import models
2+
from . import wizards
+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
##############################################################################
2+
#
3+
# Copyright (C) 2025 ADHOC SA (http://www.adhoc.com.ar)
4+
# All Rights Reserved.
5+
#
6+
# This program is free software: you can redistribute it and/or modify
7+
# it under the terms of the GNU Affero General Public License as
8+
# published by the Free Software Foundation, either version 3 of the
9+
# License, or (at your option) any later version.
10+
#
11+
# This program is distributed in the hope that it will be useful,
12+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
# GNU Affero General Public License for more details.
15+
#
16+
# You should have received a copy of the GNU Affero General Public License
17+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
18+
#
19+
##############################################################################
20+
{
21+
'name': 'Academic Payment portal',
22+
'version': "17.0.0.1.0",
23+
'sequence': 14,
24+
'summary': '',
25+
'author': 'ADHOC SA',
26+
'website': 'www.adhoc.com.ar',
27+
'license': 'AGPL-3',
28+
'depends': [
29+
'account_payment'
30+
],
31+
'data': [
32+
'wizards/res_config_setting_views.xml',
33+
],
34+
'installable': True,
35+
'auto_install': False,
36+
'application': False,
37+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from . import account_move
2+
from . import res_company
3+
from . import res_partner
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
from odoo import models
2+
3+
4+
class AccountMove(models.Model):
5+
_inherit = 'account.move'
6+
7+
def _has_to_be_paid(self):
8+
self.ensure_one()
9+
if self.company_id.users_can_pay_only_oldest_invoice and self.partner_id.sudo()._get_first_residual_invoice() != self:
10+
return False
11+
return super()._has_to_be_paid()
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
from odoo import models, fields
2+
3+
4+
class ResCompany(models.Model):
5+
6+
_inherit = 'res.company'
7+
8+
users_can_pay_only_oldest_invoice = fields.Boolean(default=True)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
from odoo import models
2+
3+
4+
class ResPartner(models.Model):
5+
6+
_inherit = 'res.partner'
7+
8+
def _get_first_residual_invoice(self):
9+
self.ensure_one()
10+
return self.env['account.move'].search(
11+
[('amount_residual', '>', 0),
12+
('state', '=', 'posted'),
13+
('move_type', '=', 'out_invoice'),
14+
('partner_id', '=', self.id)],
15+
limit=1, order="invoice_date_due ASC")
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from . import res_config_setting
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Part of Odoo. See LICENSE file for full copyright and licensing details.
2+
3+
from odoo import fields, models
4+
5+
6+
class ResConfigSettings(models.TransientModel):
7+
_inherit = 'res.config.settings'
8+
9+
users_can_pay_only_oldest_invoice = fields.Boolean(related="company_id.users_can_pay_only_oldest_invoice", readonly=False)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<odoo>
3+
4+
<record id="res_config_settings_view_form" model="ir.ui.view">
5+
<field name="name">res.config.settings.view.form.inherit.account</field>
6+
<field name="model">res.config.settings</field>
7+
<field name="inherit_id" ref="account_payment.res_config_settings_view_form"/>
8+
<field name="arch" type="xml">
9+
<setting id="account_batch_payment" position="before">
10+
<setting id="pay_only_oldest_invoice" string="Payments in portal" help="If active, portal users will only see the pay button on the oldest due date invoice">
11+
<field name="users_can_pay_only_oldest_invoice" string="Users can pay only first invoce"/>
12+
</setting>
13+
</setting>
14+
</field>
15+
</record>
16+
17+
</odoo>

0 commit comments

Comments
 (0)