تخطي للذهاب إلى المحتوى
أودو القائمة
  • تسجيل الدخول
  • جرب مجاناً
  • التطبيقات
    المالية
    • المحاسبة
    • فوترة
    • النفقات
    • جدول البيانات (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
حول هذا المنتدى
المساعدة

"AttributeError: 'tuple' object has no attribute 'items'" when modifying sale order line via custom code

اشتراك

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

لقد تم الإبلاغ عن هذا السؤال
13117 أدوات العرض
الصورة الرمزية
Diego Calzadilla

Hello everybody

I have this issue, I have different product categories, let's say cat1, cat2, cat3, and for each of these categories I have defined 2 new fields: "halfcontop" and "highcontop", what they do is to estblish 2 product quantities for getting special price. Now, all my products belong to one of the previous categories and each of my products also have two fields : "prhalfc" and "prhighc" which are my special prices for each product. Now, comes the interesting thing: these prices are reachable depending on the quantity of products by category, and not by the quantity of items of this product , for example, let's think that for cat1, highcontop=10 and I have 11 different products belonging to this category so that if I buy only one of each of these products Im gonna have 11 products and then Im gonna reach "prhighc" for each product which may be different for all products.

I have analyzed the problem and I think that what I should do is to browse the whole sale order, so that I can count the number of products by category, and then, according to this number establish the new prices if necessary.

I also took a deep look at pricelist module, but it doesn't fit my neccesity because it changes the product prices for each line, and what I need to do first is the check the whole sale order.

I have done the following points. But I stiil need some help. Thanks in advace for suggestions!!

This is the code for new fields, everything is fine here:

PY:

from openerp import netsvc from openerp import pooler from openerp.osv import fields, osv, orm from openerp.tools.translate import _

class product_otherprices_inherit(osv.osv): _inherit = 'product.product' _name='product.product' _columns = { 'prhalfc' : fields.float('Price for half consume', help='Enter the price defined for half consume'), 'prhighc' : fields.float('Price for high consume', help='Enter the price defined for high consume'), } class category_price_range_inherit(osv.osv): _inherit = 'product.category' _name = 'product.category' _description = 'Ranges for category prices half & high consume' _columns = { 'halfcontop':fields.float('Range top for half consume',help='Top for half consume'), 'highcontop':fields.float('Range top for high consume',help='Top for high consume'), }

XML:

<openerp> <data> <record model="ir.ui.view" id="product_otherprices_inherit"> <field name="name">product.otherprices.inherit</field> <field name="model">product.product</field> <field name="inherit_id" ref="product.product_normal_form_view"/> <field name="arch" type="xml"> <notebook position="inside"> <page string="Other_Prices"> <group> <field name="prhalfc"/> <field name="prhighc"/> </group> </page> </notebook> </field> </record> </data> </openerp>

<openerp> <data>

    <record model="ir.ui.view" id="category_price_range_inherit">
        <field name="name">product.category.pricerange.inherit</field>
        <field name="model">product.category</field>
        <field name="type">form</field>
        <field name="inherit_id" ref="product.product_category_form_view"/>
        <field name="arch" type="xml"> 

            <sheet> 
                <group> 
                    <group name="parent" col="4"> 
                        <field name="lowcontop" /> 
                        <field name="halfcontop"/> 
                        <field name="highcontop"/> 
                    </group> 
                </group> 
            </sheet>
        </field>
    </record>
</data>

</openerp>

Now, comes the method supossed to change the prices, but it stiil doesn't work

class sale_order_line(osv.osv):

_inherits = 'sale.order.line', 'product.product', 'product.category'
_name="sale.order.line"

def _category_amount_line(self, cr, uid, ids, field_name, arg, context=None):
    tax_obj = self.pool.get('account.tax')
    cur_obj = self.pool.get('res.currency')
    res = []
    if context is None:
        context = {}
    for line in self.browse(cr, uid, ids, context=context): #Lo que intento es que haga referencia a los campos puestos e las clases anteriores, segun entendi, esta funcion compute_all, lo unico que hace es un redondeo con los decimales.
        taxes = tax_obj.compute_all(cr, uid, line.tax_id, line.prhalfc, line.prhighc, line.product_uom_qty, line.order_id.partner_invoice_id.id, line.product_id, line.order_id.partner_id)
        cur = line.order_id.pricelist_id.currency_id
        res[line.id] = cur_obj.round(cr, uid, cur, taxes['total'])
    return res




def product_id_change(self, cr, uid, ids, pricelist, product, qty=0,
        uom=False, qty_uos=0, uos=False, name='', partner_id=False,
        lang=False, update_tax=True, date_order=False, packaging=False, fiscal_position=False, flag=False, halfcontop=0, highcontop=0, prhalfc=0, prhighc=0, context=None):

    res=[]
    res =  super(sale_order_line, self).product_id_change(
        cr, uid, ids, pricelist, product, qty,
        uom, qty_uos, uos, name, partner_id,
        lang, update_tax, date_order, packaging, fiscal_position, flag, halfcontop, highcontop, prhalfc, prhighc, context=context)
    cat_ids=[]
    for product in product.browse(cr, uid, uid):
        if product.categ_id.id not in cat_ids:
            cat_ids.append(product.categ_id.id)
    cats = pool.get('product.category').name_get(self.cr, self.uid, cat_ids, context=self.localcontext)        
    #Segun yo , hasta esta parte, hemos conseguido las categorias, me base en product_pricelist.py(funcion _get_categories)
    for cat in cats:
        x=0.0
        for product in product.browse(cr, uid, ids):
            if cat == product.product.category_id :
                 x = product.product_uom_qty  + x   #product.qty
        for product in product.browse(cr, uid, ids): 
            if cat == product.product.category_id:

                if x >= product.category.halfcontop and  x < product.category.highcontop :

                    res['price_unit'] = product.prhalfc

                elif x >= product.category.highcontop :

                    res['price_unit'] = product.prhighc

                else :

                    res['price_unit'] = product.price_unit  
    return res

and now the XML, with onchange method:

XML:

<openerp> <data> <record id="view_sale_order_form_minimalprice_form" model="ir.ui.view"> <field name="name">sale.order.form - minimal price</field> <field name="model">sale.order</field> <field name="type">form</field> <field name="priority" eval="20"/> <field name="inherit_id" ref="sale.view_order_form"/> <field name="arch" type="xml"> <data> <xpath expr="//field[@name='price_unit']" position="attributes"> <attribute name="on_change">product_id_change(parent.pricelist_id, product_id, product_uom_qty, product_uom, product_uos_qty, product_uos, name, parent.partner_id, False, True, parent.date_order, False, parent.fiscal_position, False, halfcontop, highcontop, prhalfc, prhighc, context)</attribute> </xpath> </data> </field> </record> </data> </openerp>

and fnally, whe trying to install it,, I get the following error:

Server Traceback (most recent call last): File "/opt/openerp/server/openerp/addons/web/session.py", line 89, in send return openerp.netsvc.dispatch_rpc(service_name, method, args) File "/opt/openerp/server/openerp/netsvc.py", line 292, in dispatch_rpc result = ExportService.getService(service_name).dispatch(method, params) File "/opt/openerp/server/openerp/service/web_services.py", line 626, in dispatch res = fn(db, uid, params) File "/opt/openerp/server/openerp/osv/osv.py", line 188, in execute_kw return self.execute(db, uid, obj, method, *args, *kw or {}) File "/opt/openerp/server/openerp/osv/osv.py", line 131, in wrapper return f(self, dbname, args, *kwargs) File "/opt/openerp/server/openerp/osv/osv.py", line 197, in execute res = self.execute_cr(cr, uid, obj, method, args, *kw) File "/opt/openerp/server/openerp/osv/osv.py", line 185, in execute_cr return getattr(object, method)(cr, uid, args, *kw) File "/opt/openerp/server/openerp/addons/base/module/module.py", line 424, in button_immediate_install return self._button_immediate_function(cr, uid, ids, self.button_install, context=context) File "/opt/openerp/server/openerp/addons/base/module/module.py", line 475, in _button_immediate_function _, pool = pooler.restart_pool(cr.dbname, update_module=True) File "/opt/openerp/server/openerp/pooler.py", line 39, in restart_pool registry = RegistryManager.new(db_name, force_demo, status, update_module) File "/opt/openerp/server/openerp/modules/registry.py", line 218, in new openerp.modules.load_modules(registry.db, force_demo, status, update_module) File "/opt/openerp/server/openerp/modules/loading.py", line 345, in load_modules processed = load_marked_modules(cr, graph, states_to_load, force, status, report, loaded_modules, update_module) File "/opt/openerp/server/openerp/modules/loading.py", line 256, in load_marked_modules loaded, processed = load_module_graph(cr, graph, progressdict, report=report, skip_modules=loaded_modules, perform_checks=perform_checks) File "/opt/openerp/server/openerp/modules/loading.py", line 161, in load_module_graph models = pool.load(cr, package) File "/opt/openerp/server/openerp/modules/registry.py", line 118, in load model = cls.create_instance(self, cr) File "/opt/openerp/server/openerp/osv/orm.py", line 926, in create_instance obj.__init__(pool, cr) File "/opt/openerp/server/openerp/osv/orm.py", line 1061, in __init__ self._inherits_check() File "/opt/openerp/server/openerp/osv/orm.py", line 3446, in _inherits_check for table, field_name in self._inherits.items(): AttributeError: 'tuple' object has no attribute 'items'

Thanks in adavnce for suggestions!!

1
الصورة الرمزية
إهمال
Andreas Marpmann

"How can I fix this problem?" say nothing! Please enter a short description in headline and add tags.

Ray Carnes

Please review http://help.openerp.com/question/25620/meta-why-do-some-questions-get-answers-and-others-dont/

Diego Calzadilla
الكاتب

ok, title changed!!

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

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

تسجيل
المجتمع
  • دروس
  • التوثيق
  • المنتدى
مصدر مفتوح
  • تحميل
  • جيت هاب "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