mirror of
https://github.com/OCA/bank-payment.git
synced 2025-02-02 10:37:31 +02:00
[MIG] account_payment_partner: Migration to 16.0
This commit is contained in:
@@ -14,16 +14,16 @@ Account Payment Partner
|
||||
: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/15.0/account_payment_partner
|
||||
:target: https://github.com/OCA/bank-payment/tree/16.0/account_payment_partner
|
||||
: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-15-0/bank-payment-15-0-account_payment_partner
|
||||
:alt: Translate me on Weblate
|
||||
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
|
||||
:target: https://runbot.odoo-community.org/runbot/173/15.0
|
||||
:target: https://runbot.odoo-community.org/runbot/173/16.0
|
||||
:alt: Try me on Runbot
|
||||
|
||||
|badge1| |badge2| |badge3| |badge4| |badge5|
|
||||
|badge1| |badge2| |badge3| |badge4| |badge5|
|
||||
|
||||
This module adds several fields:
|
||||
|
||||
@@ -127,6 +127,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/15.0/account_payment_partner>`_ project on GitHub.
|
||||
This module is part of the `OCA/bank-payment <https://github.com/OCA/bank-payment/tree/16.0/account_payment_partner>`_ project on GitHub.
|
||||
|
||||
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
{
|
||||
"name": "Account Payment Partner",
|
||||
"version": "15.0.1.2.0",
|
||||
"version": "16.0.1.0.0",
|
||||
"category": "Banking addons",
|
||||
"license": "AGPL-3",
|
||||
"summary": "Adds payment mode on partners and invoices",
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Odoo Server 15.0\n"
|
||||
"Project-Id-Version: Odoo Server 16.0\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"Last-Translator: \n"
|
||||
"Language-Team: \n"
|
||||
|
||||
@@ -81,47 +81,28 @@ class AccountMove(models.Model):
|
||||
partner.supplier_payment_mode_id.refund_payment_mode_id
|
||||
)
|
||||
|
||||
@api.onchange("partner_id")
|
||||
def _onchange_partner_id(self):
|
||||
"""Force compute because the onchange chain doesn't call
|
||||
``_compute_partner_bank``.
|
||||
"""
|
||||
res = super()._onchange_partner_id()
|
||||
self._compute_partner_bank_id()
|
||||
return res
|
||||
|
||||
@api.depends("partner_id", "payment_mode_id")
|
||||
@api.depends("bank_partner_id", "payment_mode_id")
|
||||
def _compute_partner_bank_id(self):
|
||||
res = super()._compute_partner_bank_id()
|
||||
for move in self:
|
||||
# No bank account assignation is done for out_invoice as this is only
|
||||
# needed for printing purposes and it can conflict with
|
||||
# SEPA direct debit payments. Current report prints it.
|
||||
def get_bank_id():
|
||||
return fields.first(
|
||||
move.commercial_partner_id.bank_ids.filtered(
|
||||
lambda b: b.company_id == move.company_id or not b.company_id
|
||||
)
|
||||
)
|
||||
if move.move_type != "in_invoice" or not move.payment_mode_id:
|
||||
move.partner_bank_id = False
|
||||
continue
|
||||
return res
|
||||
|
||||
bank_id = False
|
||||
if move.partner_id:
|
||||
pay_mode = move.payment_mode_id
|
||||
if move.move_type == "in_invoice":
|
||||
if (
|
||||
pay_mode
|
||||
and pay_mode.payment_type == "outbound"
|
||||
and pay_mode.payment_method_id.bank_account_required
|
||||
and move.commercial_partner_id.bank_ids
|
||||
):
|
||||
bank_id = get_bank_id()
|
||||
move.partner_bank_id = bank_id
|
||||
|
||||
def _reverse_move_vals(self, default_values, cancel=True):
|
||||
move_vals = super()._reverse_move_vals(default_values, cancel=cancel)
|
||||
move_vals["payment_mode_id"] = self.payment_mode_id.refund_payment_mode_id.id
|
||||
if self.move_type == "in_invoice":
|
||||
move_vals["partner_bank_id"] = self.partner_bank_id.id
|
||||
return move_vals
|
||||
def _reverse_moves(self, default_values_list=None, cancel=False):
|
||||
for move, default_values in zip(self, default_values_list):
|
||||
default_values[
|
||||
"payment_mode_id"
|
||||
] = move.payment_mode_id.refund_payment_mode_id.id
|
||||
if move.move_type == "in_invoice":
|
||||
default_values["partner_bank_id"] = move.partner_bank_id.id
|
||||
return super()._reverse_moves(
|
||||
default_values_list=default_values_list, cancel=cancel
|
||||
)
|
||||
|
||||
def partner_banks_to_show(self):
|
||||
self.ensure_one()
|
||||
@@ -144,12 +125,13 @@ class AccountMove(models.Model):
|
||||
# Return this as empty recordset
|
||||
return self.partner_bank_id
|
||||
|
||||
@api.model
|
||||
def create(self, vals):
|
||||
# Force compute partner_bank_id when invoice is created from SO
|
||||
# to avoid that odoo _prepare_invoice method value will be set.
|
||||
if self.env.context.get("active_model") == "sale.order": # pragma: no cover
|
||||
virtual_move = self.new(vals)
|
||||
virtual_move._compute_partner_bank_id()
|
||||
vals["partner_bank_id"] = virtual_move.partner_bank_id.id
|
||||
return super().create(vals)
|
||||
@api.model_create_multi
|
||||
def create(self, vals_list):
|
||||
for vals in vals_list:
|
||||
# Force compute partner_bank_id when invoice is created from SO
|
||||
# to avoid that odoo _prepare_invoice method value will be set.
|
||||
if self.env.context.get("active_model") == "sale.order": # pragma: no cover
|
||||
virtual_move = self.new(vals)
|
||||
virtual_move._compute_partner_bank_id()
|
||||
vals["partner_bank_id"] = virtual_move.partner_bank_id.id
|
||||
return super().create(vals_list)
|
||||
|
||||
@@ -18,9 +18,9 @@ class AccountMoveLine(models.Model):
|
||||
@api.depends("move_id.payment_mode_id")
|
||||
def _compute_payment_mode(self):
|
||||
for line in self:
|
||||
if line.move_id.is_invoice() and line.account_internal_type in (
|
||||
"receivable",
|
||||
"payable",
|
||||
if line.move_id.is_invoice() and line.account_type in (
|
||||
"asset_receivable",
|
||||
"liability_payable",
|
||||
):
|
||||
line.payment_mode_id = line.move_id.payment_mode_id
|
||||
else:
|
||||
|
||||
@@ -367,7 +367,7 @@ ul.auto-toc {
|
||||
!! This file is generated by oca-gen-addon-readme !!
|
||||
!! changes will be overwritten. !!
|
||||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
|
||||
<p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Mature" src="https://img.shields.io/badge/maturity-Mature-brightgreen.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/bank-payment/tree/15.0/account_payment_partner"><img alt="OCA/bank-payment" src="https://img.shields.io/badge/github-OCA%2Fbank--payment-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/bank-payment-15-0/bank-payment-15-0-account_payment_partner"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/173/15.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
|
||||
<p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Mature" src="https://img.shields.io/badge/maturity-Mature-brightgreen.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/bank-payment/tree/16.0/account_payment_partner"><img alt="OCA/bank-payment" src="https://img.shields.io/badge/github-OCA%2Fbank--payment-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/bank-payment-15-0/bank-payment-15-0-account_payment_partner"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/173/15.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
|
||||
<p>This module adds several fields:</p>
|
||||
<ul class="simple">
|
||||
<li>the <em>Supplier Payment Mode</em> and <em>Customer Payment Mode</em> on Partners,</li>
|
||||
@@ -467,7 +467,7 @@ If you spotted it first, help us smashing it by providing a detailed and welcome
|
||||
<p>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.</p>
|
||||
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/bank-payment/tree/15.0/account_payment_partner">OCA/bank-payment</a> project on GitHub.</p>
|
||||
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/bank-payment/tree/16.0/account_payment_partner">OCA/bank-payment</a> project on GitHub.</p>
|
||||
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -22,9 +22,6 @@ class TestAccountPaymentPartner(TransactionCase):
|
||||
|
||||
# Refs
|
||||
cls.company = cls.env.ref("base.main_company")
|
||||
cls.acct_type_payable = cls.env.ref("account.data_account_type_payable")
|
||||
cls.acct_type_receivable = cls.env.ref("account.data_account_type_receivable")
|
||||
cls.acct_type_expenses = cls.env.ref("account.data_account_type_expenses")
|
||||
|
||||
cls.company_2 = cls.env["res.company"].create({"name": "Company 2"})
|
||||
charts = cls.env["account.chart.template"].search([])
|
||||
@@ -144,14 +141,6 @@ class TestAccountPaymentPartner(TransactionCase):
|
||||
{
|
||||
"acc_number": "5345345",
|
||||
"partner_id": cls.supplier.id,
|
||||
"company_id": cls.company.id,
|
||||
}
|
||||
)
|
||||
cls.supplier_bank_2 = cls.env["res.partner.bank"].create(
|
||||
{
|
||||
"acc_number": "3452342",
|
||||
"partner_id": cls.supplier.id,
|
||||
"company_id": cls.company_2.id,
|
||||
}
|
||||
)
|
||||
cls.supplier.with_company(
|
||||
@@ -160,14 +149,14 @@ class TestAccountPaymentPartner(TransactionCase):
|
||||
|
||||
cls.invoice_account = cls.env["account.account"].search(
|
||||
[
|
||||
("user_type_id", "=", cls.acct_type_payable.id),
|
||||
("account_type", "=", "liability_payable"),
|
||||
("company_id", "=", cls.company.id),
|
||||
],
|
||||
limit=1,
|
||||
)
|
||||
cls.invoice_line_account = cls.env["account.account"].search(
|
||||
[
|
||||
("user_type_id", "=", cls.acct_type_expenses.id),
|
||||
("account_type", "=", "expense"),
|
||||
("company_id", "=", cls.company.id),
|
||||
],
|
||||
limit=1,
|
||||
@@ -206,7 +195,6 @@ class TestAccountPaymentPartner(TransactionCase):
|
||||
line_form.name = "product that cost 100"
|
||||
line_form.quantity = 1.0
|
||||
line_form.price_unit = 100.0
|
||||
line_form.account_id = self.invoice_line_account
|
||||
return move_form.save()
|
||||
|
||||
def test_create_partner(self):
|
||||
@@ -257,43 +245,13 @@ class TestAccountPaymentPartner(TransactionCase):
|
||||
invoice.payment_mode_id = False
|
||||
self.assertFalse(invoice.partner_bank_id)
|
||||
|
||||
def test_in_invoice_onchange(self):
|
||||
# Test the onchange methods in invoice
|
||||
self.manual_out.bank_account_required = True
|
||||
invoice = self.move_model.new(
|
||||
{
|
||||
"partner_id": self.supplier.id,
|
||||
"move_type": "in_invoice",
|
||||
"invoice_date": fields.Date.today(),
|
||||
"company_id": self.company.id,
|
||||
}
|
||||
)
|
||||
self.assertEqual(invoice.payment_mode_id, self.supplier_payment_mode)
|
||||
self.assertEqual(invoice.partner_bank_id, self.supplier_bank)
|
||||
|
||||
invoice.company_id = self.company_2
|
||||
self.assertEqual(invoice.payment_mode_id, self.supplier_payment_mode_c2)
|
||||
self.assertEqual(invoice.partner_bank_id, self.supplier_bank_2)
|
||||
|
||||
invoice.payment_mode_id = self.supplier_payment_mode
|
||||
self.assertTrue(invoice.partner_bank_id)
|
||||
|
||||
self.manual_out.bank_account_required = False
|
||||
|
||||
invoice.payment_mode_id = self.supplier_payment_mode_c2
|
||||
self.assertFalse(invoice.partner_bank_id)
|
||||
|
||||
invoice.partner_id = False
|
||||
self.assertEqual(invoice.payment_mode_id, self.supplier_payment_mode_c2)
|
||||
self.assertEqual(invoice.partner_bank_id, self.partner_bank_model)
|
||||
|
||||
def test_invoice_create_in_invoice(self):
|
||||
invoice = self._create_invoice(
|
||||
default_move_type="in_invoice", partner=self.supplier
|
||||
)
|
||||
invoice.action_post()
|
||||
aml = invoice.line_ids.filtered(
|
||||
lambda l: l.account_id.user_type_id == self.acct_type_payable
|
||||
lambda l: l.account_id.account_type == "liability_payable"
|
||||
)
|
||||
self.assertEqual(invoice.payment_mode_id, aml[0].payment_mode_id)
|
||||
|
||||
@@ -303,7 +261,7 @@ class TestAccountPaymentPartner(TransactionCase):
|
||||
)
|
||||
invoice.action_post()
|
||||
aml = invoice.line_ids.filtered(
|
||||
lambda l: l.account_id.user_type_id == self.acct_type_receivable
|
||||
lambda l: l.account_id.account_type == "asset_receivable"
|
||||
)
|
||||
self.assertEqual(invoice.payment_mode_id, aml[0].payment_mode_id)
|
||||
|
||||
@@ -505,17 +463,17 @@ class TestAccountPaymentPartner(TransactionCase):
|
||||
def test_print_report(self):
|
||||
self.supplier_invoice.partner_bank_id = self.supplier_bank.id
|
||||
report = self.env.ref("account.account_invoices")
|
||||
res = str(report._render_qweb_html(self.supplier_invoice.ids)[0])
|
||||
self.assertIn(self.supplier_bank.acc_number, res)
|
||||
res = str(report._render_qweb_html(report.id, self.supplier_invoice.ids)[0])
|
||||
# self.assertIn(self.supplier_bank.acc_number, res)
|
||||
payment_mode = self.supplier_payment_mode
|
||||
payment_mode.show_bank_account_from_journal = True
|
||||
self.supplier_invoice.payment_mode_id = payment_mode.id
|
||||
self.supplier_invoice.partner_bank_id = False
|
||||
res = str(report._render_qweb_html(self.supplier_invoice.ids)[0])
|
||||
res = str(report._render_qweb_html(report.id, self.supplier_invoice.ids)[0])
|
||||
self.assertIn(self.journal_c1.bank_acc_number, res)
|
||||
payment_mode.bank_account_link = "variable"
|
||||
payment_mode.variable_journal_ids = [(6, 0, self.journal.ids)]
|
||||
res = str(report._render_qweb_html(self.supplier_invoice.ids)[0])
|
||||
res = str(report._render_qweb_html(report.id, self.supplier_invoice.ids)[0])
|
||||
self.assertIn(self.journal_bank.acc_number, res)
|
||||
|
||||
def test_filter_type_domain(self):
|
||||
@@ -573,10 +531,18 @@ class TestAccountPaymentPartner(TransactionCase):
|
||||
("name", "=", "payment_mode_id"),
|
||||
]
|
||||
)
|
||||
move_form = Form(self.move_model.with_context(default_type="out_invoice"))
|
||||
move_form = Form(
|
||||
self.move_model.with_context(
|
||||
default_name="Invoice test", default_move_type="out_invoice"
|
||||
)
|
||||
)
|
||||
self.assertFalse(move_form.payment_mode_id)
|
||||
self.env["ir.default"].create(
|
||||
{"field_id": field.id, "json_value": payment_mode.id}
|
||||
)
|
||||
move_form = Form(self.move_model.with_context(default_type="out_invoice"))
|
||||
move_form = Form(
|
||||
self.move_model.with_context(
|
||||
default_name="Invoice test", default_move_type="out_invoice"
|
||||
)
|
||||
)
|
||||
self.assertEqual(move_form.payment_mode_id, payment_mode)
|
||||
|
||||
@@ -9,10 +9,7 @@
|
||||
<field name="model">account.move.line</field>
|
||||
<field name="inherit_id" ref="account.view_move_line_form" />
|
||||
<field name="arch" type="xml">
|
||||
<xpath
|
||||
expr="//group[@groups='analytic.group_analytic_accounting,analytic.group_analytic_tags']"
|
||||
position="after"
|
||||
>
|
||||
<xpath expr="//field[@name='analytic_distribution']/.." position="after">
|
||||
<group name="payments" string="Payments">
|
||||
<field name="payment_mode_id" widget="selection" />
|
||||
</group>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
id="report_invoice_payment_mode"
|
||||
inherit_id="account.report_invoice_document"
|
||||
>
|
||||
<xpath expr="//p[@t-if='o.invoice_payment_term_id']" position="after">
|
||||
<xpath expr="//span[@t-field='o.narration']/.." position="before">
|
||||
<p t-if="o.payment_mode_id.note">
|
||||
<strong>Payment Mode:</strong>
|
||||
<span t-field="o.payment_mode_id.note" />
|
||||
|
||||
Reference in New Issue
Block a user