Remove procurement_suggest* modules
This commit is contained in:
@@ -1,24 +0,0 @@
|
||||
# -*- encoding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# Procurement Suggest module for Odoo
|
||||
# Copyright (C) 2015 Akretion (http://www.akretion.com)
|
||||
# @author Alexis de Lattre <alexis.delattre@akretion.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/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
from . import stock
|
||||
from . import wizard
|
||||
@@ -1,46 +0,0 @@
|
||||
# -*- encoding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# Procurement Suggest module for Odoo
|
||||
# Copyright (C) 2015 Akretion (http://www.akretion.com)
|
||||
# @author Alexis de Lattre <alexis.delattre@akretion.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/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
|
||||
{
|
||||
'name': 'Procurement Suggest',
|
||||
'version': '0.1',
|
||||
'category': 'Procurements',
|
||||
'license': 'AGPL-3',
|
||||
'summary': 'Suggest POs/MOs from special suggest orderpoints',
|
||||
'description': """
|
||||
Procurement Suggest
|
||||
===================
|
||||
|
||||
TODO
|
||||
|
||||
This module has been written by Alexis de Lattre from Akretion <alexis.delattre@akretion.com>.
|
||||
""",
|
||||
'author': 'Akretion',
|
||||
'website': 'http://www.akretion.com',
|
||||
'depends': ['stock'],
|
||||
'data': [
|
||||
'stock_view.xml',
|
||||
'wizard/procurement_suggest_view.xml',
|
||||
],
|
||||
'installable': False,
|
||||
}
|
||||
@@ -1,212 +0,0 @@
|
||||
# Translation of Odoo Server.
|
||||
# This file contains the translation of the following modules:
|
||||
# * procurement_suggest
|
||||
#
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Odoo Server 8.0\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2015-12-07 15:19+0000\n"
|
||||
"PO-Revision-Date: 2015-12-07 15:19+0000\n"
|
||||
"Last-Translator: 2015-12-08\n"
|
||||
"Language-Team: EL HADJ MIMOUNE Mourad <mourad.elhadj.mimoune@akretion.com> \n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: \n"
|
||||
"Plural-Forms: \n"
|
||||
|
||||
#. module: procurement_suggest
|
||||
#: code:addons/procurement_suggest/wizard/procurement_suggest.py:195
|
||||
#: code:addons/procurement_suggest/wizard/procurement_suggest.py:196
|
||||
#, python-format
|
||||
msgid " Suggest"
|
||||
msgstr " Suggerer"
|
||||
|
||||
#. module: procurement_suggest
|
||||
#: code:addons/procurement_suggest/wizard/procurement_suggest.py:202
|
||||
#, python-format
|
||||
msgid "All requested quantities are null."
|
||||
msgstr "Toutes les quantités recherchées sont null."
|
||||
|
||||
#. module: procurement_suggest
|
||||
#: view:procurement.create.from.suggest:procurement_suggest.procurement_create_from_suggest_form
|
||||
#: view:procurement.suggest.generate:procurement_suggest.procurement_suggest_generate_form
|
||||
msgid "Cancel"
|
||||
msgstr "Annuler"
|
||||
|
||||
#. module: procurement_suggest
|
||||
#: model:ir.actions.act_window,name:procurement_suggest.procurement_create_from_suggest_action
|
||||
#: view:procurement.create.from.suggest:procurement_suggest.procurement_create_from_suggest_form
|
||||
msgid "Create Procurements"
|
||||
msgstr "Créer un réappro"
|
||||
|
||||
#. module: procurement_suggest
|
||||
#: model:ir.model,name:procurement_suggest.model_procurement_create_from_suggest
|
||||
msgid "Create Procurements from Procurement Suggestions"
|
||||
msgstr "Créer un réappro à partir de Suggestions de réappro"
|
||||
|
||||
#. module: procurement_suggest
|
||||
#: view:procurement.create.from.suggest:procurement_suggest.procurement_create_from_suggest_form
|
||||
msgid "Create Purchase Orders"
|
||||
msgstr "Créer une commande d'achat"
|
||||
|
||||
#. module: procurement_suggest
|
||||
#: field:procurement.create.from.suggest,create_uid:0
|
||||
#: field:procurement.suggest,create_uid:0
|
||||
#: field:procurement.suggest.generate,create_uid:0
|
||||
msgid "Created by"
|
||||
msgstr "Créé par"
|
||||
|
||||
#. module: procurement_suggest
|
||||
#: field:procurement.create.from.suggest,create_date:0
|
||||
#: field:procurement.suggest,create_date:0
|
||||
#: field:procurement.suggest.generate,create_date:0
|
||||
msgid "Created on"
|
||||
msgstr "Créé le"
|
||||
|
||||
#. module: procurement_suggest
|
||||
#: field:procurement.suggest,procurement_qty:0
|
||||
msgid "Current Procurement Quantity"
|
||||
msgstr "Qté réappro courrante"
|
||||
|
||||
#. module: procurement_suggest
|
||||
#: view:procurement.suggest.generate:procurement_suggest.procurement_suggest_generate_form
|
||||
msgid "Generate"
|
||||
msgstr "Générer"
|
||||
|
||||
#. module: procurement_suggest
|
||||
#: view:procurement.suggest.generate:procurement_suggest.procurement_suggest_generate_form
|
||||
msgid "Generate Procurement Suggestions"
|
||||
msgstr "Générer des Suggestions de réappro"
|
||||
|
||||
#. module: procurement_suggest
|
||||
#: view:procurement.suggest:procurement_suggest.procurement_suggest_search
|
||||
msgid "Group By"
|
||||
msgstr "Grouper par"
|
||||
|
||||
#. module: procurement_suggest
|
||||
#: field:procurement.create.from.suggest,id:0
|
||||
#: field:procurement.suggest,id:0
|
||||
#: field:procurement.suggest.generate,id:0
|
||||
msgid "ID"
|
||||
msgstr "ID"
|
||||
|
||||
#. module: procurement_suggest
|
||||
#: field:procurement.suggest,incoming_qty:0
|
||||
msgid "Incoming Quantity"
|
||||
msgstr "Qté Entrante"
|
||||
|
||||
#. module: procurement_suggest
|
||||
#: field:procurement.create.from.suggest,write_uid:0
|
||||
#: field:procurement.suggest,write_uid:0
|
||||
#: field:procurement.suggest.generate,write_uid:0
|
||||
msgid "Last Updated by"
|
||||
msgstr "Dernière MAJ par"
|
||||
|
||||
#. module: procurement_suggest
|
||||
#: field:procurement.create.from.suggest,write_date:0
|
||||
#: field:procurement.suggest,write_date:0
|
||||
#: field:procurement.suggest.generate,write_date:0
|
||||
msgid "Last Updated on"
|
||||
msgstr "Dernière MAJ le"
|
||||
|
||||
#. module: procurement_suggest
|
||||
#: model:ir.model,name:procurement_suggest.model_stock_warehouse_orderpoint
|
||||
msgid "Minimum Inventory Rule"
|
||||
msgstr "Règle de stock minimum"
|
||||
|
||||
#. module: procurement_suggest
|
||||
#: field:procurement.suggest,new_procurement_qty:0
|
||||
msgid "New Procurement Quantity"
|
||||
msgstr "Qté à acheter"
|
||||
|
||||
#. module: procurement_suggest
|
||||
#: field:procurement.suggest,outgoing_qty:0
|
||||
msgid "Outgoing Quantity"
|
||||
msgstr "Qté sortante"
|
||||
|
||||
#. module: procurement_suggest
|
||||
#: model:ir.actions.act_window,name:procurement_suggest.procurement_suggest_action
|
||||
#: model:ir.actions.act_window,name:procurement_suggest.procurement_suggest_generate_action
|
||||
#: model:ir.model,name:procurement_suggest.model_procurement_suggest
|
||||
#: model:ir.ui.menu,name:procurement_suggest.procurement_suggest_generate_menu
|
||||
#: view:procurement.suggest:procurement_suggest.procurement_suggest_search
|
||||
#: view:procurement.suggest:procurement_suggest.procurement_suggest_tree
|
||||
msgid "Procurement Suggestions"
|
||||
msgstr "Suggestions"
|
||||
|
||||
#. module: procurement_suggest
|
||||
#: field:procurement.suggest,product_id:0
|
||||
msgid "Product"
|
||||
msgstr "Article"
|
||||
|
||||
#. module: procurement_suggest
|
||||
#: field:procurement.suggest.generate,categ_id:0
|
||||
msgid "Product Category"
|
||||
msgstr "Catégorie article"
|
||||
|
||||
#. module: procurement_suggest
|
||||
#: field:procurement.suggest,qty_available:0
|
||||
msgid "Quantity On Hand"
|
||||
msgstr "Quantité en stock"
|
||||
|
||||
#. module: procurement_suggest
|
||||
#: field:procurement.suggest,orderpoint_id:0
|
||||
msgid "Re-ordering Rule"
|
||||
msgstr "Règle de réassort"
|
||||
|
||||
#. module: procurement_suggest
|
||||
#: view:stock.warehouse.orderpoint:procurement_suggest.warehouse_orderpoint_search
|
||||
msgid "Real"
|
||||
msgstr "Réel"
|
||||
|
||||
#. module: procurement_suggest
|
||||
#: view:procurement.suggest:procurement_suggest.procurement_suggest_search
|
||||
msgid "Seller"
|
||||
msgstr "Fournisseur"
|
||||
|
||||
#. module: procurement_suggest
|
||||
#: model:ir.model,name:procurement_suggest.model_procurement_suggest_generate
|
||||
msgid "Start to generate the procurement suggestions"
|
||||
msgstr "Début de génération des suggestion de réappro"
|
||||
|
||||
#. module: procurement_suggest
|
||||
#: field:procurement.suggest.generate,location_id:0
|
||||
msgid "Stock Location"
|
||||
msgstr "Emplacement de stock"
|
||||
|
||||
#. module: procurement_suggest
|
||||
#: view:stock.warehouse.orderpoint:procurement_suggest.warehouse_orderpoint_search
|
||||
#: field:stock.warehouse.orderpoint,suggest:0
|
||||
msgid "Suggest"
|
||||
msgstr "Suggerer"
|
||||
|
||||
#. module: procurement_suggest
|
||||
#: field:procurement.suggest,seller_id:0
|
||||
#: field:procurement.suggest.generate,seller_id:0
|
||||
msgid "Supplier"
|
||||
msgstr "Fournisseur"
|
||||
|
||||
#. module: procurement_suggest
|
||||
#: code:addons/procurement_suggest/wizard/procurement_suggest.py:138
|
||||
#, python-format
|
||||
msgid "The virtual stock for all related products is above the minimum stock level."
|
||||
msgstr "Le stock virtuel des produits est au dessus de stock min."
|
||||
|
||||
#. module: procurement_suggest
|
||||
#: code:addons/procurement_suggest/wizard/procurement_suggest.py:102
|
||||
#, python-format
|
||||
msgid "There are 2 orderpoints (%s and %s) for the same product on stock location %s or its children."
|
||||
msgstr "Il y a 2 règle de stock min (%s and %s) pour le même article et le même dépot %s."
|
||||
|
||||
#. module: procurement_suggest
|
||||
#: view:procurement.create.from.suggest:procurement_suggest.procurement_create_from_suggest_form
|
||||
msgid "This wizard will create procurements and confirm them, so that it creates purchase orders or manufacturing orders."
|
||||
msgstr "Ce wizard créra des réapprot et les confirme. Ces réappro crééron des commandes d'achat ou des ordres de fabrication en fonction des articles."
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
diff --git a/addons/stock/procurement.py b/addons/stock/procurement.py
|
||||
index 7b067ed..98857e6 100644
|
||||
--- a/addons/stock/procurement.py
|
||||
+++ b/addons/stock/procurement.py
|
||||
@@ -342,6 +342,7 @@ class procurement_order(osv.osv):
|
||||
|
||||
procurement_obj = self.pool.get('procurement.order')
|
||||
dom = company_id and [('company_id', '=', company_id)] or []
|
||||
+ dom.append(('suggest', '=', False))
|
||||
orderpoint_ids = orderpoint_obj.search(cr, uid, dom)
|
||||
prev_ids = []
|
||||
while orderpoint_ids:
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 6.5 KiB |
@@ -1,29 +0,0 @@
|
||||
# -*- encoding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# Procurement Suggest module for Odoo
|
||||
# Copyright (C) 2015 Akretion (http://www.akretion.com)
|
||||
# @author Alexis de Lattre <alexis.delattre@akretion.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/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
from openerp import models, fields
|
||||
|
||||
|
||||
class StockWarehouseOrderpoint(models.Model):
|
||||
_inherit = 'stock.warehouse.orderpoint'
|
||||
|
||||
suggest = fields.Boolean(string='Suggest', default=True)
|
||||
@@ -1,48 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<!--
|
||||
Copyright (C) 2015 Akretion (http://www.akretion.com/)
|
||||
@author Alexis de Lattre <alexis.delattre@akretion.com>
|
||||
The licence is in the file __openerp__.py
|
||||
-->
|
||||
|
||||
<openerp>
|
||||
<data>
|
||||
|
||||
<record id="view_warehouse_orderpoint_form" model="ir.ui.view">
|
||||
<field name="name">procurement_suggest.orderpoint.form</field>
|
||||
<field name="model">stock.warehouse.orderpoint</field>
|
||||
<field name="inherit_id" ref="stock.view_warehouse_orderpoint_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<field name="product_min_qty" position="before">
|
||||
<field name="suggest"/>
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="view_warehouse_orderpoint_tree" model="ir.ui.view">
|
||||
<field name="name">procurement_suggest.orderpoint.tree</field>
|
||||
<field name="model">stock.warehouse.orderpoint</field>
|
||||
<field name="inherit_id" ref="stock.view_warehouse_orderpoint_tree"/>
|
||||
<field name="arch" type="xml">
|
||||
<field name="product_min_qty" position="before">
|
||||
<field name="suggest"/>
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="warehouse_orderpoint_search" model="ir.ui.view">
|
||||
<field name="name">procurement_suggest.orderpoint.search</field>
|
||||
<field name="model">stock.warehouse.orderpoint</field>
|
||||
<field name="inherit_id" ref="stock.warehouse_orderpoint_search"/>
|
||||
<field name="arch" type="xml">
|
||||
<field name="product_id" position="after">
|
||||
<filter name="real" string="Real" domain="[('suggest', '=', False)]"/>
|
||||
<filter name="suggest" string="Suggest" domain="[('suggest', '=', True)]"/>
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
@@ -1,23 +0,0 @@
|
||||
# -*- encoding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# Procurement Suggest module for Odoo
|
||||
# Copyright (C) 2015 Akretion (http://www.akretion.com)
|
||||
# @author Alexis de Lattre <alexis.delattre@akretion.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/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
from . import procurement_suggest
|
||||
@@ -1,204 +0,0 @@
|
||||
# -*- encoding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# Procurement Suggest module for Odoo
|
||||
# Copyright (C) 2015 Akretion (http://www.akretion.com)
|
||||
# @author Alexis de Lattre <alexis.delattre@akretion.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/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
from openerp import models, fields, api, _
|
||||
import openerp.addons.decimal_precision as dp
|
||||
from openerp.exceptions import Warning
|
||||
from openerp.tools import float_compare
|
||||
import logging
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class ProcurementSuggestionGenerate(models.TransientModel):
|
||||
_name = 'procurement.suggest.generate'
|
||||
_description = 'Start to generate the procurement suggestions'
|
||||
|
||||
categ_id = fields.Many2one(
|
||||
'product.category', string='Product Category')
|
||||
seller_id = fields.Many2one(
|
||||
'res.partner', string='Supplier',
|
||||
domain=[('supplier', '=', True), ('is_company', '=', True)])
|
||||
location_id = fields.Many2one(
|
||||
'stock.location', string='Stock Location', required=True,
|
||||
default=lambda self: self.env.ref('stock.stock_location_stock'))
|
||||
|
||||
@api.model
|
||||
def _compute_procurement_qty(self, orderpoint):
|
||||
procs = self.env['procurement.order'].search([
|
||||
('state', 'not in', ('cancel', 'done', 'exception')),
|
||||
('orderpoint_id', '=', orderpoint.id)])
|
||||
puo = self.env['product.uom']
|
||||
proc_qty = 0
|
||||
for proc in procs:
|
||||
proc_qty += puo._compute_qty_obj(
|
||||
proc.product_uom, proc.product_qty, proc.product_id.uom_id)
|
||||
# Only take into account the qty that is not already
|
||||
# in the incoming qty or qty on hand
|
||||
for move in proc.move_ids:
|
||||
if move.state == 'draft':
|
||||
proc_qty -= move.product_qty
|
||||
return proc_qty
|
||||
|
||||
@api.model
|
||||
def _prepare_suggest_line(self, orderpoint):
|
||||
sline = {
|
||||
'product_id': orderpoint.product_id.id,
|
||||
'seller_id': orderpoint.product_id.seller_id.id or False,
|
||||
'qty_available': orderpoint.product_id.qty_available,
|
||||
'incoming_qty': orderpoint.product_id.incoming_qty,
|
||||
'outgoing_qty': orderpoint.product_id.outgoing_qty,
|
||||
'procurement_qty': self._compute_procurement_qty(orderpoint),
|
||||
'orderpoint_id': orderpoint.id,
|
||||
}
|
||||
return sline
|
||||
|
||||
@api.multi
|
||||
def run(self):
|
||||
pso = self.env['procurement.suggest']
|
||||
poo = self.env['procurement.order']
|
||||
swoo = self.env['stock.warehouse.orderpoint']
|
||||
op_domain = [
|
||||
('suggest', '=', True),
|
||||
('company_id', '=', self.env.user.company_id.id),
|
||||
('location_id', 'child_of', self.location_id.id),
|
||||
]
|
||||
if self.categ_id or self.seller_id:
|
||||
product_domain = []
|
||||
if self.categ_id:
|
||||
product_domain.append(
|
||||
('categ_id', 'child_of', self.categ_id.id))
|
||||
if self.seller_id:
|
||||
product_domain.append(
|
||||
('seller_id', '=', self.seller_id.id))
|
||||
products = self.env['product.product'].search(product_domain)
|
||||
op_domain.append(('product_id', 'in', products.ids))
|
||||
ops = swoo.search(op_domain)
|
||||
p_suggest_lines = []
|
||||
lines = {} # key = product_id ; value = {'min_qty', ...}
|
||||
for op in ops:
|
||||
if op.product_id.id in lines:
|
||||
raise Warning(
|
||||
_("There are 2 orderpoints (%s and %s) for the same "
|
||||
"product on stock location %s or its "
|
||||
"children.") % (
|
||||
lines[op.product_id.id]['orderpoint'].name,
|
||||
op.name,
|
||||
self.location_id.complete_name))
|
||||
|
||||
virtual_qty = poo._product_virtual_get(op)
|
||||
proc_qty = self._compute_procurement_qty(op)
|
||||
product_qty = virtual_qty + proc_qty
|
||||
logger.debug(
|
||||
'Product: %s Virtual qty = %s Cur. proc. qty = %s '
|
||||
'Min. qty = %s',
|
||||
op.product_id.name, virtual_qty, proc_qty, op.product_min_qty)
|
||||
if float_compare(
|
||||
product_qty, op.product_min_qty,
|
||||
precision_rounding=op.product_uom.rounding) < 0:
|
||||
logger.debug(
|
||||
'Create a procurement suggestion for %s',
|
||||
op.product_id.name)
|
||||
p_suggest_lines.append(self._prepare_suggest_line(op))
|
||||
p_suggest_lines_sorted = sorted(
|
||||
p_suggest_lines, key=lambda to_sort: to_sort['seller_id'])
|
||||
if p_suggest_lines_sorted:
|
||||
p_suggest_ids = []
|
||||
for p_suggest_line in p_suggest_lines_sorted:
|
||||
p_suggest = pso.create(p_suggest_line)
|
||||
p_suggest_ids.append(p_suggest.id)
|
||||
action = self.env['ir.actions.act_window'].for_xml_id(
|
||||
'procurement_suggest', 'procurement_suggest_action')
|
||||
action.update({
|
||||
'target': 'current',
|
||||
'domain': [('id', 'in', p_suggest_ids)],
|
||||
})
|
||||
return action
|
||||
else:
|
||||
raise Warning(_(
|
||||
"The virtual stock for all related products is above the "
|
||||
"minimum stock level."))
|
||||
|
||||
|
||||
class ProcurementSuggest(models.TransientModel):
|
||||
_name = 'procurement.suggest'
|
||||
_description = 'Procurement Suggestions'
|
||||
_rec_name = 'product_id'
|
||||
|
||||
product_id = fields.Many2one(
|
||||
'product.product', string='Product', required=True, readonly=True)
|
||||
seller_id = fields.Many2one(
|
||||
'res.partner', string='Supplier', readonly=True)
|
||||
qty_available = fields.Float(
|
||||
string='Quantity On Hand', readonly=True,
|
||||
digits=dp.get_precision('Product Unit of Measure'))
|
||||
incoming_qty = fields.Float(
|
||||
string='Incoming Quantity', readonly=True,
|
||||
digits=dp.get_precision('Product Unit of Measure'))
|
||||
procurement_qty = fields.Float(
|
||||
string='Current Procurement Quantity', readonly=True,
|
||||
digits=dp.get_precision('Product Unit of Measure'))
|
||||
outgoing_qty = fields.Float(
|
||||
string='Outgoing Quantity', readonly=True,
|
||||
digits=dp.get_precision('Product Unit of Measure'))
|
||||
orderpoint_id = fields.Many2one(
|
||||
'stock.warehouse.orderpoint', string='Re-ordering Rule',
|
||||
readonly=True)
|
||||
uom_id = fields.Many2one(
|
||||
'product.uom', related='product_id.uom_id', readonly=True)
|
||||
# on orderpoids, uom_id is a related field of product_id.uom_id
|
||||
# so I do the same here
|
||||
min_qty = fields.Float(
|
||||
string="Min Quantity", readonly=True,
|
||||
related='orderpoint_id.product_min_qty',
|
||||
digits=dp.get_precision('Product Unit of Measure'))
|
||||
new_procurement_qty = fields.Float(
|
||||
string='New Procurement Quantity',
|
||||
digits=dp.get_precision('Product Unit of Measure'))
|
||||
|
||||
|
||||
class ProcurementCreateFromSuggest(models.TransientModel):
|
||||
_name = 'procurement.create.from.suggest'
|
||||
_description = 'Create Procurements from Procurement Suggestions'
|
||||
|
||||
@api.multi
|
||||
def create_proc(self):
|
||||
self.ensure_one()
|
||||
psuggest_ids = self.env.context.get('active_ids')
|
||||
poo = self.env['procurement.order']
|
||||
new_procs = poo.browse(False)
|
||||
for line in self.env['procurement.suggest'].browse(psuggest_ids):
|
||||
if line.new_procurement_qty:
|
||||
vals = poo._prepare_orderpoint_procurement(
|
||||
line.orderpoint_id, line.new_procurement_qty)
|
||||
vals['origin'] += _(' Suggest')
|
||||
vals['name'] += _(' Suggest')
|
||||
new_procs += poo.create(vals)
|
||||
if new_procs:
|
||||
new_procs.signal_workflow('button_confirm')
|
||||
new_procs.run()
|
||||
else:
|
||||
raise Warning(_('All requested quantities are null.'))
|
||||
action = self.env['ir.actions.act_window'].for_xml_id(
|
||||
'procurement', 'procurement_action')
|
||||
action['domain'] = [('id', 'in', new_procs.ids)]
|
||||
return action
|
||||
@@ -1,110 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<!--
|
||||
Copyright (C) 2015 Akretion (http://www.akretion.com/)
|
||||
@author Alexis de Lattre <alexis.delattre@akretion.com>
|
||||
The licence is in the file __openerp__.py
|
||||
-->
|
||||
|
||||
<openerp>
|
||||
<data>
|
||||
|
||||
<record id="procurement_suggest_generate_form" model="ir.ui.view">
|
||||
<field name="name">procurement_suggest_generate.form</field>
|
||||
<field name="model">procurement.suggest.generate</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Generate Procurement Suggestions">
|
||||
<group name="name">
|
||||
<field name="categ_id"/>
|
||||
<field name="seller_id"/>
|
||||
<field name="location_id"/>
|
||||
</group>
|
||||
<footer>
|
||||
<button type="object" name="run" string="Generate" class="oe_highlight"/>
|
||||
<button special="cancel" string="Cancel" class="oe_link"/>
|
||||
</footer>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="procurement_suggest_generate_action" model="ir.actions.act_window">
|
||||
<field name="name">Procurement Suggestions</field>
|
||||
<field name="res_model">procurement.suggest.generate</field>
|
||||
<field name="view_mode">form</field>
|
||||
<field name="target">new</field>
|
||||
</record>
|
||||
|
||||
<menuitem id="procurement_suggest_generate_menu"
|
||||
action="procurement_suggest_generate_action"
|
||||
parent="stock.menu_stock_sched"
|
||||
sequence="100"/>
|
||||
|
||||
<record id="procurement_suggest_tree" model="ir.ui.view">
|
||||
<field name="name">procurement_suggest.tree</field>
|
||||
<field name="model">procurement.suggest</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Procurement Suggestions" editable="bottom">
|
||||
<field name="seller_id"/>
|
||||
<field name="product_id"/>
|
||||
<field name="qty_available"/>
|
||||
<field name="procurement_qty"/>
|
||||
<field name="incoming_qty"/>
|
||||
<field name="outgoing_qty"/>
|
||||
<field name="min_qty"/>
|
||||
<field name="uom_id"/>
|
||||
<field name="new_procurement_qty"/>
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="procurement_suggest_search" model="ir.ui.view">
|
||||
<field name="name">procurement_suggest.search</field>
|
||||
<field name="model">procurement.suggest</field>
|
||||
<field name="arch" type="xml">
|
||||
<search string="Procurement Suggestions">
|
||||
<field name="seller_id"/>
|
||||
<field name="product_id"/>
|
||||
<group string="Group By" name="groupby">
|
||||
<filter name="seller_groupby" string="Seller" context="{'group_by': 'seller_id'}"/>
|
||||
</group>
|
||||
</search>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
|
||||
<record id="procurement_suggest_action" model="ir.actions.act_window">
|
||||
<field name="name">Procurement Suggestions</field>
|
||||
<field name="res_model">procurement.suggest</field>
|
||||
<field name="view_mode">tree</field>
|
||||
<field name="target">new</field>
|
||||
<field name="limit">500</field>
|
||||
</record>
|
||||
|
||||
<record id="procurement_create_from_suggest_form" model="ir.ui.view">
|
||||
<field name="name">procurement_create_from_suggest.form</field>
|
||||
<field name="model">procurement.create.from.suggest</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Create Purchase Orders">
|
||||
<p class="oe_grey">
|
||||
This wizard will create procurements and confirm them, so that it creates purchase orders or manufacturing orders.
|
||||
</p>
|
||||
<footer>
|
||||
<button type="object" name="create_proc" string="Create Procurements" class="oe_highlight"/>
|
||||
<button special="cancel" string="Cancel" class="oe_link"/>
|
||||
</footer>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<act_window id="procurement_create_from_suggest_action"
|
||||
multi="True"
|
||||
key2="client_action_multi"
|
||||
name="Create Procurements"
|
||||
res_model="procurement.create.from.suggest"
|
||||
src_model="procurement.suggest"
|
||||
view_mode="form"
|
||||
target="new" />
|
||||
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
@@ -1,3 +0,0 @@
|
||||
# -*- encoding: utf-8 -*-
|
||||
|
||||
from . import wizard
|
||||
@@ -1,45 +0,0 @@
|
||||
# -*- encoding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# Procurement Suggest Purchase module for Odoo
|
||||
# Copyright (C) 2015 Akretion (http://www.akretion.com)
|
||||
# @author Alexis de Lattre <alexis.delattre@akretion.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/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
|
||||
{
|
||||
'name': 'Procurement Suggest Purchase',
|
||||
'version': '0.1',
|
||||
'category': 'Procurements',
|
||||
'license': 'AGPL-3',
|
||||
'summary': 'Usability enhancements to procurement suggest for purchase',
|
||||
'description': """
|
||||
Procurement Suggest Purchase
|
||||
============================
|
||||
|
||||
TODO
|
||||
|
||||
This module has been written by Alexis de Lattre from Akretion <alexis.delattre@akretion.com>.
|
||||
""",
|
||||
'author': 'Akretion',
|
||||
'website': 'http://www.akretion.com',
|
||||
'depends': ['purchase', 'procurement_suggest'],
|
||||
'data': [
|
||||
'wizard/procurement_suggest_view.xml',
|
||||
],
|
||||
'installable': False,
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
# -*- encoding: utf-8 -*-
|
||||
|
||||
from . import procurement_suggest
|
||||
@@ -1,75 +0,0 @@
|
||||
# -*- encoding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# Procurement Suggest Purchase module for Odoo
|
||||
# Copyright (C) 2015 Akretion (http://www.akretion.com)
|
||||
# @author Alexis de Lattre <alexis.delattre@akretion.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/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
from openerp import models, fields, api
|
||||
|
||||
|
||||
class ProcurementSuggestionGenerate(models.TransientModel):
|
||||
_inherit = 'procurement.suggest.generate'
|
||||
|
||||
@api.model
|
||||
def _prepare_suggest_line(self, orderpoint):
|
||||
sline = super(ProcurementSuggestionGenerate, self).\
|
||||
_prepare_suggest_line(orderpoint)
|
||||
porderline_id = False
|
||||
if orderpoint.product_id.seller_id:
|
||||
porderlines = self.env['purchase.order.line'].search([
|
||||
('state', 'not in', ('draft', 'cancel')),
|
||||
('product_id', '=', orderpoint.product_id.id)],
|
||||
order='id desc', limit=1)
|
||||
# I cannot filter on 'date_order' because it is not a stored field
|
||||
porderline_id = porderlines and porderlines[0].id or False
|
||||
sline['last_po_line_id'] = porderline_id
|
||||
return sline
|
||||
|
||||
|
||||
class ProcurementSuggest(models.TransientModel):
|
||||
_inherit = 'procurement.suggest'
|
||||
|
||||
last_po_line_id = fields.Many2one(
|
||||
'purchase.order.line', string='Last Purchase Order Line',
|
||||
readonly=True)
|
||||
last_po_date = fields.Datetime(
|
||||
related='last_po_line_id.order_id.date_order',
|
||||
string='Date of the last PO', readonly=True)
|
||||
last_po_qty = fields.Float(
|
||||
related='last_po_line_id.product_qty', readonly=True,
|
||||
string='Quantity of the Last Order')
|
||||
|
||||
|
||||
class ProcurementCreateFromSuggest(models.TransientModel):
|
||||
_inherit = 'procurement.create.from.suggest'
|
||||
|
||||
@api.multi
|
||||
def create_proc(self):
|
||||
action = super(ProcurementCreateFromSuggest, self).create_proc()
|
||||
poo = self.env['procurement.order']
|
||||
new_procs = poo.browse(action['domain'][0][2])
|
||||
po_ids = []
|
||||
for proc in new_procs:
|
||||
if proc.purchase_id and proc.purchase_id.id not in po_ids:
|
||||
po_ids.append(proc.purchase_id.id)
|
||||
if po_ids:
|
||||
action = self.env['ir.actions.act_window'].for_xml_id(
|
||||
'purchase', 'purchase_rfq')
|
||||
action['domain'] = [('id', 'in', po_ids)]
|
||||
return action
|
||||
@@ -1,27 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<!--
|
||||
Copyright (C) 2015 Akretion (http://www.akretion.com/)
|
||||
@author Alexis de Lattre <alexis.delattre@akretion.com>
|
||||
The licence is in the file __openerp__.py
|
||||
-->
|
||||
|
||||
<openerp>
|
||||
<data>
|
||||
|
||||
|
||||
<record id="procurement_suggest_tree" model="ir.ui.view">
|
||||
<field name="name">procurement_suggest.tree</field>
|
||||
<field name="model">procurement.suggest</field>
|
||||
<field name="inherit_id" ref="procurement_suggest.procurement_suggest_tree"/>
|
||||
<field name="arch" type="xml">
|
||||
<field name="min_qty" position="after">
|
||||
<field name="last_po_date" widget="date"/>
|
||||
<field name="last_po_qty"/>
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
Reference in New Issue
Block a user