浏览代码

commit inicial

Rodney Enciso Arias 8 年之前
当前提交
353e5a2659
共有 7 个文件被更改,包括 241 次插入0 次删除
  1. 22 0
      __init__.py
  2. 二进制
      __init__.pyc
  3. 47 0
      __openerp__.py
  4. 103 0
      codigo_barra.py
  5. 二进制
      codigo_barra.pyc
  6. 69 0
      codigo_barra_view.xml
  7. 二进制
      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
+

二进制
__init__.pyc


+ 47 - 0
__openerp__.py

@@ -0,0 +1,47 @@
+# -*- 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' : 'Codigo de barras de fabrica y Referencia',
+    'version' : '1.0',
+    'author' : 'Eiru Software/ Victor Obrist - Rodney Enciso Arias',
+    'sequence': 120,
+    'category': 'Product',
+    'website' : 'http://www.eiru.com.py',
+    'summary' : 'Codigo de barras de fabrica y referencia',
+    'description' : """
+Codigo de barras de fabrica y referencia de Fabrica.
+====================================================
+Agrega los campos referencia de fabrica y codigo de barras de fabrica, ademas de ocultar
+los apartados abastecimientos y ventas, el compo precio de costo es movido al apartado 
+informacion
+
+
+""",
+    'depends' : ['product'],
+    'data' : [
+        'codigo_barra_view.xml',
+    ],
+    'installable' : True,
+}
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+

+ 103 - 0
codigo_barra.py

@@ -0,0 +1,103 @@
+# -*- 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_barcode = fields.Char('Código de barra de fábrica',size=64)
+    factory_reference = fields.Char('Referencia de fábrica',size=64)
+
+    _defaults = {
+        'type':'product',
+    }
+
+    @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']
+
+
+            if  prod.factory_barcode:
+                if prod['factory_barcode'] != None:
+                    prod.factory_barcode = prod['factory_barcode']
+                    ref = prod['factory_barcode']
+            elif self.factory_barcode:
+                prod.factory_barcode = self.factory_barcode
+                ref = self['factory_barcode']
+
+            prod['default_code'] = ref
+        return prod_tmpl_id
+
+class product_product(models.Model):
+    _name = 'product.product'
+    _inherit = 'product.product'
+
+    factory_barcode = fields.Char('Código de barra de fábrica',size=64)
+    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
+
+        if prod_tmpl.factory_barcode:
+            prod_id['factory_barcode'] = prod_tmpl.factory_barcode
+            ref = prod_tmpl.factory_barcode
+
+
+        prod_id['default_code'] = ref
+        return True
+
+    @api.onchange('factory_barcode')
+    def copiar_referencia_codigo_barra(self):
+        self.default_code = self.factory_barcode
+
+product_product()
+
+
+

二进制
codigo_barra.pyc


+ 69 - 0
codigo_barra_view.xml

@@ -0,0 +1,69 @@
+<?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="standard_price" position="replace">
+                </field>
+                <field name="list_price" position="before">
+                    <field name="standard_price"/>
+                </field>
+                <field name="type" position="before">
+                    <field name="factory_barcode"/>
+                    <field name="factory_reference"/>
+                </field>
+                <field name="default_code" position="replace">
+                </field>
+                <field name="factory_reference" position="before">
+                    <field name="default_code"/>
+                </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="standard_price" position="replace">
+                </field>
+                <field name="lst_price" position="before">
+                    <field name="standard_price"/>
+                </field>
+                <field name="type" position="before">
+                    <field name="factory_barcode"/>
+                    <field name="factory_reference"/>
+                </field>
+                <field name="default_code" position="replace">
+                </field>
+                <field name="factory_reference" position="before">
+                    <field name="default_code"/>
+                </field>
+                <field name="ean13" position="replace">
+                    <field name="ean13" invisible="1"/>
+                </field>
+            </field>
+        </record>
+    </data>
+</openerp>

二进制
static/description/icon.png