Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
O
odoo
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
cooperatic-foodcoops
odoo
Commits
7c83c96a
Commit
7c83c96a
authored
Jun 29, 2021
by
François C.
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add products simple list, to fit with product search in autocomplete list
parent
57044e23
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
0 deletions
+34
-0
products.py
lacagette_addons/lacagette_products/models/products.py
+34
-0
No files found.
lacagette_addons/lacagette_products/models/products.py
View file @
7c83c96a
...
...
@@ -67,3 +67,37 @@ class LaCagetteProducts(models.Model):
@api.model
def
get_barcodes
(
self
,
data
):
return
self
.
get_bc_with_minimun_data
()
@api.model
def
get_simple_list
(
self
,
data
=
{}):
res
=
{}
try
:
sql
=
"""
SELECT
p.id,
p.product_tmpl_id as tpl_id,
(CASE WHEN translation.value IS NULL
THEN t.name
ELSE translation.value
END
) as display_name
FROM
product_product AS p
JOIN product_template AS t ON (p.product_tmpl_id = t.id)
LEFT JOIN ir_translation AS translation ON (t.id = translation.res_id AND translation.name = 'product.template,name')
WHERE p.id IS NOT NULL AND p.active = true
"""
if
'only_purchase_ok'
in
data
:
sql
+=
" AND purchase_ok = true"
self
.
env
.
cr
.
execute
(
sql
)
req_res
=
self
.
env
.
cr
.
dictfetchall
()
res
[
'list'
]
=
[]
for
p
in
req_res
:
for
attr
in
p
.
keys
():
if
p
[
attr
]
is
None
:
p
[
attr
]
=
''
res
[
'list'
]
.
append
(
p
)
except
Exception
as
e
:
res
[
'error'
]
=
str
(
e
)
return
res
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment