Remane import modules

pull/283/head
Matthieu Dietrich 2016-05-24 11:51:51 +02:00 committed by OCA-git-bot
parent 6de694cee0
commit 94b0714869
9 changed files with 265 additions and 0 deletions

View File

@ -0,0 +1,55 @@
.. 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
====================================
Bank statement Sale Order completion
====================================
This module extends the functionality of account_statement_base_import
to add support for completion rules based on Sale Orders. This was initially
part of the module account_statement_base_completion, but is now separate to
keep dependencies separate.
.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
:alt: Try me on Runbot
:target: https://runbot.odoo-community.org/runbot/98/9.0
Bug Tracker
===========
Bugs are tracked on `GitHub Issues
<https://github.com/OCA/bank-statement-reconcile/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.
Credits
=======
Images
------
* Odoo Community Association: `Icon <https://github.com/OCA/maintainer-tools/blob/master/template/module/static/description/icon.svg>`_.
Contributors
------------
* Joël Grand-Guillaume <joel.grandguillaume@camptocamp.com>
* Leonardo Pistone <leonardo.pistone@camptocamp.com>
* Matthieu Dietrich <matthieu.dietrich@camptocamp.com>
Maintainer
----------
.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://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 https://odoo-community.org.

View File

@ -0,0 +1,4 @@
# -*- coding: utf-8 -*-
# © 2011-2016 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)
from . import models

View File

@ -0,0 +1,22 @@
# -*- coding: utf-8 -*-
# © 2011-2016 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)
{
'name': "Bank statement Sale Order completion",
'version': '9.0.1.0.0',
'author': "Camptocamp,Odoo Community Association (OCA)",
'maintainer': 'Camptocamp',
'category': 'Finance',
'complexity': 'easy',
'depends': ['account_move_base_import', 'sale'],
'website': 'http://www.camptocamp.com',
'data': [
'data/completion_rule_data.xml',
],
'test': [
'test/completion_so_test.yml'],
'installable': True,
'images': [],
'auto_install': False,
'license': 'AGPL-3',
}

View File

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo noupdate="1">
<record id="bank_statement_completion_rule_1" model="account.move.completion.rule">
<field name="name">Match from line name (based on SO number)</field>
<field name="sequence">50</field>
<field name="function_to_call">get_from_name_and_so</field>
</record>
</odoo>

View File

@ -0,0 +1,28 @@
# Translation of OpenERP Server.
# This file contains the translation of the following modules:
# * account_statement_so_completion
#
msgid ""
msgstr ""
"Project-Id-Version: OpenERP Server 7.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2014-01-21 12:04+0000\n"
"PO-Revision-Date: 2014-01-21 12:04+0000\n"
"Last-Translator: <>\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"
#. module: account_statement_so_completion
#: code:addons/account_statement_so_completion/statement.py:77
#, python-format
msgid "Line named \"%s\" (Ref:%s) was matched by more than one partner while looking on SO by ref."
msgstr ""
#. module: account_statement_so_completion
#: model:ir.model,name:account_statement_so_completion.model_account_statement_completion_rule
msgid "account.statement.completion.rule"
msgstr ""

View File

@ -0,0 +1,33 @@
# Spanish translation for banking-addons
# Copyright (c) 2014 Rosetta Contributors and Canonical Ltd 2014
# This file is distributed under the same license as the banking-addons package.
# FIRST AUTHOR <EMAIL@ADDRESS>, 2014.
#
msgid ""
msgstr ""
"Project-Id-Version: banking-addons\n"
"Report-Msgid-Bugs-To: FULL NAME <EMAIL@ADDRESS>\n"
"POT-Creation-Date: 2014-01-21 12:04+0000\n"
"PO-Revision-Date: 2014-06-05 22:41+0000\n"
"Last-Translator: Pedro Manuel Baeza <pedro.baeza@gmail.com>\n"
"Language-Team: Spanish <es@li.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Launchpad-Export-Date: 2014-06-06 06:36+0000\n"
"X-Generator: Launchpad (build 17031)\n"
#. module: account_statement_so_completion
#: code:addons/account_statement_so_completion/statement.py:77
#, python-format
msgid ""
"Line named \"%s\" (Ref:%s) was matched by more than one partner while "
"looking on SO by ref."
msgstr ""
"La línea llamada \"%s\" (Ref: %s) se casó con más de una empresa al buscar "
"por referencia de pedido."
#. module: account_statement_so_completion
#: model:ir.model,name:account_statement_so_completion.model_account_statement_completion_rule
msgid "account.statement.completion.rule"
msgstr "account.statement.completion.rule"

View File

@ -0,0 +1,4 @@
# -*- coding: utf-8 -*-
# © 2011-2016 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)
from . import account_move

View File

@ -0,0 +1,50 @@
# -*- coding: utf-8 -*-
# © 2011-2016 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)
from openerp import _, models
from openerp.addons.account_move_base_import.models.account_move \
import ErrorTooManyPartner
class AccountMoveCompletionRule(models.Model):
_name = "account.move.completion.rule"
_inherit = "account.move.completion.rule"
def _get_functions(self):
res = super(AccountMoveCompletionRule, self)._get_functions()
res.append(
('get_from_name_and_so', 'From line name (based on SO number)')
)
return res
# Should be private but data are initialised with no update XML
def get_from_name_and_so(self, line):
"""
Match the partner based on the SO number and the reference of the
statement line. Then, call the generic get_values_for_line method to
complete other values. If more than one partner matched, raise the
ErrorTooManyPartner error.
:param int/long st_line: read of the concerned
account.bank.statement.line
:return:
A dict of value that can be passed directly to the write method of
the statement line or {}
{'partner_id': value,
'account_id': value,
...}
"""
res = {}
so_obj = self.env['sale.order']
orders = so_obj.search([('name', '=', line.name)])
if len(orders) > 1:
raise ErrorTooManyPartner(
_('Line named "%s" was matched by more '
'than one partner while looking on SO by ref.') %
line.name)
if len(orders) == 1:
res['partner_id'] = orders[0].partner_id.id
return res

View File

@ -0,0 +1,59 @@
-
I import account minimal data
-
!python {model: account.invoice}: |
openerp.tools.convert_file(cr,
'account',
openerp.modules.get_module_resource(
'account',
'test',
'account_minimal_test.xml'),
{}, 'init', False, 'test')
-
In order to test the banking framework for Sale Orders, I first need to
create a profile
-
!record {model: account.journal, id: account.bank_journal}:
used_for_completion: True
rule_ids:
- account_statement_base_import.bank_statement_completion_rule_4
- account_statement_base_import.bank_statement_completion_rule_5
- account_statement_base_import.bank_statement_completion_rule_2
- account_statement_base_import.bank_statement_completion_rule_3
- bank_statement_completion_rule_1
-
Now I create a statement. I create statment lines separately because I need
to find each one by XML id
-
!record {model: account.move, id: move_test_sale1}:
name: Statement for SO
journal_id: account.bank_journal
company_id: base.main_company
-
I create a move line for a SO
-
!record {model: account.move.line, id: move_line_so}:
name: SO007
account_id: account.a_sale
move_id: move_test_sale1
date_maturity: '2013-12-20'
credit: 0.0
-
and add the correct name
-
!python {model: account.move.line}: |
context['check_move_validity'] = False
model.write(cr, uid, [ref('move_line_so')],
{'credit': 14981.0},
context)
-
I run the auto complete
-
!python {model: account.move}: |
result = self.button_auto_completion(cr, uid, [ref("move_test_sale1")])
-
Now I can check that all is nice and shiny, line 1. I expect the Sale Order
Number to be recognised.
-
!assert {model: account.move.line, id: move_line_so, string: Check completion by SO number}:
- partner_id.name == u'China Export'