From a3b2dbbeff261fb85e6c043ef1e1da024d4fd11d Mon Sep 17 00:00:00 2001 From: Bertrand Chenal Date: Tue, 27 May 2008 23:45:37 +0200 Subject: [PATCH] Added supplier menuitem under Party menu. --- __init__.py | 1 + __tryton__.py | 1 + party.py | 40 ++++++++++++++++++++++++++++++++++++++++ party.xml | 20 ++++++++++++++++++++ 4 files changed, 62 insertions(+) create mode 100644 party.py create mode 100644 party.xml diff --git a/__init__.py b/__init__.py index 563fd3eae0..7e0719c06b 100644 --- a/__init__.py +++ b/__init__.py @@ -25,3 +25,4 @@ ############################################################################## from purchase import * +from party import * diff --git a/__tryton__.py b/__tryton__.py index 1f9f290a64..1d1e59bea8 100644 --- a/__tryton__.py +++ b/__tryton__.py @@ -20,5 +20,6 @@ ], 'xml': [ 'purchase.xml', + 'party.xml', ], } diff --git a/party.py b/party.py new file mode 100644 index 0000000000..164e8cd990 --- /dev/null +++ b/party.py @@ -0,0 +1,40 @@ +from trytond.wizard import Wizard + +class OpenSupplier(Wizard): + 'Open Suppliers' + _name = 'relationship.party.open_supplier' + states = { + 'init': { + 'result': { + 'type': 'action', + 'action': '_action_open', + 'state': 'end', + }, + }, + } + + def _action_open(self, cursor, user, datas, context=None): + model_data_obj = self.pool.get('ir.model.data') + act_window_obj = self.pool.get('ir.action.act_window') + + model_data_ids = model_data_obj.search(cursor, user, [ + ('fs_id', '=', 'act_party_form'), + ('module', '=', 'relationship'), + ], limit=1, context=context) + model_data = model_data_obj.browse(cursor, user, model_data_ids[0], + context=context) + res = act_window_obj.read(cursor, user, model_data.db_id, + context=context) + cursor.execute( + "SELECT party, max(purchase_date) FROM purchase_purchase "\ + "GROUP BY party "\ + "ORDER BY max(purchase_date) DESC" + ) + suppliers = [line[0] for line in cursor.fetchall()] + + domain = eval( res.get('domain') or "[]" ) + domain.append(('id', 'in', suppliers)) + res['domain'] = str(domain) + return res + +OpenSupplier() diff --git a/party.xml b/party.xml new file mode 100644 index 0000000000..f766763b00 --- /dev/null +++ b/party.xml @@ -0,0 +1,20 @@ + + + + + Active Suppliers + relationship.party.open_supplier + + + + form_action + relationship.party,0 + + + +