Turkesh Patel (openERP) has proposed merging 
lp:~openerp-dev/openobject-addons/trunk-v62_account_chart-tpa into 
lp:~openerp-dev/openobject-addons/trunk-v62_config_account-uco.

Requested reviews:
  Ujjvala Collins (OpenERP) (uco-openerp)

For more details, see:
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-v62_account_chart-tpa/+merge/97820

Account

===============================================

--> improved code for new configuration wizard
-- 
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-v62_account_chart-tpa/+merge/97820
Your team OpenERP R&D Team is subscribed to branch 
lp:~openerp-dev/openobject-addons/trunk-v62_config_account-uco.
=== modified file 'account/account_view.xml'
--- account/account_view.xml	2012-03-09 10:38:12 +0000
+++ account/account_view.xml	2012-03-16 09:40:26 +0000
@@ -2505,15 +2505,6 @@
            <field name="name">New Company Financial Setting</field>
         </record>
 
-
-        <record id="menu_act_ir_actions_bleble" model="ir.ui.menu">
-            <field name="name">New Company Financial Setting</field>
-            <field eval="1" name="sequence"/>
-            <field name="parent_id" ref="account.menu_finance_accounting"/>
-            <field name="icon">STOCK_EXECUTE</field>
-            <field name="action" ref="ir_actions_server_action_wizard_multi_chart"/>
-        </record>
-
         <record id="account_account_graph" model="ir.ui.view">
             <field name="name">account.account.graph</field>
             <field name="model">account.account</field>

=== modified file 'account/res_config.py'
--- account/res_config.py	2012-03-13 10:05:58 +0000
+++ account/res_config.py	2012-03-16 09:40:26 +0000
@@ -51,8 +51,6 @@
     _columns = {
             'company_id': fields.many2one('res.company', 'Company',help="Your company."),
             'currency_id': fields.related('company_id', 'currency_id', type='many2one', relation='res.currency', string='Currency', store=True, help="Currency of your company."),
-            'default_taxes_id': fields.float('Default Sale Tax', default_model='product.template'),
-            'default_supplier_taxes_id': fields.float('Default Purchase Tax', default_model='product.template'),
             'charts': fields.selection(_get_charts, 'Chart of Accounts',
                                         required=True,
                                         help="Installs localized accounting charts to match as closely as "
@@ -134,6 +132,13 @@
                                                        "It will add the group 'Allow dates and periods' for all users."),
             'group_proforma_invoices': fields.boolean('Allow Pro-forma Invoices', group='base.group_user', implied_group='base.group_proforma_invoices',
                                                       help="Allows you to put invoice in pro-forma state. It assigns 'Allow Pro-forma Invoices' group to all employees."),
+
+            'multi_charts_id':fields.many2one('wizard.multi.charts.accounts', 'Multi charts accounts'),
+            'taxes_id':fields.many2one('account.tax.template', 'Default Sale Tax'),
+            'supplier_taxes_id':fields.many2one('account.tax.template', 'Default Purchase Tax'),
+            'sale_tax_rate': fields.float('Sales Tax(%)'),
+            'purchase_tax_rate': fields.float('Purchase Tax(%)'),
+            'complete_tax_set': fields.boolean('Complete Set of Taxes'),
     }
     def _default_company(self, cr, uid, context=None):
         user = self.pool.get('res.users').browse(cr, uid, uid, context=context)
@@ -162,6 +167,19 @@
                 taxes.update({'supplier_taxes_id': tax[2]})
         return taxes
 
+    def set_tax_defaults(self, cr, uid, ids, context=None):
+        ir_values_obj = self.pool.get('ir.values')
+
+        res = {}
+        wizard = self.browse(cr, uid, ids)[0]
+        if wizard.taxes_id.id:
+            ir_values_obj.set_default(cr, uid, 'product.template', 'taxes_id', wizard.taxes_id.id )
+
+        if wizard.supplier_taxes_id.id:
+            ir_values_obj.set_default(cr, uid, 'product.template', 'supplier_taxes_id', wizard.supplier_taxes_id.id )
+
+        return res
+
     def default_get(self, cr, uid, fields_list, context=None):
         ir_values_obj = self.pool.get('ir.values')
         chart_template_obj = self.pool.get('account.chart.template')
@@ -189,26 +207,30 @@
                     res.update({'purchase_refund_journal_id': journal.id})
 
         if chart_template_ids:
+            data = chart_template_obj.browse(cr, uid, chart_template_ids[0], context=context)
+            res.update({'complete_tax_set': data.complete_tax_set})
+            supplier_taxes_id = ir_values_obj.get_default(cr, uid, 'product.template', 'supplier_taxes_id')
+            res.update({'supplier_taxes_id': supplier_taxes_id})
+            taxes_id = ir_values_obj.get_default(cr, uid, 'product.template', 'taxes_id')
+            res.update({'chart_template_id': taxes_id})
             res.update({'chart_template_id': chart_template_ids[0]})
+
         if fiscalyear_ids:
             res.update({'fiscalyear_id': fiscalyear_ids[0]})
         if taxes:
-            sale_tax_id = taxes.get('taxes_id')
-            res.update({'default_taxes_id': isinstance(sale_tax_id,list) and sale_tax_id[0] or sale_tax_id}) 
-            purchase_tax_id = taxes.get('supplier_taxes_id')
-            res.update({'default_supplier_taxes_id': isinstance(purchase_tax_id,list) and purchase_tax_id[0] or purchase_tax_id})
+            if chart_template_ids:
+                sale_tax_id = taxes.get('taxes_id')
+                res.update({'taxes_id': isinstance(sale_tax_id,list) and sale_tax_id[0] or sale_tax_id})
+                purchase_tax_id = taxes.get('supplier_taxes_id')
+                res.update({'supplier_taxes_id': isinstance(purchase_tax_id,list) and purchase_tax_id[0] or purchase_tax_id})
         else:
-            res.update({'default_taxes_id': 15.0, 'default_supplier_taxes_id': 15.0})
+            res.update({'sale_tax_rate': 15.0, 'purchase_tax_rate': 15.0})
         return res
 
     def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False):
         ir_values_obj = self.pool.get('ir.values')
         res = super(account_configuration, self).fields_view_get(cr, uid, view_id, view_type, context, toolbar, submenu)
         cmp_select = []
-        if self._check_default_tax(cr, uid, context):
-            if res['fields'].get('default_taxes_id') and res['fields'].get('default_supplier_taxes_id'):
-                res['fields']['default_taxes_id'] = {'domain': [('type_tax_use','=','sale')], 'views': {}, 'context': {}, 'selectable': True, 'type': 'many2one', 'relation': 'account.tax', 'string': 'Default Sale Tax'}
-                res['fields']['default_supplier_taxes_id'] = {'domain': [('type_tax_use','=','purchase')], 'views': {}, 'context': {}, 'selectable': True, 'type': 'many2one', 'relation': 'account.tax', 'string': 'Default Purchase Tax'}
         # display in the widget selection only the companies that haven't been configured yet
         unconfigured_cmp = self.get_unconfigured_cmp(cr, uid, context=context)
         for field in res['fields']:
@@ -241,8 +263,18 @@
             return {'value': {'date_stop': end_date.strftime('%Y-%m-%d')}}
         return {}
 
+    def on_change_company_id(self, cr, uid, id, company_id=False):
+        company_obj = self.pool.get('res.company')
+        currency_id = company_obj.browse(cr, uid, company_id).currency_id
+        return {'value': {'currency_id': currency_id.id}}
+
     def install_chartofaccounts(self, cr, uid, ids, context=None):
         ir_module = self.pool.get('ir.module.module')
+        multi_chart_obj = self.pool.get('wizard.multi.charts.accounts')
+        chart_template_obj = self.pool.get('account.chart.template')
+        tax_templ_obj = self.pool.get('account.tax.template')
+
+        data = self.read(cr, uid, ids, context=context)[0]
         if context is None:
             context = {}
         for res in self.read(cr, uid, ids, context=context):
@@ -257,6 +289,13 @@
                 if mod_ids and ir_module.browse(cr, uid, mod_ids[0], context).state == 'uninstalled':
                     ir_module.button_immediate_install(cr, uid, mod_ids, context)
 
+        chart_template_ids = chart_template_obj.search(cr, uid, [('visible', '=', True)], context=context)
+        complete_tax_set = chart_template_obj.browse(cr, uid, chart_template_ids[0]).complete_tax_set
+        if not complete_tax_set:
+            code_digits = multi_chart_obj.onchange_chart_template_id(cr, uid, [], chart_template_ids[0], context=context)['value']['code_digits']
+            object_id = multi_chart_obj.create(cr, uid, {'code_digits': code_digits , 'sale_tax_rate':data['sale_tax_rate'], 'purchase_tax_rate': data['purchase_tax_rate']}, context=context)
+            multi_chart_obj.execute(cr, uid, [object_id], context=context)
+
     def configure_fiscalyear(self, cr, uid, ids, context=None):
         if context is None:
             context = {}

=== modified file 'account/res_config_view.xml'
--- account/res_config_view.xml	2012-03-13 10:05:58 +0000
+++ account/res_config_view.xml	2012-03-16 09:40:26 +0000
@@ -24,17 +24,22 @@
                        <label string="You have no fiscal year/period open for this date."/>
                        <button name="configure_fiscalyear" string="Configure Fiscalyear" icon="gtk-execute" type="object"/>
                     </group>
-                    <field name="company_id" widget="selection" readonly="1" attrs="{'invisible': [('has_default_company', '=', True)]}"/>
+                    <field name="company_id" widget="selection" readonly="1" on_change="on_change_company_id(company_id)" attrs="{'invisible': [('has_default_company', '=', True)]} " />
                     <separator string="Accounting Configuration" colspan="4"/>
                     <group col="4" colspan="4">
+                        <field name ="complete_tax_set" invisible="1"/>
+                        <field name ="multi_charts_id" invisible="1"/>
+                        <newline/>
                         <group col="2" colspan="2">
-                            <field name="default_taxes_id"/>
+                            <field name="taxes_id" attrs="{'invisible': [('complete_tax_set', '!=', True)]}"/>
+                            <field name="sale_tax_rate" attrs="{'invisible': [('complete_tax_set', '=', True)]}"/>
                             <field name="module_account_accountant"/>
                             <field name="module_account_asset"/>
                             <field name="group_dates_periods"/>
                         </group>
                         <group col="2" colspan="2">
-                            <field name="default_supplier_taxes_id"/>
+                            <field name="supplier_taxes_id" attrs="{'invisible': [('complete_tax_set', '!=', True)]}"/>
+                            <field name="purchase_tax_rate" attrs="{'invisible': [('complete_tax_set', '=', True)]}"/>
                             <field name="currency_id" widget="selection"/>
                             <field name="module_account_budget"/>
                         </group>

=== modified file 'event_sale/__openerp__.py'
--- event_sale/__openerp__.py	2012-02-28 10:59:06 +0000
+++ event_sale/__openerp__.py	2012-03-16 09:40:26 +0000
@@ -37,6 +37,7 @@
     'depends': ['event','sale','sale_crm'],
     'update_xml': [
         'event_sale_view.xml',
+        'event_demo.xml',
     ],
     'test':['test/confirm.yml'],
     'installable': True,

=== added file 'event_sale/event_demo.xml'
--- event_sale/event_demo.xml	1970-01-01 00:00:00 +0000
+++ event_sale/event_demo.xml	2012-03-16 09:40:26 +0000
@@ -0,0 +1,25 @@
+<?xml version="1.0"?>
+<openerp>
+    <data>
+    <record id="event_technical_training" model="event.event">
+        <field name="name">Technical training in Grand-Rosiere</field>
+        <field eval="(DateTime.now() + timedelta(15)).strftime('%Y-%m-%d 7:00:00')" name="date_begin"/>
+        <field eval="(DateTime.now() + timedelta(20)).strftime('%Y-%m-%d 16:00:00')" name="date_end"/>
+        <field name="type" ref="event.event_type_4"/>
+        <field name="user_id" ref="base.user_root"/>
+    </record>
+
+    <record id="event_product" model="product.product">
+        <field name="name">Technical Training</field>
+        <field name="event_ok">True</field>
+        <field name="event_type_id" ref="event.event_type_4"/>
+        <field name="categ_id" ref="product.cat1"/>
+        <field name="type">service</field>
+        <field name="list_price">2500.0</field>
+        <field name="standard_price">1000.0</field>
+        <field name="supply_method">produce</field>
+        <field name="uom_id" ref="product.product_uom_unit"/>
+        <field name="uom_po_id" ref="product.product_uom_unit"/>
+    </record>
+    </data>
+</openerp>

=== added directory 'event_sale_layout'
=== added file 'event_sale_layout/__init__.py'
--- event_sale_layout/__init__.py	1970-01-01 00:00:00 +0000
+++ event_sale_layout/__init__.py	2012-03-16 09:40:26 +0000
@@ -0,0 +1,21 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+#    OpenERP, Open Source Management Solution
+#    Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
+#
+#    This program is free software: you can redistribute it and/or modify
+#    it under the terms of the GNU Affero General Public License as
+#    published by the Free Software Foundation, either version 3 of the
+#    License, or (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU Affero General Public License for more details.
+#
+#    You should have received a copy of the GNU Affero General Public License
+#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+

=== added file 'event_sale_layout/__openerp__.py'
--- event_sale_layout/__openerp__.py	1970-01-01 00:00:00 +0000
+++ event_sale_layout/__openerp__.py	2012-03-16 09:40:26 +0000
@@ -0,0 +1,40 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+#    OpenERP, Open Source Management Solution
+#    Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
+#
+#    This program is free software: you can redistribute it and/or modify
+#    it under the terms of the GNU Affero General Public License as
+#    published by the Free Software Foundation, either version 3 of the
+#    License, or (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU Affero General Public License for more details.
+#
+#    You should have received a copy of the GNU Affero General Public License
+#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+
+{
+    'name': 'Events Sales layout',
+    'version': '0.1',
+    'category': 'Tools',
+    'complexity': "easy",
+    'description': """
+    This module ensures the compatibility of the changes made on the sale.order.line form view in event_sale with the sale_layout module (that is replacing the whole field in the view by another one). Its installation is automatically triggered when both modules are installed.
+    """,
+    'author': 'OpenERP SA',
+    'depends': ['event_sale','sale_layout'],
+    'update_xml': [
+        'event_sale_layout.xml',
+    ],
+    'installable': True,
+    'auto_install':True,
+    'category': 'Hidden',
+}
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

=== added file 'event_sale_layout/event_sale_layout.xml'
--- event_sale_layout/event_sale_layout.xml	1970-01-01 00:00:00 +0000
+++ event_sale_layout/event_sale_layout.xml	2012-03-16 09:40:26 +0000
@@ -0,0 +1,18 @@
+<openerp>
+<data>
+    <record model="ir.ui.view" id="view_order_form_inherit_1">
+      <field name="name">event.sale.order</field>
+      <field name="model">sale.order</field>
+      <field name="type">form</field>
+      <field name="priority">10000</field>
+      <field name="inherit_id" ref="sale.view_order_form" />
+      <field name="arch" type="xml">
+         <xpath expr="//field[@name='discount']" position="after">
+             <field name="event_id" colspan="3" domain="[('type', 'in', list(set((event_type_id,False))))]" attrs="{'invisible': [('event_ok', '=', False)],'required': [('event_ok', '!=', False)]}"/>
+             <field name="event_type_id" invisible='1'/>
+             <field name="event_ok" invisible='1'/>
+         </xpath>
+      </field>
+ </record>
+</data>
+</openerp>

_______________________________________________
Mailing list: https://launchpad.net/~openerp-dev-gtk
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~openerp-dev-gtk
More help   : https://help.launchpad.net/ListHelp

Reply via email to