[ADD] account_discount Module
This commit is contained in:
parent
4aafcbbc3d
commit
34af6f521e
3
addons/account_discount/__init__.py
Normal file
3
addons/account_discount/__init__.py
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
# Part of Flectra See LICENSE file for full copyright and licensing details.
|
||||||
|
|
||||||
|
from . import models
|
28
addons/account_discount/__manifest__.py
Normal file
28
addons/account_discount/__manifest__.py
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
# Part of Flectra See LICENSE file for full copyright and licensing details.
|
||||||
|
|
||||||
|
{
|
||||||
|
'name': "Account Discount",
|
||||||
|
'description': """
|
||||||
|
Customized module for amending discounts
|
||||||
|
""",
|
||||||
|
'summary': 'Global Discount on Account Invoice',
|
||||||
|
'author': 'FlectraHQ',
|
||||||
|
'category': 'Accounting',
|
||||||
|
'website': 'https://flectrahq.com',
|
||||||
|
'version': '1.0',
|
||||||
|
'depends': ['account_invoicing'],
|
||||||
|
'data': [
|
||||||
|
'security/ir.model.access.csv',
|
||||||
|
'data/account_discount_data.xml',
|
||||||
|
'views/account_invoice_views.xml',
|
||||||
|
'views/res_config_settings_views.xml',
|
||||||
|
'views/discount_config_view.xml',
|
||||||
|
'report/report_menu.xml',
|
||||||
|
'report/custom_invoice_report.xml',
|
||||||
|
],
|
||||||
|
'demo':[
|
||||||
|
'demo/discount_config_demo.xml',
|
||||||
|
],
|
||||||
|
'installable': True,
|
||||||
|
'auto_install': False,
|
||||||
|
}
|
22
addons/account_discount/data/account_discount_data.xml
Normal file
22
addons/account_discount/data/account_discount_data.xml
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<flectra noupdate="1">
|
||||||
|
|
||||||
|
<record id="account_discount_config_1" model="account.discount.config">
|
||||||
|
<field name="group_id" ref="base.group_system"/>
|
||||||
|
<field name="fix_amount">1000</field>
|
||||||
|
<field name="percentage">25</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<record id="account_discount_config_2" model="account.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="account_discount_config_3" model="account.discount.config">
|
||||||
|
<field name="group_id" ref="base.group_no_one"/>
|
||||||
|
<field name="fix_amount">100</field>
|
||||||
|
<field name="percentage">10</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
</flectra>
|
15
addons/account_discount/demo/discount_config_demo.xml
Normal file
15
addons/account_discount/demo/discount_config_demo.xml
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<flectra noupdate="1">
|
||||||
|
|
||||||
|
<record id="account_discount_config_billing" model="account.discount.config">
|
||||||
|
<field name="group_id" ref="account.group_account_invoice"/>
|
||||||
|
<field name="fix_amount">1200</field>
|
||||||
|
<field name="percentage">10</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<record id="account_discount_config_manager" model="account.discount.config">
|
||||||
|
<field name="group_id" ref="account.group_account_manager"/>
|
||||||
|
<field name="fix_amount">2500</field>
|
||||||
|
<field name="percentage">25</field>
|
||||||
|
</record>
|
||||||
|
</flectra>
|
252
addons/account_discount/i18n/account_discount.pot
Normal file
252
addons/account_discount/i18n/account_discount.pot
Normal file
@ -0,0 +1,252 @@
|
|||||||
|
# Translation of Flectra Server.
|
||||||
|
# This file contains the translation of the following modules:
|
||||||
|
# * account_discount
|
||||||
|
#
|
||||||
|
msgid ""
|
||||||
|
msgstr ""
|
||||||
|
"Project-Id-Version: Flectra Server 1.0\n"
|
||||||
|
"Report-Msgid-Bugs-To: \n"
|
||||||
|
"POT-Creation-Date: 2018-01-04 11:43+0000\n"
|
||||||
|
"PO-Revision-Date: 2018-01-04 11:43+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: account_discount
|
||||||
|
#: model:ir.ui.view,arch_db:account_discount.custom_invoice_report_layout
|
||||||
|
msgid "&nbsp;<span>on</span>"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. module: account_discount
|
||||||
|
#: model:ir.ui.view,arch_db:account_discount.inherit_account_invoice_form
|
||||||
|
msgid "(Update Discount)"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. module: account_discount
|
||||||
|
#: model:ir.ui.view,arch_db:account_discount.custom_invoice_report_layout
|
||||||
|
msgid "<strong>Discount</strong>"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. module: account_discount
|
||||||
|
#: model:ir.ui.view,arch_db:account_discount.custom_invoice_report_layout
|
||||||
|
msgid "<strong>Gross Amount</strong>"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. module: account_discount
|
||||||
|
#: model:ir.ui.view,arch_db:account_discount.custom_invoice_report_layout
|
||||||
|
msgid "<strong>Subtotal</strong>"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. module: account_discount
|
||||||
|
#: model:ir.ui.view,arch_db:account_discount.custom_invoice_report_layout
|
||||||
|
msgid "<strong>Total</strong>"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. module: account_discount
|
||||||
|
#: model:ir.ui.view,arch_db:account_discount.account_discount_config_view_form
|
||||||
|
msgid "Account Discount Configuration"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. module: account_discount
|
||||||
|
#: model:ir.ui.view,arch_db:account_discount.res_config_settings_view_form_invoice_discount_form
|
||||||
|
msgid "Allow global discount on the Invoice"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. module: account_discount
|
||||||
|
#: code:addons/account_discount/models/discount_config.py:21
|
||||||
|
#, python-format
|
||||||
|
msgid "Assigned group already exist!"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. module: account_discount
|
||||||
|
#: model:ir.model.fields,field_description:account_discount.field_account_discount_config_create_uid
|
||||||
|
msgid "Created by"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. module: account_discount
|
||||||
|
#: model:ir.model.fields,field_description:account_discount.field_account_discount_config_create_date
|
||||||
|
msgid "Created on"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. module: account_discount
|
||||||
|
#: model:ir.model.fields,field_description:account_discount.field_account_invoice_discount
|
||||||
|
#: model:ir.ui.view,arch_db:account_discount.inherit_account_invoice_form
|
||||||
|
msgid "Discount"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. module: account_discount
|
||||||
|
#: model:ir.model.fields,field_description:account_discount.field_account_invoice_discount_per
|
||||||
|
msgid "Discount (%)"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. module: account_discount
|
||||||
|
#: code:addons/account_discount/models/account_invoice.py:123
|
||||||
|
#, python-format
|
||||||
|
msgid "Discount (%s) should be less than Gross Amount (%s)."
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. module: account_discount
|
||||||
|
#: model:ir.model.fields,field_description:account_discount.field_account_invoice_discount_amount
|
||||||
|
msgid "Discount Amount"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. module: account_discount
|
||||||
|
#: model:ir.model.fields,field_description:account_discount.field_account_invoice_discount_method
|
||||||
|
msgid "Discount Method"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. module: account_discount
|
||||||
|
#: code:addons/account_discount/models/account_invoice.py:121
|
||||||
|
#, python-format
|
||||||
|
msgid "Discount should be less than Gross Amount"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. module: account_discount
|
||||||
|
#: model:ir.actions.act_window,name:account_discount.action_account_discount_config
|
||||||
|
#: model:ir.ui.menu,name:account_discount.menu_account_order
|
||||||
|
msgid "Discounts"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. module: account_discount
|
||||||
|
#: model:ir.model.fields,field_description:account_discount.field_account_discount_config_display_name
|
||||||
|
msgid "Display Name"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. module: account_discount
|
||||||
|
#: model:ir.model.fields,field_description:account_discount.field_res_config_settings_global_discount_invoice_apply
|
||||||
|
msgid "Do you want to set global discount limit?"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. module: account_discount
|
||||||
|
#: model:ir.model.fields,field_description:account_discount.field_account_discount_config_fix_amount
|
||||||
|
#: model:ir.model.fields,field_description:account_discount.field_res_config_settings_global_discount_fix_invoice_amount
|
||||||
|
msgid "Fix Amount"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. module: account_discount
|
||||||
|
#: code:addons/account_discount/models/discount_config.py:30
|
||||||
|
#, python-format
|
||||||
|
msgid "Fix amount (%s) is greater than configuration Amount (%s)!"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. module: account_discount
|
||||||
|
#: selection:account.invoice,discount_method:0
|
||||||
|
msgid "Fixed"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. module: account_discount
|
||||||
|
#: model:ir.model.fields,field_description:account_discount.field_res_config_settings_global_discount_invoice_line
|
||||||
|
msgid "Global Discounts"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. module: account_discount
|
||||||
|
#: model:ir.model.fields,field_description:account_discount.field_account_invoice_gross_amount
|
||||||
|
msgid "Gross Amount"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. module: account_discount
|
||||||
|
#: model:ir.model.fields,field_description:account_discount.field_account_discount_config_group_id
|
||||||
|
msgid "Groups"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. module: account_discount
|
||||||
|
#: model:ir.model.fields,field_description:account_discount.field_account_discount_config_id
|
||||||
|
msgid "ID"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. module: account_discount
|
||||||
|
#: model:ir.model,name:account_discount.model_account_invoice
|
||||||
|
msgid "Invoice"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. module: account_discount
|
||||||
|
#: model:ir.ui.view,arch_db:account_discount.res_config_settings_view_form_invoice_discount_form
|
||||||
|
msgid "Invoice Discount"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. module: account_discount
|
||||||
|
#: model:ir.model.fields,field_description:account_discount.field_account_discount_config___last_update
|
||||||
|
msgid "Last Modified on"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. module: account_discount
|
||||||
|
#: model:ir.model.fields,field_description:account_discount.field_account_discount_config_write_uid
|
||||||
|
msgid "Last Updated by"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. module: account_discount
|
||||||
|
#: model:ir.model.fields,field_description:account_discount.field_account_discount_config_write_date
|
||||||
|
msgid "Last Updated on"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. module: account_discount
|
||||||
|
#: selection:account.invoice,discount_method:0
|
||||||
|
#: model:ir.model.fields,field_description:account_discount.field_account_discount_config_percentage
|
||||||
|
msgid "Percentage"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. module: account_discount
|
||||||
|
#: model:ir.model.fields,field_description:account_discount.field_res_config_settings_global_discount_percentage_invoice
|
||||||
|
msgid "Percentage (%)"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. module: account_discount
|
||||||
|
#: code:addons/account_discount/models/discount_config.py:44
|
||||||
|
#, python-format
|
||||||
|
msgid "Percentage (%s) is greater than configuration Percentage (%s)!"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. module: account_discount
|
||||||
|
#: code:addons/account_discount/models/account_invoice.py:95
|
||||||
|
#, python-format
|
||||||
|
msgid "Percentage should be between 0% to 100%"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. module: account_discount
|
||||||
|
#: code:addons/account_discount/models/discount_config.py:38
|
||||||
|
#, python-format
|
||||||
|
msgid "Percentage should be between 0% to 100%!"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. module: account_discount
|
||||||
|
#: model:ir.ui.view,arch_db:account_discount.inherit_account_invoice_form
|
||||||
|
msgid "Subtotal"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. module: account_discount
|
||||||
|
#: code:addons/account_discount/models/account_invoice.py:98
|
||||||
|
#, python-format
|
||||||
|
msgid "You are not allowed to apply Discount Percentage (%s) more than configured Discount Percentage (%s) in configuration setting!"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. module: account_discount
|
||||||
|
#: code:addons/account_discount/models/account_invoice.py:107
|
||||||
|
#, python-format
|
||||||
|
msgid "You are not allowed to apply Discount Percentage(%s) more than configured Discount Percentage (%s) in configuration setting!"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. module: account_discount
|
||||||
|
#: code:addons/account_discount/models/account_invoice.py:138
|
||||||
|
#, python-format
|
||||||
|
msgid "You're not allowed to apply this amount of discount as discount Amount (%s) is greater than Configuration Amount (%s)."
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. module: account_discount
|
||||||
|
#: code:addons/account_discount/models/account_invoice.py:129
|
||||||
|
#, python-format
|
||||||
|
msgid "You're not allowed to apply this amount of discount as discount Amount (%s) is greater than assign Fix Amount (%s)."
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. module: account_discount
|
||||||
|
#: model:ir.model,name:account_discount.model_account_discount_config
|
||||||
|
msgid "account.discount.config"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. module: account_discount
|
||||||
|
#: model:ir.model,name:account_discount.model_res_config_settings
|
||||||
|
msgid "res.config.settings"
|
||||||
|
msgstr ""
|
||||||
|
|
5
addons/account_discount/models/__init__.py
Normal file
5
addons/account_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 discount_config
|
||||||
|
from . import account_invoice
|
143
addons/account_discount/models/account_invoice.py
Normal file
143
addons/account_discount/models/account_invoice.py
Normal file
@ -0,0 +1,143 @@
|
|||||||
|
# Part of Flectra See LICENSE file for full copyright and licensing details.
|
||||||
|
|
||||||
|
from flectra import models, fields, api, _
|
||||||
|
from flectra.tools.misc import formatLang
|
||||||
|
from flectra.exceptions import Warning
|
||||||
|
|
||||||
|
|
||||||
|
class AccountInvoice(models.Model):
|
||||||
|
_inherit = "account.invoice"
|
||||||
|
|
||||||
|
@api.multi
|
||||||
|
@api.depends('discount_amount', 'discount_per', 'amount_untaxed')
|
||||||
|
def _get_discount(self):
|
||||||
|
total_discount = 0.0
|
||||||
|
for record in self:
|
||||||
|
for invoice_line_id in record.invoice_line_ids:
|
||||||
|
total_price = (
|
||||||
|
invoice_line_id.quantity * invoice_line_id.price_unit)
|
||||||
|
total_discount += \
|
||||||
|
(total_price * invoice_line_id.discount) / 100
|
||||||
|
record.discount = record.currency_id.round(total_discount)
|
||||||
|
|
||||||
|
@api.multi
|
||||||
|
@api.depends('invoice_line_ids', 'discount_per', 'discount_amount')
|
||||||
|
def _get_total_amount(self):
|
||||||
|
for invoice_id in self:
|
||||||
|
invoice_id.gross_amount = sum(
|
||||||
|
[line_id.quantity * line_id.price_unit
|
||||||
|
for line_id in invoice_id.invoice_line_ids])
|
||||||
|
|
||||||
|
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', 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.invoice_line_ids:
|
||||||
|
line.write({'discount': 0.0})
|
||||||
|
amount_untaxed = self.amount_untaxed
|
||||||
|
if self.discount_method == 'per':
|
||||||
|
for line in self.invoice_line_ids:
|
||||||
|
line.write({'discount': line.discount + self.discount_per})
|
||||||
|
else:
|
||||||
|
for line in self.invoice_line_ids:
|
||||||
|
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.constrains('discount_per', 'discount_amount', 'invoice_line_ids')
|
||||||
|
def _check_constrains(self):
|
||||||
|
self.onchange_discount_per()
|
||||||
|
self.onchange_discount_amount()
|
||||||
|
|
||||||
|
@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.invoice_line_ids:
|
||||||
|
raise Warning('No Invoice Line(s) were found!')
|
||||||
|
|
||||||
|
@api.multi
|
||||||
|
def get_maximum_per_amount(self):
|
||||||
|
account_dis_config_obj = self.env['account.discount.config']
|
||||||
|
max_percentage = 0
|
||||||
|
max_amount = 0
|
||||||
|
check_group = False
|
||||||
|
for groups_id in self.env.user.groups_id:
|
||||||
|
account_dis_config_id = account_dis_config_obj.search(
|
||||||
|
[('group_id', '=', groups_id.id)])
|
||||||
|
if account_dis_config_id:
|
||||||
|
check_group = True
|
||||||
|
if account_dis_config_id.percentage > max_percentage:
|
||||||
|
max_percentage = account_dis_config_id.percentage
|
||||||
|
if account_dis_config_id.fix_amount > max_amount:
|
||||||
|
max_amount = account_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_invoice_apply:
|
||||||
|
if config_id.global_discount_percentage_invoice < 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_invoice,
|
||||||
|
digits=2)))
|
||||||
|
|
||||||
|
@api.onchange('discount_amount')
|
||||||
|
def onchange_discount_amount(self):
|
||||||
|
if self.discount_method == 'per':
|
||||||
|
return True
|
||||||
|
values = self.get_maximum_per_amount()
|
||||||
|
if self.discount < 0:
|
||||||
|
raise Warning(_("Discount should be less than Gross Amount"))
|
||||||
|
if self.discount > self.gross_amount:
|
||||||
|
raise Warning(_("Discount (%s) should be less than "
|
||||||
|
"Gross Amount (%s).") % (
|
||||||
|
formatLang(self.env, self.discount, digits=2),
|
||||||
|
formatLang(self.env, self.gross_amount, digits=2)))
|
||||||
|
if self.discount > values.get('max_amount', False) \
|
||||||
|
and values.get('check_group', False):
|
||||||
|
raise Warning(_("You're not allowed to apply this amount of "
|
||||||
|
"discount as discount Amount (%s) is greater than"
|
||||||
|
" assign Fix Amount (%s).") % (
|
||||||
|
formatLang(self.env, self.discount, 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_invoice_apply:
|
||||||
|
if config_id.global_discount_fix_invoice_amount < self.discount_amount:
|
||||||
|
raise Warning(_("You're not allowed to apply this amount of"
|
||||||
|
" discount as discount Amount (%s) is greater"
|
||||||
|
" than Configuration Amount (%s).") % (
|
||||||
|
formatLang(self.env, self.discount, digits=2),
|
||||||
|
formatLang(self.env, config_id.global_discount_fix_invoice_amount,
|
||||||
|
digits=2)))
|
49
addons/account_discount/models/discount_config.py
Normal file
49
addons/account_discount/models/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 AccountDiscountConfig(models.Model):
|
||||||
|
_name = 'account.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_invoice_apply \
|
||||||
|
and config_id.global_discount_fix_invoice_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_invoice_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_invoice_apply \
|
||||||
|
and config_id.global_discount_percentage_invoice < 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_invoice,
|
||||||
|
digits=2)))
|
61
addons/account_discount/models/res_config_settings.py
Normal file
61
addons/account_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_invoice_line = fields.Boolean(
|
||||||
|
"Global Discounts",
|
||||||
|
implied_group='account_discount.global_discount_invoice_line')
|
||||||
|
global_discount_invoice_apply = fields.Boolean(
|
||||||
|
"Do you want to set global discount limit?",
|
||||||
|
implied_group='account_discount.global_discount_invoice_apply')
|
||||||
|
global_discount_fix_invoice_amount = fields.Integer(
|
||||||
|
'Fix Amount',
|
||||||
|
implied_group='account_discount.global_discount_invoice_apply')
|
||||||
|
global_discount_percentage_invoice = fields.Integer(
|
||||||
|
'Percentage (%)',
|
||||||
|
implied_group='account_discount.global_discount_percentage_invoice')
|
||||||
|
|
||||||
|
@api.onchange('global_discount_invoice_line')
|
||||||
|
def onchange_global_discount_invoice_line(self):
|
||||||
|
if not self.global_discount_invoice_line:
|
||||||
|
self.global_discount_invoice_apply = False
|
||||||
|
|
||||||
|
@api.onchange('global_discount_invoice_apply')
|
||||||
|
def onchange_global_discount_invoice_apply(self):
|
||||||
|
if not self.global_discount_invoice_apply:
|
||||||
|
self.global_discount_fix_invoice_amount = False
|
||||||
|
|
||||||
|
@api.model
|
||||||
|
def get_values(self):
|
||||||
|
res = super(ResConfigSettings, self).get_values()
|
||||||
|
res.update(
|
||||||
|
global_discount_invoice_line=self.env[
|
||||||
|
'ir.config_parameter'].sudo().get_param(
|
||||||
|
'global_discount_invoice_line'),
|
||||||
|
global_discount_invoice_apply=self.env[
|
||||||
|
'ir.config_parameter'].sudo().get_param(
|
||||||
|
'global_discount_invoice_apply'),
|
||||||
|
global_discount_fix_invoice_amount=int(self.env[
|
||||||
|
'ir.config_parameter'].sudo().get_param(
|
||||||
|
'global_discount_fix_invoice_amount')),
|
||||||
|
global_discount_percentage_invoice=int(self.env[
|
||||||
|
'ir.config_parameter'].sudo().get_param(
|
||||||
|
'global_discount_percentage_invoice')),
|
||||||
|
)
|
||||||
|
return res
|
||||||
|
|
||||||
|
def set_values(self):
|
||||||
|
super(ResConfigSettings, self).set_values()
|
||||||
|
params = self.env['ir.config_parameter'].sudo()
|
||||||
|
params.set_param('global_discount_invoice_line',
|
||||||
|
self.global_discount_invoice_line)
|
||||||
|
params.set_param('global_discount_invoice_apply',
|
||||||
|
self.global_discount_invoice_apply)
|
||||||
|
params.set_param('global_discount_fix_invoice_amount',
|
||||||
|
self.global_discount_fix_invoice_amount)
|
||||||
|
params.set_param('global_discount_percentage_invoice',
|
||||||
|
self.global_discount_percentage_invoice)
|
59
addons/account_discount/report/custom_invoice_report.xml
Normal file
59
addons/account_discount/report/custom_invoice_report.xml
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<flectra>
|
||||||
|
<template id="custom_invoice_report_layout" inherit_id="account.report_invoice_document">
|
||||||
|
<xpath expr="//div/div[hasclass('clearfix')]" position="replace">
|
||||||
|
<div id="total" class="row pull-right">
|
||||||
|
<div>
|
||||||
|
<table class="table-condensed" style="min-width: 250px;max-width: 400px;">
|
||||||
|
<tr>
|
||||||
|
<td><strong>Gross Amount</strong></td>
|
||||||
|
<td class="text-right">
|
||||||
|
<span t-field="o.gross_amount" t-options='{"widget": "monetary", "display_currency": o.currency_id}'/>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><strong>Discount</strong></td>
|
||||||
|
<td class="text-right">
|
||||||
|
<span t-field="o.discount" t-options='{"widget": "monetary", "display_currency": o.currency_id}'/>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr class="border-black">
|
||||||
|
<td><strong>Subtotal</strong></td>
|
||||||
|
<td class="text-right">
|
||||||
|
<span t-field="o.amount_untaxed" t-options='{"widget": "monetary", "display_currency": o.currency_id}'/>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<t t-set="tax_groups_length" t-value="len(o._get_tax_amount_by_group())"/>
|
||||||
|
<t t-foreach="o._get_tax_amount_by_group()" t-as="amount_by_group">
|
||||||
|
<tr style="border-bottom:1px solid #dddddd;">
|
||||||
|
<t t-if="len(o.tax_line_ids) == 1 and o.amount_untaxed == amount_by_group[2]">
|
||||||
|
<td><span t-esc="amount_by_group[0]"/></td>
|
||||||
|
<td class="text-right">
|
||||||
|
<span t-esc="amount_by_group[1]" t-options='{"widget": "monetary", "display_currency": o.currency_id}'/>
|
||||||
|
</td>
|
||||||
|
</t>
|
||||||
|
<t t-else="">
|
||||||
|
<td>
|
||||||
|
<span t-esc="amount_by_group[0]"/>
|
||||||
|
<span>&nbsp;<span>on</span>
|
||||||
|
<t t-esc="amount_by_group[2]" t-options='{"widget": "monetary", "display_currency": o.currency_id}'/>
|
||||||
|
</span>
|
||||||
|
</td>
|
||||||
|
<td class="text-right">
|
||||||
|
<span t-esc="amount_by_group[1]" t-options='{"widget": "monetary", "display_currency": o.currency_id}'/>
|
||||||
|
</td>
|
||||||
|
</t>
|
||||||
|
</tr>
|
||||||
|
</t>
|
||||||
|
<tr class="border-black">
|
||||||
|
<td><strong>Total</strong></td>
|
||||||
|
<td class="text-right">
|
||||||
|
<span t-field="o.amount_total" t-options='{"widget": "monetary", "display_currency": o.currency_id}'/>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</xpath>
|
||||||
|
</template>
|
||||||
|
</flectra>
|
12
addons/account_discount/report/report_menu.xml
Normal file
12
addons/account_discount/report/report_menu.xml
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<flectra>
|
||||||
|
<report
|
||||||
|
id="account.account_invoices"
|
||||||
|
model="account.invoice"
|
||||||
|
string="Invoices"
|
||||||
|
report_type="qweb-pdf"
|
||||||
|
name="account.report_invoice"
|
||||||
|
file="account.report_invoice"
|
||||||
|
attachment_use="False"
|
||||||
|
/>
|
||||||
|
</flectra>
|
3
addons/account_discount/security/ir.model.access.csv
Normal file
3
addons/account_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_account_discount_config,access_account_discount_config,model_account_discount_config,base.group_system,1,1,1,1
|
||||||
|
access_account_discount_config_all,access_account_discount_config_all,model_account_discount_config,,1,0,0,0
|
|
BIN
addons/account_discount/static/description/icon.png
Normal file
BIN
addons/account_discount/static/description/icon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 11 KiB |
5
addons/account_discount/tests/__init__.py
Normal file
5
addons/account_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_account_discount
|
||||||
|
from . import test_02_account_discount_invoice
|
22
addons/account_discount/tests/discount_common.py
Normal file
22
addons/account_discount/tests/discount_common.py
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
# 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_invoice_line': True,
|
||||||
|
'global_discount_invoice_apply': True,
|
||||||
|
'global_discount_fix_invoice_amount': 5000,
|
||||||
|
'global_discount_percentage_invoice': 50,
|
||||||
|
})
|
||||||
|
self.config.onchange_global_discount_invoice_line()
|
||||||
|
self.config.onchange_global_discount_invoice_apply()
|
||||||
|
self.config.set_values()
|
||||||
|
self.disc_config_1 = self.env['account.discount.config'].create({
|
||||||
|
'group_id': self.env.ref('account.group_account_user').id,
|
||||||
|
'fix_amount': 3000.0,
|
||||||
|
'percentage': 20.0,
|
||||||
|
})
|
89
addons/account_discount/tests/test_01_account_discount.py
Normal file
89
addons/account_discount/tests/test_01_account_discount.py
Normal file
@ -0,0 +1,89 @@
|
|||||||
|
# Part of Flectra See LICENSE file for full copyright and licensing details.
|
||||||
|
|
||||||
|
from .discount_common import TestDiscountCommon
|
||||||
|
import logging
|
||||||
|
import time
|
||||||
|
|
||||||
|
class TestInvoiceDiscount(TestDiscountCommon):
|
||||||
|
def setUp(self):
|
||||||
|
super(TestInvoiceDiscount, self).setUp()
|
||||||
|
|
||||||
|
def discount_01_set_fixamount(self):
|
||||||
|
self.account_id = self.env['account.account'].create({
|
||||||
|
'name': 'Test',
|
||||||
|
'code': 'DA',
|
||||||
|
'user_type_id':self.env.ref("account.data_account_type_revenue").id,
|
||||||
|
})
|
||||||
|
|
||||||
|
invoice_id = self.env['account.invoice'].create({
|
||||||
|
'name': 'Discount Invoice Test Fixed',
|
||||||
|
'partner_id': self.env.ref("base.res_partner_4").id,
|
||||||
|
'currency_id': self.env.ref('base.USD').id,
|
||||||
|
'account_id': self.account_id.id,
|
||||||
|
'type': 'out_invoice',
|
||||||
|
'date_invoice': time.strftime('%Y') + '-03-12',
|
||||||
|
})
|
||||||
|
invoice_id.onchange_discount_method()
|
||||||
|
invoice_id.write({
|
||||||
|
'discount_method': 'fixed',
|
||||||
|
'discount_amount': 100,
|
||||||
|
})
|
||||||
|
self.env['account.invoice.line'].create({
|
||||||
|
'product_id': self.env.ref("product.product_product_10").id,
|
||||||
|
'quantity': 10,
|
||||||
|
'price_unit': 400,
|
||||||
|
'invoice_id': invoice_id.id,
|
||||||
|
'name': 'Mouse, Optical',
|
||||||
|
'account_id': self.account_id.id,
|
||||||
|
})
|
||||||
|
self.env['account.invoice.line'].create({
|
||||||
|
'product_id': self.env.ref("product.product_product_12").id,
|
||||||
|
'quantity': 30,
|
||||||
|
'price_unit': 250,
|
||||||
|
'invoice_id': invoice_id.id,
|
||||||
|
'name': 'Mouse, Wireless',
|
||||||
|
'account_id': self.account_id.id,
|
||||||
|
})
|
||||||
|
self.assertTrue(invoice_id, 'Invoice: no invoice created')
|
||||||
|
invoice_id._check_constrains()
|
||||||
|
invoice_id.onchange_discount_per()
|
||||||
|
invoice_id.onchange_discount_amount()
|
||||||
|
logging.info('Successful: Invoice Created!')
|
||||||
|
invoice_id.calculate_discount()
|
||||||
|
return invoice_id
|
||||||
|
|
||||||
|
def discount_02_set_percentages(self):
|
||||||
|
self.account_id = self.env['account.account'].create({
|
||||||
|
'name': 'Test',
|
||||||
|
'code': 'DA',
|
||||||
|
'user_type_id':self.env.ref("account.data_account_type_revenue").id,
|
||||||
|
})
|
||||||
|
invoice_id = self.env['account.invoice'].create({
|
||||||
|
'name': 'Discount Invoice Test',
|
||||||
|
'partner_id': self.env.ref("base.res_partner_4").id,
|
||||||
|
'currency_id': self.env.ref('base.USD').id,
|
||||||
|
'account_id': self.account_id.id,
|
||||||
|
'type': 'out_invoice',
|
||||||
|
'discount_method': 'per',
|
||||||
|
'discount_per': 10,
|
||||||
|
'date_invoice': time.strftime('%Y') + '-03-12',
|
||||||
|
})
|
||||||
|
self.env['account.invoice.line'].create({
|
||||||
|
'product_id': self.env.ref("product.product_product_10").id,
|
||||||
|
'quantity': 10,
|
||||||
|
'price_unit': 400,
|
||||||
|
'discount': 10,
|
||||||
|
'invoice_id': invoice_id.id,
|
||||||
|
'name': 'Mouse, Optical',
|
||||||
|
'account_id': self.account_id.id,
|
||||||
|
})
|
||||||
|
self.env['account.invoice.line'].create({
|
||||||
|
'product_id': self.env.ref("product.product_product_12").id,
|
||||||
|
'quantity': 30,
|
||||||
|
'price_unit': 250,
|
||||||
|
'discount': 10,
|
||||||
|
'invoice_id': invoice_id.id,
|
||||||
|
'name': 'Mouse, Wireless',
|
||||||
|
'account_id': self.account_id.id,
|
||||||
|
})
|
||||||
|
return invoice_id
|
@ -0,0 +1,26 @@
|
|||||||
|
# Part of Flectra See LICENSE file for full copyright and licensing details.
|
||||||
|
|
||||||
|
from .test_01_account_discount import TestInvoiceDiscount
|
||||||
|
import logging
|
||||||
|
|
||||||
|
class TestDiscountInvoice(TestInvoiceDiscount):
|
||||||
|
def setUp(self):
|
||||||
|
super(TestDiscountInvoice, self).setUp()
|
||||||
|
|
||||||
|
def test_01_dp_fixed_amount(self):
|
||||||
|
invoice = self.discount_01_set_fixamount()
|
||||||
|
invoice.action_invoice_open()
|
||||||
|
|
||||||
|
def test_02_percentage_discount(self):
|
||||||
|
invoice_id = self.discount_02_set_percentages()
|
||||||
|
invoice_id._check_constrains()
|
||||||
|
invoice_id.onchange_discount_per()
|
||||||
|
invoice_id.onchange_discount_amount()
|
||||||
|
self.assertTrue(invoice_id, 'Invoice: no invoice created')
|
||||||
|
logging.info('Successful: Invoice Created!')
|
||||||
|
invoice_id.write({
|
||||||
|
'discount_method': 'per',
|
||||||
|
'discount_per': 20.0,
|
||||||
|
})
|
||||||
|
invoice_id.calculate_discount()
|
||||||
|
invoice_id.action_invoice_open()
|
37
addons/account_discount/views/account_invoice_views.xml
Normal file
37
addons/account_discount/views/account_invoice_views.xml
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<flectra>
|
||||||
|
<!-- Account -->
|
||||||
|
<record model="ir.ui.view" id="inherit_account_invoice_form">
|
||||||
|
<field name="name">account.invoice.inherit.form</field>
|
||||||
|
<field name="model">account.invoice</field>
|
||||||
|
<field name="inherit_id" ref="account.invoice_form"/>
|
||||||
|
<field name="priority" eval="20"/>
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<xpath expr="/form/sheet/notebook/page/group" position="replace">
|
||||||
|
</xpath>
|
||||||
|
<field name='comment' position="before">
|
||||||
|
<div>
|
||||||
|
<group>
|
||||||
|
<group class="pull-left">
|
||||||
|
<field name="discount_method" attrs="{'readonly': ['|', ('origin', '!=', False), ('state', '!=', 'draft')]}"/>
|
||||||
|
<field name="discount_amount" attrs="{'readonly': ['|', '|', ('origin', '!=', False), ('state', '!=', 'draft'), ('discount_method', '=', False)], 'invisible': [('discount_method', '=', 'per')]}"/>
|
||||||
|
<field name="discount_per" attrs="{'invisible': ['|', ('discount_method', '=', 'fixed'), ('discount_method', '=', False)], 'readonly': ['|', ('origin', '!=', False), ('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">
|
||||||
|
<field name="gross_amount" widget="monetary" options="{'currency_field': 'currency_id'}"/>
|
||||||
|
<field name="discount" string="Discount"/>
|
||||||
|
<field name="amount_untaxed" string="Subtotal"/>
|
||||||
|
<field name="amount_tax"/>
|
||||||
|
<field name="amount_total" class="oe_subtotal_footer_separator"/>
|
||||||
|
<field name="payments_widget" colspan="2" nolabel="1" widget="payment"/>
|
||||||
|
<field name="residual" class="oe_subtotal_footer_separator" attrs="{'invisible': [('state', '=', 'draft')]}"/>
|
||||||
|
<field name="reconciled" invisible="1"/>
|
||||||
|
<field name="outstanding_credits_debits_widget" colspan="2" nolabel="1" widget="payment" attrs="{'invisible': [('state', 'not in', 'open')]}"/>
|
||||||
|
</group>
|
||||||
|
</group>
|
||||||
|
</div>
|
||||||
|
</field>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
</flectra>
|
27
addons/account_discount/views/discount_config_view.xml
Normal file
27
addons/account_discount/views/discount_config_view.xml
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<flectra>
|
||||||
|
<record id="account_discount_config_view_form" model="ir.ui.view">
|
||||||
|
<field name="name">account.discount.config</field>
|
||||||
|
<field name="model">account.discount.config</field>
|
||||||
|
<field name="priority" eval="3"/>
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<tree editable="top" string="Account Discount Configuration">
|
||||||
|
<field name="group_id"/>
|
||||||
|
<field name="fix_amount"/>
|
||||||
|
<field name="percentage"/>
|
||||||
|
</tree>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<record id="action_account_discount_config" model="ir.actions.act_window">
|
||||||
|
<field name="name">Discounts</field>
|
||||||
|
<field name="res_model">account.discount.config</field>
|
||||||
|
<field name="view_type">form</field>
|
||||||
|
<field name="view_mode">tree</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<menuitem id="menu_account_order"
|
||||||
|
action="action_account_discount_config"
|
||||||
|
parent="account.account_account_menu"/>
|
||||||
|
</flectra>
|
||||||
|
|
45
addons/account_discount/views/res_config_settings_views.xml
Normal file
45
addons/account_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_form_invoice_discount_form" model="ir.ui.view">
|
||||||
|
<field name="name">res.config.settings.view.form.inherit.discount.account</field>
|
||||||
|
<field name="model">res.config.settings</field>
|
||||||
|
<field name="priority" eval="3"/>
|
||||||
|
<field name="inherit_id" ref="account.res_config_settings_view_form" />
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<xpath expr="//div[@id='analytic']" position="after">
|
||||||
|
<h2>Invoice 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_invoice_line"/>
|
||||||
|
</div>
|
||||||
|
<div class="o_setting_right_pane">
|
||||||
|
<label for="global_discount_invoice_line"/>
|
||||||
|
<div class="text-muted">
|
||||||
|
Allow global discount on the Invoice
|
||||||
|
</div>
|
||||||
|
<div attrs="{'invisible': [('global_discount_invoice_line' ,'=', False)]}">
|
||||||
|
<div class="o_setting_left_pane">
|
||||||
|
<field name="global_discount_invoice_apply"/>
|
||||||
|
</div>
|
||||||
|
<div class="o_setting_right_pane">
|
||||||
|
<label for="global_discount_invoice_apply"/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div attrs="{'invisible': [('global_discount_invoice_apply' ,'=', False)]}">
|
||||||
|
<div class="o_setting_right_pane">
|
||||||
|
<label for="global_discount_fix_invoice_amount"/>
|
||||||
|
<field name="global_discount_fix_invoice_amount" attrs="{'required': [('global_discount_invoice_apply', '=', True)]}"/>
|
||||||
|
</div>
|
||||||
|
<div class="o_setting_right_pane">
|
||||||
|
<label for="global_discount_percentage_invoice"/>
|
||||||
|
<field name="global_discount_percentage_invoice" attrs="{'required': [('global_discount_invoice_apply', '=', True)]}"/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</xpath>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
</flectra>
|
Loading…
Reference in New Issue
Block a user