コンテンツへスキップ
Odoo メニュー
  • サインイン
  • 無料で15日試す
  • アプリ
    財務
    • 会計
    • 請求
    • 経費
    • スプレッドシート(BI)
    • ドキュメント管理
    • 署名
    販売
    • CRM
    • 販売
    • POS店舗
    • POSレストラン
    • サブスクリプション
    • レンタル
    ウェブサイト
    • ウェブサイトビルダー
    • eコマース
    • ブログ
    • フォーラム
    • ライブチャット
    • eラーニング
    サプライチェーン
    • 在庫
    • 製造
    • 製品ライフサイクル管理 (PLM)
    • 購買
    • 整備
    • 品質
    人事業務
    • 従業員管理
    • 採用
    • 休暇管理
    • 人事評価
    • リファラル
    • フリート
    マーケティング
    • ソーシャルマーケティング
    • メールマーケティング
    • SMSマーケティング
    • イベント
    • マーケティングオートメーション
    • アンケート調査
    サービス
    • プロジェクト管理
    • タイムシート
    • フィールドサービス
    • ヘルプデスク
    • 計画
    • アポイントメント
    生産性向上ツール
    • ディスカッション
    • 承認
    • IoT
    • VoIP
    • ナレッジ
    • WhatsApp
    サードパーティアプリ Odooスタジオ Odooクラウドプラットホーム
  • インダストリー(業種別ソリューション)
    小売
    • 書店
    • アパレルショップ
    • 家具専門店
    • 食料品店
    • 金物店
    • 玩具店
    飲食・ホスピタリティ業界
    • バー・パブ
    • レストラン
    • ファストフード
    • ゲストハウス
    • 飲料販売代理店
    • ホテル
    不動産
    • 不動産会社
    • 建築事務所
    • 建設
    • 不動産管理
    • 造園
    • 住宅所有者組合
    コンサルティング
    • 会計事務所
    • Odooパートナー
    • マーケティングエージェンシー
    • 法律事務所
    • 人材派遣
    • 監査・認証
    製造
    • テキスタイル
    • 金属
    • 家具
    • 飲食
    • 醸造所
    • コーポレートギフト
    ヘルス & フィットネス
    • スポーツクラブ
    • 眼鏡店
    • フィットネスセンター
    • ウェルネス専門家
    • 薬局
    • ヘアサロン
    業種
    • 便利屋
    • IT ハードウェア・サポート
    • 太陽エネルギーシステム
    • 靴メーカー
    • クリーニングサービス
    • 空調設備サービス
    その他
    • 非営利団体
    • 環境機関
    • ビルボードレンタル
    • 写真
    • 自転車リース
    • ソフトウェアリセラー
    すべての業種を見る
  • コミュニティ
    学ぶ
    • チュートリアル
    • ドキュメンテーション
    • 認定
    • トレーニング
    • ブログ
    • ポッドキャスト
    教育サポート
    • 教育プログラム
    • Scale Up! ビジネスゲーム
    • Odooオフィス訪問
    ソフトを入手
    • ダウンロード
    • エディションを比較
    • リリース
    コラボレーション
    • 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:

  • CRM
  • 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

購読

この投稿に活動があった際に通知を受け取ります

この質問にフラグが付けられました
13131 ビュー
アバター
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
  • Runbot
  • 翻訳
サービス
  • Odoo.shホスティング
  • サポート
  • アップグレード
  • カスタム開発
  • 教育プログラム
  • 会計事務所一覧
  • パートナー一覧
  • パートナーになる
企業情報
  • 会社概要
  • ブランドアセット
  • お問い合わせ
  • 採用情報
  • イベント
  • ポッドキャスト
  • ブログ
  • お客様一覧
  • リーガル情報 • プライバシーポリシー
  • セキュリティ
الْعَرَبيّة 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(オドゥー)は、CRM、eコマース、会計、在庫管理、POS、プロジェクト管理など、企業のさまざまな業務を一つのシステムで管理できる、ベルギー発のオープンソースのERPソフトウェアです。

高機能で使いやすく、完全に統合されたERPとして、ユニークな価値を提供しています。

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