Skip to content

Commit

Permalink
Merge 27f10ac into 0b73af7
Browse files Browse the repository at this point in the history
  • Loading branch information
legalsylvain committed Nov 15, 2019
2 parents 0b73af7 + 27f10ac commit 3c92708
Show file tree
Hide file tree
Showing 11 changed files with 167 additions and 0 deletions.
Empty file.
1 change: 1 addition & 0 deletions grap_account_change_invoice_move/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
17 changes: 17 additions & 0 deletions grap_account_change_invoice_move/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Copyright (C) 2013 - Today: GRAP (http://www.grap.coop)
# @author Julien WESTE
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

{
"name": "GRAP - Custom accounting move generation from invoices",
"summary": "Remove product from the keys during account moves generation"
" from invoices",
"version": "12.0.1.0.0",
"category": "GRAP Custom",
"license": "AGPL-3",
"author": "GRAP",
"website": "http://www.grap.coop",
"depends": ["account"],
"installable": True,
"demo": ["demo/account_account.xml", "demo/account_invoice.xml"],
}
21 changes: 21 additions & 0 deletions grap_account_change_invoice_move/demo/account_account.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (C) 2019 - Today: GRAP (http://www.grap.coop)
@author Sylvain LE GAL (https://twitter.com/legalsylvain)
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
-->

<odoo>

<record id="sale_account_1" model="account.account">
<field name="name">Sale Account 1</field>
<field name="code">706GRAP</field>
<field name="user_type_id" ref="account.data_account_type_revenue"/>
</record>

<record id="sale_account_2" model="account.account">
<field name="name">Sale Account 2</field>
<field name="code">707GRAP</field>
<field name="user_type_id" ref="account.data_account_type_revenue"/>
</record>
</odoo>
56 changes: 56 additions & 0 deletions grap_account_change_invoice_move/demo/account_invoice.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (C) 2019 - Today: GRAP (http://www.grap.coop)
@author Sylvain LE GAL (https://twitter.com/legalsylvain)
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
-->

<odoo>

<record id="demo_invoice" model="account.invoice">
<field name="partner_id" ref="base.res_partner_2"/>
<field name="type">out_invoice</field>
<field name="date_invoice" eval="time.strftime('%Y-%m')+'-08'"/>
</record>

<record id="demo_invoice_line_1" model="account.invoice.line">
<field name="name" model="account.invoice.line" eval="obj().env.ref('product.consu_delivery_01').partner_ref"/>
<field name="invoice_id" ref="demo_invoice"/>
<field name="product_id" ref="product.consu_delivery_01"/>
<field name="account_id" ref="sale_account_1"/>
<field name="quantity">5</field>
<field name="price_unit">90.0</field>
<field name="invoice_line_tax_ids" eval="False"/>
</record>

<record id="demo_invoice_line_2" model="account.invoice.line">
<field name="name" model="account.invoice.line" eval="obj().env.ref('product.consu_delivery_01').partner_ref"/>
<field name="invoice_id" ref="demo_invoice"/>
<field name="product_id" ref="product.consu_delivery_01"/>
<field name="account_id" ref="sale_account_1"/>
<field name="quantity">5.0</field>
<field name="price_unit">15.0</field>
<field name="invoice_line_tax_ids" eval="False"/>
</record>

<record id="demo_invoice_line_3" model="account.invoice.line">
<field name="name" model="account.invoice.line" eval="obj().env.ref('product.consu_delivery_02').partner_ref"/>
<field name="invoice_id" ref="demo_invoice"/>
<field name="product_id" ref="product.consu_delivery_02"/>
<field name="account_id" ref="sale_account_1"/>
<field name="quantity">1.0</field>
<field name="price_unit">100.0</field>
<field name="invoice_line_tax_ids" eval="False"/>
</record>

<record id="demo_invoice_line_4" model="account.invoice.line">
<field name="name" model="account.invoice.line" eval="obj().env.ref('product.consu_delivery_03').partner_ref"/>
<field name="invoice_id" ref="demo_invoice"/>
<field name="product_id" ref="product.consu_delivery_03"/>
<field name="account_id" ref="sale_account_2"/>
<field name="quantity">5.0</field>
<field name="price_unit">25.0</field>
<field name="invoice_line_tax_ids" eval="False"/>
</record>

</odoo>
1 change: 1 addition & 0 deletions grap_account_change_invoice_move/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import account_invoice
23 changes: 23 additions & 0 deletions grap_account_change_invoice_move/models/account_invoice.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Copyright (C) 2018 - Today: GRAP (http://www.grap.coop)
# @author Julien WESTE
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from odoo import models


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

def inv_line_characteristic_hashcode(self, invoice_line):
# We override this function to group lines regardless of the
# product_id.
# Lines having the same hashcode will be grouped together if the
# journal has the 'group line' option.
return "{}-{}-{}-{}-{}-{}".format(
invoice_line["account_id"],
invoice_line.get("tax_ids", "False"),
invoice_line.get("tax_line_id", "False"),
invoice_line.get("analytic_account_id", "False"),
invoice_line.get("date_maturity", "False"),
invoice_line.get("analytic_tag_ids", "False"),
)
1 change: 1 addition & 0 deletions grap_account_change_invoice_move/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* Julien WESTE
4 changes: 4 additions & 0 deletions grap_account_change_invoice_move/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
This module extends the functionality of Accounting module
to generate smaller accounting moves from invoices.

With this module, moves are grouped, without taking into account products.
1 change: 1 addition & 0 deletions grap_account_change_invoice_move/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import test_module
42 changes: 42 additions & 0 deletions grap_account_change_invoice_move/tests/test_module.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Copyright (C) 2019 - Today: GRAP (http://www.grap.coop)
# @author: Sylvain LE GAL (https://twitter.com/legalsylvain)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from odoo.tests.common import TransactionCase


class TestModule(TransactionCase):
def setUp(self):
super().setUp()

self.sale_journal = self.env["account.journal"].search(
[("type", "=", "sale"), ("code", "=", "INV")]
)[0]

self.invoice = self.env.ref("grap_account_change_invoice_move.demo_invoice")

# Test Section
def test_01_confirm_non_grouped(self):
self.sale_journal.group_invoice_lines = False
self.invoice.action_invoice_open()

self.assertEquals(
len(self.invoice.move_id.line_ids),
5,
"In a non grouped mode, an invoice with 4 lines"
" (3 products / 2 account) should generate"
" an account move with 4 lines (4 sale lines + 1 counterpart)",
)

# Test Section
def test_01_confirm_grouped(self):
self.sale_journal.group_invoice_lines = True
self.invoice.action_invoice_open()

self.assertEquals(
len(self.invoice.move_id.line_ids),
3,
"In a grouped mode, an invoice with 4 lines"
" (3 products / 2 account) should generate"
" an account move with 3 lines (2 sale line + 1 counterpart)",
)

0 comments on commit 3c92708

Please sign in to comment.