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
Paul
odoo
Commits
4fd5831c
Commit
4fd5831c
authored
Apr 02, 2021
by
François C.
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Maj module lacagette_sales_helper
parent
c9fc08cf
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
48 additions
and
5 deletions
+48
-5
__openerp__.py
lacagette_addons/lacagette_sales_helper/__openerp__.py
+3
-2
product_template.py
..._addons/lacagette_sales_helper/models/product_template.py
+31
-3
product_template_view.xml
...ns/lacagette_sales_helper/views/product_template_view.xml
+14
-0
No files found.
lacagette_addons/lacagette_sales_helper/__openerp__.py
View file @
4fd5831c
...
...
@@ -6,8 +6,9 @@
Retrieve and display products information to help with future sales - via API or Odoo Menu"""
,
'description'
:
"""
Display on the product page buttons with Total Losses, Autoconsommation, Employees meals...
Odoo system parameters need to be set: losses, autoconso and meals locations id
Display on the product page buttons with total losses, autoconsommation,
employees meals & and nb of discounts in sales.
\n
These Odoo system parameters need to be set: losses, autoconso and meals locations id.
"""
,
'author'
:
"damien.moulard"
,
...
...
lacagette_addons/lacagette_sales_helper/models/product_template.py
View file @
4fd5831c
...
...
@@ -29,6 +29,7 @@ class ProductTemplate(models.Model):
total_losses_qty
=
fields
.
Float
(
string
=
"Total Pertes"
,
compute
=
'_compute_total_losses_qty'
)
total_autoconso_qty
=
fields
.
Float
(
string
=
"Total Autoconsommation"
,
compute
=
'_compute_total_autoconso_qty'
)
total_meals_qty
=
fields
.
Float
(
string
=
"Total Repas Salariés"
,
compute
=
'_compute_total_meals_qty'
)
total_discounts_qty
=
fields
.
Float
(
string
=
"Total Remises"
,
compute
=
'_compute_total_discounts_qty'
)
sql_stock_move
=
"""
SELECT sum(product_uom_qty) as qty
...
...
@@ -41,7 +42,7 @@ class ProductTemplate(models.Model):
@api.multi
def
_compute_total_losses_qty
(
self
):
for
product_t
in
self
:
qty
=
-
1
qty
=
0
try
:
conf
=
self
.
env
[
'ir.config_parameter'
]
losses_loc_id
=
conf
.
get_param
(
"lacagette_sales_helper.losses_location_id"
)
...
...
@@ -57,7 +58,7 @@ class ProductTemplate(models.Model):
@api.multi
def
_compute_total_autoconso_qty
(
self
):
for
product_t
in
self
:
qty
=
-
1
qty
=
0
try
:
conf
=
self
.
env
[
'ir.config_parameter'
]
autoconso_loc_id
=
conf
.
get_param
(
"lacagette_sales_helper.autoconso_location_id"
)
...
...
@@ -73,7 +74,7 @@ class ProductTemplate(models.Model):
@api.multi
def
_compute_total_meals_qty
(
self
):
for
product_t
in
self
:
qty
=
-
1
qty
=
0
try
:
conf
=
self
.
env
[
'ir.config_parameter'
]
meals_loc_id
=
conf
.
get_param
(
"lacagette_sales_helper.meals_location_id"
)
...
...
@@ -87,6 +88,29 @@ class ProductTemplate(models.Model):
product_t
.
total_meals_qty
=
qty
@api.multi
def
_compute_total_discounts_qty
(
self
):
for
product_t
in
self
:
qty
=
0
try
:
sql
=
"""
SELECT qty
FROM pos_order_line
WHERE product_id = (SELECT id FROM product_product WHERE product_tmpl_id =
%
s)
AND discount > 0
"""
self
.
env
.
cr
.
execute
(
sql
,
[
product_t
.
id
])
req_res
=
self
.
env
.
cr
.
dictfetchall
()
if
len
(
req_res
)
>
0
:
for
i
in
req_res
:
qty
+=
req_res
[
0
][
'qty'
]
qty
=
round
(
qty
,
3
)
except
Exception
as
e
:
print
(
str
(
e
))
product_t
.
total_discounts_qty
=
qty
@api.multi
def
view_losses_client_action
(
self
):
return
{
'res_model'
:
'lacagette.sales_helper'
,
...
...
@@ -112,3 +136,7 @@ class ProductTemplate(models.Model):
'tag'
:
'custom_product_meals'
,
'target'
:
'new'
,
}
@api.multi
def
view_discounts_client_action
(
self
):
return
0
;
lacagette_addons/lacagette_sales_helper/views/product_template_view.xml
View file @
4fd5831c
...
...
@@ -42,4 +42,18 @@
</div>
</field>
</record>
<record
id=
"view_template_discount_history_form"
model=
"ir.ui.view"
>
<field
name=
"model"
>
product.template
</field>
<field
name=
"inherit_id"
ref=
"product.product_template_form_view"
/>
<field
name=
"arch"
type=
"xml"
>
<div
name=
"button_box"
position=
"inside"
>
<button
name=
"view_discounts_client_action"
type=
"object"
icon=
"fa-dollar"
class=
"oe_stat_button display_discounts_stats"
groups=
"stock.group_stock_manager"
string=
""
>
<field
name=
"total_discounts_qty"
widget=
"statinfo"
/>
</button>
</div>
</field>
</record>
</odoo>
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