mirror of
https://github.com/OCA/stock-logistics-warehouse.git
synced 2025-01-21 14:27:28 +02:00
[11.0][FIX] stock_orderpoint_purchase_link:
* update PO line passes orderpoints * add tests [UPD] Update stock_orderpoint_purchase_link.pot
This commit is contained in:
committed by
Dũng (Trần Đình)
parent
ba7ff47f62
commit
ef08ef7892
@@ -4,7 +4,7 @@
|
||||
{
|
||||
"name": "Stock Orderpoint Purchase Link",
|
||||
"summary": "Link Reordering rules to purchase orders",
|
||||
"version": "11.0.1.0.1",
|
||||
"version": "11.0.1.0.2",
|
||||
"license": "LGPL-3",
|
||||
"website": "https://github.com/stock-logistics-warehouse",
|
||||
"author": "Eficent, "
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
# Translation of Odoo Server.
|
||||
# This file contains the translation of the following modules:
|
||||
# * stock_orderpoint_purchase_link
|
||||
#
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Odoo Server 11.0\n"
|
||||
"Report-Msgid-Bugs-To: \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: stock_orderpoint_purchase_link
|
||||
#: model:ir.model,name:stock_orderpoint_purchase_link.model_stock_warehouse_orderpoint
|
||||
msgid "Minimum Inventory Rule"
|
||||
msgstr ""
|
||||
|
||||
#. module: stock_orderpoint_purchase_link
|
||||
#: model:ir.model.fields,field_description:stock_orderpoint_purchase_link.field_purchase_order_line_orderpoint_ids
|
||||
#: model:ir.ui.view,arch_db:stock_orderpoint_purchase_link.purchase_order_form
|
||||
#: model:ir.ui.view,arch_db:stock_orderpoint_purchase_link.purchase_order_line_form2
|
||||
msgid "Orderpoints"
|
||||
msgstr ""
|
||||
|
||||
#. module: stock_orderpoint_purchase_link
|
||||
#: model:ir.model,name:stock_orderpoint_purchase_link.model_procurement_rule
|
||||
msgid "Procurement Rule"
|
||||
msgstr ""
|
||||
|
||||
#. module: stock_orderpoint_purchase_link
|
||||
#: model:ir.model,name:stock_orderpoint_purchase_link.model_purchase_order_line
|
||||
msgid "Purchase Order Line"
|
||||
msgstr ""
|
||||
|
||||
#. module: stock_orderpoint_purchase_link
|
||||
#: model:ir.model.fields,field_description:stock_orderpoint_purchase_link.field_stock_warehouse_orderpoint_purchase_line_ids
|
||||
msgid "Purchase Order Lines"
|
||||
msgstr ""
|
||||
|
||||
@@ -28,4 +28,8 @@ class ProcurementRule(models.Model):
|
||||
if 'orderpoint_id' in values:
|
||||
vals['orderpoint_ids'] = [
|
||||
(4, values['orderpoint_id'].id)]
|
||||
# If the procurement was run by a stock move.
|
||||
elif 'orderpoint_ids' in values:
|
||||
vals['orderpoint_ids'] = [(4, o.id)
|
||||
for o in values['orderpoint_ids']]
|
||||
return vals
|
||||
|
||||
1
stock_orderpoint_purchase_link/tests/__init__.py
Normal file
1
stock_orderpoint_purchase_link/tests/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from . import test_stock_orderpoint_purchase_link
|
||||
@@ -0,0 +1,77 @@
|
||||
# Copyright 2018 Eficent Business and IT Consulting Services S.L.
|
||||
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl-3.0).
|
||||
|
||||
from odoo.tests import common
|
||||
|
||||
|
||||
class TestOrderpointPurchaseLink(common.TransactionCase):
|
||||
def setUp(self):
|
||||
super(TestOrderpointPurchaseLink, self).setUp()
|
||||
|
||||
self.product_obj = self.env['product.product']
|
||||
self.partner_obj = self.env['res.partner']
|
||||
self.pol_obj = self.env['purchase.order.line']
|
||||
self.location_obj = self.env['stock.location']
|
||||
self.orderpoint_obj = self.env['stock.warehouse.orderpoint']
|
||||
self.route_obj = self.env['stock.location.route']
|
||||
self.rule_obj = self.env['procurement.rule']
|
||||
self.group_obj = self.env['procurement.group']
|
||||
|
||||
# WH and routes:
|
||||
self.warehouse = self.env.ref('stock.warehouse0')
|
||||
self.stock_location = self.warehouse.lot_stock_id
|
||||
self.test_location = self.location_obj.create({
|
||||
'name': 'Test',
|
||||
'location_id': self.warehouse.view_location_id.id,
|
||||
})
|
||||
route_buy = self.env.ref('purchase.route_warehouse0_buy').id
|
||||
route_test = self.route_obj.create({
|
||||
'name': 'Stock to Test',
|
||||
}).id
|
||||
self.rule_obj.create({
|
||||
'name': 'Stock to Test',
|
||||
'action': 'move',
|
||||
'procure_method': 'make_to_order',
|
||||
'location_id': self.test_location.id,
|
||||
'location_src_id': self.stock_location.id,
|
||||
'route_id': route_test,
|
||||
'picking_type_id': self.warehouse.int_type_id.id,
|
||||
'warehouse_id': self.warehouse.id,
|
||||
'group_propagation_option': 'none',
|
||||
})
|
||||
# Partners:
|
||||
vendor1 = self.partner_obj.create({'name': 'Vendor 1'})
|
||||
|
||||
# Create products:
|
||||
self.tp1 = self.product_obj.create({
|
||||
'name': 'Test Product 1',
|
||||
'type': 'product',
|
||||
'list_price': 150.0,
|
||||
'route_ids': [(6, 0, [route_buy, route_test])],
|
||||
'seller_ids': [(0, 0, {'name': vendor1.id, 'price': 20.0})],
|
||||
})
|
||||
|
||||
# Create Orderpoints:
|
||||
self.op1 = self.orderpoint_obj.create({
|
||||
'product_id': self.tp1.id,
|
||||
'location_id': self.stock_location.id,
|
||||
'product_min_qty': 5.0,
|
||||
'product_max_qty': 20.0,
|
||||
})
|
||||
self.op2 = self.orderpoint_obj.create({
|
||||
'product_id': self.tp1.id,
|
||||
'location_id': self.test_location.id,
|
||||
'product_min_qty': 5.0,
|
||||
'product_max_qty': 20.0,
|
||||
})
|
||||
|
||||
def test_01_po_line_from_orderpoints(self):
|
||||
"""Test that a PO line created/updated by two orderpoints keeps
|
||||
the link with both of them."""
|
||||
self.group_obj.run_scheduler()
|
||||
po_line = self.env['purchase.order.line'].search(
|
||||
[('product_id', '=', self.tp1.id)])
|
||||
self.assertTrue(po_line)
|
||||
# Each orderpoint must have required 20.0 units:
|
||||
self.assertEqual(po_line.product_qty, 40.0)
|
||||
self.assertEqual(len(po_line.orderpoint_ids), 2)
|
||||
Reference in New Issue
Block a user