From c2671d34b8304f39e265a62fc0d01a47fb86bc48 Mon Sep 17 00:00:00 2001 From: jbeficent Date: Tue, 26 Jan 2016 22:06:50 +0100 Subject: [PATCH] [ADD] [account_advanced_reconcile_transaction_by_purchase_line] --- .../__init__.py | 23 +++++++++ .../__openerp__.py | 40 +++++++++++++++ .../advanced_reconciliation.py | 49 +++++++++++++++++++ .../base_advanced_reconciliation.py | 37 ++++++++++++++ .../easy_reconcile.py | 36 ++++++++++++++ .../easy_reconcile_view.xml | 25 ++++++++++ 6 files changed, 210 insertions(+) create mode 100644 account_advanced_reconcile_transaction_by_purchase_line/__init__.py create mode 100644 account_advanced_reconcile_transaction_by_purchase_line/__openerp__.py create mode 100644 account_advanced_reconcile_transaction_by_purchase_line/advanced_reconciliation.py create mode 100644 account_advanced_reconcile_transaction_by_purchase_line/base_advanced_reconciliation.py create mode 100644 account_advanced_reconcile_transaction_by_purchase_line/easy_reconcile.py create mode 100644 account_advanced_reconcile_transaction_by_purchase_line/easy_reconcile_view.xml diff --git a/account_advanced_reconcile_transaction_by_purchase_line/__init__.py b/account_advanced_reconcile_transaction_by_purchase_line/__init__.py new file mode 100644 index 00000000..e19ad65a --- /dev/null +++ b/account_advanced_reconcile_transaction_by_purchase_line/__init__.py @@ -0,0 +1,23 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Author: Romain Deheele. Copyright Camptocamp SA +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## + +from . import easy_reconcile +from . import base_advanced_reconciliation +from . import advanced_reconciliation diff --git a/account_advanced_reconcile_transaction_by_purchase_line/__openerp__.py b/account_advanced_reconcile_transaction_by_purchase_line/__openerp__.py new file mode 100644 index 00000000..b9d10e92 --- /dev/null +++ b/account_advanced_reconcile_transaction_by_purchase_line/__openerp__.py @@ -0,0 +1,40 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Author: Romain Deheele. Copyright Camptocamp SA +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## + +{'name': 'Advanced Reconcile Transaction by Purchase Line', + 'description': """ +Advanced reconciliation method for the module account_advanced_reconcile +======================================================================== +Reconcile rules with transaction_ref + +""", + 'version': '1.0.1', + 'author': "Camptocamp,Odoo Community Association (OCA)", + 'category': 'Finance', + 'website': 'http://www.camptocamp.com', + 'depends': ['account_advanced_reconcile', + 'account_move_line_purchase_info'], + 'data': ['easy_reconcile_view.xml'], + 'demo': [], + 'test': [], # To be ported or migrate to unit tests or scenarios + 'auto_install': False, + 'installable': True, + 'images': [] + } diff --git a/account_advanced_reconcile_transaction_by_purchase_line/advanced_reconciliation.py b/account_advanced_reconcile_transaction_by_purchase_line/advanced_reconciliation.py new file mode 100644 index 00000000..6c74cb9e --- /dev/null +++ b/account_advanced_reconcile_transaction_by_purchase_line/advanced_reconciliation.py @@ -0,0 +1,49 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Author: Romain Deheele. Copyright Camptocamp SA +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## + +from openerp import models, api + + +class EasyReconcileAdvancedTransactionByPurchaseLine(models.TransientModel): + + _name = 'easy.reconcile.advanced.by.purchase.line' + _inherit = 'easy.reconcile.advanced' + + @api.model + def _skip_line(self, move_line): + """ + When True is returned on some conditions, the credit move line + will be skipped for reconciliation. Can be inherited to + skip on some conditions. ie: ref or partner_id is empty. + """ + return not move_line.get('partner_id') and move_line.get( + 'product_id') and move_line.get('purchase_line_id') + + @api.model + def _matchers(self, move_line): + return (('partner_id', move_line['partner_id']), + ('product_id', move_line['product_id']), + ('purchase_line_id', move_line['purchase_line_id'])) + + @api.model + def _opposite_matchers(self, move_line): + yield ('partner_id', (move_line['partner_id'])) + yield ('product_id', (move_line['product_id'])) + yield ('purchase_line_id', (move_line['purchase_line_id'])) diff --git a/account_advanced_reconcile_transaction_by_purchase_line/base_advanced_reconciliation.py b/account_advanced_reconcile_transaction_by_purchase_line/base_advanced_reconciliation.py new file mode 100644 index 00000000..74502d31 --- /dev/null +++ b/account_advanced_reconcile_transaction_by_purchase_line/base_advanced_reconciliation.py @@ -0,0 +1,37 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Author: Romain Deheele +# Copyright 2013 Camptocamp SA +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## + +from openerp import models, api + + +class EasyReconcileAdvanced(models.AbstractModel): + + _inherit = 'easy.reconcile.advanced' + + @api.model + def _base_columns(self): + """ Mandatory columns for move lines queries + An extra column aliased as ``key`` should be defined + in each query.""" + aml_cols = super(EasyReconcileAdvanced, self)._base_columns() + aml_cols.append('account_move_line.purchase_line_id') + aml_cols.append('account_move_line.product_id') + return aml_cols diff --git a/account_advanced_reconcile_transaction_by_purchase_line/easy_reconcile.py b/account_advanced_reconcile_transaction_by_purchase_line/easy_reconcile.py new file mode 100644 index 00000000..8267d441 --- /dev/null +++ b/account_advanced_reconcile_transaction_by_purchase_line/easy_reconcile.py @@ -0,0 +1,36 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Author: Romain Deheele +# Copyright 2013 Camptocamp SA +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## +from openerp import models, api + + +class AccountEasyReconcileMethod(models.Model): + + _inherit = 'account.easy.reconcile.method' + + @api.model + def _get_all_rec_method(self): + methods = super(AccountEasyReconcileMethod, self).\ + _get_all_rec_method() + methods += [ + ('easy.reconcile.advanced.by.purchase.line', + 'Advanced. GR/IR Key as partner, product, purchase order line.'), + ] + return methods diff --git a/account_advanced_reconcile_transaction_by_purchase_line/easy_reconcile_view.xml b/account_advanced_reconcile_transaction_by_purchase_line/easy_reconcile_view.xml new file mode 100644 index 00000000..cc042047 --- /dev/null +++ b/account_advanced_reconcile_transaction_by_purchase_line/easy_reconcile_view.xml @@ -0,0 +1,25 @@ + + + + + account.easy.reconcile.form + account.easy.reconcile + + + + + + + + + + + + + +