[FIX] purchase: advanced calls for tenders
add option in res_config to have advance mode for call for tender (option was lost in commit: 3d8f7c2f24)
+ fix errors in method that used old po_line state
+ change icon to font-awesome icons
This commit is contained in:
committed by
Cedric Snauwaert
parent
f208a1f575
commit
dbe3d8035f
@@ -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)
|
||||
|
||||
|
||||
@@ -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")
|
||||
|
||||
@@ -27,6 +27,8 @@
|
||||
<field name="group_uom" widget="radio"/>
|
||||
<field name="group_costing_method" widget="radio"/>
|
||||
<field name="module_purchase_requisition" widget="radio"/>
|
||||
<field name="group_advance_purchase_requisition" widget="radio"
|
||||
attrs="{'invisible': [('module_purchase_requisition', '=', 0)]}"/>
|
||||
<field name="group_manage_vendor_price" widget="radio"/>
|
||||
</group>
|
||||
<group string="Location & Warehouse">
|
||||
|
||||
@@ -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,
|
||||
}
|
||||
|
||||
@@ -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'
|
||||
|
||||
@@ -103,10 +103,10 @@
|
||||
<field name="date_planned" invisible="1"/>
|
||||
<field name="origin"/>
|
||||
<field name="state"/>
|
||||
<button name="button_cancel" states="draft,sent,to approve,purchase" string="Cancel Purchase Order" type="object" icon="gtk-cancel"/>
|
||||
<button name="button_confirm" states="draft" string="Confirm Purchase Order" type="object" icon="gtk-apply"/>
|
||||
<button name="button_approve" states="to approve" string="Approved by Vendor" type="object" icon="gtk-ok"/>
|
||||
<button name="action_rfq_send" states="draft" string="Send RFQ by Email" type="object" context="{'send_rfq':True}" icon="gtk-network"/>
|
||||
<button name="button_cancel" states="draft,sent,to approve,purchase" string="Cancel Purchase Order" type="object" icon="fa-times"/>
|
||||
<button name="button_confirm" states="draft" string="Confirm Purchase Order" type="object" icon="fa-check"/>
|
||||
<button name="button_approve" states="to approve" string="Approved by Vendor" type="object" icon="fa-check-square-o"/>
|
||||
<button name="action_rfq_send" states="draft" string="Send RFQ by Email" type="object" context="{'send_rfq':True}" icon="fa-envelope-o"/>
|
||||
</tree>
|
||||
</field>
|
||||
<separator string="Terms and Conditions"/>
|
||||
@@ -225,7 +225,7 @@
|
||||
<field name="model">purchase.order.line</field>
|
||||
<field eval="1" name="priority"/>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Purchase Order Lines" create="false" decoration-info="state == 'confirmed'" decoration-muted="state == 'cancel'">
|
||||
<tree string="Purchase Order Lines" create="false" decoration-info="quantity_tendered>0">
|
||||
<field name="name"/>
|
||||
<field name="partner_id" string="Vendor"/>
|
||||
<field name="product_id"/>
|
||||
@@ -235,11 +235,11 @@
|
||||
<field name="product_uom" groups="product.group_uom"/>
|
||||
<field name="price_subtotal"/>
|
||||
<field name="order_id" invisible="1"/>
|
||||
<button name="unlink" type="object" string="Cancel Choice" icon="gtk-cancel"
|
||||
attrs="{'invisible': [('state', 'not in', ('draft', 'sent', 'to approve'))]}"/>
|
||||
<button name="%(action_bid_line_qty)d" type="action" states="draft" string="Change Quantity" icon="gtk-ok"
|
||||
attrs="{'invisible': [('state', 'not in', ('draft'))]}"/>
|
||||
<button name="button_confirm" states="draft" type="object" string="Confirm Order" icon="gtk-apply"/>
|
||||
<button name="button_cancel" type="object" string="Cancel Choice" icon="fa-times"
|
||||
attrs="{'invisible': [('quantity_tendered', '=', 0)]}"/>
|
||||
<button name="%(action_bid_line_qty)d" type="action" string="Change Quantity" icon="fa-plus-square-o"/>
|
||||
<button name="button_confirm" type="object" string="Confirm Order" icon="fa-check"
|
||||
attrs="{'invisible': [('quantity_tendered', '>', 0)]}"/>
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
@@ -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 = $("<button type='button' class='oe_button oe_highlight oe_generate_po'>Generate PO</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) {
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<templates>
|
||||
<t t-name="CompareListView.buttons">
|
||||
<div class="oe_list_buttons">
|
||||
<button type="button" class="btn btn-sm btn-primary oe_generate_po">
|
||||
Generate PO
|
||||
</button>
|
||||
</div>
|
||||
</t>
|
||||
</templates>
|
||||
Reference in New Issue
Block a user