From dbe3d8035f6f48b630f043707ffc6bac0b1cb204 Mon Sep 17 00:00:00 2001 From: Valerie Pirenne Date: Mon, 21 Sep 2015 16:25:12 +0200 Subject: [PATCH] [FIX] purchase: advanced calls for tenders add option in res_config to have advance mode for call for tender (option was lost in commit: 3d8f7c2f24e1894af973576b9cfd3ec632d675f7) + fix errors in method that used old po_line state + change icon to font-awesome icons --- addons/purchase/purchase.py | 1 + addons/purchase/res_config.py | 6 +++++ addons/purchase/res_config_view.xml | 2 ++ addons/purchase_requisition/__openerp__.py | 3 +++ .../purchase_requisition.py | 27 ++++++++++++------- .../purchase_requisition_view.xml | 20 +++++++------- .../static/src/js/web_addons.js | 22 ++++++++------- .../static/src/xml/purchase_requisition.xml | 10 +++++++ 8 files changed, 63 insertions(+), 28 deletions(-) create mode 100644 addons/purchase_requisition/static/src/xml/purchase_requisition.xml diff --git a/addons/purchase/purchase.py b/addons/purchase/purchase.py index 50e961d880a..296a3d87152 100644 --- a/addons/purchase/purchase.py +++ b/addons/purchase/purchase.py @@ -410,6 +410,7 @@ class PurchaseOrderLine(models.Model): order_id = fields.Many2one('purchase.order', string='Order Reference', select=True, required=True, ondelete='cascade') account_analytic_id = fields.Many2one('account.analytic.account', string='Analytic Account') company_id = fields.Many2one('res.company', related='order_id.company_id', string='Company', store=True, readonly=True) + state = fields.Selection(related='order_id.state', stored=True) invoice_lines = fields.One2many('account.invoice.line', 'purchase_line_id', string="Invoice Lines", readonly=True, copy=False) diff --git a/addons/purchase/res_config.py b/addons/purchase/res_config.py index 15a51b67bb7..d2ef7967e01 100644 --- a/addons/purchase/res_config.py +++ b/addons/purchase/res_config.py @@ -34,6 +34,12 @@ class purchase_config_settings(osv.osv_memory): help="""Calls for tenders are used when you want to generate requests for quotations to several vendors for a given set of products. You can configure per product if you directly do a Request for Quotation to one vendor or if you want a Call for Tenders to compare offers from several vendors."""), + 'group_advance_purchase_requisition': fields.selection([ + (0, 'Simple call for tender (only choose from one RFQ)'), + (1, 'Advanced call for tender (choose products from different RFQ)') + ], "Advanced Calls for Tenders", + implied_group='purchase.group_advance_bidding', + help="""In the process of a public tendering, you can compare the tender lines and choose for each requested product which quantity you will buy from each bid."""), 'module_stock_dropshipping': fields.selection([ (0, 'Suppliers always deliver to your warehouse(s)'), (1, "Allow suppliers to deliver directly to your customers") diff --git a/addons/purchase/res_config_view.xml b/addons/purchase/res_config_view.xml index 4a58c836062..6aae2feaad3 100644 --- a/addons/purchase/res_config_view.xml +++ b/addons/purchase/res_config_view.xml @@ -27,6 +27,8 @@ + diff --git a/addons/purchase_requisition/__openerp__.py b/addons/purchase_requisition/__openerp__.py index 343eefc7095..3ba618c1ac1 100644 --- a/addons/purchase_requisition/__openerp__.py +++ b/addons/purchase_requisition/__openerp__.py @@ -32,5 +32,8 @@ keep track and order all your purchase orders. 'test/cancel_purchase_requisition.yml', 'test/purchase_requisition.yml', ], + 'qweb': [ + 'static/src/xml/purchase_requisition.xml', + ], 'installable': True, } diff --git a/addons/purchase_requisition/purchase_requisition.py b/addons/purchase_requisition/purchase_requisition.py index 0110b79de7c..440dd44e09b 100644 --- a/addons/purchase_requisition/purchase_requisition.py +++ b/addons/purchase_requisition/purchase_requisition.py @@ -237,14 +237,14 @@ class purchase_requisition(osv.osv): if tender.state == 'done': raise UserError(_('You have already generate the purchase order(s).')) - # confirm = False - # #check that we have at least confirm one line - # for po_line in tender.po_line_ids: - # if po_line.state == 'confirmed': - # confirm = True - # break - # if not confirm: - # raise UserError(_('You have no line selected for buying.')) + confirm = False + #check that we have at least confirm one line + for po_line in tender.po_line_ids: + if po_line.quantity_tendered > 0: + confirm = True + break + if not confirm: + raise UserError(_('You have no line selected for buying.')) #check for complete RFQ for quotation in tender.purchase_ids: @@ -255,7 +255,7 @@ class purchase_requisition(osv.osv): #get other confirmed lines per supplier for po_line in tender.po_line_ids: #only take into account confirmed line that does not belong to already confirmed purchase order - if po_line.order_id.state in ['draft', 'sent', 'to approve']: + if po_line.quantity_tendered > 0 and po_line.order_id.state in ['draft', 'sent', 'to approve']: if id_per_supplier.get(po_line.partner_id.id): id_per_supplier[po_line.partner_id.id].append(po_line) else: @@ -363,6 +363,15 @@ class purchase_order_line(osv.osv): #call generate_po from tender with active_id. Called from js widget return self.pool.get('purchase.requisition').generate_po(cr, uid, [tender_id], context=context) + def button_confirm(self, cr, uid, ids, context=None): + for element in self.browse(cr, uid, ids, context=context): + self.write(cr, uid, element.id, {'quantity_tendered': element.product_qty}, context=context) + return True + + def button_cancel(self, cr, uid, ids, context=None): + self.write(cr, uid, ids, {'quantity_tendered': 0}, context=context) + return True + class product_template(osv.osv): _inherit = 'product.template' diff --git a/addons/purchase_requisition/purchase_requisition_view.xml b/addons/purchase_requisition/purchase_requisition_view.xml index 904d1335dc8..2ab6d00a996 100644 --- a/addons/purchase_requisition/purchase_requisition_view.xml +++ b/addons/purchase_requisition/purchase_requisition_view.xml @@ -103,10 +103,10 @@ - ") - .click(this.proxy('generate_purchase_order')); - self.__parentedParent.$el.find('.oe_list_buttons').append(button); + render_buttons: function ($node) { + if (!this.$buttons) { + this.$buttons = $(QWeb.render("CompareListView.buttons", {'widget': this})); + + this.$buttons.find('.oe_generate_po').click(this.proxy('generate_purchase_order')); + + $node = $node || this.options.$buttons; + if ($node) { + this.$buttons.appendTo($node); + } else { + this.$('.oe_list_buttons').replaceWith(this.$buttons); } - }); + } }, + generate_purchase_order: function () { var self = this; new Model(self.dataset.model).call("generate_po",[self.dataset.context.tender_id,self.dataset.context]).then(function(result) { diff --git a/addons/purchase_requisition/static/src/xml/purchase_requisition.xml b/addons/purchase_requisition/static/src/xml/purchase_requisition.xml new file mode 100644 index 00000000000..0706f2877fd --- /dev/null +++ b/addons/purchase_requisition/static/src/xml/purchase_requisition.xml @@ -0,0 +1,10 @@ + + + +
+ +
+
+
\ No newline at end of file