From 87a90c3a1de34f835182f65b5b9208b1d8d36230 Mon Sep 17 00:00:00 2001
From: Guille
Date: Wed, 21 Oct 2020 09:32:44 +0200
Subject: [PATCH] [MIG] contract_payment_mode: Migration to 13.0
---
contract_payment_mode/README.rst | 11 +++++-----
contract_payment_mode/__manifest__.py | 4 ++--
contract_payment_mode/hooks.py | 2 +-
.../i18n/contract_payment_mode.pot | 7 +++---
contract_payment_mode/models/contract.py | 22 ++-----------------
contract_payment_mode/readme/CONTRIBUTORS.rst | 1 +
.../static/description/index.html | 7 +++---
.../tests/test_contract_payment.py | 18 +++++++--------
8 files changed, 28 insertions(+), 44 deletions(-)
diff --git a/contract_payment_mode/README.rst b/contract_payment_mode/README.rst
index 7c1460491..55f3fc028 100644
--- a/contract_payment_mode/README.rst
+++ b/contract_payment_mode/README.rst
@@ -14,13 +14,13 @@ Contract Payment Mode
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fcontract-lightgray.png?logo=github
- :target: https://github.com/OCA/contract/tree/12.0/contract_payment_mode
+ :target: https://github.com/OCA/contract/tree/13.0/contract_payment_mode
:alt: OCA/contract
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
- :target: https://translation.odoo-community.org/projects/contract-12-0/contract-12-0-contract_payment_mode
+ :target: https://translation.odoo-community.org/projects/contract-13-0/contract-13-0-contract_payment_mode
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
- :target: https://runbot.odoo-community.org/runbot/110/12.0
+ :target: https://runbot.odoo-community.org/runbot/110/13.0
:alt: Try me on Runbot
|badge1| |badge2| |badge3| |badge4| |badge5|
@@ -57,7 +57,7 @@ Bug Tracker
Bugs are tracked on `GitHub 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 `_.
+`feedback `_.
Do not contact contributors directly about support or help with technical issues.
@@ -78,6 +78,7 @@ Contributors
* Vicent Cubells
* David Vidal
* Carlos Dauden
+* Guillermo Llinares
Maintainers
~~~~~~~~~~~
@@ -92,6 +93,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/contract `_ project on GitHub.
+This module is part of the `OCA/contract `_ project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
diff --git a/contract_payment_mode/__manifest__.py b/contract_payment_mode/__manifest__.py
index a235ad1c4..2326ae44c 100644
--- a/contract_payment_mode/__manifest__.py
+++ b/contract_payment_mode/__manifest__.py
@@ -8,13 +8,13 @@
{
"name": "Contract Payment Mode",
"summary": "Payment mode in contracts and their invoices",
- "version": "12.0.1.1.0",
+ "version": "13.0.1.0.0",
"author": "Domatix, " "Tecnativa, " "Odoo Community Association (OCA)",
"website": "https://github.com/OCA/contract",
"depends": ["contract", "account_payment_partner"],
"category": "Sales Management",
"license": "AGPL-3",
- "data": ["views/contract_view.xml",],
+ "data": ["views/contract_view.xml"],
"post_init_hook": "post_init_hook",
"installable": True,
"auto_install": True,
diff --git a/contract_payment_mode/hooks.py b/contract_payment_mode/hooks.py
index 7ba0b9e65..6d556f31f 100644
--- a/contract_payment_mode/hooks.py
+++ b/contract_payment_mode/hooks.py
@@ -13,7 +13,7 @@ def post_init_hook(cr, registry):
with api.Environment.manage():
env = api.Environment(cr, SUPERUSER_ID, {})
m_contract = env["contract.contract"]
- contracts = m_contract.search([("payment_mode_id", "=", False),])
+ contracts = m_contract.search([("payment_mode_id", "=", False)])
if contracts:
_logger.info("Setting payment mode: %d contracts" % len(contracts))
for contract in contracts:
diff --git a/contract_payment_mode/i18n/contract_payment_mode.pot b/contract_payment_mode/i18n/contract_payment_mode.pot
index 58d48f89b..c3ce1c775 100644
--- a/contract_payment_mode/i18n/contract_payment_mode.pot
+++ b/contract_payment_mode/i18n/contract_payment_mode.pot
@@ -1,12 +1,12 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
-# * contract_payment_mode
+# * contract_payment_mode
#
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"
+"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
@@ -22,4 +22,3 @@ msgstr ""
#: model:ir.model.fields,field_description:contract_payment_mode.field_contract_contract__payment_mode_id
msgid "Payment Mode"
msgstr ""
-
diff --git a/contract_payment_mode/models/contract.py b/contract_payment_mode/models/contract.py
index edba78254..8041d6b4d 100644
--- a/contract_payment_mode/models/contract.py
+++ b/contract_payment_mode/models/contract.py
@@ -15,28 +15,10 @@ class ContractContract(models.Model):
def on_change_partner_id(self):
self.payment_mode_id = self.partner_id.customer_payment_mode_id.id
- @api.multi
def _prepare_invoice(self, date_invoice, journal=None):
- invoice_vals = super(ContractContract, self)._prepare_invoice(
+ invoice_vals, move_form = super()._prepare_invoice(
date_invoice=date_invoice, journal=journal
)
if self.payment_mode_id:
invoice_vals["payment_mode_id"] = self.payment_mode_id.id
- invoice = self.env["account.invoice"].new(invoice_vals)
- invoice._onchange_payment_mode_id()
- invoice_vals = invoice._convert_to_write(invoice._cache)
- return invoice_vals
-
- @api.model
- def _finalize_invoice_creation(self, invoices):
- """
- This override preserves the payment mode when calling the partner's
- onchange.
- """
- payment_modes_by_invoice = {}
- for invoice in invoices:
- payment_modes_by_invoice[invoice] = invoice.payment_mode_id
- res = super(ContractContract, self)._finalize_invoice_creation(invoices)
- for invoice in invoices:
- invoice.payment_mode_id = payment_modes_by_invoice.get(invoice)
- return res
+ return invoice_vals, move_form
diff --git a/contract_payment_mode/readme/CONTRIBUTORS.rst b/contract_payment_mode/readme/CONTRIBUTORS.rst
index acb944587..6bf6c2898 100644
--- a/contract_payment_mode/readme/CONTRIBUTORS.rst
+++ b/contract_payment_mode/readme/CONTRIBUTORS.rst
@@ -3,3 +3,4 @@
* Vicent Cubells
* David Vidal
* Carlos Dauden
+* Guillermo Llinares
diff --git a/contract_payment_mode/static/description/index.html b/contract_payment_mode/static/description/index.html
index 5a7e1bede..94dbd92d1 100644
--- a/contract_payment_mode/static/description/index.html
+++ b/contract_payment_mode/static/description/index.html
@@ -367,7 +367,7 @@ ul.auto-toc {
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
-

+

This module allows to set a payment mode on contract for creating the invoices
with this payment mode.
Table of contents
@@ -407,7 +407,7 @@ corresponding field.
Bugs are tracked on GitHub 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.
+feedback.
Do not contact contributors directly about support or help with technical issues.
@@ -436,7 +437,7 @@ If you spotted it first, help us smashing it by providing a detailed and welcome
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/contract project on GitHub.
+
This module is part of the OCA/contract project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
diff --git a/contract_payment_mode/tests/test_contract_payment.py b/contract_payment_mode/tests/test_contract_payment.py
index cee797167..3fb308741 100644
--- a/contract_payment_mode/tests/test_contract_payment.py
+++ b/contract_payment_mode/tests/test_contract_payment.py
@@ -12,10 +12,10 @@ from ..hooks import post_init_hook
@odoo.tests.at_install(False)
class TestContractPaymentInit(odoo.tests.HttpCase):
def setUp(self):
- super(TestContractPaymentInit, self).setUp()
+ super().setUp()
self.payment_method = self.env["account.payment.method"].create(
- {"name": "Test Payment Method", "code": "Test", "payment_type": "inbound",}
+ {"name": "Test Payment Method", "code": "Test", "payment_type": "inbound"}
)
self.payment_mode = self.env["account.payment.mode"].create(
{
@@ -41,7 +41,7 @@ class TestContractPaymentInit(odoo.tests.HttpCase):
}
)
self.contract = self.env["contract.contract"].create(
- {"name": "Maintenance of Servers", "partner_id": self.partner.id,}
+ {"name": "Maintenance of Servers", "partner_id": self.partner.id}
)
company = self.env.ref("base.main_company")
self.journal = self.env["account.journal"].create(
@@ -78,6 +78,11 @@ class TestContractPaymentInit(odoo.tests.HttpCase):
)
self.contract.write(
{
+ "line_recurrence": True,
+ "contract_type": "sale",
+ "recurring_interval": 1,
+ "recurring_rule_type": "monthly",
+ "date_start": "2018-01-15",
"contract_line_ids": [
(
0,
@@ -88,14 +93,9 @@ class TestContractPaymentInit(odoo.tests.HttpCase):
"quantity": 2.0,
"uom_id": self.product.uom_id.id,
"price_unit": 200.0,
- "recurring_rule_type": "monthly",
- "recurring_interval": 1,
- "date_start": "2018-01-01",
- "recurring_next_date": "2018-01-15",
- "is_auto_renew": False,
},
)
- ]
+ ],
}
)
self.contract.recurring_create_invoice()