mirror of
https://github.com/OCA/account-reconcile.git
synced 2025-01-20 12:27:39 +02:00
changes to the invoices views: always display the description, copy the supplier invoice number in ref. document the module
This commit is contained in:
@@ -32,30 +32,100 @@
|
||||
Invoices Reference
|
||||
==================
|
||||
|
||||
Aims to simplify the "references" things on the invoices. There is too
|
||||
many fields on the invoices. And it is very difficult to remember
|
||||
which field goes in which field of the Journal Entries and under which
|
||||
conditions.
|
||||
Aims to simplify the "references" fields on the invoices.
|
||||
|
||||
Is follows this rule: the reference of a journal entry is
|
||||
always the reference of the document which generated it to
|
||||
be able to trace them in the accounting reports. That means the origin
|
||||
of an invoice or if the invoice has been created manually without origin,
|
||||
its number.
|
||||
We observed difficulties for the users to file the references (name,
|
||||
origin, free reference) and above all, to understand which field will be
|
||||
copied in the reference field of the move and move lines.
|
||||
|
||||
The approach here is to state simple rules with one concern: consistency.
|
||||
The reference of the move lines must be the number of the document at their very
|
||||
origin (number of a sales order, of an external document like a supplier
|
||||
invoice, ...). The goal is for the accountant to be able to trace to the
|
||||
source document from a ledger).
|
||||
The description of a line should always be... well, a description. Not a number
|
||||
or a cryptic reference.
|
||||
|
||||
It particularly fits with other modules of the bank-statement-reconcile series
|
||||
like account_advanced_reconcile_transaction_ref.
|
||||
as account_advanced_reconcile_transaction_ref.
|
||||
|
||||
Use cases
|
||||
---------
|
||||
Fields
|
||||
------
|
||||
|
||||
Customer invoices
|
||||
Journal Entry Reference is the Origin of the invoice if there,
|
||||
otherwise, it is the Number of the invoice.
|
||||
Enumerating the information we need in an invoice, we find that the
|
||||
mandatory fields are:
|
||||
|
||||
Supplier invoices
|
||||
Journal Entry Reference is the Supplier Invoice Number of the invoice
|
||||
which is now mandatory.
|
||||
* Invoice Number
|
||||
* Description
|
||||
* Internal Reference ("our reference")
|
||||
* External Reference ("customer or supplier reference")
|
||||
* Optionally, a technical transaction reference (credit card payment gateways, SEPA, ...)
|
||||
|
||||
Now, on the move lines:
|
||||
|
||||
* Name
|
||||
* Reference
|
||||
* Optionally, a technical transaction reference (added by the module `base_transaction_id`)
|
||||
|
||||
Let's see how the information will be organized with this module.
|
||||
|
||||
Customers Invoices / Refunds
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
+-----------------+-----------------+------------------------------+
|
||||
| Information | Invoice field | Instead of (in base modules) |
|
||||
+=================+=================+==============================+
|
||||
| Invoice number | Invoice number | Invoice number |
|
||||
+-----------------+-----------------+------------------------------+
|
||||
| Description | Name | -- |
|
||||
+-----------------+-----------------+------------------------------+
|
||||
| Internal Ref | Origin | Origin |
|
||||
+-----------------+-----------------+------------------------------+
|
||||
| External Ref | Reference | Name |
|
||||
+-----------------+-----------------+------------------------------+
|
||||
|
||||
Information propagated to the move lines:
|
||||
|
||||
+-----------------+------------------------------------+
|
||||
| Move line field | Invoice field |
|
||||
+=================+====================================+
|
||||
| Description | Name |
|
||||
+-----------------+------------------------------------+
|
||||
| Reference | Origin, or Invoice number if empty |
|
||||
+-----------------+------------------------------------+
|
||||
|
||||
|
||||
Supplier Invoices / Refunds
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Supplier invoices have an additional field `supplier_invoice_number`
|
||||
that we consider as redundant with the reference field. This field is kept
|
||||
and even set as mandatory, while the reference field is hidden.
|
||||
|
||||
+-----------------+-----------------+------------------------------+
|
||||
| Information | Invoice field | Instead of (in base modules) |
|
||||
+=================+=================+==============================+
|
||||
| Invoice number | Invoice number | Invoice number |
|
||||
+-----------------+-----------------+------------------------------+
|
||||
| Description | Name | -- |
|
||||
+-----------------+-----------------+------------------------------+
|
||||
| Internal Ref | Origin | Origin |
|
||||
+-----------------+-----------------+------------------------------+
|
||||
| External Ref | Supplier number | Supplier number |
|
||||
+-----------------+-----------------+------------------------------+
|
||||
|
||||
The reference field is hidden when the reference type is "free reference",
|
||||
because it is already filed in the Supplier invoice number.
|
||||
|
||||
Information propagated to the move lines:
|
||||
|
||||
+-----------------+---------------------------------------------+
|
||||
| Move line field | Invoice field |
|
||||
+=================+=============================================+
|
||||
| Description | Name |
|
||||
+-----------------+---------------------------------------------+
|
||||
| Reference | Supplier number, or Invoice number if empty |
|
||||
+-----------------+---------------------------------------------+
|
||||
|
||||
""",
|
||||
'website': 'http://www.camptocamp.com',
|
||||
|
||||
@@ -13,14 +13,37 @@
|
||||
<xpath expr="/form/sheet/notebook/page[@string='Other Info']//field[@name='name']"
|
||||
position="replace">
|
||||
</xpath>
|
||||
<field name="reference" position="after">
|
||||
<field name="name" class="oe_inline"
|
||||
<field name="reference_type" position="after">
|
||||
<label string="Enter the reference in the Supplier Invoice Number field"
|
||||
class="oe_inline"
|
||||
attrs="{'invisible': [('reference_type', '!=', 'none')]}"/>
|
||||
</field>
|
||||
<field name="reference" position="attributes">
|
||||
<attribute name="attrs">{'invisible': [('reference_type', '=', 'none')]}</attribute>
|
||||
</field>
|
||||
|
||||
<xpath expr="//field[@name='reference_type']/parent::div" position="after">
|
||||
<field name="name"/>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
|
||||
<record id="invoice_form" model="ir.ui.view">
|
||||
<field name="name">account.invoice.form</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']//field[@name='name']" position="replace">
|
||||
<field name="reference" string="Customer Reference"/>
|
||||
</xpath>
|
||||
|
||||
<field name="fiscal_position" position="after">
|
||||
<field name="name"/>
|
||||
</field>
|
||||
|
||||
</field>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
|
||||
@@ -75,3 +75,25 @@ class account_invoice(orm.Model):
|
||||
'AND account_analytic_line.move_id = account_move_line.id',
|
||||
(ref, move_id))
|
||||
return True
|
||||
|
||||
def create(self, cr, uid, vals, context=None):
|
||||
if (vals.get('supplier_invoice_reference') and not
|
||||
vals.get('reference')):
|
||||
vals['reference'] = vals['supplier_invoice_reference']
|
||||
return super(account_invoice, self).create(cr, uid, vals,
|
||||
context=context)
|
||||
|
||||
def write(self, cr, uid, ids, vals, context=None):
|
||||
if vals.get('supplier_invoice_reference'):
|
||||
if isinstance(ids, (int, long)):
|
||||
ids = [ids]
|
||||
for invoice in self.browse(cr, uid, ids, context=context):
|
||||
local_vals = vals
|
||||
if not invoice.reference:
|
||||
locvals = vals.copy()
|
||||
locvals['reference'] = vals['supplier_invoice_reference']
|
||||
return super(account_invoice, self).write(cr, uid, [invoice.id],
|
||||
locvals, context=context)
|
||||
else:
|
||||
return super(account_invoice, self).write(cr, uid, ids, vals,
|
||||
context=context)
|
||||
|
||||
Reference in New Issue
Block a user