Merge lp:~nicolariolini/micronaet-fashion/nicola into lp:micronaet-fashion

Proposed by Nicola Riolini - Micronaet
Status: Merged
Approved by: Anna Micronaet
Approved revision: 206
Merged at revision: 127
Proposed branch: lp:~nicolariolini/micronaet-fashion/nicola
Merge into: lp:micronaet-fashion
Diff against target: 349 lines (+264/-3) (has conflicts)
6 files modified
fashion/__init__.py (+1/-0)
fashion/errata_corrige.py (+189/-0)
fashion/etl/errata_corrige.py (+41/-0)
fashion/etl/import.py (+2/-2)
fashion/wizard/duplication_fashion.py (+26/-0)
fashion/wizard/duplication_fashion_view.xml (+5/-1)
Contents conflict in fashion/report/form_A.odt
Contents conflict in fashion/report/form_C.odt
Contents conflict in fashion/report/form_D.odt
To merge this branch: bzr merge lp:~nicolariolini/micronaet-fashion/nicola
Reviewer Review Type Date Requested Status
Micronaet s.r.l. Pending
Review via email: mp+211534@code.launchpad.net

Description of the change

Ultime modifiche per problemi ed errori vari

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'fashion/__init__.py'
2--- fashion/__init__.py 2014-02-17 08:20:34 +0000
3+++ fashion/__init__.py 2014-03-18 14:06:54 +0000
4@@ -22,6 +22,7 @@
5 import fashion
6 import wizard
7 import report
8+import errata_corrige # only for startup phase
9
10
11 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
12
13=== added file 'fashion/errata_corrige.py'
14--- fashion/errata_corrige.py 1970-01-01 00:00:00 +0000
15+++ fashion/errata_corrige.py 2014-03-18 14:06:54 +0000
16@@ -0,0 +1,189 @@
17+#!/usr/bin/python
18+# -*- coding: utf-8 -*-
19+##############################################################################
20+#
21+# OpenERP, Open Source Management Solution
22+# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). All Rights Reserved
23+# d$
24+#
25+# This program is free software: you can redistribute it and/or modify
26+# it under the terms of the GNU General Public License as published by
27+# the Free Software Foundation, either version 3 of the License, or
28+# (at your option) any later version.
29+#
30+# This program is distributed in the hope that it will be useful,
31+# but WITHOUT ANY WARRANTY; without even the implied warranty of
32+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
33+# GNU General Public License for more details.
34+#
35+# You should have received a copy of the GNU General Public License
36+# along with this program. If not, see <http://www.gnu.org/licenses/>.
37+#
38+##############################################################################
39+import os
40+import sys
41+import csv
42+import base64
43+from osv import osv, fields
44+from datetime import datetime
45+from openerp.tools import DEFAULT_SERVER_DATETIME_FORMAT, DEFAULT_SERVER_DATE_FORMAT
46+from openerp import tools
47+import pdb
48+from openerp.tools.translate import _
49+
50+
51+# Utility:
52+def Prepare(valore):
53+ # For problems: input win output ubuntu; trim extra spaces
54+ #valore=valore.decode('ISO-8859-1')
55+ valore=valore.decode('cp1252')
56+ valore=valore.encode('utf-8')
57+ return valore.strip()
58+
59+def format_date(valore,date=True):
60+ ''' Formatta nella data di PG
61+ '''
62+ try:
63+ if date:
64+ gma = valore.split(' ')[0].split('/')
65+ return '%s-%02d-%02d' % (gma[2], int(gma[1]), int(gma[0]))
66+ except:
67+ return False
68+
69+def format_currency(valore):
70+ ''' Formatta nel float per i valori currency
71+ '''
72+ try:
73+ return float(valore.split(' ')[-1].replace(',','.'))
74+ except:
75+ return 0.0
76+
77+class fashion_form_utility(osv.osv):
78+ ''' Utility procedure for errata corrige
79+ '''
80+ _name = 'fashion.form'
81+ _inherit = 'fashion.form'
82+
83+ def correct_supplier_code(self, cr, uid, context=None):
84+ ''' test partner and find access_id + 1000
85+ '''
86+ partner_pool = self.pool.get('res.partner')
87+ accessory_pool = self.pool.get('fashion.form.accessory.rel')
88+ accessory_ids = accessory_pool.search(cr, uid, [], context=context)
89+ for item in accessory_pool.browse(cr, uid, accessory_ids, context=context):
90+ if item.supplier_id:
91+ access_id = item.supplier_id.access_id
92+ if access_id < 1000: # wrong supplier
93+ partner_ids = partner_pool.search(cr, uid, [('access_id', '=', access_id + 1000)], context=context)
94+ if partner_ids and len(partner_ids) == 1:
95+ accessory_pool.write(cr, uid, item.id, {'supplier_id': partner_ids[0], }, context=context)
96+ print "[INFO] Rel [%s] Update supplier_id %s with %s" % (item.id, item.supplier_id.id, partner_ids[0])
97+ else:
98+ print "[ERR] find partner_ids", partner_ids
99+ return True
100+
101+ def set_customer_code_in_form(self, cr, uid, context=None):
102+ ''' Read all customer code in customer and set if correct and present
103+ in form if there's the same customer
104+ '''
105+ codes = {}
106+ form_pool = self.pool.get('fashion.form')
107+ form_ids = form_pool.search(cr, uid, [], context=context)
108+ form_proxy = form_pool.browse(cr, uid, form_ids, context=context)
109+ for item in form_proxy:
110+ partner_id = False
111+ code = False
112+ update = True
113+ for customer in item.partner_rel_ids:
114+ if customer.partner_id:
115+ if not partner_id:
116+ partner_id = customer.partner_id.id
117+ if partner_id != customer.partner_id.id:
118+ update = False
119+ break
120+ if customer.code: # take if present
121+ code = customer.code
122+ if update and code:
123+ codes[item.id] = code
124+ for key in codes:
125+ form_pool.write(cr, uid, key, {'customer_code': codes[key], }, context=context)
126+ return True
127+
128+ def set_correct_accessory_price(self, cr, uid, context=None):
129+ ''' Read files with price in rel and update only price
130+ '''
131+ #form_converter={}
132+ #form_pool = self.pool.get('fashion.form')
133+ #form_ids = form_pool.search(cr, uid, [], context = context)
134+ #form_proxy = form_pool.browse(cr, uid, form_ids, context = context)
135+ #for item in form_proxy:
136+ # if item.access_id:
137+ # form_converter[item.access_id] = item.id
138+
139+ #accessory_converter={}
140+ #accessory_pool = self.pool.get('fashion.form.accessory')
141+ #accessory_ids = accessory_pool.search(cr, uid, [], context = context)
142+ #accessory_proxy = accessory_pool.browse(cr, uid, accessory_ids, context = context)
143+ #for item in accessory_proxy:
144+ # if item.access_id:
145+ # accessory_converter[item.access_id] = item.id
146+
147+ print "Start import fashion.form.accessory.rel"
148+ file_input = os.path.expanduser('~/etl/fashion/SchXacc.txt')
149+ separator = '\t'
150+ lines = csv.reader(open(file_input,'rU'),delimiter=separator)
151+ max_col = False
152+ tot = 0
153+ accessory_pool = self.pool.get('fashion.form.accessory.rel')
154+ try:
155+ for line in lines:
156+ tot += 1
157+ if not max_col:
158+ max_col = len(line)
159+
160+ if len(line)!=max_col:
161+ print "[ERROR]", tot, "Column error! "
162+ continue
163+
164+ access_id = line[0]
165+ #form = Prepare(line[1])
166+ #accessory = Prepare(line[2])
167+ #name = Prepare(line[3])
168+ #um = Prepare(line[4])
169+ quantity = format_currency(Prepare(line[5]))
170+ #supplier = Prepare(line[6])
171+ currency = format_currency(Prepare(line[7]))
172+ #note = Prepare(line[8]) # TODO mettere nel database
173+ #gerber_name = Prepare(line[9])
174+ #gerber_desc = Prepare(line[10])
175+ #gerber_h = Prepare(line[11])
176+ #gerber_l = Prepare(line[12])
177+ tot_cost = currency * quantity if currency and quantity else 0.0
178+
179+ #form_id = form_converter.get(form, False)
180+ #accessory_id = accessory_converter.get(form, False)
181+ #if not form_id or not accessory_id:
182+ # print "[WARN] %s: Form %s (%s) or Accessory %s (%s) not found!!" % (
183+ # tot, form, form_id, accessory, accessory_id)
184+ # continue
185+
186+ accessory_ids = accessory_pool.search(cr, uid, [('access_id', '=', access_id)], context=context)
187+ if accessory_ids and (quantity or currency):
188+ if len(accessory_ids) != 1:
189+ print "Errore accessory must be 1"
190+ continue
191+ accessory_pool.write(cr, uid, accessory_ids[0], {
192+ 'quantity': quantity,
193+ 'currency': currency,
194+ 'tot_cost': tot_cost,
195+ #'supplier_id': supplier_id,
196+ }, context=context)
197+ print "[INFO] Line %s Update %s {%s}!" % (tot, access_id, line)
198+ else:
199+ #print "[WARN] Line %s Jumped Access_id %s!" % (tot, access_id)
200+ pass
201+ except:
202+ print '[ERROR] Error importing data!'
203+ return True
204+
205+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
206
207=== added file 'fashion/etl/errata_corrige.py'
208--- fashion/etl/errata_corrige.py 1970-01-01 00:00:00 +0000
209+++ fashion/etl/errata_corrige.py 2014-03-18 14:06:54 +0000
210@@ -0,0 +1,41 @@
211+#!/usr/bin/env python
212+# -*- encoding: utf-8 -*-
213+# Modules used for ETL - Create User
214+
215+# Modules required:
216+import os
217+import xmlrpclib, sys, csv, ConfigParser
218+from datetime import datetime
219+
220+
221+# Set up parameters (for connection to Open ERP Database) *********************
222+config = ConfigParser.ConfigParser()
223+file_config = os.path.expanduser('~/etl/fashion/openerp.cfg')
224+config.read([file_config])
225+dbname = config.get('dbaccess','dbname')
226+user = config.get('dbaccess','user')
227+pwd = config.get('dbaccess','pwd')
228+server = config.get('dbaccess','server')
229+port = config.get('dbaccess','port') # verify if it's necessary: getint
230+separator = eval(config.get('dbaccess','separator')) # test
231+
232+# XMLRPC connection for autentication (UID) and proxy
233+sock = xmlrpclib.ServerProxy('http://%s:%s/xmlrpc/common' % (server, port), allow_none=True)
234+uid = sock.login(dbname ,user ,pwd)
235+sock = xmlrpclib.ServerProxy('http://%s:%s/xmlrpc/object' % (server, port), allow_none=True)
236+
237+if len(sys.argv) != 2:
238+ print "Use: errata_corrige parameters\n parameters: supplier, code, price"
239+ sys.exit()
240+if sys.argv[1] == 'supplier':
241+ result = sock.execute(dbname, uid, pwd, "fashion.form" , "correct_supplier_code")
242+ print "Supplier updated"
243+
244+elif sys.argv[1] == 'code':
245+ result = sock.execute(dbname, uid, pwd, "fashion.form" , "set_customer_code_in_form")
246+ print "Code updated"
247+
248+elif sys.argv[1] == 'price':
249+ result = sock.execute(dbname, uid, pwd, "fashion.form" , "set_correct_accessory_price")
250+ print "Price updated"
251+
252
253=== modified file 'fashion/etl/import.py'
254--- fashion/etl/import.py 2014-03-18 07:47:02 +0000
255+++ fashion/etl/import.py 2014-03-18 14:06:54 +0000
256@@ -1397,7 +1397,7 @@
257
258 access_id = line[0]
259 form = Prepare(line[1])
260- accessory_id = Prepare(line[2])
261+ accessory = Prepare(line[2])
262 name = Prepare(line[3])
263 um = Prepare(line[4])
264 quantity = format_currency(Prepare(line[5]))
265@@ -1420,7 +1420,7 @@
266 log_event("[WARNING] Line jumped, no form ID, Access ID:", access_id , "Access Form ID:", form)
267 continue
268
269- accessory_id = fashion_form_accessory.get(accessory_id, 0)
270+ accessory_id = fashion_form_accessory.get(accessory, 0)
271 if supplier:
272 supplier = str(extra_id + int(supplier))
273 supplier_id = res_partner.get(supplier, False)
274
275=== renamed file 'fashion/report/form_A.odt' => 'fashion/report/form_A.odt.OTHER'
276Binary files fashion/report/form_A.odt 2014-03-17 16:47:36 +0000 and fashion/report/form_A.odt.OTHER 2014-03-18 14:06:54 +0000 differ
277=== added file 'fashion/report/form_Aa.odt'
278Binary files fashion/report/form_Aa.odt 1970-01-01 00:00:00 +0000 and fashion/report/form_Aa.odt 2014-03-18 14:06:54 +0000 differ
279=== renamed file 'fashion/report/form_C.odt' => 'fashion/report/form_C.odt.OTHER'
280Binary files fashion/report/form_C.odt 2014-03-17 16:47:36 +0000 and fashion/report/form_C.odt.OTHER 2014-03-18 14:06:54 +0000 differ
281=== renamed file 'fashion/report/form_D.odt' => 'fashion/report/form_D.odt.OTHER'
282Binary files fashion/report/form_D.odt 2014-03-17 16:47:36 +0000 and fashion/report/form_D.odt.OTHER 2014-03-18 14:06:54 +0000 differ
283=== modified file 'fashion/report/form_E.odt'
284Binary files fashion/report/form_E.odt 2014-03-17 13:05:45 +0000 and fashion/report/form_E.odt 2014-03-18 14:06:54 +0000 differ
285=== modified file 'fashion/wizard/duplication_fashion.py'
286--- fashion/wizard/duplication_fashion.py 2014-03-17 19:23:40 +0000
287+++ fashion/wizard/duplication_fashion.py 2014-03-18 14:06:54 +0000
288@@ -30,16 +30,42 @@
289 _name = 'fashion.duplication'
290 _description = 'Duplication'
291
292+ def _get_error(self, cr, uid, context=None):
293+ '''
294+ '''
295+ if context is None:
296+ context = {}
297+
298+ res = False
299+ form_id = context.get('active_id')
300+ if form_id:
301+ form_proxy = self.pool.get('fashion.form').browse(cr, uid, form_id, context=context)
302+ start = int(form_proxy.start or '0')
303+ size_base = int(form_proxy.size_base or '0')
304+ if not start: # default start
305+ start = 40
306+ col_ref = 1 + (size_base - start) / 2
307+ if col_ref != form_proxy.col_ref:
308+ res = "Non conforme la gestione colonne:\nColonna base: %s\nColonna di partenza: %s\nColonna di riferimento: %s\nValore corretto %s (reimpostarlo e poi duplicare)\n" % (
309+ size_base,
310+ start,
311+ form_proxy.col_ref,
312+ col_ref,
313+ )
314+ return res
315+
316 _columns = {
317 'duplication': fields.selection([
318 ('version', 'New Revision'),
319 ('form', 'New Form'),
320 ], 'Duplication', select=True),
321 'code': fields.char('New code', size=10),
322+ 'error': fields.text('Error'),
323 }
324
325 _defaults = {
326 'duplication': lambda *a: 'version',
327+ 'error': lambda s, cr, uid, ctx: s._get_error(cr, uid, ctx),
328 }
329
330 def duplication (self, cr, uid, ids, context=None):
331
332=== modified file 'fashion/wizard/duplication_fashion_view.xml'
333--- fashion/wizard/duplication_fashion_view.xml 2013-12-12 14:25:25 +0000
334+++ fashion/wizard/duplication_fashion_view.xml 2014-03-18 14:06:54 +0000
335@@ -10,9 +10,13 @@
336 <field name="arch" type="xml">
337 <form string="Season" version="7.0">
338 <sheet>
339- <group col='4'>
340+ <group colspan="4" col='4'>
341 <field name="duplication"/>
342 <field name="code" attrs="{'invisible':[('duplication','=','version')], 'required':[('duplication','=','form')]}"/>
343+ <group colspan="4" col='4' name="error" attrs="{'invisible': [('error','=',False)]}">
344+ <separator string="Error" colspan="4"/>
345+ <field name="error" nolabel="1" colspan="4"/>
346+ </group>
347 <button string='Create' name='duplication' type='object' icon='STOCK_APPLY'/>
348 <button string="Cancel" special="cancel" icon='STOCK_CANCEL'/>
349 </group>

Subscribers

People subscribed via source and target branches