[MERGE] trunk-editable_list (make SO/PO/invoice/expense lines editable)
authorRaphael Collet <rco@openerp.com>
Tue, 4 Sep 2012 12:34:35 +0000 (14:34 +0200)
committerRaphael Collet <rco@openerp.com>
Tue, 4 Sep 2012 12:34:35 +0000 (14:34 +0200)
bzr revid: rco@openerp.com-20120904123435-lzo9gpaigdrcnsmi

addons/account/account_invoice.py
addons/account/account_invoice_view.xml
addons/hr_expense/hr_expense.py
addons/hr_expense/hr_expense_demo.xml
addons/hr_expense/hr_expense_view.xml
addons/purchase/purchase_view.xml
addons/sale/sale_view.xml
addons/sale_analytic_plans/sale_analytic_plans_view.xml

index 7bc9cea..78ef090 100644 (file)
@@ -1361,10 +1361,16 @@ class account_invoice_line(osv.osv):
         'company_id': fields.related('invoice_id','company_id',type='many2one',relation='res.company',string='Company', store=True, readonly=True),
         'partner_id': fields.related('invoice_id','partner_id',type='many2one',relation='res.partner',string='Partner',store=True)
     }
+
+    def _default_account_id(self, cr, uid, ids, context=None):
+        prop = self.pool.get('ir.property').get(cr, uid, 'property_account_income_categ', 'product.category', context=context)
+        return prop and prop.id or False
+
     _defaults = {
         'quantity': 1,
         'discount': 0.0,
         'price_unit': _price_unit_default,
+        'account_id': _default_account_id,
     }
 
     def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False):
@@ -1473,10 +1479,11 @@ class account_invoice_line(osv.osv):
             prod = self.pool.get('product.product').browse(cr, uid, product, context=context)
             prod_uom = self.pool.get('product.uom').browse(cr, uid, uom, context=context)
             if prod.uom_id.category_id.id != prod_uom.category_id.id:
-                 warning = {
+                warning = {
                     'title': _('Warning!'),
                     'message': _('The selected unit of measure is not compatible with the unit of measure of the product.')
-            }
+                }
+                res['value'].update({'uos_id': prod.uom_id.id})
             return {'value': res['value'], 'warning': warning}
         return res
 
index 143c551..610485e 100644 (file)
                         <page string="Invoice">
                             <field context="{'partner_id': partner_id, 'price_type': 'price_type' in dir() and price_type or False, 'type': type}" name="invoice_line">
                                 <tree string="Invoice lines" editable="bottom">
-                                    <field name="product_id" on_change="product_id_change(product_id, uos_id, quantity, name, parent.type, parent.partner_id, parent.fiscal_position, price_unit, parent.currency_id, context, parent.company_id)"/>
-                                    <field domain="[('company_id', '=', parent.company_id), ('journal_id', '=', parent.journal_id), ('type', '&lt;&gt;', 'view')]" name="account_id" on_change="onchange_account_id(product_id,parent.partner_id,parent.type,parent.fiscal_position,account_id)" groups="base.group_account_user"/>
-                                    <field name="invoice_line_tax_id" view_mode="2" context="{'type':parent.type}" domain="[('parent_id','=',False)]"/>
-                                    <field domain="[('type','&lt;&gt;','view'), ('company_id', '=', parent.company_id), ('parent_id', '!=', False)]" name="account_analytic_id" groups="analytic.group_analytic_accounting"/>
+                                    <field name="product_id"
+                                        on_change="product_id_change(product_id, uos_id, quantity, name, parent.type, parent.partner_id, parent.fiscal_position, price_unit, parent.currency_id, context, parent.company_id)"/>
+                                    <field name="name"/>
+                                    <field name="company_id" groups="base.group_multi_company" readonly="1"/>
+                                    <field name="account_id" groups="account.group_account_user"
+                                        domain="[('company_id', '=', parent.company_id), ('journal_id', '=', parent.journal_id), ('type', '!=', 'view')]"
+                                        on_change="onchange_account_id(product_id, parent.partner_id, parent.type, parent.fiscal_position,account_id)"/>
+                                    <field name="account_analytic_id" groups="analytic.group_analytic_accounting"
+                                        domain="[('type','!=','view'), ('company_id', '=', parent.company_id), ('parent_id', '!=', False)]"/>
                                     <field name="quantity"/>
+                                    <field name="uos_id" groups="product.group_uom"
+                                        on_change="uos_id_change(product_id, uos_id, quantity, name, parent.type, parent.partner_id, parent.fiscal_position, price_unit, parent.currency_id, context, parent.company_id)"/>
                                     <field name="price_unit"/>
+                                    <field name="discount" groups="sale.group_discount_per_so_line"/>
+                                    <field name="invoice_line_tax_id" widget="many2many_tags" context="{'type':parent.type}"
+                                        domain="[('parent_id','=',False),('company_id', '=', parent.company_id)]"/>
                                     <field name="price_subtotal"/>
-                                    <field domain="[('company_id', '=', parent.company_id), ('journal_id', '=', parent.journal_id), ('type', '&lt;&gt;', 'view')]" name="account_id" on_change="onchange_account_id(product_id,parent.partner_id,parent.type,parent.fiscal_position,account_id)" invisible="1"/>
-                                    <!-- Removed if subtotal is set -->
-                                    <field name="name" invisible="1"/>
-                                    <field name="uos_id" invisible="1"/>
                                 </tree>
                             </field>
                             <group class="oe_subtotal_footer oe_right">
                         <page string="Invoice Lines">
                             <field name="invoice_line" nolabel="1" widget="one2many_list" context="{'type': type}">
                                 <tree string="Invoice Lines" editable="bottom">
-                                    <field name="invoice_line_tax_id" invisible="1"/>
-                                    <field name="product_id" />
+                                    <field name="product_id"
+                                        on_change="product_id_change(product_id, uos_id, quantity, name, parent.type, parent.partner_id, parent.fiscal_position, price_unit, parent.currency_id, context, parent.company_id)"/>
                                     <field name="name"/>
+                                    <field name="company_id" groups="base.group_multi_company" readonly="1"/>
                                     <field name="account_id" groups="account.group_account_user"
-                                        domain="[('company_id', '=', parent.company_id), ('journal_id', '=', parent.journal_id), ('type', '&lt;&gt;', 'view')]"
+                                        domain="[('company_id', '=', parent.company_id), ('journal_id', '=', parent.journal_id), ('type', '!=', 'view')]"
                                         on_change="onchange_account_id(product_id, parent.partner_id, parent.type, parent.fiscal_position,account_id)"/>
+                                    <field name="account_analytic_id" groups="analytic.group_analytic_accounting"
+                                        domain="[('type','!=','view'), ('company_id', '=', parent.company_id), ('parent_id', '!=', False)]"/>
                                     <field name="quantity"/>
                                     <field name="uos_id" groups="product.group_uom"
                                         on_change="uos_id_change(product_id, uos_id, quantity, name, parent.type, parent.partner_id, parent.fiscal_position, price_unit, parent.currency_id, context, parent.company_id)"/>
                                     <field name="price_unit"/>
                                     <field name="discount" groups="sale.group_discount_per_so_line"/>
+                                    <field name="invoice_line_tax_id" widget="many2many_tags" context="{'type':parent.type}"
+                                        domain="[('parent_id','=',False),('company_id', '=', parent.company_id)]"/>
                                     <field name="price_subtotal"/>
                                 </tree>
                             </field>
index 594b869..83f986e 100644 (file)
@@ -256,6 +256,10 @@ class hr_expense_line(osv.osv):
         res = dict(cr.fetchall())
         return res
 
+    def _get_uom_id(self, cr, uid, context=None):
+        result = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'product', 'product_uom_unit')
+        return result and result[1] or False
+
     _columns = {
         'name': fields.char('Expense Note', size=128, required=True),
         'date_value': fields.date('Date', required=True),
@@ -264,7 +268,7 @@ class hr_expense_line(osv.osv):
         'unit_amount': fields.float('Unit Price', digits_compute=dp.get_precision('Product Price')),
         'unit_quantity': fields.float('Quantities', digits_compute= dp.get_precision('Product Unit of Measure')),
         'product_id': fields.many2one('product.product', 'Product', domain=[('hr_expense_ok','=',True)]),
-        'uom_id': fields.many2one('product.uom', 'Unit of Measure'),
+        'uom_id': fields.many2one('product.uom', 'Unit of Measure', required=True),
         'description': fields.text('Description'),
         'analytic_account': fields.many2one('account.analytic.account','Analytic account'),
         'ref': fields.char('Reference', size=32),
@@ -273,20 +277,31 @@ class hr_expense_line(osv.osv):
     _defaults = {
         'unit_quantity': 1,
         'date_value': lambda *a: time.strftime('%Y-%m-%d'),
+        'uom_id': _get_uom_id,
     }
     _order = "sequence, date_value desc"
 
-    def onchange_product_id(self, cr, uid, ids, product_id, uom_id, employee_id, context=None):
+    def onchange_product_id(self, cr, uid, ids, product_id, context=None):
         res = {}
         if product_id:
             product = self.pool.get('product.product').browse(cr, uid, product_id, context=context)
             res['name'] = product.name
             amount_unit = product.price_get('standard_price')[product.id]
             res['unit_amount'] = amount_unit
-            if not uom_id:
-                res['uom_id'] = product.uom_id.id
+            res['uom_id'] = product.uom_id.id
         return {'value': res}
 
+    def onchange_uom(self, cr, uid, ids, product_id, uom_id, context=None):
+        res = {'value':{}}
+        if not uom_id or not product_id:
+            return res
+        product = self.pool.get('product.product').browse(cr, uid, product_id, context=context)
+        uom = self.pool.get('product.uom').browse(cr, uid, uom_id, context=context)
+        if uom.category_id.id != product.uom_id.category_id.id:
+            res['warning'] = {'title': _('Warning'), 'message': _('Selected Unit of Measure does not belong to the same category as the product Unit of Measure')}
+            res['value'].update({'uom_id': product.uom_id.id})
+        return res
+
 hr_expense_line()
 
 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
index e1d6b0a..eddaf03 100644 (file)
@@ -11,6 +11,8 @@
             <field name="type">service</field>
             <field name="name">Car Travel Expenses</field>
             <field name="default_code">CarTRA</field>
+            <field name="uom_id" ref="product.product_uom_km"/>
+            <field name="uom_po_id" ref="product.product_uom_km"/>
             <field name="categ_id" ref="hr_expense.cat_expense"/>
             <field name="hr_expense_ok" eval="True" />
             <field name="image">/9j/4AAQSkZJRgABAQEASABIAAD/2wBDAAUDBAQEAwUEBAQFBQUGBwwIBwcHBw8LCwkMEQ8SEhEPERETFhwXExQaFRERGCEYGh0dHx8fExciJCIeJBweHx7/2wBDAQUFBQcGBw4ICA4eFBEUHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh7/wAARCACAAIADASIAAhEBAxEB/8QAHQABAAMBAQEBAQEAAAAAAAAAAAYHCAUEAgMBCf/EAD0QAAEDAwMCBAQDBgILAAAAAAECAwQABREGEiEHMRMiQVEUYXGBCDJCFVKRobHBJHIjJSYzU2JjkqLR8f/EABsBAQADAAMBAAAAAAAAAAAAAAABAgMEBQYH/8QAIREAAgICAgIDAQAAAAAAAAAAAAECEQMxBCESQQUTUWH/2gAMAwEAAhEDEQA/ANl0pSgFKUoBSlKAUpSgFKUoBSlKAUpSgFKUoBSlKAUpSgFKUoBSlKAUpSgFKUPHegFKqHUP4gtE2TXh07LcJgoy29dUry028P04A5SOxXnAPpgE1JI3UITZkQw7HcDbHnkNOTXE4QkrVtTgjKSMlOeQRkcHnFZSUdkWTqlKVYkUpSgFKUoBSlKAUpXE1xMulv0vMm2cxhLZSFgyM+GlORuUrHIATk/b1qG6Vg7ZIHc4qNaj11piwrLM25oXIGR8OwkuuZAzgpTnB5HfFQeTZdYX8PN3i7lCOApiNuc86TlaVHyNp4IAOF9s5zn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wUrSd/BBGQaqbSH4ZpMXWFwumqbquXDYdxbURI53PoyTveSrhJHHlBVznngZ8bMG93VwA/EO5OQOcD7VLrB071LL2nxJDST/wA5FYuTbNVGkTmLo1+2x3E2mTcQpWCpp9tXhukdtxCs/fn6HAxH9W6a1TcoyIqdLvObVBxXguJ8EqxjKUZTtPzxzx6ZBlen+lD6QlU2fIVj08U1OrToe0wkjLfiEeqjmuo5PxHH5E3k7Te69nMw8zJiVLtf0q3T2mtbzGmWZNvh2dKUhLj8p/x3iUgBJQE8oAx23f0AEz0fo692ic7KfujcpTy9ziwVFaz7qJFT+NAiRkgNMoTj2FeoADsK34vx+HjO4Lv9ZTLyJ5dnjulvZuEcsvDIIqA6g6cuvMuIgzlpbUMFlwBxsj22qzx9MVZVK5ybWjjtJ7M63LSeqrE24iHbLctkncRGa8Hce2cDIzUEuX7WhtLjrtT8ZtSysthRUgKPchPYfathuNoWMLSCPmK5Vx05apwIeitkn5VosrRm8SZhjXd7etdmSlTbjSpbyGB5VDgqG4k/5c1ZfS7Ulu05p6JeEwlyQLeqK4I7Sd6XGy45sVglSiUhaxwkDcANxXxd2pOkumb3BchzYTbrDndJ4wfcEcg/MVAJf4aLWp3/AFdqO7QG1DatKFgkj23DB/jmqzm5Oy0IKKozp1h+M1tq9y1W5LLU1UpyZMcS0geCQNjYUtCQpZxkjf5khSQexqeWPSmoLiwz4zTrz+xIccOTuVjk8/OtCaE6KaQ0lEDEGIXFE5cddIUtw+5P9gAKsCFaLfESEsx0JA+VULmdtP8ASC5yilUkbEn3qxLB0itcQJVJAWoVaaUpSMJAFf2gOHa9LWi3pAZit5Hriuw0y02MIQlI+Qr9KUApSlAKUpQClKUApSlAKUpQClKUApSlAKUpQClKUApSlAf/2Q==</field>
index 9978490..5389f88 100644 (file)
@@ -89,7 +89,7 @@
                                 <form string="Expense Lines" version="7.0">
                                     <group>
                                         <group>
-                                            <field name="product_id" on_change="onchange_product_id(product_id, uom_id, parent.employee_id, context)" context="{'default_hr_expense_ok':1}"/>
+                                            <field name="product_id" on_change="onchange_product_id(product_id, context)" context="{'default_hr_expense_ok':1}"/>
                                             <field name="name"/>
                                             <field name="ref"/>
                                             <field domain="[('type','=','normal')]" name="analytic_account" groups="analytic.group_analytic_accounting"/>
                                             <label for="unit_quantity"/>
                                             <div>
                                                 <field name="unit_quantity" class="oe_inline"/> 
-                                                <field name="uom_id" on_change="onchange_product_id(product_id, uom_id, parent.employee_id, context)" class="oe_inline"/>
+                                                <field name="uom_id" on_change="onchange_uom(product_id, uom_id, context)" class="oe_inline"/>
                                             </div>
                                             <field name="date_value" />
                                         </group>
                                     </group>
                                 </form>
+                                <tree string="Expense Lines" editable="bottom">
+                                    <field name="sequence" invisible="1"/>
+                                    <field name="product_id" on_change="onchange_product_id(product_id, context)" context="{'default_hr_expense_ok':1}"/>
+                                    <field name="date_value" string="Expense Date"/>
+                                    <field name="name"/>
+                                    <field name="ref"/>
+                                    <field domain="[('type','in',['normal','contract']), ('parent_id','!=',False)]" name="analytic_account" groups="analytic.group_analytic_accounting"/>
+                                    <field name="uom_id" on_change="onchange_uom(product_id, uom_id, context)"/>
+                                    <field name="unit_amount"/>
+                                    <field name="unit_quantity"/>
+                                    <field name="total_amount" sum="Total"/>
+                                </tree>
                             </field>
                             <group>
                                 <div>
index ba5a3c2..d133e4a 100644 (file)
                     <notebook>
                         <page string="Purchase Order">
                             <field name="order_line">
-                                <tree string="Purchase Order Lines">
-                                    <field name="date_planned"/>
+                                <tree string="Purchase Order Lines" editable="bottom">
+                                    <field name="product_id" on_change="onchange_product_id(parent.pricelist_id,product_id,product_qty,product_uom,parent.partner_id, parent.date_order,parent.fiscal_position,date_planned,name,price_unit,context)"/>
                                     <field name="name"/>
-                                    <field name="product_qty"/>
-                                    <field name="product_uom" groups="product.group_uom"/>
+                                    <field name="date_planned"/>
+                                    <field name="company_id" groups="base.group_multi_company" widget="selection"/>
+                                    <field name="account_analytic_id" groups="purchase.group_analytic_accounting" domain="[('parent_id','!=',False)]"/>
+                                    <field name="product_qty" on_change="onchange_product_id(parent.pricelist_id,product_id,product_qty,product_uom,parent.partner_id,parent.date_order,parent.fiscal_position,date_planned,name,price_unit,context)"/>
+                                    <field name="product_uom" groups="product.group_uom" on_change="onchange_product_uom(parent.pricelist_id,product_id,product_qty,product_uom,parent.partner_id, parent.date_order,parent.fiscal_position,date_planned,name,price_unit,context)"/>
                                     <field name="price_unit"/>
+                                    <field name="taxes_id" widget="many2many_tags" domain="[('parent_id','=',False),('type_tax_use','!=','sale')]"/>
                                     <field name="price_subtotal"/>
                                 </tree>
                             </field>
index a0e69ef..a2f4403 100644 (file)
                                     <field name="sequence" widget="handle"/>
                                     <field name="state" invisible="1"/>
                                     <field name="delay" invisible="1"/>
-                                    <field name="tax_id" invisible="1"/>
-                                    <field name="type" invisible="1"/>
                                     <field name="th_weight" invisible="1"/>
                                     <field name="product_packaging" invisible="1"/>
                                     <field name="product_id"
                                         groups="base.group_user" 
                                         on_change="product_id_change(parent.pricelist_id, product_id, product_uom_qty, product_uom, product_uos_qty, product_uos, name, parent.partner_id, False, True, parent.date_order, False, parent.fiscal_position, False, context)"/>
                                     <field name="name"/>
+                                    <field name="type"/>
                                     <field name="product_uom_qty"
                                         context="{'partner_id':parent.partner_id, 'quantity':product_uom_qty, 'pricelist':parent.pricelist_id, 'shop':parent.shop_id, 'uom':product_uom}"
                                         on_change="product_id_change(parent.pricelist_id, product_id, product_uom_qty, product_uom, product_uos_qty, product_uos, name, parent.partner_id, False, False, parent.date_order, False, parent.fiscal_position, True, context)"/>
                                     <field name="product_uos" string="UoS" groups="product.group_uos"/>
                                     <field name="discount" groups="sale.group_discount_per_so_line"/>
                                     <field name="price_unit"/>
+                                    <field name="tax_id" widget="many2many_tags" domain="[('parent_id','=',False),('type_tax_use','&lt;&gt;','purchase')]"/>
                                     <field name="price_subtotal"/>
                                 </tree>
                             </field>
             </field>
         </record>
 
+        <!-- inherited view to make the order lines list in the form non-editable
+             for the members of some usability groups -->
+        <record id="view_order_form_editable_list" model="ir.ui.view">
+            <field name="name">sale.order.form.editable.list</field>
+            <field name="model">sale.order</field>
+            <field name="inherit_id" ref="sale.view_order_form"/>
+            <field name="groups_id" eval="[(6, 0, [ref('product.group_uos'), ref('product.group_stock_packaging'), ref('sale.group_mrp_properties')])]"/>
+            <field name="arch" type="xml">
+                <xpath expr="//field[@name='order_line']/tree" position="attributes">
+                    <attribute name="editable"/>
+                </xpath>
+            </field>
+        </record>
+
         <record id="view_sales_order_filter" model="ir.ui.view">
             <field name="name">sale.order.list.select</field>
             <field name="model">sale.order</field>
index 6701ede..6c78886 100644 (file)
         </field>
     </record>
 
+    <!-- the presence of 'analytics_id' makes the order lines non-editable -->
+    <record id="sale.view_order_form_editable_list" model="ir.ui.view">
+        <field name="groups_id" eval="[(4, ref('analytic.group_analytic_accounting'))]"/>
+    </record>
+
     <record model="ir.ui.view" id="view_order_line_form2_inherit">
         <field name="name">sale.order.line.form2.inherit</field>
         <field name="model">sale.order.line</field>