mirror of
https://github.com/OCA/stock-logistics-warehouse.git
synced 2025-01-21 14:27:28 +02:00
[MIG] stock_orderpoint_uom: Migration to 11.0
This commit is contained in:
committed by
davidborromeo
parent
ac44c56c5f
commit
484cd385e6
@@ -19,19 +19,18 @@ Configuration
|
||||
=============
|
||||
|
||||
To configure this module, you need to 'Inventory > Configuration > Settings'
|
||||
and enable 'Some products may be sold/purchased in different unit of measures
|
||||
(advanced)' option.
|
||||
and enable 'Sell and purchase products in different units of measure' option.
|
||||
|
||||
Usage
|
||||
=====
|
||||
|
||||
Go to 'Inventory > Inventory Control > Reordering Rules' and indicate a
|
||||
Procurement UoM.
|
||||
Go to 'Inventory > Master Data > Reordering Rules' and indicate a Procurement
|
||||
UoM.
|
||||
|
||||
|
||||
.. 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/10.0
|
||||
:target: https://runbot.odoo-community.org/runbot/153/11.0
|
||||
|
||||
Bug Tracker
|
||||
===========
|
||||
@@ -54,7 +53,7 @@ Contributors
|
||||
|
||||
* Jordi Ballester Alomar <jordi.ballester@eficent.com>
|
||||
* Lois Rilo <lois.rilo@eficent.com>
|
||||
|
||||
* Bhavesh Odedra <bodedra@opensourceintegrators.com>
|
||||
|
||||
Maintainer
|
||||
----------
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
# -*- 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).
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
# -*- 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).
|
||||
@@ -6,12 +5,13 @@
|
||||
"name": "Stock Orderpoint UoM",
|
||||
"summary": "Allows to create procurement orders in the UoM indicated in "
|
||||
"the orderpoint",
|
||||
"version": "10.0.1.0.0",
|
||||
"version": "11.0.1.0.0",
|
||||
"author": "Eficent, "
|
||||
"Odoo Community Association (OCA)",
|
||||
"website": "https://www.odoo-community.org",
|
||||
"category": "Warehouse Management",
|
||||
"depends": ["stock"],
|
||||
"depends": ["purchase", "stock"],
|
||||
"demo": ["demo/product.xml"],
|
||||
"data": ["views/stock_warehouse_orderpoint_view.xml"],
|
||||
"license": "AGPL-3",
|
||||
'installable': True,
|
||||
|
||||
10
stock_orderpoint_uom/demo/product.xml
Normal file
10
stock_orderpoint_uom/demo/product.xml
Normal file
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.0"?>
|
||||
<odoo noupdate="1">
|
||||
<record id="product_supplierinfo_product_7" model="product.supplierinfo">
|
||||
<field name="product_tmpl_id" ref="product.product_product_7"/>
|
||||
<field name="name" ref="base.res_partner_3"/>
|
||||
<field name="delay">3</field>
|
||||
<field name="min_qty">1</field>
|
||||
<field name="price">72</field>
|
||||
</record>
|
||||
</odoo>
|
||||
@@ -1,5 +1,5 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
|
||||
|
||||
from . import stock_warehouse_orderpoint
|
||||
from . import product_template
|
||||
from . import procurement_group
|
||||
|
||||
20
stock_orderpoint_uom/models/procurement_group.py
Normal file
20
stock_orderpoint_uom/models/procurement_group.py
Normal file
@@ -0,0 +1,20 @@
|
||||
# Copyright (C) 2018 - TODAY, Open Source Integrators
|
||||
# (http://www.opensourceintegrators.com)
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
|
||||
|
||||
from odoo import api, models
|
||||
|
||||
|
||||
class ProcurementGroup(models.Model):
|
||||
_inherit = "procurement.group"
|
||||
|
||||
@api.model
|
||||
def run(self, product_id, product_qty, product_uom, location_id, name,
|
||||
origin, values):
|
||||
if 'orderpoint_id' in values:
|
||||
orderpoint = values.get('orderpoint_id')
|
||||
product_qty = orderpoint.product_uom._compute_quantity(
|
||||
product_qty, orderpoint.procure_uom_id)
|
||||
return super(ProcurementGroup, self).run(product_id, product_qty,
|
||||
product_uom, location_id,
|
||||
name, origin, values)
|
||||
@@ -1,4 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright 2018 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).
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
# -*- 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).
|
||||
@@ -25,14 +24,3 @@ class Orderpoint(models.Model):
|
||||
'the procurement Unit of Measure must be in the '
|
||||
'same category.'))
|
||||
return True
|
||||
|
||||
@api.model
|
||||
def _prepare_procurement_values(self, product_qty,
|
||||
date=False, group=False):
|
||||
res = super(Orderpoint, self)._prepare_procurement_values(
|
||||
product_qty, date, group)
|
||||
if self.procure_uom_id:
|
||||
res['product_qty'] = self.product_uom._compute_quantity(
|
||||
product_qty, self.procure_uom_id)
|
||||
res['product_uom'] = self.procure_uom_id.id
|
||||
return res
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
# -*- 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).
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
# -*- 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).
|
||||
@@ -12,7 +11,14 @@ class TestStockOrderpointProcureUom(common.TransactionCase):
|
||||
|
||||
def setUp(self):
|
||||
super(TestStockOrderpointProcureUom, self).setUp()
|
||||
# Refs
|
||||
self.vendor = self.env.ref(
|
||||
'stock_orderpoint_uom.product_supplierinfo_product_7')
|
||||
|
||||
# Get required Model
|
||||
productObj = self.env['product.product']
|
||||
self.purchase_model = self.env['purchase.order']
|
||||
self.purchase_line_model = self.env['purchase.order.line']
|
||||
self.warehouse = self.env.ref('stock.warehouse0')
|
||||
self.location_stock = self.env.ref('stock.stock_location_stock')
|
||||
self.uom_unit = self.env.ref('product.product_uom_unit')
|
||||
@@ -25,24 +31,31 @@ class TestStockOrderpointProcureUom(common.TransactionCase):
|
||||
'type': 'product',
|
||||
'uom_id': self.uom_unit.id,
|
||||
'default_code': 'A',
|
||||
'variant_seller_ids': [(6, 0, [self.vendor.id])],
|
||||
})
|
||||
|
||||
def test_stock_orderpoint_procure_uom(self):
|
||||
|
||||
self.env['stock.warehouse.orderpoint'].create({
|
||||
orderpoint = self.env['stock.warehouse.orderpoint'].create({
|
||||
'warehouse_id': self.warehouse.id,
|
||||
'location_id': self.location_stock.id,
|
||||
'product_id': self.productA.id,
|
||||
'product_max_qty': 24,
|
||||
'product_min_qty': 12,
|
||||
'product_uom': self.uom_unit.id,
|
||||
'procure_uom_id': self.uom_dozen.id,
|
||||
})
|
||||
|
||||
sched = self.env['procurement.order']
|
||||
sched.run_scheduler()
|
||||
proc = sched.search([('product_id', '=', self.productA.id)])
|
||||
self.assertEqual(proc.product_uom, self.uom_dozen)
|
||||
self.assertEqual(proc.product_qty, 2)
|
||||
self.env['procurement.group'].run_scheduler()
|
||||
# As per route configuration, it will create Purchase order
|
||||
purchase = self.purchase_model.search(
|
||||
[('origin', 'ilike', orderpoint.name)])
|
||||
self.assertEquals(len(purchase), 1)
|
||||
purchase_line = self.purchase_line_model.search(
|
||||
[('orderpoint_id', '=', orderpoint.id),
|
||||
('order_id', '=', purchase.id)])
|
||||
self.assertEquals(len(purchase_line), 1)
|
||||
self.assertEqual(purchase_line.product_qty, 2.0)
|
||||
|
||||
def test_stock_orderpoint_wrong_uom(self):
|
||||
|
||||
|
||||
Reference in New Issue
Block a user