diff --git a/addons/account_analytic_analysis/res_config.py b/addons/account_analytic_analysis/res_config.py index 90e3cff01fb245954fee1bdb599dc45169982397..129d759ab4a7c545fcee6c476bedfd89595d2bca 100644 --- a/addons/account_analytic_analysis/res_config.py +++ b/addons/account_analytic_analysis/res_config.py @@ -20,6 +20,7 @@ ############################################################################## from openerp.osv import fields, osv +from openerp.tools.translate import _ class sale_configuration(osv.osv_memory): _inherit = 'sale.config.settings' @@ -28,4 +29,36 @@ class sale_configuration(osv.osv_memory): 'group_template_required': fields.boolean("Mandatory use of templates.", implied_group='account_analytic_analysis.group_template_required', help="Allows you to set the template field as required when creating an analytic account or a contract."), + 'time_unit': fields.many2one('product.uom', 'The default working time unit.'), } + + def default_get(self, cr, uid, fields, context=None): + ir_model_data = self.pool.get('ir.model.data') + res = super(sale_configuration, self).default_get(cr, uid, fields, context) + if res.get('module_project'): + user = self.pool.get('res.users').browse(cr, uid, uid, context) + res['time_unit'] = user.company_id.project_time_mode_id.id + else: + product = ir_model_data.xmlid_to_object(cr, uid, 'product.product_product_consultant') + if product and product.exists(): + res['time_unit'] = product.uom_id.id + res['timesheet'] = res.get('module_account_analytic_analysis') + return res + + def set_sale_defaults(self, cr, uid, ids, context=None): + ir_model_data = self.pool.get('ir.model.data') + wizard = self.browse(cr, uid, ids)[0] + + if wizard.time_unit: + product = ir_model_data.xmlid_to_object(cr, uid, 'product.product_product_consultant') + if product and product.exists(): + product.write({'uom_id': wizard.time_unit.id, 'uom_po_id': wizard.time_unit.id}) + else: + _logger.warning("Product with xml_id 'product.product_product_consultant' not found, UoMs not updated!") + + if wizard.module_project and wizard.time_unit: + user = self.pool.get('res.users').browse(cr, uid, uid, context) + user.company_id.write({'project_time_mode_id': wizard.time_unit.id}) + res = super(sale_configuration, self).set_sale_defaults(cr, uid, ids, context) + return res + diff --git a/addons/account_analytic_analysis/res_config_view.xml b/addons/account_analytic_analysis/res_config_view.xml index 9c7881f2a9ea1e1aafa40abd8d165e4abf454887..7ef1bce70a6bdd734c7e3524b4f604458605fc16 100644 --- a/addons/account_analytic_analysis/res_config_view.xml +++ b/addons/account_analytic_analysis/res_config_view.xml @@ -13,6 +13,12 @@ <label for="group_template_required"/> </div> </xpath> + <xpath expr="//div[@name='div_default_options']" position="inside"> + <div name='time_unit' attrs="{'required':[('module_account_analytic_analysis','=',True)]}"> + <label for="time_unit"/> + <field name="time_unit" domain="[('category_id.name','=','Working Time')]" class="oe_inline"/> + </div> + </xpath> </field> </record> diff --git a/addons/hr_timesheet/hr_timesheet_data.xml b/addons/hr_timesheet/hr_timesheet_data.xml index db324ab0ffd08e6d730e7b3b6456f993a2eb462e..69677b08a3c944da28130370e709ec0ea8bd911d 100644 --- a/addons/hr_timesheet/hr_timesheet_data.xml +++ b/addons/hr_timesheet/hr_timesheet_data.xml @@ -8,13 +8,23 @@ <field name="type">general</field> </record> - <record id="hr.employee" model="hr.employee"> - <field name="journal_id" ref="analytic_journal"/> - </record> + <!-- Service Product --> <record id="product.product_product_consultant" model="product.product"> <field name="sale_ok">True</field> + <field name="list_price">75.0</field> + <field name="standard_price">30.0</field> + <field name="uom_id" ref="product.product_uom_hour"/> + <field name="uom_po_id" ref="product.product_uom_hour"/> + <field name="name">Service</field> + <field name="categ_id" ref="product.product_category_all"/> + <field name="type">service</field> + <field name="image" type="base64" file="hr_timesheet/static/img/product_product_consultant-image.jpg"/> </record> + <record id="hr.employee" model="hr.employee"> + <field name="journal_id" ref="analytic_journal"/> + <field name="product_id" ref="product.product_product_consultant"/> + </record> </data> </openerp> diff --git a/addons/hr_timesheet/hr_timesheet_demo.xml b/addons/hr_timesheet/hr_timesheet_demo.xml index d035dc9b003192fe8db28fd2a1d11b3cd4532585..7867463415ee44213150fd0bfbf56d029a5ca45b 100644 --- a/addons/hr_timesheet/hr_timesheet_demo.xml +++ b/addons/hr_timesheet/hr_timesheet_demo.xml @@ -2,10 +2,6 @@ <openerp> <data noupdate="1"> - <record id="hr.employee" model="hr.employee"> - <field name="product_id" ref="product.product_product_consultant"/> - <field name="journal_id" ref="analytic_journal"/> - </record> <!-- complete our example employee --> <record id="hr.employee_fp" model="hr.employee"> @@ -89,6 +85,10 @@ <field name="general_account_id" ref="account.a_expense"/> <field name="journal_id" ref="analytic_journal"/> </record> + + <record id="product.product_product_consultant" model="product.product"> + <field name="categ_id" ref="product.product_category_5"/> + </record> </data> </openerp> diff --git a/addons/product/static/img/product_product_consultant-image.jpg b/addons/hr_timesheet/static/img/product_product_consultant-image.jpg similarity index 100% rename from addons/product/static/img/product_product_consultant-image.jpg rename to addons/hr_timesheet/static/img/product_product_consultant-image.jpg diff --git a/addons/hr_timesheet/test/test_hr_timesheet.yml b/addons/hr_timesheet/test/test_hr_timesheet.yml index 4f0cd11911faa72fe43b3bab2284241e562aa1a5..3da29d296776d7ac3038e365368729c07371c2f2 100644 --- a/addons/hr_timesheet/test/test_hr_timesheet.yml +++ b/addons/hr_timesheet/test/test_hr_timesheet.yml @@ -14,6 +14,8 @@ name: Gilles Gravie parent_id: 'hr.employee_al' user_id: 'base.user_demo' + product_id: product.product_product_consultant + journal_id: hr_timesheet.analytic_journal - Give the access rights of Employee to Sign In/Sign Out in Project. - diff --git a/addons/product/product_data.xml b/addons/product/product_data.xml index 404c093f8fa098c9a523a20ae5b4dbd5532df75a..56f75060f0afd53fcceea652e2b43b024f9d3787 100644 --- a/addons/product/product_data.xml +++ b/addons/product/product_data.xml @@ -241,20 +241,5 @@ parameter) will see those record just disappear. <field eval="'product.pricelist,'+str(ref('list0'))" name="value"/> </record> - - <!-- - Product - --> - <record id="product_product_consultant" model="product.product"> - <field name="list_price">75.0</field> - <field name="standard_price">30.0</field> - <field name="uom_id" ref="product.product_uom_hour"/> - <field name="uom_po_id" ref="product.product_uom_hour"/> - <field name="name">Service</field> - <field name="categ_id" ref="product.product_category_all"/> - <field name="type">service</field> - <field name="sale_ok" eval="False"/> - </record> - </data> </openerp> diff --git a/addons/product/product_demo.xml b/addons/product/product_demo.xml index 093a25b2e23efc0e7fea9f20c017fe2bb0bd3b0b..7a4d97410ab988d1d555f43e18a2d24e84a62c21 100644 --- a/addons/product/product_demo.xml +++ b/addons/product/product_demo.xml @@ -84,10 +84,6 @@ Resource: product.product --> - <record id="product_product_consultant" model="product.product"> - <field name="categ_id" ref="product.product_category_5"/> - <field name="sale_ok" eval="True"/> - </record> <record id="product_product_1" model="product.product"> <field name="name">On Site Monitoring</field> diff --git a/addons/product/product_image_demo.xml b/addons/product/product_image_demo.xml index 697b31394c016888472fa8323e3f80d8daee9f90..bb26ceeb91585d48b01ee2e0c5317cf07cf244c2 100644 --- a/addons/product/product_image_demo.xml +++ b/addons/product/product_image_demo.xml @@ -2,10 +2,6 @@ <openerp> <data noupdate="false"> - <record id="product_product_consultant" model="product.product"> - <field name="image" type="base64" file="product/static/img/product_product_consultant-image.jpg"/> - </record> - <record id="product_product_1" model="product.product"> <field name="image" type="base64" file="product/static/img/product_product_1-image.jpg"/> </record> diff --git a/addons/purchase/purchase_demo.xml b/addons/purchase/purchase_demo.xml index 55d58669fd4b18303725e622ad3225a7f21b51ed..e67e10e9eae77349ebd50def18cc088a4408dc5d 100644 --- a/addons/purchase/purchase_demo.xml +++ b/addons/purchase/purchase_demo.xml @@ -13,10 +13,6 @@ <field eval="1.0" name="po_lead"/> </record> - <record id="product.product_product_consultant" model="product.product"> - <field eval="False" name="purchase_ok"/> - </record> - <record id="product.product_product_48" model="product.product"> <field name="route_ids" eval="[(4,ref('route_warehouse0_buy'))]"></field> </record> diff --git a/addons/sale/res_config.py b/addons/sale/res_config.py index e084d6494b2747db55955b0e73fd1e4cb1906745..481892d90c18cb76417a5ff68e5e74380b222d89 100644 --- a/addons/sale/res_config.py +++ b/addons/sale/res_config.py @@ -44,7 +44,6 @@ class sale_configuration(osv.TransientModel): '(650€/day for a developer), the duration (one year support contract).\n' 'You will be able to follow the progress of the contract and invoice automatically.\n' '-It installs the account_analytic_analysis module.'), - 'time_unit': fields.many2one('product.uom', 'The default working time unit for services is'), 'group_sale_pricelist':fields.boolean("Use pricelists to adapt your price per customers", implied_group='product.group_sale_pricelist', help="""Allows to manage different prices based on rules per category of customers. @@ -83,41 +82,7 @@ Example: 10% for retailers, promotion of 5 EUR on this product, etc."""), help="Allows you to specify different delivery and invoice addresses on a sales order."), } - def default_get(self, cr, uid, fields, context=None): - ir_model_data = self.pool.get('ir.model.data') - res = super(sale_configuration, self).default_get(cr, uid, fields, context) - if res.get('module_project'): - user = self.pool.get('res.users').browse(cr, uid, uid, context) - res['time_unit'] = user.company_id.project_time_mode_id.id - else: - product = ir_model_data.xmlid_to_object(cr, uid, 'product.product_product_consultant') - if product and product.exists(): - res['time_unit'] = product.uom_id.id - res['timesheet'] = res.get('module_account_analytic_analysis') - return res - - def _get_default_time_unit(self, cr, uid, context=None): - ids = self.pool.get('product.uom').search(cr, uid, [('name', '=', _('Hour'))], context=context) - return ids and ids[0] or False - - _defaults = { - 'time_unit': _get_default_time_unit, - } - def set_sale_defaults(self, cr, uid, ids, context=None): - ir_model_data = self.pool.get('ir.model.data') - wizard = self.browse(cr, uid, ids)[0] - - if wizard.time_unit: - product = ir_model_data.xmlid_to_object(cr, uid, 'product.product_product_consultant') - if product and product.exists(): - product.write({'uom_id': wizard.time_unit.id, 'uom_po_id': wizard.time_unit.id}) - else: - _logger.warning("Product with xml_id 'product.product_product_consultant' not found, UoMs not updated!") - - if wizard.module_project and wizard.time_unit: - user = self.pool.get('res.users').browse(cr, uid, uid, context) - user.company_id.write({'project_time_mode_id': wizard.time_unit.id}) return {} def onchange_task_work(self, cr, uid, ids, task_work, context=None): diff --git a/addons/sale/res_config_view.xml b/addons/sale/res_config_view.xml index e499af7e5e87e615882c5a08930280c2bc7d3b74..5375120675052aadfee5d6d05c575c8500801abe 100644 --- a/addons/sale/res_config_view.xml +++ b/addons/sale/res_config_view.xml @@ -22,13 +22,8 @@ </div> </group> <group name='default_options'> - <label for="id" string="Default Options" attrs="{'invisible':[('module_account_analytic_analysis','=',False)]}"/> - <div> - <div name='time_unit' attrs="{'invisible': [('module_account_analytic_analysis','=',False)],'required':[('module_account_analytic_analysis','=',True)]}"> - <label for="time_unit"/> - <field name="time_unit" domain="[('category_id.name','=','Working Time')]" class="oe_inline"/> - </div> - </div> + <label for="id" string="Default Options"/> + <div name="div_default_options"/> </group> </div> <div name="Customer Features" position="inside"> diff --git a/addons/sale/sale_demo.xml b/addons/sale/sale_demo.xml index 1176d0792a90c7913594a3781431aff9377e148d..ddd205f2d594e94c859fbc8be6667b6f40da59ae 100644 --- a/addons/sale/sale_demo.xml +++ b/addons/sale/sale_demo.xml @@ -66,7 +66,7 @@ <record id="sale_order_line_4" model="sale.order.line"> <field name="order_id" ref="sale_order_2"/> <field name="name">Service on demand</field> - <field name="product_id" ref="product.product_product_consultant"/> + <field name="product_id" ref="product.product_product_1"/> <field name="product_uom_qty">24</field> <field name="product_uos_qty">24</field> <field name="product_uom" ref="product.product_uom_hour"/> @@ -125,7 +125,7 @@ <record id="sale_order_line_8" model="sale.order.line"> <field name="order_id" ref="sale_order_4"/> <field name="name">Service on demand</field> - <field name="product_id" ref="product.product_product_consultant"/> + <field name="product_id" ref="product.product_product_1"/> <field name="product_uom_qty">16</field> <field name="product_uos_qty">16</field> <field name="product_uom" ref="product.product_uom_hour"/> diff --git a/addons/sale_stock/res_config_view.xml b/addons/sale_stock/res_config_view.xml index a94d94c27d2a91460d39791aa90d0d79f75ae2e5..c68943ff7e67e45f4f2d42dbb937207b8ce9e3c5 100644 --- a/addons/sale_stock/res_config_view.xml +++ b/addons/sale_stock/res_config_view.xml @@ -23,10 +23,7 @@ <label for="task_work"/> </div> </xpath> - <xpath expr="//label[@string='Default Options']" position="replace"> - <label for="id" string="Default Options"/> - </xpath> - <xpath expr="//div[@name='time_unit']" position="before"> + <xpath expr="//div[@name='div_default_options']" position="inside"> <div attrs="{'invisible':['|',('group_invoice_so_lines','=',False),('group_invoice_deli_orders','=',False)],'required': ['|',('group_invoice_so_lines','=',True),('group_invoice_deli_orders','=',True)]}"> <field name="default_order_policy" class="oe_inline" widget="radio"/> </div> @@ -54,12 +51,6 @@ <field name="group_invoice_so_lines" position="replace"> <field name="group_invoice_so_lines" on_change="onchange_invoice_methods(group_invoice_so_lines, group_invoice_deli_orders)" class="oe_inline"/> </field> - <xpath expr="//div[@name='time_unit']" position="replace"> - <div attrs="{'invisible': [('task_work','=',False), ('module_account_analytic_analysis','=',False)],'required': ['|', ('task_work','=',True), ('module_account_analytic_analysis','=',True)]}"> - <label for="time_unit"/> - <field name="time_unit" domain="[('category_id.name','=','Working Time')]" class="oe_inline"/> - </div> - </xpath> <xpath expr="//div[@name='Sale Features']" position="inside"> <div> <field name="group_route_so_lines" class="oe_inline"/> diff --git a/addons/website_sale/data/demo.xml b/addons/website_sale/data/demo.xml index 9b72228ffbeda6b25ec3f6a673e9cba63f1aa261..b6d00152f6876e8c540527fb5b4392b7bb8e6123 100644 --- a/addons/website_sale/data/demo.xml +++ b/addons/website_sale/data/demo.xml @@ -2,9 +2,6 @@ <openerp> <data noupdate="1"> - <record id="product.product_product_consultant" model="product.product"> - <field name="image" type="base64" file="website/static/description/website_edit.png"/> - </record> <record id="product.product_attribute_2" model="product.attribute"> <field name="type">color</field>