← Back to team overview

openerp-community-reviewer team mailing list archive

[Merge] lp:~jb.eficent/department-mgmt/department-mgmt-bugfixes_analytic into lp:department-mgmt

 

JB (eficent.com) has proposed merging lp:~jb.eficent/department-mgmt/department-mgmt-bugfixes_analytic into lp:department-mgmt.

Requested reviews:
  Department Core Editors (department-core-editors)
Related bugs:
  Bug #1296109 in Department Management: "Not possible to add the department to an analytic account"
  https://bugs.launchpad.net/department-mgmt/+bug/1296109
  Bug #1296119 in Department Management: "Department is not being defaulted when the analytic lines are created"
  https://bugs.launchpad.net/department-mgmt/+bug/1296119

For more details, see:
https://code.launchpad.net/~jb.eficent/department-mgmt/department-mgmt-bugfixes_analytic/+merge/212299

Fixes bugs 1296119, 1296109
-- 
https://code.launchpad.net/~jb.eficent/department-mgmt/department-mgmt-bugfixes_analytic/+merge/212299
Your team Department Core Editors is requested to review the proposed merge of lp:~jb.eficent/department-mgmt/department-mgmt-bugfixes_analytic into lp:department-mgmt.
=== modified file 'analytic_department/__openerp__.py'
--- analytic_department/__openerp__.py	2013-03-04 16:36:08 +0000
+++ analytic_department/__openerp__.py	2014-03-22 20:25:34 +0000
@@ -10,6 +10,6 @@
 corresponding tree, search and form  views.
 """,
     "website": "http://camptocamp.com";,
-    "depends": ["account", "hr"],
+    "depends": ["account", "hr", "analytic"],
     "data": ["analytic_view.xml"],
 }

=== modified file 'analytic_department/analytic.py'
--- analytic_department/analytic.py	2013-03-04 16:36:08 +0000
+++ analytic_department/analytic.py	2014-03-22 20:25:34 +0000
@@ -11,6 +11,18 @@
 
 class AnalyticLine(orm.Model):
     _inherit = "account.analytic.line"
+    
+    def _get_department(self, cr, uid, ids, context=None):
+        
+        department_id = None
+        if context:
+            account_id = context.get('account_id', False),
+            analytic_account = self.pool.get('account.analytic.account').browse(cr, uid, account_id, context=context)            
+            department_id = analytic_account.department_id.id or None
+        
+        return department_id    
+            
     _columns = {
-        'department_id': fields.many2one('hr.department', 'Department'),
-    }
+        'department_id': fields.related('account_id', 'department_id', type="many2one", relation='hr.department', store=True,
+                string="Department", readonly=True),
+    }
\ No newline at end of file

=== modified file 'analytic_department/analytic_view.xml'
--- analytic_department/analytic_view.xml	2013-03-04 16:36:08 +0000
+++ analytic_department/analytic_view.xml	2014-03-22 20:25:34 +0000
@@ -27,6 +27,17 @@
             </field>
         </record>
         
+        <record id="view_account_analytic_account_form" model="ir.ui.view">
+            <field name="name">account.analytic.account.form</field>
+            <field name="model">account.analytic.account</field>
+            <field name="inherit_id" ref="analytic.view_account_analytic_account_form"/>
+            <field name="arch" type="xml">
+                <field name="code" position="after">
+                    <field name="department_id"/>
+                </field>
+            </field>
+        </record>        
+        
         <record id="view_account_analytic_line_form" model="ir.ui.view">
             <field name="name">account.analytic.line.form</field>
             <field name="model">account.analytic.line</field>


Follow ups