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 @@
-
-
-
-
+
+
+
+
@@ -225,7 +225,7 @@
purchase.order.line
-
+
@@ -235,11 +235,11 @@
-
-
-
+
+
+
diff --git a/addons/purchase_requisition/static/src/js/web_addons.js b/addons/purchase_requisition/static/src/js/web_addons.js
index f2ea43423f0..fd74006a850 100644
--- a/addons/purchase_requisition/static/src/js/web_addons.js
+++ b/addons/purchase_requisition/static/src/js/web_addons.js
@@ -10,17 +10,21 @@ var _t = core._t;
var CompareListView = ListView.extend({
- init: function() {
- var self = this;
- this._super.apply(this, arguments);
- this.on('list_view_loaded', this, function() {
- if(self.__parentedParent.$el.find('.oe_generate_po').length == 0){
- var button = $("")
- .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 @@
+
+
+
+