mirror of
https://github.com/OCA/stock-logistics-warehouse.git
synced 2025-01-21 14:27:28 +02:00
[10.0][MIG] stock_orderpoint_manual_procurement
This commit is contained in:
committed by
Joan Sisquella
parent
945e648d0f
commit
bd4e5e031a
@@ -9,6 +9,13 @@ Stock Orderpoint Manual Procurement
|
||||
This module allows users to manually start procurements from the list of
|
||||
reordering rules, based on the quantity that is recommended to be procured.
|
||||
|
||||
Configuration
|
||||
=============
|
||||
|
||||
If you want users to be able to change the recommended quantity to procure,
|
||||
you should assign them to the security group 'Change quantity in manual
|
||||
procurements from reordering rules', under 'Settings / Users / Users'.
|
||||
|
||||
Usage
|
||||
=====
|
||||
|
||||
@@ -19,13 +26,9 @@ single or a list of reordering rules.
|
||||
The recommended quantity to procure is adjusted to the procurement unit of
|
||||
measure indicated in the reordering rule.
|
||||
|
||||
If you want users to be able to change the recommended quantity to procure,
|
||||
you should assign them to the security group 'Change quantity in manual
|
||||
procurements from reordering rules', under 'Settings / Users / Users'.
|
||||
|
||||
.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
|
||||
:alt: Try me on Runbot
|
||||
:target: https://runbot.odoo-community.org/runbot/153/8.0
|
||||
:target: https://runbot.odoo-community.org/runbot/153/10.0
|
||||
|
||||
Bug Tracker
|
||||
===========
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright 2016 Eficent Business and IT Consulting Services S.L.
|
||||
# (http://www.eficent.com)
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
|
||||
|
||||
from . import models
|
||||
|
||||
27
stock_orderpoint_manual_procurement/__manifest__.py
Normal file
27
stock_orderpoint_manual_procurement/__manifest__.py
Normal file
@@ -0,0 +1,27 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright 2016-17 Eficent Business and IT Consulting Services S.L.
|
||||
# (http://www.eficent.com)
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
|
||||
{
|
||||
"name": "Stock Orderpoint Manual Procurement",
|
||||
"summary": "Allows to create procurement orders from orderpoints instead "
|
||||
"of relying only on the scheduler.",
|
||||
"version": "10.0.1.0.0",
|
||||
"author": "Eficent, "
|
||||
"Odoo Community Association (OCA)",
|
||||
"website": "https://github.com/OCA/stock-logistics-warehouse",
|
||||
"category": "Warehouse Management",
|
||||
"depends": [
|
||||
"stock",
|
||||
"stock_orderpoint_uom",
|
||||
],
|
||||
"data": [
|
||||
"security/stock_orderpoint_manual_procurement_security.xml",
|
||||
"wizards/make_procurement_orderpoint_view.xml",
|
||||
"views/procurement_order_view.xml",
|
||||
"views/stock_warehouse_orderpoint_view.xml",
|
||||
],
|
||||
"license": "AGPL-3",
|
||||
'installable': True,
|
||||
'application': False,
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright 2016 Eficent Business and IT Consulting Services S.L.
|
||||
# (http://www.eficent.com)
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
|
||||
{
|
||||
"name": "Stock Orderpoint manual procurement",
|
||||
"summary": "Allows to create procurement orders from orderpoints instead "
|
||||
"of relying only on the scheduler",
|
||||
"version": "9.0.1.0.0",
|
||||
"author": "Eficent Business and IT Consulting Services S.L,"
|
||||
"Odoo Community Association (OCA)",
|
||||
"website": "https://www.odoo-community.org",
|
||||
"category": "Warehouse Management",
|
||||
"depends": ["stock",
|
||||
"stock_orderpoint_uom"],
|
||||
"data": ["security/stock_orderpoint_manual_procurement_security.xml",
|
||||
"wizards/make_procurement_orderpoint_view.xml",
|
||||
"views/procurement_order_view.xml",
|
||||
"views/stock_warehouse_orderpoint_view.xml"
|
||||
],
|
||||
"license": "AGPL-3",
|
||||
'installable': True,
|
||||
'application': False,
|
||||
}
|
||||
@@ -1,6 +1,4 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright 2016 Eficent Business and IT Consulting Services S.L.
|
||||
# (http://www.eficent.com)
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
|
||||
|
||||
from . import stock_warehouse_orderpoint
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright 2016 Eficent Business and IT Consulting Services S.L.
|
||||
# Copyright 2016-17 Eficent Business and IT Consulting Services S.L.
|
||||
# (http://www.eficent.com)
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
|
||||
|
||||
from openerp import api, fields, models
|
||||
from odoo import api, fields, models
|
||||
from datetime import datetime
|
||||
from openerp.addons import decimal_precision as dp
|
||||
from openerp.tools import float_compare, float_round
|
||||
from odoo.addons import decimal_precision as dp
|
||||
from odoo.tools import float_compare, float_round
|
||||
|
||||
|
||||
UNIT = dp.get_precision('Product Unit of Measure')
|
||||
@@ -15,28 +15,35 @@ UNIT = dp.get_precision('Product Unit of Measure')
|
||||
class StockWarehouseOrderpoint(models.Model):
|
||||
_inherit = 'stock.warehouse.orderpoint'
|
||||
|
||||
procure_recommended_qty = fields.Float(
|
||||
string='Procure Recommendation',
|
||||
compute="_compute_procure_recommended",
|
||||
digits=UNIT,
|
||||
)
|
||||
procure_recommended_date = fields.Date(
|
||||
string='Recommended Request Date',
|
||||
compute="_compute_procure_recommended",
|
||||
)
|
||||
|
||||
@api.multi
|
||||
@api.depends("product_min_qty", "product_id", "qty_multiple")
|
||||
def _compute_procure_recommended(self):
|
||||
procurement_model = self.env['procurement.order']
|
||||
op_qtys = self.subtract_procurements_from_orderpoints(self.ids)
|
||||
op_qtys = self.subtract_procurements_from_orderpoints()
|
||||
for op in self:
|
||||
op.procure_recommended_date = \
|
||||
procurement_model._get_orderpoint_date_planned(
|
||||
op, datetime.today())
|
||||
op.procure_recommended_date = op._get_date_planned(
|
||||
datetime.today())
|
||||
procure_recommended_qty = 0.0
|
||||
prods = op.with_context(
|
||||
virtual_qty = op.with_context(
|
||||
location=op.location_id.id).product_id.virtual_available
|
||||
if prods is None:
|
||||
continue
|
||||
if float_compare(prods, op.product_min_qty,
|
||||
if float_compare(virtual_qty, op.product_min_qty,
|
||||
precision_rounding=op.product_uom.rounding) < 0:
|
||||
qty = max(op.product_min_qty, op.product_max_qty) - prods
|
||||
reste = op.qty_multiple > 0 and qty % op.qty_multiple or 0.0
|
||||
qty = max(op.product_min_qty, op.product_max_qty) - virtual_qty
|
||||
remainder = \
|
||||
op.qty_multiple > 0 and qty % op.qty_multiple or 0.0
|
||||
if float_compare(
|
||||
reste, 0.0,
|
||||
remainder, 0.0,
|
||||
precision_rounding=op.product_uom.rounding) > 0:
|
||||
qty += op.qty_multiple - reste
|
||||
qty += op.qty_multiple - remainder
|
||||
|
||||
if float_compare(
|
||||
qty, 0.0,
|
||||
@@ -56,11 +63,3 @@ class StockWarehouseOrderpoint(models.Model):
|
||||
product_qty = procure_recommended_qty
|
||||
|
||||
op.procure_recommended_qty = product_qty
|
||||
|
||||
procure_recommended_qty = fields.Float(
|
||||
string='Procure recommendation',
|
||||
compute="_compute_procure_recommended",
|
||||
digits=UNIT)
|
||||
procure_recommended_date = fields.Date(
|
||||
string='Request Date',
|
||||
compute="_compute_procure_recommended")
|
||||
|
||||
@@ -1,12 +1,10 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data noupdate="0">
|
||||
<odoo noupdate="1">
|
||||
|
||||
<record id="group_change_orderpoint_procure_qty" model="res.groups">
|
||||
<field name="name">Change quantity in manual procurements from reordering rules</field>
|
||||
<field name="implied_ids" eval="[(4, ref('base.group_user'))]"/>
|
||||
<field name="category_id" ref="base.module_category_warehouse_management"/>
|
||||
<field name="category_id" ref="base.module_category_hidden"/>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
</odoo>
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright 2016 Eficent Business and IT Consulting Services S.L.
|
||||
# (http://www.eficent.com)
|
||||
# Copyright 2016 Serpent Consulting Services Pvt. Ltd.
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
|
||||
|
||||
from . import test_stock_orderpoint_manual_procurement
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright 2016 Eficent Business and IT Consulting Services S.L.
|
||||
# Copyright 2016-17 Eficent Business and IT Consulting Services S.L.
|
||||
# (http://www.eficent.com)
|
||||
# Copyright 2016 Serpent Consulting Services Pvt. Ltd.
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
|
||||
|
||||
from openerp.tests import common
|
||||
from odoo.tests import common
|
||||
|
||||
|
||||
class TestStockWarehouseOrderpoint(common.TransactionCase):
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<?xml version="1.0"?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
|
||||
<record id="view_procurement_filter" model="ir.ui.view">
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?xml version="1.0"?>
|
||||
<openerp>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
|
||||
<record id="view_warehouse_orderpoint_tree" model="ir.ui.view">
|
||||
<field name="name">stock.warehouse.orderpoint.tree</field>
|
||||
@@ -13,15 +13,15 @@
|
||||
<field name="procure_recommended_date"/>
|
||||
<button string="Create Procurement"
|
||||
name="%(stock_orderpoint_manual_procurement.act_make_procurement_from_orderpoint)d"
|
||||
icon="gtk-execute" type="action"/>
|
||||
icon="fa fa-cogs" type="action"/>
|
||||
<button string="Procurements"
|
||||
name="%(procurement.procurement_action)d"
|
||||
attrs="{'invisible':[('procurement_ids', '=', False)]}"
|
||||
icon="gtk-open" type="action"
|
||||
attrs="{'invisible':[('procurement_ids', '=', [])]}"
|
||||
icon="fa fa-folder-open" type="action"
|
||||
domain="[('orderpoint_id','=', active_id)]"
|
||||
context="{'search_default_orderpoint_id': [active_id]}"/>
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
</openerp>
|
||||
</odoo>
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright 2016 Eficent Business and IT Consulting Services S.L.
|
||||
# (http://www.eficent.com)
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
|
||||
|
||||
from . import make_procurement_orderpoint
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright 2016 Eficent Business and IT Consulting Services S.L.
|
||||
# Copyright 2016-17 Eficent Business and IT Consulting Services S.L.
|
||||
# (http://www.eficent.com)
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
|
||||
|
||||
from openerp import api, fields, models
|
||||
from odoo import api, fields, models, _
|
||||
from odoo.exceptions import ValidationError
|
||||
|
||||
|
||||
class MakeProcurementOrderpoint(models.TransientModel):
|
||||
@@ -58,12 +59,11 @@ class MakeProcurementOrderpoint(models.TransientModel):
|
||||
for item in self.item_ids:
|
||||
data = item._prepare_procurement()
|
||||
procurement = self.env['procurement.order'].create(data)
|
||||
procurement.signal_workflow('button_confirm')
|
||||
procurement.run()
|
||||
res.append(procurement.id)
|
||||
|
||||
return {
|
||||
'domain': "[('id','in', ["+','.join(map(str, res))+"])]",
|
||||
'name': _('Created Procurements'),
|
||||
'domain': [('id', 'in', res)],
|
||||
'view_type': 'form',
|
||||
'view_mode': 'tree,form',
|
||||
'res_model': 'procurement.order',
|
||||
@@ -100,6 +100,8 @@ class MakeProcurementOrderpointItem(models.TransientModel):
|
||||
|
||||
@api.multi
|
||||
def _prepare_procurement(self):
|
||||
if not self.qty:
|
||||
raise ValidationError(_("Quantity must be positive."))
|
||||
return {
|
||||
'name': self.orderpoint_id.name,
|
||||
'date_planned': self.date_planned,
|
||||
|
||||
@@ -1,63 +1,61 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
<odoo>
|
||||
|
||||
<!-- Make Procurement -->
|
||||
<!-- Make Procurement -->
|
||||
|
||||
<record id="view_make_procurment_buffer_wizard" model="ir.ui.view">
|
||||
<field name="name">Request Procurement</field>
|
||||
<field name="model">make.procurement.orderpoint</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Procurement Request">
|
||||
<p class="oe_gray">
|
||||
Use this assistant to generate a procurement request for this
|
||||
stock buffer. According to the product configuration,
|
||||
this may trigger a draft purchase order, a manufacturing
|
||||
order or a transfer picking.
|
||||
</p>
|
||||
<group name="items" string="Items">
|
||||
<field name="item_ids" nolabel="1">
|
||||
<tree string="Items" nocreate="1" editable="top">
|
||||
<field name="orderpoint_id" invisible="True"/>
|
||||
<field name="warehouse_id" groups="stock.group_locations"/>
|
||||
<field name="location_id" groups="stock.group_locations"/>
|
||||
<field name="product_id"/>
|
||||
<field name="qty" groups="stock_orderpoint_manual_procurement.group_change_orderpoint_procure_qty"/>
|
||||
<field name="uom_id" groups="product.group_uom"/>
|
||||
<field name="date_planned"/>
|
||||
</tree>
|
||||
</field>
|
||||
</group>
|
||||
<footer>
|
||||
<button name="make_procurement" string="Execute"
|
||||
type="object" class="oe_highlight" />
|
||||
or
|
||||
<button string="Cancel" class="oe_link" special="cancel" />
|
||||
</footer>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
<record id="view_make_procurment_buffer_wizard" model="ir.ui.view">
|
||||
<field name="name">Request Procurement</field>
|
||||
<field name="model">make.procurement.orderpoint</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Procurement Request">
|
||||
<p class="oe_gray">
|
||||
Use this assistant to generate a procurement request for this
|
||||
stock buffer. According to the product configuration,
|
||||
this may trigger a draft purchase order, a manufacturing
|
||||
order or a transfer picking.
|
||||
</p>
|
||||
<group name="items" string="Items">
|
||||
<field name="item_ids" nolabel="1">
|
||||
<tree string="Items" nocreate="1" editable="top">
|
||||
<field name="orderpoint_id" invisible="True"/>
|
||||
<field name="warehouse_id" groups="stock.group_locations"/>
|
||||
<field name="location_id" groups="stock.group_locations"/>
|
||||
<field name="product_id"/>
|
||||
<field name="qty" groups="stock_orderpoint_manual_procurement.group_change_orderpoint_procure_qty"/>
|
||||
<field name="uom_id" groups="product.group_uom"/>
|
||||
<field name="date_planned"/>
|
||||
</tree>
|
||||
</field>
|
||||
</group>
|
||||
<footer>
|
||||
<button name="make_procurement" string="Execute"
|
||||
type="object" class="oe_highlight" />
|
||||
or
|
||||
<button string="Cancel" class="oe_link" special="cancel" />
|
||||
</footer>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
|
||||
<record model="ir.actions.act_window"
|
||||
id="act_make_procurement_from_orderpoint">
|
||||
<field name="name">Request Procurement</field>
|
||||
<field name="res_model">make.procurement.orderpoint</field>
|
||||
<field name="src_model">stock.warehouse.orderpoint</field>
|
||||
<field name="view_mode">form</field>
|
||||
<field name="target">new</field>
|
||||
</record>
|
||||
<record model="ir.actions.act_window"
|
||||
id="act_make_procurement_from_orderpoint">
|
||||
<field name="name">Request Procurement</field>
|
||||
<field name="res_model">make.procurement.orderpoint</field>
|
||||
<field name="src_model">stock.warehouse.orderpoint</field>
|
||||
<field name="view_mode">form</field>
|
||||
<field name="target">new</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.values"
|
||||
id="stock_warehouse_orderpoint_make_procurement">
|
||||
<field name="model_id"
|
||||
ref="stock.model_stock_warehouse_orderpoint" />
|
||||
<field name="name">Request Procurement</field>
|
||||
<field name="key2">client_action_multi</field>
|
||||
<field name="value" eval="'ir.actions.act_window,' + str(ref('act_make_procurement_from_orderpoint'))" />
|
||||
<field name="key">action</field>
|
||||
<field name="model">stock.warehouse.orderpoint</field>
|
||||
</record>
|
||||
<record model="ir.values"
|
||||
id="stock_warehouse_orderpoint_make_procurement">
|
||||
<field name="model_id"
|
||||
ref="stock.model_stock_warehouse_orderpoint" />
|
||||
<field name="name">Request Procurement</field>
|
||||
<field name="key2">client_action_multi</field>
|
||||
<field name="value" eval="'ir.actions.act_window,' + str(ref('act_make_procurement_from_orderpoint'))" />
|
||||
<field name="key">action</field>
|
||||
<field name="model">stock.warehouse.orderpoint</field>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
</odoo>
|
||||
|
||||
Reference in New Issue
Block a user