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
1=== modified file 'account/account.py'
2--- account/account.py 2014-04-24 13:45:33 +0000
3+++ account/account.py 2014-05-13 09:20:43 +0000
4@@ -3366,6 +3366,17 @@
5 obj_tax_temp.write(cr, uid, ref_tax_ids, {'amount': value/100.0, 'name': _('Purchase Tax %.2f%%') % value})
6 return True
7
8+ def _next(self, cr, uid, context=None):
9+ if context is None:context = {}
10+ res = super(wizard_multi_charts_accounts, self)._next(cr, uid, context=context)
11+ if context.get('reload_page'):
12+ res = {
13+ 'type': 'ir.actions.client',
14+ 'tag': 'reload',
15+ }
16+ context.pop('reload_page')
17+ return res
18+
19 def execute(self, cr, uid, ids, context=None):
20 '''
21 This function is called at the confirmation of the wizard to generate the COA from the templates. It will read
22
23=== modified file 'account/account_installer.xml'
24--- account/account_installer.xml 2013-10-27 12:31:04 +0000
25+++ account/account_installer.xml 2014-05-13 09:20:43 +0000
26@@ -11,6 +11,8 @@
27 <footer position="replace">
28 <footer>
29 <button name="action_next" context="{'default_charts':charts}" type="object" string="Continue" class="oe_highlight"/>
30+ or
31+ <button string="Cancel" special="cancel" class="oe_link"/>
32 </footer>
33 </footer>
34 <separator string="title" position="replace">
35
36=== modified file 'account/installer.py'
37--- account/installer.py 2014-04-10 10:36:38 +0000
38+++ account/installer.py 2014-05-13 09:20:43 +0000
39@@ -135,6 +135,21 @@
40 return {'value': {'date_stop': end_date.strftime('%Y-%m-%d')}}
41 return {}
42
43+ def _next(self, cr, uid, context=None):
44+ if context is None:context = {}
45+ ir_todo_obj = self.pool.get('ir.actions.todo')
46+ ir_model_obj = self.pool.get('ir.model.data')
47+ if context.get('reload_page'):
48+ action_id = ir_model_obj.get_object_reference(cr, uid, 'account', 'account_configuration_installer_todo')[1]
49+ state = ir_todo_obj.browse(cr, uid, action_id, context=context).state
50+ if state == 'open':
51+ ir_todo_obj.write(cr, uid, action_id, {'state':'done'}, context=context)
52+ action_id = ir_model_obj.get_object_reference(cr, uid, 'account', context['reload_page'])[1]
53+ state = ir_todo_obj.browse(cr, uid, action_id, context=context).state
54+ if state == 'done':
55+ ir_todo_obj.write(cr, uid, action_id, {'state':'open'}, context=context)
56+ return super(account_installer, self)._next(cr, uid, context=context)
57+
58 def execute(self, cr, uid, ids, context=None):
59 self.execute_simple(cr, uid, ids, context)
60 return super(account_installer, self).execute(cr, uid, ids, context=context)
61@@ -171,6 +186,26 @@
62 context=context)[0]['charts']
63 _logger.debug('Installing chart of accounts %s', chart)
64 return (modules | set([chart])) - set(['has_default_company', 'configurable'])
65-
66+
67+ def _open_account_configuration_installer(self, cr, uid, ids, context=None):
68+ groups = self.pool.get('ir.model.data').get_object(cr, uid, 'account', 'group_account_manager')
69+ user_ids = [user.id for user in groups.users]
70+ if uid in user_ids:
71+ view_id = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'account', 'view_account_configuration_installer')[1]
72+ result = {
73+ 'name': 'Configure Accounting Data',
74+ 'view_type': 'form',
75+ 'view_mode': 'form',
76+ 'view_id': view_id,
77+ 'res_model': 'account.installer',
78+ 'type': 'ir.actions.act_window',
79+ 'nodestroy': True,
80+ 'target': 'new',
81+ 'context': {'reload_page': 'action_wizard_multi_chart_todo'}
82+ }
83+ return result
84+ else:
85+ raise osv.except_osv(_('Access Right Error!'), _('Sorry, you are not allowed to create this kind of document. Please ask your Financial Manager.'))
86+ return {'type': 'ir.actions.act_window_close'}
87
88 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
89
90=== modified file 'account/partner.py'
91--- account/partner.py 2014-05-07 18:29:17 +0000
92+++ account/partner.py 2014-05-13 09:20:43 +0000
93@@ -21,7 +21,7 @@
94
95 from operator import itemgetter
96 import time
97-
98+from openerp.tools.translate import _
99 from openerp.osv import fields, osv
100
101 class account_fiscal_position(osv.osv):
102@@ -205,6 +205,17 @@
103 def mark_as_reconciled(self, cr, uid, ids, context=None):
104 return self.write(cr, uid, ids, {'last_reconciliation_date': time.strftime('%Y-%m-%d %H:%M:%S')}, context=context)
105
106+ def _check_coa_configured(self, cr, uid, context=None):
107+ company_id = self.pool.get('res.users').browse(cr, uid, uid).company_id.id
108+ 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)
109+ return bool(prop_ids)
110+
111+ def _get_coa_configured(self, cr, uid, ids, field_names, arg, context=None):
112+ return dict.fromkeys(ids, self._check_coa_configured(cr, uid, context=context))
113+
114+ def open_account_configuration_installer(self, cr, uid, ids, context=None):
115+ return self.pool.get('account.installer')._open_account_configuration_installer(cr, uid, ids, context=context)
116+
117 _columns = {
118 'credit': fields.function(_credit_debit_get,
119 fnct_search=_credit_search, string='Total Receivable', multi='dc', help="Total amount this customer owes you."),
120@@ -245,9 +256,14 @@
121 help="This payment term will be used instead of the default one for purchase orders and supplier invoices"),
122 'ref_companies': fields.one2many('res.company', 'partner_id',
123 'Companies that refers to partner'),
124- '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.')
125+ '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.'),
126+ 'is_coa_configured': fields.function(_get_coa_configured, type='boolean', string='COA Configured',),
127 }
128
129+ _defaults = {
130+ 'is_coa_configured': _check_coa_configured
131+ }
132+
133 def _commercial_fields(self, cr, uid, context=None):
134 return super(res_partner, self)._commercial_fields(cr, uid, context=context) + \
135 ['debit_limit', 'property_account_payable', 'property_account_receivable', 'property_account_position',
136
137=== modified file 'account/partner_view.xml'
138--- account/partner_view.xml 2014-05-02 13:07:53 +0000
139+++ account/partner_view.xml 2014-05-13 09:20:43 +0000
140@@ -124,6 +124,7 @@
141 <field name="property_account_payable" groups="account.group_account_invoice"/>
142 <field name="property_supplier_payment_term" widget="selection"/>
143 <field name="debit"/>
144+ <field name="is_coa_configured" invisible="1"/>
145 </group>
146 </group>
147 <field name="bank_ids" context="{'default_partner_id': active_id, 'form_view_ref': 'base.view_partner_bank_form'}">
148@@ -142,6 +143,13 @@
149 </div>
150 </page>
151 </page>
152+ <sheet position="before">
153+ <div name="warning" class="oe_form_box_info oe_text_center" attrs="{'invisible':[('is_coa_configured','=',True)]}">
154+ <p>Accounting data do not seem well configured.</p>
155+ <p>Please click here to automatically set up your taxes and chart of accounts:
156+ <button type="object" name="open_account_configuration_installer" string="Setup Accounting Information" class="oe_link" special="nosave"/></p>
157+ </div>
158+ </sheet>
159 </field>
160 </record>
161 </data>
162
163=== modified file 'account/product.py'
164--- account/product.py 2013-11-29 16:56:44 +0000
165+++ account/product.py 2014-05-13 09:20:43 +0000
166@@ -20,6 +20,7 @@
167 ##############################################################################
168
169 from openerp.osv import fields, osv
170+from openerp.tools.translate import _
171
172 class product_category(osv.osv):
173 _inherit = "product.category"
174@@ -60,6 +61,51 @@
175 string="Expense Account",
176 help="This account will be used for invoices instead of the default one to value expenses for the current product."),
177 }
178-
179-
180+class product_product(osv.osv):
181+ _inherit = "product.product"
182+
183+ def _check_coa_configured(self, cr, uid, context=None):
184+ company_id = self.pool.get('res.users').browse(cr, uid, uid).company_id.id
185+ 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)
186+ return bool(prop_ids)
187+
188+ def _get_coa_configured(self, cr, uid, ids, field_names, arg, context=None):
189+ return dict.fromkeys(ids, self._check_coa_configured(cr, uid, context=context))
190+
191+ def open_account_configuration_installer(self, cr, uid, ids, context=None):
192+ return self.pool.get('account.installer')._open_account_configuration_installer(cr, uid, ids, context=context)
193+
194+ _columns = {
195+ 'is_coa_configured': fields.function(_get_coa_configured, type='boolean', string='COA Configured',
196+ store={
197+ 'product.product': (lambda self, cr, uid, ids, c={}: ids, ['property_account_income', 'property_account_expense'], 50),
198+ },),
199+ }
200+ _defaults = {
201+ 'is_coa_configured': _check_coa_configured,
202+ }
203+
204+class product_category(osv.osv):
205+ _inherit = "product.category"
206+
207+ def _check_coa_configured(self, cr, uid, context=None):
208+ company_id = self.pool.get('res.users').browse(cr, uid, uid).company_id.id
209+ 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)
210+ return bool(prop_ids)
211+
212+ def _get_coa_configured(self, cr, uid, ids, field_names, arg, context=None):
213+ return dict.fromkeys(ids, self._check_coa_configured(cr, uid, context=context))
214+
215+ def open_account_configuration_installer(self, cr, uid, ids, context=None):
216+ return self.pool.get('account.installer')._open_account_configuration_installer(cr, uid, ids, context=context)
217+
218+ _columns = {
219+ 'is_coa_configured': fields.function(_get_coa_configured, type='boolean', string='COA Configured',
220+ store={
221+ 'product.category': (lambda self, cr, uid, ids, c={}: ids, ['property_account_income_categ', 'property_account_expense_categ'], 50),
222+ }),
223+ }
224+ _defaults = {
225+ 'is_coa_configured': _check_coa_configured,
226+ }
227 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
228
229=== modified file 'account/product_view.xml'
230--- account/product_view.xml 2014-01-22 09:58:26 +0000
231+++ account/product_view.xml 2014-05-13 09:20:43 +0000
232@@ -11,6 +11,7 @@
233 <page string="Accounting" groups="account.group_account_invoice">
234 <group name="properties">
235 <group>
236+ <field name="is_coa_configured" invisible="1"/>
237 <field name="property_account_income" domain="[('type','=','other')]" groups="account.group_account_user"
238 attrs="{'readonly': [('is_only_child', '=', False)]}"/>
239 <field name="taxes_id" colspan="2" widget="many2many_tags"
240@@ -25,6 +26,13 @@
241 </group>
242 </page>
243 </notebook>
244+ <sheet position="before">
245+ <div name="warning" class="oe_form_box_info oe_text_center" attrs="{'invisible':[('is_coa_configured','=',True)]}">
246+ <p>Accounting data do not seem well configured.</p>
247+ <p>Please click here to automatically set up your taxes and chart of accounts:
248+ <button type="object" name="open_account_configuration_installer" string="Setup Accounting Information" class="oe_link" special="nosave"/></p>
249+ </div>
250+ </sheet>
251 </field>
252 </record>
253
254@@ -60,11 +68,19 @@
255 <data>
256 <xpath expr="//group[@name='parent']" position="inside">
257 <group name="account_property" string="Account Properties" colspan="2">
258+ <field name="is_coa_configured" invisible="1"/>
259 <field name="property_account_income_categ" domain="[('type','&lt;&gt;','view'),('type','&lt;&gt;','consolidation')]"/>
260 <field name="property_account_expense_categ" domain="[('type','&lt;&gt;','view'),('type','&lt;&gt;','consolidation')]"/>
261 </group>
262 </xpath>
263 </data>
264+ <sheet position="before">
265+ <div name="warning" class="oe_form_box_info oe_text_center" attrs="{'invisible':[('is_coa_configured','=',True)]}">
266+ <p>Accounting data do not seem well configured.</p>
267+ <p>Please click here to automatically set up your taxes and chart of accounts:
268+ <button type="object" name="open_account_configuration_installer" string="Setup Accounting Information" class="oe_link" special="nosave"/></p>
269+ </div>
270+ </sheet>
271 </field>
272 </record>
273

Subscribers

People subscribed via source and target branches

to all changes: