mirror of
https://github.com/OCA/contract.git
synced 2025-02-13 17:57:24 +02:00
[MIG] contract_payment_mode: Migration to 13.0
This commit is contained in:
@@ -14,13 +14,13 @@ Contract Payment Mode
|
|||||||
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
|
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
|
||||||
:alt: License: AGPL-3
|
:alt: License: AGPL-3
|
||||||
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fcontract-lightgray.png?logo=github
|
.. |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
|
:alt: OCA/contract
|
||||||
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
|
.. |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
|
:alt: Translate me on Weblate
|
||||||
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
|
.. |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
|
:alt: Try me on Runbot
|
||||||
|
|
||||||
|badge1| |badge2| |badge3| |badge4| |badge5|
|
|badge1| |badge2| |badge3| |badge4| |badge5|
|
||||||
@@ -57,7 +57,7 @@ Bug Tracker
|
|||||||
Bugs are tracked on `GitHub Issues <https://github.com/OCA/contract/issues>`_.
|
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.
|
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
|
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.
|
Do not contact contributors directly about support or help with technical issues.
|
||||||
|
|
||||||
@@ -78,6 +78,7 @@ Contributors
|
|||||||
* Vicent Cubells <vicent.cubells@tecnativa.com>
|
* Vicent Cubells <vicent.cubells@tecnativa.com>
|
||||||
* David Vidal <david.vidal@tecnativa.com>
|
* David Vidal <david.vidal@tecnativa.com>
|
||||||
* Carlos Dauden <carlos.dauden@tecnativa.com>
|
* Carlos Dauden <carlos.dauden@tecnativa.com>
|
||||||
|
* Guillermo Llinares <guillermo@studio73.es>
|
||||||
|
|
||||||
Maintainers
|
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
|
mission is to support the collaborative development of Odoo features and
|
||||||
promote its widespread use.
|
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.
|
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
|
||||||
|
|||||||
@@ -8,13 +8,13 @@
|
|||||||
{
|
{
|
||||||
"name": "Contract Payment Mode",
|
"name": "Contract Payment Mode",
|
||||||
"summary": "Payment mode in contracts and their invoices",
|
"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)",
|
"author": "Domatix, " "Tecnativa, " "Odoo Community Association (OCA)",
|
||||||
"website": "https://github.com/OCA/contract",
|
"website": "https://github.com/OCA/contract",
|
||||||
"depends": ["contract", "account_payment_partner"],
|
"depends": ["contract", "account_payment_partner"],
|
||||||
"category": "Sales Management",
|
"category": "Sales Management",
|
||||||
"license": "AGPL-3",
|
"license": "AGPL-3",
|
||||||
"data": ["views/contract_view.xml",],
|
"data": ["views/contract_view.xml"],
|
||||||
"post_init_hook": "post_init_hook",
|
"post_init_hook": "post_init_hook",
|
||||||
"installable": True,
|
"installable": True,
|
||||||
"auto_install": True,
|
"auto_install": True,
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ def post_init_hook(cr, registry):
|
|||||||
with api.Environment.manage():
|
with api.Environment.manage():
|
||||||
env = api.Environment(cr, SUPERUSER_ID, {})
|
env = api.Environment(cr, SUPERUSER_ID, {})
|
||||||
m_contract = env["contract.contract"]
|
m_contract = env["contract.contract"]
|
||||||
contracts = m_contract.search([("payment_mode_id", "=", False),])
|
contracts = m_contract.search([("payment_mode_id", "=", False)])
|
||||||
if contracts:
|
if contracts:
|
||||||
_logger.info("Setting payment mode: %d contracts" % len(contracts))
|
_logger.info("Setting payment mode: %d contracts" % len(contracts))
|
||||||
for contract in contracts:
|
for contract in contracts:
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
#
|
#
|
||||||
msgid ""
|
msgid ""
|
||||||
msgstr ""
|
msgstr ""
|
||||||
"Project-Id-Version: Odoo Server 12.0\n"
|
"Project-Id-Version: Odoo Server 13.0\n"
|
||||||
"Report-Msgid-Bugs-To: \n"
|
"Report-Msgid-Bugs-To: \n"
|
||||||
"Last-Translator: <>\n"
|
"Last-Translator: <>\n"
|
||||||
"Language-Team: \n"
|
"Language-Team: \n"
|
||||||
|
|||||||
@@ -15,28 +15,10 @@ class ContractContract(models.Model):
|
|||||||
def on_change_partner_id(self):
|
def on_change_partner_id(self):
|
||||||
self.payment_mode_id = self.partner_id.customer_payment_mode_id.id
|
self.payment_mode_id = self.partner_id.customer_payment_mode_id.id
|
||||||
|
|
||||||
@api.multi
|
|
||||||
def _prepare_invoice(self, date_invoice, journal=None):
|
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
|
date_invoice=date_invoice, journal=journal
|
||||||
)
|
)
|
||||||
if self.payment_mode_id:
|
if self.payment_mode_id:
|
||||||
invoice_vals["payment_mode_id"] = self.payment_mode_id.id
|
invoice_vals["payment_mode_id"] = self.payment_mode_id.id
|
||||||
invoice = self.env["account.invoice"].new(invoice_vals)
|
return invoice_vals, move_form
|
||||||
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
|
|
||||||
|
|||||||
@@ -3,3 +3,4 @@
|
|||||||
* Vicent Cubells <vicent.cubells@tecnativa.com>
|
* Vicent Cubells <vicent.cubells@tecnativa.com>
|
||||||
* David Vidal <david.vidal@tecnativa.com>
|
* David Vidal <david.vidal@tecnativa.com>
|
||||||
* Carlos Dauden <carlos.dauden@tecnativa.com>
|
* Carlos Dauden <carlos.dauden@tecnativa.com>
|
||||||
|
* Guillermo Llinares <guillermo@studio73.es>
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||||
<head>
|
<head>
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
<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>
|
<title>Contract Payment Mode</title>
|
||||||
<style type="text/css">
|
<style type="text/css">
|
||||||
|
|
||||||
@@ -367,7 +367,7 @@ ul.auto-toc {
|
|||||||
!! This file is generated by oca-gen-addon-readme !!
|
!! This file is generated by oca-gen-addon-readme !!
|
||||||
!! changes will be overwritten. !!
|
!! 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
|
<p>This module allows to set a payment mode on contract for creating the invoices
|
||||||
with this payment mode.</p>
|
with this payment mode.</p>
|
||||||
<p><strong>Table of contents</strong></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>.
|
<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.
|
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
|
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>
|
<p>Do not contact contributors directly about support or help with technical issues.</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="section" id="credits">
|
<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 <<a class="reference external" href="mailto:vicent.cubells@tecnativa.com">vicent.cubells@tecnativa.com</a>></li>
|
<li>Vicent Cubells <<a class="reference external" href="mailto:vicent.cubells@tecnativa.com">vicent.cubells@tecnativa.com</a>></li>
|
||||||
<li>David Vidal <<a class="reference external" href="mailto:david.vidal@tecnativa.com">david.vidal@tecnativa.com</a>></li>
|
<li>David Vidal <<a class="reference external" href="mailto:david.vidal@tecnativa.com">david.vidal@tecnativa.com</a>></li>
|
||||||
<li>Carlos Dauden <<a class="reference external" href="mailto:carlos.dauden@tecnativa.com">carlos.dauden@tecnativa.com</a>></li>
|
<li>Carlos Dauden <<a class="reference external" href="mailto:carlos.dauden@tecnativa.com">carlos.dauden@tecnativa.com</a>></li>
|
||||||
|
<li>Guillermo Llinares <<a class="reference external" href="mailto:guillermo@studio73.es">guillermo@studio73.es</a>></li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
<div class="section" id="maintainers">
|
<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
|
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose
|
||||||
mission is to support the collaborative development of Odoo features and
|
mission is to support the collaborative development of Odoo features and
|
||||||
promote its widespread use.</p>
|
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>
|
<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>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -12,10 +12,10 @@ from ..hooks import post_init_hook
|
|||||||
@odoo.tests.at_install(False)
|
@odoo.tests.at_install(False)
|
||||||
class TestContractPaymentInit(odoo.tests.HttpCase):
|
class TestContractPaymentInit(odoo.tests.HttpCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(TestContractPaymentInit, self).setUp()
|
super().setUp()
|
||||||
|
|
||||||
self.payment_method = self.env["account.payment.method"].create(
|
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(
|
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(
|
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")
|
company = self.env.ref("base.main_company")
|
||||||
self.journal = self.env["account.journal"].create(
|
self.journal = self.env["account.journal"].create(
|
||||||
@@ -78,6 +78,11 @@ class TestContractPaymentInit(odoo.tests.HttpCase):
|
|||||||
)
|
)
|
||||||
self.contract.write(
|
self.contract.write(
|
||||||
{
|
{
|
||||||
|
"line_recurrence": True,
|
||||||
|
"contract_type": "sale",
|
||||||
|
"recurring_interval": 1,
|
||||||
|
"recurring_rule_type": "monthly",
|
||||||
|
"date_start": "2018-01-15",
|
||||||
"contract_line_ids": [
|
"contract_line_ids": [
|
||||||
(
|
(
|
||||||
0,
|
0,
|
||||||
@@ -88,14 +93,9 @@ class TestContractPaymentInit(odoo.tests.HttpCase):
|
|||||||
"quantity": 2.0,
|
"quantity": 2.0,
|
||||||
"uom_id": self.product.uom_id.id,
|
"uom_id": self.product.uom_id.id,
|
||||||
"price_unit": 200.0,
|
"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()
|
self.contract.recurring_create_invoice()
|
||||||
|
|||||||
Reference in New Issue
Block a user