codigo_barra.py 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. # -*- coding: utf-8 -*-
  2. ##############################################################################
  3. #
  4. # OpenERP, Open Source Management Solution
  5. # Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
  6. #
  7. # This program is free software: you can redistribute it and/or modify
  8. # it under the terms of the GNU Affero General Public License as
  9. # published by the Free Software Foundation, either version 3 of the
  10. # License, or (at your option) any later version.
  11. #
  12. # This program is distributed in the hope that it will be useful,
  13. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. # GNU Affero General Public License for more details.
  16. #
  17. # You should have received a copy of the GNU Affero General Public License
  18. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  19. #
  20. ##############################################################################
  21. from openerp import models, fields, api
  22. class product_template(models.Model):
  23. _name = 'product.template'
  24. _inherit = 'product.template'
  25. factory_reference = fields.Char('Referencia de fábrica',size=64)
  26. # @api.multi
  27. # def write(self, vals):
  28. # prod_tmpl_id = super(product_template,self).write(vals)
  29. #
  30. # for p in self.product_variant_ids:
  31. # prod = self.env['product.product'].browse(p['id'])
  32. # ref = ''
  33. #
  34. # if prod.factory_reference:
  35. # if prod['factory_reference'] != None:
  36. # prod.factory_reference = self.factory_reference
  37. # ref = prod['factory_reference']
  38. # elif self.factory_reference:
  39. # prod.factory_reference = self.factory_reference
  40. # ref = self['factory_reference']
  41. #
  42. # return prod_tmpl_id
  43. #
  44. class product_product(models.Model):
  45. _name = 'product.product'
  46. _inherit = 'product.product'
  47. factory_reference = fields.Char('Referencia de fábrica',size=64)
  48. #
  49. # @api.model
  50. # def create(self, vals):
  51. # prod_id = super(product_product,self).create(vals)
  52. # self.copiar_referencia(prod_id)
  53. # return prod_id
  54. #
  55. # @api.model
  56. # def copiar_referencia(self,prod_id):
  57. # prod_tmpl = self.env['product.template'].browse(prod_id['product_tmpl_id']['id'])
  58. #
  59. # ref = ''
  60. # if prod_tmpl.factory_reference:
  61. # prod_id['factory_reference'] = prod_tmpl.factory_reference
  62. # ref = prod_tmpl.factory_reference
  63. #
  64. # return True
  65. #
  66. # product_product()