Add module account_payment_line_manual_account
This commit is contained in:
1
account_payment_line_manual_account/__init__.py
Normal file
1
account_payment_line_manual_account/__init__.py
Normal file
@@ -0,0 +1 @@
|
|||||||
|
from . import models
|
||||||
25
account_payment_line_manual_account/__manifest__.py
Normal file
25
account_payment_line_manual_account/__manifest__.py
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
# Copyright 2024 Akretion France (http://www.akretion.com/)
|
||||||
|
# @author: Alexis de Lattre <alexis.delattre@akretion.com>
|
||||||
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||||
|
|
||||||
|
{
|
||||||
|
'name': 'Account Payment Line Manual Account',
|
||||||
|
'version': '14.0.1.0.0',
|
||||||
|
'category': 'Accounting',
|
||||||
|
'license': 'AGPL-3',
|
||||||
|
'summary': 'Ability to select the account on payment lines without journal item',
|
||||||
|
'description': """
|
||||||
|
With this module, when you manually create a payment line that is not linked to a journal item, you can select an account (by default, it is set to the payable/receivable account of the partner) : this account will be used as the counter part of the outbound/inbound payment account configured on the bank journal. It covers special needs of a few companies that use SEPA credit transfer for the same partner in different accounting scenarios.
|
||||||
|
|
||||||
|
This module has been written by Alexis de Lattre from Akretion
|
||||||
|
<alexis.delattre@akretion.com>.
|
||||||
|
""",
|
||||||
|
'author': 'Akretion',
|
||||||
|
'maintainers': ['alexis-via'],
|
||||||
|
'website': 'https://github.com/akretion/odoo-usability',
|
||||||
|
'depends': ['account_payment_order'],
|
||||||
|
'data': [
|
||||||
|
"views/account_payment_line.xml",
|
||||||
|
],
|
||||||
|
'installable': True,
|
||||||
|
}
|
||||||
2
account_payment_line_manual_account/models/__init__.py
Normal file
2
account_payment_line_manual_account/models/__init__.py
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
from . import account_payment_line
|
||||||
|
from . import account_payment_order
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
# Copyright 2024 Akretion France (https://www.akretion.com/)
|
||||||
|
# @author: Alexis de Lattre <alexis.delattre@akretion.com>
|
||||||
|
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
|
||||||
|
|
||||||
|
from odoo import api, fields, models
|
||||||
|
|
||||||
|
|
||||||
|
class AccountPaymentLine(models.Model):
|
||||||
|
_inherit = "account.payment.line"
|
||||||
|
|
||||||
|
account_id = fields.Many2one(
|
||||||
|
'account.account',
|
||||||
|
compute="_compute_account_id", store=True, readonly=False, check_company=True,
|
||||||
|
domain="[('company_id', '=', company_id), ('deprecated', '=', False)]")
|
||||||
|
|
||||||
|
@api.depends('move_line_id', 'partner_id')
|
||||||
|
def _compute_account_id(self):
|
||||||
|
for line in self:
|
||||||
|
account_id = False
|
||||||
|
if not line.move_line_id and line.partner_id:
|
||||||
|
partner = line.partner_id.with_company(line.order_id.company_id.id)
|
||||||
|
if line.order_id.payment_type == "inbound":
|
||||||
|
account_id = partner.property_account_receivable_id.id
|
||||||
|
else:
|
||||||
|
account_id = partner.property_account_payable_id.id
|
||||||
|
line.account_id = account_id
|
||||||
|
|
||||||
|
# take info account account_id for grouping
|
||||||
|
def payment_line_hashcode(self):
|
||||||
|
hashcode = super().payment_line_hashcode()
|
||||||
|
account_str = str(self.account_id.id or False)
|
||||||
|
hashcode = '-'.join([hashcode, account_str])
|
||||||
|
return hashcode
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
# Copyright 2024 Akretion France (https://www.akretion.com/)
|
||||||
|
# @author: Alexis de Lattre <alexis.delattre@akretion.com>
|
||||||
|
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
|
||||||
|
|
||||||
|
from odoo import models
|
||||||
|
|
||||||
|
|
||||||
|
class AccountPaymentOrder(models.Model):
|
||||||
|
_inherit = "account.payment.order"
|
||||||
|
|
||||||
|
def _prepare_move_line_partner_account(self, bank_line):
|
||||||
|
vals = super()._prepare_move_line_partner_account(bank_line)
|
||||||
|
if not bank_line.payment_line_ids[0].move_line_id:
|
||||||
|
vals['account_id'] = bank_line.payment_line_ids[0].account_id.id
|
||||||
|
return vals
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!--
|
||||||
|
Copyright 2024 Akretion France (https://www.akretion.com/)
|
||||||
|
@author: Alexis de Lattre <alexis.delattre@akretion.com>
|
||||||
|
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||||
|
-->
|
||||||
|
|
||||||
|
|
||||||
|
<odoo>
|
||||||
|
|
||||||
|
|
||||||
|
<record id="account_payment_line_form" model="ir.ui.view">
|
||||||
|
<field name="model">account.payment.line</field>
|
||||||
|
<field name="inherit_id" ref="account_payment_order.account_payment_line_form"/>
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<field name="company_id" position="after">
|
||||||
|
<field name="account_id" attrs="{'invisible': [('move_line_id', '!=', False)], 'required': [('move_line_id', '=', False)]}"/>
|
||||||
|
</field>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<record id="account_payment_line_tree" model="ir.ui.view">
|
||||||
|
<field name="model">account.payment.line</field>
|
||||||
|
<field name="inherit_id" ref="account_payment_order.account_payment_line_tree"/>
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<field name="move_line_id" position="after">
|
||||||
|
<field name="account_id" optional="hide"/>
|
||||||
|
</field>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
|
||||||
|
</odoo>
|
||||||
Reference in New Issue
Block a user