Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by dreispt
- Loading branch information
Showing
13 changed files
with
106 additions
and
0 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 |
---|---|---|
@@ -0,0 +1 @@ | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# Copyright 2019 Lorenzo Battistini | ||
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl). | ||
|
||
{ | ||
"name": "Outbound payments: select account", | ||
"summary": "Allow user to select the account where journal item will be recorded", | ||
"version": "12.0.1.0.0", | ||
"development_status": "Beta", | ||
"category": "Invoicing Management", | ||
"website": "https://github.com/OCA/account-payment", | ||
"author": "TAKOBI, Odoo Community Association (OCA)", | ||
"maintainers": ["eLBati"], | ||
"license": "LGPL-3", | ||
"application": False, | ||
"installable": True, | ||
"depends": [ | ||
"account", | ||
], | ||
"data": [ | ||
"views/account_payment_view.xml" | ||
], | ||
} |
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import account_payment |
18 changes: 18 additions & 0 deletions
18
account_payment_select_cost_account/models/account_payment.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 |
---|---|---|
@@ -0,0 +1,18 @@ | ||
from odoo import models, fields, api | ||
|
||
|
||
class Payment(models.Model): | ||
_inherit = 'account.payment' | ||
force_destination_account_id = fields.Many2one( | ||
'account.account', string="Cost account") | ||
|
||
@api.onchange("destination_account_id") | ||
def onchange_destination_account_id(self): | ||
if self.destination_account_id: | ||
self.force_destination_account_id = self.destination_account_id.id | ||
|
||
def _get_counterpart_move_line_vals(self, invoice=False): | ||
vals = super(Payment, self)._get_counterpart_move_line_vals(invoice) | ||
if self.force_destination_account_id: | ||
vals['account_id'] = self.force_destination_account_id.id | ||
return vals |
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
* Lorenzo Battistini |
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
The development of this module has been financially supported by: | ||
|
||
* TAKOBI https://takobi.online |
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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
The module allows users to specify which account to use in outbound payments. | ||
|
||
Without this module, you can only use a payable account, not being able to use a cost account. | ||
|
||
This is useful when you need to track payment status, also attaching files and chatting, for payments not tracked by other documents, like fiscal payments, | ||
penalties, etc. |
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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
Just select "Cost account" in vendors payments | ||
|
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import test_account_payment_select_cost_account |
29 changes: 29 additions & 0 deletions
29
account_payment_select_cost_account/tests/test_account_payment_select_cost_account.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 |
---|---|---|
@@ -0,0 +1,29 @@ | ||
from odoo.tests.common import TransactionCase | ||
|
||
|
||
class TestPaymentSelectCost(TransactionCase): | ||
|
||
def setUp(self): | ||
super(TestPaymentSelectCost, self).setUp() | ||
self.account_cost = self.env['account.account'].search([ | ||
('user_type_id', '=', self.env.ref('account.data_account_type_expenses').id) | ||
], limit=1) | ||
self.bank_journal = self.env['account.journal'].create( | ||
{'name': 'Bank', 'type': 'bank', 'code': 'BNK'}) | ||
|
||
def test_outbound_payment(self): | ||
payment = self.env['account.payment'].create({ | ||
'payment_type': 'outbound', | ||
'partner_type': 'supplier', | ||
'journal_id': self.bank_journal.id, | ||
'payment_method_id': self.bank_journal.outbound_payment_method_ids[0].id, | ||
'amount': 100, | ||
}) | ||
payment.onchange_destination_account_id() | ||
payment._convert_to_write(payment._cache) | ||
payment.force_destination_account_id = self.account_cost.id | ||
payment.post() | ||
self.assertEqual(len(payment.move_line_ids), 2) | ||
for line in payment.move_line_ids: | ||
if line.debit: | ||
self.assertEqual(line.account_id.id, self.account_cost.id) |
15 changes: 15 additions & 0 deletions
15
account_payment_select_cost_account/views/account_payment_view.xml
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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<odoo> | ||
<record id="view_account_payment_form_select_account" model="ir.ui.view"> | ||
<field name="name">view_account_payment_form_select_account</field> | ||
<field name="model">account.payment</field> | ||
<field name="inherit_id" ref="account.view_account_payment_form"/> | ||
<field name="arch" type="xml"> | ||
<field name="partner_id" position="after"> | ||
<field name="destination_account_id" invisible="1"/> | ||
<field name="force_destination_account_id" | ||
attrs="{'required': [('state', '=', 'draft'), ('payment_type', 'in', ('outbound'))], 'invisible': [('payment_type', 'not in', ('outbound'))], 'readonly': [('state', '!=', 'draft')]}"/> | ||
</field> | ||
</field> | ||
</record> | ||
</odoo> |
1 change: 1 addition & 0 deletions
1
setup/account_payment_select_cost_account/odoo/addons/account_payment_select_cost_account
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
../../../../account_payment_select_cost_account |
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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import setuptools | ||
|
||
setuptools.setup( | ||
setup_requires=['setuptools-odoo'], | ||
odoo_addon=True, | ||
) |