From 5f5f8d8efee6061b673a0682c7fccc6e59b490ab Mon Sep 17 00:00:00 2001 From: Jeremy Kersten Date: Thu, 21 Apr 2016 18:00:28 +0200 Subject: [PATCH] [IMP] sale: allow to show total of order line tax inc or based on unit price. Allow to set in configuration mode b2b or b2c. Change the column of order line in sale view and in reports depending of sale. Fix price_reduce field (wrong if tax was included in price) and merge with code discounted_price from website_sale. Change header from reports "Price Tax Excluded' by 'Price' in report. That is wrong, sometime the amount can haxe tax included in the price. --- addons/account/views/report_overdue.xml | 2 +- addons/sale/res_config.py | 23 ++++++++++++++++--- addons/sale/res_config_view.xml | 6 +++++ addons/sale/sale.py | 16 +++++++++++-- addons/sale/sale_view.xml | 3 ++- addons/sale/security/sale_security.xml | 14 +++++++++++ addons/sale/views/report_invoice_layouted.xml | 9 ++++++-- addons/sale/views/report_saleorder.xml | 9 ++++++-- .../website_quote/views/website_quotation.xml | 14 +++++++---- addons/website_sale/models/sale_order.py | 11 --------- addons/website_sale/views/templates.xml | 6 ++--- 11 files changed, 83 insertions(+), 30 deletions(-) diff --git a/addons/account/views/report_overdue.xml b/addons/account/views/report_overdue.xml index 8071c8d7601..79e0e3cf025 100644 --- a/addons/account/views/report_overdue.xml +++ b/addons/account/views/report_overdue.xml @@ -55,7 +55,7 @@ - Sub-Total : + Subtotal : diff --git a/addons/sale/res_config.py b/addons/sale/res_config.py index e675ea343aa..5027f89cf86 100644 --- a/addons/sale/res_config.py +++ b/addons/sale/res_config.py @@ -66,9 +66,15 @@ class sale_configuration(osv.TransientModel): (1, 'Display 3 fields on sales orders: customer, invoice address, delivery address') ], "Addresses", implied_group='sale.group_delivery_invoice_address'), 'sale_pricelist_setting': fields.selection([('fixed', 'A single sale price per product'), ('percentage', 'Different prices per customer segment'), ('formula', 'Advanced pricing based on formula')], required=True, - help='Fix Price: all price manage from products sale price.\n' - 'Different prices per Customer: you can assign price on buying of minimum quantity in products sale tab.\n' - 'Advanced pricing based on formula: You can have all the rights on pricelist'), + help='Fix Price: all price manage from products sale price.\n' + 'Different prices per Customer: you can assign price on buying of minimum quantity in products sale tab.\n' + 'Advanced pricing based on formula: You can have all the rights on pricelist'), + 'group_show_price_subtotal': fields.boolean("Show subtotal", implied_group='sale.group_show_price_subtotal', group='base.group_portal,base.group_user,base.group_public'), + 'group_show_price_total': fields.boolean("Show total", implied_group='sale.group_show_price_total', group='base.group_portal,base.group_user,base.group_public'), + 'sale_show_tax': fields.selection([ + ('total', 'Show line subtotals with taxes included (B2C)'), + ('subtotal', 'Show line subtotals without taxes (except if unit price includes taxes) (B2B)')], "Tax Display", + required=True), 'default_invoice_policy': fields.selection([ ('order', 'Invoice ordered quantities'), ('delivery', 'Invoice delivered quantities') @@ -87,6 +93,7 @@ class sale_configuration(osv.TransientModel): _defaults = { 'sale_pricelist_setting': 'fixed', + 'sale_show_tax': 'subtotal', 'default_invoice_policy': 'order', } @@ -111,3 +118,13 @@ class sale_configuration(osv.TransientModel): if sale_pricelist_setting == 'formula': return {'value': {'group_pricelist_item': True, 'group_sale_pricelist': True, 'group_product_pricelist': False}} return {'value': {'group_pricelist_item': False, 'group_sale_pricelist': False, 'group_product_pricelist': False}} + + def set_sale_tax_defaults(self, cr, uid, ids, context=None): + sale_tax = self.browse(cr, uid, ids, context=context).sale_show_tax + res = self.pool.get('ir.values').set_default(cr, SUPERUSER_ID, 'sale.config.settings', 'sale_show_tax', sale_tax) + return res + + def onchange_sale_tax(self, cr, uid, ids, sale_show_tax, context=None): + res = {'value': dict(group_show_price_subtotal=False, group_show_price_total=False)} + res['value']['group_show_price_%s' % sale_show_tax] = True + return res diff --git a/addons/sale/res_config_view.xml b/addons/sale/res_config_view.xml index cb58e4ae0b6..7377bdbbeb6 100644 --- a/addons/sale/res_config_view.xml +++ b/addons/sale/res_config_view.xml @@ -22,6 +22,12 @@ +