[IMP] pos: ease starting steps by adding general settings

In order to facilitate the usage of the pos app, we need to add a global
settings menu (res_config_settings).

Related to task #34026
Closes #19443
This commit is contained in:
Ankit Joshi
2018-05-22 15:44:34 +02:00
committed by RomainLibert
parent 4699f3c2bf
commit e434690fe3
14 changed files with 212 additions and 58 deletions
+1
View File
@@ -34,6 +34,7 @@
'views/pos_order_report_view.xml',
'views/account_statement_view.xml',
'views/account_statement_report.xml',
'views/res_config_settings_views.xml',
'views/res_users_views.xml',
'views/res_partner_view.xml',
'views/report_statement.xml',
+2
View File
@@ -11,3 +11,5 @@ from . import pos_session
from . import product
from . import res_partner
from . import res_users
from . import res_company
from . import res_config_settings
+7 -13
View File
@@ -93,7 +93,6 @@ class PosConfig(models.Model):
iface_customer_facing_display = fields.Boolean(string='Customer Facing Display', help="Show checkout to customers with a remotely-connected screen.")
iface_print_via_proxy = fields.Boolean(string='Print via Proxy', help="Bypass browser printing and prints via the hardware proxy.")
iface_scan_via_proxy = fields.Boolean(string='Scan via Proxy', help="Enable barcode scanning with a remotely connected barcode scanner.")
iface_invoicing = fields.Boolean(string='Invoicing', help='Enables invoice generation from the Point of Sale.')
iface_big_scrollbars = fields.Boolean('Large Scrollbars', help='For imprecise industrial touchscreens.')
iface_print_auto = fields.Boolean(string='Automatic Receipt Printing', default=False,
help='The receipt will automatically be printed at the end of each order.')
@@ -101,7 +100,7 @@ class PosConfig(models.Model):
help='The receipt screen will be skipped if the receipt can be printed automatically.')
iface_precompute_cash = fields.Boolean(string='Prefill Cash Payment',
help='The payment input will behave similarily to bank payment input, and will be prefilled with the exact due amount.')
iface_tax_included = fields.Selection([('subtotal', 'Tax-Excluded Prices'), ('total', 'Tax-Included Prices')], "Tax Display", default='subtotal', required=True)
iface_tax_included = fields.Selection([('subtotal', 'Tax-Excluded Price'), ('total', 'Tax-Included Price')], related="company_id.iface_tax_included", required=True)
iface_start_categ_id = fields.Many2one('pos.category', string='Initial Category',
help='The point of sale will display this product category by default. If no category is specified, all available products will be shown.')
iface_display_categ_images = fields.Boolean(string='Display Category Pictures',
@@ -151,16 +150,11 @@ class PosConfig(models.Model):
default_cashbox_lines_ids = fields.One2many('account.cashbox.line', 'default_pos_id', string='Default Balance')
customer_facing_display_html = fields.Html(string='Customer facing display content', translate=True, default=_compute_default_customer_html)
use_pricelist = fields.Boolean("Use a pricelist.")
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.""")
group_pricelist_item = fields.Boolean("Show pricelists to customers",
implied_group='product.group_pricelist_item')
tax_regime = fields.Boolean("Tax Regime")
tax_regime_selection = fields.Boolean("Tax Regime Selection value")
barcode_scanner = fields.Boolean("Barcode Scanner")
start_category = fields.Boolean("Set Start Category")
module_account_invoicing = fields.Boolean(string='Invoicing', help='Enables invoice generation from the Point of Sale.')
module_pos_restaurant = fields.Boolean("Is a Bar/Restaurant")
module_pos_discount = fields.Boolean("Global Discounts")
module_pos_loyalty = fields.Boolean("Loyalty Program")
@@ -259,6 +253,11 @@ class PosConfig(models.Model):
def _onchange_iface_print_via_proxy(self):
self.iface_print_auto = self.iface_print_via_proxy
@api.onchange('module_account_invoicing')
def _onchange_module_account_invoicing(self):
if self.module_account_invoicing:
self.invoice_journal_id = self.env.ref('point_of_sale.pos_sale_journal')
@api.onchange('picking_type_id')
def _onchange_picking_type_id(self):
if self.picking_type_id.default_location_src_id.usage == 'internal' and self.picking_type_id.default_location_dest_id.usage == 'customer':
@@ -272,11 +271,6 @@ class PosConfig(models.Model):
"""
if not self.use_pricelist:
self.pricelist_id = self._default_pricelist()
else:
self.update({
'group_sale_pricelist': True,
'group_pricelist_item': True,
})
@api.onchange('available_pricelist_ids')
def _onchange_available_pricelist_ids(self):
+1
View File
@@ -477,6 +477,7 @@ class PosOrder(models.Model):
domain="[('state', '=', 'opened')]", states={'draft': [('readonly', False)]},
readonly=True, default=_default_session)
config_id = fields.Many2one('pos.config', related='session_id.config_id', string="Point of Sale")
invoice_group = fields.Boolean(related="config_id.module_account_invoicing")
state = fields.Selection(
[('draft', 'New'), ('cancel', 'Cancelled'), ('paid', 'Paid'), ('done', 'Posted'), ('invoiced', 'Invoiced')],
'Status', readonly=True, copy=False, default='draft')
@@ -0,0 +1,9 @@
# -*- coding: utf-8 -*-
from odoo import fields, models
class ResCompany(models.Model):
_inherit = "res.company"
iface_tax_included = fields.Selection([('subtotal', 'Tax-Excluded Price'), ('total', 'Tax-Included Price')], default='subtotal', required=True)
@@ -0,0 +1,44 @@
# -*- coding: utf-8 -*-
from odoo import api, fields, models
class ResConfigSettings(models.TransientModel):
_inherit = 'res.config.settings'
sale_tax_id = fields.Many2one('account.tax', string="Default Sale Tax", related='company_id.account_sale_tax_id')
iface_tax_included = fields.Selection([('subtotal', 'Tax-Excluded Price'), ('total', 'Tax-Included Price')], related="company_id.iface_tax_included", required=True)
module_pos_mercury = fields.Boolean(string="Integrated Card Payments", help="The transactions are processed by Vantiv. Set your Vantiv credentials on the related payment journal.")
pos_sales_price = fields.Boolean("Multiple Product Prices", config_parameter='point_of_sale.pos_sales_price')
pos_pricelist_setting = fields.Selection([
('percentage', 'Multiple prices per product (e.g. customer segments, currencies)'),
('formula', 'Price computed from formulas (discounts, margins, roundings)')
], string="Pricelists", config_parameter='point_of_sale.pos_pricelist_setting')
@api.onchange('pos_sales_price')
def _onchange_sale_price(self):
if not self.pos_sales_price:
self.pos_pricelist_setting = False
if self.pos_sales_price and not self.pos_pricelist_setting:
self.pos_pricelist_setting = 'percentage'
@api.onchange('pos_pricelist_setting')
def _onchange_pos_pricelist_setting(self):
if self.pos_pricelist_setting == 'percentage':
self.update({
'group_product_pricelist': True,
'group_sale_pricelist': True,
'group_pricelist_item': False,
})
elif self.pos_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,
})
+1 -1
View File
@@ -678,7 +678,7 @@
</t>
</span>
</div>
<t t-if='widget.pos.config.iface_invoicing'>
<t t-if='widget.pos.config.module_account_invoicing'>
<t t-if='widget.pos.get_order()'>
<div t-attf-class='button js_invoice #{ widget.pos.get_order().is_to_invoice() ? "highlight" : ""} '>
<i class='fa fa-file-text-o' /> Invoice
@@ -141,8 +141,8 @@
</div>
</div>
<div t-if="widget.editable" class="o_kanban_card_manage_settings row">
<div class="col-xs-12 text-right">
<div t-if="widget.editable" class="o_kanban_card_manage_settings row" groups="point_of_sale.group_pos_manager">
<div class="col-xs-12">
<a type="edit">Settings</a>
</div>
</div>
@@ -14,6 +14,12 @@
parent="menu_point_root"
sequence="10"/>
<menuitem id="menu_point_of_sale_customer"
name="Customers"
parent="menu_point_of_sale"
action="base.action_partner_customer_form"
sequence="100"/>
<!-- Reporting menu -->
<menuitem id="menu_point_rep"
name="Reporting"
+7 -37
View File
@@ -211,20 +211,6 @@
</div>
<h2>Pricing</h2>
<div class="row mt16 o_settings_container">
<div class="col-xs-12 col-md-6 o_setting_box" id="product_prices">
<div class="o_setting_right_pane">
<label for="iface_tax_included" string="Product Prices"/>
<div class="text-muted">
Product prices on receipts
</div>
<div class="content-group">
<div class="mt16">
<field name="iface_tax_included" class="o_light_label" widget="radio"/>
</div>
<a attrs="{'invisible': [('iface_tax_included', '!=', 'total')]}" href="https://www.odoo.com/documentation/user/11.0/accounting/others/taxes/tax_included.html" target="_blank" class="oe-link"><i class="fa fa-fw fa-arrow-right"/>How to manage tax-included prices</a>
</div>
</div>
</div>
<div class="col-xs-12 col-md-6 o_setting_box" >
<div class="o_setting_left_pane">
<field name="module_pos_discount"/>
@@ -267,7 +253,7 @@
</div>
<div class="col-xs-12 col-md-6 o_setting_box">
<div class="o_setting_left_pane">
<field name="module_pos_loyalty" widget="upgrade_boolean"/>
<field name="module_pos_loyalty" widget="upgrade_boolean" nolabel="1"/>
</div>
<div class="o_setting_right_pane" title="Loyalty program to use for this point of sale. ">
<label for="module_pos_loyalty"/>
@@ -309,22 +295,6 @@
</div>
</div>
</div>
<div class="col-xs-12 col-md-6 o_setting_box">
<div class="o_setting_left_pane">
<field name="module_pos_mercury"/>
</div>
<div class="o_setting_right_pane">
<label for="module_pos_mercury" string="Integrated Card Reader"/>
<div class="text-muted">
Accept payments with an integrated card reader
</div>
<div class="content-group" attrs="{'invisible': [('module_pos_mercury', '=', False)]}">
<div class="mt16" id="btn_use_pos_mercury">
<button string="Save" type="object" name="execute" class="oe_highlight"/>
</div>
</div>
</div>
</div>
<div class="col-xs-12 col-md-6 o_setting_box">
<div class="o_setting_left_pane">
<field name="cash_control"/>
@@ -425,14 +395,14 @@
</div>
<div class="col-xs-12 col-md-6 o_setting_box" id="iface_invoicing">
<div class="o_setting_left_pane">
<field name="iface_invoicing"/>
<field name="module_account_invoicing"/>
</div>
<div class="o_setting_right_pane">
<label for="iface_invoicing"/>
<label for="module_account_invoicing"/>
<div class="text-muted" id="invoice_journal">
Print invoices on customer request
</div>
<div class="content-group mt16" attrs="{'invisible': [('iface_invoicing', '=', False)]}">
<div class="content-group mt16" attrs="{'invisible': [('module_account_invoicing', '=', False)]}">
<div class="row mt16">
<label string="Invoice Journal" for="invoice_journal_id" class="col-md-3 o_light_label"/>
<field name="invoice_journal_id"/>
@@ -466,8 +436,8 @@
</div>
</div>
</div>
<h2 attrs="{'invisible': [('is_installed_account_accountant', '=', False)]}">Accounting</h2>
<div class="row mt16 o_settings_container" attrs="{'invisible': [('is_installed_account_accountant', '=', False)]}">
<h2>Accounting</h2>
<div class="row mt16 o_settings_container">
<div class="col-xs-12 col-md-6 o_setting_box">
<div class="o_setting_right_pane">
<label string="Journal Entries"/>
@@ -536,7 +506,7 @@
id="menu_pos_config_pos"
name="Point of Sale"
parent="menu_point_config_product"
sequence="0"
sequence="1"
action="action_pos_config_pos"
groups="group_pos_manager"/>
@@ -7,7 +7,7 @@
<form string="Point of Sale Orders" create="0">
<header>
<button name="%(action_pos_payment)d" string="Payment" class="oe_highlight" type="action" states="draft" context="{'pos_session_id' : session_id}"/>
<button name="action_pos_order_invoice" string="Invoice" type="object" states="paid" attrs="{'readonly': [('partner_id','=',False)]}"/>
<button name="action_pos_order_invoice" string="Invoice" type="object" attrs="{'invisible': ['|', ('invoice_group', '=', False), ('state','!=','invoiced')], 'readonly': [('partner_id','=',False)]}"/>
<button name="refund" string="Return Products" type="object"
attrs="{'invisible':[('state','=','draft')]}"/>
<field name="state" widget="statusbar" statusbar_visible="draft,paid,done" />
@@ -28,6 +28,7 @@
<field name="session_id" />
<field name="partner_id" domain="[('customer', '=', True)]" context="{'search_default_customer':1}" attrs="{'readonly': [('state','=','invoiced')]}"/>
<field name="fiscal_position_id" options="{'no_create': True}"/>
<field name="invoice_group" invisible="1"/>
</group>
<notebook colspan="4">
<page string="Products">
@@ -85,7 +86,7 @@
<field name="picking_id" readonly="1"/>
<field name="pos_reference"/>
</group>
<group string="Accounting Information">
<group string="Accounting Information" groups="account.group_account_manager">
<group>
<field name="sale_journal" domain="[('type','=','sale')]"/>
<field name="account_move" readonly="1"
+1 -1
View File
@@ -64,7 +64,7 @@
<!-- Product Catalog menus and sub menus -->
<menuitem id="pos_config_menu_catalog"
name="Catalog"
name="Product"
parent="point_of_sale.menu_point_root"/>
<menuitem id="menu_pos_products"
action="product_template_action_pos_product"
@@ -0,0 +1,126 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="res_config_settings_view_form" model="ir.ui.view">
<field name="name">res.config.settings.view.form.inherit.point_of_sale</field>
<field name="model">res.config.settings</field>
<field name="priority" eval="95"/>
<field name="inherit_id" ref="base.res_config_settings_view_form" />
<field name="arch" type="xml">
<xpath expr="//div[hasclass('settings')]" position="inside">
<div class="app_settings_block" data-string="Point of sale" string="Point of Sale" data-key="point_of_sale" groups="point_of_sale.group_pos_manager">
<h2>Taxes</h2>
<div class="row mt16 o_settings_container">
<div class="col-xs-12 col-md-6 o_setting_box" title="This tax is applied to any new product created in the catalog.">
<div class="o_setting_right_pane">
<div>
<label string="Default Sales Tax"/>
<div class="text-muted">
Default sales tax for products
</div>
<div class="content-group mt16">
<field name="sale_tax_id" colspan="4" nolabel="1" domain="[('type_tax_use', 'in', ('sale', 'all')), ('company_id', '=', company_id)]"/>
</div>
</div>
<div>
<button name="%(account.action_tax_form)d" icon="fa-arrow-right" type="action" string="Taxes" class="btn-link"/>
</div>
</div>
</div>
</div>
<h2>Pricing</h2>
<div class="row mt16 o_settings_container">
<div class="col-xs-12 col-md-6 o_setting_box" id="product_prices">
<div class="o_setting_right_pane">
<label for="iface_tax_included" string="Product Prices"/>
<div class="text-muted">
Product prices on receipts
</div>
<div class="content-group">
<div class="mt16">
<field name="iface_tax_included" class="o_light_label" widget="radio"/>
</div>
<a attrs="{'invisible': [('iface_tax_included', '!=', 'total')]}" href="https://www.odoo.com/documentation/user/11.0/accounting/others/taxes/tax_included.html" target="_blank" class="oe-link"><i class="fa fa-fw fa-arrow-right"/>How to manage tax-included prices</a>
</div>
</div>
</div>
<div class="col-xs-12 col-md-6 o_setting_box" title="There are two ways to manage pricelists: 1) Multiple prices per product (e.g. quantity, shop-specific) : must be set in the Sales tab of the product detail form. 2) Price computed from formulas (discounts, margins, rounding) : must be set in the pricelist form.">
<div class="o_setting_left_pane">
<field name="pos_sales_price"/>
</div>
<div class="o_setting_right_pane">
<label for="pos_sales_price"/>
<div class="text-muted">
Set multiple prices per product, automated discounts, etc.
</div>
<div class="content-group" attrs="{'invisible': [('pos_sales_price' ,'=', False)]}">
<div class="mt16">
<field name="group_product_pricelist" invisible="1"/>
<field name="group_sale_pricelist" invisible="1"/>
<field name="group_pricelist_item" invisible="1"/>
<field name="pos_pricelist_setting" widget="radio" class="o_light_label"/>
</div>
<button name="%(product.product_pricelist_action2)d" icon="fa-arrow-right" type="action" string="Pricelists"
attrs="{'invisible': [('pos_pricelist_setting', '=', False)]}" class="btn-link"/>
</div>
</div>
</div>
<div class="col-xs-12 col-md-6 o_setting_box" id="multicurrencies_setting" title="This adds the choice of a currency on pricelists.">
<div class="o_setting_left_pane">
<field name="group_multi_currency"/>
</div>
<div class="o_setting_right_pane">
<label for="group_multi_currency"/>
<div class="text-muted">
Sell in several currencies
</div>
<div class="content-group" attrs="{'invisible': [('group_multi_currency', '=', False)]}">
<div class="mt16">
<button type="action" name="%(base.action_currency_form)d" string="Currencies" class="btn-link" icon="fa-arrow-right"/>
</div>
<div>
<button name="%(base.action_currency_all_form)d" icon="fa-arrow-right" type="action" string="Advanced Currencies Setup" class="btn-link"/>
</div>
</div>
</div>
</div>
</div>
<h2>Payments</h2>
<div class="row mt16 o_settings_container">
<div class="col-xs-12 col-md-6 o_setting_box" title="The transactions are processed by Vantiv. Set your Vantiv credentials on the related payment journal.">
<div class="o_setting_left_pane">
<field name="module_pos_mercury"/>
</div>
<div class="o_setting_right_pane">
<label for="module_pos_mercury" string="Credit Card Reader"/>
<div class="text-muted">
Accept payments with a credit card reader
</div>
<div class="content-group" attrs="{'invisible': [('module_pos_mercury', '=', False)]}">
<div class="mt16" id="btn_use_pos_mercury">
<button string="Save" type="object" name="execute" class="oe_highlight"/>
</div>
</div>
</div>
</div>
</div>
</div>
</xpath>
</field>
</record>
<record id="action_pos_configuration" model="ir.actions.act_window">
<field name="name">Settings</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">res.config.settings</field>
<field name="view_mode">form</field>
<field name="target">inline</field>
<field name="context">{'module' : 'point_of_sale'}</field>
</record>
<menuitem id="menu_pos_global_settings"
name="Settings"
parent="menu_point_config_product"
sequence="0"
action="action_pos_configuration"
groups="base.group_system"/>
</odoo>
@@ -2,8 +2,8 @@
<odoo>
<record id="pos_config_view_form_inherit_pos_mercury" model="ir.ui.view">
<field name="name">pos.config.form.inherit.mercury</field>
<field name="model">pos.config</field>
<field name="inherit_id" ref="point_of_sale.pos_config_view_form"/>
<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="btn_use_pos_mercury" position="replace">
<div class="mt16">