Merge lp:~openerp-dev/openobject-addons/trunk-account-installer-wizard-pza into lp:openobject-addons

Proposed by Jitendra Prajapati(OpenERP)
Status: Needs review
Proposed branch: lp:~openerp-dev/openobject-addons/trunk-account-installer-wizard-pza
Merge into: lp:openobject-addons
Diff against target: 272 lines (+139/-5)
7 files modified
account/account.py (+11/-0)
account/account_installer.xml (+2/-0)
account/installer.py (+36/-1)
account/partner.py (+18/-2)
account/partner_view.xml (+8/-0)
account/product.py (+48/-2)
account/product_view.xml (+16/-0)
To merge this branch: bzr merge lp:~openerp-dev/openobject-addons/trunk-account-installer-wizard-pza
Reviewer Review Type Date Requested Status
Mustufa Rangwala (Open ERP) (community) Needs Fixing
Thibault Delavallée (OpenERP) Pending
Review via email: mp+204842@code.launchpad.net

This proposal supersedes a proposal from 2013-11-22.

Description of the change

Hello,

 I have update the code as per your suggestion.
 => (_next override): if i test without that code, below test case does not work properly.

 Steps for test case:
   1 Create another company “Demo Company”.
   2 Create new user “Demo User” and set the company of user “Demo company”.
   3 Provide appropriate rights and login with this user.
   Go to Accounting -> Customers -> Customers menu and click on Create button to create a new customer. You will find a warning message above customer
   Now, To configure accounting chart and taxes click on link appear on message “Setup Accounting Information”. It will open "Configure Accounting Data" wizard after click on continue on this wizard next wizard("Set Your Accounting Options") for set accounting option will not pop up if we remove that code and it redirects to customer and also give that warning again.

Thanks.
Jitendra(JPR)

To post a comment you must log in.
Revision history for this message
Thibault Delavallée (OpenERP) (tde-openerp) wrote : Posted in a previous version of this proposal

Hello,

In account/installer.py: I don't see the point with the _next override. When removing this code, everything seems to work fine. Please confirm that this code is not necessary and remove it.

In account/partner.py:
- _check_coa_configured: simplifty code using return bool(prop_ids)

In account/partner_view.py:
- next_action does not seem necessary; introduce a key 'reload_page' replacing next action, and handle it in account/account.py, in _next.

In account/account.py:
- probably replace next_action by reload_page
- context.get returns None by default: no need to use if context.get(key, False) -> if context.get(key)
- instead of updating context, simply remove the key from context (context.pop(key))

review: Needs Fixing
8979. By Jitendra Prajapati(OpenERP)

[MERGE]with lp:openobject-addons

8980. By Jitendra Prajapati(OpenERP)

[IMP]check context

8981. By Chirag Dodiya(OpenERP)

[MRG]Merge with lp:openobject-addons

8982. By Randhir Mayatra (OpenERP)

[IMP]add coa configuration links on product and product category

8983. By Randhir Mayatra (OpenERP)

[IMP]improve help string regarding coa in partner form

8984. By Randhir Mayatra (OpenERP)

[MERGE] merge with latest trunk

8985. By Randhir Mayatra (OpenERP)

[IMP] imrpoved message as per access right

8986. By Randhir Mayatra (OpenERP)

[MERGE] merge with latest trunk

8987. By Randhir Mayatra (OpenERP)

[IMP] improve help string

8988. By Randhir Mayatra (OpenERP)

[IMP] improve warning message as per the user access right

8989. By Randhir Mayatra (OpenERP)

[MERGE] merge with latest trunk

8990. By Randhir Mayatra (OpenERP)

[IMP] optimize code

Revision history for this message
Mustufa Rangwala (Open ERP) (mra-tinyerp) wrote :

Points to improve:
- _check_coa_configured => remove company_id from domain it will be handled by record rules.
- try to avoid searching by name of Finance manager.

review: Needs Fixing
Revision history for this message
Mustufa Rangwala (Open ERP) (mra-tinyerp) wrote :

Use store={} instead of simple function field.

You can take account_id references on different object to call base function method.

Regards,

review: Needs Fixing
8991. By Randhir Mayatra (OpenERP)

[IMP] improved search methods

8992. By Randhir Mayatra (OpenERP)

[MERGE] merge with latest trunk

8993. By Randhir Mayatra (OpenERP)

[IMP] imorived company_id domain

8994. By Randhir Mayatra (OpenERP)

[MERGE] merge with latest trunk

8995. By Randhir Mayatra (OpenERP)

[IMP] update open_account_installer method

Unmerged revisions

8995. By Randhir Mayatra (OpenERP)

[IMP] update open_account_installer method

8994. By Randhir Mayatra (OpenERP)

[MERGE] merge with latest trunk

8993. By Randhir Mayatra (OpenERP)

[IMP] imorived company_id domain

8992. By Randhir Mayatra (OpenERP)

[MERGE] merge with latest trunk

8991. By Randhir Mayatra (OpenERP)

[IMP] improved search methods

8990. By Randhir Mayatra (OpenERP)

[IMP] optimize code

8989. By Randhir Mayatra (OpenERP)

[MERGE] merge with latest trunk

8988. By Randhir Mayatra (OpenERP)

[IMP] improve warning message as per the user access right

8987. By Randhir Mayatra (OpenERP)

[IMP] improve help string

8986. By Randhir Mayatra (OpenERP)

[MERGE] merge with latest trunk

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'account/account.py'
--- account/account.py 2014-04-24 13:45:33 +0000
+++ account/account.py 2014-05-13 09:20:43 +0000
@@ -3366,6 +3366,17 @@
3366 obj_tax_temp.write(cr, uid, ref_tax_ids, {'amount': value/100.0, 'name': _('Purchase Tax %.2f%%') % value})3366 obj_tax_temp.write(cr, uid, ref_tax_ids, {'amount': value/100.0, 'name': _('Purchase Tax %.2f%%') % value})
3367 return True3367 return True
33683368
3369 def _next(self, cr, uid, context=None):
3370 if context is None:context = {}
3371 res = super(wizard_multi_charts_accounts, self)._next(cr, uid, context=context)
3372 if context.get('reload_page'):
3373 res = {
3374 'type': 'ir.actions.client',
3375 'tag': 'reload',
3376 }
3377 context.pop('reload_page')
3378 return res
3379
3369 def execute(self, cr, uid, ids, context=None):3380 def execute(self, cr, uid, ids, context=None):
3370 '''3381 '''
3371 This function is called at the confirmation of the wizard to generate the COA from the templates. It will read3382 This function is called at the confirmation of the wizard to generate the COA from the templates. It will read
33723383
=== modified file 'account/account_installer.xml'
--- account/account_installer.xml 2013-10-27 12:31:04 +0000
+++ account/account_installer.xml 2014-05-13 09:20:43 +0000
@@ -11,6 +11,8 @@
11 <footer position="replace">11 <footer position="replace">
12 <footer>12 <footer>
13 <button name="action_next" context="{'default_charts':charts}" type="object" string="Continue" class="oe_highlight"/>13 <button name="action_next" context="{'default_charts':charts}" type="object" string="Continue" class="oe_highlight"/>
14 or
15 <button string="Cancel" special="cancel" class="oe_link"/>
14 </footer>16 </footer>
15 </footer>17 </footer>
16 <separator string="title" position="replace">18 <separator string="title" position="replace">
1719
=== modified file 'account/installer.py'
--- account/installer.py 2014-04-10 10:36:38 +0000
+++ account/installer.py 2014-05-13 09:20:43 +0000
@@ -135,6 +135,21 @@
135 return {'value': {'date_stop': end_date.strftime('%Y-%m-%d')}}135 return {'value': {'date_stop': end_date.strftime('%Y-%m-%d')}}
136 return {}136 return {}
137137
138 def _next(self, cr, uid, context=None):
139 if context is None:context = {}
140 ir_todo_obj = self.pool.get('ir.actions.todo')
141 ir_model_obj = self.pool.get('ir.model.data')
142 if context.get('reload_page'):
143 action_id = ir_model_obj.get_object_reference(cr, uid, 'account', 'account_configuration_installer_todo')[1]
144 state = ir_todo_obj.browse(cr, uid, action_id, context=context).state
145 if state == 'open':
146 ir_todo_obj.write(cr, uid, action_id, {'state':'done'}, context=context)
147 action_id = ir_model_obj.get_object_reference(cr, uid, 'account', context['reload_page'])[1]
148 state = ir_todo_obj.browse(cr, uid, action_id, context=context).state
149 if state == 'done':
150 ir_todo_obj.write(cr, uid, action_id, {'state':'open'}, context=context)
151 return super(account_installer, self)._next(cr, uid, context=context)
152
138 def execute(self, cr, uid, ids, context=None):153 def execute(self, cr, uid, ids, context=None):
139 self.execute_simple(cr, uid, ids, context)154 self.execute_simple(cr, uid, ids, context)
140 return super(account_installer, self).execute(cr, uid, ids, context=context)155 return super(account_installer, self).execute(cr, uid, ids, context=context)
@@ -171,6 +186,26 @@
171 context=context)[0]['charts']186 context=context)[0]['charts']
172 _logger.debug('Installing chart of accounts %s', chart)187 _logger.debug('Installing chart of accounts %s', chart)
173 return (modules | set([chart])) - set(['has_default_company', 'configurable'])188 return (modules | set([chart])) - set(['has_default_company', 'configurable'])
174189
190 def _open_account_configuration_installer(self, cr, uid, ids, context=None):
191 groups = self.pool.get('ir.model.data').get_object(cr, uid, 'account', 'group_account_manager')
192 user_ids = [user.id for user in groups.users]
193 if uid in user_ids:
194 view_id = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'account', 'view_account_configuration_installer')[1]
195 result = {
196 'name': 'Configure Accounting Data',
197 'view_type': 'form',
198 'view_mode': 'form',
199 'view_id': view_id,
200 'res_model': 'account.installer',
201 'type': 'ir.actions.act_window',
202 'nodestroy': True,
203 'target': 'new',
204 'context': {'reload_page': 'action_wizard_multi_chart_todo'}
205 }
206 return result
207 else:
208 raise osv.except_osv(_('Access Right Error!'), _('Sorry, you are not allowed to create this kind of document. Please ask your Financial Manager.'))
209 return {'type': 'ir.actions.act_window_close'}
175210
176# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:211# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
177212
=== modified file 'account/partner.py'
--- account/partner.py 2014-05-07 18:29:17 +0000
+++ account/partner.py 2014-05-13 09:20:43 +0000
@@ -21,7 +21,7 @@
2121
22from operator import itemgetter22from operator import itemgetter
23import time23import time
2424from openerp.tools.translate import _
25from openerp.osv import fields, osv25from openerp.osv import fields, osv
2626
27class account_fiscal_position(osv.osv):27class account_fiscal_position(osv.osv):
@@ -205,6 +205,17 @@
205 def mark_as_reconciled(self, cr, uid, ids, context=None):205 def mark_as_reconciled(self, cr, uid, ids, context=None):
206 return self.write(cr, uid, ids, {'last_reconciliation_date': time.strftime('%Y-%m-%d %H:%M:%S')}, context=context)206 return self.write(cr, uid, ids, {'last_reconciliation_date': time.strftime('%Y-%m-%d %H:%M:%S')}, context=context)
207207
208 def _check_coa_configured(self, cr, uid, context=None):
209 company_id = self.pool.get('res.users').browse(cr, uid, uid).company_id.id
210 prop_ids = self.pool.get('ir.property').search(cr, uid, [('name', 'in', ('property_account_receivable', 'property_account_payable')), (('company_id', '=', company_id) or ('company_id', '=', False))], context=context)
211 return bool(prop_ids)
212
213 def _get_coa_configured(self, cr, uid, ids, field_names, arg, context=None):
214 return dict.fromkeys(ids, self._check_coa_configured(cr, uid, context=context))
215
216 def open_account_configuration_installer(self, cr, uid, ids, context=None):
217 return self.pool.get('account.installer')._open_account_configuration_installer(cr, uid, ids, context=context)
218
208 _columns = {219 _columns = {
209 'credit': fields.function(_credit_debit_get,220 'credit': fields.function(_credit_debit_get,
210 fnct_search=_credit_search, string='Total Receivable', multi='dc', help="Total amount this customer owes you."),221 fnct_search=_credit_search, string='Total Receivable', multi='dc', help="Total amount this customer owes you."),
@@ -245,9 +256,14 @@
245 help="This payment term will be used instead of the default one for purchase orders and supplier invoices"),256 help="This payment term will be used instead of the default one for purchase orders and supplier invoices"),
246 'ref_companies': fields.one2many('res.company', 'partner_id',257 'ref_companies': fields.one2many('res.company', 'partner_id',
247 'Companies that refers to partner'),258 'Companies that refers to partner'),
248 'last_reconciliation_date': fields.datetime('Latest Full Reconciliation Date', help='Date on which the partner accounting entries were fully reconciled last time. It differs from the last date where a reconciliation has been made for this partner, as here we depict the fact that nothing more was to be reconciled at this date. This can be achieved in 2 different ways: either the last unreconciled debit/credit entry of this partner was reconciled, either the user pressed the button "Nothing more to reconcile" during the manual reconciliation process.')259 'last_reconciliation_date': fields.datetime('Latest Full Reconciliation Date', help='Date on which the partner accounting entries were fully reconciled last time. It differs from the last date where a reconciliation has been made for this partner, as here we depict the fact that nothing more was to be reconciled at this date. This can be achieved in 2 different ways: either the last unreconciled debit/credit entry of this partner was reconciled, either the user pressed the button "Nothing more to reconcile" during the manual reconciliation process.'),
260 'is_coa_configured': fields.function(_get_coa_configured, type='boolean', string='COA Configured',),
249 }261 }
250262
263 _defaults = {
264 'is_coa_configured': _check_coa_configured
265 }
266
251 def _commercial_fields(self, cr, uid, context=None):267 def _commercial_fields(self, cr, uid, context=None):
252 return super(res_partner, self)._commercial_fields(cr, uid, context=context) + \268 return super(res_partner, self)._commercial_fields(cr, uid, context=context) + \
253 ['debit_limit', 'property_account_payable', 'property_account_receivable', 'property_account_position',269 ['debit_limit', 'property_account_payable', 'property_account_receivable', 'property_account_position',
254270
=== modified file 'account/partner_view.xml'
--- account/partner_view.xml 2014-05-02 13:07:53 +0000
+++ account/partner_view.xml 2014-05-13 09:20:43 +0000
@@ -124,6 +124,7 @@
124 <field name="property_account_payable" groups="account.group_account_invoice"/>124 <field name="property_account_payable" groups="account.group_account_invoice"/>
125 <field name="property_supplier_payment_term" widget="selection"/>125 <field name="property_supplier_payment_term" widget="selection"/>
126 <field name="debit"/>126 <field name="debit"/>
127 <field name="is_coa_configured" invisible="1"/>
127 </group>128 </group>
128 </group>129 </group>
129 <field name="bank_ids" context="{'default_partner_id': active_id, 'form_view_ref': 'base.view_partner_bank_form'}">130 <field name="bank_ids" context="{'default_partner_id': active_id, 'form_view_ref': 'base.view_partner_bank_form'}">
@@ -142,6 +143,13 @@
142 </div>143 </div>
143 </page>144 </page>
144 </page>145 </page>
146 <sheet position="before">
147 <div name="warning" class="oe_form_box_info oe_text_center" attrs="{'invisible':[('is_coa_configured','=',True)]}">
148 <p>Accounting data do not seem well configured.</p>
149 <p>Please click here to automatically set up your taxes and chart of accounts:
150 <button type="object" name="open_account_configuration_installer" string="Setup Accounting Information" class="oe_link" special="nosave"/></p>
151 </div>
152 </sheet>
145 </field>153 </field>
146 </record>154 </record>
147 </data>155 </data>
148156
=== modified file 'account/product.py'
--- account/product.py 2013-11-29 16:56:44 +0000
+++ account/product.py 2014-05-13 09:20:43 +0000
@@ -20,6 +20,7 @@
20##############################################################################20##############################################################################
2121
22from openerp.osv import fields, osv22from openerp.osv import fields, osv
23from openerp.tools.translate import _
2324
24class product_category(osv.osv):25class product_category(osv.osv):
25 _inherit = "product.category"26 _inherit = "product.category"
@@ -60,6 +61,51 @@
60 string="Expense Account",61 string="Expense Account",
61 help="This account will be used for invoices instead of the default one to value expenses for the current product."),62 help="This account will be used for invoices instead of the default one to value expenses for the current product."),
62 }63 }
6364class product_product(osv.osv):
6465 _inherit = "product.product"
66
67 def _check_coa_configured(self, cr, uid, context=None):
68 company_id = self.pool.get('res.users').browse(cr, uid, uid).company_id.id
69 prop_ids = self.pool.get('ir.property').search(cr, uid, [('name','in',('property_account_income', 'property_account_income_categ', 'property_account_expense', 'property_account_expense_categ')),(('company_id', '=', company_id) or ('company_id', '=', False))], context=context)
70 return bool(prop_ids)
71
72 def _get_coa_configured(self, cr, uid, ids, field_names, arg, context=None):
73 return dict.fromkeys(ids, self._check_coa_configured(cr, uid, context=context))
74
75 def open_account_configuration_installer(self, cr, uid, ids, context=None):
76 return self.pool.get('account.installer')._open_account_configuration_installer(cr, uid, ids, context=context)
77
78 _columns = {
79 'is_coa_configured': fields.function(_get_coa_configured, type='boolean', string='COA Configured',
80 store={
81 'product.product': (lambda self, cr, uid, ids, c={}: ids, ['property_account_income', 'property_account_expense'], 50),
82 },),
83 }
84 _defaults = {
85 'is_coa_configured': _check_coa_configured,
86 }
87
88class product_category(osv.osv):
89 _inherit = "product.category"
90
91 def _check_coa_configured(self, cr, uid, context=None):
92 company_id = self.pool.get('res.users').browse(cr, uid, uid).company_id.id
93 prop_ids = self.pool.get('ir.property').search(cr, uid, [('name', 'in', ('property_account_income_categ', 'property_account_expense_categ')), (('company_id', '=', company_id) or ('company_id', '=', False))], context=context)
94 return bool(prop_ids)
95
96 def _get_coa_configured(self, cr, uid, ids, field_names, arg, context=None):
97 return dict.fromkeys(ids, self._check_coa_configured(cr, uid, context=context))
98
99 def open_account_configuration_installer(self, cr, uid, ids, context=None):
100 return self.pool.get('account.installer')._open_account_configuration_installer(cr, uid, ids, context=context)
101
102 _columns = {
103 'is_coa_configured': fields.function(_get_coa_configured, type='boolean', string='COA Configured',
104 store={
105 'product.category': (lambda self, cr, uid, ids, c={}: ids, ['property_account_income_categ', 'property_account_expense_categ'], 50),
106 }),
107 }
108 _defaults = {
109 'is_coa_configured': _check_coa_configured,
110 }
65# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:111# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
66112
=== modified file 'account/product_view.xml'
--- account/product_view.xml 2014-01-22 09:58:26 +0000
+++ account/product_view.xml 2014-05-13 09:20:43 +0000
@@ -11,6 +11,7 @@
11 <page string="Accounting" groups="account.group_account_invoice">11 <page string="Accounting" groups="account.group_account_invoice">
12 <group name="properties">12 <group name="properties">
13 <group>13 <group>
14 <field name="is_coa_configured" invisible="1"/>
14 <field name="property_account_income" domain="[('type','=','other')]" groups="account.group_account_user"15 <field name="property_account_income" domain="[('type','=','other')]" groups="account.group_account_user"
15 attrs="{'readonly': [('is_only_child', '=', False)]}"/>16 attrs="{'readonly': [('is_only_child', '=', False)]}"/>
16 <field name="taxes_id" colspan="2" widget="many2many_tags"17 <field name="taxes_id" colspan="2" widget="many2many_tags"
@@ -25,6 +26,13 @@
25 </group>26 </group>
26 </page>27 </page>
27 </notebook>28 </notebook>
29 <sheet position="before">
30 <div name="warning" class="oe_form_box_info oe_text_center" attrs="{'invisible':[('is_coa_configured','=',True)]}">
31 <p>Accounting data do not seem well configured.</p>
32 <p>Please click here to automatically set up your taxes and chart of accounts:
33 <button type="object" name="open_account_configuration_installer" string="Setup Accounting Information" class="oe_link" special="nosave"/></p>
34 </div>
35 </sheet>
28 </field>36 </field>
29 </record>37 </record>
3038
@@ -60,11 +68,19 @@
60 <data>68 <data>
61 <xpath expr="//group[@name='parent']" position="inside">69 <xpath expr="//group[@name='parent']" position="inside">
62 <group name="account_property" string="Account Properties" colspan="2">70 <group name="account_property" string="Account Properties" colspan="2">
71 <field name="is_coa_configured" invisible="1"/>
63 <field name="property_account_income_categ" domain="[('type','&lt;&gt;','view'),('type','&lt;&gt;','consolidation')]"/>72 <field name="property_account_income_categ" domain="[('type','&lt;&gt;','view'),('type','&lt;&gt;','consolidation')]"/>
64 <field name="property_account_expense_categ" domain="[('type','&lt;&gt;','view'),('type','&lt;&gt;','consolidation')]"/>73 <field name="property_account_expense_categ" domain="[('type','&lt;&gt;','view'),('type','&lt;&gt;','consolidation')]"/>
65 </group>74 </group>
66 </xpath>75 </xpath>
67 </data>76 </data>
77 <sheet position="before">
78 <div name="warning" class="oe_form_box_info oe_text_center" attrs="{'invisible':[('is_coa_configured','=',True)]}">
79 <p>Accounting data do not seem well configured.</p>
80 <p>Please click here to automatically set up your taxes and chart of accounts:
81 <button type="object" name="open_account_configuration_installer" string="Setup Accounting Information" class="oe_link" special="nosave"/></p>
82 </div>
83 </sheet>
68 </field>84 </field>
69 </record>85 </record>
7086

Subscribers

People subscribed via source and target branches

to all changes: