Browse Source

Módulo para etiquetar se cambio medidas

SEBAS 6 months ago
commit
d4ee9a152b

+ 24 - 0
__init__.py

@@ -0,0 +1,24 @@
+# -*- encoding: utf-8 -*-
+##############################################################################
+#
+#    OpenERP, Open Source Management Solution
+#
+#    Copyright (c) 2015 ICTSTUDIO (www.ictstudio.eu).
+#
+#    This program is free software: you can redistribute it and/or modify
+#    it under the terms of the GNU Affero General Public License as
+#    published by the Free Software Foundation, either version 3 of the
+#    License, or (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+#    GNU Affero General Public License for more details.
+#
+#    You should have received a copy of the GNU Affero General Public License
+#    along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+from . import models
+from . import wizard

BIN
__init__.pyc


+ 40 - 0
__openerp__.py

@@ -0,0 +1,40 @@
+# -*- encoding: utf-8 -*-
+##############################################################################
+#
+#    Copyright (C) 2015 ICTSTUDIO (<http://www.ictstudio.eu>).
+#
+#    This program is free software: you can redistribute it and/or modify
+#    it under the terms of the GNU Affero General Public License as
+#    published by the Free Software Foundation, either version 3 of the
+#    License, or (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU Affero General Public License for more details.
+#
+#    You should have received a copy of the GNU Affero General Public License
+#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+{
+    'name': 'Product Labels',
+    'version': '8.0.0.0.1',
+    'category': 'Stock',
+    'author': 'ICTSTUDIO | André Schenkels',
+    'website': 'http://www.ictstudio.eu',
+    'license': 'AGPL-3',
+    'summary': 'Print Labels on Products',
+    'depends': [
+        'stock',
+    ],
+    'data': [
+        'data/report_paperformat.xml',
+        'report/report_product_labels.xml',
+        'report/report_product_labels_wizard.xml',
+        'views/product_product.xml',
+        'views/product_template.xml',
+        'wizard/product_product_label_print.xml'
+    ],
+    'installable': True,
+}

+ 20 - 0
data/report_paperformat.xml

@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<openerp>
+    <data>
+        <record id="paperformat_product_label" model="report.paperformat">
+            <field name="name">Product Label</field>
+            <field name="default" eval="True"/>
+            <field name="format">custom</field>
+            <field name="page_height">40</field>
+            <field name="page_width">65</field>
+            <field name="orientation">Portrait</field>
+            <field name="margin_top">1</field>
+            <field name="margin_bottom">1</field>
+            <field name="margin_left">2</field>
+            <field name="margin_right">2</field>
+            <field name="header_line" eval="False" />
+            <field name="header_spacing">0</field>
+            <field name="dpi">300</field>
+        </record>
+    </data>
+</openerp>

+ 24 - 0
models/__init__.py

@@ -0,0 +1,24 @@
+# -*- encoding: utf-8 -*-
+##############################################################################
+#
+#    OpenERP, Open Source Management Solution
+#
+#    Copyright (c) 2015 ICTSTUDIO (www.ictstudio.eu).
+#
+#    This program is free software: you can redistribute it and/or modify
+#    it under the terms of the GNU Affero General Public License as
+#    published by the Free Software Foundation, either version 3 of the
+#    License, or (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+#    GNU Affero General Public License for more details.
+#
+#    You should have received a copy of the GNU Affero General Public License
+#    along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+from . import product_product
+from . import product_template

BIN
models/__init__.pyc


+ 35 - 0
models/product_product.py

@@ -0,0 +1,35 @@
+# -*- encoding: utf-8 -*-
+##############################################################################
+#
+#    OpenERP, Open Source Management Solution
+#
+#    Copyright (c) 2015 ICTSTUDIO (www.ictstudio.eu).
+#
+#    This program is free software: you can redistribute it and/or modify
+#    it under the terms of the GNU Affero General Public License as
+#    published by the Free Software Foundation, either version 3 of the
+#    License, or (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+#    GNU Affero General Public License for more details.
+#
+#    You should have received a copy of the GNU Affero General Public License
+#    along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+from openerp import models, fields, api, _
+import logging
+
+_logger = logging.getLogger(__name__)
+
+class ProductProduct(models.Model):
+    _inherit = 'product.product'
+
+    @api.multi
+    def print_labels(self):
+        return self.env['report'].get_action(self,
+                'product_labels.product_label'
+        )

BIN
models/product_product.pyc


+ 37 - 0
models/product_template.py

@@ -0,0 +1,37 @@
+# -*- encoding: utf-8 -*-
+##############################################################################
+#
+#    OpenERP, Open Source Management Solution
+#
+#    Copyright (c) 2015 ICTSTUDIO (www.ictstudio.eu).
+#
+#    This program is free software: you can redistribute it and/or modify
+#    it under the terms of the GNU Affero General Public License as
+#    published by the Free Software Foundation, either version 3 of the
+#    License, or (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+#    GNU Affero General Public License for more details.
+#
+#    You should have received a copy of the GNU Affero General Public License
+#    along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+from openerp import models, fields, api, _
+import logging
+
+_logger = logging.getLogger(__name__)
+
+class ProductTemplate(models.Model):
+    _inherit = 'product.template'
+
+    @api.multi
+    def print_labels(self):
+        self.ensure_one()
+        return self.env['report'].get_action(
+                self.product_variant_ids,
+                'product_labels.product_label'
+        )

BIN
models/product_template.pyc


+ 61 - 0
report/report_product_labels.xml

@@ -0,0 +1,61 @@
+<?xml version="1.0" encoding="utf-8"?>
+<openerp>
+	<data>
+
+        <report
+			id="product.report_product_label"
+			string="Product Label"
+			model="product.product"
+			report_type="qweb-pdf"
+			file="product_label"
+			name="product_labels.product_label"
+		/>
+
+        <record id="product.report_product_label" model="ir.actions.report.xml">
+            <field name="paperformat_id" ref="product_labels.paperformat_product_label"/>
+        </record>
+
+
+		<template id="product_label">
+            <!-- Multicompany -->
+            <t t-if="o and 'company_id' in o">
+-				<t t-set="company" t-value="o.company_id"/>
+-			</t>
+-			 <t t-if="not o or not 'company_id' in o">
+-				<t t-set="company" t-value="res_company"/>
+-			</t>
+
+		    <t t-call="report.html_container">
+                <t t-foreach="docs" t-as="product">
+                    <div class="page">
+                        <div class="oe_structure"/>
+                        <div class="row">
+                            <table style="width: 100%; border: 1px solid black; text-align: center;">
+
+                                <tr style="border: 1px solid black;">
+                                        <td colspan="2">
+                                            <h4><span t-field="product.name"/></h4>
+                                        </td>
+                                </tr>
+                                <tr style="border: 1px solid black;">
+                                    <td colspan="2">
+                                        <h4><span>Code: </span><span t-field="product.default_code" /></h4>
+                                    </td>
+                                </tr>
+                                <tr style="border: 1px solid black;">
+                                    <td colspan="2">
+                                        <span t-if="product.ean13">
+                                            <img t-att-src="'/report/barcode/?type=%s&amp;value=%s&amp;width=%s&amp;height=%s' % ('EAN13', product.ean13, 600, 100)" style="margin-top: 5px; width:270px; height:50px"/>
+                                            <h5><span t-esc="product.ean13" /></h5>
+                                        </span>
+                                    </td>
+                                </tr>
+                            </table>
+                        </div>
+                    </div>
+                 </t>
+		    </t>
+		</template>
+
+	</data>
+</openerp>

+ 56 - 0
report/report_product_labels_wizard.xml

@@ -0,0 +1,56 @@
+<?xml version="1.0" encoding="utf-8"?>
+<openerp>
+    <data>
+
+        <report
+            id="report_product_product_label"
+            string="Product Label"
+            model="product.product.label"
+            report_type="qweb-pdf"
+            file="product_label"
+            name="product_labels.product_product_label"
+        />
+
+        <record id="report_product_product_label" model="ir.actions.report.xml">
+            <field name="paperformat_id" ref="product_labels.paperformat_product_label"/>
+        </record>
+
+        <template id="product_product_label">
+            <t t-call="report.html_container">
+                <t t-foreach="docs" t-as="label">
+                    <t t-foreach="label.label_lines" t-as="line">
+                        <t t-foreach="range(int(line.quantity))" t-as="range_line">
+                            <div class="page">
+                                <div class="oe_structure"/>
+                                <div class="row">
+                                    <table style="width: 100%; border: 1px solid black; text-align: center;">
+
+                                        <tr style="border: 1px solid black;">
+                                            <td colspan="2">
+                                                <h4><span t-field="line.product_id.name"/></h4>
+                                            </td>
+                                        </tr>
+                                        <tr style="border: 1px solid black;">
+                                            <td colspan="2">
+                                                <h4><span>Code: </span><span t-field="line.product_id.default_code" /></h4>
+                                            </td>
+                                        </tr>
+                                        <tr style="border: 1px solid black;">
+                                            <td colspan="2">
+                                                <span t-if="line.product_id.ean13">
+                                                    <img t-att-src="'/report/barcode/?type=%s&amp;value=%s&amp;width=%s&amp;height=%s' % ('EAN13', line.product_id.ean13, 600, 100)" style="margin-top: 5px; width:270px; height:20px"/>
+                                                    <h5><span t-esc="line.product_id.ean13" /></h5>
+                                                </span>
+                                            </td>
+                                        </tr>
+                                    </table>
+                                </div>
+                            </div>
+                        </t>
+                    </t>
+                </t>
+            </t>
+        </template>
+
+    </data>
+</openerp>

BIN
static/description/icon.png


+ 20 - 0
views/product_product.xml

@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<openerp>
+    <data>
+
+        <record id="product_normal_form_view" model="ir.ui.view">
+            <field name="name">ProductProductViewFormInherit</field>
+            <field name="model">product.product</field>
+            <field name="inherit_id" ref="product.product_normal_form_view" />
+            <field eval="900" name="priority"/>
+            <field name="arch" type="xml">
+                <xpath expr="//sheet" position="before">
+                    <header>
+                        <button class="oe_highlight" type="object" string="Etiqueta" name="print_labels"/>
+                    </header>
+                </xpath>
+            </field>
+        </record>
+
+    </data>
+</openerp>

+ 20 - 0
views/product_template.xml

@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<openerp>
+    <data>
+
+        <record id="product_template_only_form_view" model="ir.ui.view">
+            <field name="name">ProductTemplateViewFormInherit</field>
+            <field name="model">product.template</field>
+            <field name="priority" eval="900" />
+            <field name="inherit_id" ref="product.product_template_only_form_view"/>
+            <field name="arch" type="xml">
+                <xpath expr="//sheet" position="before">
+                    <header>
+                        <button class="oe_highlight" type="object" string="Etiqueta" name="print_labels"/>
+                    </header>
+                </xpath>
+            </field>
+        </record>
+
+    </data>
+</openerp>

+ 23 - 0
wizard/__init__.py

@@ -0,0 +1,23 @@
+# -*- encoding: utf-8 -*-
+##############################################################################
+#
+#    OpenERP, Open Source Management Solution
+#
+#    Copyright (c) 2015 ICTSTUDIO (www.ictstudio.eu).
+#
+#    This program is free software: you can redistribute it and/or modify
+#    it under the terms of the GNU Affero General Public License as
+#    published by the Free Software Foundation, either version 3 of the
+#    License, or (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+#    GNU Affero General Public License for more details.
+#
+#    You should have received a copy of the GNU Affero General Public License
+#    along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+from . import product_product_label_print

BIN
wizard/__init__.pyc


+ 82 - 0
wizard/product_product_label_print.py

@@ -0,0 +1,82 @@
+# -*- encoding: utf-8 -*-
+##############################################################################
+#
+#    OpenERP, Open Source Management Solution
+#
+#    Copyright (c) 2015 ICTSTUDIO (www.ictstudio.eu).
+#
+#    This program is free software: you can redistribute it and/or modify
+#    it under the terms of the GNU Affero General Public License as
+#    published by the Free Software Foundation, either version 3 of the
+#    License, or (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+#    GNU Affero General Public License for more details.
+#
+#    You should have received a copy of the GNU Affero General Public License
+#    along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+from openerp import models, fields, api
+
+
+class ProductProductLabel(models.TransientModel):
+    _name = "product.product.label"
+
+    label_lines = fields.One2many(
+            comodel_name='product.product.label.line',
+            inverse_name='label_id',
+            string='Labels'
+    )
+
+    @api.model
+    def default_get(self, fields):
+        res = super(ProductProductLabel, self).default_get(fields)
+        label_lines = self.lines_get()
+        res['label_lines'] = label_lines
+        return res
+
+    @api.multi
+    def lines_get(self):
+        context = self._context or {}
+        products = self.env['product.product'].browse(context.get('active_ids', []))
+        label_list = []
+        for product in products:
+            label_list.append([0,0,{
+                'product_id': product.id,
+                'quantity': 1
+            }])
+        return label_list
+
+    @api.multi
+    def print_labels(self):
+        records = self
+        return self.env['report'].get_action(records,
+                                             'product_labels.product_product_label'
+                                             )
+
+
+class ProductProductLabelLine(models.TransientModel):
+    _name = "product.product.label.line"
+
+    label_id = fields.Many2one(
+        comodel_name="product.product.label",
+        string="Product Label"
+    )
+    product_id = fields.Many2one(
+        comodel_name="product.product",
+        string="Product"
+    )
+    quantity = fields.Integer(string="Label Qty", default=1)
+
+    @api.one
+    def get_label_data(self):
+        return {
+            'label_id': self.label_id.id,
+            'name': self.product_id.name,
+            'code': self.product_id.default_code or False,
+            'barcode': self.product_id.ean13 or False,
+        }

BIN
wizard/product_product_label_print.pyc


+ 45 - 0
wizard/product_product_label_print.xml

@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="utf-8"?>
+<openerp>
+    <data>
+
+        <record id="product_product_label_view_form" model="ir.ui.view">
+            <field name="name">product.product.label.view.form</field>
+            <field name="model">product.product.label</field>
+            <field name="arch" type="xml">
+                <form string="Etiquetas">
+                    <group col="4">
+                        <field name="label_lines" string="Lineas">
+                            <tree editable="bottom">
+                                <field name="product_id" string="Producto"/>
+                                <field name="quantity" string="Cantidad"/>
+                            </tree>
+                        </field>
+                    </group>
+                    <footer>
+                        <button string="Imprimir" name="print_labels" type="object" default_focus="1" class="btn-primary"/>
+                        <button string="Cancelar" class="btn-default" special="cancel"/>
+                    </footer>
+                </form>
+            </field>
+        </record>
+
+        <record id="product_product_label_view_action" model="ir.actions.act_window">
+            <field name="name">Etiquetas</field>
+            <field name="res_model">product.product.label</field>
+            <field name="view_type">form</field>
+            <field name="view_mode">form</field>
+            <field name="view_id" ref="product_product_label_view_form"/>
+            <field name="target">new</field>
+        </record>
+
+        <record id="product_product_action_product_product_label" model="ir.values">
+            <field name="model_id" ref="product.model_product_product" />
+            <field name="name">Etiquetas</field>
+            <field name="key2">client_action_multi</field>
+            <field name="value" eval="'ir.actions.act_window,' +str(ref('product_product_label_view_action'))" />
+            <field name="key">action</field>
+            <field name="model">product.product</field>
+        </record>
+
+    </data>
+</openerp>