From 96be406ca85b380e412008b5f5e9cce963b66dd6 Mon Sep 17 00:00:00 2001 From: Pierrick Brun Date: Mon, 25 Mar 2019 13:12:33 +0100 Subject: [PATCH] [MIG] 12.0 with integration of pos_return --- pos_order_mgmt/__manifest__.py | 4 ++-- pos_order_mgmt/models/pos_order.py | 28 ++++++++++++++++++------ pos_order_mgmt/views/view_pos_config.xml | 4 ++-- 3 files changed, 25 insertions(+), 11 deletions(-) diff --git a/pos_order_mgmt/__manifest__.py b/pos_order_mgmt/__manifest__.py index d90bc1c6..b139f96e 100644 --- a/pos_order_mgmt/__manifest__.py +++ b/pos_order_mgmt/__manifest__.py @@ -5,7 +5,7 @@ { 'name': 'POS Frontend Orders Management', 'summary': 'Manage old POS Orders from the frontend', - 'version': '11.0.1.0.1', + 'version': '12.0.1.0.1', 'category': 'Point of Sale', 'author': 'GRAP, ' 'Tecnativa, ' @@ -13,7 +13,7 @@ 'website': 'https://github.com/OCA/pos', 'license': 'AGPL-3', 'depends': [ - 'pos_order_return', + 'point_of_sale', ], 'data': [ 'views/assets.xml', diff --git a/pos_order_mgmt/models/pos_order.py b/pos_order_mgmt/models/pos_order.py index c2ae6382..f3793749 100644 --- a/pos_order_mgmt/models/pos_order.py +++ b/pos_order_mgmt/models/pos_order.py @@ -2,12 +2,28 @@ # Copyright 2018 Tecnativa S.L. - David Vidal # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -from odoo import api, models +from odoo import api, models, fields class PosOrder(models.Model): _inherit = 'pos.order' + returned_order_id = fields.Many2one( + comodel_name='pos.order', + string='Returned Order', + readonly=True, + ) + refund_order_ids = fields.One2many( + comodel_name='pos.order', + inverse_name='returned_order_id', + string='Refund Orders', + readonly=True, + ) + refund_order_qty = fields.Integer( + compute='_compute_refund_order_qty', + string='Refund Orders Quantity', + ) + @api.model def _prepare_filter_for_pos(self, pos_session_id): return [ @@ -26,7 +42,7 @@ class PosOrder(models.Model): def _prepare_fields_for_pos_list(self): return [ 'name', 'pos_reference', 'partner_id', 'date_order', - 'amount_total', 'amount_paid', 'amount_return', 'session_id', + 'amount_total', 'amount_paid', 'amount_return', 'session_id', 'amount_tax', 'statement_ids', 'lines', 'invoice_id', 'returned_order_id', 'fiscal_position_id' ] @@ -43,9 +59,9 @@ class PosOrder(models.Model): # Search globally by criteria condition += self._prepare_filter_query_for_pos(pos_session_id, query) - fields = self._prepare_fields_for_pos_list() + field_names = self._prepare_fields_for_pos_list() return self.search_read( - condition, fields, limit=config.iface_load_done_order_max_qty) + condition, field_names, limit=config.iface_load_done_order_max_qty) @api.multi def _prepare_done_order_for_pos(self): @@ -102,9 +118,7 @@ class PosOrder(models.Model): if (not pos_order.get('return') or not pos_order.get('returned_order_id')): return super()._process_order(pos_order) - order = super(PosOrder, - self.with_context(do_not_check_negative_qty=True) - )._process_order(pos_order) + order = super(PosOrder, self)._process_order(pos_order) returned_order_id = pos_order.get('returned_order_id') if isinstance(returned_order_id, int): order.returned_order_id = self.browse(returned_order_id) diff --git a/pos_order_mgmt/views/view_pos_config.xml b/pos_order_mgmt/views/view_pos_config.xml index 391c9848..f94ac8ad 100644 --- a/pos_order_mgmt/views/view_pos_config.xml +++ b/pos_order_mgmt/views/view_pos_config.xml @@ -16,7 +16,7 @@
-