-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge commit 'refs/pull/112/head' of github.com:acsone/acsone-addons …
…into exq_master
- Loading branch information
Showing
9 changed files
with
254 additions
and
0 deletions.
There are no files selected for viewing
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,32 @@ | ||
.. 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 Invoice Project | ||
======================= | ||
|
||
This module provides a new stored and computed fields on account.invoice. | ||
This fields contains the project related to the invoice lines if the lines | ||
have the same project. In case where the lines are linked to different | ||
projects then the new computed fields will be "False" | ||
|
||
Credits | ||
======= | ||
|
||
Contributors | ||
------------ | ||
|
||
* Stéphane Bidoul <stephane.bidoul@acsone.eu> | ||
* Laetitia Gangloff <Laetitia.Gangloff@acsone.eu > | ||
* Laurent Mignon <laurent.mignon@acsone.eu > | ||
* Jonathan Nemry <jonathan.nemry@acsone.eu> | ||
|
||
Maintainer | ||
---------- | ||
|
||
.. image:: https://www.acsone.eu/logo.png | ||
:alt: ACSONE SA/NV | ||
:target: http://www.acsone.eu | ||
|
||
This module is maintained by ACSONE SA/NV. |
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 @@ | ||
# -*- coding: utf-8 -*- | ||
# Copyright 2016 ACSONE SA/NV (<http://acsone.eu>) | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
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,20 @@ | ||
# -*- coding: utf-8 -*- | ||
# Copyright 2016 ACSONE SA/NV (<http://acsone.eu>) | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
{ | ||
"name": "Account Invoice Project", | ||
"version": "8.0.1.0.0", | ||
"author": "ACSONE SA/NV", | ||
"category": "Accounting & Finance", | ||
"website": "http://acsone.eu", | ||
"depends": [ | ||
"account", | ||
"project", | ||
], | ||
"summary": """Account Invoice Project""", | ||
"data": [ | ||
"views/account_invoice_view.xml", | ||
], | ||
"license": "AGPL-3", | ||
"installable": True, | ||
} |
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,39 @@ | ||
# Translation of Odoo Server. | ||
# This file contains the translation of the following modules: | ||
# * account_invoice_project | ||
# | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: Odoo Server 8.0\n" | ||
"Report-Msgid-Bugs-To: \n" | ||
"POT-Creation-Date: 2016-02-19 11:47+0000\n" | ||
"PO-Revision-Date: 2016-02-19 11:47+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_invoice_project | ||
#: field:account.invoice,account_analytic_id:0 | ||
msgid "Analytic account" | ||
msgstr "Compte analytique" | ||
|
||
#. module: account_invoice_project | ||
#: model:ir.model,name:account_invoice_project.model_account_invoice | ||
msgid "Invoice" | ||
msgstr "Facture" | ||
|
||
#. module: account_invoice_project | ||
#: view:account.invoice:account_invoice_project.view_account_invoice_filter | ||
msgid "Project" | ||
msgstr "Projet" | ||
|
||
#. module: account_invoice_project | ||
#: view:account.invoice:account_invoice_project.invoice_form | ||
msgid "{'default_account_analytic_id':\n" | ||
" account_analytic_id}" | ||
msgstr "{'default_account_analytic_id':\n" | ||
" account_analytic_id}" | ||
|
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 @@ | ||
# -*- coding: utf-8 -*- | ||
# Copyright 2016 ACSONE SA/NV (<http://acsone.eu>) | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
from . import account_invoice |
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,46 @@ | ||
# -*- coding: utf-8 -*- | ||
# Copyright 2016 ACSONE SA/NV (<http://acsone.eu>) | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
from openerp import api, fields, models | ||
|
||
|
||
class AccountInvoice(models.Model): | ||
_inherit = "account.invoice" | ||
|
||
@api.model | ||
def _get_account_analytic_id(self, invoice_lines): | ||
''' compute account_analytic_id by looking at the invoice line, | ||
and returning the analytic account from the invoice line | ||
if it is the same on all line. If there are lines with different | ||
analytic accounts, it must be False.''' | ||
account = False | ||
for il in invoice_lines: | ||
cur_account = False | ||
if type(il) is dict: | ||
cur_account = il['account_analytic_id'] | ||
else: | ||
cur_account = il.account_analytic_id and \ | ||
il.account_analytic_id.id or False | ||
if account and account != cur_account: | ||
return False | ||
else: | ||
account = cur_account | ||
return account | ||
|
||
@api.one | ||
@api.depends('invoice_line') | ||
def _account_analytic_id(self): | ||
self.account_analytic_id = self._get_account_analytic_id( | ||
self.invoice_line) | ||
|
||
@api.onchange('invoice_line') | ||
def onchange_invoice_line(self): | ||
self.account_analytic_id = self._get_account_analytic_id( | ||
self.invoice_line) | ||
|
||
# new field | ||
account_analytic_id = fields.Many2one( | ||
compute='_account_analytic_id', | ||
comodel_name="account.analytic.account", | ||
string="Analytic account", | ||
store=True) |
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 @@ | ||
# -*- coding: utf-8 -*- | ||
# Copyright 2016 ACSONE SA/NV (<http://acsone.eu>) | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
from . import test_account_analytic_project |
52 changes: 52 additions & 0 deletions
52
account_invoice_project/tests/test_account_analytic_project.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,52 @@ | ||
# -*- coding: utf-8 -*- | ||
from openerp.tests import common | ||
from openerp import fields | ||
|
||
|
||
class TestAccountAnalyticProject(common.TransactionCase): | ||
|
||
def test_account_analytic_project(self): | ||
partner_id = self.env['res.partner'].create({ | ||
'name': 'name', | ||
}) | ||
vals = { | ||
'name': 'product_test_01', | ||
'lst_price': 2000.00, | ||
} | ||
product = self.env['product.product'].create(vals) | ||
sale_journal_id = self.env.ref('account.sales_journal') | ||
aai_id = self.ref('project.project_project_1') | ||
invoice_line = self.env['account.invoice.line'].create({ | ||
'name': 'test', | ||
'account_id': self.ref('account.a_sale'), | ||
'price_unit': 2000.00, | ||
'quantity': 1, | ||
'product_id': product.id, | ||
'account_analytic_id': aai_id, | ||
}) | ||
account_invoice = self.env['account.invoice'].create({ | ||
'partner_id': partner_id.id, | ||
'account_id': self.ref('account.a_recv'), | ||
'journal_id': sale_journal_id.id, | ||
'date_invoice': fields.Date.today(), | ||
'invoice_line': [(6, 0, [invoice_line.id])], | ||
}) | ||
self.assertTrue( | ||
account_invoice.account_analytic_id, 'Should have an account') | ||
self.assertEquals( | ||
account_invoice.account_analytic_id.id, | ||
aai_id, | ||
'Should have same account') | ||
invoice_line2 = self.env['account.invoice.line'].create({ | ||
'name': 'test2', | ||
'account_id': self.ref('account.a_recv'), | ||
'price_unit': 2000.00, | ||
'quantity': 1, | ||
'product_id': product.id, | ||
'account_analytic_id': self.ref('project.project_project_2') | ||
}) | ||
account_invoice.write({ | ||
'invoice_line': [(4, invoice_line2.id)] | ||
}) | ||
self.assertFalse( | ||
account_invoice.account_analytic_id, 'Should have an account') |
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,53 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<openerp> | ||
<data> | ||
|
||
<!-- customize invoice filters --> | ||
<record model="ir.ui.view" id="view_account_invoice_filter"> | ||
<field name="name">account.invoice.select | ||
(account_invoice_project) | ||
</field> | ||
<field name="model">account.invoice</field> | ||
<field name="inherit_id" ref="account.view_account_invoice_filter" /> | ||
<field name="arch" type="xml"> | ||
<field name="partner_id" position="after"> | ||
<field name="account_analytic_id" string="Project" /> | ||
</field> | ||
</field> | ||
</record> | ||
<!-- customize invoice tree view --> | ||
<record model="ir.ui.view" id="invoice_tree"> | ||
<field name="name">account.invoice.tree | ||
(account_invoice_project) | ||
</field> | ||
<field name="model">account.invoice</field> | ||
<field name="inherit_id" ref="account.invoice_tree" /> | ||
<field name="arch" type="xml"> | ||
<field name="number" position="after"> | ||
<field name="account_analytic_id" /> | ||
</field> | ||
</field> | ||
</record> | ||
<record model="ir.ui.view" id="invoice_form"> | ||
<field name="name">account.invoice.form | ||
(account_invoice_project) | ||
</field> | ||
<field name="model">account.invoice</field> | ||
<field name="inherit_id" ref="account.invoice_form" /> | ||
<field name="arch" type="xml"> | ||
<xpath | ||
expr="//page[@string='Other Info']/group/group/field[@name='name']" | ||
position="before"> | ||
<field name="account_analytic_id" /> | ||
</xpath> | ||
<field name="invoice_line" position="attributes"> | ||
<attribute name="context"> | ||
{'default_account_analytic_id': | ||
account_analytic_id} | ||
</attribute> | ||
</field> | ||
</field> | ||
</record> | ||
|
||
</data> | ||
</openerp> |