diff --git a/purchase_requisition_full_bid_order_generator/README.rst b/purchase_requisition_full_bid_order_generator/README.rst new file mode 100644 index 0000000..347d4d8 --- /dev/null +++ b/purchase_requisition_full_bid_order_generator/README.rst @@ -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 +* Pedro M. Baeza +* Ana Juaristi +* Oihane Crucelaegui diff --git a/purchase_requisition_full_bid_order_generator/__init__.py b/purchase_requisition_full_bid_order_generator/__init__.py new file mode 100644 index 0000000..ad6c818 --- /dev/null +++ b/purchase_requisition_full_bid_order_generator/__init__.py @@ -0,0 +1,6 @@ +# -*- coding: utf-8 -*- +############################################################################## +# For copyright and license notices, see __openerp__.py file in root directory +############################################################################## + +from . import models diff --git a/purchase_requisition_full_bid_order_generator/__manifest__.py b/purchase_requisition_full_bid_order_generator/__manifest__.py new file mode 100644 index 0000000..f6d9406 --- /dev/null +++ b/purchase_requisition_full_bid_order_generator/__manifest__.py @@ -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 . +# +############################################################################## +{ + "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 ", + "Pedro M. Baeza ", + "Ana Juaristi ", + "Oihane Crucelaegui "], + "depends": ["base", "purchase", "purchase_requisition"], + "data": [ + "views/bids_ext_view.xml", + "views/purchase_config_setting_view.xml",], + "installable": True +} diff --git a/purchase_requisition_full_bid_order_generator/i18n/es.po b/purchase_requisition_full_bid_order_generator/i18n/es.po new file mode 100644 index 0000000..08afdd5 --- /dev/null +++ b/purchase_requisition_full_bid_order_generator/i18n/es.po @@ -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" diff --git a/purchase_requisition_full_bid_order_generator/i18n/purchase_requisition_full_bid_order_generator.pot b/purchase_requisition_full_bid_order_generator/i18n/purchase_requisition_full_bid_order_generator.pot new file mode 100644 index 0000000..1945640 --- /dev/null +++ b/purchase_requisition_full_bid_order_generator/i18n/purchase_requisition_full_bid_order_generator.pot @@ -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 "" + diff --git a/purchase_requisition_full_bid_order_generator/i18n/sl.po b/purchase_requisition_full_bid_order_generator/i18n/sl.po new file mode 100644 index 0000000..650ffa1 --- /dev/null +++ b/purchase_requisition_full_bid_order_generator/i18n/sl.po @@ -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 \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" diff --git a/purchase_requisition_full_bid_order_generator/models/__init__.py b/purchase_requisition_full_bid_order_generator/models/__init__.py new file mode 100644 index 0000000..4ae5b1e --- /dev/null +++ b/purchase_requisition_full_bid_order_generator/models/__init__.py @@ -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 diff --git a/purchase_requisition_full_bid_order_generator/models/bids.py b/purchase_requisition_full_bid_order_generator/models/bids.py new file mode 100644 index 0000000..38f2347 --- /dev/null +++ b/purchase_requisition_full_bid_order_generator/models/bids.py @@ -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 diff --git a/purchase_requisition_full_bid_order_generator/models/purchase_config_setting.py b/purchase_requisition_full_bid_order_generator/models/purchase_config_setting.py new file mode 100644 index 0000000..89abad5 --- /dev/null +++ b/purchase_requisition_full_bid_order_generator/models/purchase_config_setting.py @@ -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']) diff --git a/purchase_requisition_full_bid_order_generator/models/res_company.py b/purchase_requisition_full_bid_order_generator/models/res_company.py new file mode 100644 index 0000000..2807bc2 --- /dev/null +++ b/purchase_requisition_full_bid_order_generator/models/res_company.py @@ -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') diff --git a/purchase_requisition_full_bid_order_generator/views/bids_ext_view.xml b/purchase_requisition_full_bid_order_generator/views/bids_ext_view.xml new file mode 100644 index 0000000..3672309 --- /dev/null +++ b/purchase_requisition_full_bid_order_generator/views/bids_ext_view.xml @@ -0,0 +1,20 @@ + + + + + + bids.ext.form.view + purchase.requisition + + form + + + + + + + + diff --git a/tko_purchase_supplier_min_purchase_value/res_partner.py b/tko_purchase_supplier_min_purchase_value/res_partner.py new file mode 100644 index 0000000..c956cf7 --- /dev/null +++ b/tko_purchase_supplier_min_purchase_value/res_partner.py @@ -0,0 +1,32 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2004-2010 Tiny SPRL (). +# +# ThinkOpen Solutions Brasil +# Copyright (C) Thinkopen Solutions . +# +# 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 . +# +############################################################################## + +# from openerp.osv import osv, fields +from odoo import fields, api, models +from odoo.exceptions import Warning + +class ResPartner(models.Model): + _inherit = 'res.partner' + + min_purchase_value = fields.Float(string="Minimum Purchase Amount") \ No newline at end of file diff --git a/tko_purchase_supplier_min_purchase_value/res_partner_view.xml b/tko_purchase_supplier_min_purchase_value/res_partner_view.xml new file mode 100644 index 0000000..f6fbd44 --- /dev/null +++ b/tko_purchase_supplier_min_purchase_value/res_partner_view.xml @@ -0,0 +1,16 @@ + + + + + res.partner + res.partner + + + + + + + + + + diff --git a/tko_purchase_supplier_min_purchase_value/static/description/icon.png b/tko_purchase_supplier_min_purchase_value/static/description/icon.png new file mode 100644 index 0000000..7da98fe Binary files /dev/null and b/tko_purchase_supplier_min_purchase_value/static/description/icon.png differ