瀏覽代碼

Campo de Referencia de fabrica en Producto

sebas 3 年之前
當前提交
e7dfe7a881
共有 5 個文件被更改,包括 188 次插入0 次删除
  1. 22 0
      __init__.py
  2. 44 0
      __openerp__.py
  3. 78 0
      codigo_barra.py
  4. 44 0
      codigo_barra_view.xml
  5. 二進制
      static/description/icon.png

+ 22 - 0
__init__.py

@@ -0,0 +1,22 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+#    OpenERP, Open Source Management Solution
+#    Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
+#
+#    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 codigo_barra
+

+ 44 - 0
__openerp__.py

@@ -0,0 +1,44 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+#    OpenERP, Open Source Management Solution
+#    Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
+#
+#    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' : 'Campo de Referencia de fabrica en Producto',
+    'version' : '1.0',
+    'author' : 'Eiru Software/ Victor Obrist - Rodney Enciso Arias',
+    'sequence': 120,
+    'category': 'Product',
+    'website' : 'http://www.eiru.com.py',
+    'summary' : 'Campo de Referencia de fabrica en Producto',
+    'description' : """
+Campo de Referencia de fabrica en Producto.
+====================================================
+Agrega el campo de referencia de fabrica, en todos los sistemas se debe instalar
+
+
+""",
+    'depends' : ['product'],
+    'data' : [
+        'codigo_barra_view.xml',
+    ],
+    'installable' : True,
+}
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

+ 78 - 0
codigo_barra.py

@@ -0,0 +1,78 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+#    OpenERP, Open Source Management Solution
+#    Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
+#
+#    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 product_template(models.Model):
+    _name = 'product.template'
+    _inherit = 'product.template'
+
+    factory_reference = fields.Char('Referencia de fábrica',size=64)
+
+
+    @api.multi
+    def write(self, vals):
+        prod_tmpl_id = super(product_template,self).write(vals)
+
+        for p in self.product_variant_ids:
+            prod = self.env['product.product'].browse(p['id'])
+            ref = ''
+
+            if  prod.factory_reference:
+                if prod['factory_reference'] != None:
+                    #prod.factory_reference = prod['factory_reference']
+                    prod.factory_reference = self.factory_reference
+                    ref = prod['factory_reference']
+            elif self.factory_reference:
+                prod.factory_reference = self.factory_reference
+                ref = self['factory_reference']
+
+            prod['default_code'] = ref
+        return prod_tmpl_id
+
+class product_product(models.Model):
+    _name = 'product.product'
+    _inherit = 'product.product'
+
+    factory_reference = fields.Char('Referencia de fábrica',size=64)
+
+    @api.model
+    def create(self, vals):
+        prod_id = super(product_product,self).create(vals)
+        self.copiar_referencia(prod_id)
+        return prod_id
+
+    @api.model
+    def copiar_referencia(self,prod_id):
+        # print prod_id['id']
+        prod_tmpl = self.env['product.template'].browse(prod_id['product_tmpl_id']['id'])
+        #print prod_tmpl
+
+        ref = ''
+        if prod_tmpl.factory_reference:
+            prod_id['factory_reference'] = prod_tmpl.factory_reference
+            ref = prod_tmpl.factory_reference
+
+
+        prod_id['default_code'] = ref
+        return True
+
+product_product()

+ 44 - 0
codigo_barra_view.xml

@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<openerp>
+    <data>
+        <!-- Product Template Form View -->
+        <record model="ir.ui.view" id="product_template_form_view_barcode">
+            <field name="name">product.template.form.view.barcode</field>
+            <field name="model">product.template</field>
+            <field name="inherit_id" ref="product.product_template_only_form_view" />
+            <field name="arch" type="xml">
+                <field name="type" position="before">
+                    <field name="factory_reference"/>
+                </field>
+            </field>
+        </record>
+        <!-- <record id="product_template_hide" model="ir.ui.view">
+            <field name="name">product.template_hide</field>
+            <field name="model">product.template</field>
+            <field name="inherit_id" ref="product.product_template_form_view"/>
+            <field name="arch" type="xml">
+                <xpath expr="//form/sheet/notebook//page[@string='Procurements']" position="attributes">
+                    <attribute name="attrs">{'invisible':True}</attribute>
+                </xpath>
+                <xpath expr="//form/sheet/notebook//page[@string='Sales']" position="attributes">
+                    <attribute name="attrs">{'invisible':True}</attribute>
+                </xpath>
+            </field>
+        </record> -->
+
+
+
+
+         <!-- Product Form View -->
+        <record model="ir.ui.view" id="product_form_view_barcode">
+            <field name="name">product.form.view.barcode</field>
+            <field name="model">product.product</field>
+            <field name="inherit_id" ref="product.product_normal_form_view"/>
+            <field name="arch" type="xml">
+                <field name="type" position="before">
+                    <field name="factory_reference"/>
+                </field>
+            </field>
+        </record>
+    </data>
+</openerp>

二進制
static/description/icon.png