Added supplier menuitem under Party menu.

This commit is contained in:
Bertrand Chenal
2008-05-27 23:45:37 +02:00
parent 1670b7ac84
commit a3b2dbbeff
4 changed files with 62 additions and 0 deletions
+1
View File
@@ -25,3 +25,4 @@
##############################################################################
from purchase import *
from party import *
+1
View File
@@ -20,5 +20,6 @@
],
'xml': [
'purchase.xml',
'party.xml',
],
}
+40
View File
@@ -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()
+20
View File
@@ -0,0 +1,20 @@
<?xml version="1.0"?>
<tryton>
<data>
<record model="ir.action.wizard" id="act_open_supplier">
<field name="name">Active Suppliers</field>
<field name="wiz_name">relationship.party.open_supplier</field>
</record>
<record model="ir.action.keyword" id="act_open_supplier_keyword1">
<field name="action" ref="act_open_supplier"/>
<field name="keyword">form_action</field>
<field name="model">relationship.party,0</field>
</record>
<menuitem name="Suppliers"
parent="relationship.menu_party_form"
action="act_open_supplier"
type="wizard"
icon="STOCK_JUSTIFY_FILL"
id="menu_open_supplier"/>
</data>
</tryton>