This commit is contained in:
resteve 2016-03-09 22:20:30 +01:00
parent 2d03141d8c
commit eae51d2fd1
4 changed files with 17 additions and 2 deletions

View file

@ -2,3 +2,9 @@ Stock Lot CSV Module
#################### ####################
Módulo para la importación de lotes de producto mediante ficheros CSV. Módulo para la importación de lotes de producto mediante ficheros CSV.
El fichero CSV contendrá esta estructura:
"Código producto","Número de lote"
Si el lote ya existe en el producto, este no será creado y se omite.

View file

@ -26,6 +26,10 @@ msgctxt "field:import.csv.start,separator:"
msgid "CSV Separator" msgid "CSV Separator"
msgstr "Separador CSV" msgstr "Separador CSV"
msgctxt "help:import.csv.start,archive:"
msgid "First column: product code. Second column: number lot"
msgstr "Primera columna: codi producte. Segona columna: número lot"
msgctxt "help:import.csv.start,header:" msgctxt "help:import.csv.start,header:"
msgid "Set this check box to true if CSV file has headers." msgid "Set this check box to true if CSV file has headers."
msgstr "Marqueu aquesta casella si l'arxiu CSV té capçaleres." msgstr "Marqueu aquesta casella si l'arxiu CSV té capçaleres."

View file

@ -26,6 +26,10 @@ msgctxt "field:import.csv.start,separator:"
msgid "CSV Separator" msgid "CSV Separator"
msgstr "Separador CSV" msgstr "Separador CSV"
msgctxt "help:import.csv.start,archive:"
msgid "First column: product code. Second column: number lot"
msgstr "Primera columna: código producto. Segunda columna: número lote"
msgctxt "help:import.csv.start,header:" msgctxt "help:import.csv.start,header:"
msgid "Set this check box to true if CSV file has headers." msgid "Set this check box to true if CSV file has headers."
msgstr "Marque esta casilla si el archivo CSV tiene cabeceras." msgstr "Marque esta casilla si el archivo CSV tiene cabeceras."

View file

@ -18,7 +18,8 @@ logger = getLogger(__name__)
class ImportCSVStart(ModelView): class ImportCSVStart(ModelView):
'Import CSV start' 'Import CSV start'
__name__ = 'import.csv.start' __name__ = 'import.csv.start'
archive = fields.Binary('Archive', required=True) archive = fields.Binary('Archive', required=True,
help='First column: product code. Second column: number lot')
character_encoding = fields.Selection([ character_encoding = fields.Selection([
('utf-8', 'UTF-8'), ('utf-8', 'UTF-8'),
('latin-1', 'Latin-1'), ('latin-1', 'Latin-1'),
@ -88,7 +89,7 @@ class ImportCSV(Wizard):
lot = Lot.__table__() lot = Lot.__table__()
product = Product.__table__() product = Product.__table__()
cursor.execute(*lot cursor.execute(*lotr
.join(product, 'LEFT', condition=(lot.product == product.id)) .join(product, 'LEFT', condition=(lot.product == product.id))
.select( .select(
product.code.as_('code'), product.code.as_('code'),