[REF] all: pass pre-commit on the whole repo
Needed for the lint job of the CI to go green. Mostly automatic hook fixes (black, isort, prettier, pyupgrade, autoflake, whitespace). By hand: - flake8: two unused imports, an ambiguous variable name `l`. - pylint-odoo mandatory: manifest keys equal to their default value (installable, application, data, external_dependencies). - end-of-file-fixer skips *.patch too, like trailing-whitespace: the upstream patches stay as git format-patch wrote them. No behaviour change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
d9d9e8be2d
commit
fbd43bb459
45 changed files with 330 additions and 295 deletions
|
|
@ -4,64 +4,64 @@ import { Component } from "@odoo/owl";
|
|||
import { usePos } from "@point_of_sale/app/store/pos_hook";
|
||||
|
||||
export class ReorderButton extends Component {
|
||||
static template = "ReorderButton";
|
||||
static template = "ReorderButton";
|
||||
|
||||
setup() {
|
||||
this.pos = usePos();
|
||||
}
|
||||
get isEmptyOrder() {
|
||||
if (!this.props.order) return true;
|
||||
return this.props.order.is_empty();
|
||||
}
|
||||
_reOrder() {
|
||||
if (this.isEmptyOrder) {
|
||||
return;
|
||||
setup() {
|
||||
this.pos = usePos();
|
||||
}
|
||||
const order = this.props.order;
|
||||
const pos = this.pos;
|
||||
const partner = order.get_partner();
|
||||
const newOrder = pos.add_new_order();
|
||||
if (partner) {
|
||||
newOrder.set_partner(partner);
|
||||
get isEmptyOrder() {
|
||||
if (!this.props.order) return true;
|
||||
return this.props.order.is_empty();
|
||||
}
|
||||
if (order.fiscal_position) {
|
||||
newOrder.fiscal_position = order.fiscal_position;
|
||||
_reOrder() {
|
||||
if (this.isEmptyOrder) {
|
||||
return;
|
||||
}
|
||||
const order = this.props.order;
|
||||
const pos = this.pos;
|
||||
const partner = order.get_partner();
|
||||
const newOrder = pos.add_new_order();
|
||||
if (partner) {
|
||||
newOrder.set_partner(partner);
|
||||
}
|
||||
if (order.fiscal_position) {
|
||||
newOrder.fiscal_position = order.fiscal_position;
|
||||
}
|
||||
if (order.pricelist) {
|
||||
newOrder.set_pricelist(order.pricelist);
|
||||
}
|
||||
const lines = order.get_orderlines();
|
||||
for (var i = 0; i < lines.length; i++) {
|
||||
const line = lines[i];
|
||||
const new_line = this.props.order.models["pos.order.line"].create(
|
||||
this._prepareReorderLineVals(newOrder, line)
|
||||
);
|
||||
if (line.pack_lot_lines) {
|
||||
new_line.setPackLotLines({
|
||||
modifiedPackLotLines: [],
|
||||
newPackLotLines: (line.lot_names || []).map((name) => ({
|
||||
lot_name: name,
|
||||
})),
|
||||
});
|
||||
}
|
||||
new_line.set_unit_price(line.get_unit_price());
|
||||
new_line.set_quantity(line.get_quantity());
|
||||
new_line.set_discount(line.get_discount());
|
||||
}
|
||||
this.pos.closeScreen();
|
||||
}
|
||||
if (order.pricelist) {
|
||||
newOrder.set_pricelist(order.pricelist);
|
||||
_prepareReorderLineVals(order, line) {
|
||||
return {
|
||||
order_id: order,
|
||||
product_id: line.product_id,
|
||||
description: line.name,
|
||||
price_unit: line.price_unit,
|
||||
tax_ids: line.tax_ids.map((tax) => ["link", tax]),
|
||||
price_manually_set: true,
|
||||
customer_note: line.customer_note,
|
||||
};
|
||||
}
|
||||
const lines = order.get_orderlines();
|
||||
for (var i = 0; i < lines.length; i++) {
|
||||
const line = lines[i];
|
||||
const new_line = this.props.order.models["pos.order.line"].create(
|
||||
this._prepareReorderLineVals(newOrder, line)
|
||||
);
|
||||
if (line.pack_lot_lines) {
|
||||
new_line.setPackLotLines({
|
||||
modifiedPackLotLines: [],
|
||||
newPackLotLines: (line.lot_names || []).map((name) => ({
|
||||
lot_name: name,
|
||||
})),
|
||||
});
|
||||
}
|
||||
new_line.set_unit_price(line.get_unit_price());
|
||||
new_line.set_quantity(line.get_quantity());
|
||||
new_line.set_discount(line.get_discount());
|
||||
_onClick() {
|
||||
this._reOrder();
|
||||
}
|
||||
this.pos.closeScreen();
|
||||
}
|
||||
_prepareReorderLineVals(order, line) {
|
||||
return {
|
||||
order_id: order,
|
||||
product_id: line.product_id,
|
||||
description: line.name,
|
||||
price_unit: line.price_unit,
|
||||
tax_ids: line.tax_ids.map((tax) => ["link", tax]),
|
||||
price_manually_set: true,
|
||||
customer_note: line.customer_note,
|
||||
};
|
||||
}
|
||||
_onClick() {
|
||||
this._reOrder();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,5 +3,5 @@ import { patch } from "@web/core/utils/patch";
|
|||
import { ReorderButton } from "@pos_order_reorder/js/Screens/TicketScreen/ControlButtons/ReorderButton.esm";
|
||||
|
||||
patch(TicketScreen, {
|
||||
components: { ...TicketScreen.components, ReorderButton },
|
||||
components: { ...TicketScreen.components, ReorderButton },
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue