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
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
Show 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 @@
...
@@ -6,8 +6,9 @@
Retrieve and display products information to help with future sales - via API or Odoo Menu"""
,
Retrieve and display products information to help with future sales - via API or Odoo Menu"""
,
'description'
:
"""
'description'
:
"""
Display on the product page buttons with Total Losses, Autoconsommation, Employees meals...
Display on the product page buttons with total losses, autoconsommation,
Odoo system parameters need to be set: losses, autoconso and meals locations id
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"
,
'author'
:
"damien.moulard"
,
...
...
lacagette_addons/lacagette_sales_helper/models/product_template.py
View file @
4fd5831c
...
@@ -29,6 +29,7 @@ class ProductTemplate(models.Model):
...
@@ -29,6 +29,7 @@ class ProductTemplate(models.Model):
total_losses_qty
=
fields
.
Float
(
string
=
"Total Pertes"
,
compute
=
'_compute_total_losses_qty'
)
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_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_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
=
"""
sql_stock_move
=
"""
SELECT sum(product_uom_qty) as qty
SELECT sum(product_uom_qty) as qty
...
@@ -41,7 +42,7 @@ class ProductTemplate(models.Model):
...
@@ -41,7 +42,7 @@ class ProductTemplate(models.Model):
@api.multi
@api.multi
def
_compute_total_losses_qty
(
self
):
def
_compute_total_losses_qty
(
self
):
for
product_t
in
self
:
for
product_t
in
self
:
qty
=
-
1
qty
=
0
try
:
try
:
conf
=
self
.
env
[
'ir.config_parameter'
]
conf
=
self
.
env
[
'ir.config_parameter'
]
losses_loc_id
=
conf
.
get_param
(
"lacagette_sales_helper.losses_location_id"
)
losses_loc_id
=
conf
.
get_param
(
"lacagette_sales_helper.losses_location_id"
)
...
@@ -57,7 +58,7 @@ class ProductTemplate(models.Model):
...
@@ -57,7 +58,7 @@ class ProductTemplate(models.Model):
@api.multi
@api.multi
def
_compute_total_autoconso_qty
(
self
):
def
_compute_total_autoconso_qty
(
self
):
for
product_t
in
self
:
for
product_t
in
self
:
qty
=
-
1
qty
=
0
try
:
try
:
conf
=
self
.
env
[
'ir.config_parameter'
]
conf
=
self
.
env
[
'ir.config_parameter'
]
autoconso_loc_id
=
conf
.
get_param
(
"lacagette_sales_helper.autoconso_location_id"
)
autoconso_loc_id
=
conf
.
get_param
(
"lacagette_sales_helper.autoconso_location_id"
)
...
@@ -73,7 +74,7 @@ class ProductTemplate(models.Model):
...
@@ -73,7 +74,7 @@ class ProductTemplate(models.Model):
@api.multi
@api.multi
def
_compute_total_meals_qty
(
self
):
def
_compute_total_meals_qty
(
self
):
for
product_t
in
self
:
for
product_t
in
self
:
qty
=
-
1
qty
=
0
try
:
try
:
conf
=
self
.
env
[
'ir.config_parameter'
]
conf
=
self
.
env
[
'ir.config_parameter'
]
meals_loc_id
=
conf
.
get_param
(
"lacagette_sales_helper.meals_location_id"
)
meals_loc_id
=
conf
.
get_param
(
"lacagette_sales_helper.meals_location_id"
)
...
@@ -87,6 +88,29 @@ class ProductTemplate(models.Model):
...
@@ -87,6 +88,29 @@ class ProductTemplate(models.Model):
product_t
.
total_meals_qty
=
qty
product_t
.
total_meals_qty
=
qty
@api.multi
@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
):
def
view_losses_client_action
(
self
):
return
{
return
{
'res_model'
:
'lacagette.sales_helper'
,
'res_model'
:
'lacagette.sales_helper'
,
...
@@ -112,3 +136,7 @@ class ProductTemplate(models.Model):
...
@@ -112,3 +136,7 @@ class ProductTemplate(models.Model):
'tag'
:
'custom_product_meals'
,
'tag'
:
'custom_product_meals'
,
'target'
:
'new'
,
'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 @@
...
@@ -42,4 +42,18 @@
</div>
</div>
</field>
</field>
</record>
</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>
</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