[MIG] mrp: migrate remaining code in new API and transform rml report into standard report
rml_parse report bom_structure is translated into standard web report
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
<span t-esc="l['pname']"/>
|
||||
</td>
|
||||
<td>
|
||||
<span t-esc="formatLang(l['pqty'])"/>
|
||||
<span t-esc="l['pqty']"/>
|
||||
<span t-esc="l['uname']" groups="product.group_uom"/>
|
||||
</td>
|
||||
<td>
|
||||
|
||||
@@ -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"
|
||||
/>
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user