mirror of
https://github.com/OCA/contract.git
synced 2025-02-13 17:57:24 +02:00
[MIG] contract_payment_mode: Migration to 17.0
This commit is contained in:
@@ -44,16 +44,15 @@ Your user should be a Sales Manager or Accountant.
|
||||
Usage
|
||||
=====
|
||||
|
||||
1. Go to *Accounting > Sales > Contracts*.
|
||||
1. Go to *Invoicing > Customers > Customer Contracts*.
|
||||
2. Create one.
|
||||
3. Select a partner to which invoice.
|
||||
4. If the partner has a payment mode, this payment mode is selected
|
||||
here.
|
||||
5. If not, or if you want another payment mode, you can change it in the
|
||||
corresponding field.
|
||||
6. Click on **Generate recurring invoices automatically** checkbox.
|
||||
7. Add a product to invoice.
|
||||
8. If you create an invoice, new invoice will have the selected payment
|
||||
6. Add a product to invoice.
|
||||
7. If you create an invoice, new invoice will have the selected payment
|
||||
mode.
|
||||
|
||||
Bug Tracker
|
||||
@@ -86,6 +85,10 @@ Contributors
|
||||
- Guillermo Llinares <guillermo@studio73.es>
|
||||
- Amamr Officewala <aofficewala@opensourceintegrators.com>
|
||||
- Carolina Fernandez <carolina.fernandez@tecnativa.com>
|
||||
- David Jaen david.jaen.revert@gmail.com
|
||||
- Alberto Martínez <alberto.martinez@sygel.es>
|
||||
- Harald Panten <harald.panten@sygel.es>
|
||||
- Valentin Vinagre <valentin.vinagre@sygel.es>
|
||||
|
||||
Maintainers
|
||||
-----------
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
{
|
||||
"name": "Contract Payment Mode",
|
||||
"summary": "Payment mode in contracts and their invoices",
|
||||
"version": "16.0.1.0.0",
|
||||
"version": "17.0.1.0.0",
|
||||
"author": "Domatix, " "Tecnativa, " "Odoo Community Association (OCA)",
|
||||
"website": "https://github.com/OCA/contract",
|
||||
"depends": ["contract", "account_payment_partner"],
|
||||
|
||||
@@ -3,14 +3,11 @@
|
||||
|
||||
import logging
|
||||
|
||||
from odoo import SUPERUSER_ID, api
|
||||
|
||||
_logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def post_init_hook(cr, registry):
|
||||
def post_init_hook(env):
|
||||
"""Copy payment mode from partner to the new field at contract."""
|
||||
env = api.Environment(cr, SUPERUSER_ID, {})
|
||||
m_contract = env["contract.contract"]
|
||||
contracts = m_contract.search([("payment_mode_id", "=", False)])
|
||||
if contracts:
|
||||
|
||||
@@ -9,15 +9,19 @@ class ContractContract(models.Model):
|
||||
string="Payment Mode",
|
||||
domain=[("payment_type", "=", "inbound")],
|
||||
index=True,
|
||||
compute="_compute_payment_mode_id",
|
||||
store=True,
|
||||
readonly=False,
|
||||
)
|
||||
|
||||
@api.onchange("partner_id")
|
||||
def on_change_partner_id(self):
|
||||
partner = self.with_company(self.company_id).partner_id
|
||||
if self.contract_type == "purchase":
|
||||
self.payment_mode_id = partner.supplier_payment_mode_id.id
|
||||
else:
|
||||
self.payment_mode_id = partner.customer_payment_mode_id.id
|
||||
@api.depends("partner_id", "contract_type")
|
||||
def _compute_payment_mode_id(self):
|
||||
for rec in self:
|
||||
partner = rec.with_company(rec.company_id).partner_id
|
||||
if rec.contract_type == "purchase":
|
||||
rec.payment_mode_id = partner.supplier_payment_mode_id.id
|
||||
else:
|
||||
rec.payment_mode_id = partner.customer_payment_mode_id.id
|
||||
|
||||
def _prepare_invoice(self, date_invoice, journal=None):
|
||||
invoice_vals = super()._prepare_invoice(
|
||||
|
||||
@@ -6,3 +6,7 @@
|
||||
- Guillermo Llinares \<<guillermo@studio73.es>\>
|
||||
- Amamr Officewala \<<aofficewala@opensourceintegrators.com>\>
|
||||
- Carolina Fernandez \<<carolina.fernandez@tecnativa.com>\>
|
||||
- David Jaen <david.jaen.revert@gmail.com>
|
||||
- Alberto Martínez \<<alberto.martinez@sygel.es>\>
|
||||
- Harald Panten \<<harald.panten@sygel.es>\>
|
||||
- Valentin Vinagre \<<valentin.vinagre@sygel.es>\>
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
1. Go to *Accounting \> Sales \> Contracts*.
|
||||
1. Go to *Invoicing \> Customers \> Customer Contracts*.
|
||||
2. Create one.
|
||||
3. Select a partner to which invoice.
|
||||
4. If the partner has a payment mode, this payment mode is selected
|
||||
here.
|
||||
5. If not, or if you want another payment mode, you can change it in
|
||||
the corresponding field.
|
||||
6. Click on **Generate recurring invoices automatically** checkbox.
|
||||
7. Add a product to invoice.
|
||||
8. If you create an invoice, new invoice will have the selected payment
|
||||
6. Add a product to invoice.
|
||||
7. If you create an invoice, new invoice will have the selected payment
|
||||
mode.
|
||||
|
||||
@@ -393,14 +393,13 @@ invoices with this payment mode.</p>
|
||||
<div class="section" id="usage">
|
||||
<h1><a class="toc-backref" href="#toc-entry-2">Usage</a></h1>
|
||||
<ol class="arabic simple">
|
||||
<li>Go to <em>Accounting > Sales > Contracts</em>.</li>
|
||||
<li>Go to <em>Invoicing > Customers > Customer Contracts</em>.</li>
|
||||
<li>Create one.</li>
|
||||
<li>Select a partner to which invoice.</li>
|
||||
<li>If the partner has a payment mode, this payment mode is selected
|
||||
here.</li>
|
||||
<li>If not, or if you want another payment mode, you can change it in the
|
||||
corresponding field.</li>
|
||||
<li>Click on <strong>Generate recurring invoices automatically</strong> checkbox.</li>
|
||||
<li>Add a product to invoice.</li>
|
||||
<li>If you create an invoice, new invoice will have the selected payment
|
||||
mode.</li>
|
||||
@@ -434,6 +433,10 @@ If you spotted it first, help us to smash it by providing a detailed and welcome
|
||||
<li>Guillermo Llinares <<a class="reference external" href="mailto:guillermo@studio73.es">guillermo@studio73.es</a>></li>
|
||||
<li>Amamr Officewala <<a class="reference external" href="mailto:aofficewala@opensourceintegrators.com">aofficewala@opensourceintegrators.com</a>></li>
|
||||
<li>Carolina Fernandez <<a class="reference external" href="mailto:carolina.fernandez@tecnativa.com">carolina.fernandez@tecnativa.com</a>></li>
|
||||
<li>David Jaen <a class="reference external" href="mailto:david.jaen.revert@gmail.com">david.jaen.revert@gmail.com</a></li>
|
||||
<li>Alberto Martínez <<a class="reference external" href="mailto:alberto.martinez@sygel.es">alberto.martinez@sygel.es</a>></li>
|
||||
<li>Harald Panten <<a class="reference external" href="mailto:harald.panten@sygel.es">harald.panten@sygel.es</a>></li>
|
||||
<li>Valentin Vinagre <<a class="reference external" href="mailto:valentin.vinagre@sygel.es">valentin.vinagre@sygel.es</a>></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="section" id="maintainers">
|
||||
|
||||
@@ -6,8 +6,7 @@
|
||||
|
||||
from unittest.mock import patch
|
||||
|
||||
import odoo.tests
|
||||
from odoo.tests import tagged
|
||||
from odoo.tests import common, tagged
|
||||
|
||||
from odoo.addons.account.models.account_payment_method import AccountPaymentMethod
|
||||
|
||||
@@ -15,7 +14,7 @@ from ..hooks import post_init_hook
|
||||
|
||||
|
||||
@tagged("post_install", "-at_install")
|
||||
class TestContractPaymentInit(odoo.tests.HttpCase):
|
||||
class TestContractPaymentInit(common.TransactionCase):
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
super().setUpClass()
|
||||
@@ -91,12 +90,11 @@ class TestContractPaymentInit(odoo.tests.HttpCase):
|
||||
contract.payment_mode_id = False
|
||||
self.assertEqual(contract.payment_mode_id.id, False)
|
||||
|
||||
post_init_hook(self.cr, self.env)
|
||||
post_init_hook(self.env)
|
||||
self.assertEqual(contract.payment_mode_id, self.payment_mode)
|
||||
|
||||
def test_contract_and_invoices(self):
|
||||
self.contract.write({"partner_id": self.partner.id})
|
||||
self.contract.on_change_partner_id()
|
||||
self.assertEqual(
|
||||
self.contract.payment_mode_id,
|
||||
self.contract.partner_id.customer_payment_mode_id,
|
||||
|
||||
Reference in New Issue
Block a user