Skip to content

Commit

Permalink
[FIX] pep8, README.rst
Browse files Browse the repository at this point in the history
  • Loading branch information
jbaudoux authored and SirTakobi committed Apr 21, 2022
1 parent a2299c8 commit 0130434
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 22 deletions.
37 changes: 37 additions & 0 deletions account_invoice_line_default_account/README.rst
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 <[email protected]> (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.

18 changes: 3 additions & 15 deletions account_invoice_line_default_account/__openerp__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#
# OpenERP, Open Source Management Solution
# This module copyright (C) 2012 Therp BV (<http://therp.nl>).
# This module copyright (C) 2013 BCIM SPRL (<http://www.bcim.be>).
# 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
Expand All @@ -21,25 +21,13 @@
##############################################################################
{
'name': 'Account Invoice Line Default Account',
'version': '7.0.1.0',
'version': '1.0',
'depends': [
'account'
],
'author': 'Therp BV',
'author': 'Therp BV,BCIM,Odoo Community Association (OCA)',
'contributors': ['Jacques-Etienne Baudoux <[email protected]>'],
'category': 'Accounting',
'description': '''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 sme
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.''',
'data': [
'view/res_partner.xml',
'view/account_invoice.xml',
Expand Down
17 changes: 10 additions & 7 deletions account_invoice_line_default_account/model/account_invoice_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,13 @@ def _account_id_default(self, cr, uid, context=None):
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,
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,
partner = partner_model.read(
cr, uid, partner_id,
['property_account_income'], context=context)
return partner['property_account_income']
return False
Expand All @@ -45,23 +47,24 @@ def onchange_account_id(
# 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,
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']):
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']):
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)
cr, uid, ids, product_id, partner_id, inv_type,
fposition_id, account_id)

0 comments on commit 0130434

Please sign in to comment.