In python if I would like to concatenate a string and a number i need just a simple syntax like
product_id = 1
product = 'product.product,' + str(product_id)
print product
to get as a result
product = product.product,1
In a module for Odoo 10 I have:
@api.depends('price_unit', 'qty')
def _compute_cst_line(self):
sql_std_cst = 'SELECT value_float FROM ir_property WHERE res_id = %s'
for record in self:
product = 'product.product,' + str(record.product_id)
self.env.cr.execute(sql_std_cst,[product])
###############more stuff here###############
_logger.info('product = %s, product)
And as a result I get
product = product.product,product.product(1,)
As a temporary workaround I'm using 're' for extracting the numbers:
import re
self.env.cr.execute(sql_std_cst,['product.product,'
+ str(re.findall(r'\d+', str(record.product_id))[0])])
But I'm still curious to know what is the correct syntax.
EDIT - Solved with:
self.env.cr.execute(sql_std_cst,['product.product,' + str(record.product_id.id)])