Browse Source

[ADD] [8.0] contract_account_banking_mandate (#38)

pull/41/head
elacunza 8 years ago
committed by Pedro M. Baeza
parent
commit
4a1b55d617
  1. 39
      contract_account_banking_mandate/README.rst
  2. 4
      contract_account_banking_mandate/__init__.py
  3. 22
      contract_account_banking_mandate/__openerp__.py
  4. 23
      contract_account_banking_mandate/i18n/es.po
  5. 4
      contract_account_banking_mandate/models/__init__.py
  6. 20
      contract_account_banking_mandate/models/account_analytic_account.py
  7. 68
      contract_account_banking_mandate/tests/contract_account_banking_mandate.yml
  8. 19
      contract_account_banking_mandate/views/contract_view.xml

39
contract_account_banking_mandate/README.rst

@ -0,0 +1,39 @@
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
================================
Contract Account Banking Mandate
================================
This module adds an account banking mandate field to contracts. This is used
for the creation of recurring invoices.
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
`here <https://github.com/OCA/contract/issues/new?body=module:%20contract_account_banking_mandate%0Aversion:%208.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
Credits
=======
Contributors
------------
* Eneko Lacunza (Binovo)
Maintainer
----------
.. image:: http://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: http://odoo-community.org
This module is maintained by the OCA.
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.
To contribute to this module, please visit http://odoo-community.org.

4
contract_account_banking_mandate/__init__.py

@ -0,0 +1,4 @@
# -*- coding: utf-8 -*-
# Copyright 2016 Binovo IT Human Project SL
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from . import models

22
contract_account_banking_mandate/__openerp__.py

@ -0,0 +1,22 @@
# -*- coding: utf-8 -*-
# Copyright 2016 Binovo IT Human Project SL
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
{
"name": "Contract Account Banking Mandate",
"version": "8.0.1.0.0",
"depends": [
"account_analytic_analysis", "account_banking_mandate"
],
"author": "Binovo IT Human Project SL, Odoo Community Association (OCA)",
"category": 'Sales Management',
"website": "http://www.binovo.es",
"summary": "Add banking mandate field to contracts for their invoices",
"data": [
"views/contract_view.xml",
],
"test": [
"tests/contract_account_banking_mandate.yml"
],
"installable": True,
"auto_install": False,
}

23
contract_account_banking_mandate/i18n/es.po

@ -0,0 +1,23 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * account_banking_mandate
#
# Translators:
msgid ""
msgstr ""
"Project-Id-Version: bank-payment (8.0)\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2016-04-08 00:46+0000\n"
"PO-Revision-Date: 2016-04-07 16:04+0000\n"
"Last-Translator: OCA Transbot <transbot@odoo-community.org>\n"
"Language-Team: Spanish (http://www.transifex.com/oca/OCA-bank-payment-8-0/language/es/)\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Language: es\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
#. module: contract_account_banking_mandate
#: field:account.analytic.account,mandate_id:0
msgid "Direct Debit Mandate"
msgstr "Mandato de adeudo directo"

4
contract_account_banking_mandate/models/__init__.py

@ -0,0 +1,4 @@
# -*- coding: utf-8 -*-
# Copyright 2016 Binovo IT Human Project SL
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from . import account_analytic_account

20
contract_account_banking_mandate/models/account_analytic_account.py

@ -0,0 +1,20 @@
# -*- coding: utf-8 -*-
# Copyright 2016 Binovo IT Human Project SL
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
from openerp import models, fields, api
class AccountAnalyticAccount(models.Model):
_inherit = 'account.analytic.account'
mandate_id = fields.Many2one(
'account.banking.mandate', string='Direct Debit Mandate',
domain=[('state', '=', 'valid')])
@api.model
def _prepare_invoice_data(self, contract):
invoice_vals = super(AccountAnalyticAccount, self).\
_prepare_invoice_data(contract)
if contract.mandate_id:
invoice_vals['mandate_id'] = contract.mandate_id.id
return invoice_vals

68
contract_account_banking_mandate/tests/contract_account_banking_mandate.yml

@ -0,0 +1,68 @@
-
In order to test mandates in contracts, create a partner with a bank account.
Then, create two mandates, and validate them.
Finally, create a contract with mandate2, create a recurring invoice and
check that the invoice has set the contract mandate (mandate2).
Create a partner
-
!record {model: res.partner, id: test_partner, view: False}:
name: "Contract mandate test"
-
Create a partner bank account
-
!record {model: res.partner.bank, id: test_partner_bank, view: False}:
state: 'bank'
acc_number: '1234'
partner_id: test_partner
-
Create mandate1 on 1st January
-
!record {model: account.banking.mandate, id: test_mandate1, view: False}:
partner_bank_id: test_partner_bank
signature_date: "2014-01-01"
-
Create mandate2 on 15th February
-
!record {model: account.banking.mandate, id: test_mandate2, view: False}:
partner_bank_id: test_partner_bank
signature_date: "2015-02-15"
-
Validate both mandates
-
!python {model: account.banking.mandate}: |
self.validate(cr, uid, [ref('test_mandate1')])
self.validate(cr, uid, [ref('test_mandate2')])
-
Create new contract with a mandate2
-
!record {model: account.analytic.account, id: test_contract}:
name: Recurring with mandate
company_id: base.main_company
partner_id: base.main_partner
type: contract
recurring_invoices : 1
recurring_interval : 1
recurring_rule_type: 'monthly'
recurring_next_date: '2016-02-29'
recurring_invoice_line_ids:
- quantity: 2.0
price_unit: 100.0
name: Database Administration 25
product_id: product.product_product_consultant
uom_id: product.product_uom_hour
mandate_id: test_mandate2
-
Generate all invoices from contracts having recurring invoicing
-
!python {model: account.analytic.account}: |
self.recurring_create_invoice(cr, uid, [])
-
Check created invoice has mandate2
-
!python {model: account.invoice}: |
aid = ref('test_contract')
ids = self.search(cr, uid, [('invoice_line.account_analytic_id','=',aid)], context=context)
assert len(ids) == 1, "Expected exactly one invoice created for the contract, got %d"%(len(ids))
for invoice in self.browse(cr, uid, ids,context=context):
assert invoice.mandate_id.id == ref('test_mandate2'), "Recurring invoice has mandate id %d, but should have mandate id %d"%(invoice.mandate_id.id, ref('test_mandate2'))

19
contract_account_banking_mandate/views/contract_view.xml

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright 2016 Binovo IT Human Project SL
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -->
<openerp>
<data>
<record id="account_analytic_account_form_form_mandate" model="ir.ui.view">
<field name="name">account.analytic.account.form.form.mandate</field>
<field name="model">account.analytic.account</field>
<field name="inherit_id"
ref="account_analytic_analysis.account_analytic_account_form_form" />
<field name="arch" type="xml">
<field name="recurring_next_date" position="after">
<field name="mandate_id" domain="[('partner_id', '=', partner_id), ('state', '=', 'valid')]"/>
</field>
</field>
</record>
</data>
</openerp>
Loading…
Cancel
Save