Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions purchase_requisition_full_bid_order_generator/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
Purchase Requisition Full Bid Order Generator
=============================================

This module allows you to request a quotation for each supplier that has all
the products/services included in the bid. For that, the supplier must be
included in the "Suppliers" section of the "Procurement" tab of the products.


Credits
=======


Contributors
------------
* Esther Martín <esthermartin@avanzosc.es>
* Pedro M. Baeza <pedro.baeza@serviciosbaeza.com>
* Ana Juaristi <anajuaristi@avanzosc.es>
* Oihane Crucelaegui <oihanecrucelaegi@avanzosc.es>
6 changes: 6 additions & 0 deletions purchase_requisition_full_bid_order_generator/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# -*- coding: utf-8 -*-
##############################################################################
# For copyright and license notices, see __openerp__.py file in root directory
##############################################################################

from . import models
34 changes: 34 additions & 0 deletions purchase_requisition_full_bid_order_generator/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
{
"name": "Purchase Requisition Full Bid Order Generator",
"version": "1.0",
"author": "AvanzOSC, "
"Serv. Tecnol. Avanzados - Pedro M. Baeza",
"website": "www.avanzosc.es",
"category": "Purchase Management",
"contributors": ["Esther Martín <esthermartin@avanzosc.es>",
"Pedro M. Baeza <pedro.baeza@serviciosbaeza.com>",
"Ana Juaristi <anajuaristi@avanzosc.es>",
"Oihane Crucelaegui <oihanecrucelaegi@avanzosc.es>"],
"depends": ["base", "purchase", "purchase_requisition"],
"data": [
"views/bids_ext_view.xml",
"views/purchase_config_setting_view.xml",],
"installable": True
}
32 changes: 32 additions & 0 deletions purchase_requisition_full_bid_order_generator/i18n/es.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * purchase_requisition_full_bid_order_generator
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 8.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2015-07-09 14:10+0000\n"
"PO-Revision-Date: 2015-07-09 16:10+0100\n"
"Last-Translator: <>\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: \n"
"X-Generator: Poedit 1.5.4\n"

#. module: purchase_requisition_full_bid_order_generator
#: model:ir.model,name:purchase_requisition_full_bid_order_generator.model_purchase_requisition
msgid "Purchase Requisition"
msgstr "Solicitud de compra"

#. module: purchase_requisition_full_bid_order_generator
#: view:purchase.requisition:purchase_requisition_full_bid_order_generator.bids_ext_form_view
msgid "Request a Quotation"
msgstr "Solicitar un presupuesto"

#. module: purchase_requisition_full_bid_order_generator
#: view:purchase.requisition:purchase_requisition_full_bid_order_generator.bids_ext_form_view
msgid "Request a quotation to suppliers of all products"
msgstr "Solicitar un presupuesto a los proveedores de todos los productos"
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * purchase_requisition_full_bid_order_generator
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 8.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2015-07-09 14:09+0000\n"
"PO-Revision-Date: 2015-07-09 14:09+0000\n"
"Last-Translator: <>\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"

#. module: purchase_requisition_full_bid_order_generator
#: model:ir.model,name:purchase_requisition_full_bid_order_generator.model_purchase_requisition
msgid "Purchase Requisition"
msgstr ""

#. module: purchase_requisition_full_bid_order_generator
#: view:purchase.requisition:purchase_requisition_full_bid_order_generator.bids_ext_form_view
msgid "Request a Quotation"
msgstr ""

#. module: purchase_requisition_full_bid_order_generator
#: view:purchase.requisition:purchase_requisition_full_bid_order_generator.bids_ext_form_view
msgid "Request a quotation to suppliers of all products"
msgstr ""

33 changes: 33 additions & 0 deletions purchase_requisition_full_bid_order_generator/i18n/sl.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * purchase_requisition_full_bid_order_generator
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 8.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2015-07-09 14:09+0000\n"
"PO-Revision-Date: 2015-08-15 09:19+0200\n"
"Last-Translator: Matjaz Mozetic <m.mozetic@matmoz.si>\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: \n"
"Language: sl\n"
"X-Generator: Poedit 1.8.4\n"

#. module: purchase_requisition_full_bid_order_generator
#: model:ir.model,name:purchase_requisition_full_bid_order_generator.model_purchase_requisition
msgid "Purchase Requisition"
msgstr "Nabavni zahtevek"

#. module: purchase_requisition_full_bid_order_generator
#: view:purchase.requisition:purchase_requisition_full_bid_order_generator.bids_ext_form_view
msgid "Request a Quotation"
msgstr "Povpraševanje po predračunu"

#. module: purchase_requisition_full_bid_order_generator
#: view:purchase.requisition:purchase_requisition_full_bid_order_generator.bids_ext_form_view
msgid "Request a quotation to suppliers of all products"
msgstr "Povpraševanje po predračunu dobaviteljem vseh proizvodov"
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# -*- coding: utf-8 -*-
##############################################################################
# For copyright and license notices, see __openerp__.py file in root directory
##############################################################################

from . import bids
from . import purchase_config_setting
from . import res_company
82 changes: 82 additions & 0 deletions purchase_requisition_full_bid_order_generator/models/bids.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
# -*- coding: utf-8 -*-
##############################################################################
# For copyright and license notices, see __manifest__.py file in root directory
##############################################################################

from odoo import models, fields, api, _

class PurchaseRequisition(models.Model):
_inherit = 'purchase.requisition'

@api.multi
def prepare_requisition_purchase_order_line(self, line, product, product_qty, purchase_id, supplier):
date_order = self.ordering_date or fields.Datetime.now()
qty = self.env['product.uom'].browse(product.uom_id.id)._compute_quantity(product_qty, product.uom_po_id)
vals = {'product_id':product.id,
'product_qty':qty,
'order_id':purchase_id,
'product_uom':product.uom_po_id.id,
'price_unit':product.standard_price,
'name':product.name,
'date_planned':fields.Datetime.now(),
'taxes_id': [(6, 0, [x.id for x in product.supplier_taxes_id])],
}
line_id = self.env['purchase.order.line'].create(vals)
return line_id

@api.multi
def create_purchase_order(self):
# Create RFQ to all supplie rs with products they have from Requisition line
if self.company_id.rfq_to_suppliers == 's':
suppliers_dict = {}
for line in self.line_ids:
for supplier in line.product_id.seller_ids:
supplier_id = supplier.name.id
if supplier_id not in suppliers_dict.keys():
suppliers_dict[supplier_id] = [{line.product_id: line.product_qty}]
else:
if suppliers_dict[supplier_id][0].has_key(line.product_id):
suppliers_dict[supplier_id][0][line.product_id] = suppliers_dict[supplier_id][0][
line.product_id] + line.product_qty
else:
suppliers_dict[supplier_id].append({line.product_id: line.product_qty})

for supplier, product_list in suppliers_dict.iteritems():
res_partner = self.env['res.partner']
supplier = res_partner.browse(supplier)
# create purcahse order
purchase = self.make_purchase_order(supplier, requisition=False)
for product_dict in product_list:
for product, qty in product_dict.iteritems():
# create purchase order line
line = self.env['purchase.requisition.line'].search(
[('product_id', '=', product.id), ('requisition_id', '=', self.id)], limit=1)
p_line = self.prepare_requisition_purchase_order_line(line, product, qty, purchase.id, supplier)
# p_line.onchange_product_id()
else:
# Create RFQ to the supplier which has all the products
supplier_obj = self.env['res.partner']
supplierinfo_obj = self.env['product.supplierinfo']
# Start with all suppliers
suppliers = supplier_obj.search([('supplier', '=', True)])
for line in self.line_ids:
sinfos = supplierinfo_obj.search(
[('product_tmpl_id', '=', line.product_id.product_tmpl_id.id)])
suppliers &= sinfos.mapped('name')
# Stop condition to avoid the full loop if we don't have suppliers
if not suppliers:
break
for supplier in suppliers:
self.make_purchase_order(supplier, requisition=True)

@api.multi
def make_purchase_order(self, supplier, requisition):
vals = {
'partner_id':supplier.id,
'requisition_id':self.id,
}
purchase_order_id = self.env['purchase.order'].create(vals)
purchase_order_id.onchange_partner_id()
if requisition:
purchase_order_id._onchange_requisition_id()
return purchase_order_id
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# -*- coding: utf-8 -*-
##############################################################################
# For copyright and license notices, see __manifest__.py file in root directory
##############################################################################

from odoo import models, api, fields


class purchase_config_settings(models.TransientModel):
_inherit = 'purchase.config.settings'

rfq_to_suppliers = fields.Selection([('a', 'Create RFQ to only suppliers, with all the products'),
('s', 'Create RFQ to all the suppliers with available products')],
string='RFQ from Bids')

def get_default_rfq_to_suppliers(self, fields):
rfq_to_suppliers = self.env['ir.config_parameter'].get_param('rfq_to_suppliers', default=False)
return dict(rfq_to_suppliers=rfq_to_suppliers)

def set_default_rfq_to_suppliers(self):
self.env.user.company_id.write({'rfq_to_suppliers': self.rfq_to_suppliers})
self.env['ir.config_parameter'].set_param(
'rfq_to_suppliers', (self.rfq_to_suppliers), groups=['base.group_system'])
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# -*- coding: utf-8 -*-
##############################################################################
# For copyright and license notices, see __manifest__.py file in root directory
##############################################################################

from odoo import models, api, fields


class res_company(models.Model):
_inherit = 'res.company'

rfq_to_suppliers = fields.Selection([('a', 'To All Products'), ('s', 'To All Suppliers')], default='a',
required=True, string='RFQ from Bids')
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data>

<record id="bids_ext_form_view" model="ir.ui.view">
<field name="name">bids.ext.form.view</field>
<field name="model">purchase.requisition</field>
<field name="inherit_id" ref="purchase_requisition.view_purchase_requisition_form"/>
<field name="type">form</field>
<field name="arch" type="xml">
<xpath expr="//form/sheet/div[@name='button_box']/button[@class='oe_stat_button']" position="before">
<button name="create_purchase_order" type="object" string="Request Quotations"
class="btn-primary" style="margin-right: 10px;"
attrs="{'invisible': ['|', ('line_ids','=',[]),('state', 'in', ('draft' ,'open','done'))]}"/>
</xpath>
</field>
</record>

</data>
</odoo>
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>

<record id="view_purchase_configuration" model="ir.ui.view">
<field name="name">purchase settings</field>
<field name="model">purchase.config.settings</field>
<field name="inherit_id" ref="purchase.view_purchase_configuration"/>
<field name="arch" type="xml">
<xpath expr="//form/group[2]" position="after">
<separator string="Purchase Requisition"/>
<group>
<field name="rfq_to_suppliers" widget="radio"/>
</group>
</xpath>
</field>
</record>

</data>
</openerp>
26 changes: 26 additions & 0 deletions tko_purchase_supplier_min_purchase_value/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
# ThinkOpen Solutions Brasil
# Copyright (C) Thinkopen Solutions <http://www.tkobr.com>.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################

import purchase
import res_partner
Loading