[ADD] sales_discount Module
This commit is contained in:
parent
34af6f521e
commit
fe79fe27e6
4
addons/sales_discount/__init__.py
Normal file
4
addons/sales_discount/__init__.py
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
# Part of Flectra See LICENSE file for full copyright and licensing details.
|
||||||
|
|
||||||
|
from . import models
|
||||||
|
from . import report
|
27
addons/sales_discount/__manifest__.py
Normal file
27
addons/sales_discount/__manifest__.py
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
# Part of Flectra See LICENSE file for full copyright and licensing details.
|
||||||
|
|
||||||
|
{
|
||||||
|
'name': "Sale Discount",
|
||||||
|
'category': 'Sale',
|
||||||
|
'description': """
|
||||||
|
Customized module for amending discounts
|
||||||
|
""",
|
||||||
|
'summary': 'Global Discount on Sale Order',
|
||||||
|
'author': 'FlectraHQ',
|
||||||
|
'website': 'https://flectrahq.com',
|
||||||
|
'version': '1.0',
|
||||||
|
'depends': ['sale_management', 'sale_stock', 'account_discount'],
|
||||||
|
'data': [
|
||||||
|
'security/ir.model.access.csv',
|
||||||
|
'data/sale_discount_data.xml',
|
||||||
|
'views/res_config_settings_views.xml',
|
||||||
|
'views/sale_discount_config_view.xml',
|
||||||
|
'views/sale_view.xml',
|
||||||
|
'report/sale_order_report_view.xml',
|
||||||
|
],
|
||||||
|
'demo': [
|
||||||
|
'demo/sale_order.xml',
|
||||||
|
],
|
||||||
|
'installable': True,
|
||||||
|
'auto_install': False,
|
||||||
|
}
|
22
addons/sales_discount/data/sale_discount_data.xml
Normal file
22
addons/sales_discount/data/sale_discount_data.xml
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<flectra noupdate="1">
|
||||||
|
|
||||||
|
<record id="sale_discount_config_1" model="sale.discount.config">
|
||||||
|
<field name="group_id" ref="base.group_system"/>
|
||||||
|
<field name="fix_amount">1000</field>
|
||||||
|
<field name="percentage">25</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<record id="sale_discount_config_2" model="sale.discount.config">
|
||||||
|
<field name="group_id" ref="base.group_erp_manager"/>
|
||||||
|
<field name="fix_amount">500</field>
|
||||||
|
<field name="percentage">15</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<record id="sale_discount_config_3" model="sale.discount.config">
|
||||||
|
<field name="group_id" ref="base.group_no_one"/>
|
||||||
|
<field name="fix_amount">100</field>
|
||||||
|
<field name="percentage">10</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
</flectra>
|
36
addons/sales_discount/demo/sale_order.xml
Normal file
36
addons/sales_discount/demo/sale_order.xml
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<flectra noupdate="1">
|
||||||
|
|
||||||
|
<record model="sale.order" id="discount_sale_order">
|
||||||
|
<field name="partner_id" ref="base.res_partner_3"/>
|
||||||
|
<field name="discount_method">per</field>
|
||||||
|
<field name="discount_per">10</field>
|
||||||
|
<field name="pricelist_id" ref="product.list0"/>
|
||||||
|
<field name="partner_invoice_id" ref="base.res_partner_address_11"/>
|
||||||
|
<field name="user_id" ref="base.user_root"/>
|
||||||
|
<field name="state">draft</field>
|
||||||
|
<field name="team_id" ref="sales_team.team_sales_department"/>
|
||||||
|
<field name="partner_shipping_id" ref="base.res_partner_address_11"/>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<record model="sale.order.line" id="discount_sale_order_line_1">
|
||||||
|
<field name="order_id" ref="discount_sale_order"/>
|
||||||
|
<field name="name">Headset USB</field>
|
||||||
|
<field name="product_id" ref="product.product_delivery_01"/>
|
||||||
|
<field name="product_uom_qty">10</field>
|
||||||
|
<field name="product_uom" ref="product.product_uom_unit"/>
|
||||||
|
<field name="price_unit">65</field>
|
||||||
|
<field name="discount">10</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<record model="sale.order.line" id="discount_sale_order_line_2">
|
||||||
|
<field name="order_id" ref="discount_sale_order"/>
|
||||||
|
<field name="name">Laptop E5023</field>
|
||||||
|
<field name="product_id" ref="product.product_product_25"/>
|
||||||
|
<field name="product_uom_qty">20</field>
|
||||||
|
<field name="product_uom" ref="product.product_uom_unit"/>
|
||||||
|
<field name="price_unit">2950.00</field>
|
||||||
|
<field name="discount">10</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
</flectra>
|
247
addons/sales_discount/i18n/sales_discount.pot
Normal file
247
addons/sales_discount/i18n/sales_discount.pot
Normal file
@ -0,0 +1,247 @@
|
|||||||
|
# Translation of Flectra Server.
|
||||||
|
# This file contains the translation of the following modules:
|
||||||
|
# * sales_discount
|
||||||
|
#
|
||||||
|
msgid ""
|
||||||
|
msgstr ""
|
||||||
|
"Project-Id-Version: Flectra Server 1.0\n"
|
||||||
|
"Report-Msgid-Bugs-To: \n"
|
||||||
|
"POT-Creation-Date: 2018-01-04 11:42+0000\n"
|
||||||
|
"PO-Revision-Date: 2018-01-04 11:42+0000\n"
|
||||||
|
"Last-Translator: <>\n"
|
||||||
|
"Language-Team: \n"
|
||||||
|
"MIME-Version: 1.0\n"
|
||||||
|
"Content-Type: text/plain; charset=UTF-8\n"
|
||||||
|
"Content-Transfer-Encoding: \n"
|
||||||
|
"Plural-Forms: \n"
|
||||||
|
|
||||||
|
#. module: sales_discount
|
||||||
|
#: model:ir.ui.view,arch_db:sales_discount.inherit_view_order_form
|
||||||
|
msgid "(Update Discount)"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. module: sales_discount
|
||||||
|
#: model:ir.ui.view,arch_db:sales_discount.inherit_view_order_form
|
||||||
|
msgid "(update)"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. module: sales_discount
|
||||||
|
#: model:ir.ui.view,arch_db:sales_discount.custom_report_sale_layout
|
||||||
|
msgid "<strong>Discount</strong>"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. module: sales_discount
|
||||||
|
#: model:ir.ui.view,arch_db:sales_discount.custom_report_sale_layout
|
||||||
|
msgid "<strong>Gross Amount</strong>"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. module: sales_discount
|
||||||
|
#: model:ir.ui.view,arch_db:sales_discount.custom_report_sale_layout
|
||||||
|
msgid "<strong>Taxes</strong>"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. module: sales_discount
|
||||||
|
#: model:ir.ui.view,arch_db:sales_discount.custom_report_sale_layout
|
||||||
|
msgid "<strong>Total</strong>"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. module: sales_discount
|
||||||
|
#: model:ir.ui.view,arch_db:sales_discount.custom_report_sale_layout
|
||||||
|
msgid "<strong>Untaxed Amount</strong>"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. module: sales_discount
|
||||||
|
#: model:ir.ui.view,arch_db:sales_discount.res_config_settings_view_discount_form
|
||||||
|
msgid "Allow global discount on the sale order"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. module: sales_discount
|
||||||
|
#: code:addons/sales_discount/models/sale_discount_config.py:21
|
||||||
|
#, python-format
|
||||||
|
msgid "Assigned group already exist!"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. module: sales_discount
|
||||||
|
#: model:ir.model.fields,field_description:sales_discount.field_sale_discount_config_create_uid
|
||||||
|
msgid "Created by"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. module: sales_discount
|
||||||
|
#: model:ir.model.fields,field_description:sales_discount.field_sale_discount_config_create_date
|
||||||
|
msgid "Created on"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. module: sales_discount
|
||||||
|
#: model:ir.model.fields,field_description:sales_discount.field_sale_order_discount
|
||||||
|
#: model:ir.ui.view,arch_db:sales_discount.inherit_view_order_form
|
||||||
|
msgid "Discount"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. module: sales_discount
|
||||||
|
#: model:ir.model.fields,field_description:sales_discount.field_sale_order_discount_per
|
||||||
|
msgid "Discount (%)"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. module: sales_discount
|
||||||
|
#: code:addons/sales_discount/models/sale.py:121
|
||||||
|
#, python-format
|
||||||
|
msgid "Discount (%s) should be less than Gross Amount (%s)."
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. module: sales_discount
|
||||||
|
#: model:ir.model.fields,field_description:sales_discount.field_sale_order_discount_amount
|
||||||
|
msgid "Discount Amount"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. module: sales_discount
|
||||||
|
#: model:ir.model.fields,field_description:sales_discount.field_sale_order_discount_method
|
||||||
|
msgid "Discount Method"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. module: sales_discount
|
||||||
|
#: code:addons/sales_discount/models/sale.py:118
|
||||||
|
#, python-format
|
||||||
|
msgid "Discount should be less than Gross Amount"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. module: sales_discount
|
||||||
|
#: model:ir.model.fields,field_description:sales_discount.field_sale_discount_config_display_name
|
||||||
|
msgid "Display Name"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. module: sales_discount
|
||||||
|
#: model:ir.model.fields,field_description:sales_discount.field_res_config_settings_global_discount_apply
|
||||||
|
msgid "Do you want to set global discount limit?"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. module: sales_discount
|
||||||
|
#: model:ir.model.fields,field_description:sales_discount.field_res_config_settings_global_discount_fix_amount
|
||||||
|
#: model:ir.model.fields,field_description:sales_discount.field_sale_discount_config_fix_amount
|
||||||
|
msgid "Fix Amount"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. module: sales_discount
|
||||||
|
#: code:addons/sales_discount/models/sale_discount_config.py:30
|
||||||
|
#, python-format
|
||||||
|
msgid "Fix amount (%s) is greater than configuration Amount (%s)!"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. module: sales_discount
|
||||||
|
#: selection:sale.order,discount_method:0
|
||||||
|
msgid "Fixed"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. module: sales_discount
|
||||||
|
#: model:ir.model.fields,field_description:sales_discount.field_res_config_settings_global_discount_per_so_invoice_line
|
||||||
|
msgid "Global Discounts"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. module: sales_discount
|
||||||
|
#: model:ir.model.fields,field_description:sales_discount.field_sale_order_gross_amount
|
||||||
|
msgid "Gross Amount"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. module: sales_discount
|
||||||
|
#: model:ir.model.fields,field_description:sales_discount.field_sale_discount_config_group_id
|
||||||
|
msgid "Groups"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. module: sales_discount
|
||||||
|
#: model:ir.model.fields,field_description:sales_discount.field_sale_discount_config_id
|
||||||
|
msgid "ID"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. module: sales_discount
|
||||||
|
#: model:ir.ui.view,arch_db:sales_discount.inherit_view_order_form
|
||||||
|
msgid "Invoices"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. module: sales_discount
|
||||||
|
#: model:ir.model.fields,field_description:sales_discount.field_sale_discount_config___last_update
|
||||||
|
msgid "Last Modified on"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. module: sales_discount
|
||||||
|
#: model:ir.model.fields,field_description:sales_discount.field_sale_discount_config_write_uid
|
||||||
|
msgid "Last Updated by"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. module: sales_discount
|
||||||
|
#: model:ir.model.fields,field_description:sales_discount.field_sale_discount_config_write_date
|
||||||
|
msgid "Last Updated on"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. module: sales_discount
|
||||||
|
#: model:ir.model.fields,field_description:sales_discount.field_sale_discount_config_percentage
|
||||||
|
#: selection:sale.order,discount_method:0
|
||||||
|
msgid "Percentage"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. module: sales_discount
|
||||||
|
#: model:ir.model.fields,field_description:sales_discount.field_res_config_settings_global_discount_percentage
|
||||||
|
msgid "Percentage (%)"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. module: sales_discount
|
||||||
|
#: code:addons/sales_discount/models/sale_discount_config.py:44
|
||||||
|
#, python-format
|
||||||
|
msgid "Percentage (%s) is greater than configuration Percentage (%s)!"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. module: sales_discount
|
||||||
|
#: code:addons/sales_discount/models/sale.py:94
|
||||||
|
#, python-format
|
||||||
|
msgid "Percentage should be between 0% to 100%"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. module: sales_discount
|
||||||
|
#: code:addons/sales_discount/models/sale_discount_config.py:38
|
||||||
|
#, python-format
|
||||||
|
msgid "Percentage should be between 0% to 100%!"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. module: sales_discount
|
||||||
|
#: model:ir.model,name:sales_discount.model_sale_order
|
||||||
|
msgid "Quotation"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. module: sales_discount
|
||||||
|
#: model:ir.ui.view,arch_db:sales_discount.sale_discount_config_view_form
|
||||||
|
msgid "Sale Discount Configuration"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. module: sales_discount
|
||||||
|
#: model:ir.ui.view,arch_db:sales_discount.res_config_settings_view_discount_form
|
||||||
|
msgid "Sale Order Discount"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. module: sales_discount
|
||||||
|
#: model:ir.actions.act_window,name:sales_discount.action_sale_discount_config
|
||||||
|
#: model:ir.ui.menu,name:sales_discount.menu_sale_order
|
||||||
|
msgid "Sales Discounts"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. module: sales_discount
|
||||||
|
#: code:addons/sales_discount/models/sale.py:97
|
||||||
|
#: code:addons/sales_discount/models/sale.py:106
|
||||||
|
#, python-format
|
||||||
|
msgid "You are not allowed to apply Discount Percentage (%s) more than configured Discount Percentage (%s) in configuration setting!"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. module: sales_discount
|
||||||
|
#: code:addons/sales_discount/models/sale.py:127
|
||||||
|
#: code:addons/sales_discount/models/sale.py:136
|
||||||
|
#, python-format
|
||||||
|
msgid "You're not allowed to apply Discount Amount (%s) more than configured amount (%s) in configuration setting!"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. module: sales_discount
|
||||||
|
#: model:ir.model,name:sales_discount.model_res_config_settings
|
||||||
|
msgid "res.config.settings"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. module: sales_discount
|
||||||
|
#: model:ir.model,name:sales_discount.model_sale_discount_config
|
||||||
|
msgid "sale.discount.config"
|
||||||
|
msgstr ""
|
||||||
|
|
5
addons/sales_discount/models/__init__.py
Normal file
5
addons/sales_discount/models/__init__.py
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
# Part of Flectra See LICENSE file for full copyright and licensing details.
|
||||||
|
|
||||||
|
from . import res_config_settings
|
||||||
|
from . import sale_discount_config
|
||||||
|
from . import sale
|
61
addons/sales_discount/models/res_config_settings.py
Normal file
61
addons/sales_discount/models/res_config_settings.py
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
# Part of Flectra See LICENSE file for full copyright and licensing details.
|
||||||
|
|
||||||
|
from flectra import api, fields, models
|
||||||
|
|
||||||
|
|
||||||
|
class ResConfigSettings(models.TransientModel):
|
||||||
|
_inherit = 'res.config.settings'
|
||||||
|
|
||||||
|
global_discount_per_so_invoice_line = fields.Boolean(
|
||||||
|
"Global Discounts",
|
||||||
|
implied_group='sales_discount.global_discount_per_so_invoice_line')
|
||||||
|
global_discount_apply = fields.Boolean(
|
||||||
|
"Do you want to set global discount limit?",
|
||||||
|
implied_group='sales_discount.global_discount_apply')
|
||||||
|
global_discount_fix_amount = fields.Integer(
|
||||||
|
'Fix Amount',
|
||||||
|
implied_group='sales_discount.global_discount_apply')
|
||||||
|
global_discount_percentage = fields.Integer(
|
||||||
|
'Percentage (%)',
|
||||||
|
implied_group='sales_discount.global_discount_percentage')
|
||||||
|
|
||||||
|
@api.onchange('global_discount_per_so_invoice_line')
|
||||||
|
def onchange_global_discount_per_so_invoice_line(self):
|
||||||
|
if not self.global_discount_per_so_invoice_line:
|
||||||
|
self.global_discount_apply = False
|
||||||
|
|
||||||
|
@api.onchange('global_discount_apply')
|
||||||
|
def onchange_global_discount_apply(self):
|
||||||
|
if not self.global_discount_apply:
|
||||||
|
self.global_discount_fix_amount = False
|
||||||
|
|
||||||
|
@api.model
|
||||||
|
def get_values(self):
|
||||||
|
res = super(ResConfigSettings, self).get_values()
|
||||||
|
res.update(
|
||||||
|
global_discount_per_so_invoice_line=self.env[
|
||||||
|
'ir.config_parameter'].sudo().get_param(
|
||||||
|
'global_discount_per_so_invoice_line'),
|
||||||
|
global_discount_apply=self.env[
|
||||||
|
'ir.config_parameter'].sudo().get_param(
|
||||||
|
'global_discount_apply'),
|
||||||
|
global_discount_fix_amount=int(self.env[
|
||||||
|
'ir.config_parameter'].sudo().get_param(
|
||||||
|
'global_discount_fix_amount')),
|
||||||
|
global_discount_percentage=int(self.env[
|
||||||
|
'ir.config_parameter'].sudo().get_param(
|
||||||
|
'global_discount_percentage')),
|
||||||
|
)
|
||||||
|
return res
|
||||||
|
|
||||||
|
def set_values(self):
|
||||||
|
super(ResConfigSettings, self).set_values()
|
||||||
|
params = self.env['ir.config_parameter'].sudo()
|
||||||
|
params.set_param('global_discount_per_so_invoice_line',
|
||||||
|
self.global_discount_per_so_invoice_line)
|
||||||
|
params.set_param('global_discount_apply',
|
||||||
|
self.global_discount_apply)
|
||||||
|
params.set_param('global_discount_fix_amount',
|
||||||
|
self.global_discount_fix_amount)
|
||||||
|
params.set_param('global_discount_percentage',
|
||||||
|
self.global_discount_percentage)
|
154
addons/sales_discount/models/sale.py
Normal file
154
addons/sales_discount/models/sale.py
Normal file
@ -0,0 +1,154 @@
|
|||||||
|
# Part of Flectra See LICENSE file for full copyright and licensing details.
|
||||||
|
|
||||||
|
from flectra import api, fields, models, _
|
||||||
|
from flectra.tools.misc import formatLang
|
||||||
|
from flectra.exceptions import Warning
|
||||||
|
|
||||||
|
|
||||||
|
class SaleOrder(models.Model):
|
||||||
|
_inherit = "sale.order"
|
||||||
|
|
||||||
|
@api.multi
|
||||||
|
@api.depends('discount_amount', 'discount_per', 'amount_untaxed')
|
||||||
|
def _get_discount(self):
|
||||||
|
total_discount = 0.0
|
||||||
|
for record in self:
|
||||||
|
for so_line_id in record.order_line:
|
||||||
|
total_price = \
|
||||||
|
(so_line_id.product_uom_qty * so_line_id.price_unit)
|
||||||
|
total_discount += (total_price * so_line_id.discount) / 100
|
||||||
|
record.discount = record.pricelist_id.currency_id.round(total_discount)
|
||||||
|
|
||||||
|
@api.multi
|
||||||
|
@api.depends('order_line', 'discount_per', 'discount_amount')
|
||||||
|
def _get_total_amount(self):
|
||||||
|
for order_id in self:
|
||||||
|
order_id.gross_amount = sum(
|
||||||
|
[line_id.product_uom_qty *
|
||||||
|
line_id.price_unit for line_id in order_id.order_line])
|
||||||
|
|
||||||
|
discount_method = fields.Selection(
|
||||||
|
[('fixed', 'Fixed'), ('per', 'Percentage')], string="Discount Method")
|
||||||
|
discount_amount = fields.Float(string="Discount Amount")
|
||||||
|
discount_per = fields.Float(string="Discount (%)")
|
||||||
|
discount = fields.Monetary(
|
||||||
|
string='Discount', store=True, readonly=True, compute='_get_discount',
|
||||||
|
track_visibility='always')
|
||||||
|
gross_amount = fields.Float(string="Gross Amount",
|
||||||
|
compute='_get_total_amount', store=True)
|
||||||
|
|
||||||
|
@api.multi
|
||||||
|
def calculate_discount(self):
|
||||||
|
self._check_constrains()
|
||||||
|
for line in self.order_line:
|
||||||
|
line.write({'discount': 0.0})
|
||||||
|
amount_untaxed = self.amount_untaxed
|
||||||
|
if self.discount_method == 'per':
|
||||||
|
for line in self.order_line:
|
||||||
|
line.write({'discount': line.discount + self.discount_per})
|
||||||
|
else:
|
||||||
|
for line in self.order_line:
|
||||||
|
discount_value_ratio = \
|
||||||
|
(self.discount_amount *
|
||||||
|
line.price_subtotal) / amount_untaxed
|
||||||
|
discount_per_ratio = \
|
||||||
|
(discount_value_ratio * 100) / line.price_subtotal
|
||||||
|
line.write({'discount': line.discount + discount_per_ratio})
|
||||||
|
|
||||||
|
@api.onchange('discount_method')
|
||||||
|
def onchange_discount_method(self):
|
||||||
|
self.discount_amount = 0.0
|
||||||
|
self.discount_per = 0.0
|
||||||
|
if self.discount_method and not self.order_line:
|
||||||
|
raise Warning('No Sale Order Line(s) were found!')
|
||||||
|
|
||||||
|
@api.constrains('discount_per', 'discount_amount', 'order_line')
|
||||||
|
def _check_constrains(self):
|
||||||
|
self.onchange_discount_per()
|
||||||
|
self.onchange_discount_amount()
|
||||||
|
|
||||||
|
@api.multi
|
||||||
|
def get_maximum_per_amount(self):
|
||||||
|
sale_dis_config_obj = self.env['sale.discount.config']
|
||||||
|
max_percentage = 0
|
||||||
|
max_amount = 0
|
||||||
|
check_group = False
|
||||||
|
for groups_id in self.env.user.groups_id:
|
||||||
|
sale_dis_config_id = \
|
||||||
|
sale_dis_config_obj.search([('group_id', '=', groups_id.id)])
|
||||||
|
if sale_dis_config_id:
|
||||||
|
check_group = True
|
||||||
|
if sale_dis_config_id.percentage > max_percentage:
|
||||||
|
max_percentage = sale_dis_config_id.percentage
|
||||||
|
if sale_dis_config_id.fix_amount > max_amount:
|
||||||
|
max_amount = sale_dis_config_id.fix_amount
|
||||||
|
return {'max_percentage': max_percentage,
|
||||||
|
'max_amount': max_amount, 'check_group': check_group}
|
||||||
|
|
||||||
|
@api.onchange('discount_per')
|
||||||
|
def onchange_discount_per(self):
|
||||||
|
values = self.get_maximum_per_amount()
|
||||||
|
if self.discount_method == 'per' and (
|
||||||
|
self.discount_per > 100 or self.discount_per < 0) and \
|
||||||
|
values.get('check_group', False):
|
||||||
|
raise Warning(_("Percentage should be between 0% to 100%"))
|
||||||
|
if self.discount_per > values.get('max_percentage', False) and \
|
||||||
|
values.get('check_group', False):
|
||||||
|
raise Warning(_("You are not allowed to apply Discount Percentage"
|
||||||
|
" (%s) more than configured Discount Percentage "
|
||||||
|
"(%s) in configuration setting!") % (
|
||||||
|
formatLang(self.env, self.discount_per, digits=2),
|
||||||
|
formatLang(self.env, values['max_percentage'], digits=2)))
|
||||||
|
config_id = self.env['res.config.settings'].search(
|
||||||
|
[], order='id desc', limit=1)
|
||||||
|
if config_id and config_id.global_discount_apply:
|
||||||
|
if config_id.global_discount_percentage < self.discount_per:
|
||||||
|
raise Warning(_("You are not allowed to apply Discount "
|
||||||
|
"Percentage (%s) more than configured "
|
||||||
|
"Discount Percentage (%s) in configuration "
|
||||||
|
"setting!") % (
|
||||||
|
formatLang(self.env, self.discount_per, digits=2),
|
||||||
|
formatLang(self.env, config_id.global_discount_percentage,
|
||||||
|
digits=2)))
|
||||||
|
|
||||||
|
@api.onchange('discount_amount')
|
||||||
|
def onchange_discount_amount(self):
|
||||||
|
values = self.get_maximum_per_amount()
|
||||||
|
if self.discount < 0:
|
||||||
|
raise Warning(_("Discount should be less than Gross Amount"))
|
||||||
|
discount = self.discount or self.discount_amount
|
||||||
|
if discount > self.gross_amount:
|
||||||
|
raise Warning(_("Discount (%s) should be less than "
|
||||||
|
"Gross Amount (%s).") % (
|
||||||
|
formatLang(self.env, discount, digits=2),
|
||||||
|
formatLang(self.env, self.gross_amount, digits=2)))
|
||||||
|
if self.discount_amount > values.get('max_amount', False) \
|
||||||
|
and values.get('check_group', False):
|
||||||
|
raise Warning(_("You're not allowed to apply Discount Amount "
|
||||||
|
"(%s) more than configured amount (%s) in "
|
||||||
|
"configuration setting!") % (
|
||||||
|
formatLang(self.env, self.discount_amount, digits=2),
|
||||||
|
formatLang(self.env, values['max_amount'], digits=2)))
|
||||||
|
config_id = self.env['res.config.settings'].search(
|
||||||
|
[], order='id desc', limit=1)
|
||||||
|
if config_id and config_id.global_discount_apply:
|
||||||
|
if config_id.global_discount_fix_amount < self.discount_amount:
|
||||||
|
raise Warning(_("You're not allowed to apply Discount "
|
||||||
|
"Amount (%s) more than configured amount "
|
||||||
|
"(%s) in configuration setting!") % (
|
||||||
|
formatLang(self.env, self.discount_amount, digits=2),
|
||||||
|
formatLang(self.env, config_id.global_discount_fix_amount,
|
||||||
|
digits=2)))
|
||||||
|
|
||||||
|
@api.multi
|
||||||
|
def _prepare_invoice(self):
|
||||||
|
sale_order = self.env['sale.order'].browse(
|
||||||
|
self._context.get('active_ids', []))
|
||||||
|
invoice_vals = super(SaleOrder, self)._prepare_invoice()
|
||||||
|
invoice_vals.update({
|
||||||
|
'discount_method': sale_order.discount_method,
|
||||||
|
'discount_amount': sale_order.discount_amount,
|
||||||
|
'discount_per': sale_order.discount_per,
|
||||||
|
'discount': sale_order.discount,
|
||||||
|
})
|
||||||
|
return invoice_vals
|
49
addons/sales_discount/models/sale_discount_config.py
Normal file
49
addons/sales_discount/models/sale_discount_config.py
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
# Part of Flectra See LICENSE file for full copyright and licensing details.
|
||||||
|
|
||||||
|
from flectra import api, fields, models, _
|
||||||
|
from flectra.tools.misc import formatLang
|
||||||
|
|
||||||
|
|
||||||
|
class SaleDiscountConfig(models.Model):
|
||||||
|
_name = 'sale.discount.config'
|
||||||
|
|
||||||
|
group_id = fields.Many2one('res.groups', 'Groups', required=True)
|
||||||
|
fix_amount = fields.Float('Fix Amount', required=True)
|
||||||
|
percentage = fields.Float('Percentage', required=True)
|
||||||
|
|
||||||
|
@api.constrains('group_id')
|
||||||
|
def _check_already_exist(self):
|
||||||
|
check_name = self.search(
|
||||||
|
[('id', '!=', self.id),
|
||||||
|
('group_id.name', '=', self.group_id.name)])
|
||||||
|
if check_name:
|
||||||
|
raise ValueError(
|
||||||
|
_("Assigned group already exist!"))
|
||||||
|
|
||||||
|
@api.constrains('fix_amount')
|
||||||
|
def _check_fix_amount_value(self):
|
||||||
|
config_id = self.env['res.config.settings'].search(
|
||||||
|
[], order='id desc', limit=1)
|
||||||
|
if config_id and config_id.global_discount_apply \
|
||||||
|
and config_id.global_discount_fix_amount < self.fix_amount:
|
||||||
|
raise ValueError(
|
||||||
|
_("Fix amount (%s) is greater than configuration Amount (%s)!"
|
||||||
|
) % (formatLang(
|
||||||
|
self.env, self.fix_amount, digits=2), formatLang(
|
||||||
|
self.env, config_id.global_discount_fix_amount, digits=2)))
|
||||||
|
|
||||||
|
@api.constrains('percentage')
|
||||||
|
def _check_percentage(self):
|
||||||
|
if self.percentage < 0 or self.percentage > 100:
|
||||||
|
raise ValueError(_("Percentage should be between 0% to 100%!"))
|
||||||
|
config_id = self.env[
|
||||||
|
'res.config.settings'].search([], order='id desc', limit=1)
|
||||||
|
if config_id and config_id.global_discount_apply \
|
||||||
|
and config_id.global_discount_percentage < self.percentage:
|
||||||
|
raise ValueError(
|
||||||
|
_("Percentage (%s) is greater than configuration Percentage "
|
||||||
|
"(%s)!") % (formatLang(
|
||||||
|
self.env, self.percentage, digits=2),
|
||||||
|
formatLang(self.env,
|
||||||
|
config_id.global_discount_percentage,
|
||||||
|
digits=2)))
|
43
addons/sales_discount/report/sale_order_report_view.xml
Normal file
43
addons/sales_discount/report/sale_order_report_view.xml
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<flectra>
|
||||||
|
<template id="custom_report_sale_layout" inherit_id="sale.report_saleorder_document">
|
||||||
|
<xpath expr="//div[@name='total']" position="replace">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-xs-4 pull-right">
|
||||||
|
<table class="table table-condensed">
|
||||||
|
<tr>
|
||||||
|
<td><strong>Gross Amount</strong></td>
|
||||||
|
<td class="text-right">
|
||||||
|
<span t-field="doc.gross_amount" t-options='{"widget": "monetary", "display_currency": doc.pricelist_id.currency_id}'/>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><strong>Discount</strong></td>
|
||||||
|
<td class="text-right">
|
||||||
|
<span t-field="doc.discount" t-options='{"widget": "monetary", "display_currency": doc.pricelist_id.currency_id}'/>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr class="border-black">
|
||||||
|
<td><strong>Untaxed Amount</strong></td>
|
||||||
|
<td class="text-right">
|
||||||
|
<span t-field="doc.amount_untaxed" t-options='{"widget": "monetary", "display_currency": doc.pricelist_id.currency_id}'/>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><strong>Taxes</strong></td>
|
||||||
|
<td class="text-right">
|
||||||
|
<span t-esc="doc.amount_tax or 0.0" t-options='{"widget": "monetary", "display_currency": doc.pricelist_id.currency_id}'/>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr class="border-black">
|
||||||
|
<td><strong>Total</strong></td>
|
||||||
|
<td class="text-right">
|
||||||
|
<span t-esc="doc.amount_total or 0.0" t-options='{"widget": "monetary", "display_currency": doc.pricelist_id.currency_id}'/>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</xpath>
|
||||||
|
</template>
|
||||||
|
</flectra>
|
3
addons/sales_discount/security/ir.model.access.csv
Normal file
3
addons/sales_discount/security/ir.model.access.csv
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
|
||||||
|
access_sale_discount_config,access_sale_discount_config,model_sale_discount_config,base.group_system,1,1,1,1
|
||||||
|
access_sale_discount_config_all,access_sale_discount_config_all,model_sale_discount_config,,1,0,0,0
|
|
BIN
addons/sales_discount/static/description/icon.png
Normal file
BIN
addons/sales_discount/static/description/icon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 9.3 KiB |
5
addons/sales_discount/tests/__init__.py
Normal file
5
addons/sales_discount/tests/__init__.py
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
# Part of Flectra See LICENSE file for full copyright and licensing details.
|
||||||
|
|
||||||
|
from . import discount_common
|
||||||
|
from . import test_01_sale_order_discount
|
||||||
|
from . import test_02_so_discount_invoice
|
30
addons/sales_discount/tests/discount_common.py
Normal file
30
addons/sales_discount/tests/discount_common.py
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
# Part of Flectra See LICENSE file for full copyright and licensing details.
|
||||||
|
|
||||||
|
from flectra.tests.common import TransactionCase
|
||||||
|
|
||||||
|
|
||||||
|
class TestDiscountCommon(TransactionCase):
|
||||||
|
def setUp(self):
|
||||||
|
super(TestDiscountCommon, self).setUp()
|
||||||
|
self.config = self.env['res.config.settings'].create({
|
||||||
|
'global_discount_per_so_invoice_line': True,
|
||||||
|
'global_discount_apply': True,
|
||||||
|
'global_discount_fix_amount': 5000,
|
||||||
|
'global_discount_percentage': 50,
|
||||||
|
})
|
||||||
|
self.config.onchange_global_discount_per_so_invoice_line()
|
||||||
|
self.config.onchange_global_discount_apply()
|
||||||
|
self.config.set_values()
|
||||||
|
self.disc_config_1 = self.env['sale.discount.config'].create({
|
||||||
|
'group_id': self.env.ref('sales_team.group_sale_manager').id,
|
||||||
|
'fix_amount': 3000.0,
|
||||||
|
'percentage': 20.0,
|
||||||
|
})
|
||||||
|
self.partner_id = self.env.ref('base.res_partner_3')
|
||||||
|
self.partner_invoice_id = self.env.ref('base.res_partner_address_11')
|
||||||
|
self.user_id = self.env.ref('base.user_root')
|
||||||
|
self.partner_shipping_id = self.env.ref('base.res_partner_address_11')
|
||||||
|
self.pricelist_id = self.env.ref('product.list0')
|
||||||
|
self.product_1 = self.env.ref('product.product_delivery_01')
|
||||||
|
self.product_uom = self.env.ref('product.product_uom_unit')
|
||||||
|
self.product_2 = self.env.ref('product.product_product_25')
|
81
addons/sales_discount/tests/test_01_sale_order_discount.py
Normal file
81
addons/sales_discount/tests/test_01_sale_order_discount.py
Normal file
@ -0,0 +1,81 @@
|
|||||||
|
# Part of Flectra See LICENSE file for full copyright and licensing details.
|
||||||
|
|
||||||
|
from .discount_common import TestDiscountCommon
|
||||||
|
import logging
|
||||||
|
|
||||||
|
|
||||||
|
class TestSODiscount(TestDiscountCommon):
|
||||||
|
def setUp(self):
|
||||||
|
super(TestSODiscount, self).setUp()
|
||||||
|
|
||||||
|
def discount_01_set_fixamount(self):
|
||||||
|
sale_order = self.env['sale.order'].create({
|
||||||
|
'partner_id': self.partner_id.id,
|
||||||
|
'partner_invoice_id': self.partner_invoice_id.id,
|
||||||
|
'partner_shipping_id': self.partner_shipping_id.id,
|
||||||
|
'pricelist_id': self.pricelist_id.id,
|
||||||
|
})
|
||||||
|
sale_order.onchange_discount_method()
|
||||||
|
self.env['sale.order.line'].create({
|
||||||
|
'name': self.product_1.name,
|
||||||
|
'product_id': self.product_1.id,
|
||||||
|
'product_uom_qty': 20,
|
||||||
|
'product_uom': self.product_1.uom_id.id,
|
||||||
|
'price_unit': self.product_1.list_price,
|
||||||
|
'order_id': sale_order.id,
|
||||||
|
})
|
||||||
|
self.env['sale.order.line'].create({
|
||||||
|
'name': self.product_2.name,
|
||||||
|
'product_id': self.product_2.id,
|
||||||
|
'product_uom_qty': 20,
|
||||||
|
'product_uom': self.product_2.uom_id.id,
|
||||||
|
'price_unit': self.product_2.list_price,
|
||||||
|
'order_id': sale_order.id,
|
||||||
|
})
|
||||||
|
sale_order.write({
|
||||||
|
'discount_method': 'fixed',
|
||||||
|
'discount_amount': 100,
|
||||||
|
})
|
||||||
|
self.assertTrue(sale_order, 'Sale Order: no sale order created')
|
||||||
|
logging.info('Successful: Sale Order Created!')
|
||||||
|
sale_order.calculate_discount()
|
||||||
|
return sale_order
|
||||||
|
|
||||||
|
def discount_02_set_percentages(self):
|
||||||
|
sale_order = self.env['sale.order'].create({
|
||||||
|
'partner_id': self.partner_id.id,
|
||||||
|
'partner_invoice_id': self.partner_invoice_id.id,
|
||||||
|
'partner_shipping_id': self.partner_shipping_id.id,
|
||||||
|
'pricelist_id': self.pricelist_id.id,
|
||||||
|
})
|
||||||
|
sale_order.onchange_discount_method()
|
||||||
|
sale_order.write({
|
||||||
|
'discount_method': 'per',
|
||||||
|
'discount_per': 10,
|
||||||
|
})
|
||||||
|
self.env['sale.order.line'].create({
|
||||||
|
'name': self.product_1.name,
|
||||||
|
'product_id': self.product_1.id,
|
||||||
|
'product_uom_qty': 10,
|
||||||
|
'product_uom': self.product_1.uom_id.id,
|
||||||
|
'price_unit': self.product_1.list_price,
|
||||||
|
'order_id': sale_order.id,
|
||||||
|
'discount': 10,
|
||||||
|
})
|
||||||
|
self.env['sale.order.line'].create({
|
||||||
|
'name': self.product_2.name,
|
||||||
|
'product_id': self.product_2.id,
|
||||||
|
'product_uom_qty': 20,
|
||||||
|
'product_uom': self.product_2.uom_id.id,
|
||||||
|
'price_unit': self.product_2.list_price,
|
||||||
|
'order_id': sale_order.id,
|
||||||
|
'discount': 10,
|
||||||
|
})
|
||||||
|
self.assertTrue(sale_order, 'Sale Order: no sale order created')
|
||||||
|
logging.info('Successful: Sale Order Created!')
|
||||||
|
sale_order.calculate_discount()
|
||||||
|
sale_order.write({
|
||||||
|
'discount_method': 'per',
|
||||||
|
'discount_per': 20.0,
|
||||||
|
})
|
||||||
|
return sale_order
|
17
addons/sales_discount/tests/test_02_so_discount_invoice.py
Normal file
17
addons/sales_discount/tests/test_02_so_discount_invoice.py
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
# Part of Flectra See LICENSE file for full copyright and licensing details.
|
||||||
|
|
||||||
|
from .test_01_sale_order_discount import TestSODiscount
|
||||||
|
|
||||||
|
|
||||||
|
class TestSODiscountInvoice(TestSODiscount):
|
||||||
|
def setUp(self):
|
||||||
|
super(TestSODiscountInvoice, self).setUp()
|
||||||
|
|
||||||
|
def test_01_so_dp_fixed_amount(self):
|
||||||
|
so = self.discount_01_set_fixamount()
|
||||||
|
so._prepare_invoice()
|
||||||
|
|
||||||
|
def test_02_so_percentage_discount(self):
|
||||||
|
so = self.discount_02_set_percentages()
|
||||||
|
so._prepare_invoice()
|
||||||
|
|
45
addons/sales_discount/views/res_config_settings_views.xml
Normal file
45
addons/sales_discount/views/res_config_settings_views.xml
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<flectra>
|
||||||
|
<record id="res_config_settings_view_discount_form" model="ir.ui.view">
|
||||||
|
<field name="name">res.config.settings.view.form.inherit.discount.sale</field>
|
||||||
|
<field name="model">res.config.settings</field>
|
||||||
|
<field name="priority" eval="3"/>
|
||||||
|
<field name="inherit_id" ref="sale.res_config_settings_view_form" />
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<xpath expr="//div[hasclass('settings')]/div[hasclass('app_settings_block')]/div[1]" position="after">
|
||||||
|
<h2>Sale Order Discount</h2>
|
||||||
|
<div class="row mt16 o_settings_container">
|
||||||
|
<div class="col-xs-12 col-md-12 o_setting_box">
|
||||||
|
<div class="o_setting_left_pane">
|
||||||
|
<field name="global_discount_per_so_invoice_line"/>
|
||||||
|
</div>
|
||||||
|
<div class="o_setting_right_pane">
|
||||||
|
<label for="global_discount_per_so_invoice_line"/>
|
||||||
|
<div class="text-muted">
|
||||||
|
Allow global discount on the sale order
|
||||||
|
</div>
|
||||||
|
<div attrs="{'invisible': [('global_discount_per_so_invoice_line' ,'=', False)]}">
|
||||||
|
<div class="o_setting_left_pane">
|
||||||
|
<field name="global_discount_apply"/>
|
||||||
|
</div>
|
||||||
|
<div class="o_setting_right_pane">
|
||||||
|
<label for="global_discount_apply"/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div attrs="{'invisible': [('global_discount_apply' ,'=', False)]}">
|
||||||
|
<div class="o_setting_right_pane">
|
||||||
|
<label for="global_discount_fix_amount"/>
|
||||||
|
<field name="global_discount_fix_amount" attrs="{'required': [('global_discount_apply', '=', True)]}"/>
|
||||||
|
</div>
|
||||||
|
<div class="o_setting_right_pane">
|
||||||
|
<label for="global_discount_percentage"/>
|
||||||
|
<field name="global_discount_percentage" attrs="{'required': [('global_discount_apply', '=', True)]}"/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</xpath>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
</flectra>
|
26
addons/sales_discount/views/sale_discount_config_view.xml
Normal file
26
addons/sales_discount/views/sale_discount_config_view.xml
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<flectra>
|
||||||
|
<record id="sale_discount_config_view_form" model="ir.ui.view">
|
||||||
|
<field name="name">sale.discount.config</field>
|
||||||
|
<field name="model">sale.discount.config</field>
|
||||||
|
<field name="priority" eval="3"/>
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<tree editable="top" string="Sale Discount Configuration">
|
||||||
|
<field name="group_id"/>
|
||||||
|
<field name="fix_amount"/>
|
||||||
|
<field name="percentage"/>
|
||||||
|
</tree>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<record id="action_sale_discount_config" model="ir.actions.act_window">
|
||||||
|
<field name="name">Sales Discounts</field>
|
||||||
|
<field name="res_model">sale.discount.config</field>
|
||||||
|
<field name="view_type">form</field>
|
||||||
|
<field name="view_mode">tree</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<menuitem id="menu_sale_order"
|
||||||
|
action="action_sale_discount_config"
|
||||||
|
parent="sale.menu_sale_config"/>
|
||||||
|
</flectra>
|
44
addons/sales_discount/views/sale_view.xml
Normal file
44
addons/sales_discount/views/sale_view.xml
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<flectra>
|
||||||
|
<!-- Sale -->
|
||||||
|
<record model="ir.ui.view" id="inherit_view_order_form">
|
||||||
|
<field name="name">sale.order.inherit.form</field>
|
||||||
|
<field name="model">sale.order</field>
|
||||||
|
<field name="inherit_id" ref="sale.view_order_form"/>
|
||||||
|
<field name="priority" eval="20"/>
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<xpath expr="//button[@name='action_view_invoice']" position="replace">
|
||||||
|
<button name="action_view_invoice"
|
||||||
|
type="object"
|
||||||
|
class="oe_stat_button"
|
||||||
|
icon="fa-pencil-square-o"
|
||||||
|
context="{'default_discount_method': discount_method, 'default_discount_amount': discount_amount, 'default_discount': discount,'default_discount_per': discount_per, 'var_for_default_get': True}"
|
||||||
|
attrs="{'invisible': [('invoice_count', '=', 0)]}">
|
||||||
|
<field name="invoice_count" widget="statinfo" string="Invoices"/>
|
||||||
|
</button>
|
||||||
|
</xpath>
|
||||||
|
<xpath expr="//group[@name='sale_total']" position="replace">
|
||||||
|
<div>
|
||||||
|
<group>
|
||||||
|
<group class="pull-left">
|
||||||
|
<field name="discount_method" attrs="{'readonly': [('state', '!=', 'draft')]}"/>
|
||||||
|
<field name="discount_amount" attrs="{'invisible': [('discount_method', '=', 'per')], 'readonly': ['|', ('state', '!=', 'draft'), ('discount_method', '=', False)]}"/>
|
||||||
|
<field name="discount_per" attrs="{'invisible': ['|', ('discount_method', '=', 'fixed'), ('discount_method', '=', False)], 'readonly': [('state', '!=', 'draft')]}"/>
|
||||||
|
<button name="calculate_discount" type="object" class="oe_edit_only oe_link" string="(Update Discount)" attrs="{'invisible': [('discount_method', '=', False)]}" confirm="If you want to apply global discount other discount methods will be reset."/>
|
||||||
|
</group>
|
||||||
|
<group class="oe_subtotal_footer oe_right" colspan="2" name="sale_total">
|
||||||
|
<field name="gross_amount" widget="monetary" options="{'currency_field': 'currency_id'}"/>
|
||||||
|
<field name="discount" string="Discount" widget="monetary" options="{'currency_field': 'currency_id'}"/>
|
||||||
|
<field name="amount_untaxed" widget="monetary" options="{'currency_field': 'currency_id'}"/>
|
||||||
|
<field name="amount_tax" widget="monetary" options="{'currency_field': 'currency_id'}"/>
|
||||||
|
<div class="oe_subtotal_footer_separator oe_inline o_td_label">
|
||||||
|
<label for="amount_total"/>
|
||||||
|
</div>
|
||||||
|
<field name="amount_total" nolabel="1" class="oe_subtotal_footer_separator" widget="monetary" options="{'currency_field': 'currency_id'}"/>
|
||||||
|
</group>
|
||||||
|
</group>
|
||||||
|
</div>
|
||||||
|
</xpath>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
</flectra>
|
Loading…
Reference in New Issue
Block a user