Skip to content

Commit

Permalink
[MIG] pos_order_reorder: Migration to 18.0
Browse files Browse the repository at this point in the history
  • Loading branch information
HeliconiaSolutions committed Feb 10, 2025
1 parent 6b717ee commit 3fe1cdf
Show file tree
Hide file tree
Showing 9 changed files with 41 additions and 29 deletions.
3 changes: 3 additions & 0 deletions pos_order_reorder/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ Contributors

- Cetmix <https://cetmix.com/>
- Dinar Gabbasov
- `Heliconia Solutions Pvt. Ltd. <https://www.heliconia.io>`__

- Bhavesh Heliconia

Maintainers
-----------
Expand Down
4 changes: 2 additions & 2 deletions pos_order_reorder/__manifest__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Point of Sale Re-order",
"version": "16.0.0.1.2",
"version": "18.0.1.0.0",
"category": "Sales/Point of Sale",
"summary": "Simple Re-order in the Point of Sale ",
"depends": ["point_of_sale"],
Expand All @@ -12,7 +12,7 @@
],
"installable": True,
"assets": {
"point_of_sale.assets": [
"point_of_sale._assets_pos": [
"pos_order_reorder/static/src/js/**/*.js",
"pos_order_reorder/static/src/xml/**/*.xml",
],
Expand Down
2 changes: 2 additions & 0 deletions pos_order_reorder/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
- Cetmix \<<https://cetmix.com/>\>
- Dinar Gabbasov
- [Heliconia Solutions Pvt. Ltd.](https://www.heliconia.io)
- Bhavesh Heliconia
4 changes: 4 additions & 0 deletions pos_order_reorder/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,10 @@ <h2><a class="toc-backref" href="#toc-entry-5">Contributors</a></h2>
<ul class="simple">
<li>Cetmix &lt;<a class="reference external" href="https://cetmix.com/">https://cetmix.com/</a>&gt;</li>
<li>Dinar Gabbasov</li>
<li><a class="reference external" href="https://www.heliconia.io">Heliconia Solutions Pvt. Ltd.</a><ul>
<li>Bhavesh Heliconia</li>
</ul>
</li>
</ul>
</div>
<div class="section" id="maintainers">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
/** @odoo-module **/

import {Orderline} from "point_of_sale.models";
import PosComponent from "point_of_sale.PosComponent";
import Registries from "point_of_sale.Registries";
import {Component} from "@odoo/owl";
import {usePos} from "@point_of_sale/app/store/pos_hook";

class ReorderButton extends PosComponent {
export class ReorderButton extends Component {
static template = "ReorderButton";

setup() {
this.pos = usePos();
}
get isEmptyOrder() {
if (!this.props.order) return true;
return this.props.order.is_empty();
Expand All @@ -14,7 +18,7 @@ class ReorderButton extends PosComponent {
return;
}
const order = this.props.order;
const pos = this.env.pos;
const pos = this.pos;
const partner = order.get_partner();
const newOrder = pos.add_new_order();
if (partner) {
Expand All @@ -29,8 +33,7 @@ class ReorderButton extends PosComponent {
const lines = order.get_orderlines();
for (var i = 0; i < lines.length; i++) {
const line = lines[i];
const new_line = Orderline.create(
{},
const new_line = this.props.order.models["pos.order.line"].create(
this._prepareReorderLineVals(newOrder, line)
);
if (line.pack_lot_lines) {
Expand All @@ -44,18 +47,16 @@ class ReorderButton extends PosComponent {
new_line.set_unit_price(line.get_unit_price());
new_line.set_quantity(line.get_quantity());
new_line.set_discount(line.get_discount());
newOrder.add_orderline(new_line);
}
this.trigger("click-order", newOrder);
this.pos.closeScreen();
}
_prepareReorderLineVals(order, line) {
return {
pos: this.env.pos,
order: order,
product: this.env.pos.db.get_product_by_id(line.get_product().id),
order_id: order,
product_id: line.product_id,
description: line.name,
price: line.price_unit,
tax_ids: order.fiscal_position ? undefined : line.tax_id,
price_unit: line.price_unit,
tax_ids: line.tax_ids.map((tax) => ["link", tax]),
price_manually_set: true,
customer_note: line.customer_note,
};
Expand All @@ -64,7 +65,3 @@ class ReorderButton extends PosComponent {
this._reOrder();
}
}
ReorderButton.template = "ReorderButton";
Registries.Component.add(ReorderButton);

export default ReorderButton;
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import {TicketScreen} from "@point_of_sale/app/screens/ticket_screen/ticket_screen";
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},
});
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
<?xml version="1.0" encoding="UTF-8" ?>
<templates id="template" xml:space="preserve">

<t t-name="ReorderButton" owl="1">
<span class="control-button" t-on-click="_onClick">
<t t-name="ReorderButton">
<span
class="control-button btn btn-light btn-lg lh-lg flex-grow-1 flex-shrink-1"
t-on-click="_onClick"
>
<i class="fa fa-copy" />
<span />
<span>Re-order</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,8 @@
t-name="TicketScreen"
t-inherit="point_of_sale.TicketScreen"
t-inherit-mode="extension"
owl="1"
>
<xpath
expr="//div[hasclass('leftpane')]//div[hasclass('control-buttons')]"
position="inside"
>
<xpath expr="//InvoiceButton" position="after">
<ReorderButton order="_selectedSyncedOrder" />
</xpath>
</t>
Expand Down
4 changes: 2 additions & 2 deletions pos_order_reorder/views/res_config_settings_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<field name="model">res.config.settings</field>
<field name="inherit_id" ref="point_of_sale.res_config_settings_view_form" />
<field name="arch" type="xml">
<div id="pos_interface_section" position="inside">
<xpath expr="//block[@id='pos_interface_section']" position="inside">
<div class="col-12 col-lg-6 o_setting_box">
<div class="o_setting_left_pane">
<field name="pos_allow_reorder" />
Expand All @@ -17,7 +17,7 @@
</div>
</div>
</div>
</div>
</xpath>
</field>
</record>
</odoo>

0 comments on commit 3fe1cdf

Please sign in to comment.