diff --git a/addons/account/account_invoice.py b/addons/account/account_invoice.py index 6a0a29cb2fe..b1c5db23df6 100644 --- a/addons/account/account_invoice.py +++ b/addons/account/account_invoice.py @@ -306,7 +306,7 @@ class account_invoice(osv.osv): if view_type == 'form': if partner['supplier'] and not partner['customer']: view_id = self.pool.get('ir.ui.view').search(cr,uid,[('name', '=', 'account.invoice.supplier.form')]) - else: + elif partner['customer'] and not partner['supplier']: view_id = self.pool.get('ir.ui.view').search(cr,uid,[('name', '=', 'account.invoice.form')]) if view_id and isinstance(view_id, (list, tuple)): view_id = view_id[0] diff --git a/addons/purchase/partner.py b/addons/purchase/partner.py index 86cce749a21..2edcf5ec0d8 100644 --- a/addons/purchase/partner.py +++ b/addons/purchase/partner.py @@ -24,6 +24,21 @@ from osv import fields, osv class res_partner(osv.osv): _name = 'res.partner' _inherit = 'res.partner' + + def _purchase_order_count(self, cr, uid, ids, field_name, arg, context=None): + res = {} + for partner in self.browse(cr, uid, ids, context=context): + res[partner.id] = len(partner.purchase_order_ids) + return res + + def copy(self, cr, uid, id, default=None, context=None): + if default is None: + default = {} + + default.update({'purchase_order_ids': []}) + + super(res_partner, self).copy(cr, uid, id, default=default, context=context) + _columns = { 'property_product_pricelist_purchase': fields.property( 'product.pricelist', @@ -33,6 +48,8 @@ class res_partner(osv.osv): string="Purchase Pricelist", view_load=True, help="This pricelist will be used, instead of the default one, for purchases from the current partner"), + 'purchase_order_count': fields.function(_purchase_order_count, string='# of Purchase Order', type='integer'), + 'purchase_order_ids': fields.one2many('purchase.order','partner_id','Purchase Order') } res_partner() diff --git a/addons/purchase/partner_view.xml b/addons/purchase/partner_view.xml index 5a9a731358c..81eaac92827 100644 --- a/addons/purchase/partner_view.xml +++ b/addons/purchase/partner_view.xml @@ -16,6 +16,73 @@ + + + RFQs and Purchases + purchase.order + form + tree,form,graph + {'search_default_partner_id': active_id} + + + This supplier has no RFQ or Purchase Order. Click here to create a new RFQ. + <p> + The "Quotation" is the first step of the Purchases flow. Manage your purchases from quotation to invoice. + <p> + You will be able to buy products (manage receptions) as well as services (create projects). + + + + + + res.partner.kanban.purchaseorder.inherit + res.partner + kanban + + + + + + + + Purchases + + + + + + + Supplier Invoices + account.invoice + form + tree,form,graph + [('type','=','in_invoice')] + {'search_default_partner_id': active_id, 'default_type': 'in_invoice', 'type': 'in_invoice', 'journal_type': 'purchase'} + + Click here to create Supplier invoice. + <p> + You can control the invoice from your supplier according to what you purchased or received. + <p> + OpenERP can also generate draft invoices automatically from purchase orders or receipts. + + + + + res.partner.view.purchase.buttons + res.partner + form + + + + +