mirror of
https://github.com/OCA/stock-logistics-warehouse.git
synced 2025-01-21 14:27:28 +02:00
V9 migration modifications.
* mrp_bom.name has been deleted.
* mrp_bom_line.type moved to mrp_bom.type.
* Fix missing group_mrp_user issue.
* Change versions
This commit is contained in:
committed by
Víctor Martínez
parent
4d2b9567e7
commit
c57208670a
@@ -1,9 +1,9 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# © 2014 Numérigraphe SARL
|
||||
# © 2014 Numérigraphe SARL, Camptocamp
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||
{
|
||||
'name': 'Consider the production potential is available to promise',
|
||||
'version': '8.0.3.1.1',
|
||||
'version': '9.0.1.0.0',
|
||||
"author": u"Numérigraphe,"
|
||||
u"Odoo Community Association (OCA)",
|
||||
'category': 'Hidden',
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
|
||||
- Add a BOM whereby 0.042K "RAM SR2" can be replaced with 13 dozens "HDD-SH1" + 8 CPUa8 with 50% efficiency. This lets us test UoM conversions for the finished product and the raw materials, as well as the unfolding of phantom BoMs
|
||||
- !record {model: mrp.bom, id: sr2_from_hdd}:
|
||||
name: RAM SR2 made from HDD-SH1
|
||||
product_id: product.product_product_14
|
||||
product_tmpl_id: product.product_product_14_product_template
|
||||
product_uom: thousand
|
||||
|
||||
@@ -7,6 +7,8 @@ from collections import Counter
|
||||
from openerp import models, fields, api
|
||||
from openerp.addons import decimal_precision as dp
|
||||
|
||||
from openerp.exceptions import AccessError
|
||||
|
||||
|
||||
class ProductProduct(models.Model):
|
||||
_inherit = 'product.product'
|
||||
@@ -53,7 +55,12 @@ class ProductProduct(models.Model):
|
||||
bom = bom_obj.browse(bom_id)
|
||||
|
||||
# Need by product (same product can be in many BOM lines/levels)
|
||||
component_needs = self._get_components_needs(product, bom)
|
||||
try:
|
||||
component_needs = self._get_components_needs(product, bom)
|
||||
except AccessError:
|
||||
# If user doesn't have access to BOM
|
||||
# he can't see potential_qty
|
||||
component_needs = None
|
||||
|
||||
if not component_needs:
|
||||
# The BoM has no line we can use
|
||||
|
||||
@@ -86,13 +86,14 @@ class TestPotentialQty(TransactionCase):
|
||||
inventory.action_done()
|
||||
|
||||
def create_simple_bom(self, product, sub_product,
|
||||
product_qty=1, sub_product_qty=1):
|
||||
product_qty=1, sub_product_qty=1,
|
||||
routing_id=False):
|
||||
bom = self.bom_model.create({
|
||||
'product_tmpl_id': product.product_tmpl_id.id,
|
||||
'product_id': product.id,
|
||||
'product_qty': product_qty,
|
||||
'product_uom': self.ref('product.product_uom_unit'),
|
||||
|
||||
'routing_id': routing_id,
|
||||
})
|
||||
self.bom_line_model.create({
|
||||
'bom_id': bom.id,
|
||||
@@ -159,7 +160,8 @@ class TestPotentialQty(TransactionCase):
|
||||
'login': 'test_demo',
|
||||
'company_id': self.ref('base.main_company'),
|
||||
'company_ids': [(4, self.ref('base.main_company'))],
|
||||
'groups_id': [(4, self.ref('stock.group_stock_user'))]})
|
||||
'groups_id': [(4, self.ref('stock.group_stock_user')),
|
||||
(4, self.ref('mrp.group_mrp_user'))]})
|
||||
|
||||
bom = self.env['mrp.bom'].search(
|
||||
[('product_tmpl_id', '=', self.tmpl.id)])
|
||||
@@ -185,6 +187,29 @@ class TestPotentialQty(TransactionCase):
|
||||
self.assertPotentialQty(
|
||||
test_user_tmpl, 1000.0, '')
|
||||
|
||||
def test_group_mrp_missing(self):
|
||||
test_user = self.env['res.users'].create({
|
||||
'name': 'test_demo',
|
||||
'login': 'test_demo',
|
||||
'company_id': self.ref('base.main_company'),
|
||||
'company_ids': [(4, self.ref('base.main_company'))],
|
||||
'groups_id': [(4, self.ref('stock.group_stock_user'))],
|
||||
})
|
||||
|
||||
p1 = self.product_model.create({'name': 'Test P1'})
|
||||
p2 = self.product_model.create({'name': 'Test P2'})
|
||||
|
||||
self.create_simple_bom(p1, p2,
|
||||
routing_id=self.ref('mrp.mrp_routing_0'))
|
||||
self.create_inventory(p2.id, 1)
|
||||
|
||||
test_user_p1 = p1.sudo(test_user)
|
||||
# Test user doesn't have access to mrp_routing, can't compute potential
|
||||
self.assertEqual(0, test_user_p1.potential_qty)
|
||||
|
||||
test_user.groups_id = [(4, self.ref('mrp.group_mrp_user'))]
|
||||
self.assertEqual(1, test_user_p1.potential_qty)
|
||||
|
||||
def test_potential_qty(self):
|
||||
for i in [self.tmpl, self.var1, self.var2]:
|
||||
self.assertPotentialQty(
|
||||
@@ -313,12 +338,12 @@ class TestPotentialQty(TransactionCase):
|
||||
'product_id': p2.id,
|
||||
'product_qty': 2,
|
||||
'product_uom': self.ref('product.product_uom_unit'),
|
||||
'type': 'phantom',
|
||||
})
|
||||
|
||||
bom_p2 = self.bom_model.create({
|
||||
'product_tmpl_id': p2.product_tmpl_id.id,
|
||||
'product_id': p2.id,
|
||||
'type': 'phantom',
|
||||
})
|
||||
|
||||
# p2 need 2 unit of component
|
||||
@@ -435,7 +460,7 @@ class TestPotentialQty(TransactionCase):
|
||||
})
|
||||
|
||||
# Need 1 iMac for that
|
||||
p1_bom_line = self.bom_line_model.create({
|
||||
self.bom_line_model.create({
|
||||
'bom_id': bom_p1.id,
|
||||
'product_id': imac.id,
|
||||
'product_qty': 1,
|
||||
@@ -464,8 +489,8 @@ class TestPotentialQty(TransactionCase):
|
||||
'product_id': imac.id,
|
||||
'product_qty': 1,
|
||||
'product_uom': self.ref('product.product_uom_unit'),
|
||||
'type': 'phantom',
|
||||
})
|
||||
p1_bom_line.type = 'phantom'
|
||||
|
||||
# Need 1 imac_component for iMac
|
||||
self.bom_line_model.create({
|
||||
|
||||
@@ -9,8 +9,16 @@
|
||||
<field name="inherit_id" ref="stock_available.view_stock_available_form" />
|
||||
<field name="arch" type="xml">
|
||||
<data>
|
||||
<xpath expr="//field[@name='immediately_usable_qty']" position="before">
|
||||
<field name="potential_qty"/>
|
||||
<xpath expr="//field[@name='immediately_usable_qty']/ancestor::button" position="after">
|
||||
<button type="action" name="%(stock.product_open_quants)d"
|
||||
attrs="{'invisible':[('type', '!=', 'product')]}"
|
||||
class="oe_stat_button" icon="fa-building-o">
|
||||
<div class="o_form_field o_stat_info">
|
||||
<field name="potential_qty"
|
||||
widget="statinfo" nolabel="1"/>
|
||||
<span class="o_stat_text">Potential</span>
|
||||
</div>
|
||||
</button>
|
||||
</xpath>
|
||||
</data>
|
||||
</field>
|
||||
|
||||
Reference in New Issue
Block a user