-
-
Notifications
You must be signed in to change notification settings - Fork 664
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
455 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,37 @@ | ||
Account Invoice Line default Account | ||
==================================== | ||
|
||
When entering sales or purchase invoices directly, the user has to select an | ||
account which will be used as a counterpart in the generated move lines. Each | ||
supplier will mostly be linked to one account. For instance when ordering paper | ||
from a supplier that deals in paper, the counterpart account will mostly be | ||
something like 'office expenses'. The same principle has been applied for | ||
customers. This module will add a default counterpart expense and income | ||
account to a partner, comparable to the similiar field in product. When an | ||
invoice is entered, withouth a product, the field from partner will be used as | ||
default. Also when an account is entered on an invoice line (not automatically | ||
selected for a product), the account will be automatically linked to the | ||
partner as default expense or income account, unless explicitly disabled in the | ||
partner record. | ||
|
||
Credits | ||
======= | ||
|
||
Contributors | ||
------------ | ||
|
||
* Jacques-Etienne Baudoux <je@bcim.be> (BCIM sprl) | ||
|
||
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. | ||
|
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,12 @@ | ||
# -*- coding: UTF-8 -*- | ||
''' | ||
Created on 30 jan. 2013 | ||
@author: Ronald Portier, Therp | ||
rportier@therp.nl | ||
http://www.therp.nl | ||
Ported to 7.0 on Sept. 17, 2013 by Jacques-Etienne Baudoux, BCIM (www.bcim.be) | ||
''' | ||
from . import model |
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 @@ | ||
# -*- coding: utf-8 -*- | ||
############################################################################## | ||
# | ||
# OpenERP, Open Source Management Solution | ||
# This module copyright (C) 2012 Therp BV (<http://therp.nl>). | ||
# This module copyright (C) 2013-2015 BCIM SPRL (<http://www.bcim.be>). | ||
# | ||
# 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 Invoice Line Default Account', | ||
'version': '1.0', | ||
'depends': [ | ||
'account' | ||
], | ||
'author': 'Therp BV,BCIM,Odoo Community Association (OCA)', | ||
'contributors': ['Jacques-Etienne Baudoux <je@bcim.be>'], | ||
'category': 'Accounting', | ||
'data': [ | ||
'view/res_partner.xml', | ||
'view/account_invoice.xml', | ||
], | ||
'demo': [], | ||
'test': [], | ||
'installable': True, | ||
'active': False, | ||
} |
59 changes: 59 additions & 0 deletions
59
account_invoice_line_default_account/i18n/account_invoice_line_default_account.pot
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,59 @@ | ||
# Translation of OpenERP Server. | ||
# This file contains the translation of the following modules: | ||
# * account_invoice_line_default_account | ||
# | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: OpenERP Server 7.saas~1\n" | ||
"Report-Msgid-Bugs-To: \n" | ||
"POT-Creation-Date: 2013-09-18 16:01+0000\n" | ||
"PO-Revision-Date: 2013-09-18 16:01+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_line_default_account | ||
#: field:res.partner,property_account_expense:0 | ||
msgid "Default Expense Account" | ||
msgstr "" | ||
|
||
#. module: account_invoice_line_default_account | ||
#: help:res.partner,property_account_expense:0 | ||
msgid "Default counterpart account for purchases on invoice lines" | ||
msgstr "" | ||
|
||
#. module: account_invoice_line_default_account | ||
#: help:res.partner,auto_update_account_expense:0 | ||
msgid "When an account is selected on an invoice line, automatically assign it as default expense account" | ||
msgstr "" | ||
|
||
#. module: account_invoice_line_default_account | ||
#: code:addons/account_invoice_line_default_account/model/account_invoice_line.py:27 | ||
#: code:addons/account_invoice_line_default_account/model/account_invoice_line.py:47 | ||
#, python-format | ||
msgid "No object created for partner %d" | ||
msgstr "" | ||
|
||
#. module: account_invoice_line_default_account | ||
#: model:ir.model,name:account_invoice_line_default_account.model_account_invoice_line | ||
msgid "Invoice Line" | ||
msgstr "" | ||
|
||
#. module: account_invoice_line_default_account | ||
#: view:res.partner:0 | ||
msgid "autosave from invoice line" | ||
msgstr "" | ||
|
||
#. module: account_invoice_line_default_account | ||
#: field:res.partner,auto_update_account_expense:0 | ||
msgid "Autosave Selection on Invoice Line" | ||
msgstr "" | ||
|
||
#. module: account_invoice_line_default_account | ||
#: model:ir.model,name:account_invoice_line_default_account.model_res_partner | ||
msgid "Partner" | ||
msgstr "" | ||
|
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,59 @@ | ||
# Translation of OpenERP Server. | ||
# This file contains the translation of the following modules: | ||
# * account_invoice_line_default_account | ||
# | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: OpenERP Server 7.saas~1\n" | ||
"Report-Msgid-Bugs-To: \n" | ||
"POT-Creation-Date: 2013-09-18 16:01+0000\n" | ||
"PO-Revision-Date: 2013-09-18 16:01+0000\n" | ||
"Last-Translator: Jacques-Etienne Baudoux <je@bcim.be>\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_line_default_account | ||
#: field:res.partner,property_account_expense:0 | ||
msgid "Default Expense Account" | ||
msgstr "Compte de charge par défaut" | ||
|
||
#. module: account_invoice_line_default_account | ||
#: help:res.partner,property_account_expense:0 | ||
msgid "Default counterpart account for purchases on invoice lines" | ||
msgstr "Compte de contrepartie par défaut pour les lignes de factures d'achat" | ||
|
||
#. module: account_invoice_line_default_account | ||
#: help:res.partner,auto_update_account_expense:0 | ||
msgid "When an account is selected on an invoice line, automatically assign it as default expense account" | ||
msgstr "Lorsqu'un compte est sélectionné sur une ligne de facture, l'assigner automatiquement comme compte de charge par défaut" | ||
|
||
#. module: account_invoice_line_default_account | ||
#: code:addons/account_invoice_line_default_account/model/account_invoice_line.py:27 | ||
#: code:addons/account_invoice_line_default_account/model/account_invoice_line.py:47 | ||
#, python-format | ||
msgid "No object created for partner %d" | ||
msgstr "" | ||
|
||
#. module: account_invoice_line_default_account | ||
#: model:ir.model,name:account_invoice_line_default_account.model_account_invoice_line | ||
msgid "Invoice Line" | ||
msgstr "" | ||
|
||
#. module: account_invoice_line_default_account | ||
#: view:res.partner:0 | ||
msgid "autosave from invoice line" | ||
msgstr "sauvegarde automatique" | ||
|
||
#. module: account_invoice_line_default_account | ||
#: field:res.partner,auto_update_account_expense:0 | ||
msgid "Autosave Selection on Invoice Line" | ||
msgstr "" | ||
|
||
#. module: account_invoice_line_default_account | ||
#: model:ir.model,name:account_invoice_line_default_account.model_res_partner | ||
msgid "Partner" | ||
msgstr "" | ||
|
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,59 @@ | ||
# Translation of OpenERP Server. | ||
# This file contains the translation of the following modules: | ||
# * account_invoice_line_default_account | ||
# | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: OpenERP Server 7.saas~1\n" | ||
"Report-Msgid-Bugs-To: \n" | ||
"POT-Creation-Date: 2013-09-18 16:01+0000\n" | ||
"PO-Revision-Date: 2013-09-18 16:01+0000\n" | ||
"Last-Translator: Jacques-Etienne Baudoux <je@bcim.be>\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_line_default_account | ||
#: field:res.partner,property_account_expense:0 | ||
msgid "Default Expense Account" | ||
msgstr "Standaard kostenrekening" | ||
|
||
#. module: account_invoice_line_default_account | ||
#: help:res.partner,property_account_expense:0 | ||
msgid "Default counterpart account for purchases on invoice lines" | ||
msgstr "Standaard tegenrekening voor inkoop factuur lijnen" | ||
|
||
#. module: account_invoice_line_default_account | ||
#: help:res.partner,auto_update_account_expense:0 | ||
msgid "When an account is selected on an invoice line, automatically assign it as default expense account" | ||
msgstr "Wanneer een rekening op een factuur lijn is geselecteerd, automatisch toewijzen als standaard kostenrekening" | ||
|
||
#. module: account_invoice_line_default_account | ||
#: code:addons/account_invoice_line_default_account/model/account_invoice_line.py:27 | ||
#: code:addons/account_invoice_line_default_account/model/account_invoice_line.py:47 | ||
#, python-format | ||
msgid "No object created for partner %d" | ||
msgstr "" | ||
|
||
#. module: account_invoice_line_default_account | ||
#: model:ir.model,name:account_invoice_line_default_account.model_account_invoice_line | ||
msgid "Invoice Line" | ||
msgstr "" | ||
|
||
#. module: account_invoice_line_default_account | ||
#: view:res.partner:0 | ||
msgid "autosave from invoice line" | ||
msgstr "automatisch bewaren" | ||
|
||
#. module: account_invoice_line_default_account | ||
#: field:res.partner,auto_update_account_expense:0 | ||
msgid "Autosave Selection on Invoice Line" | ||
msgstr "" | ||
|
||
#. module: account_invoice_line_default_account | ||
#: model:ir.model,name:account_invoice_line_default_account.model_res_partner | ||
msgid "Partner" | ||
msgstr "" | ||
|
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 -*- | ||
|
||
from . import res_partner | ||
from . import account_invoice_line |
70 changes: 70 additions & 0 deletions
70
account_invoice_line_default_account/model/account_invoice_line.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,70 @@ | ||
# -*- coding: UTF-8 -*- | ||
''' | ||
Created on 30 jan. 2013 | ||
@author: Ronald Portier, Therp | ||
@contributor: Jacques-Etienne Baudoux, BCIM | ||
''' | ||
|
||
from openerp.osv import orm | ||
from openerp.tools.translate import _ | ||
|
||
|
||
class account_invoice_line(orm.Model): | ||
_inherit = 'account.invoice.line' | ||
|
||
def _account_id_default(self, cr, uid, context=None): | ||
if context is None: | ||
context = {} | ||
partner_id = context.get('partner_id') | ||
if not partner_id: | ||
return False | ||
assert isinstance(partner_id, (int, long)), ( | ||
_('No valid id for context partner_id %d') % partner_id) | ||
invoice_type = context.get('type') | ||
partner_model = self.pool.get('res.partner') | ||
if invoice_type in ['in_invoice', 'in_refund']: | ||
partner = partner_model.read( | ||
cr, uid, partner_id, | ||
['property_account_expense'], context=context) | ||
return partner['property_account_expense'] | ||
elif invoice_type in ['out_invoice', 'out_refund']: | ||
partner = partner_model.read( | ||
cr, uid, partner_id, | ||
['property_account_income'], context=context) | ||
return partner['property_account_income'] | ||
return False | ||
|
||
_defaults = { | ||
'account_id': _account_id_default, | ||
} | ||
|
||
def onchange_account_id( | ||
self, cr, uid, ids, product_id, partner_id, inv_type, | ||
fposition_id, account_id, context=None): | ||
if account_id and partner_id and not product_id: | ||
# We have a manually entered account_id (no product_id, so the | ||
# account_id is not the result of a product selection). | ||
# Store this account_id as future default in res_partner. | ||
partner_model = self.pool.get('res.partner') | ||
partner = partner_model.read( | ||
cr, uid, partner_id, | ||
['auto_update_account_expense', 'property_account_expense', | ||
'auto_update_account_income', 'property_account_income'], | ||
context=context) | ||
vals = {} | ||
if (inv_type in ['in_invoice', 'in_refund'] and | ||
partner['auto_update_account_expense']): | ||
if account_id != partner['property_account_expense']: | ||
# only write when something really changed | ||
vals.update({'property_account_expense': account_id}) | ||
elif (inv_type in ['out_invoice', 'out_refund'] and | ||
partner['auto_update_account_income']): | ||
if account_id != partner['property_account_income']: | ||
# only write when something really changed | ||
vals.update({'property_account_income': account_id}) | ||
if vals: | ||
partner_model.write(cr, uid, partner_id, vals, context=context) | ||
return super(account_invoice_line, self).onchange_account_id( | ||
cr, uid, ids, product_id, partner_id, inv_type, | ||
fposition_id, account_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,46 @@ | ||
# -*- coding: UTF-8 -*- | ||
''' | ||
Created on 30 jan. 2013 | ||
@author: Ronald Portier, Therp | ||
@contributor: Jacques-Etienne Baudoux, BCIM | ||
''' | ||
|
||
from openerp.osv import orm | ||
from openerp.osv import fields | ||
|
||
|
||
class res_partner(orm.Model): | ||
_inherit = 'res.partner' | ||
|
||
_columns = { | ||
'property_account_income': fields.property( | ||
obj_prop='account.account', | ||
type='many2one', | ||
relation='account.account', | ||
string='Default Income Account', | ||
domain='''[('user_type.report_type', '=', 'income')]''', | ||
help='Default counterpart account for sales on invoice lines', | ||
required=False), | ||
'auto_update_account_income': fields.boolean( | ||
'Autosave Selection on Invoice Line', | ||
help='When an account is selected on an invoice line, ' | ||
'automatically assign it as default income account'), | ||
'property_account_expense': fields.property( | ||
obj_prop='account.account', | ||
type='many2one', | ||
relation='account.account', | ||
string='Default Expense Account', | ||
domain='''[('user_type.report_type', '=', 'expense')]''', | ||
help='Default counterpart account for purchases on invoice lines', | ||
required=False), | ||
'auto_update_account_expense': fields.boolean( | ||
'Autosave Selection on Invoice Line', | ||
help='When an account is selected on an invoice line, ' | ||
'automatically assign it as default expense account'), | ||
} | ||
|
||
_defaults = { | ||
'auto_update_account_income': True, | ||
'auto_update_account_expense': True, | ||
} |
Oops, something went wrong.