changes to the invoices views: always display the description, copy the supplier invoice number in ref. document the module

This commit is contained in:
Guewen Baconnier
2014-01-24 15:03:51 +01:00
parent c52a975357
commit 84678c368f
3 changed files with 135 additions and 20 deletions

View File

@@ -32,30 +32,100 @@
Invoices Reference Invoices Reference
================== ==================
Aims to simplify the "references" things on the invoices. There is too Aims to simplify the "references" fields on the invoices.
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.
Is follows this rule: the reference of a journal entry is We observed difficulties for the users to file the references (name,
always the reference of the document which generated it to origin, free reference) and above all, to understand which field will be
be able to trace them in the accounting reports. That means the origin copied in the reference field of the move and move lines.
of an invoice or if the invoice has been created manually without origin,
its number. 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 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 Enumerating the information we need in an invoice, we find that the
Journal Entry Reference is the Origin of the invoice if there, mandatory fields are:
otherwise, it is the Number of the invoice.
Supplier invoices * Invoice Number
Journal Entry Reference is the Supplier Invoice Number of the invoice * Description
which is now mandatory. * 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', 'website': 'http://www.camptocamp.com',

View File

@@ -13,14 +13,37 @@
<xpath expr="/form/sheet/notebook/page[@string='Other Info']//field[@name='name']" <xpath expr="/form/sheet/notebook/page[@string='Other Info']//field[@name='name']"
position="replace"> position="replace">
</xpath> </xpath>
<field name="reference" position="after"> <field name="reference_type" position="after">
<field name="name" class="oe_inline" <label string="Enter the reference in the Supplier Invoice Number field"
class="oe_inline"
attrs="{'invisible': [('reference_type', '!=', 'none')]}"/> attrs="{'invisible': [('reference_type', '!=', 'none')]}"/>
</field> </field>
<field name="reference" position="attributes"> <field name="reference" position="attributes">
<attribute name="attrs">{'invisible': [('reference_type', '=', 'none')]}</attribute> <attribute name="attrs">{'invisible': [('reference_type', '=', 'none')]}</attribute>
</field> </field>
<xpath expr="//field[@name='reference_type']/parent::div" position="after">
<field name="name"/>
</xpath>
</field> </field>
</record> </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> </data>
</openerp> </openerp>

View File

@@ -75,3 +75,25 @@ class account_invoice(orm.Model):
'AND account_analytic_line.move_id = account_move_line.id', 'AND account_analytic_line.move_id = account_move_line.id',
(ref, move_id)) (ref, move_id))
return True 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)