mirror of
https://github.com/OCA/stock-logistics-reporting.git
synced 2025-02-16 17:13:21 +02:00
[IMP] stock_card_report: black, isort, prettier
This commit is contained in:
committed by
ps-tubtim
parent
6a9eef7840
commit
f274130e65
1
setup/stock_card_report/odoo/addons/stock_card_report
Symbolic link
1
setup/stock_card_report/odoo/addons/stock_card_report
Symbolic link
@@ -0,0 +1 @@
|
||||
../../../../stock_card_report
|
||||
6
setup/stock_card_report/setup.py
Normal file
6
setup/stock_card_report/setup.py
Normal file
@@ -0,0 +1,6 @@
|
||||
import setuptools
|
||||
|
||||
setuptools.setup(
|
||||
setup_requires=['setuptools-odoo'],
|
||||
odoo_addon=True,
|
||||
)
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
<record id="paperformat_stock_card" model="report.paperformat">
|
||||
<field name="name">Stock Card A4</field>
|
||||
<field name="default" eval="True"/>
|
||||
<field name="default" eval="True" />
|
||||
<field name="format">A4</field>
|
||||
<field name="page_height">0</field>
|
||||
<field name="page_width">0</field>
|
||||
@@ -11,7 +11,7 @@
|
||||
<field name="margin_bottom">28</field>
|
||||
<field name="margin_left">7</field>
|
||||
<field name="margin_right">7</field>
|
||||
<field name="header_line" eval="False"/>
|
||||
<field name="header_line" eval="False" />
|
||||
<field name="header_spacing">24</field>
|
||||
<field name="dpi">90</field>
|
||||
</record>
|
||||
|
||||
@@ -6,21 +6,25 @@
|
||||
<field name="context" eval="{'active_model': 'report.stock.card.report'}" />
|
||||
</record>
|
||||
|
||||
<report string="Stock Card PDF"
|
||||
id="action_stock_card_report_pdf"
|
||||
model="report.stock.card.report"
|
||||
name="stock_card_report.report_stock_card_report_pdf"
|
||||
file="stock_card_report.report_stock_card_report_pdf"
|
||||
report_type="qweb-pdf"
|
||||
print_report_name="'Stock Card Report - [%s]' % object.location_id.display_name"
|
||||
paperformat="stock_card_report.paperformat_stock_card"/>
|
||||
<report
|
||||
string="Stock Card PDF"
|
||||
id="action_stock_card_report_pdf"
|
||||
model="report.stock.card.report"
|
||||
name="stock_card_report.report_stock_card_report_pdf"
|
||||
file="stock_card_report.report_stock_card_report_pdf"
|
||||
report_type="qweb-pdf"
|
||||
print_report_name="'Stock Card Report - [%s]' % object.location_id.display_name"
|
||||
paperformat="stock_card_report.paperformat_stock_card"
|
||||
/>
|
||||
|
||||
<report string="Stock Card XLSX"
|
||||
id="action_stock_card_report_xlsx"
|
||||
model="report.stock.card.report"
|
||||
name="stock_card_report.report_stock_card_report_xlsx"
|
||||
file="Stock Card Report"
|
||||
report_type="xlsx"
|
||||
attachment_use="False"/>
|
||||
<report
|
||||
string="Stock Card XLSX"
|
||||
id="action_stock_card_report_xlsx"
|
||||
model="report.stock.card.report"
|
||||
name="stock_card_report.report_stock_card_report_xlsx"
|
||||
file="Stock Card Report"
|
||||
report_type="xlsx"
|
||||
attachment_use="False"
|
||||
/>
|
||||
|
||||
</odoo>
|
||||
|
||||
@@ -1,26 +1,39 @@
|
||||
<odoo>
|
||||
|
||||
<template id="assets_backend"
|
||||
name="stock_card_report assets" inherit_id="web.assets_backend">
|
||||
<template
|
||||
id="assets_backend"
|
||||
name="stock_card_report assets"
|
||||
inherit_id="web.assets_backend"
|
||||
>
|
||||
<xpath expr="." position="inside">
|
||||
<link href="/stock_card_report/static/src/css/report.css" rel="stylesheet"/>
|
||||
<script type="text/javascript"
|
||||
src="/stock_card_report/static/src/js/stock_card_report_backend.js"/>
|
||||
<link
|
||||
href="/stock_card_report/static/src/css/report.css"
|
||||
rel="stylesheet"
|
||||
/>
|
||||
<script
|
||||
type="text/javascript"
|
||||
src="/stock_card_report/static/src/js/stock_card_report_backend.js"
|
||||
/>
|
||||
</xpath>
|
||||
</template>
|
||||
|
||||
<template id="stock_card_report.internal_layout">
|
||||
<div class="article">
|
||||
<link href="/stock_card_report/static/src/css/report.css" rel="stylesheet"/>
|
||||
<t t-raw="0"/>
|
||||
<link
|
||||
href="/stock_card_report/static/src/css/report.css"
|
||||
rel="stylesheet"
|
||||
/>
|
||||
<t t-raw="0" />
|
||||
</div>
|
||||
<div class="footer">
|
||||
<div class="row">
|
||||
<div class="col-6 custom_footer">
|
||||
<span t-esc="context_timestamp(datetime.datetime.now()).strftime('%Y-%m-%d')"/>
|
||||
<span
|
||||
t-esc="context_timestamp(datetime.datetime.now()).strftime('%Y-%m-%d')"
|
||||
/>
|
||||
</div>
|
||||
<div class="col-6 text-right custom_footer">
|
||||
<span class="page"/>/<span class="topage"/>
|
||||
<span class="page" />/<span class="topage" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -28,15 +41,19 @@
|
||||
|
||||
<template id="report_buttons">
|
||||
<div class="button_row">
|
||||
<button class="o_stock_card_reports_print btn btn-sm oe_button"><span class="fa fa-print"/>Print</button>
|
||||
<button class="o_stock_card_reports_export btn btn-sm oe_button"><span class="fa fa-download"/>Export</button>
|
||||
<button class="o_stock_card_reports_print btn btn-sm oe_button"><span
|
||||
class="fa fa-print"
|
||||
/>Print</button>
|
||||
<button class="o_stock_card_reports_export btn btn-sm oe_button"><span
|
||||
class="fa fa-download"
|
||||
/>Export</button>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<template id="report_stock_card_report_html">
|
||||
<div class="o_stock_card_reports_page">
|
||||
<t t-call="stock_card_report.report_buttons"/>
|
||||
<t t-call="stock_card_report.report_stock_card_report_base"/>
|
||||
<t t-call="stock_card_report.report_buttons" />
|
||||
<t t-call="stock_card_report.report_stock_card_report_base" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -44,7 +61,7 @@
|
||||
<t t-call="web.html_container">
|
||||
<t t-foreach="docs" t-as="o">
|
||||
<t t-call="stock_card_report.internal_layout">
|
||||
<t t-call="stock_card_report.report_stock_card_report_base"/>
|
||||
<t t-call="stock_card_report.report_stock_card_report_base" />
|
||||
</t>
|
||||
</t>
|
||||
</t>
|
||||
@@ -54,36 +71,45 @@
|
||||
<t t-foreach="o.product_ids" t-as="product">
|
||||
<div class="page">
|
||||
<div class="row">
|
||||
<t t-set="title">Stock Card - <t t-raw="product.name"/></t>
|
||||
<h4 class="mt0" t-esc="title" style="text-align: center;"/>
|
||||
<t t-set="title">Stock Card - <t t-raw="product.name" /></t>
|
||||
<h4 class="mt0" t-esc="title" style="text-align: center;" />
|
||||
</div>
|
||||
<!-- Display filters -->
|
||||
<t t-call="stock_card_report.report_stock_card_report_filters"/>
|
||||
<t t-call="stock_card_report.report_stock_card_report_filters" />
|
||||
<!-- Display stock card table -->
|
||||
<div class="act_as_table data_table mt4" style="width: 100%;">
|
||||
<!-- Display header line-->
|
||||
<t t-call="stock_card_report.report_stock_card_lines_header"/>
|
||||
<t t-call="stock_card_report.report_stock_card_lines_header" />
|
||||
<!-- Display initial lines -->
|
||||
<t t-set="initial" t-value="o._get_initial(o.results.filtered(lambda l: l.product_id == product and l.is_initial))"/>
|
||||
<t
|
||||
t-set="initial"
|
||||
t-value="o._get_initial(o.results.filtered(lambda l: l.product_id == product and l.is_initial))"
|
||||
/>
|
||||
<div class="act_as_row lines">
|
||||
<div class="act_as_cell"/>
|
||||
<div class="act_as_cell" />
|
||||
<div class="act_as_cell">
|
||||
Initial
|
||||
</div>
|
||||
<div class="act_as_cell"/>
|
||||
<div class="act_as_cell"/>
|
||||
<div class="act_as_cell" />
|
||||
<div class="act_as_cell" />
|
||||
<div class="act_as_cell right">
|
||||
<t t-esc="'{0:,.3f}'.format(initial)"/>
|
||||
<t t-esc="'{0:,.3f}'.format(initial)" />
|
||||
</div>
|
||||
</div>
|
||||
<!-- Display each lines -->
|
||||
<t t-set="product_balance" t-value="initial"/>
|
||||
<t t-foreach="o.results.filtered(lambda l: l.product_id == product and not l.is_initial)" t-as="product_line">
|
||||
<t t-set="product_balance" t-value="product_balance + product_line.product_in - product_line.product_out"/>
|
||||
<t t-call="stock_card_report.report_stock_card_lines"/>
|
||||
<t t-set="product_balance" t-value="initial" />
|
||||
<t
|
||||
t-foreach="o.results.filtered(lambda l: l.product_id == product and not l.is_initial)"
|
||||
t-as="product_line"
|
||||
>
|
||||
<t
|
||||
t-set="product_balance"
|
||||
t-value="product_balance + product_line.product_in - product_line.product_out"
|
||||
/>
|
||||
<t t-call="stock_card_report.report_stock_card_lines" />
|
||||
</t>
|
||||
</div>
|
||||
<p style="page-break-before:always;"></p>
|
||||
<p style="page-break-before:always;" />
|
||||
</div>
|
||||
</t>
|
||||
</template>
|
||||
@@ -97,13 +123,13 @@
|
||||
</div>
|
||||
<div class="act_as_row">
|
||||
<div class="act_as_cell">
|
||||
<span t-field="o.date_from"/>
|
||||
<span t-field="o.date_from" />
|
||||
</div>
|
||||
<div class="act_as_cell">
|
||||
<span t-field="o.date_to"/>
|
||||
<span t-field="o.date_to" />
|
||||
</div>
|
||||
<div class="act_as_cell">
|
||||
<span t-field="o.location_id"/>
|
||||
<span t-field="o.location_id" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -124,19 +150,19 @@
|
||||
<template id="stock_card_report.report_stock_card_lines">
|
||||
<div class="act_as_row lines">
|
||||
<div class="act_as_cell left">
|
||||
<t t-esc="product_line.date.strftime('%Y-%m-%d')"/>
|
||||
<t t-esc="product_line.date.strftime('%Y-%m-%d')" />
|
||||
</div>
|
||||
<div class="act_as_cell left">
|
||||
<t t-esc="product_line.reference"/>
|
||||
<t t-esc="product_line.reference" />
|
||||
</div>
|
||||
<div class="act_as_cell right">
|
||||
<t t-esc="'{0:,.3f}'.format(product_line.product_in)"/>
|
||||
<t t-esc="'{0:,.3f}'.format(product_line.product_in)" />
|
||||
</div>
|
||||
<div class="act_as_cell right">
|
||||
<t t-esc="'{0:,.3f}'.format(product_line.product_out)"/>
|
||||
<t t-esc="'{0:,.3f}'.format(product_line.product_out)" />
|
||||
</div>
|
||||
<div class="act_as_cell right">
|
||||
<t t-esc="'{0:,.3f}'.format(product_balance)"/>
|
||||
<t t-esc="'{0:,.3f}'.format(product_balance)" />
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
display: table !important;
|
||||
background-color: white;
|
||||
}
|
||||
.act_as_row {
|
||||
.act_as_row {
|
||||
display: table-row !important;
|
||||
page-break-inside: avoid;
|
||||
}
|
||||
@@ -14,21 +14,21 @@
|
||||
display: table-header-group !important;
|
||||
}
|
||||
.act_as_row.labels {
|
||||
background-color:#F0F0F0 !important;
|
||||
background-color: #f0f0f0 !important;
|
||||
}
|
||||
.data_table {
|
||||
width: 100% !important;
|
||||
border-left:0px;
|
||||
border-right:0px;
|
||||
text-align:center;
|
||||
font-size:10px;
|
||||
padding-right:3px;
|
||||
padding-left:3px;
|
||||
padding-top:2px;
|
||||
padding-bottom:2px;
|
||||
border-collapse:collapse;
|
||||
border-left: 0px;
|
||||
border-right: 0px;
|
||||
text-align: center;
|
||||
font-size: 10px;
|
||||
padding-right: 3px;
|
||||
padding-left: 3px;
|
||||
padding-top: 2px;
|
||||
padding-bottom: 2px;
|
||||
border-collapse: collapse;
|
||||
}
|
||||
.data_table .act_as_cell{
|
||||
.data_table .act_as_cell {
|
||||
border: 1px solid lightGrey;
|
||||
text-align: center;
|
||||
}
|
||||
@@ -39,13 +39,13 @@
|
||||
font-weight: bold;
|
||||
}
|
||||
.act_as_cell.left {
|
||||
text-align:left;
|
||||
text-align: left;
|
||||
}
|
||||
.act_as_cell.right {
|
||||
text-align:right;
|
||||
text-align: right;
|
||||
}
|
||||
.custom_footer {
|
||||
font-size:7px !important;
|
||||
font-size: 7px !important;
|
||||
}
|
||||
.button_row {
|
||||
padding-bottom: 10px;
|
||||
|
||||
@@ -1,17 +1,16 @@
|
||||
odoo.define('stock_card_report.stock_card_report_backend', function (require) {
|
||||
'use strict';
|
||||
|
||||
var AbstractAction = require('web.AbstractAction');
|
||||
var core = require('web.core');
|
||||
var ReportWidget = require('web.Widget');
|
||||
odoo.define("stock_card_report.stock_card_report_backend", function (require) {
|
||||
"use strict";
|
||||
|
||||
var AbstractAction = require("web.AbstractAction");
|
||||
var core = require("web.core");
|
||||
var ReportWidget = require("web.Widget");
|
||||
|
||||
var report_backend = AbstractAction.extend({
|
||||
hasControlPanel: true,
|
||||
// Stores all the parameters of the action.
|
||||
events: {
|
||||
'click .o_stock_card_reports_print': 'print',
|
||||
'click .o_stock_card_reports_export': 'export',
|
||||
"click .o_stock_card_reports_print": "print",
|
||||
"click .o_stock_card_reports_export": "export",
|
||||
},
|
||||
init: function (parent, action) {
|
||||
this._super.apply(this, arguments);
|
||||
@@ -22,8 +21,8 @@ odoo.define('stock_card_report.stock_card_report_backend', function (require) {
|
||||
if (action.context.context) {
|
||||
this.given_context = action.context.context;
|
||||
}
|
||||
this.given_context.active_id = action.context.active_id ||
|
||||
action.params.active_id;
|
||||
this.given_context.active_id =
|
||||
action.context.active_id || action.params.active_id;
|
||||
this.given_context.model = action.context.active_model || false;
|
||||
this.given_context.ttype = action.context.ttype || false;
|
||||
},
|
||||
@@ -35,7 +34,7 @@ odoo.define('stock_card_report.stock_card_report_backend', function (require) {
|
||||
var def = Promise.resolve();
|
||||
if (!this.report_widget) {
|
||||
this.report_widget = new ReportWidget(this, this.given_context);
|
||||
def = this.report_widget.appendTo(this.$('.o_content'));
|
||||
def = this.report_widget.appendTo(this.$(".o_content"));
|
||||
}
|
||||
def.then(function () {
|
||||
self.report_widget.$el.html(self.html);
|
||||
@@ -52,15 +51,14 @@ odoo.define('stock_card_report.stock_card_report_backend', function (require) {
|
||||
var defs = [];
|
||||
return this._rpc({
|
||||
model: this.given_context.model,
|
||||
method: 'get_html',
|
||||
method: "get_html",
|
||||
args: [self.given_context],
|
||||
context: self.odoo_context,
|
||||
})
|
||||
.then(function (result) {
|
||||
self.html = result.html;
|
||||
defs.push(self.update_cp());
|
||||
return $.when.apply($, defs);
|
||||
});
|
||||
}).then(function (result) {
|
||||
self.html = result.html;
|
||||
defs.push(self.update_cp());
|
||||
return $.when.apply($, defs);
|
||||
});
|
||||
},
|
||||
// Updates the control panel and render the elements that have yet
|
||||
// to be rendered
|
||||
@@ -81,8 +79,8 @@ odoo.define('stock_card_report.stock_card_report_backend', function (require) {
|
||||
var self = this;
|
||||
this._rpc({
|
||||
model: this.given_context.model,
|
||||
method: 'print_report',
|
||||
args: [this.given_context.active_id, 'qweb-pdf'],
|
||||
method: "print_report",
|
||||
args: [this.given_context.active_id, "qweb-pdf"],
|
||||
context: self.odoo_context,
|
||||
}).then(function (result) {
|
||||
self.do_action(result);
|
||||
@@ -92,8 +90,8 @@ odoo.define('stock_card_report.stock_card_report_backend', function (require) {
|
||||
var self = this;
|
||||
this._rpc({
|
||||
model: this.given_context.model,
|
||||
method: 'print_report',
|
||||
args: [this.given_context.active_id, 'xlsx'],
|
||||
method: "print_report",
|
||||
args: [this.given_context.active_id, "xlsx"],
|
||||
context: self.odoo_context,
|
||||
}).then(function (result) {
|
||||
self.do_action(result);
|
||||
@@ -104,9 +102,6 @@ odoo.define('stock_card_report.stock_card_report_backend', function (require) {
|
||||
},
|
||||
});
|
||||
|
||||
core.action_registry.add(
|
||||
"stock_card_report_backend",
|
||||
report_backend
|
||||
);
|
||||
core.action_registry.add("stock_card_report_backend", report_backend);
|
||||
return report_backend;
|
||||
});
|
||||
|
||||
@@ -7,22 +7,35 @@
|
||||
<form>
|
||||
<group name="criteria">
|
||||
<group>
|
||||
<field name="date_range_id"/>
|
||||
<field name="date_from"/>
|
||||
<field name="date_to"/>
|
||||
<field name="date_range_id" />
|
||||
<field name="date_from" />
|
||||
<field name="date_to" />
|
||||
</group>
|
||||
<group>
|
||||
<field name="product_ids" widget="many2many_tags"/>
|
||||
<field name="location_id"/>
|
||||
<field name="product_ids" widget="many2many_tags" />
|
||||
<field name="location_id" />
|
||||
</group>
|
||||
</group>
|
||||
<footer>
|
||||
<button name="button_export_html" string="View"
|
||||
type="object" default_focus="1" class="oe_highlight"/>
|
||||
<button
|
||||
name="button_export_html"
|
||||
string="View"
|
||||
type="object"
|
||||
default_focus="1"
|
||||
class="oe_highlight"
|
||||
/>
|
||||
or
|
||||
<button name="button_export_pdf" string="Export PDF" type="object"/>
|
||||
<button
|
||||
name="button_export_pdf"
|
||||
string="Export PDF"
|
||||
type="object"
|
||||
/>
|
||||
or
|
||||
<button name="button_export_xlsx" string="Export XLSX" type="object"/>
|
||||
<button
|
||||
name="button_export_xlsx"
|
||||
string="Export XLSX"
|
||||
type="object"
|
||||
/>
|
||||
or
|
||||
<button string="Cancel" class="oe_link" special="cancel" />
|
||||
</footer>
|
||||
@@ -37,9 +50,11 @@
|
||||
<field name="target">new</field>
|
||||
</record>
|
||||
|
||||
<menuitem id="stock_card_report_menu"
|
||||
action="stock_card_report_action"
|
||||
parent="stock.menu_warehouse_report"
|
||||
sequence="30"/>
|
||||
<menuitem
|
||||
id="stock_card_report_menu"
|
||||
action="stock_card_report_action"
|
||||
parent="stock.menu_warehouse_report"
|
||||
sequence="30"
|
||||
/>
|
||||
|
||||
</odoo>
|
||||
|
||||
Reference in New Issue
Block a user