تخطي للذهاب إلى المحتوى
أودو القائمة
  • تسجيل الدخول
  • جرب مجاناً
  • التطبيقات
    المالية
    • المحاسبة
    • فوترة
    • النفقات
    • جدول البيانات (BI)
    • المستندات
    • توقيع إلكتروني
    المبيعات
    • إدارة علاقات العملاء
    • المبيعات
    • نقطة البيع للمتاجر
    • نقطة البيع للمطاعم
    • الاشتراكات
    • تأجير
    المواقع الإلكترونية
    • أداة بناء المواقع الإلكترونية
    • متاجر إلكترونية
    • مدونة
    • المنتدى
    • دردشة مباشرة
    • التعليم الإلكتروني
    سلسلة التوريد
    • المستودعات
    • التصنيع
    • إدارة دورة حياة المنتج
    • المشتريات
    • الصيانة
    • الجودة
    الموارد البشرية
    • موظفون
    • التوظيف
    • إجازة عمل
    • التقييمات
    • الإحالات
    • تطبيق الأسطول
    التسويق
    • التسويق الإجتماعي
    • التسويق عبر البريد الإلكتروني
    • التسويق عبر الرسائل النصية
    • فعاليات
    • أتمتة التسويق
    • الاستطلاعات
    الخدمات
    • المشاريع
    • الجداول الزمنية
    • الخدمة الميدانية
    • مكتب المساعدة
    • التخطيط
    • مواعيد
    اﻹنتاجية
    • مناقشة
    • الموافقات
    • إنترنت الأشياء "IoT"
    • بروتوكول ربط المحادثات الصوتية عبر الإنترنت
    • المعرفة
    • WhatsApp
    التطبيقات الخارجية ستوديو أودو منصة أودو السحابية
  • قطاعات الأعمال
    البيع بالتجزئة
    • متجر كتب
    • متجر ملابس
    • متجر أثاث
    • متجر بقالة
    • متجر معدات
    • متجر ألعاب
    الطعام والضيافة
    • بار وحانة
    • المطعم
    • مطعم للوجبات السريعة
    • نزل للضيوف
    • موزّع مشروبات
    • فندق
    العقارات
    • وكالة عقارات
    • شركة هندسة معمارية
    • البناء
    • إدارة العقارات
    • العناية بالحدائق
    • اتحاد مُلاّك العقارات
    استشارة
    • مؤسسة محاسبية
    • شريك أودو
    • وكالة تسويقية
    • منشأة قانونية
    • استقطاب المواهب
    • التدقيق والتوثيق
    التصنيع
    • الأقمشة
    • معدني
    • الأثاث
    • الطعام
    • مصنع خمور
    • هدايا الشركات
    الصحة واللياقة البدنية
    • نادي رياضي
    • متجر نظارات
    • مركز لياقة بدنية
    • الممارسون الصحيون
    • صيدلية
    • صالون تصفيف الشعر
    التجارة
    • عامل صيانة
    • الأجهزة والمعدات التقنية ودعمها
    • أنظمة الطاقة الشمسية
    • صانع أحذية
    • خدمات التنظيف
    • خدمات التكييف (HVAC)
    غير ذلك
    • منظمة غير ربحية
    • وكالة بيئية
    • تأجير لوحات إعلانية
    • تصوير
    • تأجير دراجات
    • بائع وسيط للبرمجيات
    تصفح كافة قطاعات الأعمال
  • مجتمع أودو
    تعلم
    • دروس
    • التوثيق
    • شهادات
    • التدريب
    • مدونة
    • بودكاست
    قم بتعزيز التعليم
    • برنامج تعليم
    • Scale UP! لعبة الأعمال
    • قم بزيارة أودو
    احصل على البرنامج
    • تحميل
    • قارنْ الإصدارات
    • إطلاق
    تعاون
    • جيت هاب "Github"
    • المنتدى
    • فعاليات
    • الترجمات
    • كنْ شريكاً
    • خدمات الشركاء
    • سجل مكتب المحاسبة الخاص بك
    احصل على الخدمات
    • اعثر على شريك
    • اعثر على محاسب
    • قابل أحد مرشدي الأعمال
    • خدمات التنفيذ
    • مراجع العملاء
    • الدعم
    • الترقيات
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    الحصول على عرض توضيحي
  • الأسعار
  • المساعدة

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

  • إدارة علاقات العملاء
  • e-Commerce
  • المحاسبة
  • المخزون
  • PoS
  • المشروع
  • MRP
All apps
يجب أن تكون مسجلاً حتى تتفاعل مع المجتمع.
كافة المنشورات الأفراد الشارات
علامات التصنيف (عرض الكل)
odoo accounting v14 pos v15
حول هذا المنتدى
يجب أن تكون مسجلاً حتى تتفاعل مع المجتمع.
كافة المنشورات الأفراد الشارات
علامات التصنيف (عرض الكل)
odoo accounting v14 pos v15
حول هذا المنتدى
المساعدة

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

اشتراك

تسلم الإشعارات عندما يكون هناك نشاط في هذا المنشور

لقد تم الإبلاغ عن هذا السؤال
python2.7odooV9
1 الرد
10249 أدوات العرض
الصورة الرمزية
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
الصورة الرمزية
إهمال
الصورة الرمزية
Cybrosys Techno Solutions Pvt.Ltd
أفضل إجابة

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
الصورة الرمزية
إهمال
Dhouha
الكاتب

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
الكاتب

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

هل أعجبك النقاش؟ لا تكن مستمعاً فقط. شاركنا!

أنشئ حساباً اليوم لتستمتع بالخصائص الحصرية، وتفاعل مع مجتمعنا الرائع!

تسجيل
المنشورات ذات الصلة الردود أدوات العرض النشاط
How to add fixed tax automatically in invoice
python2.7 odooV9
الصورة الرمزية
الصورة الرمزية
الصورة الرمزية
2
يوليو 22
6667
how to create a access rule to limit product creation for sale managers?
python2.7 odooV9
الصورة الرمزية
الصورة الرمزية
الصورة الرمزية
2
يوليو 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
الصورة الرمزية
0
يوليو 18
3521
AttributeError: 'int' object has no attribute 'id' on odoo 9
python2.7 odooV9
الصورة الرمزية
الصورة الرمزية
1
يوليو 17
11251
create a notification on odoo v9 تم الحل
python2.7 odooV9
الصورة الرمزية
الصورة الرمزية
1
يوليو 17
3911
المجتمع
  • دروس
  • التوثيق
  • المنتدى
مصدر مفتوح
  • تحميل
  • جيت هاب "Github"
  • المشغل الآلي رنبوت
  • الترجمات
خدماتنا
  • استضافة أودو إس إتش
  • الدعم
  • الترقية
  • التطويرات المخصصة
  • التعليم
  • اعثر على محاسب
  • اعثر على شريك
  • كنْ شريكاً
معلومات عنا
  • شركتنا
  • أصول العلامة التجارية
  • اتصلْ بنا
  • الوظائف
  • فعاليات
  • بودكاست
  • مدونة
  • عملاء
  • قانوني • الخصوصية
  • الحماية
الْعَرَبيّة 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

أودو هو عبارة عن مجموعة من تطبيقات الأعمال مفتوحة المصدر التي تغطي جميع احتياجات شركتك، مثل: إدارة علاقات العملاء والتجارة الإلكترونية والمحاسبة والمخزون ونقاط البيع وإدارة المشاريع وما إلى ذلك.

ما يجعل من أودو مميزاً هو هدفه بأن يكون سهل الاستخدام للغاية ومتكاملاً تمامًا في الوقت ذاته.

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