Apply pre-commit

This commit is contained in:
João Marques
2021-02-17 15:45:37 +00:00
parent 3700f9c69b
commit c06c7fbe41
10 changed files with 226 additions and 164 deletions

View File

@@ -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>

View File

@@ -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>

View File

@@ -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>

View File

@@ -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;

View File

@@ -1,19 +1,18 @@
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) {
init: function(parent, action) {
this._super.apply(this, arguments);
this.actionManager = parent;
this.given_context = {};
@@ -22,49 +21,48 @@ 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;
},
willStart: function () {
willStart: function() {
return Promise.all([this._super.apply(this, arguments), this.get_html()]);
},
set_html: function () {
set_html: function() {
var self = this;
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 () {
def.then(function() {
self.report_widget.$el.html(self.html);
});
},
start: function () {
start: function() {
this.set_html();
return this._super();
},
// Fetches the html and is previous report.context if any,
// else create it
get_html: function () {
get_html: function() {
var self = this;
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
update_cp: function () {
update_cp: function() {
if (this.$buttons) {
var status = {
breadcrumbs: this.actionManager.get_breadcrumbs(),
@@ -73,40 +71,37 @@ odoo.define('stock_card_report.stock_card_report_backend', function (require) {
return this.update_control_panel(status);
}
},
do_show: function () {
do_show: function() {
this._super();
this.update_cp();
},
print: function () {
print: function() {
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) {
}).then(function(result) {
self.do_action(result);
});
},
export: function () {
export: function() {
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) {
}).then(function(result) {
self.do_action(result);
});
},
canBeRemoved: function () {
canBeRemoved: function() {
return Promise.resolve();
},
});
core.action_registry.add(
"stock_card_report_backend",
report_backend
);
core.action_registry.add("stock_card_report_backend", report_backend);
return report_backend;
});

View File

@@ -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>

View File

@@ -1,9 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<template id="valued_report_picking" inherit_id="stock.report_delivery_document">
<xpath expr="//table[@t-if=&quot;o.move_line_ids and o.state==&apos;done&apos;&quot;]/thead/tr"
position="inside">
<xpath
expr="//table[@t-if=&quot;o.move_line_ids and o.state==&apos;done&apos;&quot;]/thead/tr"
position="inside"
>
<t t-if="o.valued and o.sale_id and o.move_line_ids">
<t t-if="o.state != 'done'">
<th class="text-right"><strong>Qty Reserved</strong></th>
@@ -20,21 +22,25 @@
<t t-if="o.valued and o.sale_id and o.move_line_ids">
<t t-if="move_line.picking_id.state != 'done'">
<td class="text-right">
<span t-field="move_line.product_uom_qty"/>
<span t-field="move_line.product_uom_id"/></td>
<span t-field="move_line.product_uom_qty" />
<span t-field="move_line.product_uom_id" /></td>
</t>
<td class="text-right"><span
t-field="move_line.sale_price_unit" /></td>
<td class="text-right"><span t-field="move_line.sale_price_unit" /></td>
<td class="text-right" groups="product.group_discount_per_so_line">
<span t-field="move_line.sale_discount" />
</td>
<td class="text-right"><span
t-field="move_line.sale_price_subtotal" /></td>
t-field="move_line.sale_price_subtotal"
/></td>
<td class="text-right"><span
t-field="move_line.sale_tax_description"/></td>
t-field="move_line.sale_tax_description"
/></td>
</t>
</xpath>
<xpath expr="//table[@t-if=&quot;o.move_line_ids and o.state==&apos;done&apos;&quot;]" position="after">
<xpath
expr="//table[@t-if=&quot;o.move_line_ids and o.state==&apos;done&apos;&quot;]"
position="after"
>
<t t-if="o.valued and o.sale_id and o.move_line_ids">
<table class="table table-sm mt32">
<thead>
@@ -47,13 +53,13 @@
<tbody>
<tr>
<td class="text-right">
<span t-field="o.amount_untaxed"/>
<span t-field="o.amount_untaxed" />
</td>
<td class="text-right">
<span t-field="o.amount_tax"/>
<span t-field="o.amount_tax" />
</td>
<td class="text-right">
<span t-field="o.amount_total"/>
<span t-field="o.amount_total" />
</td>
</tr>
</tbody>

View File

@@ -1,13 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<record model="ir.ui.view" id="view_partner_valued_picking">
<field name="name">Partner view (Valued picking)</field>
<field name="model">res.partner</field>
<field name="inherit_id" ref="base.view_partner_form"/>
<field name="inherit_id" ref="base.view_partner_form" />
<field name="arch" type="xml">
<xpath expr="//page[@name='sales_purchases']//field[@name='user_id']" position="after">
<field name="valued_picking"/>
<xpath
expr="//page[@name='sales_purchases']//field[@name='user_id']"
position="after"
>
<field name="valued_picking" />
</xpath>
</field>
</record>

View File

@@ -1,23 +1,25 @@
odoo.define('stock.InventoryReportLocationListController', function (require) {
"use strict";
/* eslint-disable no-unused-vars */
odoo.define("stock.InventoryReportLocationListController", function(require) {
"use strict";
var core = require('web.core');
var InventoryReportListController = require('stock.InventoryReportListController');
var core = require("web.core");
var InventoryReportListController = require("stock.InventoryReportListController");
var qweb = core.qweb;
var _t = core._t;
var qweb = core.qweb;
var _t = core._t;
var InventoryReportLocationListController = InventoryReportListController.include({
renderButtons: function ($node) {
this._super.apply(this, arguments);
if (this.context.no_at_date) {
return;
}
if (this.modelName === "stock.quant") {
$node.find('.o_list_buttons').find(".btn-primary").html(_t("Inventory at Date & Location"))
}
},
});
var InventoryReportLocationListController = InventoryReportListController.include({
renderButtons: function($node) {
this._super.apply(this, arguments);
if (this.context.no_at_date) {
return;
}
if (this.modelName === "stock.quant") {
$node
.find(".o_list_buttons")
.find(".btn-primary")
.html(_t("Inventory at Date & Location"));
}
},
});
});

View File

@@ -1,22 +1,33 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<template id="stock_quantity_history_location_assets_backend" name="mrp_workorder assets" inherit_id="web.assets_backend">
<template
id="stock_quantity_history_location_assets_backend"
name="mrp_workorder assets"
inherit_id="web.assets_backend"
>
<xpath expr="." position="inside">
<script type="text/javascript" src="/stock_quantity_history_location/static/src/js/inventory_report.js"></script>
<script
type="text/javascript"
src="/stock_quantity_history_location/static/src/js/inventory_report.js"
/>
</xpath>
</template>
<record id="view_stock_quantity_history_location" model="ir.ui.view">
<field name="name">Inventory Report</field>
<field name="model">stock.quantity.history</field>
<field name="inherit_id" ref="stock.view_stock_quantity_history"/>
<field name="inherit_id" ref="stock.view_stock_quantity_history" />
<field name="arch" type="xml">
<field name="inventory_datetime" position="before">
<field name="location_id"
invisible="context.get('active_model') == 'stock.valuation.layer'"/>
<field name="include_child_locations"
attrs="{'invisible': [('location_id', '=', False)]}"/>
<field
name="location_id"
invisible="context.get('active_model') == 'stock.valuation.layer'"
/>
<field
name="include_child_locations"
attrs="{'invisible': [('location_id', '=', False)]}"
/>
</field>
</field>
</record>