[MERGE] merge with lp:openobject-server

bzr revid: sbh@tinyerp.com-20120419082626-y3jwqmfwolgd888o
This commit is contained in:
Sbh (Openerp) 2012-04-19 13:56:26 +05:30
commit 459abe3c36
11 changed files with 188 additions and 180 deletions

View File

@ -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)

View File

@ -1,36 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<menuitem icon="terp-administration" id="menu_administration"
name="Settings" sequence="50"
web_icon="data/administration.png"
web_icon_hover="data/administration-hover.png"/>
<menuitem icon="terp-administration" id="menu_administration_shortcut" parent="menu_administration" name="Custom Shortcuts" sequence="50"/>
<menuitem id="menu_custom" name="Customization"
parent="base.menu_administration" sequence="6"
groups="base.group_extended"/>
<menuitem id="next_id_4" name="Low Level Objects"
parent="base.menu_custom" sequence="30"/>
<menuitem id="menu_low_workflow" name="Workflows" parent="base.next_id_4"/>
<menuitem id="menu_custom_action" name="Actions" parent="base.menu_custom" groups="base.group_extended" sequence="20"/>
<menuitem id="menu_config" name="Configuration" parent="base.menu_administration" sequence="1"/>
<menuitem id="menu_translation" name="Translations" parent="base.menu_administration" sequence="6"/>
<menuitem id="menu_translation_app" name="Application Terms" parent="base.menu_translation" sequence="4" groups="base.group_extended"/>
<menuitem id="menu_translation_export" name="Import / Export"
groups="base.group_extended" parent="base.menu_translation" sequence="3"/>
<menuitem id="menu_users" name="Users" parent="base.menu_administration" sequence="4"/>
<menuitem id="menu_security" name="Security" parent="base.menu_administration" sequence="5"
groups="base.group_extended"/>
<menuitem id="menu_management" name="Modules" parent="base.menu_administration" sequence="0"/>
<menuitem id="reporting_menu"
parent="base.menu_custom" name="Reporting" sequence="30"
/>
<menuitem id="base.menu_reporting" name="Reporting" sequence="45"/>
<menuitem id="base.menu_reporting_dashboard" name="Dashboards" sequence="0" parent="base.menu_reporting" groups="base.group_extended"/>
<menuitem id="menu_audit" name="Audit" parent="base.menu_reporting" sequence="50" groups="base.group_system"/>
<menuitem id="base.menu_reporting_config" name="Configuration" parent="base.menu_reporting" sequence="100" groups="base.group_system"/>
<menuitem id="menu_reporting" name="Reporting" sequence="90"/>
<menuitem id="menu_reporting_dashboard" name="Dashboards" parent="menu_reporting" sequence="0" groups="group_extended"/>
<menuitem id="menu_reporting_config" name="Configuration" parent="menu_reporting" sequence="100" groups="group_system"/>
<menuitem id="menu_administration" name="Settings" sequence="100" icon="terp-administration"/>
<menuitem id="menu_management" name="Modules" parent="menu_administration" sequence="0"/>
<menuitem id="menu_config" name="Configuration" parent="menu_administration" sequence="1"/>
<menuitem id="menu_custom" name="Technical" parent="menu_config" sequence="8" groups="group_extended"/>
<menuitem id="next_id_2" name="User Interface" parent="menu_custom" groups="base.group_extended"/>
<menuitem id="menu_email" name="Email" parent="menu_custom" sequence="1"/>
<menuitem id="menu_security" name="Security" parent="menu_custom" sequence="25"/>
<menuitem id="next_id_4" name="Low Level Objects" parent="menu_custom" sequence="30"/>
<menuitem id="menu_low_workflow" name="Workflows" parent="next_id_4"/>
<menuitem id="menu_administration_shortcut" parent="menu_administration" name="Custom Shortcuts" sequence="50"/>
<menuitem id="menu_users" name="Users" parent="menu_administration" sequence="4"/>
<menuitem id="menu_translation" name="Translations" parent="menu_administration" sequence="7"/>
<menuitem id="menu_translation_app" name="Application Terms" parent="menu_translation" sequence="4" groups="group_extended"/>
<menuitem id="menu_translation_export" name="Import / Export" groups="group_extended" parent="menu_translation" sequence="3"/>
</data>
</openerp>

View File

@ -1,18 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<!--
======================
Languages
======================
-->
<menuitem id="next_id_2" name="User Interface" parent="base.menu_custom" groups="base.group_extended"/>
<!--
======================
Groups
======================
-->
<!-- res.groups -->
<record id="view_groups_form" model="ir.ui.view">
<field name="name">res.groups.form</field>
<field name="model">res.groups</field>

View File

@ -8,13 +8,13 @@ msgstr ""
"Project-Id-Version: openobject-server\n"
"Report-Msgid-Bugs-To: FULL NAME <EMAIL@ADDRESS>\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 <Unknown>\n"
"Language-Team: Japanese <ja@li.org>\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"
" ・ つのCODAファイル中の異なった銀行口座の複数の口座明細をサポート\n"
" ・ つの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処理の中のつのオブジェクトの除去は結果として関連付けられたオブジェクトを除去します。\n"
" 複数銀行明細を含むCODAファイルの除去は同じくそれらの関連する明細を除去します。\n"
" 複数銀行取引明細を含むCODAファイルの除去は同じくそれらの関連する取引明細を除去します。\n"
"\n"
" 次の調停のロジックはCODA処理の中に実装されています:\n"
" 1) CODA明細の会社の銀行口座番号は、会社のCODA銀行口座設定レコード銀行口座のタイプ\n"
" 1) CODA取引明細の会社の銀行口座番号は、会社のCODA銀行口座設定レコード銀行口座のタイプ\n"
" がinfoと定義された設定レコードは無視されますの銀行口座番号項目を基準に判断されます。\n"
" '内部転送'トランザクションはCODAファイルインポートウィザードの内部転送口座項目を使って生成されます。\n"
" 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"
"つの明細書の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"

View File

@ -662,9 +662,9 @@
<menuitem action="ir_action_wizard" id="menu_ir_action_wizard" parent="base.next_id_6"/>
<!-- Needaction mechanism -->
<record model="ir.ui.view" id="view_ir_needaction_users_tree">
<field name="name">ir.needaction_users.tree</field>
<field name="model">ir.needaction_users</field>
<record model="ir.ui.view" id="view_ir_needaction_users_rel_tree">
<field name="name">ir.needaction_users_rel.tree</field>
<field name="model">ir.needaction_users_rel</field>
<field name="type">tree</field>
<field name="sequence">10</field>
<field name="arch" type="xml">
@ -676,14 +676,14 @@
</field>
</record>
<record id="action_view_needaction_users" model="ir.actions.act_window">
<record id="action_view_needaction_users_rel" model="ir.actions.act_window">
<field name="name">Need action relationships</field>
<field name="res_model">ir.needaction_users</field>
<field name="res_model">ir.needaction_users_rel</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
</record>
<menuitem id="menu_needaction_users" name="Need actions" parent="base.menu_users" sequence="20" action="action_view_needaction_users" groups="base.group_no_one"/>
<menuitem id="menu_needaction_users_rel" name="Need actions" parent="base.menu_users" sequence="20" action="action_view_needaction_users_rel" groups="base.group_no_one"/>
<!-- Companies -->
<menuitem id="menu_res_company_global"
@ -893,7 +893,7 @@
<field name="res_model">ir.ui.view.custom</field>
<field name="help">Customized views are used when users reorganize the content of their dashboard views (via web client)</field>
</record>
<menuitem action="action_ui_view_custom" id="menu_action_ui_view_custom" parent="base.next_id_4"/>
<menuitem id="menu_action_ui_view_custom" action="action_ui_view_custom" parent="base.next_id_2"/>
<!-- Attachment -->
@ -1479,11 +1479,8 @@
</record>
<menuitem action="grant_menu_access" id="menu_grant_menu_access" parent="base.next_id_2" sequence="1"/>
<!--
=============================================================
Cron Jobs
=============================================================
-->
<!-- ir.cron -->
<record id="ir_cron_view_tree" model="ir.ui.view">
<field name="name">ir.cron.tree</field>
<field name="model">ir.cron</field>
@ -1574,9 +1571,10 @@
<field name="view_id" ref="ir_cron_view_tree"/>
</record>
<menuitem id="next_id_10" name="Scheduler" parent="base.menu_config" groups="base.group_extended" sequence="23"/>
<menuitem action="ir_cron_act" id="menu_ir_cron_act" parent="next_id_10"/>
<menuitem id="menu_ir_cron" name="Scheduler" parent="menu_custom" groups="base.group_extended" sequence="23"/>
<menuitem id="menu_ir_cron_act" action="ir_cron_act" parent="menu_ir_cron"/>
<!-- ir.model.access -->
<record id="ir_access_view_tree" model="ir.ui.view">
<field name="name">ir.model.access.tree</field>
@ -1878,6 +1876,8 @@
</record>
<menuitem action="action_server_action" id="menu_server_action" parent="base.next_id_6"/>
<!-- ir.actions.todo -->
<record id="ir_actions_todo_tree" model="ir.ui.view">
<field name="model">ir.actions.todo</field>
<field name="name">Config Wizard Steps</field>
@ -1950,13 +1950,8 @@
<field name="view_type">form</field>
<field name="help">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.</field>
</record>
<menuitem id="next_id_11" name="Configuration Wizards" parent="base.menu_config" sequence="20"
groups="base.group_extended"/>
<menuitem action="act_ir_actions_todo_form" id="menu_ir_actions_todo_form"
parent="next_id_11" sequence="20"/>
<menuitem id="menu_ir_actions_todo" name="Configuration Wizards" parent="menu_custom" sequence="20" groups="base.group_extended"/>
<menuitem id="menu_ir_actions_todo_form" action="act_ir_actions_todo_form" parent="menu_ir_actions_todo"/>
<record model="ir.cron" id="cronjob_osv_memory_autovacuum">
<field name='name'>AutoVacuum osv_memory objects</field>
@ -1969,7 +1964,9 @@
<field name="function">power_on</field>
<field name="args">()</field>
</record>
<!-- ir.actions.todo category -->
<record id="ir_actions_todo_category_form" model="ir.ui.view">
<field name="name">ir.actions.todo.category.form</field>
<field name="model">ir.actions.todo.category</field>
@ -1982,7 +1979,7 @@
</form>
</field>
</record>
<record id="ir_actions_todo_category_tree" model="ir.ui.view">
<field name="name">ir.actions.todo.category.tree</field>
<field name="model">ir.actions.todo.category</field>
@ -1998,12 +1995,12 @@
<record id="category_sales_management_config" model="ir.actions.todo.category">
<field name="name">Sales Management</field>
<field name="sequence">5</field>
</record>
</record>
<record id="category_tools_customization_config" model="ir.actions.todo.category">
<field name="name">Tools / Customization</field>
<field name="sequence">5</field>
</record>
</record>
<!-- ir.mail.server -->
<record model="ir.ui.view" id="ir_mail_server_form">
@ -2070,8 +2067,6 @@
<field name="view_id" ref="ir_mail_server_list" />
<field name="search_view_id" ref="view_ir_mail_server_search"/>
</record>
<menuitem id="menu_email" name="Email" parent="base.menu_config" sequence="22"/>
<menuitem id="menu_mail_servers" parent="menu_email" action="action_ir_mail_server_list" sequence="15" groups="base.group_no_one"/>
</data>

View File

@ -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:

View File

@ -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=[

View File

@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<menuitem id="menu_publisher_warranty" name="OpenERP Entreprise" parent="base.menu_administration" sequence="5"/>
<record id="publisher_warranty_contract_tree_view" model="ir.ui.view">
<field name="name">publisher_warranty.contract.tree</field>
@ -81,12 +82,7 @@
<field name="view_mode">tree,form,calendar</field>
<field name="search_view_id" ref="publisher_warranty_contract_search_view"/>
</record>
<menuitem name="Publisher Warranty" id="publisher_warranty"
parent="base.menu_administration"/>
<menuitem action="action_publisher_warranty_contract_form" id="menu_publisher_warranty_contract"
parent="publisher_warranty" sequence="2"/>
<menuitem id="menu_publisher_warranty_contract" parent="menu_publisher_warranty" action="action_publisher_warranty_contract_form" sequence="2"/>
<record id="publisher_warranty_contract_add_wizard" model="ir.ui.view">
@ -139,11 +135,7 @@
<field name="view_mode">form</field>
<field name="target">new</field>
</record>
<menuitem
action="action_publisher_warranty_contract_add_wizard"
id="menu_publisher_warranty_contract_add"
parent="publisher_warranty" sequence="1"/>
<menuitem id="menu_publisher_warranty_contract_add" action="action_publisher_warranty_contract_add_wizard" parent="menu_publisher_warranty" sequence="1"/>
</data>
</openerp>

View File

@ -75,7 +75,7 @@
<field name="view_type">form</field>
<field name="view_id" ref="ir_property_view_tree"/>
</record>
<menuitem id="next_id_15" name="Parameters" parent="base.menu_config" groups="base.group_extended" sequence="24"/>
<menuitem action="ir_property_form" id="menu_ir_property_form_all" parent="base.next_id_15"/>
<menuitem id="menu_ir_property" name="Parameters" parent="menu_custom" groups="group_extended" sequence="24"/>
<menuitem id="menu_ir_property_form_all" parent="menu_ir_property" action="ir_property_form"/>
</data>
</openerp>

View File

@ -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

1 id name model_id:id group_id:id perm_read perm_write perm_create perm_unlink
121 access_ir_mail_server_all ir_mail_server model_ir_mail_server 1 0 0 0
122 access_ir_actions_todo_category ir_actions_todo_category model_ir_actions_todo_category group_system 1 1 1 1
123 access_ir_actions_client ir_actions_client all model_ir_actions_client 1 0 0 0
124 access_ir_needaction_users access_ir_needaction_users_rel ir_needaction_users ir_needaction_users_rel model_ir_needaction_users model_ir_needaction_users_rel 1 1 1 1
125 access_ir_needaction_mixin ir_needaction_mixin model_ir_needaction_mixin 1 1 1 1
126

View File

@ -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):