Skip to content

Commit

Permalink
[MIG][10.0] account_invoice_report_by_partner module
Browse files Browse the repository at this point in the history
  • Loading branch information
cubells committed Jun 6, 2017
1 parent a110246 commit 6d6d22e
Show file tree
Hide file tree
Showing 10 changed files with 122 additions and 196 deletions.
46 changes: 25 additions & 21 deletions account_invoice_report_by_partner/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,58 +6,62 @@
Invoice Report by Partner
=========================

This module was written to extend the functionality of invoice reports to support diferent invoice report by partner and allow you to set the invoice report template in partner form to print this template as default.
This module was written to extend the functionality of invoice reports to
support different invoice report by partner and allow you to set the invoice
report template in partner form to print this template as default.

Usage
=====

To use this module, you need to:

* go to partner configuration
* set default invoice report template
* print invoice report
#. Go to partner configuration
#. Set default invoice report template
#. Print invoice report

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

.. repo_id is available in https://github.com/OCA/maintainer-tools/blob/master/tools/repos_with_ids.txt
.. branch is "8.0" for example
For further information, please visit:

* https://www.odoo.com/forum/help-1
:target: https://runbot.odoo-community.org/runbot/94/10.0

Known issues / Roadmap
======================

* Print button on invoices gets invoice report for the partner, clicking Print on upper dropdown you could get other invoice report
* Print button on invoices gets invoice report for the partner, clicking Print
on upper dropdown you could get other invoice report

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

Bugs are tracked on `GitHub Issues <https://github.com/OCA/account_invoice_reporting/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_invoice_reporting/issues/new?body=module:%20account_invoice_report_by_partner%0Aversion:%208.0.1.0.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
Bugs are tracked on `GitHub Issues
<https://github.com/OCA/account_invoice_reporting/issues>`_. In case of
trouble, please check there if your issue has already been reported. If you
spotted it first, help us smash it by providing 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
------------

* Angel Moya <angel.moya@domatix.com>
* Vicent Cubells <vicent.cubells@tecnativa.com>

Maintainer
----------

.. image:: http://odoo-community.org/logo.png
.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: http://odoo-community.org
: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.
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.
To contribute to this module, please visit https://odoo-community.org.
18 changes: 1 addition & 17 deletions account_invoice_report_by_partner/__init__.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,4 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# 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/>.
#
##############################################################################
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from . import models
from . import tests
21 changes: 21 additions & 0 deletions account_invoice_report_by_partner/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# -*- coding: utf-8 -*-
# Copyright 2014 Angel Moya <angel.moya@domatix.com>
# Copyright 2017 Tecnativa - Vicent Cubells
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
{
'name': "Invoice Report by Partner",
'version': "10.0.1.0.0",
'author': "Domatix, "
"Tecnativa, "
"Odoo Community Association (OCA)",
'website': 'http://www.domatix.com/',
'category': 'Accounting & Finance',
'license': "AGPL-3",
'depends': [
'account',
],
'data': [
'views/partner_view.xml',
],
'installable': True,
}
33 changes: 0 additions & 33 deletions account_invoice_report_by_partner/__openerp__.py

This file was deleted.

17 changes: 1 addition & 16 deletions account_invoice_report_by_partner/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,5 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# 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/>.
#
##############################################################################
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from . import partner
from . import account
33 changes: 10 additions & 23 deletions account_invoice_report_by_partner/models/account.py
Original file line number Diff line number Diff line change
@@ -1,33 +1,20 @@
# encoding: utf-8
##############################################################################
#
# 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/>.
#
##############################################################################
# -*- coding: utf-8 -*-
# Copyright 2014 Angel Moya <angel.moya@domatix.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from openerp import models, api
from odoo import api, models


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

@api.multi
def invoice_print(self):
result = super(AccountInvoice, self).invoice_print()
self.ensure_one()
self.sent = True
invoice = self[0]
action_name = invoice.partner_id.invoice_report_id \
and invoice.partner_id.invoice_report_id.report_name \
or 'account.report_invoice'
action_name = self.partner_id.invoice_report_id \
and self.partner_id.invoice_report_id.report_name \
or False
if not action_name:
return result
return self.env['report'].get_action(self, action_name)
27 changes: 7 additions & 20 deletions account_invoice_report_by_partner/models/partner.py
Original file line number Diff line number Diff line change
@@ -1,29 +1,16 @@
# encoding: utf-8
##############################################################################
#
# 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/>.
#
##############################################################################
# -*- coding: utf-8 -*-
# Copyright 2014 Angel Moya <angel.moya@domatix.com>
# Copyright 2017 Tecnativa - Vicent Cubells
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from openerp import models, fields
from odoo import fields, models


class ResPartner(models.Model):
_inherit = 'res.partner'

invoice_report_id = fields.Many2one(
'ir.actions.report.xml',
comodel_name='ir.actions.report.xml',
string='Invoice Report Template',
domain="[('model', '=', 'account.invoice')]",
)
)
17 changes: 1 addition & 16 deletions account_invoice_report_by_partner/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,4 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# 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/>.
#
##############################################################################
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from . import test_account_invoice_report_by_partner
Original file line number Diff line number Diff line change
@@ -1,43 +1,55 @@
# -*- coding: utf-8 -*-
# Copyright 2014 Angel Moya <angel.moya@domatix.com>
# Copyright 2017 Tecnativa - Vicent Cubells
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

import openerp.tests.common as common
from datetime import datetime
from openerp.tools import DEFAULT_SERVER_DATE_FORMAT
from odoo.tests.common import SavepointCase
from odoo import fields


class TestInvoiceReportByPartner(common.TransactionCase):
class TestInvoiceReportByPartner(SavepointCase):

def create_simple_invoice(self):
partner_id = self.ref('base.res_partner_2')
product_id = self.ref('product.product_product_4')
today = datetime.now()
journal_id = self.ref('account.sales_journal')
date = today.strftime(DEFAULT_SERVER_DATE_FORMAT)
return self.env['account.invoice']\
.create({'partner_id': partner_id,
'account_id':
self.ref('account.a_recv'),
'journal_id':
journal_id,
'date_invoice': date,
'invoice_line': [(0, 0, {'name': 'test',
'account_id':
self.ref('account.a_sale'),
'price_unit': 2000.00,
'quantity': 1,
'product_id': product_id,
}
)
],
})
date = fields.Date.today()
return self.env['account.invoice'].create({
'partner_id': self.partner_id.id,
'account_id': self.account_id.id,
'journal_id': self.journal_id,
'date_invoice': date,
'invoice_line_ids': [
(0, 0, {
'name': 'test',
'account_id': self.account_id.id,
'price_unit': 2000.00,
'quantity': 1,
'product_id': self.product_id.id,
})],
})

def setUp(self):
super(TestInvoiceReportByPartner, self).setUp()
@classmethod
def setUpClass(cls):
super(TestInvoiceReportByPartner, cls).setUpClass()

cls.partner_id = cls.env['res.partner'].create({
'name': 'Test partner',
})
cls.product_id = cls.env['product.product'].create({
'name': 'Test product',
})
cls.journal_id = cls.env['account.journal'].search(
[('type', '=', 'sale')]).id
cls.account_type = cls.env['account.account.type'].create({
'name': 'Test account_type'
})
cls.account_id = cls.env['account.account'].create({
'name': 'Test account',
'code': '440000_demo',
'user_type_id': cls.account_type.id,
'reconcile': True})

def test_report_by_partner(self):
"""Assign report to partner and print invoice"""
report_obj = self.env['ir.actions.report.xml']
partner_obj = self.env['res.partner']

invoice = self.create_simple_invoice()

Expand All @@ -51,11 +63,7 @@ def test_report_by_partner(self):
'report_rml': action_name_copy,
'report_name': action_name_copy})

partner_id = self.ref('base.res_partner_2')

partner = partner_obj.browse(partner_id)

partner.write(
self.partner_id.write(
{'invoice_report_id': invoice_report_copy.id})

invoice_print = invoice.invoice_print()
Expand Down
Loading

0 comments on commit 6d6d22e

Please sign in to comment.