Maintainers
This module is maintained by the OCA.
- + + +OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use.
diff --git a/pos_operating_unit/README.rst b/pos_operating_unit/README.rst index 7c24db1d93..6596f5fde7 100644 --- a/pos_operating_unit/README.rst +++ b/pos_operating_unit/README.rst @@ -1,6 +1,6 @@ -========================= -POS Operating Unit Access -========================= +======================== +POS with Operating Units +======================== .. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! diff --git a/pos_operating_unit/__manifest__.py b/pos_operating_unit/__manifest__.py index 17bf915eb4..9a4a89fd63 100644 --- a/pos_operating_unit/__manifest__.py +++ b/pos_operating_unit/__manifest__.py @@ -1,6 +1,6 @@ { - "name": "POS Operating Unit Access", - "version": "14.0.1.0.0", + "name": "POS with Operating Units", + "version": "17.0.1.0.0", "author": "Ilyas, Ooops404, Odoo Community Association (OCA)", "website": "https://github.com/OCA/operating-unit", "category": "Point of sale", @@ -9,5 +9,6 @@ "data": [ "security/pos_security.xml", "views/pos_views.xml", + "views/res_config_settings_views.xml", ], } diff --git a/pos_operating_unit/models/__init__.py b/pos_operating_unit/models/__init__.py index 55d2bb6794..199e05d7ee 100644 --- a/pos_operating_unit/models/__init__.py +++ b/pos_operating_unit/models/__init__.py @@ -2,3 +2,4 @@ from . import pos_order from . import pos_session from . import pos_payment +from . import res_config_settings diff --git a/pos_operating_unit/models/pos_order.py b/pos_operating_unit/models/pos_order.py index 0c19571c9e..1ec9085f02 100644 --- a/pos_operating_unit/models/pos_order.py +++ b/pos_operating_unit/models/pos_order.py @@ -11,14 +11,15 @@ class POSOrder(models.Model): ) config_id = fields.Many2one(related="session_id.config_id", readonly=True) - @api.model - def create(self, vals): - session_id = self.env["pos.session"].sudo().browse(vals.get("session_id")) - if session_id.config_id: - vals["operating_unit_ids"] = [ - (6, 0, session_id.config_id.operating_unit_ids.ids) - ] - return super(POSOrder, self).create(vals) + @api.model_create_multi + def create(self, vals_list): + for vals in vals_list: + session_id = self.env["pos.session"].sudo().browse(vals.get("session_id")) + if session_id.config_id: + vals["operating_unit_ids"] = [ + (6, 0, session_id.config_id.operating_unit_ids.ids) + ] + return super().create(vals_list) class POSOrderLine(models.Model): @@ -30,11 +31,12 @@ class POSOrderLine(models.Model): string="Operating Units", ) - @api.model - def create(self, vals): - order_id = self.env["pos.order"].sudo().browse(vals.get("order_id")) - if order_id.config_id: - vals["operating_unit_ids"] = [ - (6, 0, order_id.config_id.operating_unit_ids.ids) - ] - return super(POSOrderLine, self).create(vals) + @api.model_create_multi + def create(self, vals_list): + for vals in vals_list: + order_id = self.env["pos.order"].sudo().browse(vals.get("order_id")) + if order_id.config_id: + vals["operating_unit_ids"] = [ + (6, 0, order_id.config_id.operating_unit_ids.ids) + ] + return super().create(vals_list) diff --git a/pos_operating_unit/models/pos_payment.py b/pos_operating_unit/models/pos_payment.py index 5f7098d4f8..82be4ba6fb 100644 --- a/pos_operating_unit/models/pos_payment.py +++ b/pos_operating_unit/models/pos_payment.py @@ -11,11 +11,12 @@ class POSPayment(models.Model): ) config_id = fields.Many2one(related="session_id.config_id", readonly=True) - @api.model - def create(self, vals): - pos_order_id = self.env["pos.order"].sudo().browse(vals.get("pos_order_id")) - if pos_order_id.config_id: - vals["operating_unit_ids"] = [ - (6, 0, pos_order_id.config_id.operating_unit_ids.ids) - ] - return super(POSPayment, self).create(vals) + @api.model_create_multi + def create(self, vals_list): + for vals in vals_list: + pos_order_id = self.env["pos.order"].sudo().browse(vals.get("pos_order_id")) + if pos_order_id.config_id: + vals["operating_unit_ids"] = [ + (6, 0, pos_order_id.config_id.operating_unit_ids.ids) + ] + return super().create(vals_list) diff --git a/pos_operating_unit/models/pos_session.py b/pos_operating_unit/models/pos_session.py index 734235265d..3a6b97ec40 100644 --- a/pos_operating_unit/models/pos_session.py +++ b/pos_operating_unit/models/pos_session.py @@ -10,9 +10,10 @@ class POSSession(models.Model): string="Operating Units", ) - @api.model - def create(self, vals): - config_id = self.env["pos.config"].sudo().browse(vals.get("config_id")) - if config_id: - vals["operating_unit_ids"] = [(6, 0, config_id.operating_unit_ids.ids)] - return super(POSSession, self).create(vals) + @api.model_create_multi + def create(self, vals_list): + for vals in vals_list: + config_id = self.env["pos.config"].sudo().browse(vals.get("config_id")) + if config_id: + vals["operating_unit_ids"] = [(6, 0, config_id.operating_unit_ids.ids)] + return super().create(vals_list) diff --git a/pos_operating_unit/models/res_config_settings.py b/pos_operating_unit/models/res_config_settings.py new file mode 100644 index 0000000000..087acd3d83 --- /dev/null +++ b/pos_operating_unit/models/res_config_settings.py @@ -0,0 +1,10 @@ +from odoo import fields, models + + +class ResConfigSettings(models.TransientModel): + _inherit = "res.config.settings" + + pos_operating_unit_ids = fields.Many2many( + related="pos_config_id.operating_unit_ids", + readonly=False, + ) diff --git a/pos_operating_unit/security/pos_security.xml b/pos_operating_unit/security/pos_security.xml index 36630438bd..e2ce66e1f0 100644 --- a/pos_operating_unit/security/pos_security.xml +++ b/pos_operating_unit/security/pos_security.xml @@ -3,7 +3,7 @@