Skip to Content
Odoo Menu
  • Zaloguj się
  • Wypróbuj za darmo
  • Aplikacje
    Finanse
    • Księgowość
    • Fakturowanie
    • Wydatki
    • Arkusz kalkulacyjny (BI)
    • Dokumenty
    • Podpisy
    Sprzedaż
    • CRM
    • Sprzedaż
    • PoS Sklep
    • PoS Restauracja
    • Subskrypcje
    • Wypożyczalnia
    Strony Internetowe
    • Kreator Stron Internetowych
    • eCommerce
    • Blog
    • Forum
    • Czat na Żywo
    • eLearning
    Łańcuch dostaw
    • Magazyn
    • Produkcja
    • PLM
    • Zakupy
    • Konserwacja
    • Jakość
    Zasoby Ludzkie
    • Pracownicy
    • Rekrutacja
    • Urlopy
    • Ocena pracy
    • Polecenia Pracownicze
    • Flota
    Marketing
    • Marketing Społecznościowy
    • E-mail Marketing
    • SMS Marketing
    • Wydarzenia
    • Automatyzacja Marketingu
    • Ankiety
    Usługi
    • Projekt
    • Ewidencja czasu pracy
    • Usługi Terenowe
    • Helpdesk
    • Planowanie
    • Spotkania
    Produktywność
    • Dyskusje
    • Zatwierdzenia
    • IoT
    • VoIP
    • Baza wiedzy
    • WhatsApp
    Aplikacje trzecich stron Studio Odoo Odoo Cloud Platform
  • Branże
    Sprzedaż detaliczna
    • Księgarnia
    • Sklep odzieżowy
    • Sklep meblowy
    • Sklep spożywczy
    • Sklep z narzędziami
    • Sklep z zabawkami
    Żywienie i hotelarstwo
    • Bar i Pub
    • Restauracja
    • Fast Food
    • Pensjonat
    • Dystrybutor napojów
    • Hotel
    Agencja nieruchomości
    • Agencja nieruchomości
    • Biuro architektoniczne
    • Budowa
    • Zarządzanie nieruchomościami
    • Ogrodnictwo
    • Stowarzyszenie właścicieli nieruchomości
    Doradztwo
    • Biuro księgowe
    • Partner Odoo
    • Agencja marketingowa
    • Kancelaria prawna
    • Agencja rekrutacyjna
    • Audyt i certyfikacja
    Produkcja
    • Tekstylia
    • Metal
    • Meble
    • Jedzenie
    • Browar
    • Prezenty firmowe
    Zdrowie & Fitness
    • Klub sportowy
    • Salon optyczny
    • Centrum fitness
    • Praktycy Wellness
    • Apteka
    • Salon fryzjerski
    Transakcje
    • Złota rączka
    • Wsparcie Sprzętu IT
    • Systemy energii słonecznej
    • Szewc
    • Firma sprzątająca
    • Usługi HVAC
    Inne
    • Organizacja non-profit
    • Agencja Środowiskowa
    • Wynajem billboardów
    • Fotografia
    • Leasing rowerów
    • Sprzedawca oprogramowania
    Przeglądaj wszystkie branże
  • Community
    Ucz się
    • Samouczki
    • Dokumentacja
    • Certyfikacje
    • Szkolenie
    • Blog
    • Podcast
    Pomóż w nauce innym
    • Program Edukacyjny
    • Scale Up! Gra biznesowa
    • Odwiedź Odoo
    Skorzystaj z oprogramowania
    • Pobierz
    • Porównaj edycje
    • Wydania
    Współpracuj
    • Github
    • Forum
    • Wydarzenia
    • Tłumaczenia
    • Zostań partnerem
    • Usługi dla partnerów
    • Zarejestruj swoją firmę rachunkową
    Skorzystaj z usług
    • Znajdź partnera
    • Znajdź księgowego
    • Spotkaj się z doradcą
    • Usługi wdrożenia
    • Opinie klientów
    • Wsparcie
    • Aktualizacje
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Zaplanuj demo
  • Cennik
  • Pomoc

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

  • CRM
  • e-Commerce
  • Księgowość
  • Zapasy
  • PoS
  • Projekt
  • MRP
All apps
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
Wszystkie posty Osoby Odznaki
Tagi (Zobacz wszystko)
odoo accounting v14 pos v15
O tym forum
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
Wszystkie posty Osoby Odznaki
Tagi (Zobacz wszystko)
odoo accounting v14 pos v15
O tym forum
Pomoc

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

Zaprenumeruj

Otrzymaj powiadomienie o aktywności w tym poście

To pytanie dostało ostrzeżenie
python2.7odooV9
1 Odpowiedz
10251 Widoki
Awatar
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
Awatar
Odrzuć
Awatar
Cybrosys Techno Solutions Pvt.Ltd
Najlepsza odpowiedź

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
Awatar
Odrzuć
Dhouha
Autor

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
Autor

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

Podoba Ci się ta dyskusja? Dołącz do niej!

Stwórz konto dzisiaj, aby cieszyć się ekskluzywnymi funkcjami i wchodzić w interakcje z naszą wspaniałą społecznością!

Zarejestruj się
Powiązane posty Odpowiedzi Widoki Czynność
How to add fixed tax automatically in invoice
python2.7 odooV9
Awatar
Awatar
Awatar
2
lip 22
6667
how to create a access rule to limit product creation for sale managers?
python2.7 odooV9
Awatar
Awatar
Awatar
2
lip 21
7066
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
Awatar
0
lip 18
3521
AttributeError: 'int' object has no attribute 'id' on odoo 9
python2.7 odooV9
Awatar
Awatar
1
lip 17
11251
create a notification on odoo v9 Rozwiązane
python2.7 odooV9
Awatar
Awatar
1
lip 17
3911
Społeczność
  • Samouczki
  • Dokumentacja
  • Forum
Open Source
  • Pobierz
  • Github
  • Runbot
  • Tłumaczenia
Usługi
  • Hosting Odoo.sh
  • Wsparcie
  • Aktualizacja
  • Indywidualne rozwiązania
  • Edukacja
  • Znajdź księgowego
  • Znajdź partnera
  • Zostań partnerem
O nas
  • Nasza firma
  • Zasoby marki
  • Skontaktuj się z nami
  • Oferty pracy
  • Wydarzenia
  • Podcast
  • Blog
  • Klienci
  • Informacje prawne • Prywatność
  • Bezpieczeństwo Odoo
الْعَرَبيّة 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 to pakiet aplikacji biznesowych typu open source, które zaspokoją wszystkie potrzeby Twojej firmy: CRM, eCommerce, księgowość, inwentaryzacja, punkt sprzedaży, zarządzanie projektami itp.

Unikalną wartością Odoo jest to, że jest jednocześnie bardzo łatwe w użyciu i w pełni zintegrowane.

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