3

自分のmodule.itsをアンインストールしようとすると、エラーが発生します。(OpenErp ver 7)私のクラスでもさまざまな変更を入力しましたが、すべてをクリアして以下のコードのみを保持するわけではありません。これの問題を見つけるのを手伝ってください。今、address_bookモジュールをインストールしようとするとこのエラーが発生しました

  File "/home/priyan/Software/openerp-7.0-20130309-002120/openerp/modules/registry.py", line 218, in new
    openerp.modules.load_modules(registry.db, force_demo, status, update_module)
  File "/home/priyan/Software/openerp-7.0-20130309-002120/openerp/modules/loading.py", line 416, in load_modules
    pool.get('ir.module.module').module_uninstall(cr, SUPERUSER_ID, mod_ids_to_remove)
  File "/home/priyan/Software/openerp-7.0-20130309-002120/openerp/addons/base/module/module.py", line 439, in module_uninstall
    ir_model_constraint._module_data_uninstall(cr, uid, constraint_ids, context)
  File "/home/priyan/Software/openerp-7.0-20130309-002120/openerp/addons/base/ir/ir_model.py", line 533, in _module_data_uninstall
    WHERE cs.contype=%s and cs.conname=%s and cl.relname=%s""", ('f', name, model_obj._table))
AttributeError: 'NoneType' object has no attribute '_table'

これが私のview.xmlファイルです

<?xml version="1.0"?>
<openerp>
    <data>
        <!-- 1st part of the sim_view start -->
        <record model="ir.ui.view" id="worker_form">
            <field name="name">Basic Data</field>
            <field name="model">checkroll.plucker</field>
            <field name="type">form</field>
            <field name="arch" type="xml">
                <form string="Worker_test">
                    <field name="reg_no" />
                    <field name="worker_name" />
                    <field name="spouse_name" />
                    <field name="gender" />
                    <field name="epf_no" />
                </form>
            </field>
        </record>
        <!--2nd part of the sim_view start -->
        <record model="ir.ui.view" id="worker_tree">
            <field name="name">Basic Data</field>
            <field name="model">checkroll.plucker</field>
            <field name="type">tree</field>
            <field name="arch" type="xml">
                <tree string="Worker_test"><!-- which columns need to shows in OpenERP List View -->
                    <field name="reg_no" />
                    <field name="worker_name" />
                    <field name="spouse_name" />
                </tree>
            </field>
        </record>
        <!-- 3rd part of the sim_view start -->
        <record model="ir.actions.act_window" id="action_worker_reg">
            <field name="name">Worker Registration</field><!-- This shows what should 
                screen caption in form/tree views -->
            <field name="res_model">checkroll.plucker</field>
            <field name="view_type">form</field>
            <field name="view_mode">tree,form</field>
        </record>



    </data>
</openerp>

これが私のクラスファイルです

from openerp.osv import fields, osv
import random

class checkroll(osv.osv):
    _name = "checkroll.plucker"
    _description = "This table is for keeping personal data of plucker"
    _columns = {
        'reg_no': fields.char('Registration Number', size=256, required=True),
        'worker_name': fields.char('Worker Name', size=256, required=True),
        'spouse_name': fields.char('Spouse Name', size=256),
        'gender' : fields.selection((('male', 'Male'), ('female', 'Female'), ('middle', 'Test')), 'Gender', required=True),
        'epf_no':fields.char('EPF Number', size=256)
    }

checkroll()
4

3 に答える 3

1

バックエンドのデータ マッピングに問題があるようです。そのため、openerp に管理者としてログインし、新しいデータベースを作成して、モジュールをそこに移行しました。今では完璧に動作します

全てに感謝

このエラーを受け取った人がこの回答から助けを得ることを願っています

于 2013-03-19T10:03:05.270 に答える
1

openerp .pyで必要なすべての依存関係を提供したかどうかを確認します。これで問題は解決しました。

于 2013-11-12T07:58:39.670 に答える
-1

ベース モジュールをアップグレードすると、データベース内の古い参照が削除され、モジュールのアンインストールに役立つ場合があります。

それでもうまくいかない場合は、自己責任でこのスタンドアロン スクリプトを試すことができます。バックアップを作成してください!

編集:リンクが更新されました

EDIT2 :ここにuninstall_module.pyを貼り付けて、消えないようにします。

これを使用する場合は、データをバックアップしてください。データベース名、次にモジュール名を渡してスクリプトを呼び出します。例を次に示します。

chaouche@karabeela ~/CODE/OPENERP/TEST $ python uninstall_module.py test helloworld
No handlers could be found for logger "openerp.modules.graph"
data browse_record(ir.model.constraint, 352)
data.name newfield_country_id_fkey
data browse_record(ir.model.constraint, 353)
data.name newfield_res_partner_category_rel_partner_id_fkey
data browse_record(ir.model.constraint, 354)
data.name newfield_res_partner_category_rel_category_id_fkey
data browse_record(ir.model.constraint, 355)
data.name newfield_title_fkey
data browse_record(ir.model.constraint, 356)
data.name newfield_parent_id_fkey
data browse_record(ir.model.constraint, 357)
data.name newfield_user_id_fkey
data browse_record(ir.model.constraint, 358)
data.name newfield_company_id_fkey
data browse_record(ir.model.constraint, 359)
data.name newfield_section_id_fkey
data browse_record(ir.model.constraint, 360)
data.name newfield_state_id_fkey
chaouche@karabeela ~/CODE/OPENERP/TEST $

ここに uninstall_module.pyがあります:

import openerp
import logging
import sys
import argparse
_logger = logging.getLogger(__name__)

class ModuleRemover:
    _logger = logging.getLogger(__name__)
    uid        = openerp.SUPERUSER_ID

    def __init__(self,database,module_name):
        """
        """
        self.module_name = module_name
        self.pool        = openerp.modules.registry.RegistryManager.get(database)
        self.cr          = self.pool.db.cursor()

    def uninstall(self):
        """
        """
        module      = self.pool.get("ir.module.module")
        constraint  = self.pool.get("ir.model.constraint")
        model_data  = self.pool.get('ir.model.data')
        module_id   = module.search(self.cr,self.uid,[("name","=",self.module_name)])[0]
        module_name = module.browse(self.cr,self.uid,module_id).name
        ids         = constraint.search(self.cr, self.uid, [('module', '=', module_id)])
        self.cleanup(constraint,ids)
        model_data._module_data_uninstall(self.cr,self.uid,[module_name])
        module.write(self.cr, self.uid, module_id, {'state': 'uninstalled'})

    def cleanup(self,constraint,ids):
        """
        """
        for data in constraint.browse(self.cr,self.uid,ids):
            print "data",data
            model = data.model.model
            model_obj = type("tmp",(),{})()
            model_table = model
            name = openerp.tools.ustr(data.name)
            print "data.name",name
            typ = data.type
            if typ in ("u",'f'):
                # test if FK exists on this table (it could be on a related m2m table, in which case we ignore it)
                SQL = """SELECT 1 from pg_constraint cs JOIN pg_class cl ON (cs.conrelid = cl.oid)
                           WHERE cs.contype=%s and cs.conname=%s and cl.relname=%s""" % (typ, name, model_table)
                print SQL
                self.cr.execute(SQL)
                if self.cr.fetchone():
                    SQL = 'ALTER TABLE "%s" DROP CONSTRAINT "%s"' % (model_table, name)
                    print SQL
                    self.cr.execute(SQL)
                    print 'Dropped FK CONSTRAINT %s@%s' % (name, model)

        constraint.unlink(self.cr, self.uid, ids)


def main():
    argparser = argparse.ArgumentParser()
    argparser.add_argument("database", help="openerp database"     ,type=str, )
    argparser.add_argument("module"  , help="module to uninstall"  ,type=str, )
    args = argparser.parse_args(sys.argv[1:])
    ModuleRemover(args.database,args.module).uninstall()

if __name__ == "__main__":
    main()

逸話としては、これが私が openerp/oodoo をやめさせた理由であり、他のいくつかの理由もあります。

于 2014-03-04T21:37:58.977 に答える