-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
167 additions
and
0 deletions.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import models |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"], | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import account_invoice |
23 changes: 23 additions & 0 deletions
23
grap_account_change_invoice_move/models/account_invoice.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"), | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
* Julien WESTE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import test_module |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)", | ||
) |