I'm trying to constraint the domain of a many 2 one field using an external id (The XML id).
I want to be able to choose product which are variant of a specific product template.
#This piece of code doesn't work
the_field = fields.Many2one('product.product', domain = [('product_tmpl_id','=', "ref('the_package.the_external_id')")])
The code above doesn't work for some reason. But I've been able to look in the database to resolve the external id and it's 56. With that knowledge, I've been able to hardcode the following line and make everything work.
#This piece of code works, but it's hardcoded
the_field = fields.Many2one('product.product', domain = [('product_tmpl_id','=', 56)])
How can I do to solve this using the External id and not the hardcoded id in database?
EDIT: I cannot access all the self variables (self.env, self.pool, ...) since I'm in a static context.