[MIG][16.0] contract_mandate

This commit is contained in:
Adrià Pallejà
2024-05-13 20:01:05 +02:00
parent 0671cfb203
commit 704a58ba1c
6 changed files with 23 additions and 17 deletions

View File

@@ -7,7 +7,7 @@ Contract Mandate
!! 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. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:a83455161d4bb4363ea205049514708dda57ac56a8f4b1ae35ea6c0da45c788b !! source digest: sha256:720c5d6130934b9fb77aedd2189daf8a9bc219ccc94df720cecd72bb4a84b2a3
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png .. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
@@ -39,11 +39,11 @@ with this mandate.
Usage Usage
===== =====
#. Go to *Sales > Sales > Contracts*. #. Go to *Sales > Orders > Contracts*.
#. Create one. #. Create one.
#. Select a partner to which invoice. #. Select a partner to which invoice.
#. Select a mandate. #. Select a mandate.
#. Click on **Generate recurring invoices automatically** checkbox. #. Add invoice recurrency information.
#. Add a product to invoice. #. Add a product to invoice.
#. If you create an invoice, new invoice will have the selected mandate. #. If you create an invoice, new invoice will have the selected mandate.

View File

@@ -32,9 +32,7 @@ class ContractContract(models.Model):
self.mandate_id = False self.mandate_id = False
def _prepare_invoice(self, date_invoice, journal=None): def _prepare_invoice(self, date_invoice, journal=None):
invoice_vals, move_form = super()._prepare_invoice( invoice_vals = super()._prepare_invoice(date_invoice, journal=journal)
date_invoice, journal=journal
)
if self.mandate_id: if self.mandate_id:
invoice_vals["mandate_id"] = self.mandate_id.id invoice_vals["mandate_id"] = self.mandate_id.id
elif self.payment_mode_id.payment_method_id.mandate_required: elif self.payment_mode_id.payment_method_id.mandate_required:
@@ -47,4 +45,4 @@ class ContractContract(models.Model):
limit=1, limit=1,
) )
invoice_vals["mandate_id"] = mandate.id invoice_vals["mandate_id"] = mandate.id
return invoice_vals, move_form return invoice_vals

View File

@@ -1,7 +1,7 @@
#. Go to *Sales > Sales > Contracts*. #. Go to *Sales > Orders > Contracts*.
#. Create one. #. Create one.
#. Select a partner to which invoice. #. Select a partner to which invoice.
#. Select a mandate. #. Select a mandate.
#. Click on **Generate recurring invoices automatically** checkbox. #. Add invoice recurrency information.
#. Add a product to invoice. #. Add a product to invoice.
#. If you create an invoice, new invoice will have the selected mandate. #. If you create an invoice, new invoice will have the selected mandate.

View File

@@ -1,4 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<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>
@@ -9,10 +8,11 @@
/* /*
:Author: David Goodger (goodger@python.org) :Author: David Goodger (goodger@python.org)
:Id: $Id: html4css1.css 8954 2022-01-20 10:10:25Z milde $ :Id: $Id: html4css1.css 9511 2024-01-13 09:50:07Z milde $
:Copyright: This stylesheet has been placed in the public domain. :Copyright: This stylesheet has been placed in the public domain.
Default cascading style sheet for the HTML output of Docutils. Default cascading style sheet for the HTML output of Docutils.
Despite the name, some widely supported CSS2 features are used.
See https://docutils.sourceforge.io/docs/howto/html-stylesheets.html for how to See https://docutils.sourceforge.io/docs/howto/html-stylesheets.html for how to
customize this style sheet. customize this style sheet.
@@ -275,7 +275,7 @@ pre.literal-block, pre.doctest-block, pre.math, pre.code {
margin-left: 2em ; margin-left: 2em ;
margin-right: 2em } margin-right: 2em }
pre.code .ln { color: grey; } /* line numbers */ pre.code .ln { color: gray; } /* line numbers */
pre.code, code { background-color: #eeeeee } pre.code, code { background-color: #eeeeee }
pre.code .comment, code .comment { color: #5C6576 } pre.code .comment, code .comment { color: #5C6576 }
pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold } pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold }
@@ -301,7 +301,7 @@ span.option {
span.pre { span.pre {
white-space: pre } white-space: pre }
span.problematic { span.problematic, pre.problematic {
color: red } color: red }
span.section-subtitle { span.section-subtitle {
@@ -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. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:a83455161d4bb4363ea205049514708dda57ac56a8f4b1ae35ea6c0da45c788b !! source digest: sha256:720c5d6130934b9fb77aedd2189daf8a9bc219ccc94df720cecd72bb4a84b2a3
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! --> !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external image-reference" 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 image-reference" 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 image-reference" href="https://github.com/OCA/contract/tree/16.0/contract_mandate"><img alt="OCA/contract" src="https://img.shields.io/badge/github-OCA%2Fcontract-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/contract-16-0/contract-16-0-contract_mandate"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/contract&amp;target_branch=16.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p> <p><a class="reference external image-reference" 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 image-reference" 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 image-reference" href="https://github.com/OCA/contract/tree/16.0/contract_mandate"><img alt="OCA/contract" src="https://img.shields.io/badge/github-OCA%2Fcontract-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/contract-16-0/contract-16-0-contract_mandate"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/contract&amp;target_branch=16.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p>This module allows to set a mandate mode on contract for creating the invoices <p>This module allows to set a mandate mode on contract for creating the invoices
@@ -388,11 +388,11 @@ with this mandate.</p>
<div class="section" id="usage"> <div class="section" id="usage">
<h1><a class="toc-backref" href="#toc-entry-1">Usage</a></h1> <h1><a class="toc-backref" href="#toc-entry-1">Usage</a></h1>
<ol class="arabic simple"> <ol class="arabic simple">
<li>Go to <em>Sales &gt; Sales &gt; Contracts</em>.</li> <li>Go to <em>Sales &gt; Orders &gt; Contracts</em>.</li>
<li>Create one.</li> <li>Create one.</li>
<li>Select a partner to which invoice.</li> <li>Select a partner to which invoice.</li>
<li>Select a mandate.</li> <li>Select a mandate.</li>
<li>Click on <strong>Generate recurring invoices automatically</strong> checkbox.</li> <li>Add invoice recurrency information.</li>
<li>Add a product to invoice.</li> <li>Add a product to invoice.</li>
<li>If you create an invoice, new invoice will have the selected mandate.</li> <li>If you create an invoice, new invoice will have the selected mandate.</li>
</ol> </ol>
@@ -425,7 +425,9 @@ If you spotted it first, help us to smash it by providing a detailed and welcome
<div class="section" id="maintainers"> <div class="section" id="maintainers">
<h2><a class="toc-backref" href="#toc-entry-6">Maintainers</a></h2> <h2><a class="toc-backref" href="#toc-entry-6">Maintainers</a></h2>
<p>This module is maintained by the OCA.</p> <p>This module is maintained by the OCA.</p>
<a class="reference external image-reference" href="https://odoo-community.org"><img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" /></a> <a class="reference external image-reference" href="https://odoo-community.org">
<img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" />
</a>
<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>

View File

@@ -56,6 +56,11 @@ class TestContractMandate(TestContractBase):
new_invoice = self.contract_with_mandate.recurring_create_invoice() new_invoice = self.contract_with_mandate.recurring_create_invoice()
self.assertEqual(new_invoice.mandate_id, self.mandate2) self.assertEqual(new_invoice.mandate_id, self.mandate2)
def test_onchange_payment_mode_id(self):
self.contract_with_mandate.mandate_required = False
self.contract_with_mandate._onchange_payment_mode_id()
self.assertFalse(self.contract_with_mandate.mandate_id)
def test_contract_mandate_default(self): def test_contract_mandate_default(self):
self.payment_mode.payment_method_id.mandate_required = False self.payment_mode.payment_method_id.mandate_required = False
self.contract_with_mandate.mandate_id = False self.contract_with_mandate.mandate_id = False

View File

@@ -10,6 +10,7 @@
/> />
<field name="arch" type="xml"> <field name="arch" type="xml">
<field name="payment_mode_id" position="after"> <field name="payment_mode_id" position="after">
<field name="company_id" invisible="1" />
<field <field
name="mandate_id" name="mandate_id"
domain="[('partner_id', '=', commercial_partner_id), ('state', '=', 'valid'), ('company_id', '=', company_id)]" domain="[('partner_id', '=', commercial_partner_id), ('state', '=', 'valid'), ('company_id', '=', company_id)]"