How can I print the map values ​in a list? i use kotlin, springboot, jpa, jsp - kotlin

Using jpa join in kotlin, model and view objects are passed to jsp.
i return
changeSiseList=[TbExchangeQuoteLast(sign=USD, tbExchangeMeta=TbExchangeMeta(sign=USD, nationNm=United States, nationEngNm=U.S.A., currencyNm=Dollar, currencyEngNm=US.DLRS, currencyBasis=1, order=1), date=20230131, time=100206, degreeCount=71, saleBaseRate=1230.0, cashBuyingVal=1251.52, cashSellingVal=1208.48, sendMoneyVal=1242.0, receiveMoneyVal=1218.0, travelerCheckBuyingVal=null, foreignCheckSellingVal=1215.81, change=1FeeRate=6.418, changeRate=1218.0, usdConvertingRate=6.418, usd 0.0), TbExchangeQuoteLast(sign=JPY, tbExchangeMeta=TbExchangeMeta(sign=JPY, nationNm=Japan, nationEngNm=JAPAN, currencyNm=JPY, currencyEngNm=YEN, currencyBasis=100, order=3), date=20230131, time=100206, degreeCount=71, saleBaseRate=944.52, cashBuyingVal=961.04, cashSellingVal=928.0, sendMoneyVal=953.77, receiveMoneyVal=935.27, travelerCheckBuyingVal=null, foreignCheckSellingVal=934.8, exchangeFeeRate=2.027, usdConvertingRate=0.10.0.1)changeVal=1.768, changeVal=1.768 , TbExchangeQuoteLast(sign=EUR, tbExchangeMeta=TbExchan geMeta(sign=EUR, nationNm=EU, nationEngNm=EUROPEAN UNION, currencyNm=Euro, currencyEngNm=E.CUR.UNIT, currencyBasis=1, order=2), date=20230131, time=100206, degreeCount=71, saleBaseRate =1334.86, cashBuyingVal=1361.42, cashSellingVal=1308.3, sendMoneyVal=1348.2, receiveMoneyVal=1321.52, travelerCheckBuyingVal=null, foreignCheckSellingVal=1320.0, exchangeFeeRate=4.105, usdConvertingRate=1.085, changeVal=-4.73, changeRate=-0.35), TbExchangeQuoteLast(sign= CAD, tbExchangeMeta=TbExchangeMeta(sign=CAD, nationNm=Canada, nationEngNm=CANADA, currencyNm=Dollar, currencyEngNm=CAN.DLRS, currencyBasis=1, order=9), date=20230131, time=100206, degreeCount=71, saleBaseRate =918.9, cashBuyingVal=937.0, cashSellingVal=900.8, sendMoneyVal=928.08, receiveMoneyVal=909.72, travelerCheckBuyingVal=null, foreignCheckSellingVal=908.06, exchangeFeeRate=6.522, usdConvertingRate=0.747, changeVal=-3.60, changeQuote.Lastbchange=9 GBP, tbExchangeMeta=TbExchangeMeta(sign=GBP, nationNm=UK, nationEngNm=ENGLAND, currencyNm=pound, currencyEngNm=POUND STR., currencyBasis=1, order=7), date=20230131, time=100206, degreeCount=71, saleBaseRate=1520.46, cashBuyingVal=1550.41,
When an object such as is received, the saleBaseRate value can be output as ${list.saleBaseRate}, but the nationNm value in TbExchangeQuoteLast cannot be output.
${list.ExchangeAllSiseList.TbExchangeQuoteLast.nationNm} or
${list.ExchangeAllSiseList.TbExchangeQuoteLast[nationNm]}
The above method failed.

Related

How to add custom field value in Odoo Invoice sequence in Odoo 9

I was trying to add custom field into Invoice number sequence.
So the field I added was a many2one field or selection field whose value needs to be appended to the Invoice sequence.
The field is in account.invoice class
seq_pat = fields.Many2one('account.sequence.new','Sequence Pattern')
Other way I was trying is by overriding ir.sequence class method which creates the legends in sequences.
class ir_sequence(osv.osv):
_inherit = 'ir.sequence'
def _interpolation_dict_context(self, context=None):
if context is None:
context = {}
test1 = self.pool.get('account.invoice').browse()
test = test1.seq_pat.name
t = datetime.now(pytz.timezone(context.get('tz') or 'UTC'))
sequences = {
'year': '%Y', 'month': '%m', 'day': '%d', 'y': '%y', 'doy': '%j', 'woy': '%W',
'weekday': '%w', 'h24': '%H', 'h12': '%I', 'min': '%M', 'sec': '%S',
'pattern': '%P'
}
return {key: t.strftime(sequence) for key, sequence in sequences.iteritems()}
which succeeded in making it to the legends section of Odoo.
But I am stuck with how to get my field recognised by ir.sequence.
Anyone with any other idea to achieve this would be really helpful.

Openerp dynamic domain filter

On my class folder a have many goods and many amounts. I need to use a domain filter on my field good_id of class amount, on that field I need to show the list of my object folder's goods.
so I create a function on my amount class (_get_folder_list_goods) that returns the list of folder's goods and I add a domain attribute on my field good_id of class amount.
here are my classes:
class folder(osv.osv):
_name = 'folder'
_columns = {
'name' : fields.char(u'Numéro',size=50, readonly=True),
'goods_ids': fields.many2many('good', 'doss_bien_rel', 'folder_id', 'good_id', 'Goods'),
'amount_id': fields.one2many('amount', 'folder_id', 'Amounts'),
....}
class good(osv.osv):
_name = 'good'
_columns = {
'name' : fields.function(_name_get_fnc, type="char", string=u''),
....}
class amount(osv.osv):
_name = 'amount'
def _get_folder_list_biens(self, cr, uid,folder_id, context={}):
liste_goods=[]
object_folder = self.pool.get('folder').browse(cr,uid,folder_id,context)
if object_folder.goods_ids:
for good in object_folder.goods_ids:
liste_goods.append(good.id)
return liste_goods
_columns = {
'folder_id': fields.many2one('folder', 'Ref folder', select=True),
'good_id':fields.many2one('good', Goos',domain="[('id', 'in', _get_folder_list_biens(folder_id))]"),
}
I got this error:
Uncaught Error: NameError: name '_get_folder_list_biens' is not defined
The domain is used on the client when the user starts to key (or lookup) and Good and it (the client) knows nothing about this method. What you need to do is create a functional field of type many2one that calls _get_folder_list_biens and returns a list of ids. Put the new functional field on your form as invisible and then make your domain ('id', 'in', my_functional_field)

OpenERP - Field many2one, in inherited class, returning empty rows

I want to display many2one, x_categ_id, field in inherited mrp.bom class. I have defined it in _columns{..} but I am getting empty values, in the table mrp_bom, for that column, i.e. "x_categ_id". I must be missing something? Any insights are greatly appreciated.
class mrp_bom(osv.osv):
_inherit = 'mrp.bom'
_name = 'mrp.bom'
_columns = {
'x_categ_id': fields.many2one('product.category','Item Class',
required=True, change_default=True),
}
What do you actually want to display? If you want to display the contents of BOM, you can just do this:
'product_id': fields.related('bom_id', 'product_id', type="many2one",relation='product.product', readonly=True, string="Product"),
'cost_price': fields.related('product_id', 'standard_price',type="float",digits_compute=dp.get_precision('Product Price'), store=False, readonly=True, string="Cost Price"),
'margin': fields.float('Margin',digits_compute=dp.get_precision('Product Price'),required=True),
'quantity': fields.float('Quantity',digits_compute=dp.get_precision('Product Unit of Measu re'),readonly=True),
'bom_id': fields.many2one('mrp.bom', 'Bom', readonly=True)

OpenERP - which field is getting the value from overridden name_get() function?

I hope this question makes sense. My goal is to display field as defined in name_get(). I have overridden name_get() function in mrp_bom class, code attached. However, I don't know which field will get return value from the function name_get(). Any insight is greatly appreciated!
class mrp_bom(osv.osv):
_inherit = 'mrp.bom'
_name = 'mrp.bom'
_columns = {
'x_nk_default_code': fields.related('product_id', 'default_code',
type='char', relation='product.product',
string='Part Number', store=True,
readonly=True),
'x_nk_class_desc': fields.related('product_id', 'categ_id', 'name',
type='char', string='Class Description',
store=True, readonly=True),
'x_nk_item_desc': fields.related('product_tmpl_id', 'name',
type='char', relation='product.template',
string='Item Description', store=True,
readonly=True),
'categ_id': fields.related('product_id', 'categ_id', type='integer',
relation='product.product', string='Categ_ID',
store=True, readonly=True),
'x_category_code': fields.related('product_id', 'categ_id',
'x_category_code', type='char', string='Class
Description', store=True, readonly=True),
}
def name_get(self, cr, user, ids, context=None):
if context is None:
context = {}
if isinstance(ids, (int, long)):
ids = [ids]
if not len(ids):
return []
def _name_get(d):
name = d.get('name','')
code = context.get('display_default_code', True) and
d.get('x_category_code',False) or False
if code:
name = '[%s] %s' % (code,name)
return (d['id'], name)
result = []
for product_category in self.browse(cr, user, ids, context=context):
mydict = {
'id': product_category.id,
'name': product_category.name,
'x_category_code':
product_category.x_category_code,
}
result.append(_name_get(mydict))
return result
The name_get method is used to display value of a record in a many2one field. For example, in a sale order line, if you select a product, the value displayed in the sale order line for the field 'product_id' must be the result of the 'name_get' on the product.product object.
There is no special field to display the result of name_get. If you need to put the result of name_get method in a field of a record, you should create with an attribute 'compute' : http://odoo-new-api-guide-line.readthedocs.org/en/latest/fields.html#computed-fields
You can find more information here : http://odoo-new-api-guide-line.readthedocs.org/en/latest/environment.html?highlight=name_get
I hope this help you.

Openerp - AttributeError in function of stock.picking.in

Really struggling with this one:
I have inherited from stock.picking.in and have added a few columns. I then added a function field.
In the function that the function field refers to, it works if I do not use any attribute from the stock.picking.in object. The moment I use any value from the object, it starts giving 'AttributeError: ' and some attribute at random. It doesn't specify any other reasons or causes.
Code:
class stock_picking_custom(osv.osv):
_name = 'stock.picking.in'
_inherit = 'stock.picking.in'
_table = "stock_picking"
def calc_royalty(self, cr, uid, ids, field_name, arg, context=None):
if not ids: return {}
res = {}
for line in self.browse(cr, uid, ids, context=context):
res[line.id] = 0 #line.royalty_rate * line.loading_netweight
return res
_columns = {
'loading_netweight': fields.float('Net weight at loading', digits=(16,2), help="Net weight at loading (interior weight)"),
'royalty_date': fields.date('Royalty Issue date'),
'royalty_number' : fields.char('Royalty Number', size=64),
'royalty_rate' : fields.float('Royalty Rate (p. ton)', digits=(16,2)),
'royalty_amount' : fields.function(calc_royalty, type='float', digits=(16,2), string='Royalty Amount', store=True, select=True)
}
stock_picking_custom()
I have commented out the line that I want to use. The moment I put this line back in the code, it would give attribute error on royalty_date (for example) which is not even mentioned in the function.
Please guide.
EDIT: I tried the exact same code with purchase.order and it works perfectly. What is different about stock.picking.in?
Thanks
Ok, found the answer in stock module in delivery addon. So this is a framework limitation issue related to inheritance order etc.
Sharing here in case someone ends up in a similar situation.
To solve, I repeated the same fields in stock.picking and stock.picking.in. Then I called the calc function of the picking class from the picking.in class.
Code:
class stock_picking_custom(osv.osv):
_name = 'stock.picking'
_inherit = 'stock.picking'
def calc_royalty(self, cr, uid, ids, field_name, arg, context=None):
if not ids: return {}
res = {}
for line in self.browse(cr, uid, ids, context=context):
res[line.id] = line.royalty_rate * line.loading_netweight
return res
_columns = {
'loading_netweight': fields.float('Net weight at loading', digits=(16,2), help="Net weight at loading (interior weight)"),
'royalty_date': fields.date('Royalty Issue date'),
'royalty_number' : fields.char('Royalty Number', size=64),
'royalty_rate' : fields.float('Royalty Rate (p. ton)', digits=(16,2)),
'royalty_amount' : fields.function(calc_royalty, type='float', digits=(16,2), string='Royalty Amount', store=True, select=True)
}
stock_picking_custom()
class stock_picking_in_custom(osv.osv):
_name = 'stock.picking.in'
_inherit = 'stock.picking.in'
_table = "stock_picking"
def calc_royalty(self, cr, uid, ids, field_name, arg, context=None):
return self.pool.get('stock.picking').calc_royalty(cr,uid,ids,field_name,arg,context=context)
_columns = {
'loading_netweight': fields.float('Net weight at loading', digits=(16,2), help="Net weight at loading (interior weight)"),
'royalty_date': fields.date('Royalty Issue date'),
'royalty_number' : fields.char('Royalty Number', size=64),
'royalty_rate' : fields.float('Royalty Rate (p. ton)', digits=(16,2)),
'royalty_amount' : fields.function(calc_royalty, type='float', digits=(16,2), string='Royalty Amount', store=True, select=True)
}
stock_picking_in_custom()
I did not get much time to spend on it but I came to know that line is coming with stock.picking.in object and fields, you defined, are stored in stock_picking table that's why it may going to search that field with stock.picking.in, not getting and error is coming.
There may be issue with fields defined in object and table, but not sure.