[MERGE]
authornel@tinyerp.com <>
Mon, 29 Mar 2010 09:51:38 +0000 (11:51 +0200)
committernel@tinyerp.com <>
Mon, 29 Mar 2010 09:51:38 +0000 (11:51 +0200)
bzr revid: nel@tinyerp.com-20100329095138-wzwgli2t51rchom5

addons/hr_expense/hr_expense.py
addons/hr_expense/hr_expense_view.xml
bin/osv/orm.py

index 3c99276..d474775 100644 (file)
@@ -56,17 +56,17 @@ class hr_expense_expense(osv.osv):
         'id': fields.integer('Sheet ID', readonly=True),
         'ref': fields.char('Reference', size=32),
         'date': fields.date('Date'),
-        'journal_id': fields.many2one('account.journal', 'Force Journal'),
+        'journal_id': fields.many2one('account.journal', 'Force Journal', help = "The journal used when the expense is invoiced"),
         'employee_id': fields.many2one('hr.employee', "Employee's Name", required=True),
         'user_id': fields.many2one('res.users', 'User', required=True),
-        'date_confirm': fields.date('Date Confirmed'),
-        'date_valid': fields.date('Date Validated'),
+        'date_confirm': fields.date('Confirmation Date', help = "Date of the confirmation of the sheet expense. It's filled when the button Confirm is pressed."),
+        'date_valid': fields.date('Validation Date', help = "Date of the acceptation of the sheet expense. It's filled when the button Accept is pressed."),
         'user_valid': fields.many2one('res.users', 'Validation User'),
         'account_move_id': fields.many2one('account.move', 'Ledger Posting'),
         'line_ids': fields.one2many('hr.expense.line', 'expense_id', 'Expense Lines', readonly=True, states={'draft':[('readonly',False)]} ),
         'note': fields.text('Note'),
         'amount': fields.function(_amount, method=True, string='Total Amount'),
-        'invoice_id': fields.many2one('account.invoice', 'Invoice'),
+        'invoice_id': fields.many2one('account.invoice', "Employee's Invoice"),
         'currency_id': fields.many2one('res.currency', 'Currency', required=True),
         'department_id':fields.many2one('hr.department','Department'),
         'company_id': fields.many2one('res.company', 'Company', required=True),
index 16828a8..0cf1b94 100644 (file)
@@ -68,7 +68,7 @@
                     <group colspan="4" col="6">
                         <field name="name" select="1"/>
                         <field name="employee_id" select="1"/>
-                        <field name="id" select="2"/>
+                        <field name="ref" select="2"/>
                         <field name="date" select="1"/>
                         <field name="amount"/>
                         <field name="currency_id"/>
@@ -77,7 +77,6 @@
                     </group>
                     <notebook colspan="4">
                         <page string="Expense Sheet">
-                            <field name="ref" select="2"/>
                             <newline/>
                             <field colspan="4" name="line_ids" nolabel="1">
                                 <form string="Expense Lines">
                             <separator colspan="4" string="Accounting data"/>
                             <field name="journal_id"/>
                             <separator colspan="4" string="Validation"/>
-                            <field name="date_confirm" select="2"/>
-                            <field name="date_valid" select="2"/>
+                            <field name="date_confirm" select="2" readonly = "1"/>
+                            <field name="date_valid" select="2" readonly = "1"/>
                             <field name="user_valid" select="2"/>
                             <field name="invoice_id" select="2"/>
                             <separator colspan="4" string="Notes"/>
                         help="Expenses to Invoice"/>
                       <separator orientation="vertical"/>
                       <field name="name" select='1'/>
+                      <field name="date" select='1'/>
                       <field name="user_id" select="1" widget="selection">
                           <filter
                             icon="gtk-execute"
index 165b9a2..fcdf304 100644 (file)
@@ -69,6 +69,15 @@ from tools.config import config
 
 regex_order = re.compile('^(([a-z0-9_]+|"[a-z0-9_]+")( *desc| *asc)?( *, *|))+$', re.I)
 
+
+POSTGRES_CONFDELTYPES = {
+    'RESTRICT': 'r',
+    'NO ACTION': 'a',
+    'CASCADE': 'c',
+    'SET NULL': 'n',
+    'SET DEFAULT': 'd',
+}
+
 def last_day_of_current_month():
     today = datetime.date.today()
     last_day = str(calendar.monthrange(today.year, today.month)[1])
@@ -2277,14 +2286,7 @@ class orm(orm_template):
                                                 "AND con.contype = 'f'", (self._table, ref, k, 'id'))
                                     res = cr.dictfetchall()
                                     if res:
-                                        confdeltype = {
-                                            'RESTRICT': 'r',
-                                            'NO ACTION': 'a',
-                                            'CASCADE': 'c',
-                                            'SET NULL': 'n',
-                                            'SET DEFAULT': 'd',
-                                        }
-                                        if res[0]['confdeltype'] != confdeltype.get(f.ondelete.upper(), 'a'):
+                                        if res[0]['confdeltype'] != POSTGRES_CONFDELTYPES.get(f.ondelete.upper(), 'a'):
                                             cr.execute('ALTER TABLE "' + self._table + '" DROP CONSTRAINT "' + res[0]['conname'] + '"')
                                             cr.execute('ALTER TABLE "' + self._table + '" ADD FOREIGN KEY ("' + k + '") REFERENCES "' + ref + '" ON DELETE ' + f.ondelete)
                                             cr.commit()