mirror of
https://github.com/OCA/bank-payment.git
synced 2025-02-02 10:37:31 +02:00
[MIG] account_payment_sale to 14.0
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
|
||||
{
|
||||
"name": "Account Payment Sale",
|
||||
"version": "13.0.1.1.1",
|
||||
"version": "14.0.1.0.0",
|
||||
"category": "Banking addons",
|
||||
"license": "AGPL-3",
|
||||
"summary": "Adds payment mode on sale orders",
|
||||
|
||||
@@ -1,2 +1 @@
|
||||
from . import account_move
|
||||
from . import sale_order
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||
|
||||
from odoo import api, models
|
||||
|
||||
|
||||
class AccountMove(models.Model):
|
||||
_inherit = "account.move"
|
||||
|
||||
@api.model
|
||||
def create(self, vals_list):
|
||||
if vals_list.get("payment_mode_id"):
|
||||
payment_mode = self.env["account.payment.mode"].browse(
|
||||
vals_list["payment_mode_id"]
|
||||
)
|
||||
if payment_mode.bank_account_link == "fixed":
|
||||
vals_list[
|
||||
"invoice_partner_bank_id"
|
||||
] = payment_mode.fixed_journal_id.bank_account_id.id
|
||||
return super().create(vals_list)
|
||||
@@ -1,4 +1,4 @@
|
||||
# Copyright 2014-2016 Akretion - Alexis de Lattre
|
||||
# Copyright 2014-2020 Akretion - Alexis de Lattre
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from odoo import api, fields, models
|
||||
@@ -12,7 +12,8 @@ class SaleOrder(models.Model):
|
||||
compute="_compute_payment_mode",
|
||||
store=True,
|
||||
readonly=False,
|
||||
domain=[("payment_type", "=", "inbound")],
|
||||
check_company=True,
|
||||
domain="[('payment_type', '=', 'inbound'), ('company_id', '=', company_id)]",
|
||||
)
|
||||
|
||||
@api.depends("partner_id")
|
||||
@@ -31,11 +32,11 @@ class SaleOrder(models.Model):
|
||||
and self.payment_mode_id.payment_method_id.code == "manual"
|
||||
):
|
||||
vals[
|
||||
"invoice_partner_bank_id"
|
||||
"partner_bank_id"
|
||||
] = self.payment_mode_id.fixed_journal_id.bank_account_id.id
|
||||
return vals
|
||||
|
||||
def _prepare_invoice(self):
|
||||
"""Copy bank partner from sale order to invoice"""
|
||||
vals = super()._prepare_invoice()
|
||||
return self._get_payment_mode_vals(vals)
|
||||
self._get_payment_mode_vals(vals)
|
||||
return vals
|
||||
|
||||
@@ -1,8 +1,3 @@
|
||||
This modules adds one field on sale orders: *Payment Mode*.
|
||||
This field is copied from customer to sale order and then from sale order to
|
||||
customer invoice.
|
||||
|
||||
This module is similar to the *sale_payment* module; the main difference is
|
||||
that it doesn't depend on the *account_payment_extension* module (it's not the
|
||||
only module to conflict with *account_payment_extension*; all the SEPA
|
||||
modules in the banking addons conflict with *account_payment_extension*.
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
You are able to add a payment mode directly on a partner.
|
||||
This payment mode is automatically associated to the sale order, then on related invoice.
|
||||
This default value can be changed in a draft sale order or draft invoice.
|
||||
This payment mode is automatically associated to the sale order, then copied to the related invoice.
|
||||
This default value can be changed sale orders or on draft invoices.
|
||||
|
||||
@@ -39,7 +39,7 @@ class TestSaleOrder(CommonTestCase):
|
||||
invoice = order.invoice_ids
|
||||
self.assertEqual(len(invoice), 1)
|
||||
self.assertEqual(invoice.payment_mode_id, expected_payment_mode)
|
||||
self.assertEqual(invoice.invoice_partner_bank_id, expected_partner_bank)
|
||||
self.assertEqual(invoice.partner_bank_id, expected_partner_bank)
|
||||
|
||||
def test_sale_to_invoice_payment_mode(self):
|
||||
"""
|
||||
@@ -95,4 +95,4 @@ class TestSaleOrder(CommonTestCase):
|
||||
invoice = order.invoice_ids
|
||||
self.assertEqual(len(invoice), 1)
|
||||
self.assertEqual(invoice.payment_mode_id, self.payment_mode_2)
|
||||
self.assertEqual(invoice.invoice_partner_bank_id, self.bank)
|
||||
self.assertEqual(invoice.partner_bank_id, self.bank)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<!--
|
||||
© 2014-2016 Akretion (Alexis de Lattre <alexis.delattre@akretion.com>)
|
||||
Copyright 2014-2020 Akretion (Alexis de Lattre <alexis.delattre@akretion.com>)
|
||||
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
-->
|
||||
<odoo>
|
||||
@@ -12,7 +12,6 @@
|
||||
<field name="payment_term_id" position="after">
|
||||
<field
|
||||
name="payment_mode_id"
|
||||
domain="[('payment_type', '=', 'inbound')]"
|
||||
options="{'no_open': True, 'no_create': True}"
|
||||
/>
|
||||
</field>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# Copyright 2016 Akretion - Alexis de Lattre
|
||||
# Copyright 2016-2020 Akretion - Alexis de Lattre
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from odoo import models
|
||||
@@ -7,10 +7,8 @@ from odoo import models
|
||||
class SaleAdvancePaymentInv(models.TransientModel):
|
||||
_inherit = "sale.advance.payment.inv"
|
||||
|
||||
def _create_invoice(self, order, so_line, amount):
|
||||
def _prepare_invoice_values(self, order, name, amount, so_line):
|
||||
"""Copy payment mode from sale order to invoice"""
|
||||
inv = super()._create_invoice(order, so_line, amount)
|
||||
vals = order._get_payment_mode_vals({})
|
||||
if vals:
|
||||
inv.write(vals)
|
||||
return inv
|
||||
vals = super()._prepare_invoice_values(order, name, amount, so_line)
|
||||
order._get_payment_mode_vals(vals)
|
||||
return vals
|
||||
|
||||
Reference in New Issue
Block a user