From 1e6b71548cdca3b3e060d43b962c9021f78ba5fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Fri, 1 Aug 2008 16:30:52 +0200 Subject: [PATCH] Add default value for payment_term and warehouse if there is only one --- purchase.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/purchase.py b/purchase.py index 61f51b10ce..cfa50dedc7 100644 --- a/purchase.py +++ b/purchase.py @@ -96,6 +96,24 @@ class Purchase(OSV): 'button_compute', ] + def default_payment_term(self, cursor, user, context=None): + payment_term_obj = self.pool.get('account.invoice.payment_term') + payment_term_ids = payment_term_obj.search(cursor, user, [], + context=context) + if len(payment_term_ids) == 1: + return payment_term_obj.name_get(cursor, user, payment_term_ids, + context=context)[0] + return False + + def default_warehouse(self, cursor, user, context=None): + location_obj = self.pool.get('stock.location') + location_ids = location_obj.search(cursor, user, + self.warehouse._domain, context=context) + if len(location_ids) == 1: + return location_obj.name_get(cursor, user, location_ids, + context=context)[0] + return False + def default_company(self, cursor, user, context=None): company_obj = self.pool.get('company.company') if context is None: