Created
March 11, 2024 07:59
-
-
Save em230418/d958fddeaa85b7cc31be98047bf4cfff to your computer and use it in GitHub Desktop.
product_id to selection
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- if "project_expense_type" in res and "selection" in attributes: | |
- self.env.cr.execute( | |
- f""" | |
-SELECT DISTINCT t.project_expense_type | |
-FROM {self._table} t | |
-LEFT JOIN product_product p ON p.id = t.project_expense_type | |
-LEFT JOIN product_template pt ON pt.id = p.product_tmpl_id | |
-WHERE project_expense_type IS NOT NULL | |
- """ | |
- ) | |
- get_product_name = lambda x: self.env["product.product"].browse(x).name | |
- | |
- selections = [(x[0], get_product_name(x[0])) for x in self.env.cr.fetchall()] | |
- res["project_expense_type"].update( | |
- { | |
- "type": "selection", | |
- "selection": selections, | |
- } | |
- ) | |
- print(selections) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment