diff --git a/doc/api/need_action_specs.rst b/doc/api/need_action_specs.rst index c9f32dd60c4..74e5efe1b3d 100644 --- a/doc/api/need_action_specs.rst +++ b/doc/api/need_action_specs.rst @@ -1,41 +1,84 @@ Need action mechanism ===================== -ir.needaction mixin class -++++++++++++++++++++++++++ +.. versionadded:: 7.0 + +ir.needaction_mixin class ++++++++++++++++++++++++++ + +.. versionadded:: openobject-server.4124 This revision adds a mixin class for objects using the need action feature. Need action feature can be used by objects willing to be able to signal that an action is required on a particular record. If in the business logic an action must be performed by somebody, for instance validation by a manager, this mechanism allows to set a list of users asked to perform an action. -This class wraps a class (ir.needaction_users) that behaves like a many2many field. However, no field is added to the model inheriting from base.needaction. The mixin class manages the low-level considerations of updating relationships. Every change made on the record calls a method that updates the relationships. +This class wraps a class (ir.ir_needaction_users_rel) that behaves like a many2many field. However, no field is added to the model inheriting from ir.needaction_mixin. The mixin class manages the low-level considerations of updating relationships. Every change made on the record calls a method that updates the relationships. Objects using the need_action feature should override the ``get_needaction_user_ids`` method. This methods returns a dictionary whose keys are record ids, and values a list of user ids, like in a many2many relationship. Therefore by defining only one method, you can specify if an action is required by defining the users that have to do it, in every possible situation. This class also offers several global services,: - ``needaction_get_record_ids``: for the current model and uid, get all record ids that ask this user to perform an action. This mechanism is used for instance to display the number of pending actions in menus, such as Leads (12) - ``needaction_get_action_count``: as ``needaction_get_record_ids`` but returns only the number of action, not the ids (performs a search with count=True) - - ``needaction_get_user_record_references``: for a given uid, get all the records that ask this user to perform an action. Records are given as references, a list of tuples (model_name, record_id) + - ``needaction_get_user_record_references``: for a given uid, get all the records that ask this user to perform an action. Records are given as references, a list of tuples (model_name, record_id). + +.. versionadded:: openobject-server.XXXX + +This revision of the needaction_mixin mechanism slighty modifies the class behavior. The ``ir_needaction_mixin`` class now adds a function field on models inheriting from the class. This field allows to state whether a given record has a needaction for the current user. This is usefull if you want to customize views according to the needaction feature. For example, you may want to set records in bold in a list view if the current user has an action to perform on the record. This makes the class not a pure abstract class, but allows to easily use the action information. The field definition is:: + + + def get_needaction_pending(self, cr, uid, ids, name, arg, context=None): + res = {} + needaction_user_ids = self.get_needaction_user_ids(cr, uid, ids, context=context) + for id in ids: + res[id] = uid in needaction_user_ids[id] + return res + + _columns = { + 'needaction_pending': fields.function(get_needaction_pending, type='boolean', + string='Need action pending', + help='If True, this field states that users have to perform an action. \ + This field comes from the needaction mechanism. Please refer \ + to the ir.needaction_mixin class.'), + } + +ir.needaction_users_rel class ++++++++++++++++++++++++++++++ + +.. versionadded:: openobject-server.4124 + +This class essentially wraps a database table that behaves like a many2many. +It holds data related to the needaction mechanism inside OpenERP. A row +in this model is characterized by: + + - ``res_model``: model of the record requiring an action + - ``res_id``: ID of the record requiring an action + - ``user_id``: foreign key to the res.users table, to the user that + has to perform the action + +This model can be seen as a many2many, linking (res_model, res_id) to +users (those whose attention is required on the record) Menu modification +++++++++++++++++ +.. versionchanged:: openobject-server.XXXX + This revision adds three functional fields to ``ir.ui.menu`` model : - ``uses_needaction``: boolean field. If the menu entry action is an act_window action, and if this action is related to a model that uses the need_action mechanism, this field is set to true. Otherwise, it is false. - ``needaction_uid_ctr``: integer field. If the target model uses the need action mechanism, this field gives the number of actions the current user has to perform. - - ``needaction_record_ids``: many2many field. If the target model uses the need action mechanism, this field holds the ids of the record requesting the user to perform an action. + - **REMOVED** ``needaction_record_ids``: many2many field. If the target model uses the need action mechanism, this field holds the ids of the record requesting the user to perform an action. **This field has been removed on version XXXX**. Those fields are functional, because they depend on the user and must therefore be computed at every refresh, each time menus are displayed. The use of the need action mechanism is done by taking into account the action domain in order to display accurate results. When computing the value of the functional fields, the ids of records asking the user to perform an action is concatenated to the action domain. A counting search is then performed on the model, giving back the number of action the users has to perform, limited to the domain of the action. Addon implementation example ++++++++++++++++++++++++++++ -In your ``foo`` module, you want to specify that when it is in state ``confirmed``, it has to be validated by a manager, given by the field ``manager_id``. After making ``foo`` inheriting from ``base.needaction``, you override the ``get_needaction_user_ids`` method: +In your ``foo`` module, you want to specify that when it is in state ``confirmed``, it has to be validated by a manager, given by the field ``manager_id``. After making ``foo`` inheriting from ``ir.needaction_mixin``, you override the ``get_needaction_user_ids`` method: :: [...] - _inherit = [base.needaction] + _inherit = [`ir.needaction_mixin] [...] def get_needaction_user_ids(self, cr, uid, ids, context=None): result = dict.fromkeys(ids) diff --git a/openerp/addons/base/base_menu.xml b/openerp/addons/base/base_menu.xml index d8cde2700ba..efc6844d383 100644 --- a/openerp/addons/base/base_menu.xml +++ b/openerp/addons/base/base_menu.xml @@ -1,36 +1,22 @@ - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + diff --git a/openerp/addons/base/base_update.xml b/openerp/addons/base/base_update.xml index 8a46c985dad..597fa824a59 100644 --- a/openerp/addons/base/base_update.xml +++ b/openerp/addons/base/base_update.xml @@ -1,18 +1,7 @@ - - - - + res.groups.form res.groups diff --git a/openerp/addons/base/i18n/ja.po b/openerp/addons/base/i18n/ja.po index b2433098807..8fb6a885e43 100644 --- a/openerp/addons/base/i18n/ja.po +++ b/openerp/addons/base/i18n/ja.po @@ -8,13 +8,13 @@ msgstr "" "Project-Id-Version: openobject-server\n" "Report-Msgid-Bugs-To: FULL NAME \n" "POT-Creation-Date: 2012-02-08 00:44+0000\n" -"PO-Revision-Date: 2012-04-18 02:23+0000\n" +"PO-Revision-Date: 2012-04-19 04:33+0000\n" "Last-Translator: Akira Hiyama \n" "Language-Team: Japanese \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"X-Launchpad-Export-Date: 2012-04-18 04:41+0000\n" +"X-Launchpad-Export-Date: 2012-04-19 04:37+0000\n" "X-Generator: Launchpad (build 15108)\n" #. module: base @@ -596,7 +596,7 @@ msgstr "スペイン語(ベネズエラ)/ Español (VE)" #. module: base #: model:ir.module.module,shortdesc:base.module_hr_timesheet_invoice msgid "Invoice on Timesheets" -msgstr "タイムシートによる請求書" +msgstr "勤務表による請求書" #. module: base #: view:base.module.upgrade:0 @@ -1203,13 +1203,13 @@ msgstr "" "==============================================\n" "\n" "このモジュールは分析的な会計を基本として、以下の機能が統合されています。\n" -" ・ タイムシートの割り当て\n" +" ・ 勤務表の割り当て\n" " ・ 休日管理\n" " ・ プロジェクト管理\n" "\n" "各部門のマネジャは、チームの誰かが計画上妥当性を考慮中の未割り当ての時間があるか、タスクの割り当てを必要としている誰かがいるのかを知ることができます。\n" "\n" -"月末に計画マネジャは、割り当てられたタイムシートがそれぞれの分析会計を尊重した計画であるかをチェックすることもできます。\n" +"月末に計画マネジャは、割り当てられた勤務表がそれぞれの分析会計を尊重した計画であるかをチェックすることもできます。\n" #. module: base #: selection:ir.property,type:0 @@ -2371,7 +2371,7 @@ msgstr "" " ・ 従業員へ請求書に基づく支払い\n" "\n" "このモジュールは分析会計も使うとともに、プロジェクトによる作業の場合は、顧客の出費の\n" -"再請求書を自動的に作成するタイムシート上の請求書と互換性があります。\n" +"再請求書を自動的に作成する勤務表上の請求書と互換性があります。\n" " " #. module: base @@ -3632,7 +3632,7 @@ msgstr "" "------------------\n" " ・ オーダー時に請求(発送前または発送後)\n" " ・ 配達時に請求\n" -" ・ タイムシートによる請求\n" +" ・ 勤務表による請求\n" " ・ 前請求\n" "\n" "パートナの選択:\n" @@ -3650,7 +3650,7 @@ msgstr "" " ・ 複数の小包\n" " ・ 配送コスト\n" "\n" -"セールス管理のダッシュボードに含むもの:\n" +"受注管理のダッシュボードに含むもの:\n" "------------------------------------------\n" " ・ 見積り\n" " ・ 月別受注\n" @@ -5598,7 +5598,7 @@ msgid "" "revenue\n" "reports, etc." msgstr "" -"経費、タイムシート入力などから請求書を作成します。\n" +"経費、勤務表入力などから請求書を作成します。\n" "コスト(人的資源、経費など)に基づく請求書を作成するためのモジュールです。========================================" "====================================\n" "\n" @@ -6180,23 +6180,23 @@ msgstr "" " ・ 全てのトランザクションコード、構造化された形式の通信の解析とロギング\n" " ・ CODA構成パラメータを通した自動金融仕訳帳割り当て\n" " ・ 銀行口座番号ごとの複数仕訳帳のサポート\n" -" ・ 1つのCODAファイル中の異なった銀行口座の複数の口座明細をサポート\n" +" ・ 1つのCODAファイル中の異なった銀行口座の複数の口座取引明細書をサポート\n" " ・ CODA銀行口座の構文解析のみをサポート(CODA銀行口座設定でtype='info'と定義された)\n" " ・ 多言語CODA解析、イギリス、オランダ、フランスのために与えられた解析設定データ\n" "\n" -" 機械で読み込み可能なCODAファイルはCODA銀行明細の中に人間が読むことのできる形式に解析され保存されます。\n" -" また、銀行明細はCODA情報のサブセットを含むように生成されます(これらのトランザクション行は金融会計レコード\n" +" 機械で読み込み可能なCODAファイルはCODA銀行取引明細書の中に人間が読むことのできる形式に解析され保存されます。\n" +" また、銀行取引明細書はCODA情報のサブセットを含むように生成されます(これらのトランザクション行は金融会計レコード\n" " 生成のためだけに要求されます)。\n" -" CODA銀行明細は読み込み専用オブジェクトです。銀行明細が会計ビジネス処理の要求によって\n" +" CODA銀行取引明細書は読み込み専用オブジェクトです。銀行取引明細書が会計ビジネス処理の要求によって\n" " 更新されるのに対して、オリジナルのCODAファイルは信頼できるものとして残されます。\n" "\n" -" タイプが'Info'として設定されたCODA銀行口座は、CODA銀行明細を作るだけです。\n" +" タイプが'Info'として設定されたCODA銀行口座は、CODA銀行取引明細書を作るだけです。\n" "\n" " CODA処理の中の1つのオブジェクトの除去は結果として関連付けられたオブジェクトを除去します。\n" -" 複数銀行明細を含むCODAファイルの除去は同じくそれらの関連する明細を除去します。\n" +" 複数銀行取引明細書を含むCODAファイルの除去は同じくそれらの関連する取引明細書を除去します。\n" "\n" " 次の調停のロジックはCODA処理の中に実装されています:\n" -" 1) CODA明細の会社の銀行口座番号は、会社のCODA銀行口座設定レコード(銀行口座のタイプ\n" +" 1) CODA取引明細書の会社の銀行口座番号は、会社のCODA銀行口座設定レコード(銀行口座のタイプ\n" " が’info’と定義された設定レコードは無視されます)の銀行口座番号項目を基準に判断されます。\n" " '内部転送'トランザクションはCODAファイルインポートウィザードの’内部転送口座’項目を使って生成されます。\n" " 2) 第2ステップとしてCODAトランザクション行の’構造化通信’項目は内部あるいは外部への請求書\n" @@ -6206,7 +6206,7 @@ msgstr "" " 4) 上記のステップが成功しないケースは、さらに手作業による処理を行うために、CODAファイルインポート\n" " ウィザードの’認識できない移動のためのデフォルト口座’項目を使ってトランザクションは生成されます。\n" "\n" -" 生成された銀行明細の手作業による調整の代わりに、不十分な自動的な認識情報であったOpenERPデータ\n" +" 生成された銀行取引明細書の手作業による調整の代わりに、不十分な自動的な認識情報であったOpenERPデータ\n" " ベースを更新した後のCODAを再度インポートすることもできます。\n" "\n" " CODA V1 サポートの注意事項:\n" @@ -7029,7 +7029,7 @@ msgstr "" "=============================================================================" "=======================\n" "\n" -"ユーザが自身のタイムシートをエンコードするときに主に利用されます: \n" +"ユーザが自身の勤務表をエンコードするときに主に利用されます: \n" "値が引き出され、それらの項目は自動的に埋められます。しかし、変更の可能性のためにそれらの値は利用可能です。\n" "\n" "明確に現在のアカウントに何も記録されていない場合は、このモジュールは古い設定と完全に互換性を持つために、\n" @@ -7384,7 +7384,7 @@ msgstr "ソース用語" #. module: base #: model:ir.module.module,shortdesc:base.module_hr_timesheet_sheet msgid "Timesheets Validation" -msgstr "タイムシートの検証" +msgstr "勤務表の検証" #. module: base #: model:ir.ui.menu,name:base.menu_main_pm @@ -10536,25 +10536,25 @@ msgid "" " " msgstr "" "\n" -"このモジュールはタイムシートと出勤のエンコードと検証を同じビューの中で簡易にできるように手助けします。\n" +"このモジュールは勤務表と出勤のエンコードと検証を同じビューの中で簡易にできるように手助けします。\n" "=============================================================================" "======================\n" "\n" "ビューの上部は出勤と追跡(Sign In / Sign Out)イベントのためにあります。\n" -"ビューの下部はタイムシートのためにあります。\n" +"ビューの下部は勤務表のためにあります。\n" "\n" "その他のタブはあなたの時間やあなたのチームの時間を分析を手助けする統計的なビューが含まれています:\n" "・ 日別の勤務時間(出勤を含む)\n" "・ プロジェクト別の勤務時間\n" "\n" -"このモジュールは完全なタイムシートの検証プロセスも実装されています:\n" +"このモジュールは完全な勤務表の検証プロセスも実装されています:\n" "・ ドラフトシート\n" "・ 従業員による期間の終わりの確認\n" "・ プロジェクトマネジャによる検証\n" "\n" "検証は会社に対して構成されます:\n" "・ 期間のサイズ(日、週、月、年)\n" -"・ タイムシートと出勤の間の最大の相違\n" +"・ 勤務表と出勤の間の最大の相違\n" " " #. module: base @@ -11153,7 +11153,7 @@ msgstr "" "税金管理\n" "予算\n" "顧客と仕入先請求書\n" -"銀行明細書\n" +"銀行取引明細書\n" "パートナによる調整処理\n" "\n" "会計士のための次のものを含むダッシュボードを作成して下さい:\n" @@ -11501,7 +11501,7 @@ msgstr "" "=============================================================================" "=================================\n" "\n" -"これは主にユーザが自身のタイムシートをエンコードする時に使用されています:\n" +"これは主にユーザが自身の勤務表をエンコードする時に使用されています:\n" "値は取り出され、そして項目は自動的に埋められます。しかし、これらの値の変更は可能です。\n" "\n" "現在のアカウントに何のデータも記録されていないことが明らかな場合は、このモジュールは古い構成と完全に互換性があるためアカウントデータによるデフォルト値がい" @@ -12230,7 +12230,7 @@ msgstr "" "=============================================================================" "========================================\n" "\n" -"1つの明細書のIBAN口座から正確に表現されたローカル口座を抜き抜く能力\n" +"1つの取引明細書のIBAN口座から正確に表現されたローカル口座を抜き抜く能力\n" " " #. module: base @@ -14597,7 +14597,7 @@ msgstr "" #. module: base #: model:ir.ui.menu,name:base.menu_project_management_time_tracking msgid "Time Tracking" -msgstr "追跡時間" +msgstr "時間記録" #. module: base #: view:res.partner.category:0 @@ -15185,7 +15185,7 @@ msgstr "" "・ 多数の支払いタイプのためにDTAの作成\n" "・ BVR管理(番号生成、レポート他)\n" "・ 銀行ファイルからインポート口座の移動(v11 他)\n" -"・ 調和のために銀行明細書を扱う方法の簡素化\n" +"・ 調和のために銀行取引明細書を扱う方法の簡素化\n" "\n" "次のZIPと銀行の不足項目の追加ができます:\n" "・ l10n_ch_zip\n" @@ -17108,7 +17108,7 @@ msgid "" " " msgstr "" "\n" -"このモジュールはタイムシートシステムを実装します。\n" +"このモジュールは勤務表システムを実装します。\n" "==========================================\n" "\n" "それぞれの従業員は異なったプロジェクトに費やした時間のエンコードと追跡ができます。\n" diff --git a/openerp/addons/base/ir/ir.xml b/openerp/addons/base/ir/ir.xml index ccec381f1d1..bf970a9b4d1 100644 --- a/openerp/addons/base/ir/ir.xml +++ b/openerp/addons/base/ir/ir.xml @@ -662,9 +662,9 @@ - - ir.needaction_users.tree - ir.needaction_users + + ir.needaction_users_rel.tree + ir.needaction_users_rel tree 10 @@ -676,14 +676,14 @@ - + Need action relationships - ir.needaction_users + ir.needaction_users_rel form tree,form - + ir.ui.view.custom Customized views are used when users reorganize the content of their dashboard views (via web client) - + @@ -1479,11 +1479,8 @@ - + + ir.cron.tree ir.cron @@ -1574,9 +1571,10 @@ - - + + + ir.model.access.tree @@ -1878,6 +1876,8 @@ + + ir.actions.todo Config Wizard Steps @@ -1950,13 +1950,8 @@ form The configuration wizards are used to help you configure a new instance of OpenERP. They are launched during the installation of new modules, but you can choose to restart some wizards manually from this menu. - - - - - + + AutoVacuum osv_memory objects @@ -1969,7 +1964,9 @@ power_on () - + + + ir.actions.todo.category.form ir.actions.todo.category @@ -1982,7 +1979,7 @@ - + ir.actions.todo.category.tree ir.actions.todo.category @@ -1998,12 +1995,12 @@ Sales Management 5 - + Tools / Customization 5 - + @@ -2070,8 +2067,6 @@ - - diff --git a/openerp/addons/base/ir/ir_needaction.py b/openerp/addons/base/ir/ir_needaction.py index 3fcd56affae..75a6c6cb523 100644 --- a/openerp/addons/base/ir/ir_needaction.py +++ b/openerp/addons/base/ir/ir_needaction.py @@ -24,17 +24,18 @@ from operator import itemgetter from osv import osv, fields from tools.translate import _ -class ir_needaction_users(osv.osv): +class ir_needaction_users_rel(osv.osv): ''' - ir_needaction_users holds data related to the needaction - mechanism inside OpenERP. A needaction is characterized by: + ir_needaction_users_rel holds data related to the needaction + mechanism inside OpenERP. A row in this model is characterized by: - res_model: model of the record requiring an action - res_id: ID of the record requiring an action - user_id: foreign key to the res.users table, to the user that has to perform the action - ''' + This model can be seen as a many2many, linking (res_model, res_id) to + users (those whose attention is required on the record).''' - _name = 'ir.needaction_users' + _name = 'ir.needaction_users_rel' _description = 'Needaction relationship table' _rec_name = 'id' _order = 'id desc' @@ -49,15 +50,11 @@ class ir_needaction_users(osv.osv): def _get_users(self, cr, uid, res_ids, res_model, context=None): """Given res_ids of res_model, get user_ids present in table""" - if context is None: - context = {} - needact_ids = self.search(cr, uid, [('res_model', '=', res_model), ('res_id', 'in', res_ids)], context=context) - return map(itemgetter('res_id'), self.read(cr, uid, needact_ids, context=context)) + rel_ids = self.search(cr, uid, [('res_model', '=', res_model), ('res_id', 'in', res_ids)], context=context) + return list(set(map(itemgetter('user_id'), self.read(cr, uid, rel_ids, ['user_id'], context=context)))) def create_users(self, cr, uid, res_ids, res_model, user_ids, context=None): """Given res_ids of res_model, add user_ids to the relationship table""" - if context is None: - context = {} for res_id in res_ids: for user_id in user_ids: self.create(cr, uid, {'res_model': res_model, 'res_id': res_id, 'user_id': user_id}, context=context) @@ -65,8 +62,6 @@ class ir_needaction_users(osv.osv): def unlink_users(self, cr, uid, res_ids, res_model, context=None): """Given res_ids of res_model, delete all entries in the relationship table""" - if context is None: - context = {} to_del_ids = self.search(cr, uid, [('res_model', '=', res_model), ('res_id', 'in', res_ids)], context=context) return self.unlink(cr, uid, to_del_ids, context=context) @@ -74,7 +69,7 @@ class ir_needaction_users(osv.osv): """Given res_ids of res_model, update their entries in the relationship table to user_ids""" # read current records cur_users = self._get_users(cr, uid, res_ids, res_model, context=context) - if len(cur_users) == len(user_ids) and all([cur_user in user_ids for cur_user in cur_users]): + if len(cur_users) == len(user_ids) and all(cur_user in user_ids for cur_user in cur_users): return True # unlink old records self.unlink_users(cr, uid, res_ids, res_model, context=context) @@ -92,13 +87,13 @@ class ir_needaction_mixin(osv.osv): validation by a manager, this mechanism allows to set a list of users asked to perform an action. - This class wraps a class (ir.needaction_users) that behaves + This class wraps a class (ir.ir_needaction_users_rel) that behaves like a many2many field. However, no field is added to the model - inheriting from base.needaction. The mixin class manages the low-level + inheriting from this mixin class. This class handles the low-level considerations of updating relationships. Every change made on the record calls a method that updates the relationships. - Objects using the need_action feature should override the + Objects using the 'need_action' feature should override the ``get_needaction_user_ids`` method. This methods returns a dictionary whose keys are record ids, and values a list of user ids, like in a many2many relationship. Therefore by defining only one method, @@ -116,9 +111,32 @@ class ir_needaction_mixin(osv.osv): - ``needaction_get_user_record_references``: for a given uid, get all the records that ask this user to perform an action. Records are given as references, a list of tuples (model_name, record_id) - ''' + + The ``ir_needaction_mixin`` class adds a function field on models inheriting + from the class. This field allows to state whether a given record has + a needaction for the current user. This is usefull if you want to customize + views according to the needaction feature. For example, you may want to + set records in bold in a list view if the current user has an action to + perform on the record. This makes the class not a pure abstract class, + but allows to easily use the action information.''' + _name = 'ir.needaction_mixin' - _description = 'Need action of users on records API' + _description = '"Need action" mixin' + + def get_needaction_pending(self, cr, uid, ids, name, arg, context=None): + res = {} + needaction_user_ids = self.get_needaction_user_ids(cr, uid, ids, context=context) + for id in ids: + res[id] = uid in needaction_user_ids[id] + return res + + _columns = { + 'needaction_pending': fields.function(get_needaction_pending, type='boolean', + string='Need action pending', + help='If True, this field states that users have to perform an action. \ + This field comes from the needaction mechanism. Please refer \ + to the ir.needaction_mixin class.'), + } #------------------------------------------------------ # Addon API @@ -131,68 +149,56 @@ class ir_needaction_mixin(osv.osv): return dict.fromkeys(ids, []) def create(self, cr, uid, values, context=None): - if context is None: - context = {} - needact_table_obj = self.pool.get('ir.needaction_users') + rel_obj = self.pool.get('ir.needaction_users_rel') # perform create obj_id = super(ir_needaction_mixin, self).create(cr, uid, values, context=context) # link user_ids needaction_user_ids = self.get_needaction_user_ids(cr, uid, [obj_id], context=context) - needact_table_obj.create_users(cr, uid, [obj_id], self._name, needaction_user_ids[obj_id], context=context) + rel_obj.create_users(cr, uid, [obj_id], self._name, needaction_user_ids[obj_id], context=context) return obj_id def write(self, cr, uid, ids, values, context=None): - if context is None: - context = {} - needact_table_obj = self.pool.get('ir.needaction_users') + rel_obj = self.pool.get('ir.needaction_users_rel') # perform write write_res = super(ir_needaction_mixin, self).write(cr, uid, ids, values, context=context) # get and update user_ids needaction_user_ids = self.get_needaction_user_ids(cr, uid, ids, context=context) for id in ids: - needact_table_obj.update_users(cr, uid, [id], self._name, needaction_user_ids[id], context=context) + rel_obj.update_users(cr, uid, [id], self._name, needaction_user_ids[id], context=context) return write_res def unlink(self, cr, uid, ids, context=None): - if context is None: - context = {} # unlink user_ids - needact_table_obj = self.pool.get('ir.needaction_users') - needact_table_obj.unlink_users(cr, uid, ids, self._name, context=context) + rel_obj = self.pool.get('ir.needaction_users_rel') + rel_obj.unlink_users(cr, uid, ids, self._name, context=context) # perform unlink return super(ir_needaction_mixin, self).unlink(cr, uid, ids, context=context) #------------------------------------------------------ - # Need action API + # "Need action" API #------------------------------------------------------ def needaction_get_record_ids(self, cr, uid, user_id, limit=80, context=None): """Given the current model and a user_id - get the number of actions it has to perform""" - if context is None: - context = {} - needact_table_obj = self.pool.get('ir.needaction_users') - needact_table_ids = needact_table_obj.search(cr, uid, [('res_model', '=', self._name), ('user_id', '=', user_id)], limit=limit, context=context) - return map(itemgetter('res_id'), needact_table_obj.read(cr, uid, needact_table_ids, context=context)) + return the record ids that require the user to perform an + action""" + rel_obj = self.pool.get('ir.needaction_users_rel') + rel_ids = rel_obj.search(cr, uid, [('res_model', '=', self._name), ('user_id', '=', user_id)], limit=limit, context=context) + return map(itemgetter('res_id'), rel_obj.read(cr, uid, rel_ids, ['res_id'], context=context)) def needaction_get_action_count(self, cr, uid, user_id, limit=80, context=None): """Given the current model and a user_id get the number of actions it has to perform""" - if context is None: - context = {} - needact_table_obj = self.pool.get('ir.needaction_users') - return needact_table_obj.search(cr, uid, [('res_model', '=', self._name), ('user_id', '=', user_id)], limit=limit, count=True, context=context) + rel_obj = self.pool.get('ir.needaction_users_rel') + return rel_obj.search(cr, uid, [('res_model', '=', self._name), ('user_id', '=', user_id)], limit=limit, count=True, context=context) def needaction_get_record_references(self, cr, uid, user_id, offset=None, limit=None, order=None, context=None): """For a given user_id, get all the records that asks this user to perform an action. Records are given as references, a list of tuples (model_name, record_id). This method is trans-model.""" - if context is None: - context = {} - needact_table_obj = self.pool.get('ir.needaction_users') - needact_table_ids = needact_table_obj.search(cr, uid, [('user_id', '=', user_id)], offset=offset, limit=limit, order=order, context=context) - needact_records = needact_table_obj.read(cr, uid, needact_table_ids, context=context) - return map(itemgetter('res_model', 'id'), needact_records) + rel_obj = self.pool.get('ir.needaction_users_rel') + rel_ids = rel_obj.search(cr, uid, [('user_id', '=', user_id)], offset=offset, limit=limit, order=order, context=context) + return map(itemgetter('res_model', 'res_id'), rel_obj.read(cr, uid, rel_ids, ['res_model', 'res_id'], context=context)) # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/openerp/addons/base/ir/ir_ui_menu.py b/openerp/addons/base/ir/ir_ui_menu.py index 1f3f2e0f181..15d250a7489 100644 --- a/openerp/addons/base/ir/ir_ui_menu.py +++ b/openerp/addons/base/ir/ir_ui_menu.py @@ -258,19 +258,15 @@ class ir_ui_menu(osv.osv): def _get_needaction(self, cr, uid, ids, field_names, args, context=None): if context is None: context = {} - res = dict.fromkeys(ids) + res = {} for menu in self.browse(cr, uid, ids, context=context): res[menu.id] = {} if menu.action and menu.action.type == 'ir.actions.act_window' and menu.action.res_model: - menu_needaction_res = self.pool.get(menu.action.res_model).get_needaction_info(cr, uid, uid, domain=menu.action.domain, context=context) - # TODO: find the addon that causes a bug on runbot, not on local - if not isinstance(menu_needaction_res[1], (int, long)): menu_needaction_res[1] = 0 + menu_needaction_res = self.pool.get(menu.action.res_model)._get_needaction_info(cr, uid, uid, domain=menu.action.domain, context=context) else: - menu_needaction_res = [False, 0, ()] + menu_needaction_res = [False, 0] res[menu.id]['needaction_enabled'] = menu_needaction_res[0] res[menu.id]['needaction_counter'] = menu_needaction_res[1] - # not used currently, therefore set to a void list - res[menu.id]['needaction_record_ids'] = [] return res _columns = { @@ -291,7 +287,6 @@ class ir_ui_menu(osv.osv): 'web_icon_hover_data':fields.function(_get_image_icon, string='Web Icon Image (hover)', type='binary', readonly=True, store=True, multi='icon'), 'needaction_enabled': fields.function(_get_needaction, string='Target model uses the need action mechanism', type='boolean', help='If the menu entry action is an act_window action, and if this action is related to a model that uses the need_action mechanism, this field is set to true. Otherwise, it is false.', multi='_get_needaction'), 'needaction_counter': fields.function(_get_needaction, string='Number of actions the user has to perform', type='integer', help='If the target model uses the need action mechanism, this field gives the number of actions the current user has to perform.', multi='_get_needaction'), - 'needaction_record_ids': fields.function(_get_needaction, string='Ids of records requesting an action from the user', type='many2many', help='If the target model uses the need action mechanism, this field holds the ids of the record requesting the user to perform an action.', multi='_get_needaction'), 'action': fields.function(_action, fnct_inv=_action_inv, type='reference', string='Action', selection=[ diff --git a/openerp/addons/base/publisher_warranty/publisher_warranty_view.xml b/openerp/addons/base/publisher_warranty/publisher_warranty_view.xml index 8c40d0a1c6b..4b15ff8f8c0 100644 --- a/openerp/addons/base/publisher_warranty/publisher_warranty_view.xml +++ b/openerp/addons/base/publisher_warranty/publisher_warranty_view.xml @@ -1,6 +1,7 @@ + publisher_warranty.contract.tree @@ -81,12 +82,7 @@ tree,form,calendar - - - - + @@ -139,11 +135,7 @@ form new - - + diff --git a/openerp/addons/base/res/ir_property_view.xml b/openerp/addons/base/res/ir_property_view.xml index d0292576199..87835cafffc 100644 --- a/openerp/addons/base/res/ir_property_view.xml +++ b/openerp/addons/base/res/ir_property_view.xml @@ -75,7 +75,7 @@ form - - + + diff --git a/openerp/addons/base/security/ir.model.access.csv b/openerp/addons/base/security/ir.model.access.csv index ac05b726341..8b906ba48a5 100644 --- a/openerp/addons/base/security/ir.model.access.csv +++ b/openerp/addons/base/security/ir.model.access.csv @@ -121,6 +121,6 @@ "access_ir_mail_server_all","ir_mail_server","model_ir_mail_server",,1,0,0,0 "access_ir_actions_todo_category","ir_actions_todo_category","model_ir_actions_todo_category","group_system",1,1,1,1 "access_ir_actions_client","ir_actions_client all","model_ir_actions_client",,1,0,0,0 -"access_ir_needaction_users","ir_needaction_users","model_ir_needaction_users",,1,1,1,1 +"access_ir_needaction_users_rel","ir_needaction_users_rel","model_ir_needaction_users_rel",,1,1,1,1 "access_ir_needaction_mixin","ir_needaction_mixin","model_ir_needaction_mixin",,1,1,1,1 diff --git a/openerp/osv/orm.py b/openerp/osv/orm.py index 313c96a9fb4..bdf78fd3567 100644 --- a/openerp/osv/orm.py +++ b/openerp/osv/orm.py @@ -4866,7 +4866,7 @@ class BaseModel(object): get_xml_id = get_external_id _get_xml_ids = _get_external_ids - def get_needaction_info(self, cr, uid, user_id, limit=None, order=None, domain=False, context=None): + def _get_needaction_info(self, cr, uid, user_id, limit=None, order=None, domain=False, context=None): """Base method for needaction mechanism - see ir.needaction for actual implementation - if the model uses the need action mechanism @@ -4883,16 +4883,18 @@ class BaseModel(object): :return: [uses_needaction=True/False, needaction_uid_ctr=%d] """ if hasattr(self, 'needaction_get_record_ids'): + # Arbitrary limit, but still much lower thant infinity, to avoid + # getting too much data. ids = self.needaction_get_record_ids(cr, uid, user_id, limit=8192, context=context) if not ids: - return [True, 0, []] + return [True, 0] if domain: new_domain = eval(domain, locals_dict={'uid': user_id}) + [('id', 'in', ids)] else: new_domain = [('id', 'in', ids)] - return [True, self.search(cr, uid, new_domain, limit=limit, order=order, count=True, context=context), ids] + return [True, self.search(cr, uid, new_domain, limit=limit, order=order, count=True, context=context)] else: - return [False, 0, []] + return [False, 0] # Transience def is_transient(self):