From 6ddaaf2f8eb088e8d44714d0564ffe818338c2e5 Mon Sep 17 00:00:00 2001 From: Haresh Shyara Date: Thu, 1 Dec 2016 16:29:29 +0530 Subject: [PATCH] [IMP] point_of_sale*: Improve the settings form view --- addons/point_of_sale/models/res_config.py | 72 +++++--- .../point_of_sale/views/res_config_view.xml | 167 +++++++++++++++--- addons/pos_mercury/__manifest__.py | 1 + .../views/pos_config_setting_views.xml | 15 ++ 4 files changed, 210 insertions(+), 45 deletions(-) create mode 100644 addons/pos_mercury/views/pos_config_setting_views.xml diff --git a/addons/point_of_sale/models/res_config.py b/addons/point_of_sale/models/res_config.py index a11834ed634..415d1c75876 100644 --- a/addons/point_of_sale/models/res_config.py +++ b/addons/point_of_sale/models/res_config.py @@ -1,32 +1,58 @@ # -*- coding: utf-8 -*- # Part of Odoo. See LICENSE file for full copyright and licensing details. -from odoo import fields, models +from odoo import api, fields, models class PosConfiguration(models.TransientModel): _inherit = 'res.config.settings' _name = 'pos.config.settings' - module_pos_restaurant = fields.Selection([ - (0, "Point of sale for shops"), - (1, "Restaurant: activate table management") - ], string="Restaurant", - help='This module adds several restaurant features to the Point of Sale: \n\n- Bill Printing: Allows you to print a receipt before the order is paid \n\n- Bill Splitting: Allows you to split an order into different orders \n\n- Kitchen Order Printing: allows you to print orders updates to kitchen or bar printers') - module_pos_loyalty = fields.Boolean( - string="Loyalty Program", - help='Allows you to define a loyalty program in the point of sale, where the customers earn loyalty points and get rewards') - module_pos_discount = fields.Selection([ - (0, "Allow discounts on order lines only"), - (1, "Allow global discounts") - ], string="Discount", - help='Allows the cashier to quickly give a percentage sale discount for all the sales order to a customer') - module_pos_mercury = fields.Selection([ - (0, "No credit card"), - (1, "Allows customers to pay with credit cards.") - ], string="Credit Cards", - help='The transactions are processed by MercuryPay') - module_pos_reprint = fields.Selection([ - (0, "No reprint"), - (1, "Allow cashier to reprint receipts") - ], string="Reprints") + group_multi_currency = fields.Boolean("Multi-Currencies", implied_group='base.group_multi_currency') + group_product_variant = fields.Boolean("Attributes & Variants", implied_group='product.group_product_variant') + group_product_pricelist = fields.Boolean("Show pricelists On Products", + implied_group='product.group_product_pricelist') + group_pricelist_item = fields.Boolean("Show pricelists to customers", + implied_group='product.group_pricelist_item') + group_sale_pricelist = fields.Boolean("Use pricelists to adapt your price per customers", + implied_group='product.group_sale_pricelist', + help="""Allows to manage different prices based on rules per category of customers. + Example: 10% for retailers, promotion of 5 EUR on this product, etc.""") + default_sale_price = fields.Boolean("A single sale price per product", default_model='pos.config.settings') + default_pricelist_setting = fields.Selection([ + ('percentage', 'Multiple prices per product (e.g. quantity, shop-specific)'), + ('formula', 'Price computed from formulas (discounts, margins, rounding)') + ], string="Pricelists", default_model='pos.config.settings') + module_pos_restaurant = fields.Boolean(string="Restaurant") + module_pos_loyalty = fields.Boolean(string="Loyalty Program") + module_pos_discount = fields.Boolean(string="Global Discounts") + module_pos_mercury = fields.Boolean(string="Credit Cards") + module_pos_reprint = fields.Boolean(string="Reprint Receipt") module_pos_data_drinks = fields.Boolean(string="Import common drinks data") + + @api.onchange('default_sale_price') + def _onchange_fix_sale_price(self): + if not self.default_sale_price: + self.default_pricelist_setting = False + if self.default_sale_price and not self.default_pricelist_setting: + self.default_pricelist_setting = 'percentage' + + @api.onchange('default_pricelist_setting') + def _onchange_sale_price(self): + if self.default_pricelist_setting == 'percentage': + self.update({ + 'group_product_pricelist': True, + 'group_sale_pricelist': True, + 'group_pricelist_item': False, + }) + elif self.default_pricelist_setting == 'formula': + self.update({ + 'group_product_pricelist': False, + 'group_sale_pricelist': True, + 'group_pricelist_item': True, + }) + else: + self.update({ + 'group_product_pricelist': False, + 'group_sale_pricelist': False, + 'group_pricelist_item': False, + }) diff --git a/addons/point_of_sale/views/res_config_view.xml b/addons/point_of_sale/views/res_config_view.xml index 4e82b88ef7d..3e736489ee0 100644 --- a/addons/point_of_sale/views/res_config_view.xml +++ b/addons/point_of_sale/views/res_config_view.xml @@ -1,37 +1,160 @@ - + pos.config.settings.form pos.config.settings
-
- -