Merge lp:~vauxoo/addons-vauxoo/7.0-purchase_sale_test_data_imp_validations_dev_jorge into lp:addons-vauxoo/7.0

Status: Needs review
Proposed branch: lp:~vauxoo/addons-vauxoo/7.0-purchase_sale_test_data_imp_validations_dev_jorge
Merge into: lp:addons-vauxoo/7.0
Diff against target: 326 lines (+136/-31)
7 files modified
ifrs_report/report/report_webkit_html.mako (+1/-1)
purchase_test_data_imp/__openerp__.py (+6/-0)
purchase_test_data_imp/patch/uid_yaml_import.py.patch (+40/-0)
purchase_test_data_imp/test/purchase_order_product_can_be_purchased.yml (+27/-19)
sale_test_data_imp/__openerp__.py (+6/-0)
sale_test_data_imp/patch/uid_yaml_import.py.patch (+40/-0)
sale_test_data_imp/test/sale_order_product_can_be_sold.yml (+16/-11)
To merge this branch: bzr merge lp:~vauxoo/addons-vauxoo/7.0-purchase_sale_test_data_imp_validations_dev_jorge
Reviewer Review Type Date Requested Status
Jorge Angel Naranjo Rogel - http://www.vauxoo.com Needs Resubmitting
Moisés López - http://www.vauxoo.com Approve
Isaac López Zúñiga Pending
Review via email: mp+191533@code.launchpad.net

Description of the change

Se realiza validación para cuando no se crea la factura ya sea de compra o venta, ademas, se buscan los productos que no tiene compañía. Se quitan los replace ya que la librería csv genera ese trabajo.

To post a comment you must log in.
875. By Jorge Angel Naranjo Rogel - http://www.vauxoo.com

[IMP][purchase_test_data_imp] When product is service the invoice_method is picking
[IMP][sale_test_data_imp] When product is service the order_policy is picking

876. By Jorge Angel Naranjo Rogel - http://www.vauxoo.com

[FIX][purchase_test_data_imp] Delete ) in update
[FIX][sale_test_data_imp] Delete ) in update

Revision history for this message
Moisés López - http://www.vauxoo.com (moylop260) wrote :

@Jorge,
Agrega en el description de este módulo los merges que se necesitan agregar, para que pueda funcionar el módulo, please!

review: Approve
877. By Jorge Angel Naranjo Rogel - http://www.vauxoo.com

[ADD][purchase_test_data_imp] Added patch for server
[ADD][sale_test_data_imp] Added patch for server

Revision history for this message
Jorge Angel Naranjo Rogel - http://www.vauxoo.com (jorge-nr) wrote :

Listo moy se agrega el parche que va en el server y se comenta en el description.

review: Needs Resubmitting
878. By Jorge Angel Naranjo Rogel - http://www.vauxoo.com

[FIX][purchase_test_data_imp]Fixed Error unicode
[FIX][sale_test_data_imp] Fixed Error unicode

Revision history for this message
Jorge Angel Naranjo Rogel - http://www.vauxoo.com (jorge-nr) wrote :

Queda corregido el detalle de unicode.

review: Needs Resubmitting

Unmerged revisions

878. By Jorge Angel Naranjo Rogel - http://www.vauxoo.com

[FIX][purchase_test_data_imp]Fixed Error unicode
[FIX][sale_test_data_imp] Fixed Error unicode

877. By Jorge Angel Naranjo Rogel - http://www.vauxoo.com

[ADD][purchase_test_data_imp] Added patch for server
[ADD][sale_test_data_imp] Added patch for server

876. By Jorge Angel Naranjo Rogel - http://www.vauxoo.com

[FIX][purchase_test_data_imp] Delete ) in update
[FIX][sale_test_data_imp] Delete ) in update

875. By Jorge Angel Naranjo Rogel - http://www.vauxoo.com

[IMP][purchase_test_data_imp] When product is service the invoice_method is picking
[IMP][sale_test_data_imp] When product is service the order_policy is picking

874. By Jorge Angel Naranjo Rogel - http://www.vauxoo.com

[MERGE] Merge from lp:addons-vauxoo/7.0

873. By Jorge Angel Naranjo Rogel - http://www.vauxoo.com

[IMP][purchase_test_data_imp] Validate products when company is False and not create invoice for purchase order
[IMP][psale_test_data_imp] Validate products when company is False and not create invoice for sale order

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'ifrs_report/report/report_webkit_html.mako'
2--- ifrs_report/report/report_webkit_html.mako 2013-08-15 23:11:39 +0000
3+++ ifrs_report/report/report_webkit_html.mako 2013-10-23 23:20:26 +0000
4@@ -15,7 +15,7 @@
5 <td>
6 <table style="width: 100%; text-align:center;">
7 <tr><td><div class="td_company_title">${ifrs.company_id.name or ''|entity}</div></td></tr>
8- <tr><td><div class="td_company">${ifrs._get_period_print_info(data['period'],data['report_type']) }</div></td></tr>
9+ <tr><td><div class="td_company_date">${ifrs._get_period_print_info(data['period'],data['report_type']) }</div></td></tr>
10 <tr><td><div class="td_company">${ifrs.fiscalyear_id.name or ''|entity}</div></td></tr>
11 </table>
12 </td>
13
14=== modified file 'purchase_test_data_imp/__openerp__.py'
15--- purchase_test_data_imp/__openerp__.py 2013-10-09 14:47:35 +0000
16+++ purchase_test_data_imp/__openerp__.py 2013-10-23 23:20:26 +0000
17@@ -44,6 +44,12 @@
18
19 This test yaml only works with user admin and the search of partner and
20 product is based in the company that have this user assigned.
21+
22+-You will need to apply the patch patch/uid_yaml_import.py.patch,
23+that is located in this module ( use:patch -b file.py file.patch ) in
24+the server.
25+
26+This patch is momentary.
27 """,
28 "website": "http://vauxoo.com",
29 "category": "Addons Vauxoo",
30
31=== added directory 'purchase_test_data_imp/patch'
32=== added file 'purchase_test_data_imp/patch/uid_yaml_import.py.patch'
33--- purchase_test_data_imp/patch/uid_yaml_import.py.patch 1970-01-01 00:00:00 +0000
34+++ purchase_test_data_imp/patch/uid_yaml_import.py.patch 2013-10-23 23:20:26 +0000
35@@ -0,0 +1,40 @@
36+=== modified file 'openerp/tools/yaml_import.py'
37+--- openerp/tools/yaml_import.py 2012-12-01 11:35:24 +0000
38++++ openerp/tools/yaml_import.py 2013-10-16 17:49:19 +0000
39+@@ -101,7 +101,9 @@
40+ return dict.__getitem__(self, key)
41+
42+ class YamlInterpreter(object):
43+- def __init__(self, cr, module, id_map, mode, filename, report=None, noupdate=False, loglevel=logging.DEBUG):
44++ def __init__(self, cr, module, id_map, mode, filename, report=None, noupdate=False, loglevel=logging.DEBUG, context=None):
45++ if context is None:
46++ context = {}
47+ self.cr = cr
48+ self.module = module
49+ self.id_map = id_map
50+@@ -113,8 +115,8 @@
51+ self.noupdate = noupdate
52+ self.loglevel = loglevel
53+ self.pool = pooler.get_pool(cr.dbname)
54+- self.uid = 1
55+- self.context = {} # opererp context
56++ self.uid = context.get('uid', 1) #TODO: Use session user
57++ self.context = context # opererp context
58+ self.eval_context = {'ref': self._ref(),
59+ '_ref': self._ref(), # added '_ref' so that record['ref'] is possible
60+ 'time': time,
61+@@ -919,12 +921,12 @@
62+ is_preceded_by_comment = False
63+ return is_preceded_by_comment
64+
65+-def yaml_import(cr, module, yamlfile, kind, idref=None, mode='init', noupdate=False, report=None):
66++def yaml_import(cr, module, yamlfile, kind, idref=None, mode='init', noupdate=False, report=None, context=None):
67+ if idref is None:
68+ idref = {}
69+ loglevel = logging.TEST if kind == 'test' else logging.DEBUG
70+ yaml_string = yamlfile.read()
71+- yaml_interpreter = YamlInterpreter(cr, module, idref, mode, filename=yamlfile.name, report=report, noupdate=noupdate, loglevel=loglevel)
72++ yaml_interpreter = YamlInterpreter(cr, module, idref, mode, filename=yamlfile.name, report=report, noupdate=noupdate, loglevel=loglevel, context=context)
73+ yaml_interpreter.process(yaml_string)
74+
75+ # keeps convention of convert.py
76
77=== modified file 'purchase_test_data_imp/test/purchase_order_product_can_be_purchased.yml'
78--- purchase_test_data_imp/test/purchase_order_product_can_be_purchased.yml 2013-10-16 15:59:51 +0000
79+++ purchase_test_data_imp/test/purchase_order_product_can_be_purchased.yml 2013-10-23 23:20:26 +0000
80@@ -18,9 +18,10 @@
81 account_invoice_obj = self.pool.get('account.invoice')
82 account_invoice_line_obj = self.pool.get('account.invoice.line')
83 stock_picking_in_object = self.pool.get('stock.picking.in')
84- product_ids = product_obj.search(cr, uid, [('purchase_ok','=','True'),
85+ product_ids = product_obj.search(cr, uid, [('purchase_ok','=','True'),
86 ('active','=','True'),
87- ('company_id','=',company_id)])
88+ '|',('company_id','=',company_id),('company_id','=',False)])
89+
90 invoice_id = None
91 partner_id = None
92 products_tax_not_fund = []
93@@ -44,10 +45,10 @@
94 fcsv_csv_Log.writerow({'error': 'error', 'localization':'localization' ,'product_id': 'product_id'})
95
96 except Exception, e:
97- fcsv_csv_Log.writerow({'error' : tools.ustr(e).replace('\n', ''), 'localization':'Error create files'})
98+ fcsv_csv_Log.writerow({'error' : tools.ustr(e), 'localization':'Error create files'})
99
100 if not partner_id:
101- fcsv_csv_Log.writerow({'error' : 'Wrong, You can not generate a sale without a partner'})
102+ fcsv_csv_Log.writerow({'error' : 'Wrong, You can not generate a purchase without a partner'})
103
104 assert partner_id , 'Wrong, You can not generate a purchase without a partner'
105
106@@ -60,6 +61,9 @@
107 'partner_id': partner_id,
108 'location_id': ref('stock_location_stock_purchase_test_data')})
109
110+ if product_data[0].type == 'service' :
111+ purchase_order_data.update({'invoice_method': 'picking'})
112+
113 #~ Data of purchase order line
114 purchase_order_line_data = purchase_order_line_obj.onchange_product_id(cr, uid, [], purchase_order_data.get('pricelist_id'), product_id, qty=1.0, uom_id=1,
115 partner_id=partner_id, date_order=False,
116@@ -77,7 +81,7 @@
117 #~ Create purchase order with this product
118 purchase_order_id = self.create(cr, uid, purchase_order_data )
119 except Exception, e:
120- fcsv_csv_Log.writerow({'error' : tools.ustr(e).replace('\n', ''), 'localization': 'Create Purchase', 'product_id' : repr(product_id)})
121+ fcsv_csv_Log.writerow({'error' : tools.ustr(e), 'localization': 'Create Purchase', 'product_id' : repr(product_id)})
122
123 #~ Click button Confirm
124 if purchase_order_id:
125@@ -85,15 +89,15 @@
126 wf_service = netsvc.LocalService("workflow")
127 wf_service.trg_validate(uid, 'purchase.order', purchase_order_id , 'purchase_confirm', cr)
128 except Exception, e:
129- fcsv_csv_Log.writerow({'error' : tools.ustr(e).replace('\n', ''), 'localization': 'Confirm purchase', 'product_id' : repr(product_id)})
130+ fcsv_csv_Log.writerow({'error' : tools.ustr(e), 'localization': 'Confirm purchase', 'product_id' : repr(product_id)})
131
132- #~ Chech picking out by purchase order
133+ #~ Check picking out by purchase order
134 if not product_data[0].type == 'service' :
135 try:
136 stock_picking_in_ids = stock_picking_in_object.search(cr, uid, [('purchase_id','=',purchase_order_id)])
137 assert len(stock_picking_in_ids) > 0 , 'Wrong. Stock picking in not fund'
138 except Exception, e:
139- fcsv_csv_Log.writerow({'error' : tools.ustr(e).replace('\n', ''), 'localization': 'Check picking in', 'product_id' : repr(product_id)})
140+ fcsv_csv_Log.writerow({'error' : tools.ustr(e), 'localization': 'Check picking in', 'product_id' : repr(product_id)})
141
142 #~ Create invoice for this purchase order
143 try:
144@@ -104,20 +108,24 @@
145 except Exception, e:
146 #~ cr.execute("ROLLBACK TO SAVEPOINT purchase_order_savepoint")
147 fcsv_csv_ProductLog.writerow({'id':repr(product_data[0].id),
148- 'name': product_data[0].name.encode('utf8').replace(',','.'),
149- 'name_category': product_data[0].categ_id.name.encode('utf8').replace(',','.'),
150- 'error': tools.ustr(e).replace('\n', '')})
151+ 'name': product_data[0].name.encode('utf8','strict'),
152+ 'name_category': product_data[0].categ_id.name.encode('utf8','strict'),
153+ 'error': repr(tools.ustr(e))})
154
155 #~ Validate invoice for this purchase order
156 if invoice_id:
157 if invoice_id.get('res_id', False):
158 cost_invoice = account_invoice_obj.browse(cr, uid, invoice_id.get('res_id'), context=context).amount_total or 0
159 account_invoice_obj.write(cr, uid, [invoice_id.get('res_id')], {'check_total' : cost_invoice}, context=context)
160- try:
161- wf_service = netsvc.LocalService("workflow")
162- wf_service.trg_validate(uid, 'account.invoice', invoice_id.get('res_id') , 'invoice_open', cr)
163- except Exception, e:
164- fcsv_csv_Log.writerow({'error' : tools.ustr(e).replace('\n', ''), 'localization': 'Validate Invoice', 'product_id' : repr(product_id)})
165-
166- assert len(products_tax_not_fund) == 0 , 'Wrong. Some products not have tax : %s' % (products_tax_not_fund)
167-
168+ try:
169+ wf_service = netsvc.LocalService("workflow")
170+ wf_service.trg_validate(uid, 'account.invoice', invoice_id.get('res_id') , 'invoice_open', cr)
171+ except Exception, e:
172+ fcsv_csv_Log.writerow({'error' : tools.ustr(e), 'localization': 'Validate Invoice', 'product_id' : repr(product_id)})
173+ else:
174+ fcsv_csv_Log.writerow({'error' : 'Not found invoice for this purchase order', 'localization': 'Validate Invoice', 'product_id' : repr(product_id)})
175+
176+ f_write_ProductLog_csv.close()
177+ f_write_Log_csv.close()
178+ #~ assert len(products_tax_not_fund) == 0 , 'Wrong. Some products not have tax : %s' % (products_tax_not_fund)
179+
180
181=== modified file 'sale_test_data_imp/__openerp__.py'
182--- sale_test_data_imp/__openerp__.py 2013-10-09 14:47:35 +0000
183+++ sale_test_data_imp/__openerp__.py 2013-10-23 23:20:26 +0000
184@@ -43,6 +43,12 @@
185
186 This test yaml only works with user admin and the search of partner and
187 product is based in the company that have this user assigned.
188+
189+-You will need to apply the patch patch/uid_yaml_import.py.patch,
190+that is located in this module ( use:patch -b file.py file.patch ) in
191+the server.
192+
193+This patch is momentary.
194 """,
195 "website": "http://vauxoo.com",
196 "category": "Addons Vauxoo",
197
198=== added directory 'sale_test_data_imp/patch'
199=== added file 'sale_test_data_imp/patch/uid_yaml_import.py.patch'
200--- sale_test_data_imp/patch/uid_yaml_import.py.patch 1970-01-01 00:00:00 +0000
201+++ sale_test_data_imp/patch/uid_yaml_import.py.patch 2013-10-23 23:20:26 +0000
202@@ -0,0 +1,40 @@
203+=== modified file 'openerp/tools/yaml_import.py'
204+--- openerp/tools/yaml_import.py 2012-12-01 11:35:24 +0000
205++++ openerp/tools/yaml_import.py 2013-10-16 17:49:19 +0000
206+@@ -101,7 +101,9 @@
207+ return dict.__getitem__(self, key)
208+
209+ class YamlInterpreter(object):
210+- def __init__(self, cr, module, id_map, mode, filename, report=None, noupdate=False, loglevel=logging.DEBUG):
211++ def __init__(self, cr, module, id_map, mode, filename, report=None, noupdate=False, loglevel=logging.DEBUG, context=None):
212++ if context is None:
213++ context = {}
214+ self.cr = cr
215+ self.module = module
216+ self.id_map = id_map
217+@@ -113,8 +115,8 @@
218+ self.noupdate = noupdate
219+ self.loglevel = loglevel
220+ self.pool = pooler.get_pool(cr.dbname)
221+- self.uid = 1
222+- self.context = {} # opererp context
223++ self.uid = context.get('uid', 1) #TODO: Use session user
224++ self.context = context # opererp context
225+ self.eval_context = {'ref': self._ref(),
226+ '_ref': self._ref(), # added '_ref' so that record['ref'] is possible
227+ 'time': time,
228+@@ -919,12 +921,12 @@
229+ is_preceded_by_comment = False
230+ return is_preceded_by_comment
231+
232+-def yaml_import(cr, module, yamlfile, kind, idref=None, mode='init', noupdate=False, report=None):
233++def yaml_import(cr, module, yamlfile, kind, idref=None, mode='init', noupdate=False, report=None, context=None):
234+ if idref is None:
235+ idref = {}
236+ loglevel = logging.TEST if kind == 'test' else logging.DEBUG
237+ yaml_string = yamlfile.read()
238+- yaml_interpreter = YamlInterpreter(cr, module, idref, mode, filename=yamlfile.name, report=report, noupdate=noupdate, loglevel=loglevel)
239++ yaml_interpreter = YamlInterpreter(cr, module, idref, mode, filename=yamlfile.name, report=report, noupdate=noupdate, loglevel=loglevel, context=context)
240+ yaml_interpreter.process(yaml_string)
241+
242+ # keeps convention of convert.py
243
244=== modified file 'sale_test_data_imp/test/sale_order_product_can_be_sold.yml'
245--- sale_test_data_imp/test/sale_order_product_can_be_sold.yml 2013-10-11 19:13:51 +0000
246+++ sale_test_data_imp/test/sale_order_product_can_be_sold.yml 2013-10-23 23:20:26 +0000
247@@ -20,7 +20,7 @@
248 stock_picking_out_object = self.pool.get('stock.picking.out')
249 product_ids = product_obj.search(cr, uid, [('sale_ok','=','True'),
250 ('active','=','True'),
251- ('company_id','=',company_id)])
252+ '|',('company_id','=',company_id),('company_id','=',False)])
253 invoice_id = None
254 partner_id = None
255 products_tax_not_fund = []
256@@ -44,7 +44,7 @@
257 fcsv_csv_Log.writerow({'error': 'error', 'localization':'localization' ,'product_id': 'product_id'})
258
259 except Exception, e:
260- fcsv_csv_Log.writerow({'error' : tools.ustr(e).replace('\n', ''), 'localization':'Error create files'})
261+ fcsv_csv_Log.writerow({'error' : tools.ustr(e), 'localization':'Error create files'})
262
263 if not partner_id:
264 fcsv_csv_Log.writerow({'error' : 'Wrong, You can not generate a sale without a partner'})
265@@ -58,6 +58,9 @@
266 sale_order_data = self.onchange_partner_id(cr, uid, [], partner_id, context=context)['value']
267 sale_order_data.update({'picking_policy': 'direct','partner_id': partner_id,'order_policy': 'manual',})
268
269+ if product_data[0].type == 'service' :
270+ sale_order_data.update({'order_policy': 'picking'})
271+
272 #~ Data of sale order line
273 sale_order_line_data = sale_order_line_obj.product_id_change(cr, uid, [], sale_order_data.get('pricelist_id'), product_id, qty=1,
274 uom=False, qty_uos=0, uos=False, name='', partner_id=partner_id,
275@@ -74,14 +77,14 @@
276 #~ Create sale order with this product
277 sale_order_id = self.create(cr, uid, sale_order_data )
278 except Exception, e:
279- fcsv_csv_Log.writerow({'error' : tools.ustr(e).replace('\n', ''), 'localization': 'Create sale order', 'product_id' : repr(product_id)})
280+ fcsv_csv_Log.writerow({'error' : tools.ustr(e), 'localization': 'Create sale order', 'product_id' : repr(product_id)})
281
282 #~ Click button Confirm
283 if sale_order_id:
284 try:
285 self.action_button_confirm(cr, uid, [sale_order_id],context=context)
286 except Exception, e:
287- fcsv_csv_Log.writerow({'error' : tools.ustr(e).replace('\n', ''), 'localization': 'Confirm sale order', 'product_id' : repr(product_id)})
288+ fcsv_csv_Log.writerow({'error' : tools.ustr(e), 'localization': 'Confirm sale order', 'product_id' : repr(product_id)})
289
290 #~ Chech picking out by sale order
291 if not product_data[0].type == 'service' :
292@@ -89,7 +92,7 @@
293 stock_picking_out_ids = stock_picking_out_object.search(cr, uid, [('sale_id','=',sale_order_id)])
294 assert len(stock_picking_out_ids) > 0 , 'Wrong. Stock picking out not fund'
295 except Exception, e:
296- fcsv_csv_Log.writerow({'error' : tools.ustr(e).replace('\n', ''), 'localization': 'Check picking out', 'product_id' : repr(product_id)})
297+ fcsv_csv_Log.writerow({'error' : tools.ustr(e), 'localization': 'Check picking out', 'product_id' : repr(product_id)})
298
299 #~ Create invoice for this sale order
300 try:
301@@ -103,18 +106,20 @@
302 except Exception, e:
303 #~ cr.execute("ROLLBACK TO SAVEPOINT sale_order_savepoint")
304 fcsv_csv_ProductLog.writerow({'id':repr(product_data[0].id),
305- 'name': product_data[0].name.encode('utf8').replace(',','.'),
306- 'name_category': product_data[0].categ_id.name.encode('utf8').replace(',','.'),
307- 'error': tools.ustr(e).replace('\n', '')})
308+ 'name': product_data[0].name.encode('utf8','strict'),
309+ 'name_category': product_data[0].categ_id.name.encode('utf8','strict'),
310+ 'error': repr(tools.ustr(e))})
311 #~ Validate invoice for this sale order
312 if invoice_id:
313 try:
314 wf_service = netsvc.LocalService("workflow")
315 wf_service.trg_validate(uid, 'account.invoice', invoice_id.get('res_id') , 'invoice_open', cr)
316 except Exception, e:
317- fcsv_csv_Log.writerow({'error' : tools.ustr(e).replace('\n', ''), 'localization': 'Validate Invoice', 'product_id' : repr(product_id)})
318-
319+ fcsv_csv_Log.writerow({'error' : tools.ustr(e), 'localization': 'Validate Invoice', 'product_id' : repr(product_id)})
320+ else:
321+ fcsv_csv_Log.writerow({'error' : 'Not found invoice for this sale order', 'localization': 'Validate Invoice', 'product_id' : repr(product_id)})
322+
323 f_write_ProductLog_csv.close()
324 f_write_Log_csv.close()
325- assert len(products_tax_not_fund) == 0 , 'Wrong. Some products not have tax : %s' % (products_tax_not_fund)
326+ #~ assert len(products_tax_not_fund) == 0 , 'Wrong. Some products not have tax : %s' % (products_tax_not_fund)
327