İçereği Atla
Odoo Menü
  • Portal
  • Ücretsiz deneyin
  • Uygulamalar
    Finans
    • Muhasebe
    • Faturalama
    • Masraf Yönetimi
    • Elektronik Çizelge (BI)
    • Belgeler
    • İmza
    Satış
    • Müşteri İlişkileri Yönetimi (CRM)
    • Satış
    • Satış Noktası Mağaza
    • Satış Noktası Restoran
    • Abonelikler
    • Kiralama
    Web Sitesi
    • Web Sitesi Oluşturucu
    • eTicaret
    • Blog
    • Forum
    • Canlı Sohbet
    • eÖğrenme
    Tedarik Zinciri
    • Envanter
    • Üretim
    • Ürün Yaşam Döngüsü Yönetimi
    • Satın Alma
    • Bakım
    • Kalite
    İnsan Kaynakları
    • Çalışanlar
    • İşe Alım
    • İzin
    • Değerlendirme
    • Referans
    • Filo Yönetimi
    Pazarlama
    • Sosyal Medyada Pazarlama
    • E-posta ile Pazarlama
    • SMS ile Pazarlama
    • Etkinlikler
    • Pazarlama Otomasyonu
    • Anket
    Hizmetler
    • Proje Yönetimi
    • Çalışma Çizelgeleri
    • Saha Hizmeti
    • Yardım Masası
    • Planlama
    • Randevular
    Verimlilik
    • Sohbet
    • Onay
    • Nesnelerin İnterneti
    • VoIP
    • Bilgi Bankası
    • WhatsApp
    Üçüncü taraf uygulamalar Odoo Stüdyo Odoo Bulut Platformu
  • Sektörler
    Perakende satış
    • Kitapçı
    • Giyim Mağazası
    • Mobilya Mağazası
    • Gıda Marketi
    • Hırdavat Dükkanı
    • Oyuncak Dükkanı
    Gıda ve Konaklama
    • Bar ve Pub
    • Restoran
    • Fast Food Restoranı
    • Konuk Evi
    • İçecek Distribütörü
    • Otel
    Gayrimenkul
    • Emlak Acentesi
    • Mimarlık Firması
    • İnşaat
    • Emlak Yönetimi
    • Bahçe Tasarımı
    • Mülk Sahipleri Derneği
    Uzmanlık
    • Muhasebe Firması
    • Odoo Partner
    • Pazarlama Ajansı
    • Hukuk Firması
    • Yetenek Kazanımı
    • Denetim ve Belgelendirme
    Üretim
    • Tekstil
    • Metal
    • Mobilyalar
    • Gıda
    • Bira fabrikası
    • Kurumsal Hediye
    Sağlık ve Spor
    • Spor Kulübü
    • Optik Mağazası
    • Fitness Merkezi
    • Sağlıklı Yaşam Merkezi
    • Eczane
    • Kuaför Salonu
    Ticaret
    • Tamirci
    • BT Donanım & Destek
    • Güneş Enerjisi Sistemleri
    • Ayakkabı İmalatçısı
    • Temizlik Hizmetleri
    • HVAC Hizmetleri
    Diğerleri
    • Kar Amacı Gütmeyen Kuruluş
    • Çevre Ajansı
    • Reklam Panosu Kiralama
    • Fotoğrafçılık
    • Bisiklet Kiralama
    • Yazılım Bayisi
    Tüm Sektörlere Göz Atın
  • Topluluk
    Öğrenim
    • Eğitim Araçları
    • Dokümantasyon
    • Sertifikasyonlar
    • Eğitim Etkinlikleri
    • Blog
    • Podcast
    Eğitim ve Gelişim
    • Eğitim Programı
    • Scale Up! İşletme Oyunu
    • Odoo'yu Ziyaret Edin
    Yazılım
    • İndirin
    • Sürümleri Kıyaslayın
    • Sürümler
    İş Birliği
    • Github
    • Forum
    • Etkinlikler
    • Çeviriler
    • Partner Olun
    • Partnerler için Hizmetler
    • Muhasebe Firmanızı Kaydettirin
    Hizmetler
    • Partner Bulun
    • Muhasebeci Bulun
    • Bir danışmanla görüşün
    • Kurulum Hizmetleri
    • Müşteri Referansları
    • Destek
    • Sürüm Yükseltme
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Demo randevusu alın
  • Fiyatlandırma
  • Yardım

Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:

  • Müşteri İlişkileri Yönetimi
  • e-Commerce
  • Muhasebe
  • Envanter
  • PoS
  • Proje Yönetimi
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Etiketler (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Etiketler (View all)
odoo accounting v14 pos v15
About this forum
Yardım

how to resolve errorhow to resolve this error " 'product.template' has no attribute 'generate_ean13' ??

Abone Ol

Get notified when there's activity on this post

Bu soru işaretlendi
python2.7odooV9
1 Cevapla
10174 Görünümler
Avatar
Dhouha

i'm using  odoo 9 and i have created a custom module for product barcode generation. Everytime when i press the button 'generate the ean13 ' this error shows and i don't know what to do .

Any help please this is my code 

_______________________________________________________________________________________________

product_view.xml 

<?xml version="1.0" encoding="utf-8"?>

<odoo>


        <record id="view_product_category_simple_ean_form" model="ir.ui.view">

            <field name="name">product.category.form</field>

            <field name="model">product.category</field>

            <field name="inherit_id" ref="product.product_category_form_view" />

            <field name="arch" type="xml">

                <field name="type" position="after">

                    <field name="ean_sequence_id" domain="[('barcode_sequence', '=', 1)]"

                        context="{'default_name': name and 'EAN ' + name or 'EAN', 'default_barcode_sequence': 1}" />

                    <newline />

                </field>

            </field>

        </record>


        <record id="view_product_simple_ean_form" model="ir.ui.view">

            <field name="name">product.template.product.form.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="barcode" position="after">

                  

                    <button string="Generate the EAN13" name="generate_ean13"

                        attrs="{'invisible': [('barcode', '!=', False)]}"

                        type="object" colspan="2" />

                </field>

            </field>

        </record>

</odoo>

__________________________________________________________________________________________

product.py 

<?xml version="1.0" encoding="utf-8"?>

<odoo>


        <record id="view_product_category_simple_ean_form" model="ir.ui.view">

            <field name="name">product.category.form</field>

            <field name="model">product.category</field>

            <field name="inherit_id" ref="product.product_category_form_view" />

            <field name="arch" type="xml">

                <field name="type" position="after">

                    <field name="ean_sequence_id" domain="[('barcode_sequence', '=', 1)]"

                        context="{'default_name': name and 'EAN ' + name or 'EAN', 'default_barcode_sequence': 1}" />

                    <newline />

                </field>

            </field>

        </record>


        <record id="view_product_simple_ean_form" model="ir.ui.view">

            <field name="name">product.template.product.form.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="barcode" position="after">

                  

                    <button string="Generate the EAN13" name="generate_ean13"

                        attrs="{'invisible': [('barcode', '!=', False)]}"

                        type="object" colspan="2" />

                </field>

            </field>

        </record>

</odoo>



0
Avatar
Vazgeç
Avatar
Cybrosys Techno Solutions Pvt.Ltd
En İyi Yanıt

Hi,

Going through the given code along with the question, it seems you have added a new button to the product.template model.


You have to add the function generate_ean13 to the same model.  Right now as there is no such a function in the same model you are getting this error when you click the newly added button.

class ProductTemplate(models.Model):
_inherit = "product.template"

@api.multi
def generate_ean13(self):
# code here


Also, you can have a look at the Product Barcode Generator module available in the v10 : https://www.odoo.com/apps/modules/10.0/product_barcode/


Thanks

4
Avatar
Vazgeç
Dhouha
Üretici

199/5000

I did not notice that it pasted the product_view.xml code into product.py. my problem that I already wrote the function generate_ean13 but he did not take it into consideration here is my code

from openerp import api, models, fields, _

from openerp import exceptions

def isodd(x):

return bool(x % 2)

class ProductCategory(models.Model):

_inherit = 'product.category'

ean_sequence_id = fields.Many2one('ir.sequence', string='Ean sequence')

class ProductTemplate(models.Model):

_inherit = 'product.template'

barcode = fields.Char(copy=False)

ean= fields.Char(copy=False)

_columns = {

ean_sequence_id : fields.Many2one('ir.sequence', string='Ean sequence')

}

@api.model

def _get_ean_next_code(self, product):

sequence_obj = self.env['ir.sequence']

if product.ean_sequence_id:

ean = sequence_obj.next_by_id(product.ean_sequence_id.id)

elif product.categ_id.ean_sequence_id:

ean = sequence_obj.next_by_id(product.categ_id.ean_sequence_id.id)

elif product.company_id and product.company_id.ean_sequence_id:

ean = sequence_obj.next_by_id(

product.company_id.ean_sequence_id.id)

elif self.env.context.get('sequence_id', False):

ean = sequence_obj.next_by_id(self.env.context.get('sequence_id'))

else:

return None

ean = (len(ean[0:6]) == 6 and ean[0:6] or

ean[0:6].ljust(6, '0')) + ean[6:].rjust(6, '0')

if len(ean) > 12:

raise exceptions.Warning(

_("Configuration Error!"

"The next sequence is longer than 12 characters. "

"It is not valid for an EAN13 needing 12 characters, "

"the 13 being used as a control digit"

"You will have to redefine the sequence or create a new one")

)

return ean

def _get_ean_control_digit(self, code):

sum = 0

for i in range(12):

if isodd(i):

sum += 3 * int(code[i])

else:

sum += int(code[i])

key = (10 - sum % 10) % 10

return '%d' % key

@api.model

def _generate_ean13_value(self, product):

ean = self._get_ean_next_code(product)

if not ean:

return None

key = self._get_ean_control_digit(ean)

barcode = ean + key

return barcode

@api.one

def generate_ean13(self):

if not self.barcode:

barcode = self._generate_ean13_value(self)

if barcode:

self.write({'barcode': barcode})

return True

Cybrosys Techno Solutions Pvt.Ltd

Then check whether this py file is called in the init file

Dhouha
Üretici

he is called in the init file "from . import product" that's why i'm i'm desprerate because i have tried every thing but i still don't know why this error shows up

Enjoying the discussion? Don't just read, join in!

Create an account today to enjoy exclusive features and engage with our awesome community!

Üye Ol
İlgili Gönderiler Cevaplar Görünümler Aktivite
How to add fixed tax automatically in invoice
python2.7 odooV9
Avatar
Avatar
Avatar
2
Tem 22
6616
how to create a access rule to limit product creation for sale managers?
python2.7 odooV9
Avatar
Avatar
Avatar
2
Tem 21
7017
How can I setup Tax so that I can charge on the TOTAL Invoice amount, then on the Products, then a Stamp Tax.
python2.7 odooV9
Avatar
0
Tem 18
3486
AttributeError: 'int' object has no attribute 'id' on odoo 9
python2.7 odooV9
Avatar
Avatar
1
Tem 17
11215
create a notification on odoo v9 Çözüldü
python2.7 odooV9
Avatar
Avatar
1
Tem 17
3870
Topluluk
  • Eğitim Araçları
  • Dokümantasyon
  • Forum
Açık Kaynak
  • İndirin
  • Github
  • Runbot
  • Çeviriler
Hizmetler
  • Odoo.sh Hosting
  • Destek
  • Sürüm Yükseltme
  • Özel Geliştirmeler
  • Eğitim
  • Muhasebeci Bulun
  • Partner Bulun
  • Partner Olun
Hakkında
  • Şirketimiz
  • Pazarlama Gereçleri
  • İletişim
  • Kariyer
  • Etkinlikler
  • Podcast
  • Blog
  • Müşteriler
  • Hukuki • Gizlilik
  • Güvenlik
الْعَرَبيّة Català 简体中文 繁體中文 (台灣) Čeština Dansk Nederlands English Suomi Français Deutsch हिंदी Bahasa Indonesia Italiano 日本語 한국어 (KR) Lietuvių kalba Język polski Português (BR) română русский язык Slovenský jazyk slovenščina Español (América Latina) Español ภาษาไทย Türkçe українська Tiếng Việt

Odoo, müşteri ilişkileri yönetimi, eTicaret, muhasebe, envanter, satış noktası, proje yönetimi gibi şirketinizin tüm ihtiyaçlarını karşılayan bir açık kaynak işletme uygulamaları paketidir.

Odoo’nun eşsiz değer önermesi, aynı anda hem kullanımının çok kolay olup hem de tamamen entegre olmasıdır.

Website made with

Odoo Experience on YouTube

1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.

Live support on Youtube
Watch now