[MIG] account_payment_sale to 14.0

This commit is contained in:
Alexis de Lattre
2020-12-24 10:33:49 +01:00
parent 7647d81f10
commit f6f59e47a4
9 changed files with 17 additions and 44 deletions

View File

@@ -4,7 +4,7 @@
{ {
"name": "Account Payment Sale", "name": "Account Payment Sale",
"version": "13.0.1.1.1", "version": "14.0.1.0.0",
"category": "Banking addons", "category": "Banking addons",
"license": "AGPL-3", "license": "AGPL-3",
"summary": "Adds payment mode on sale orders", "summary": "Adds payment mode on sale orders",

View File

@@ -1,2 +1 @@
from . import account_move
from . import sale_order from . import sale_order

View File

@@ -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)

View File

@@ -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). # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import api, fields, models from odoo import api, fields, models
@@ -12,7 +12,8 @@ class SaleOrder(models.Model):
compute="_compute_payment_mode", compute="_compute_payment_mode",
store=True, store=True,
readonly=False, readonly=False,
domain=[("payment_type", "=", "inbound")], check_company=True,
domain="[('payment_type', '=', 'inbound'), ('company_id', '=', company_id)]",
) )
@api.depends("partner_id") @api.depends("partner_id")
@@ -31,11 +32,11 @@ class SaleOrder(models.Model):
and self.payment_mode_id.payment_method_id.code == "manual" and self.payment_mode_id.payment_method_id.code == "manual"
): ):
vals[ vals[
"invoice_partner_bank_id" "partner_bank_id"
] = self.payment_mode_id.fixed_journal_id.bank_account_id.id ] = self.payment_mode_id.fixed_journal_id.bank_account_id.id
return vals
def _prepare_invoice(self): def _prepare_invoice(self):
"""Copy bank partner from sale order to invoice""" """Copy bank partner from sale order to invoice"""
vals = super()._prepare_invoice() vals = super()._prepare_invoice()
return self._get_payment_mode_vals(vals) self._get_payment_mode_vals(vals)
return vals

View File

@@ -1,8 +1,3 @@
This modules adds one field on sale orders: *Payment Mode*. 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 This field is copied from customer to sale order and then from sale order to
customer invoice. 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*.

View File

@@ -1,3 +1,3 @@
You are able to add a payment mode directly on a partner. 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 payment mode is automatically associated to the sale order, then copied to the related invoice.
This default value can be changed in a draft sale order or draft invoice. This default value can be changed sale orders or on draft invoices.

View File

@@ -39,7 +39,7 @@ class TestSaleOrder(CommonTestCase):
invoice = order.invoice_ids invoice = order.invoice_ids
self.assertEqual(len(invoice), 1) self.assertEqual(len(invoice), 1)
self.assertEqual(invoice.payment_mode_id, expected_payment_mode) 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): def test_sale_to_invoice_payment_mode(self):
""" """
@@ -95,4 +95,4 @@ class TestSaleOrder(CommonTestCase):
invoice = order.invoice_ids invoice = order.invoice_ids
self.assertEqual(len(invoice), 1) self.assertEqual(len(invoice), 1)
self.assertEqual(invoice.payment_mode_id, self.payment_mode_2) 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)

View File

@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?> <?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). License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
--> -->
<odoo> <odoo>
@@ -12,7 +12,6 @@
<field name="payment_term_id" position="after"> <field name="payment_term_id" position="after">
<field <field
name="payment_mode_id" name="payment_mode_id"
domain="[('payment_type', '=', 'inbound')]"
options="{'no_open': True, 'no_create': True}" options="{'no_open': True, 'no_create': True}"
/> />
</field> </field>

View File

@@ -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). # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import models from odoo import models
@@ -7,10 +7,8 @@ from odoo import models
class SaleAdvancePaymentInv(models.TransientModel): class SaleAdvancePaymentInv(models.TransientModel):
_inherit = "sale.advance.payment.inv" _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""" """Copy payment mode from sale order to invoice"""
inv = super()._create_invoice(order, so_line, amount) vals = super()._prepare_invoice_values(order, name, amount, so_line)
vals = order._get_payment_mode_vals({}) order._get_payment_mode_vals(vals)
if vals: return vals
inv.write(vals)
return inv