Browse Source

[10.0][MIG][pos_order_mgmt] Backport to v10.0

pull/416/head
Roberto Fichera 5 years ago
parent
commit
9339aa6b4d
  1. 2
      pos_order_mgmt/__init__.py
  2. 4
      pos_order_mgmt/__manifest__.py
  3. 2
      pos_order_mgmt/models/__init__.py
  4. 1
      pos_order_mgmt/models/pos_config.py
  5. 5
      pos_order_mgmt/models/pos_order.py
  6. 1
      pos_order_mgmt/readme/CONTRIBUTORS.rst
  7. 130
      pos_order_mgmt/static/src/js/widgets.js
  8. 2
      pos_order_mgmt/static/src/xml/pos.xml
  9. 2
      pos_order_mgmt/tests/test_module.py
  10. 48
      pos_order_mgmt/views/view_pos_config.xml

2
pos_order_mgmt/__init__.py

@ -1 +1,3 @@
# coding=utf-8
from . import models

4
pos_order_mgmt/__manifest__.py

@ -1,3 +1,5 @@
# coding=utf-8
# Copyright 2018 GRAP - Sylvain LE GAL
# Copyright 2018 Tecnativa S.L. - David Vidal
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
@ -5,7 +7,7 @@
{
'name': 'POS Frontend Orders Management',
'summary': 'Manage old POS Orders from the frontend',
'version': '12.0.1.0.3',
'version': '10.0.1.0.3',
'category': 'Point of Sale',
'author': 'GRAP, '
'Tecnativa, '

2
pos_order_mgmt/models/__init__.py

@ -1,2 +1,4 @@
# coding=utf-8
from . import pos_config
from . import pos_order

1
pos_order_mgmt/models/pos_config.py

@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
# Copyright 2018 GRAP - Sylvain LE GAL
# Copyright 2018 Tecnativa S.L. - David Vidal
# Copyright 2019 Coop IT Easy SCRLfs

5
pos_order_mgmt/models/pos_order.py

@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
# Copyright 2018 GRAP - Sylvain LE GAL
# Copyright 2018 Tecnativa S.L. - David Vidal
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
@ -58,7 +59,7 @@ class PosOrder(models.Model):
@api.returns('self', lambda value: value.id)
def copy(self, default=None):
self.ensure_one()
order = super().copy(default=default)
order = super(PosOrder, self).copy(default=default)
if self.env.context.get('refund', False):
order.returned_order_id = self.id
return order
@ -153,7 +154,7 @@ class PosOrder(models.Model):
@api.model
def _order_fields(self, ui_order):
res = super()._order_fields(ui_order)
res = super(PosOrder, self)._order_fields(ui_order)
res.update({
'returned_order_id': ui_order.get('returned_order_id', False),
})

1
pos_order_mgmt/readme/CONTRIBUTORS.rst

@ -3,3 +3,4 @@
* Carlos Martínez <carlos@domatix.com>
* Pierrick Brun <pierrick.brun@akretion.com>
* Iván Todorovich <ivan.todorovich@druidoo.io>
* Roberto Fichera <roberto.fichera@levelprime.com>

130
pos_order_mgmt/static/src/js/widgets.js

@ -13,6 +13,7 @@ odoo.define('pos_order_mgmt.widgets', function (require) {
var gui = require('point_of_sale.gui');
var chrome = require('point_of_sale.chrome');
var pos = require('point_of_sale.models');
var Model = require('web.Model');
var QWeb = core.qweb;
var ScreenWidget = screens.ScreenWidget;
@ -21,7 +22,7 @@ odoo.define('pos_order_mgmt.widgets', function (require) {
screens.ReceiptScreenWidget.include({
render_receipt: function () {
if (!this.pos.reloaded_order) {
return this._super();
return this._super.apply(this, arguments);
}
var order = this.pos.reloaded_order;
this.$('.pos-receipt-container').html(QWeb.render('PosTicket', {
@ -36,7 +37,7 @@ odoo.define('pos_order_mgmt.widgets', function (require) {
},
click_next: function () {
if (!this.pos.from_loaded_order) {
return this._super();
return this._super.apply(this, arguments);
}
this.pos.from_loaded_order = false;
// When reprinting a loaded order we temporarily set it as the
@ -75,7 +76,7 @@ odoo.define('pos_order_mgmt.widgets', function (require) {
this.gui.screen_instances.receipt.click_next();
this.gui.show_screen('orderlist');
}
this._super();
this._super.apply(this, arguments);
this.renderElement();
this.old_order = this.pos.get_order();
this.$('.back').click(function () {
@ -178,23 +179,14 @@ odoo.define('pos_order_mgmt.widgets', function (require) {
this.pos.set_order(order);
if (this.pos.config.iface_print_via_proxy) {
this.pos.proxy.print_receipt(QWeb.render(
'XmlReceipt', {
receipt: order.export_for_printing(),
widget: this,
pos: this.pos,
order: order,
orderlines: order.get_orderlines(),
paymentlines: order.get_paymentlines(),
}));
this.pos.set_order(this.pos.current_order);
this.pos.current_order = false;
} else {
this.pos.reloaded_order = order;
this.gui.show_screen('receipt');
this.pos.reloaded_order = false;
}
this.pos.reloaded_order = order;
var skip_screen_state = this.pos.config.iface_print_skip_screen;
// Disable temporarily skip screen if set
this.pos.config.iface_print_skip_screen = false;
this.gui.show_screen('receipt');
this.pos.reloaded_order = false;
// Set skip screen to whatever previous state
this.pos.config.iface_print_skip_screen = skip_screen_state;
// If it's invoiced, we also print the invoice
if (order_data.to_invoice) {
@ -335,27 +327,25 @@ odoo.define('pos_order_mgmt.widgets', function (require) {
load_order_data: function (order_id) {
var self = this;
return this._rpc({
model: 'pos.order',
method: 'load_done_order_for_pos',
args: [order_id],
}).fail(function (error) {
if (parseInt(error.code, 10) === 200) {
// Business Logic Error, not a connection problem
self.gui.show_popup(
'error-traceback', {
'title': error.data.message,
'body': error.data.debug,
return new Model('pos.order')
.call('load_done_order_for_pos', [order_id])
.fail(function (error) {
if (parseInt(error.code, 10) === 200) {
// Business Logic Error, not a connection problem
self.gui.show_popup(
'error-traceback', {
'title': error.data.message,
'body': error.data.debug,
});
} else {
self.gui.show_popup('error', {
'title': _t('Connection error'),
'body': _t(
'Can not execute this action because the POS' +
' is currently offline'),
});
} else {
self.gui.show_popup('error', {
'title': _t('Connection error'),
'body': _t(
'Can not execute this action because the POS' +
' is currently offline'),
});
}
});
}
});
},
load_order_from_data: function (order_data, action) {
@ -380,38 +370,36 @@ odoo.define('pos_order_mgmt.widgets', function (require) {
// Search Part
search_done_orders: function (query) {
var self = this;
return this._rpc({
model: 'pos.order',
method: 'search_done_orders_for_pos',
args: [query || '', this.pos.pos_session.id],
}).then(function (result) {
self.orders = result;
// Get the date in local time
_.each(self.orders, function (order) {
if (order.date_order) {
order.date_order = moment.utc(order.date_order)
.local().format('YYYY-MM-DD HH:mm:ss');
}
});
}).fail(function (error, event) {
if (parseInt(error.code, 10) === 200) {
// Business Logic Error, not a connection problem
self.gui.show_popup(
'error-traceback', {
'title': error.data.message,
'body': error.data.debug,
return new Model('pos.order')
.call('search_done_orders_for_pos', [query || '', this.pos.pos_session.id])
.then(function (result) {
self.orders = result;
// Get the date in local time
_.each(self.orders, function (order) {
if (order.date_order) {
order.date_order = moment.utc(order.date_order)
.local().format('YYYY-MM-DD HH:mm:ss');
}
);
} else {
self.gui.show_popup('error', {
'title': _t('Connection error'),
'body': _t(
'Can not execute this action because the POS' +
' is currently offline'),
});
}
event.preventDefault();
});
}).fail(function (error, event) {
if (parseInt(error.code, 10) === 200) {
// Business Logic Error, not a connection problem
self.gui.show_popup(
'error-traceback', {
'title': error.data.message,
'body': error.data.debug,
}
);
} else {
self.gui.show_popup('error', {
'title': _t('Connection error'),
'body': _t(
'Can not execute this action because the POS' +
' is currently offline'),
});
}
event.preventDefault();
});
},
perform_search: function () {
@ -451,7 +439,7 @@ odoo.define('pos_order_mgmt.widgets', function (require) {
renderElement: function () {
var self = this;
this._super();
this._super.apply(this, arguments);
this.$el.click(function () {
self.button_click();
});

2
pos_order_mgmt/static/src/xml/pos.xml

@ -84,7 +84,7 @@
</t>
</t>
<t t-jquery=".receipt-user" t-operation="after">
<t t-if="pos.reloaded_order">
<t t-if="pos and pos.reloaded_order">
<br/>
<div style='text-align:center'>DUPLICATE</div>
<br/>

2
pos_order_mgmt/tests/test_module.py

@ -16,7 +16,7 @@ class TestModule(TransactionCase):
self.AccountPayment = self.env['account.payment']
# Get Object
self.pos_product = self.env.ref('point_of_sale.whiteboard_pen')
self.pos_product = self.env.ref('point_of_sale.limon')
self.pricelist = self.env.ref('product.list0')
self.partner = self.env.ref('base.res_partner_12')

48
pos_order_mgmt/views/view_pos_config.xml

@ -2,45 +2,29 @@
<!-- Copyright 2018 GRAP - Sylvain LE GAL
Copyright 2018 Tecnativa - David Vidal
Copyright 2019 Druidoo - Iván Todorovich
Copyright 2019 Level Prime Srl - Roberto Fichera
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
-->
<odoo>
<record id="view_pos_config_form" model="ir.ui.view">
<field name="model">pos.config</field>
<field name="inherit_id" ref="point_of_sale.pos_config_view_form"/>
<field name="inherit_id" ref="point_of_sale.view_pos_config_form"/>
<field name="arch" type="xml">
<div id="receipt" position="inside">
<div class="col-xs-12 col-md-6 o_setting_box" id="pos_order_mgmt">
<div class="o_setting_left_pane">
<field name="iface_order_mgmt"/>
</div>
<div class="o_setting_right_pane">
<label for="iface_order_mgmt"/>
<div class="text-muted">
Allows to manage already done orders in the frontend.
</div>
<div class="content-group mt16" attrs="{'invisible': [('iface_order_mgmt', '=', False)]}">
<div class="row mt16" id="reprint_done_order">
<label for="iface_reprint_done_order" class="col-lg-3 o_light_label"/>
<field name="iface_reprint_done_order"/>
</div>
<div class="row mt16" id="copy_done_order">
<label for="iface_return_done_order" class="col-lg-3 o_light_label"/>
<field name="iface_return_done_order"/>
</div>
<div class="row mt16" id="return_done_order">
<label for="iface_copy_done_order" class="col-lg-3 o_light_label"/>
<field name="iface_copy_done_order"/>
</div>
<div class="row mt16" id="load_done_order_max_qty">
<label for="iface_load_done_order_max_qty" class="col-lg-3 o_light_label"/>
<field name="iface_load_done_order_max_qty"/>
</div>
</div>
</div>
</div>
</div>
<group name="receipt" position="inside">
<field name="iface_order_mgmt"/>
</group>
<group name="receipt" position="after">
<group string="Order Management" name="order_management"
attrs="{'invisible': [('iface_order_mgmt', '=', False)]}">
<group>
<field name="iface_reprint_done_order"/>
<field name="iface_return_done_order"/>
<field name="iface_copy_done_order"/>
<field name="iface_load_done_order_max_qty"/>
</group>
</group>
</group>
</field>
</record>

Loading…
Cancel
Save