mirror of
https://github.com/OCA/stock-logistics-reporting.git
synced 2025-02-16 17:13:21 +02:00
[IMP] stock_picking_report_summary: apply pre-commit auto fixes
This commit is contained in:
@@ -0,0 +1 @@
|
||||
../../../../stock_picking_report_summary
|
||||
6
setup/stock_picking_report_summary/setup.py
Normal file
6
setup/stock_picking_report_summary/setup.py
Normal file
@@ -0,0 +1,6 @@
|
||||
import setuptools
|
||||
|
||||
setuptools.setup(
|
||||
setup_requires=['setuptools-odoo'],
|
||||
odoo_addon=True,
|
||||
)
|
||||
@@ -6,8 +6,7 @@
|
||||
"name": "Stock Picking Report Summary",
|
||||
"summary": "Stock Picking Report Summary",
|
||||
"version": "12.0.1.1.0",
|
||||
"author": "Grap, "
|
||||
"Odoo Community Association (OCA)",
|
||||
"author": "Grap, " "Odoo Community Association (OCA)",
|
||||
"maintainers": ["quentinDupont", "legalsylvain"],
|
||||
"website": "https://github.com/OCA/stock-logistics-reporting",
|
||||
"category": "Warehouse Management",
|
||||
@@ -15,12 +14,12 @@
|
||||
"depends": [
|
||||
"stock",
|
||||
],
|
||||
'data': [
|
||||
'reports/report_paperformat.xml',
|
||||
'reports/report_print_picking_summary.xml',
|
||||
'reports/report_print_picking_summary_template.xml',
|
||||
'views/view_picking_summary_wizard.xml',
|
||||
'views/action.xml',
|
||||
"data": [
|
||||
"reports/report_paperformat.xml",
|
||||
"reports/report_print_picking_summary.xml",
|
||||
"reports/report_print_picking_summary_template.xml",
|
||||
"views/view_picking_summary_wizard.xml",
|
||||
"views/action.xml",
|
||||
],
|
||||
"installable": True,
|
||||
}
|
||||
|
||||
@@ -3,87 +3,104 @@
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||
|
||||
from odoo import api, fields, models
|
||||
|
||||
from odoo.addons import decimal_precision as dp
|
||||
|
||||
|
||||
class PickingSummaryWizard(models.TransientModel):
|
||||
_name = 'picking.summary.wizard'
|
||||
_description = 'Picking Summary Wizard'
|
||||
_name = "picking.summary.wizard"
|
||||
_description = "Picking Summary Wizard"
|
||||
|
||||
# Columns Section
|
||||
print_summary = fields.Boolean(
|
||||
string='Print Summary', default=True)
|
||||
print_summary = fields.Boolean(string="Print Summary", default=True)
|
||||
|
||||
print_detail = fields.Boolean(
|
||||
string='Print Detail', default=True)
|
||||
print_detail = fields.Boolean(string="Print Detail", default=True)
|
||||
|
||||
print_unity_in_list = fields.Boolean(
|
||||
string='Print Unit in Pickings List', default=True)
|
||||
string="Print Unit in Pickings List", default=True
|
||||
)
|
||||
|
||||
print_prices = fields.Boolean(
|
||||
string='Print Standard Prices', default=False)
|
||||
print_prices = fields.Boolean(string="Print Standard Prices", default=False)
|
||||
|
||||
product_line_ids = fields.One2many(
|
||||
comodel_name='picking.summary.wizard.product',
|
||||
inverse_name='wizard_id',
|
||||
default=lambda self: self._default_product_line_ids())
|
||||
comodel_name="picking.summary.wizard.product",
|
||||
inverse_name="wizard_id",
|
||||
default=lambda self: self._default_product_line_ids(),
|
||||
)
|
||||
|
||||
standard_price_total = fields.Float(
|
||||
compute='_compute_standard_price_total',
|
||||
digits=dp.get_precision('Product Price'))
|
||||
compute="_compute_standard_price_total",
|
||||
digits=dp.get_precision("Product Price"),
|
||||
)
|
||||
|
||||
picking_line_ids = fields.One2many(
|
||||
comodel_name='picking.summary.wizard.picking',
|
||||
inverse_name='wizard_id',
|
||||
default=lambda self: self._default_picking_line_ids())
|
||||
comodel_name="picking.summary.wizard.picking",
|
||||
inverse_name="wizard_id",
|
||||
default=lambda self: self._default_picking_line_ids(),
|
||||
)
|
||||
|
||||
picking_line_qty = fields.Integer(
|
||||
string='Number of Selected Picking', readonly=True,
|
||||
default=lambda self: self._default_picking_line_qty())
|
||||
string="Number of Selected Picking",
|
||||
readonly=True,
|
||||
default=lambda self: self._default_picking_line_qty(),
|
||||
)
|
||||
|
||||
# Default Section
|
||||
def _default_picking_line_qty(self):
|
||||
return len(self._context.get('active_ids', []))
|
||||
return len(self._context.get("active_ids", []))
|
||||
|
||||
def _default_picking_line_ids(self):
|
||||
picking_obj = self.env['stock.picking']
|
||||
picking_obj = self.env["stock.picking"]
|
||||
res = []
|
||||
picking_ids = self._context.get('active_ids', [])
|
||||
picking_ids = self._context.get("active_ids", [])
|
||||
for picking in picking_obj.browse(picking_ids):
|
||||
res.append((0, 0, {
|
||||
'picking_id': picking.id,
|
||||
}))
|
||||
res.append(
|
||||
(
|
||||
0,
|
||||
0,
|
||||
{
|
||||
"picking_id": picking.id,
|
||||
},
|
||||
)
|
||||
)
|
||||
return res
|
||||
|
||||
def _default_product_line_ids(self):
|
||||
picking_obj = self.env['stock.picking']
|
||||
picking_obj = self.env["stock.picking"]
|
||||
res = []
|
||||
product_lines = {}
|
||||
picking_ids = self.env.context.get('active_ids', [])
|
||||
picking_ids = self.env.context.get("active_ids", [])
|
||||
# move.product_qty is real quantity with referent uom
|
||||
for picking in picking_obj.browse(picking_ids):
|
||||
for move in picking.move_lines:
|
||||
if move.product_id.id not in product_lines.keys():
|
||||
product_lines[move.product_id.id] = {
|
||||
'name': move.product_id.name,
|
||||
'categ': move.product_id.categ_id.name.capitalize(),
|
||||
'qty': move.product_qty
|
||||
"name": move.product_id.name,
|
||||
"categ": move.product_id.categ_id.name.capitalize(),
|
||||
"qty": move.product_qty,
|
||||
}
|
||||
else:
|
||||
old_qty = product_lines[move.product_id.id]['qty']
|
||||
old_qty = product_lines[move.product_id.id]["qty"]
|
||||
product_lines[move.product_id.id] = {
|
||||
'name': move.product_id.name,
|
||||
'categ': move.product_id.categ_id.name.capitalize(),
|
||||
'qty': old_qty + move.product_qty
|
||||
"name": move.product_id.name,
|
||||
"categ": move.product_id.categ_id.name.capitalize(),
|
||||
"qty": old_qty + move.product_qty,
|
||||
}
|
||||
# Arranged in alphabetical order for category then product name
|
||||
product_lines_sorted = sorted(
|
||||
product_lines.items(), key=lambda x: (x[1]['categ'], x[1]['name']))
|
||||
product_lines.items(), key=lambda x: (x[1]["categ"], x[1]["name"])
|
||||
)
|
||||
for product_id, name_qty in product_lines_sorted:
|
||||
res.append((0, 0, {
|
||||
'product_id': product_id,
|
||||
'quantity_total': name_qty['qty'],
|
||||
}))
|
||||
res.append(
|
||||
(
|
||||
0,
|
||||
0,
|
||||
{
|
||||
"product_id": product_id,
|
||||
"quantity_total": name_qty["qty"],
|
||||
},
|
||||
)
|
||||
)
|
||||
return res
|
||||
|
||||
# Compute Section
|
||||
@@ -91,4 +108,5 @@ class PickingSummaryWizard(models.TransientModel):
|
||||
def _compute_standard_price_total(self):
|
||||
self.ensure_one()
|
||||
self.standard_price_total = sum(
|
||||
self.mapped('product_line_ids.standard_price_total'))
|
||||
self.mapped("product_line_ids.standard_price_total")
|
||||
)
|
||||
|
||||
@@ -6,9 +6,9 @@ from openerp import fields, models
|
||||
|
||||
|
||||
class PickingSummaryWizardPicking(models.TransientModel):
|
||||
_name = 'picking.summary.wizard.picking'
|
||||
_description = 'Picking Summary Wizard Picking'
|
||||
_name = "picking.summary.wizard.picking"
|
||||
_description = "Picking Summary Wizard Picking"
|
||||
|
||||
wizard_id = fields.Many2one(comodel_name='picking.summary.wizard')
|
||||
wizard_id = fields.Many2one(comodel_name="picking.summary.wizard")
|
||||
|
||||
picking_id = fields.Many2one(comodel_name='stock.picking')
|
||||
picking_id = fields.Many2one(comodel_name="stock.picking")
|
||||
|
||||
@@ -3,29 +3,32 @@
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||
|
||||
from odoo import api, fields, models
|
||||
|
||||
from odoo.addons import decimal_precision as dp
|
||||
|
||||
|
||||
class PickingSummaryWizardProduct(models.TransientModel):
|
||||
_name = 'picking.summary.wizard.product'
|
||||
_description = 'Picking Summary Wizard Product'
|
||||
_name = "picking.summary.wizard.product"
|
||||
_description = "Picking Summary Wizard Product"
|
||||
|
||||
wizard_id = fields.Many2one(comodel_name='picking.summary.wizard')
|
||||
wizard_id = fields.Many2one(comodel_name="picking.summary.wizard")
|
||||
|
||||
product_id = fields.Many2one(comodel_name='product.product')
|
||||
product_id = fields.Many2one(comodel_name="product.product")
|
||||
|
||||
quantity_total = fields.Float()
|
||||
|
||||
standard_price = fields.Float(
|
||||
related='product_id.standard_price',
|
||||
digits=dp.get_precision('Product Price'))
|
||||
related="product_id.standard_price", digits=dp.get_precision("Product Price")
|
||||
)
|
||||
|
||||
standard_price_total = fields.Float(
|
||||
compute='_compute_standard_price_total',
|
||||
digits=dp.get_precision('Product Price'))
|
||||
compute="_compute_standard_price_total",
|
||||
digits=dp.get_precision("Product Price"),
|
||||
)
|
||||
|
||||
@api.multi
|
||||
def _compute_standard_price_total(self):
|
||||
for line in self:
|
||||
line.standard_price_total =\
|
||||
line.standard_price_total = (
|
||||
line.product_id.standard_price * line.quantity_total
|
||||
)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<?xml version="1.0"?>
|
||||
<?xml version="1.0" ?>
|
||||
<!-- Copyright (C) 2020 - Today: GRAP (http://www.grap.coop)
|
||||
@author: Quentin DUPONT (quentin.dupont@grap.coop)
|
||||
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<odoo>
|
||||
<report
|
||||
id="report_picking_summary"
|
||||
|
||||
@@ -1,22 +1,25 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<odoo>
|
||||
<template id="picking_summary">
|
||||
<t t-call="web.basic_layout">
|
||||
<t t-foreach="docs" t-as="picking_w">
|
||||
<style type="text/css">
|
||||
table, th, td {
|
||||
border: 1px solid #4a4a4a;
|
||||
width:100%;
|
||||
}
|
||||
h1 {
|
||||
text-align:center;
|
||||
}
|
||||
th, td {
|
||||
padding: 8px;
|
||||
}
|
||||
.align-center{
|
||||
text-align:center;
|
||||
}
|
||||
table,
|
||||
th,
|
||||
td {
|
||||
border: 1px solid #4a4a4a;
|
||||
width: 100%;
|
||||
}
|
||||
h1 {
|
||||
text-align: center;
|
||||
}
|
||||
th,
|
||||
td {
|
||||
padding: 8px;
|
||||
}
|
||||
.align-center {
|
||||
text-align: center;
|
||||
}
|
||||
</style>
|
||||
<!-- Summary Part -->
|
||||
<p t-if="picking_w.print_summary">
|
||||
@@ -28,26 +31,51 @@
|
||||
<th>Category</th>
|
||||
<th class="align-center">Quantity</th>
|
||||
<th class="align-center">Unity</th>
|
||||
<th t-if="picking_w.print_prices" class="align-center">Standard Unit Price</th>
|
||||
<th t-if="picking_w.print_prices" class="align-center">Total price</th>
|
||||
<th
|
||||
t-if="picking_w.print_prices"
|
||||
class="align-center"
|
||||
>Standard Unit Price</th>
|
||||
<th
|
||||
t-if="picking_w.print_prices"
|
||||
class="align-center"
|
||||
>Total price</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<t t-foreach="picking_w.product_line_ids" t-as="product_line">
|
||||
<t
|
||||
t-foreach="picking_w.product_line_ids"
|
||||
t-as="product_line"
|
||||
>
|
||||
<tr>
|
||||
<td><span t-field="product_line.product_id.name"/></td>
|
||||
<td><span t-esc="product_line.product_id.categ_id.name.capitalize()"/></td>
|
||||
<td><span
|
||||
t-field="product_line.product_id.name"
|
||||
/></td>
|
||||
<td><span
|
||||
t-esc="product_line.product_id.categ_id.name.capitalize()"
|
||||
/></td>
|
||||
<td class="align-center">
|
||||
<span t-field="product_line.quantity_total"/>
|
||||
<span t-field="product_line.quantity_total" />
|
||||
</td>
|
||||
<td class="align-center">
|
||||
<span t-field="product_line.product_id.uom_id.name"/>
|
||||
<span
|
||||
t-field="product_line.product_id.uom_id.name"
|
||||
/>
|
||||
</td>
|
||||
<td t-if="picking_w.print_prices" class="align-center">
|
||||
<span t-esc="product_line.product_id.standard_price"/>
|
||||
<td
|
||||
t-if="picking_w.print_prices"
|
||||
class="align-center"
|
||||
>
|
||||
<span
|
||||
t-esc="product_line.product_id.standard_price"
|
||||
/>
|
||||
</td>
|
||||
<td t-if="picking_w.print_prices" class="align-center">
|
||||
<span t-esc="product_line.standard_price_total"/>
|
||||
<td
|
||||
t-if="picking_w.print_prices"
|
||||
class="align-center"
|
||||
>
|
||||
<span
|
||||
t-esc="product_line.standard_price_total"
|
||||
/>
|
||||
</td>
|
||||
</tr>
|
||||
</t>
|
||||
@@ -56,7 +84,9 @@
|
||||
<tr>
|
||||
<th colspan="5">Standard Price Total</th>
|
||||
<td class="align-center">
|
||||
<span t-esc="round(picking_w.standard_price_total,2)"/>
|
||||
<span
|
||||
t-esc="round(picking_w.standard_price_total,2)"
|
||||
/>
|
||||
</td>
|
||||
</tr>
|
||||
</tfoot>
|
||||
@@ -71,26 +101,47 @@
|
||||
<tr>
|
||||
<th>Product</th>
|
||||
<th class="align-center">Quantity</th>
|
||||
<th t-if="picking_w.print_unity_in_list" class="align-center">Unity</th>
|
||||
<th
|
||||
t-if="picking_w.print_unity_in_list"
|
||||
class="align-center"
|
||||
>Unity</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<t t-foreach="picking_w.picking_line_ids" t-as="picking_line">
|
||||
<t
|
||||
t-foreach="picking_w.picking_line_ids"
|
||||
t-as="picking_line"
|
||||
>
|
||||
<tr class="line" style="background-color:#ddd">
|
||||
<th colspan="3"><span t-field="picking_line.picking_id.partner_id.name" /> - <span t-field="picking_line.picking_id.name" /></th>
|
||||
<th colspan="3"><span
|
||||
t-field="picking_line.picking_id.partner_id.name"
|
||||
/> - <span
|
||||
t-field="picking_line.picking_id.name"
|
||||
/></th>
|
||||
</tr>
|
||||
<t t-foreach="picking_line.picking_id.move_lines" t-as="move_line">
|
||||
<t
|
||||
t-foreach="picking_line.picking_id.move_lines"
|
||||
t-as="move_line"
|
||||
>
|
||||
|
||||
<t t-set="td_move_style" t-value="move_line.product_qty == 0 and 'border:1px black solid; color:gray;' or 'border:1px black solid; color:black;'"/>
|
||||
<t
|
||||
t-set="td_move_style"
|
||||
t-value="move_line.product_qty == 0 and 'border:1px black solid; color:gray;' or 'border:1px black solid; color:black;'"
|
||||
/>
|
||||
<tr t-att-style="td_move_style">
|
||||
<td>
|
||||
<span t-field="move_line.product_id.name"/>
|
||||
<span t-field="move_line.product_id.name" />
|
||||
</td>
|
||||
<td class="align-center">
|
||||
<span t-field="move_line.product_qty"/>
|
||||
<span t-field="move_line.product_qty" />
|
||||
</td>
|
||||
<td t-if="picking_w.print_unity_in_list" class="align-center">
|
||||
<span t-field="move_line.product_id.uom_id.name"/>
|
||||
<td
|
||||
t-if="picking_w.print_unity_in_list"
|
||||
class="align-center"
|
||||
>
|
||||
<span
|
||||
t-field="move_line.product_id.uom_id.name"
|
||||
/>
|
||||
</td>
|
||||
</tr>
|
||||
</t>
|
||||
@@ -98,7 +149,9 @@
|
||||
<t t-if="picking_line.picking_id.note">
|
||||
<tr class="line">
|
||||
<td colspan="100%">
|
||||
<span t-field="picking_line.picking_id.note" />
|
||||
<span
|
||||
t-field="picking_line.picking_id.note"
|
||||
/>
|
||||
</td>
|
||||
</tr>
|
||||
</t>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!--
|
||||
Copyright (C) 2018 - Today: GRAP (http://www.grap.coop)
|
||||
@author: Sylvain LE GAL (https://twitter.com/legalsylvain)
|
||||
@@ -12,7 +12,7 @@ License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">form</field>
|
||||
<field name="target">new</field>
|
||||
<field name="binding_model_id" ref="stock.model_stock_picking"/>
|
||||
<field name="binding_model_id" ref="stock.model_stock_picking" />
|
||||
</record>
|
||||
|
||||
</data></odoo>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!--
|
||||
Copyright (C) 2014 - Today: GRAP (http://www.grap.coop)
|
||||
@author: Sylvain LE GAL (https://twitter.com/legalsylvain)
|
||||
@@ -13,20 +13,32 @@ License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||
<form string="Print Product Summary">
|
||||
<group colspan="4">
|
||||
<group string="General Parameters">
|
||||
<field name="picking_line_qty"/>
|
||||
<field name="picking_line_qty" />
|
||||
</group>
|
||||
<group string="Summary" colspan="2">
|
||||
<field name="print_summary"/>
|
||||
<field name="print_prices" attrs="{'invisible': [('print_summary', '=', False)]}"/>
|
||||
<field name="print_summary" />
|
||||
<field
|
||||
name="print_prices"
|
||||
attrs="{'invisible': [('print_summary', '=', False)]}"
|
||||
/>
|
||||
</group>
|
||||
<group string="Pickings Details" colspan="2">
|
||||
<field name="print_detail"/>
|
||||
<field name="print_unity_in_list" attrs="{'invisible': [('print_detail', '=', False)]}"/>
|
||||
<field name="print_detail" />
|
||||
<field
|
||||
name="print_unity_in_list"
|
||||
attrs="{'invisible': [('print_detail', '=', False)]}"
|
||||
/>
|
||||
</group>
|
||||
</group>
|
||||
<footer>
|
||||
<button name="%(report_picking_summary)d" string="Print Summary" type="action" icon="fa-print" class="oe_highlight"/>
|
||||
<button icon="fa-ban" special="cancel" string="Cancel"/>
|
||||
<button
|
||||
name="%(report_picking_summary)d"
|
||||
string="Print Summary"
|
||||
type="action"
|
||||
icon="fa-print"
|
||||
class="oe_highlight"
|
||||
/>
|
||||
<button icon="fa-ban" special="cancel" string="Cancel" />
|
||||
</footer>
|
||||
</form>
|
||||
</field>
|
||||
|
||||
Reference in New Issue
Block a user