Skip to content

Commit

Permalink
Merge 82cfc53 into 53a08fb
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexis de Lattre committed Sep 18, 2015
2 parents 53a08fb + 82cfc53 commit 3f2640e
Show file tree
Hide file tree
Showing 7 changed files with 283 additions and 0 deletions.
55 changes: 55 additions & 0 deletions account_group_invoice_lines/README.rst
Original file line number Diff line number Diff line change
@@ -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

==========================
Account Group Invoice Line
==========================

This module was written to extend the option *Group Invoice Line* of the journal. With this module, you can choose to group the account move lines generated when you validate an invoice per account, instead of grouping per product.

Configuration
=============

To configure this module, go to the menu *Accounting > Configuration > Journals > Journals* and select a sale or purchase journal. On the form view of the journal, you have an option *Group Invoice Line*. If you activate this option, you will see a new option **Group by** with two possible values:

* **by Product**: the account move lines generated when you validate an invoice will be grouped by product, account, analytic account and tax code (this is the behavior when this module is not installed)

* **by Account**: the account move lines will be grouped by account, analytic account and tax code, without taking into account the product.

Usage
=====

.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
:alt: Try me on Runbot
:target: https://runbot.odoo-community.org/runbot/95/8.0

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/account-invoicing/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/account-invoicing/issues/new?body=module:%20account_group_invoice_line%0Aversion:%208.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Credits
=======

Contributors
------------

* Sébastien LANGE <sebastien.lange@syleam.fr>
* Alexis de Lattre <alexis.delattre@akretion.com>

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.
3 changes: 3 additions & 0 deletions account_group_invoice_lines/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# -*- coding: utf-8 -*-

from . import account
36 changes: 36 additions & 0 deletions account_group_invoice_lines/__openerp__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# account_group_invoice_lines module for Odoo
# Copyright (C) 2012-2015 SYLEAM Info Services (<http://www.syleam.fr/>)
# Copyright (C) 2015 Akretion (http://www.akretion.com)
# @author: Sébastien LANGE <sebastien.lange@syleam.fr>
# @author: Alexis de Lattre <alexis.delattre@akretion.com>
#
# 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 <http://www.gnu.org/licenses/>.
#
##############################################################################

{
'name': 'Account Group Invoice Lines',
'version': '8.0.1.1.0',
'category': 'Accounting & Finance',
'summary': 'Add option to group invoice line per account',
'author': 'SYLEAM,Akretion,Odoo Community Association (OCA)',
'license': 'AGPL-3',
'website': 'http://www.syleam.fr/',
'depends': ['account'],
'data': ['account_view.xml'],
'installable': True,
}
71 changes: 71 additions & 0 deletions account_group_invoice_lines/account.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# account_group_invoice_lines module for Odoo
# Copyright (C) 2012 SYLEAM Info Services (<http://www.syleam.fr/>)
# Copyright (C) 2015 Akretion (http://www.akretion.com)
# @author: Sébastien LANGE <sebastien.lange@syleam.fr>
# @author: Alexis de Lattre <alexis.delattre@akretion.com>
#
# 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 <http://www.gnu.org/licenses/>.
#
##############################################################################

from openerp import models, fields, api


class AccountInvoice(models.Model):
_inherit = 'account.invoice'

def inv_line_characteristic_hashcode(self, invoice_line):
"""Inherit the native method that generate hashcodes for grouping.
When grouping per account, we remove the product_id from
the hashcode.
WARNING: I suppose that the other methods that inherit this
method add data on the end of the hashcode, not at the beginning.
This is the case of github/OCA/account-closing/
account_cutoff_prepaid/account.py"""
res = super(AccountInvoice, self).inv_line_characteristic_hashcode(
invoice_line)
if self.journal_id.group_method == 'account':
hash_list = res.split('-')
# remove product_id from hashcode
hash_list.pop(2)
res = '-'.join(hash_list)
return res

@api.model
def line_get_convert(self, line, part, date):
res = super(AccountInvoice, self).line_get_convert(line, part, date)
if (
self.journal_id.group_invoice_lines and
self.journal_id.group_method == 'account'):
res['name'] = '/'
res['product_id'] = False
return res


class AccountJournal(models.Model):
_inherit = 'account.journal'

group_method = fields.Selection([
('product', 'By Product'),
('account', 'By Account')
], string='Group by', default='account',
help="If you select 'By Product', the account move lines generated "
"when you validate an invoice will be "
"grouped by product, account, analytic account and tax code. "
"If you select 'By Account', they will be grouped by account, "
"analytic account and tax code, without taking into account "
"the product.")
24 changes: 24 additions & 0 deletions account_group_invoice_lines/account_view.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<openerp>
<data>

<!--
Copyright (C) 2012-2015 SYLEAM Info Services ([http://www.syleam.fr/])
@author: Sébastien LANGE [sebastien.lange@syleam.fr]
The licence is in the file __openerp__.py
-->

<record id="view_account_journal_form" model="ir.ui.view">
<field name="name">group.invoice.lines.account.journal.form</field>
<field name="model">account.journal</field>
<field name="inherit_id" ref="account.view_account_journal_form"/>
<field name="arch" type="xml">
<field name="group_invoice_lines" position="after">
<field name="group_method"
attrs="{'invisible': [('group_invoice_lines','=', False)], 'required': [('group_invoice_lines','=', True)]}"/>
</field>
</field>
</record>

</data>
</openerp>
47 changes: 47 additions & 0 deletions account_group_invoice_lines/i18n/account_group_invoice_lines.pot
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * account_group_invoice_lines
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 8.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2015-09-16 20:43+0000\n"
"PO-Revision-Date: 2015-09-16 20:43+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_group_invoice_lines
#: selection:account.journal,group_method:0
msgid "By Account"
msgstr ""

#. module: account_group_invoice_lines
#: selection:account.journal,group_method:0
msgid "By Product"
msgstr ""

#. module: account_group_invoice_lines
#: field:account.journal,group_method:0
msgid "Group by"
msgstr ""

#. module: account_group_invoice_lines
#: help:account.journal,group_method:0
msgid "If you select 'By Product', the account move lines generated when you validate an invoice will be grouped by product, account, analytic account and tax code. If you select 'By Account', they will be grouped by account, analytic account and tax code, without taking into account the product."
msgstr ""

#. module: account_group_invoice_lines
#: model:ir.model,name:account_group_invoice_lines.model_account_invoice
msgid "Invoice"
msgstr ""

#. module: account_group_invoice_lines
#: model:ir.model,name:account_group_invoice_lines.model_account_journal
msgid "Journal"
msgstr ""

47 changes: 47 additions & 0 deletions account_group_invoice_lines/i18n/fr.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * account_group_invoice_lines
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 8.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2015-09-16 20:43+0000\n"
"PO-Revision-Date: 2015-09-16 20:43+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_group_invoice_lines
#: selection:account.journal,group_method:0
msgid "By Account"
msgstr "Par compte comptable"

#. module: account_group_invoice_lines
#: selection:account.journal,group_method:0
msgid "By Product"
msgstr "Par article"

#. module: account_group_invoice_lines
#: field:account.journal,group_method:0
msgid "Group by"
msgstr "Grouper par"

#. module: account_group_invoice_lines
#: help:account.journal,group_method:0
msgid "If you select 'By Product', the account move lines generated when you validate an invoice will be grouped by product, account, analytic account and tax code. If you select 'By Account', they will be grouped by account, analytic account and tax code, without taking into account the product."
msgstr "Si vous sélectionnez 'Par article', les lignes comptables générées lors de la validation d'une facture seront groupées par article, compte comptable, compte analytique et code de taxe. Si vous sélectionnez 'Par compte comptable', elles seront groupées par compte comptable, compte analytique et code de taxe, sans tenir compte de l'article."

#. module: account_group_invoice_lines
#: model:ir.model,name:account_group_invoice_lines.model_account_invoice
msgid "Invoice"
msgstr "Facture"

#. module: account_group_invoice_lines
#: model:ir.model,name:account_group_invoice_lines.model_account_journal
msgid "Journal"
msgstr "Journal"

0 comments on commit 3f2640e

Please sign in to comment.