mirror of
https://github.com/OCA/bank-payment.git
synced 2025-02-02 10:37:31 +02:00
[MIG] account_payment_purchase: Migration to 13.0
This commit is contained in:
@@ -14,16 +14,16 @@ Account Payment Purchase
|
||||
: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/12.0/account_payment_purchase
|
||||
:target: https://github.com/OCA/bank-payment/tree/13.0/account_payment_purchase
|
||||
: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-12-0/bank-payment-12-0-account_payment_purchase
|
||||
:target: https://translation.odoo-community.org/projects/bank-payment-13-0/bank-payment-13-0-account_payment_purchase
|
||||
: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/12.0
|
||||
:target: https://runbot.odoo-community.org/runbot/173/13.0
|
||||
:alt: Try me on Runbot
|
||||
|
||||
|badge1| |badge2| |badge3| |badge4| |badge5|
|
||||
|badge1| |badge2| |badge3| |badge4| |badge5|
|
||||
|
||||
This module adds 2 fields on purchase orders: *Bank Account* and *Payment
|
||||
Mode*. These fields are copied from partner to purchase order and then from
|
||||
@@ -44,7 +44,7 @@ Installation
|
||||
|
||||
This module depends on :
|
||||
|
||||
- purchase
|
||||
- purchase_stock
|
||||
- account_payment_partner
|
||||
|
||||
This module is part of the OCA/bank-payment suite.
|
||||
@@ -69,7 +69,7 @@ Bug Tracker
|
||||
Bugs are tracked on `GitHub Issues <https://github.com/OCA/bank-payment/issues>`_.
|
||||
In case of trouble, please check there if your issue has already been reported.
|
||||
If you spotted it first, help us smashing it by providing a detailed and welcomed
|
||||
`feedback <https://github.com/OCA/bank-payment/issues/new?body=module:%20account_payment_purchase%0Aversion:%2012.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
|
||||
`feedback <https://github.com/OCA/bank-payment/issues/new?body=module:%20account_payment_purchase%0Aversion:%2013.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
|
||||
|
||||
Do not contact contributors directly about support or help with technical issues.
|
||||
|
||||
@@ -96,6 +96,7 @@ Contributors
|
||||
* Vicent Cubells <vicent.cubells@tecnativa.com>
|
||||
|
||||
* Nikul Chaudhary <nikulchaudhary2112@gmail.com>
|
||||
* Miquel Raïch <miquel.raich@forgeflow.com>
|
||||
|
||||
Maintainers
|
||||
~~~~~~~~~~~
|
||||
@@ -110,6 +111,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/12.0/account_payment_purchase>`_ project on GitHub.
|
||||
This module is part of the `OCA/bank-payment <https://github.com/OCA/bank-payment/tree/13.0/account_payment_purchase>`_ project on GitHub.
|
||||
|
||||
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
|
||||
|
||||
@@ -4,11 +4,11 @@
|
||||
|
||||
{
|
||||
"name": "Account Payment Purchase",
|
||||
"version": "12.0.1.0.0",
|
||||
"version": "13.0.1.0.0",
|
||||
"category": "Banking addons",
|
||||
"license": "AGPL-3",
|
||||
"summary": "Adds Bank Account and Payment Mode on Purchase Orders",
|
||||
"author": "Akretion, " "Tecnativa, " "Odoo Community Association (OCA)",
|
||||
"author": "Akretion, Tecnativa, Odoo Community Association (OCA)",
|
||||
"website": "https://github.com/OCA/bank-payment",
|
||||
"depends": ["account_payment_partner", "purchase_stock"],
|
||||
"data": ["views/purchase_order_view.xml"],
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Odoo Server 12.0\n"
|
||||
"Project-Id-Version: Odoo Server 13.0\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"Last-Translator: <>\n"
|
||||
"Language-Team: \n"
|
||||
|
||||
@@ -5,27 +5,26 @@
|
||||
from odoo import _, api, models
|
||||
|
||||
|
||||
class AccountInvoice(models.Model):
|
||||
_inherit = "account.invoice"
|
||||
class AccountMove(models.Model):
|
||||
_inherit = "account.move"
|
||||
|
||||
@api.onchange("purchase_id")
|
||||
def purchase_order_change(self):
|
||||
@api.onchange("purchase_vendor_bill_id", "purchase_id")
|
||||
def _onchange_purchase_auto_complete(self):
|
||||
new_mode = self.purchase_id.payment_mode_id.id or False
|
||||
new_bank = self.purchase_id.supplier_partner_bank_id.id or False
|
||||
res = super(AccountInvoice, self).purchase_order_change()
|
||||
res = super()._onchange_purchase_auto_complete() or {}
|
||||
if self.payment_mode_id and self.payment_mode_id.id != new_mode:
|
||||
res["warning"] = {
|
||||
"title": _("Warning"),
|
||||
"message": _("Selected purchase order have different " "payment mode."),
|
||||
"message": _("Selected purchase order have different payment mode."),
|
||||
}
|
||||
return res
|
||||
self.payment_mode_id = new_mode
|
||||
if self.partner_bank_id and self.partner_bank_id.id != new_bank:
|
||||
if self.invoice_partner_bank_id and self.invoice_partner_bank_id.id != new_bank:
|
||||
res["warning"] = {
|
||||
"title": _("Warning"),
|
||||
"message": _(
|
||||
"Selected purchase order have different " "supplier bank."
|
||||
),
|
||||
"message": _("Selected purchase order have different supplier bank."),
|
||||
}
|
||||
return res
|
||||
self.partner_bank_id = new_bank
|
||||
self.invoice_partner_bank_id = new_bank
|
||||
return res
|
||||
|
||||
@@ -27,7 +27,7 @@ class PurchaseOrder(models.Model):
|
||||
"""This function is designed to be inherited"""
|
||||
return partner.bank_ids and partner.bank_ids[0].id or False
|
||||
|
||||
@api.onchange("partner_id")
|
||||
@api.onchange("partner_id", "company_id")
|
||||
def onchange_partner_id(self):
|
||||
super(PurchaseOrder, self).onchange_partner_id()
|
||||
if self.partner_id:
|
||||
|
||||
@@ -7,18 +7,18 @@ from odoo import models
|
||||
class StockRule(models.Model):
|
||||
_inherit = "stock.rule"
|
||||
|
||||
def _prepare_purchase_order(
|
||||
self, product_id, product_qty, product_uom, origin, values, partner
|
||||
):
|
||||
def _prepare_purchase_order(self, company_id, origins, values):
|
||||
"""Propagate payment mode on MTO/drop shipping."""
|
||||
values = super(StockRule, self)._prepare_purchase_order(
|
||||
product_id, product_qty, product_uom, origin, values, partner
|
||||
res = super(StockRule, self)._prepare_purchase_order(
|
||||
company_id, origins, values
|
||||
)
|
||||
values = values[0]
|
||||
partner = values["supplier"].name
|
||||
if partner:
|
||||
values["payment_mode_id"] = partner.with_context(
|
||||
res["payment_mode_id"] = partner.with_context(
|
||||
force_company=self.company_id.id
|
||||
).supplier_payment_mode_id.id
|
||||
values["supplier_partner_bank_id"] = self.env[
|
||||
res["supplier_partner_bank_id"] = self.env[
|
||||
"purchase.order"
|
||||
]._get_default_supplier_partner_bank(partner)
|
||||
return values
|
||||
return res
|
||||
|
||||
@@ -9,3 +9,4 @@
|
||||
* Vicent Cubells <vicent.cubells@tecnativa.com>
|
||||
|
||||
* Nikul Chaudhary <nikulchaudhary2112@gmail.com>
|
||||
* Miquel Raïch <miquel.raich@forgeflow.com>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
This module depends on :
|
||||
|
||||
- purchase
|
||||
- purchase_stock
|
||||
- account_payment_partner
|
||||
|
||||
This module is part of the OCA/bank-payment suite.
|
||||
|
||||
@@ -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="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.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/12.0/account_payment_purchase"><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-12-0/bank-payment-12-0-account_payment_purchase"><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/12.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="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.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/13.0/account_payment_purchase"><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-13-0/bank-payment-13-0-account_payment_purchase"><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/13.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
|
||||
<p>This module adds 2 fields on purchase orders: <em>Bank Account</em> and <em>Payment
|
||||
Mode</em>. These fields are copied from partner to purchase order and then from
|
||||
purchase order to supplier invoice.</p>
|
||||
@@ -393,7 +393,7 @@ modules in the banking addons conflict with <em>account_payment_extension</em>).
|
||||
<h1><a class="toc-backref" href="#id1">Installation</a></h1>
|
||||
<p>This module depends on :</p>
|
||||
<ul class="simple">
|
||||
<li>purchase</li>
|
||||
<li>purchase_stock</li>
|
||||
<li>account_payment_partner</li>
|
||||
</ul>
|
||||
<p>This module is part of the OCA/bank-payment suite.</p>
|
||||
@@ -414,7 +414,7 @@ Invoices without any payment mode are displayed too.</p>
|
||||
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/bank-payment/issues">GitHub Issues</a>.
|
||||
In case of trouble, please check there if your issue has already been reported.
|
||||
If you spotted it first, help us smashing it by providing a detailed and welcomed
|
||||
<a class="reference external" href="https://github.com/OCA/bank-payment/issues/new?body=module:%20account_payment_purchase%0Aversion:%2012.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
|
||||
<a class="reference external" href="https://github.com/OCA/bank-payment/issues/new?body=module:%20account_payment_purchase%0Aversion:%2013.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
|
||||
<p>Do not contact contributors directly about support or help with technical issues.</p>
|
||||
</div>
|
||||
<div class="section" id="credits">
|
||||
@@ -440,6 +440,7 @@ If you spotted it first, help us smashing it by providing a detailed and welcome
|
||||
</ul>
|
||||
</li>
|
||||
<li>Nikul Chaudhary <<a class="reference external" href="mailto:nikulchaudhary2112@gmail.com">nikulchaudhary2112@gmail.com</a>></li>
|
||||
<li>Miquel Raïch <<a class="reference external" href="mailto:miquel.raich@forgeflow.com">miquel.raich@forgeflow.com</a>></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="section" id="maintainers">
|
||||
@@ -449,7 +450,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/12.0/account_payment_purchase">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/13.0/account_payment_purchase">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>
|
||||
|
||||
@@ -3,10 +3,10 @@
|
||||
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
|
||||
|
||||
from odoo import fields
|
||||
from odoo.tests import common
|
||||
from odoo.tests import Form, SavepointCase
|
||||
|
||||
|
||||
class TestAccountPaymentPurchase(common.SavepointCase):
|
||||
class TestAccountPaymentPurchase(SavepointCase):
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
super(TestAccountPaymentPurchase, cls).setUpClass()
|
||||
@@ -63,7 +63,7 @@ class TestAccountPaymentPurchase(common.SavepointCase):
|
||||
"product_qty": 1.0,
|
||||
"product_id": cls.mto_product.id,
|
||||
"product_uom": cls.uom_id,
|
||||
"date_planned": fields.Date.today(),
|
||||
"date_planned": fields.Datetime.today(),
|
||||
"price_unit": 1.0,
|
||||
},
|
||||
)
|
||||
@@ -82,14 +82,11 @@ class TestAccountPaymentPurchase(common.SavepointCase):
|
||||
picking.move_lines.write({"quantity_done": 1.0})
|
||||
picking.button_validate()
|
||||
|
||||
invoice = self.env["account.invoice"].create(
|
||||
{
|
||||
"partner_id": self.partner.id,
|
||||
"purchase_id": self.purchase.id,
|
||||
"account_id": self.partner.property_account_payable_id.id,
|
||||
}
|
||||
invoice = self.env["account.move"].create(
|
||||
{"partner_id": self.partner.id, "type": "in_invoice"}
|
||||
)
|
||||
invoice.purchase_order_change()
|
||||
with Form(invoice) as inv:
|
||||
inv.purchase_id = self.purchase
|
||||
self.assertEqual(
|
||||
self.purchase.invoice_ids[0].payment_mode_id, self.payment_mode
|
||||
)
|
||||
@@ -99,84 +96,88 @@ class TestAccountPaymentPurchase(common.SavepointCase):
|
||||
stockable_product = self.env["product.product"].create(
|
||||
{"name": "Test stockable product", "type": "product"}
|
||||
)
|
||||
self.purchase.order_line[0].product_id = stockable_product.id
|
||||
self.purchase.order_line[0].product_id = stockable_product
|
||||
self.purchase.button_confirm()
|
||||
picking = self.purchase.picking_ids[0]
|
||||
picking.action_confirm()
|
||||
picking.move_lines.write({"quantity_done": 1.0})
|
||||
picking.button_validate()
|
||||
|
||||
invoice = self.env["account.invoice"].create(
|
||||
{
|
||||
"partner_id": self.partner.id,
|
||||
"purchase_id": self.purchase.id,
|
||||
"account_id": self.partner.property_account_payable_id.id,
|
||||
}
|
||||
invoice = self.env["account.move"].create(
|
||||
{"partner_id": self.partner.id, "type": "in_invoice"}
|
||||
)
|
||||
invoice.purchase_order_change()
|
||||
invoice.purchase_id = self.purchase
|
||||
invoice._onchange_purchase_auto_complete()
|
||||
self.assertEqual(invoice.payment_mode_id, self.payment_mode)
|
||||
purchase2 = self.purchase.copy()
|
||||
payment_mode2 = self.payment_mode.copy()
|
||||
purchase2.payment_mode_id = payment_mode2.id
|
||||
purchase2.payment_mode_id = payment_mode2
|
||||
purchase2.button_confirm()
|
||||
picking = purchase2.picking_ids[0]
|
||||
picking.action_confirm()
|
||||
picking.move_lines.write({"quantity_done": 1.0})
|
||||
picking.button_validate()
|
||||
invoice.purchase_id = purchase2.id
|
||||
result = invoice.purchase_order_change()
|
||||
self.assertEqual(result["warning"]["title"], "Warning")
|
||||
invoice.purchase_id = purchase2
|
||||
result = invoice._onchange_purchase_auto_complete()
|
||||
self.assertEqual(
|
||||
result and result.get("warning", {}).get("title", False), "Warning"
|
||||
)
|
||||
|
||||
def test_picking_from_purchase_order_invoicing_bank(self):
|
||||
# Test patner_bank
|
||||
# Test partner_bank
|
||||
stockable_product = self.env["product.product"].create(
|
||||
{"name": "Test stockable product", "type": "product"}
|
||||
)
|
||||
self.purchase.order_line[0].product_id = stockable_product.id
|
||||
self.purchase.order_line[0].product_id = stockable_product
|
||||
self.purchase.payment_mode_id = False
|
||||
self.purchase.supplier_partner_bank_id = self.bank.id
|
||||
self.purchase.supplier_partner_bank_id = self.bank
|
||||
self.purchase.button_confirm()
|
||||
picking = self.purchase.picking_ids[0]
|
||||
picking.action_confirm()
|
||||
picking.move_lines.write({"quantity_done": 1.0})
|
||||
picking.button_validate()
|
||||
|
||||
invoice = self.env["account.invoice"].create(
|
||||
{
|
||||
"partner_id": self.partner.id,
|
||||
"purchase_id": self.purchase.id,
|
||||
"account_id": self.partner.property_account_payable_id.id,
|
||||
}
|
||||
invoice = self.env["account.move"].create(
|
||||
{"partner_id": self.partner.id, "type": "in_invoice"}
|
||||
)
|
||||
# Avoid bank company from default_get method
|
||||
invoice.partner_bank_id = False
|
||||
invoice.purchase_order_change()
|
||||
self.assertEqual(invoice.partner_bank_id, self.bank)
|
||||
invoice.purchase_id = self.purchase
|
||||
invoice._onchange_purchase_auto_complete()
|
||||
self.assertEqual(invoice.invoice_partner_bank_id, self.bank)
|
||||
purchase2 = self.purchase.copy()
|
||||
purchase2.supplier_partner_bank_id = self.bank2.id
|
||||
purchase2.supplier_partner_bank_id = self.bank2
|
||||
purchase2.button_confirm()
|
||||
picking = purchase2.picking_ids[0]
|
||||
picking.action_confirm()
|
||||
picking.move_lines.write({"quantity_done": 1.0})
|
||||
picking.button_validate()
|
||||
invoice.purchase_id = purchase2.id
|
||||
result = invoice.purchase_order_change()
|
||||
self.assertEqual(result["warning"]["title"], "Warning")
|
||||
invoice.purchase_id = purchase2
|
||||
result = invoice._onchange_purchase_auto_complete()
|
||||
self.assertEqual(
|
||||
result and result.get("warning", {}).get("title", False), "Warning"
|
||||
)
|
||||
|
||||
def test_procurement_buy_payment_mode(self):
|
||||
route = self.env.ref("purchase_stock.route_warehouse0_buy")
|
||||
rule = self.env["stock.rule"].search([("route_id", "=", route.id)], limit=1)
|
||||
rule._run_buy(
|
||||
product_id=self.mto_product,
|
||||
product_qty=1,
|
||||
product_uom=self.mto_product.uom_id,
|
||||
location_id=self.env["stock.location"].search([], limit=1),
|
||||
name="Procurement order test",
|
||||
origin="Test",
|
||||
values={
|
||||
"company_id": self.env.user.company_id,
|
||||
"date_planned": fields.Datetime.now(),
|
||||
},
|
||||
procurements=[
|
||||
(
|
||||
self.env["procurement.group"].Procurement(
|
||||
self.mto_product,
|
||||
1,
|
||||
self.mto_product.uom_id,
|
||||
self.env["stock.location"].search([], limit=1),
|
||||
"Procurement order test",
|
||||
"Test",
|
||||
rule.company_id,
|
||||
{
|
||||
"company_id": rule.company_id,
|
||||
"date_planned": fields.Datetime.now(),
|
||||
},
|
||||
),
|
||||
rule,
|
||||
)
|
||||
]
|
||||
)
|
||||
purchase = self.env["purchase.order"].search([("origin", "=", "Test")])
|
||||
self.assertEqual(purchase.payment_mode_id, self.payment_mode)
|
||||
|
||||
Reference in New Issue
Block a user