Skip to content

Commit

Permalink
Merge 32a857b into 3e58848
Browse files Browse the repository at this point in the history
  • Loading branch information
Chanakya-SerpentCS committed Dec 10, 2019
2 parents 3e58848 + 32a857b commit 82099e7
Show file tree
Hide file tree
Showing 13 changed files with 218 additions and 0 deletions.
29 changes: 29 additions & 0 deletions account_invoice_refund_reason/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
Description
===========

This module allows you to define a list of reasons to create a credit note from an invoice and report on them.

Configuration
=============
Go to Accounting > Configuration > Management > Refund Reasons
Create the different reasons you want to provide users

Usage
=====

Go to Accounting > Customers > Invoices (or Accounting > Vendors > Bills)
Select an open invoice (or bill)
Click on the "Add Credit Note"
Select the reason and create the credit note

Credits
=======

* Open Source Integrators <http://www.opensourceintegrators.com>
* Serpent Consulting Services Pvt. Ltd. <support@serpentcs.com>

Contributors
============

* Open Source Integrators <http://www.opensourceintegrators.com>
* Serpent Consulting Services Pvt. Ltd. <support@serpentcs.com>
6 changes: 6 additions & 0 deletions account_invoice_refund_reason/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Copyright (C) 2019 Open Source Integrators
# Copyright (C) 2019 Serpent Consulting Services Pvt. Ltd.
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from . import models
from . import wizard
23 changes: 23 additions & 0 deletions account_invoice_refund_reason/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Copyright (C) 2019 Open Source Integrators
# Copyright (C) 2019 Serpent Consulting Services Pvt. Ltd.
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

{
'name': 'Account Invoice Refund Reason',
'version': '12.0.1.0.0',
"summary": "Account Invoice Refund Reason.",
'category': 'Accounting',
'author': "Open Source Integrators, "
"Odoo Community Association (OCA), ",
"Serpent CS, "
'website': 'https://github.com/OCA/account-invoicing.git',
'data': ['security/ir.model.access.csv',
'data/account.invoice.refund.reason.csv',
'views/account_invoice_view.xml',
'views/account_invoice_refund_reason_view.xml',
'wizard/account_invoice_refund_view.xml'],
'depends': ['account'],
'license': 'AGPL-3',
'development_status': 'Beta',
'maintainers': ['max3903']
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
id,name
refund_reason_cancellation,Cancellation
refund_reason_noref,Invoice without reference
refund_reason_error,Lease and/or Minimum Charge Error
refund_reason_agreement,Commercial and/or Collection Agreement
refund_reason_difference,Price Difference
refund_reason_correction,Data Correction
refund_reason_others,Others
6 changes: 6 additions & 0 deletions account_invoice_refund_reason/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Copyright (C) 2019 Open Source Integrators
# Copyright (C) 2019 Serpent Consulting Services Pvt. Ltd.
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from . import account_invoice_refund_reason
from . import account_invoice
12 changes: 12 additions & 0 deletions account_invoice_refund_reason/models/account_invoice.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Copyright (C) 2019 Open Source Integrators
# Copyright (C) 2019 Serpent Consulting Services Pvt. Ltd.
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import fields, models


class AccountInvoice(models.Model):
_inherit = 'account.invoice'

reason_id = fields.Many2one('account.invoice.refund.reason',
string="Reason")
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Copyright (C) 2019 Open Source Integrators
# Copyright (C) 2019 Serpent Consulting Services Pvt. Ltd.
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import fields, models


class AccountInvoiceRefundReason(models.Model):
_name = 'account.invoice.refund.reason'
_description = 'Account Invoice refund Reasons'

name = fields.Char('Name', required=True, translate=True)
3 changes: 3 additions & 0 deletions account_invoice_refund_reason/security/ir.model.access.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_account_invoice_refund_reason_user,access_account_invoice_refund_reason_user,model_account_invoice_refund_reason,account.group_account_invoice,1,0,0,0
access_account_invoice_refund_reason_manager,access_account_invoice_refund_reason_manager,model_account_invoice_refund_reason,account.group_account_manager,1,1,1,1
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<odoo>
<record id="view_account_invoice_refund_reason" model="ir.ui.view">
<field name="name">account.invoice.refund.reason.form</field>
<field name="model">account.invoice.refund.reason</field>
<field name="arch" type="xml">
<form>
<sheet>
<group>
<field name="name"/>
</group>
</sheet>
</form>
</field>
</record>

<record id="view_account_invoice_refund_reason_tree" model="ir.ui.view">
<field name="name">account.invoice.refund.reason.tree</field>
<field name="model">account.invoice.refund.reason</field>
<field name="arch" type="xml">
<tree>
<field name="name"/>
</tree>
</field>
</record>

<record id="refund_reason_action" model="ir.actions.act_window">
<field name="name">Refund Reasons</field>
<field name="res_model">account.invoice.refund.reason</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
</record>

<menuitem
id="refund_reasons_menu"
name="Refund Reasons"
parent="account.account_management_menu"
action="refund_reason_action"
groups="base.group_user"/>
</odoo>
29 changes: 29 additions & 0 deletions account_invoice_refund_reason/views/account_invoice_view.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<odoo>
<record id="extended_view_account_invoice" model="ir.ui.view">
<field name="name">extended.account.invoice.form</field>
<field name="model">account.invoice</field>
<field name="inherit_id" ref="account.invoice_form"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='reference']" position="after">
<field name="reason_id" attrs="{'invisible': [('reason_id', '=', False)]}" readonly="1"/>
</xpath>
<xpath expr="//page[@name='other_info']/group/group[1]/field[@name='name']" position="attributes">
<attribute name="attrs">{'invisible': [('reason_id','!=', False)]}</attribute>
</xpath>
</field>
</record>

<record id="extended_view_account_invoice_supplier_form" model="ir.ui.view">
<field name="name">extended.account.invoice.supplier.form</field>
<field name="model">account.invoice</field>
<field name="inherit_id" ref="account.invoice_supplier_form"/>
<field name="arch" type="xml">
<xpath expr="//page[@name='other_info']/group/group[1]/field[@name='name']" position="attributes">
<attribute name="attrs">{'invisible': [('reason_id','!=', False)]}</attribute>
</xpath>
<xpath expr="//field[@name='date']" position="after">
<field name="reason_id" attrs="{'invisible': [('reason_id', '=', False)]}" readonly="1"/>
</xpath>
</field>
</record>
</odoo>
5 changes: 5 additions & 0 deletions account_invoice_refund_reason/wizard/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Copyright (C) 2019 Open Source Integrators
# Copyright (C) 2019 Serpent Consulting Services Pvt. Ltd.
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from . import account_invoice_refund
30 changes: 30 additions & 0 deletions account_invoice_refund_reason/wizard/account_invoice_refund.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Copyright (C) 2019 Open Source Integrators
# Copyright (C) 2019 Serpent Consulting Services Pvt. Ltd.
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import api, fields, models


class AccountInvoiceRefund(models.TransientModel):
_inherit = 'account.invoice.refund'

reason_id = fields.Many2one('account.invoice.refund.reason',
string="Reason")

@api.onchange('reason_id')
def _onchange_reason_id(self):
if self.reason_id:
self.description = self.reason_id.name

@api.multi
def invoice_refund(self):
res = super(AccountInvoiceRefund, self).invoice_refund()
data_refund = self.read(['filter_refund'])[0]['filter_refund']
if data_refund == 'modify':
inv_id = res.get('res_id')
else:
inv_id = res.get('domain')[1][2][0]
if inv_id:
invoice = self.env['account.invoice'].browse(inv_id)
invoice.reason_id = self.reason_id
return res
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<odoo>
<record id="extended_view_account_invoice_refund" model="ir.ui.view">
<field name="name">extended.account.invoice.refund.form</field>
<field name="model">account.invoice.refund</field>
<field name="inherit_id" ref="account.view_account_invoice_refund"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='description']" position="attributes">
<attribute name="invisible">1</attribute>
<attribute name="required">0</attribute>
</xpath>
<xpath expr="//group[3]" position="inside">
<field name="reason_id" required="1"/>
</xpath>
</field>
</record>
</odoo>

0 comments on commit 82099e7

Please sign in to comment.