deisy 5 years ago
parent
commit
809a020920
4 changed files with 17 additions and 5 deletions
  1. 1 0
      __openerp__.py
  2. 10 0
      data/data.xml
  3. 1 0
      models/account_invoice.py
  4. 5 5
      views/expense.xml

+ 1 - 0
__openerp__.py

@@ -16,5 +16,6 @@
     ],
     "data": [
         "views/expense.xml",
+        "data/data.xml",
     ],
 }

+ 10 - 0
data/data.xml

@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<openerp>
+    <data>
+        <record id="expenses_journal" model="account.journal">
+            <field name="name">Diario de Gastos</field>
+            <field name="code">GASTO</field>
+            <field name="type">purchase</field>
+        </record>
+    </data>
+</openerp>

+ 1 - 0
models/account_invoice.py

@@ -1,5 +1,6 @@
 # -*- encoding: utf-8 -*-
 from openerp import models, fields, api, _
+from openerp.exceptions import Warning
 
 class account_invoice(models.Model):
     _inherit = "account.invoice"

+ 5 - 5
views/expense.xml

@@ -8,10 +8,10 @@
         <field name="inherit_id" ref="account.invoice_supplier_form"/>
         <field name="arch" type="xml">
           <field name="type" position="after">
-          <field name="is_a_expense" invisible="1"/>
-        </field>
+            <field name="is_a_expense" invisible="1"/>
+          </field>
           <field name="origin" position="replace">
-            <field name="origin" attrs="{'invisible': [('is_a_expense', '=', True)]}"/>
+            <field name="origin" attrs="{'invisible': [('is_a_expense', '=', True)]}" readonly="1"/>
           </field>
         </field>
       </record>
@@ -23,7 +23,7 @@
             <field name="type">ir.actions.act_window</field>
             <field name="res_model">account.invoice</field>
             <field name="view_type">form</field>
-            <field name="view_id" ref="account.invoice_tree"/>
+            <field name="view_id" eval="False"/>
             <field name="view_mode">tree,form</field>
             <field name="context">{'default_type': 'in_invoice', 'type': 'in_invoice', 'journal_type': 'purchase','default_is_a_expense':True,'is_a_expense':True}</field>
             <field name="domain">['|',('origin', 'ilike', 'AA'),('origin', '=', False),('type', '=', 'in_invoice')]</field>
@@ -59,7 +59,7 @@
             <field name="view_mode">tree,form,calendar</field>
             <field eval="False" name="view_id"/>
             <field name="domain">['|',('origin', 'ilike', 'PO'),('origin', '!=', False),('type', '=', 'in_invoice')]</field>
-            <field name="context">{'default_type': 'in_invoice', 'type': 'in_invoice', 'journal_type': 'purchase'}</field>
+            <field name="context">{'default_type': 'in_invoice', 'type': 'in_invoice', 'journal_type': 'purchase', 'default_origin':'PO', 'origin':'PO'}</field>
             <field name="search_view_id" ref="account.view_account_invoice_filter"/>
             <field name="help" type="html">
               <p class="oe_view_nocontent_create">