From f0cb9e9cbcdd3feeca7ced9a6a590d86428d2682 Mon Sep 17 00:00:00 2001 From: Your Name Date: Mon, 21 Aug 2017 23:03:48 +0530 Subject: [PATCH 1/5] Add Migrated module in v10 tko-purchase --- .../__init__.py | 26 +++++++++ .../__manifest__.py | 51 ++++++++++++++++++ .../purchase.py | 44 +++++++++++++++ .../purchase_view.xml | 21 ++++++++ .../res_partner.py | 32 +++++++++++ .../res_partner_view.xml | 16 ++++++ .../static/description/icon.png | Bin 0 -> 2293 bytes 7 files changed, 190 insertions(+) create mode 100644 tko_purchase_supplier_min_purchase_value/__init__.py create mode 100644 tko_purchase_supplier_min_purchase_value/__manifest__.py create mode 100644 tko_purchase_supplier_min_purchase_value/purchase.py create mode 100644 tko_purchase_supplier_min_purchase_value/purchase_view.xml create mode 100644 tko_purchase_supplier_min_purchase_value/res_partner.py create mode 100644 tko_purchase_supplier_min_purchase_value/res_partner_view.xml create mode 100644 tko_purchase_supplier_min_purchase_value/static/description/icon.png diff --git a/tko_purchase_supplier_min_purchase_value/__init__.py b/tko_purchase_supplier_min_purchase_value/__init__.py new file mode 100644 index 0000000..5492d97 --- /dev/null +++ b/tko_purchase_supplier_min_purchase_value/__init__.py @@ -0,0 +1,26 @@ +# -*- 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 . +# +############################################################################## + +import purchase +import res_partner diff --git a/tko_purchase_supplier_min_purchase_value/__manifest__.py b/tko_purchase_supplier_min_purchase_value/__manifest__.py new file mode 100644 index 0000000..92ae11c --- /dev/null +++ b/tko_purchase_supplier_min_purchase_value/__manifest__.py @@ -0,0 +1,51 @@ +# -*- 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 . +# +############################################################################## + +{ + 'name': 'tko_purchase_supplier_min_purchase_value', + 'category': 'Customization', + 'sequence': 10, + 'complexity': 'normal', + 'description': '''tko_purchase_supplier_min_purchase_value''', + 'author': 'ThinkOpen Solutions Brasil', + 'license': 'AGPL-3', + 'website': 'http://www.tkobr.com', + 'depends': [ + 'purchase', + ], + 'data': [ + 'purchase_view.xml', + 'res_partner_view.xml', + ], + 'init': [], + 'demo': [], + 'update': [], + 'test': [], # YAML files with tests + 'installable': True, + 'application': False, + # If it's True, the modules will be auto-installed when all dependencies + # are installed + 'auto_install': False, + 'certificate': '', +} diff --git a/tko_purchase_supplier_min_purchase_value/purchase.py b/tko_purchase_supplier_min_purchase_value/purchase.py new file mode 100644 index 0000000..24938ae --- /dev/null +++ b/tko_purchase_supplier_min_purchase_value/purchase.py @@ -0,0 +1,44 @@ +# -*- 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 PurchaseOrder(models.Model): + _inherit = "purchase.order" + + @api.one + @api.depends('partner_id', 'order_line.product_id', 'order_line.product_qty', 'order_line.price_unit', 'order_line') + def get_valid_order(self): + self.valid_order = False + context = self._context + if self.partner_id.min_purchase_value <= self.amount_total: + self.valid_order = True + else: + if context.get('warn', False): + raise Warning(u'Order total is less than allowed for supplier!') + + valid_order = fields.Boolean(compute=get_valid_order, string="Is Visible", default=False) diff --git a/tko_purchase_supplier_min_purchase_value/purchase_view.xml b/tko_purchase_supplier_min_purchase_value/purchase_view.xml new file mode 100644 index 0000000..c630426 --- /dev/null +++ b/tko_purchase_supplier_min_purchase_value/purchase_view.xml @@ -0,0 +1,21 @@ + + + + + purchase.order.form + purchase.order + + + + + + + + + + + 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 0000000000000000000000000000000000000000..7da98fe5f30817b2528b8a62eb5bb33acc244779 GIT binary patch literal 2293 zcmVzgCfUW}EjF7?jtMlR?k4MT>fG0IzevmDS?1Lg%fYj{J%K(=qyH-YHLt{o*57WL>B8MHd`YWoAf&=1>Qb3BbCL!?NOLw67$AyW`tW#I$))h23fZ>`Z(r5(+3F_&#%=SuWOq2!^9R1}6gy zM}71LAp#TRlQv<1V|da>@2H2saBcHhuVMhe^mc~n zWRBUx9J9Lx{{Gj0Y?$I%3DY#%_|i-FeisNg1O@@)`Nz-j{C7V+D7!Xc000<0ImYP8 zasK)F*B7|Fc#R-nHM`?|oUFUbv?F9{j?MNLA_5Z`3`c!*bv=4_wC$hDA(QuwHgG0F zR!rTM^prfl04561Kk9V`z>l7u0@r$pkbebZHjjSCdX@ppD&@2^dOB+bJEL_lxPW z)Bcw8l{&A?Bv?bqE_Lm{ZTp6-@2r;Z1c2G9Qj+3Kc5;F6v7t>MhzRj2#$whT3nth1 zHAGSIZy(t{!HyQKfIu5LY&My92EfhbEvSM5#`XvTsoY2`mAlUSUCu`XHeSV;JuEr{ z;PtmRl_p^9yj2n@hy@xD+T=w9Nt|qi2PX7~5rS|dbQDx%5iF)l#OoN#*$Q!-U@=|d z`sEl;KRDaSS~=qm$ofPe0xaiCy!n1o>D-N-v{M=|Ga!ilY_Nd{4CD8I`VHRu;0cTg z5cNZ_VT3(Xq#td(auN&H%QcpZ6|P^7asJf>&cC_aKa3ht zwl@edIPPtf8z&*F+Sm7ikUMQ(=IQkTrP9r6&~cK5K_-Hu(V%fkOUxkVQWmQHElnVO zlPEyd-D~AiW>TeMN^xsB1L9CkFY1T&_xP3f>^R!0``ypjpQ0)94xzAj2LMST7@RcM z^@%oSuuong9`%V7Q5F>ysb3NkKLd!ZNWm@Ev(o%_S8wpia2mARgb~)-T-HF0IyAi*<8fnC9(mmfCfq4JZr%>8rNERuKddMMNg&<&U z)5>wZTI2rB6c4wvouzkMI;5Kxdl?{!;MaeAj*mY11$u)B(I7%#Hv4Rp(ta^pVzpS~ zn=k&2zkU8C9{+fR;YlARG6;JHVPr~_PU0l52&a=7?#EM1uI{}uTqmpV7DE~fk~qPK zA3ww6_fA#Qj|L&4!6pTM`uq&%UteH$H?N)86r3Ivvp7;x+qO)ibUwlD%#NE!kB0Sg zc}p(K-K*z>gjjo3?n;-6Er$(l08yv~v;)LBI_bfqopC%)$|V$UaAF%20}#^NlbZh<&)=qDpXrQw6Zz6oUfV%X0aw|m2BPvS04Y+8USvY z+Io&piuT}$u#)H|;rfI_7p)9HiLO+8+p2agARZvFHHln?vsTzQ`8I&q?hZQ+ivWE8 z;;L37w^w)j>DcNoCKUC_aguH{(46GHmnk?GYcy;a|NQbCFaPrjM1-(saQtYPi^X{~)yb)yWO=T`N}fLB&b#8!nBS13*ARxVgN=>;K+B1mJ*RLX!`2 zm7eeh5lk3>18$bXi$~3X;}jFWGF?^7?Yhr+x4W3YU~r#RaV_i__>!o`4$@Q479@J! zz4Gpkb`@yGeW;L$u~iW&N5)&N+C&lfT!|i}?o;eCjjD07>t#zD3`CW`f$?RL2LT~| ze_`hh_M-X1=B_Bgs%EAgD`E2fs7GT@s|ma4=8{YFiGLH9oEpUig58_76CouNAsvL) z+2Dx|rJBO(TRop#p?Mg1L_;5<`Ms!4S6u*G13@Y3ZQr12i@t(NM9PPx?7{nxEg>p? zztGzGBJC$}o-A?~BMPFZYVV5O_(Dycc Date: Thu, 24 Aug 2017 23:29:15 +0530 Subject: [PATCH 2/5] Add Module to branch --- .../README.rst | 18 +++++ .../__init__.py | 6 ++ .../__manifest__.py | 34 ++++++++ .../i18n/es.po | 32 ++++++++ ...e_requisition_full_bid_order_generator.pot | 32 ++++++++ .../i18n/sl.po | 33 ++++++++ .../models/__init__.py | 8 ++ .../models/bids.py | 81 +++++++++++++++++++ .../models/purchase_config_setting.py | 23 ++++++ .../models/res_company.py | 13 +++ .../views/bids_ext_view.xml | 20 +++++ .../views/purchase_config_setting_view.xml | 20 +++++ 12 files changed, 320 insertions(+) create mode 100644 purchase_requisition_full_bid_order_generator/README.rst create mode 100644 purchase_requisition_full_bid_order_generator/__init__.py create mode 100644 purchase_requisition_full_bid_order_generator/__manifest__.py create mode 100644 purchase_requisition_full_bid_order_generator/i18n/es.po create mode 100644 purchase_requisition_full_bid_order_generator/i18n/purchase_requisition_full_bid_order_generator.pot create mode 100644 purchase_requisition_full_bid_order_generator/i18n/sl.po create mode 100644 purchase_requisition_full_bid_order_generator/models/__init__.py create mode 100644 purchase_requisition_full_bid_order_generator/models/bids.py create mode 100644 purchase_requisition_full_bid_order_generator/models/purchase_config_setting.py create mode 100644 purchase_requisition_full_bid_order_generator/models/res_company.py create mode 100644 purchase_requisition_full_bid_order_generator/views/bids_ext_view.xml create mode 100644 purchase_requisition_full_bid_order_generator/views/purchase_config_setting_view.xml 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..d04005a --- /dev/null +++ b/purchase_requisition_full_bid_order_generator/models/bids.py @@ -0,0 +1,81 @@ +# -*- 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() + } + 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 \ No newline at end of file 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 + + +