diff --git a/addons/mrp/report/bom_structure.py b/addons/mrp/report/bom_structure.py
index e6d05648324..ae8599fa5b5 100644
--- a/addons/mrp/report/bom_structure.py
+++ b/addons/mrp/report/bom_structure.py
@@ -1,16 +1,11 @@
-## -*- coding: utf-8 -*-
+# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
-from odoo import models
-from odoo.report import report_sxw
+from odoo import api, models
-class bom_structure(report_sxw.rml_parse):
- def __init__(self, cr, uid, name, context):
- super(bom_structure, self).__init__(cr, uid, name, context=context)
- self.localcontext.update({
- 'get_children': self.get_children,
- })
+class BomStructureReport(models.AbstractModel):
+ _name = 'report.mrp.report_mrpbomstructure'
def get_children(self, object, level=0):
result = []
@@ -26,20 +21,24 @@ class bom_structure(report_sxw.rml_parse):
res['code'] = l.bom_id.code
result.append(res)
if l.child_line_ids:
- if level<6:
+ if level < 6:
level += 1
- _get_rec(l.child_line_ids,level)
- if level>0 and level<6:
+ _get_rec(l.child_line_ids, level)
+ if level > 0 and level < 6:
level -= 1
return result
- children = _get_rec(object,level)
+ children = _get_rec(object, level)
return children
-
-class report_mrpbomstructure(models.AbstractModel):
- _name = 'report.mrp.report_mrpbomstructure'
- _inherit = 'report.abstract_report'
- _template = 'mrp.report_mrpbomstructure'
- _wrapped_report_class = bom_structure
+ @api.multi
+ def render_html(self, docids, data=None):
+ docargs = {
+ 'doc_ids': docids,
+ 'doc_model': 'mrp.bom',
+ 'docs': self.env['mrp.bom'].browse(docids),
+ 'get_children': self.get_children,
+ 'data': data,
+ }
+ return self.env['report'].render('mrp.report_mrpbomstructure', docargs)
diff --git a/addons/mrp/report/mrp_bom_templates.xml b/addons/mrp/report/mrp_bom_templates.xml
index c2730044b3d..80e5eec5fa2 100644
--- a/addons/mrp/report/mrp_bom_templates.xml
+++ b/addons/mrp/report/mrp_bom_templates.xml
@@ -36,7 +36,7 @@
-
+
|
diff --git a/addons/mrp/report/mrp_report_views_main.xml b/addons/mrp/report/mrp_report_views_main.xml
index 4bc22e4d16f..2262a234c91 100644
--- a/addons/mrp/report/mrp_report_views_main.xml
+++ b/addons/mrp/report/mrp_report_views_main.xml
@@ -14,7 +14,7 @@
string="Production Order"
id="action_report_production_order"
model="mrp.production"
- name="mrp.report_mrporder"
+ name="mrp.report_mrporder"
file="mrp.report.mrp_production_templates"
report_type="qweb-pdf"
/>
diff --git a/addons/mrp/tests/test_multicompany.py b/addons/mrp/tests/test_multicompany.py
index 56052b566f0..8a1d1fc3716 100644
--- a/addons/mrp/tests/test_multicompany.py
+++ b/addons/mrp/tests/test_multicompany.py
@@ -8,30 +8,26 @@ class TestMrpMulticompany(common.TransactionCase):
def setUp(self):
super(TestMrpMulticompany, self).setUp()
- cr, uid = self.cr, self.uid
-
- # Usefull models
- self.ir_model_data = self.registry('ir.model.data')
- self.res_users = self.registry('res.users')
- self.stock_location = self.registry('stock.location')
-
- group_user_id = self.registry('ir.model.data').xmlid_to_res_id(cr, uid, 'base.group_user')
- group_stock_manager_id = self.registry('ir.model.data').xmlid_to_res_id(cr, uid, 'stock.group_stock_manager')
- company_2_id = self.registry('ir.model.data').xmlid_to_res_id(cr, uid, 'stock.res_company_1')
- self.multicompany_user_id = self.res_users.create(cr, uid,
- {'name': 'multicomp', 'login': 'multicomp',
- 'groups_id': [(6, 0, [group_user_id, group_stock_manager_id])],
- 'company_id': company_2_id, 'company_ids': [(6,0,[company_2_id])]})
+ group_user = self.env.ref('base.group_user')
+ group_stock_manager = self.env.ref('stock.group_stock_manager')
+ company_2 = self.env.ref('stock.res_company_1')
+ self.multicompany_user_id = self.env['res.users'].create({
+ 'name': 'multicomp',
+ 'login': 'multicomp',
+ 'groups_id': [(6, 0, [group_user.id, group_stock_manager.id])],
+ 'company_id': company_2.id,
+ 'company_ids': [(6, 0, [company_2.id])]
+ })
def test_00_multicompany_user(self):
"""check no error on getting default mrp.production values in multicompany setting"""
- cr, uid, context = self.cr, self.multicompany_user_id, {}
+ StockLocation = self.env['stock.location'].sudo(self.multicompany_user_id)
fields = ['location_src_id', 'location_dest_id']
- defaults = self.stock_location.default_get(cr, uid, ['location_id', 'location_dest_id', 'type'], context)
+ defaults = StockLocation.default_get(['location_id', 'location_dest_id', 'type'])
for field in fields:
if defaults.get(field):
try:
- self.stock_location.check_access_rule(cr, uid, [defaults[field]], 'read', context)
+ StockLocation.check_access_rule([defaults[field]], 'read')
except Exception, exc:
assert False, "unreadable location %s: %s" % (field, exc)
|