[VIEW] ~account_analytic field is mandatory and filter in account invoice form
authorLudovic CHEVALIER <ludovic.chevalier@heureux-cyclage.org>
Wed, 27 May 2015 09:52:05 +0000 (11:52 +0200)
committerLudovic CHEVALIER <ludovic.chevalier@heureux-cyclage.org>
Wed, 27 May 2015 09:52:05 +0000 (11:52 +0200)
__openerp__.py
view/account_invoice_view.xml [new file with mode: 0644]

index f7d782c..28f0e31 100644 (file)
@@ -34,18 +34,21 @@ Account analytic module improvement
 
 It installs the profile for bike co-ops to manage some features like:
     * Analytic account is mandatory, and is filter (normal, with code and open only) in:
 
 It installs the profile for bike co-ops to manage some features like:
     * Analytic account is mandatory, and is filter (normal, with code and open only) in:
-        * expense form view
+        * expense form view;
+        * account invoice form view.
     * ...
     """,
     'website': 'http://www.heureux-cyclage.org',
     'images': [],
     'depends': [
     * ...
     """,
     'website': 'http://www.heureux-cyclage.org',
     'images': [],
     'depends': [
+        'account',
         'analytic',
         'hr_expense',
     ],
     'init_xml': [
     ],
     'update_xml': [
         'analytic',
         'hr_expense',
     ],
     'init_xml': [
     ],
     'update_xml': [
+        'view/account_invoice_view.xml',
         'view/hr_expense.xml',
     ],
     'installable': True,
         'view/hr_expense.xml',
     ],
     'installable': True,
diff --git a/view/account_invoice_view.xml b/view/account_invoice_view.xml
new file mode 100644 (file)
index 0000000..04acc9b
--- /dev/null
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<openerp>
+    <data>
+        <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="//field[@name='account_analytic_id']" position="attributes">
+                    <attribute name="required">1</attribute>
+                </xpath>
+                <xpath expr="//tree/field[@name='account_analytic_id']" position="replace">
+                    <field name="account_analytic_id" domain="[('type', '=', 'normal'), ('company_id', '=', parent.company_id), ('code', '!=', 'False'), ('state', '=', 'open')]" required="1" />
+                </xpath>
+            </field>
+        </record>
+    </data>
+</openerp>