[MIG] contract_payment_mode: Migration to 13.0

This commit is contained in:
Guille
2020-10-21 09:32:44 +02:00
parent b30f04cfa4
commit 525db6d090
9 changed files with 28 additions and 42 deletions

View File

@@ -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 <https://github.com/OCA/contract/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/contract/issues/new?body=module:%20contract_payment_mode%0Aversion:%2012.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
`feedback <https://github.com/OCA/contract/issues/new?body=module:%20contract_payment_mode%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.
@@ -78,6 +78,7 @@ Contributors
* Vicent Cubells <vicent.cubells@tecnativa.com>
* David Vidal <david.vidal@tecnativa.com>
* Carlos Dauden <carlos.dauden@tecnativa.com>
* Guillermo Llinares <guillermo@studio73.es>
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 <https://github.com/OCA/contract/tree/12.0/contract_payment_mode>`_ project on GitHub.
This module is part of the `OCA/contract <https://github.com/OCA/contract/tree/13.0/contract_payment_mode>`_ project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

View File

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

View File

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

View File

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

View File

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

View File

@@ -3,3 +3,4 @@
* Vicent Cubells <vicent.cubells@tecnativa.com>
* David Vidal <david.vidal@tecnativa.com>
* Carlos Dauden <carlos.dauden@tecnativa.com>
* Guillermo Llinares <guillermo@studio73.es>

View File

@@ -3,7 +3,7 @@
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils 0.15.1: http://docutils.sourceforge.net/" />
<meta name="generator" content="Docutils 0.14: http://docutils.sourceforge.net/" />
<title>Contract Payment Mode</title>
<style type="text/css">
@@ -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/contract/tree/12.0/contract_payment_mode"><img alt="OCA/contract" src="https://img.shields.io/badge/github-OCA%2Fcontract-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/contract-12-0/contract-12-0-contract_payment_mode"><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/110/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/contract/tree/13.0/contract_payment_mode"><img alt="OCA/contract" src="https://img.shields.io/badge/github-OCA%2Fcontract-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/contract-13-0/contract-13-0-contract_payment_mode"><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/110/13.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
<p>This module allows to set a payment mode on contract for creating the invoices
with this payment mode.</p>
<p><strong>Table of contents</strong></p>
@@ -407,7 +407,7 @@ corresponding field.</li>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/contract/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/contract/issues/new?body=module:%20contract_payment_mode%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/contract/issues/new?body=module:%20contract_payment_mode%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">
@@ -427,6 +427,7 @@ If you spotted it first, help us smashing it by providing a detailed and welcome
<li>Vicent Cubells &lt;<a class="reference external" href="mailto:vicent.cubells&#64;tecnativa.com">vicent.cubells&#64;tecnativa.com</a>&gt;</li>
<li>David Vidal &lt;<a class="reference external" href="mailto:david.vidal&#64;tecnativa.com">david.vidal&#64;tecnativa.com</a>&gt;</li>
<li>Carlos Dauden &lt;<a class="reference external" href="mailto:carlos.dauden&#64;tecnativa.com">carlos.dauden&#64;tecnativa.com</a>&gt;</li>
<li>Guillermo Llinares &lt;<a class="reference external" href="mailto:guillermo&#64;studio73.es">guillermo&#64;studio73.es</a>&gt;</li>
</ul>
</div>
<div class="section" id="maintainers">
@@ -436,7 +437,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/contract/tree/12.0/contract_payment_mode">OCA/contract</a> project on GitHub.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/contract/tree/13.0/contract_payment_mode">OCA/contract</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>

View File

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

1
oca_dependencies.txt Normal file
View File

@@ -0,0 +1 @@
bank-payment