mirror of
https://github.com/OCA/bank-payment.git
synced 2025-02-02 10:37:31 +02:00
[MIG] account_payment_partner: Migration to 15.0
This commit is contained in:
committed by
Thomas Binsfeld
parent
8ad04276f5
commit
ec6028f8d4
@@ -6,7 +6,7 @@
|
||||
|
||||
{
|
||||
"name": "Account Payment Partner",
|
||||
"version": "14.0.1.3.2",
|
||||
"version": "15.0.1.0.0",
|
||||
"category": "Banking addons",
|
||||
"license": "AGPL-3",
|
||||
"summary": "Adds payment mode on partners and invoices",
|
||||
|
||||
@@ -17,7 +17,7 @@ class AccountMove(models.Model):
|
||||
)
|
||||
payment_mode_id = fields.Many2one(
|
||||
comodel_name="account.payment.mode",
|
||||
compute="_compute_payment_mode",
|
||||
compute="_compute_payment_mode_id",
|
||||
store=True,
|
||||
ondelete="restrict",
|
||||
readonly=False,
|
||||
@@ -27,7 +27,7 @@ class AccountMove(models.Model):
|
||||
related="payment_mode_id.payment_method_id.bank_account_required", readonly=True
|
||||
)
|
||||
partner_bank_id = fields.Many2one(
|
||||
compute="_compute_partner_bank",
|
||||
compute="_compute_partner_bank_id",
|
||||
store=True,
|
||||
ondelete="restrict",
|
||||
readonly=False,
|
||||
@@ -54,9 +54,8 @@ class AccountMove(models.Model):
|
||||
move.partner_bank_filter_type_domain = False
|
||||
|
||||
@api.depends("partner_id", "company_id")
|
||||
def _compute_payment_mode(self):
|
||||
def _compute_payment_mode_id(self):
|
||||
for move in self:
|
||||
move.payment_mode_id = move.payment_mode_id
|
||||
if move.company_id and move.payment_mode_id.company_id != move.company_id:
|
||||
move.payment_mode_id = False
|
||||
if move.partner_id:
|
||||
@@ -88,19 +87,21 @@ class AccountMove(models.Model):
|
||||
``_compute_partner_bank``.
|
||||
"""
|
||||
res = super()._onchange_partner_id()
|
||||
self._compute_partner_bank()
|
||||
self._compute_partner_bank_id()
|
||||
return res
|
||||
|
||||
@api.depends("partner_id", "payment_mode_id")
|
||||
def _compute_partner_bank(self):
|
||||
def _compute_partner_bank_id(self):
|
||||
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 move.commercial_partner_id.bank_ids.filtered(
|
||||
lambda b: b.company_id == move.company_id or not b.company_id
|
||||
)[:1]
|
||||
return fields.first(
|
||||
move.commercial_partner_id.bank_ids.filtered(
|
||||
lambda b: b.company_id == move.company_id or not b.company_id
|
||||
)
|
||||
)
|
||||
|
||||
bank_id = False
|
||||
if move.partner_id:
|
||||
@@ -145,11 +146,10 @@ class AccountMove(models.Model):
|
||||
|
||||
@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.
|
||||
"""
|
||||
# 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()
|
||||
virtual_move._compute_partner_bank_id()
|
||||
vals["partner_bank_id"] = virtual_move.partner_bank_id.id
|
||||
return super().create(vals)
|
||||
|
||||
@@ -5,13 +5,14 @@
|
||||
from odoo import _, fields
|
||||
from odoo.exceptions import UserError, ValidationError
|
||||
from odoo.fields import Date
|
||||
from odoo.tests.common import Form, SavepointCase
|
||||
from odoo.tests.common import Form, TransactionCase
|
||||
|
||||
|
||||
class TestAccountPaymentPartner(SavepointCase):
|
||||
class TestAccountPaymentPartner(TransactionCase):
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
super().setUpClass()
|
||||
cls.env = cls.env(context=dict(cls.env.context, tracking_disable=True))
|
||||
|
||||
cls.res_users_model = cls.env["res.users"]
|
||||
cls.move_model = cls.env["account.move"]
|
||||
@@ -105,7 +106,7 @@ class TestAccountPaymentPartner(SavepointCase):
|
||||
cls.customer_payment_mode = cls.payment_mode_model.create(
|
||||
{
|
||||
"name": "Customers to Bank 1",
|
||||
"bank_account_link": "fixed",
|
||||
"bank_account_link": "variable",
|
||||
"payment_method_id": cls.manual_in.id,
|
||||
"company_id": cls.company.id,
|
||||
"fixed_journal_id": cls.journal_c1.id,
|
||||
@@ -405,7 +406,13 @@ class TestAccountPaymentPartner(SavepointCase):
|
||||
"active_model": "account.move",
|
||||
}
|
||||
)
|
||||
.create({"refund_method": "refund", "reason": "reason test create"})
|
||||
.create(
|
||||
{
|
||||
"refund_method": "refund",
|
||||
"reason": "reason test create",
|
||||
"journal_id": invoice.journal_id.id,
|
||||
}
|
||||
)
|
||||
)
|
||||
refund_invoice = self.move_model.browse(
|
||||
refund_invoice_wizard.reverse_moves()["res_id"]
|
||||
@@ -433,7 +440,13 @@ class TestAccountPaymentPartner(SavepointCase):
|
||||
"active_model": "account.move",
|
||||
}
|
||||
)
|
||||
.create({"refund_method": "refund", "reason": "reason test create"})
|
||||
.create(
|
||||
{
|
||||
"refund_method": "refund",
|
||||
"reason": "reason test create",
|
||||
"journal_id": invoice.journal_id.id,
|
||||
}
|
||||
)
|
||||
)
|
||||
refund_invoice = self.move_model.browse(
|
||||
refund_invoice_wizard.reverse_moves()["res_id"]
|
||||
|
||||
@@ -30,7 +30,6 @@
|
||||
widget="selection"
|
||||
attrs="{'readonly': [('state', '!=', 'draft')], 'invisible': [('move_type', 'not in', ('out_invoice','out_refund','in_invoice','in_refund'))]}"
|
||||
/>
|
||||
<field name="commercial_partner_id" invisible="1" />
|
||||
<field name="bank_account_required" invisible="1" />
|
||||
<field name="payment_mode_filter_type_domain" invisible="1" />
|
||||
<field name="partner_bank_filter_type_domain" invisible="1" />
|
||||
|
||||
Reference in New Issue
Block a user