mirror of
https://github.com/ForgeFlow/stock-rma.git
synced 2025-01-21 12:57:49 +02:00
[14.0][ADD] rma_invoice
This commit is contained in:
81
rma_invoice/README.rst
Normal file
81
rma_invoice/README.rst
Normal file
@@ -0,0 +1,81 @@
|
||||
====================
|
||||
RMA Invoices Related
|
||||
====================
|
||||
|
||||
.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
!! This file is generated by oca-gen-addon-readme !!
|
||||
!! changes will be overwritten. !!
|
||||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
|
||||
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
|
||||
:target: https://odoo-community.org/page/development-status
|
||||
:alt: Beta
|
||||
.. |badge2| image:: https://img.shields.io/badge/licence-LGPL--3-blue.png
|
||||
:target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html
|
||||
:alt: License: LGPL-3
|
||||
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Frma-lightgray.png?logo=github
|
||||
:target: https://github.com/OCA/rma/tree/14.0/rma_invoice
|
||||
:alt: OCA/rma
|
||||
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
|
||||
:target: https://translation.odoo-community.org/projects/rma-14-0/rma-14-0-rma_invoice
|
||||
:alt: Translate me on Weblate
|
||||
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
|
||||
:target: https://runbot.odoo-community.org/runbot/145/14.0
|
||||
:alt: Try me on Runbot
|
||||
|
||||
|badge1| |badge2| |badge3| |badge4| |badge5|
|
||||
|
||||
This module add possibility to create invoice for extra services on RMA creation
|
||||
|
||||
**Table of contents**
|
||||
|
||||
.. contents::
|
||||
:local:
|
||||
|
||||
Bug Tracker
|
||||
===========
|
||||
|
||||
Bugs are tracked on `GitHub Issues <https://github.com/OCA/rma/issues>`_.
|
||||
In case of trouble, please check there if your issue has already been reported.
|
||||
If you spotted it first, help us smashing it by providing a detailed and welcomed
|
||||
`feedback <https://github.com/OCA/rma/issues/new?body=module:%20rma_invoice%0Aversion:%2014.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
|
||||
|
||||
Do not contact contributors directly about support or help with technical issues.
|
||||
|
||||
Credits
|
||||
=======
|
||||
|
||||
Authors
|
||||
~~~~~~~
|
||||
|
||||
* ForgeFlow
|
||||
|
||||
Contributors
|
||||
~~~~~~~~~~~~
|
||||
|
||||
* Christopher Ormaza <chris.ormaza@forgeflow.com>
|
||||
|
||||
Maintainers
|
||||
~~~~~~~~~~~
|
||||
|
||||
This module is maintained by the OCA.
|
||||
|
||||
.. image:: https://odoo-community.org/logo.png
|
||||
:alt: Odoo Community Association
|
||||
:target: https://odoo-community.org
|
||||
|
||||
OCA, or the Odoo Community Association, is a nonprofit organization whose
|
||||
mission is to support the collaborative development of Odoo features and
|
||||
promote its widespread use.
|
||||
|
||||
.. |maintainer-ChisOForgeFlow| image:: https://github.com/ChisOForgeFlow.png?size=40px
|
||||
:target: https://github.com/ChisOForgeFlow
|
||||
:alt: ChisOForgeFlow
|
||||
|
||||
Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:
|
||||
|
||||
|maintainer-ChisOForgeFlow|
|
||||
|
||||
This module is part of the `OCA/rma <https://github.com/OCA/rma/tree/14.0/rma_invoice>`_ project on GitHub.
|
||||
|
||||
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
|
||||
2
rma_invoice/__init__.py
Normal file
2
rma_invoice/__init__.py
Normal file
@@ -0,0 +1,2 @@
|
||||
from . import models
|
||||
from . import wizard
|
||||
23
rma_invoice/__manifest__.py
Normal file
23
rma_invoice/__manifest__.py
Normal file
@@ -0,0 +1,23 @@
|
||||
# © 2022 ForgeFlow S.L.
|
||||
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html)
|
||||
|
||||
{
|
||||
"name": "RMA Invoices Related",
|
||||
"version": "14.0.1.0.0",
|
||||
"category": "RMA",
|
||||
"summary": "RMA Invoices Related",
|
||||
"license": "LGPL-3",
|
||||
"author": "ForgeFlow, Odoo Community Association (OCA)",
|
||||
"website": "https://github.com/ForgeFlow/stock-rma",
|
||||
"depends": ["rma", "rma_account", "purchase"],
|
||||
"data": [
|
||||
"security/ir.model.access.csv",
|
||||
"wizard/wizard_create_invoice_rma_view.xml",
|
||||
"views/account_move_view.xml",
|
||||
"views/rma_order_line_view.xml",
|
||||
"views/rma_operation_view.xml",
|
||||
],
|
||||
"maintainers": ["ChisOForgeFlow"],
|
||||
"development_status": "Beta",
|
||||
"installable": True,
|
||||
}
|
||||
3
rma_invoice/models/__init__.py
Normal file
3
rma_invoice/models/__init__.py
Normal file
@@ -0,0 +1,3 @@
|
||||
from . import account_move
|
||||
from . import rma_order_line
|
||||
from . import rma_operation
|
||||
52
rma_invoice/models/account_move.py
Normal file
52
rma_invoice/models/account_move.py
Normal file
@@ -0,0 +1,52 @@
|
||||
# Copyright 2022 ForgeFlow S.L.
|
||||
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html)
|
||||
from odoo import api, fields, models
|
||||
from odoo.tools.safe_eval import safe_eval
|
||||
|
||||
|
||||
class AccountMove(models.Model):
|
||||
|
||||
_inherit = "account.move"
|
||||
|
||||
rma_order_line_ids = fields.Many2many(
|
||||
comodel_name="rma.order.line", string="Rma orders"
|
||||
)
|
||||
|
||||
rma_order_line_count = fields.Integer(
|
||||
string="Rma order lines Count",
|
||||
compute="_compute_rma_order_line_count",
|
||||
)
|
||||
|
||||
@api.depends("rma_order_line_ids")
|
||||
def _compute_rma_order_line_count(self):
|
||||
for rec in self:
|
||||
rec.rma_order_line_count = len(rec.rma_order_line_ids)
|
||||
|
||||
def action_show_rma_lines(self):
|
||||
self.ensure_one()
|
||||
action = {}
|
||||
form_view = False
|
||||
if self.move_type == "out_invoice":
|
||||
action = self.env["ir.actions.actions"]._for_xml_id(
|
||||
"rma.action_rma_customer_lines"
|
||||
)
|
||||
form_view = [(self.env.ref("rma.view_rma_line_form").id, "form")]
|
||||
elif self.move_type == "in_invoice":
|
||||
action = self.env["ir.actions.actions"]._for_xml_id(
|
||||
"rma.action_rma_supplier_lines"
|
||||
)
|
||||
form_view = [(self.env.ref("rma.view_rma_line_supplier_form").id, "form")]
|
||||
if len(self.rma_order_line_ids) <= 1 and form_view:
|
||||
if "views" in action:
|
||||
action["views"] = form_view + [
|
||||
(state, view) for state, view in action["views"] if view != "form"
|
||||
]
|
||||
else:
|
||||
action["views"] = form_view
|
||||
action["res_id"] = self.rma_order_line_ids.ids[0]
|
||||
else:
|
||||
action["domain"] += [("id", "in", self.rma_order_line_ids.ids)]
|
||||
domain = safe_eval(action["domain"]) or []
|
||||
domain += [("id", "in", self.rma_order_line_ids.ids)]
|
||||
action["domain"] = action["domain"]
|
||||
return action
|
||||
18
rma_invoice/models/rma_operation.py
Normal file
18
rma_invoice/models/rma_operation.py
Normal file
@@ -0,0 +1,18 @@
|
||||
# Copyright 2022 ForgeFlow S.L.
|
||||
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html)
|
||||
from odoo import fields, models
|
||||
|
||||
|
||||
class RmaOperation(models.Model):
|
||||
|
||||
_inherit = "rma.operation"
|
||||
|
||||
invoice_policy = fields.Selection(
|
||||
string="Invoice policy",
|
||||
selection=[
|
||||
("no", "Can't Create Services Invoice"),
|
||||
("yes", "Can Create Services Invoice"),
|
||||
],
|
||||
required=False,
|
||||
default="no",
|
||||
)
|
||||
76
rma_invoice/models/rma_order_line.py
Normal file
76
rma_invoice/models/rma_order_line.py
Normal file
@@ -0,0 +1,76 @@
|
||||
# Copyright 2022 ForgeFlow S.L.
|
||||
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html)
|
||||
from odoo import api, fields, models
|
||||
from odoo.tools.safe_eval import safe_eval
|
||||
|
||||
|
||||
class RmaOrderLine(models.Model):
|
||||
|
||||
_inherit = "rma.order.line"
|
||||
|
||||
invoice_policy = fields.Selection(
|
||||
string="Invoice policy",
|
||||
selection=[
|
||||
("no", "No Service Invoice"),
|
||||
("yes", "Create Service Invoice"),
|
||||
],
|
||||
)
|
||||
|
||||
invoice_ids = fields.Many2many(comodel_name="account.move", string="Invoices")
|
||||
|
||||
invoice_count = fields.Integer(
|
||||
string="Invoices count",
|
||||
compute="_compute_invoice_count",
|
||||
)
|
||||
|
||||
@api.depends(
|
||||
"invoice_ids",
|
||||
)
|
||||
def _compute_invoice_count(self):
|
||||
for rec in self:
|
||||
rec.invoice_count = len(rec.invoice_ids)
|
||||
|
||||
def action_show_invoices(self):
|
||||
self.ensure_one()
|
||||
action = {}
|
||||
if self.type == "customer":
|
||||
action = self.env["ir.actions.actions"]._for_xml_id(
|
||||
"account.action_move_out_invoice_type"
|
||||
)
|
||||
elif self.type == "supplier":
|
||||
action = self.env["ir.actions.actions"]._for_xml_id(
|
||||
"account.action_move_in_invoice_type"
|
||||
)
|
||||
if len(self.invoice_ids) <= 1:
|
||||
form_view = [(self.env.ref("account.view_move_form").id, "form")]
|
||||
if "views" in action:
|
||||
action["views"] = form_view + [
|
||||
(state, view) for state, view in action["views"] if view != "form"
|
||||
]
|
||||
else:
|
||||
action["views"] = form_view
|
||||
action["res_id"] = self.invoice_ids.ids[0]
|
||||
else:
|
||||
domain = safe_eval(action["domain"]) or []
|
||||
domain += [("id", "in", self.invoice_ids.ids)]
|
||||
action["domain"] = action["domain"]
|
||||
return action
|
||||
|
||||
def _prepare_rma_line_from_stock_move(self, sm, lot=False):
|
||||
operation_model = self.env["rma.operation"]
|
||||
res = super()._prepare_rma_line_from_stock_move()
|
||||
if res.get("operation_id", False):
|
||||
operation = operation_model.browse(res.get("operation_id", False))
|
||||
res.update(
|
||||
{
|
||||
"invoice_policy": operation.invoice_policy,
|
||||
}
|
||||
)
|
||||
return res
|
||||
|
||||
@api.onchange("operation_id")
|
||||
def _onchange_operation_id(self):
|
||||
res = super()._onchange_operation_id()
|
||||
if self.operation_id:
|
||||
self.invoice_policy = self.operation_id.invoice_policy
|
||||
return res
|
||||
1
rma_invoice/readme/CONTRIBUTORS.rst
Normal file
1
rma_invoice/readme/CONTRIBUTORS.rst
Normal file
@@ -0,0 +1 @@
|
||||
* Christopher Ormaza <chris.ormaza@forgeflow.com>
|
||||
1
rma_invoice/readme/DESCRIPTION.rst
Normal file
1
rma_invoice/readme/DESCRIPTION.rst
Normal file
@@ -0,0 +1 @@
|
||||
This module add possibility to create invoice for extra services on RMA creation
|
||||
2
rma_invoice/security/ir.model.access.csv
Normal file
2
rma_invoice/security/ir.model.access.csv
Normal file
@@ -0,0 +1,2 @@
|
||||
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
|
||||
access_wizard_create_invoice_rma,access_wizard_create_invoice_rma,model_wizard_create_invoice_rma,,1,1,1,1
|
||||
|
421
rma_invoice/static/description/index.html
Normal file
421
rma_invoice/static/description/index.html
Normal file
@@ -0,0 +1,421 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<meta name="generator" content="Docutils: http://docutils.sourceforge.net/" />
|
||||
<title>RMA Invoices Related</title>
|
||||
<style type="text/css">
|
||||
|
||||
/*
|
||||
:Author: David Goodger (goodger@python.org)
|
||||
:Id: $Id: html4css1.css 7952 2016-07-26 18:15:59Z milde $
|
||||
:Copyright: This stylesheet has been placed in the public domain.
|
||||
|
||||
Default cascading style sheet for the HTML output of Docutils.
|
||||
|
||||
See http://docutils.sf.net/docs/howto/html-stylesheets.html for how to
|
||||
customize this style sheet.
|
||||
*/
|
||||
|
||||
/* used to remove borders from tables and images */
|
||||
.borderless, table.borderless td, table.borderless th {
|
||||
border: 0 }
|
||||
|
||||
table.borderless td, table.borderless th {
|
||||
/* Override padding for "table.docutils td" with "! important".
|
||||
The right padding separates the table cells. */
|
||||
padding: 0 0.5em 0 0 ! important }
|
||||
|
||||
.first {
|
||||
/* Override more specific margin styles with "! important". */
|
||||
margin-top: 0 ! important }
|
||||
|
||||
.last, .with-subtitle {
|
||||
margin-bottom: 0 ! important }
|
||||
|
||||
.hidden {
|
||||
display: none }
|
||||
|
||||
.subscript {
|
||||
vertical-align: sub;
|
||||
font-size: smaller }
|
||||
|
||||
.superscript {
|
||||
vertical-align: super;
|
||||
font-size: smaller }
|
||||
|
||||
a.toc-backref {
|
||||
text-decoration: none ;
|
||||
color: black }
|
||||
|
||||
blockquote.epigraph {
|
||||
margin: 2em 5em ; }
|
||||
|
||||
dl.docutils dd {
|
||||
margin-bottom: 0.5em }
|
||||
|
||||
object[type="image/svg+xml"], object[type="application/x-shockwave-flash"] {
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
/* Uncomment (and remove this text!) to get bold-faced definition list terms
|
||||
dl.docutils dt {
|
||||
font-weight: bold }
|
||||
*/
|
||||
|
||||
div.abstract {
|
||||
margin: 2em 5em }
|
||||
|
||||
div.abstract p.topic-title {
|
||||
font-weight: bold ;
|
||||
text-align: center }
|
||||
|
||||
div.admonition, div.attention, div.caution, div.danger, div.error,
|
||||
div.hint, div.important, div.note, div.tip, div.warning {
|
||||
margin: 2em ;
|
||||
border: medium outset ;
|
||||
padding: 1em }
|
||||
|
||||
div.admonition p.admonition-title, div.hint p.admonition-title,
|
||||
div.important p.admonition-title, div.note p.admonition-title,
|
||||
div.tip p.admonition-title {
|
||||
font-weight: bold ;
|
||||
font-family: sans-serif }
|
||||
|
||||
div.attention p.admonition-title, div.caution p.admonition-title,
|
||||
div.danger p.admonition-title, div.error p.admonition-title,
|
||||
div.warning p.admonition-title, .code .error {
|
||||
color: red ;
|
||||
font-weight: bold ;
|
||||
font-family: sans-serif }
|
||||
|
||||
/* Uncomment (and remove this text!) to get reduced vertical space in
|
||||
compound paragraphs.
|
||||
div.compound .compound-first, div.compound .compound-middle {
|
||||
margin-bottom: 0.5em }
|
||||
|
||||
div.compound .compound-last, div.compound .compound-middle {
|
||||
margin-top: 0.5em }
|
||||
*/
|
||||
|
||||
div.dedication {
|
||||
margin: 2em 5em ;
|
||||
text-align: center ;
|
||||
font-style: italic }
|
||||
|
||||
div.dedication p.topic-title {
|
||||
font-weight: bold ;
|
||||
font-style: normal }
|
||||
|
||||
div.figure {
|
||||
margin-left: 2em ;
|
||||
margin-right: 2em }
|
||||
|
||||
div.footer, div.header {
|
||||
clear: both;
|
||||
font-size: smaller }
|
||||
|
||||
div.line-block {
|
||||
display: block ;
|
||||
margin-top: 1em ;
|
||||
margin-bottom: 1em }
|
||||
|
||||
div.line-block div.line-block {
|
||||
margin-top: 0 ;
|
||||
margin-bottom: 0 ;
|
||||
margin-left: 1.5em }
|
||||
|
||||
div.sidebar {
|
||||
margin: 0 0 0.5em 1em ;
|
||||
border: medium outset ;
|
||||
padding: 1em ;
|
||||
background-color: #ffffee ;
|
||||
width: 40% ;
|
||||
float: right ;
|
||||
clear: right }
|
||||
|
||||
div.sidebar p.rubric {
|
||||
font-family: sans-serif ;
|
||||
font-size: medium }
|
||||
|
||||
div.system-messages {
|
||||
margin: 5em }
|
||||
|
||||
div.system-messages h1 {
|
||||
color: red }
|
||||
|
||||
div.system-message {
|
||||
border: medium outset ;
|
||||
padding: 1em }
|
||||
|
||||
div.system-message p.system-message-title {
|
||||
color: red ;
|
||||
font-weight: bold }
|
||||
|
||||
div.topic {
|
||||
margin: 2em }
|
||||
|
||||
h1.section-subtitle, h2.section-subtitle, h3.section-subtitle,
|
||||
h4.section-subtitle, h5.section-subtitle, h6.section-subtitle {
|
||||
margin-top: 0.4em }
|
||||
|
||||
h1.title {
|
||||
text-align: center }
|
||||
|
||||
h2.subtitle {
|
||||
text-align: center }
|
||||
|
||||
hr.docutils {
|
||||
width: 75% }
|
||||
|
||||
img.align-left, .figure.align-left, object.align-left, table.align-left {
|
||||
clear: left ;
|
||||
float: left ;
|
||||
margin-right: 1em }
|
||||
|
||||
img.align-right, .figure.align-right, object.align-right, table.align-right {
|
||||
clear: right ;
|
||||
float: right ;
|
||||
margin-left: 1em }
|
||||
|
||||
img.align-center, .figure.align-center, object.align-center {
|
||||
display: block;
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
}
|
||||
|
||||
table.align-center {
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
}
|
||||
|
||||
.align-left {
|
||||
text-align: left }
|
||||
|
||||
.align-center {
|
||||
clear: both ;
|
||||
text-align: center }
|
||||
|
||||
.align-right {
|
||||
text-align: right }
|
||||
|
||||
/* reset inner alignment in figures */
|
||||
div.align-right {
|
||||
text-align: inherit }
|
||||
|
||||
/* div.align-center * { */
|
||||
/* text-align: left } */
|
||||
|
||||
.align-top {
|
||||
vertical-align: top }
|
||||
|
||||
.align-middle {
|
||||
vertical-align: middle }
|
||||
|
||||
.align-bottom {
|
||||
vertical-align: bottom }
|
||||
|
||||
ol.simple, ul.simple {
|
||||
margin-bottom: 1em }
|
||||
|
||||
ol.arabic {
|
||||
list-style: decimal }
|
||||
|
||||
ol.loweralpha {
|
||||
list-style: lower-alpha }
|
||||
|
||||
ol.upperalpha {
|
||||
list-style: upper-alpha }
|
||||
|
||||
ol.lowerroman {
|
||||
list-style: lower-roman }
|
||||
|
||||
ol.upperroman {
|
||||
list-style: upper-roman }
|
||||
|
||||
p.attribution {
|
||||
text-align: right ;
|
||||
margin-left: 50% }
|
||||
|
||||
p.caption {
|
||||
font-style: italic }
|
||||
|
||||
p.credits {
|
||||
font-style: italic ;
|
||||
font-size: smaller }
|
||||
|
||||
p.label {
|
||||
white-space: nowrap }
|
||||
|
||||
p.rubric {
|
||||
font-weight: bold ;
|
||||
font-size: larger ;
|
||||
color: maroon ;
|
||||
text-align: center }
|
||||
|
||||
p.sidebar-title {
|
||||
font-family: sans-serif ;
|
||||
font-weight: bold ;
|
||||
font-size: larger }
|
||||
|
||||
p.sidebar-subtitle {
|
||||
font-family: sans-serif ;
|
||||
font-weight: bold }
|
||||
|
||||
p.topic-title {
|
||||
font-weight: bold }
|
||||
|
||||
pre.address {
|
||||
margin-bottom: 0 ;
|
||||
margin-top: 0 ;
|
||||
font: inherit }
|
||||
|
||||
pre.literal-block, pre.doctest-block, pre.math, pre.code {
|
||||
margin-left: 2em ;
|
||||
margin-right: 2em }
|
||||
|
||||
pre.code .ln { color: grey; } /* line numbers */
|
||||
pre.code, code { background-color: #eeeeee }
|
||||
pre.code .comment, code .comment { color: #5C6576 }
|
||||
pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold }
|
||||
pre.code .literal.string, code .literal.string { color: #0C5404 }
|
||||
pre.code .name.builtin, code .name.builtin { color: #352B84 }
|
||||
pre.code .deleted, code .deleted { background-color: #DEB0A1}
|
||||
pre.code .inserted, code .inserted { background-color: #A3D289}
|
||||
|
||||
span.classifier {
|
||||
font-family: sans-serif ;
|
||||
font-style: oblique }
|
||||
|
||||
span.classifier-delimiter {
|
||||
font-family: sans-serif ;
|
||||
font-weight: bold }
|
||||
|
||||
span.interpreted {
|
||||
font-family: sans-serif }
|
||||
|
||||
span.option {
|
||||
white-space: nowrap }
|
||||
|
||||
span.pre {
|
||||
white-space: pre }
|
||||
|
||||
span.problematic {
|
||||
color: red }
|
||||
|
||||
span.section-subtitle {
|
||||
/* font-size relative to parent (h1..h6 element) */
|
||||
font-size: 80% }
|
||||
|
||||
table.citation {
|
||||
border-left: solid 1px gray;
|
||||
margin-left: 1px }
|
||||
|
||||
table.docinfo {
|
||||
margin: 2em 4em }
|
||||
|
||||
table.docutils {
|
||||
margin-top: 0.5em ;
|
||||
margin-bottom: 0.5em }
|
||||
|
||||
table.footnote {
|
||||
border-left: solid 1px black;
|
||||
margin-left: 1px }
|
||||
|
||||
table.docutils td, table.docutils th,
|
||||
table.docinfo td, table.docinfo th {
|
||||
padding-left: 0.5em ;
|
||||
padding-right: 0.5em ;
|
||||
vertical-align: top }
|
||||
|
||||
table.docutils th.field-name, table.docinfo th.docinfo-name {
|
||||
font-weight: bold ;
|
||||
text-align: left ;
|
||||
white-space: nowrap ;
|
||||
padding-left: 0 }
|
||||
|
||||
/* "booktabs" style (no vertical lines) */
|
||||
table.docutils.booktabs {
|
||||
border: 0px;
|
||||
border-top: 2px solid;
|
||||
border-bottom: 2px solid;
|
||||
border-collapse: collapse;
|
||||
}
|
||||
table.docutils.booktabs * {
|
||||
border: 0px;
|
||||
}
|
||||
table.docutils.booktabs th {
|
||||
border-bottom: thin solid;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
h1 tt.docutils, h2 tt.docutils, h3 tt.docutils,
|
||||
h4 tt.docutils, h5 tt.docutils, h6 tt.docutils {
|
||||
font-size: 100% }
|
||||
|
||||
ul.auto-toc {
|
||||
list-style-type: none }
|
||||
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="document" id="rma-invoices-related">
|
||||
<h1 class="title">RMA Invoices Related</h1>
|
||||
|
||||
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
!! This file is generated by oca-gen-addon-readme !!
|
||||
!! changes will be overwritten. !!
|
||||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
|
||||
<p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/lgpl-3.0-standalone.html"><img alt="License: LGPL-3" src="https://img.shields.io/badge/licence-LGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/rma/tree/14.0/rma_invoice"><img alt="OCA/rma" src="https://img.shields.io/badge/github-OCA%2Frma-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/rma-14-0/rma-14-0-rma_invoice"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/145/14.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
|
||||
<p>This module add possibility to create invoice for extra services on RMA creation</p>
|
||||
<p><strong>Table of contents</strong></p>
|
||||
<div class="contents local topic" id="contents">
|
||||
<ul class="simple">
|
||||
<li><a class="reference internal" href="#bug-tracker" id="id1">Bug Tracker</a></li>
|
||||
<li><a class="reference internal" href="#credits" id="id2">Credits</a><ul>
|
||||
<li><a class="reference internal" href="#authors" id="id3">Authors</a></li>
|
||||
<li><a class="reference internal" href="#contributors" id="id4">Contributors</a></li>
|
||||
<li><a class="reference internal" href="#maintainers" id="id5">Maintainers</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="section" id="bug-tracker">
|
||||
<h1><a class="toc-backref" href="#id1">Bug Tracker</a></h1>
|
||||
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/rma/issues">GitHub Issues</a>.
|
||||
In case of trouble, please check there if your issue has already been reported.
|
||||
If you spotted it first, help us smashing it by providing a detailed and welcomed
|
||||
<a class="reference external" href="https://github.com/OCA/rma/issues/new?body=module:%20rma_invoice%0Aversion:%2014.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
|
||||
<p>Do not contact contributors directly about support or help with technical issues.</p>
|
||||
</div>
|
||||
<div class="section" id="credits">
|
||||
<h1><a class="toc-backref" href="#id2">Credits</a></h1>
|
||||
<div class="section" id="authors">
|
||||
<h2><a class="toc-backref" href="#id3">Authors</a></h2>
|
||||
<ul class="simple">
|
||||
<li>ForgeFlow</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="section" id="contributors">
|
||||
<h2><a class="toc-backref" href="#id4">Contributors</a></h2>
|
||||
<ul class="simple">
|
||||
<li>Christopher Ormaza <<a class="reference external" href="mailto:chris.ormaza@forgeflow.com">chris.ormaza@forgeflow.com</a>></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="section" id="maintainers">
|
||||
<h2><a class="toc-backref" href="#id5">Maintainers</a></h2>
|
||||
<p>This module is maintained by the OCA.</p>
|
||||
<a class="reference external image-reference" href="https://odoo-community.org"><img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" /></a>
|
||||
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose
|
||||
mission is to support the collaborative development of Odoo features and
|
||||
promote its widespread use.</p>
|
||||
<p>Current <a class="reference external" href="https://odoo-community.org/page/maintainer-role">maintainer</a>:</p>
|
||||
<p><a class="reference external" href="https://github.com/ChisOForgeFlow"><img alt="ChisOForgeFlow" src="https://github.com/ChisOForgeFlow.png?size=40px" /></a></p>
|
||||
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/rma/tree/14.0/rma_invoice">OCA/rma</a> project on GitHub.</p>
|
||||
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
31
rma_invoice/views/account_move_view.xml
Normal file
31
rma_invoice/views/account_move_view.xml
Normal file
@@ -0,0 +1,31 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<odoo>
|
||||
<data>
|
||||
|
||||
<record id="view_account_move_form" model="ir.ui.view">
|
||||
<field name="name">account.move.form</field>
|
||||
<field name="model">account.move</field>
|
||||
<field name="inherit_id" ref="account.view_move_form" />
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//button[@name='open_reconcile_view']" position="before">
|
||||
<button
|
||||
type="object"
|
||||
name="action_show_rma_lines"
|
||||
class="oe_stat_button"
|
||||
icon="fa-link"
|
||||
groups="rma.group_rma_customer_user,rma.group_rma_supplier_user"
|
||||
attrs="{'invisible': [('rma_order_line_count', '<=', 0)]}"
|
||||
>
|
||||
<field
|
||||
name="rma_order_line_count"
|
||||
widget="statinfo"
|
||||
string="RMAs"
|
||||
/>
|
||||
</button>
|
||||
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</odoo>
|
||||
17
rma_invoice/views/rma_operation_view.xml
Normal file
17
rma_invoice/views/rma_operation_view.xml
Normal file
@@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<odoo>
|
||||
<data>
|
||||
|
||||
<record id="rma_operation_form" model="ir.ui.view">
|
||||
<field name="name">rma.operation.form.view</field>
|
||||
<field name="model">rma.operation</field>
|
||||
<field name="inherit_id" ref="rma.rma_operation_form" />
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//field[@name='delivery_policy']" position="after">
|
||||
<field name="invoice_policy" />
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</odoo>
|
||||
43
rma_invoice/views/rma_order_line_view.xml
Normal file
43
rma_invoice/views/rma_order_line_view.xml
Normal file
@@ -0,0 +1,43 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<odoo>
|
||||
<data>
|
||||
|
||||
<record id="view_rma_line_form" model="ir.ui.view">
|
||||
<field name="name">rma.order.line.form.view</field>
|
||||
<field name="model">rma.order.line</field>
|
||||
<field name="inherit_id" ref="rma.view_rma_line_form" />
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//button[@name='action_view_rma_lines']" position="before">
|
||||
<button
|
||||
type="object"
|
||||
name="action_show_invoices"
|
||||
class="oe_stat_button"
|
||||
icon="fa-sticky-note-o"
|
||||
groups="account.group_account_invoice"
|
||||
attrs="{'invisible': [('invoice_count', '<=', 0)]}"
|
||||
>
|
||||
<field
|
||||
name="invoice_count"
|
||||
widget="statinfo"
|
||||
string="Service Invoices"
|
||||
/>
|
||||
</button>
|
||||
</xpath>
|
||||
<xpath expr="//field[@name='receipt_policy']" position="before">
|
||||
<field name="invoice_policy" />
|
||||
</xpath>
|
||||
<xpath expr="//button[@name='action_rma_done']" position="after">
|
||||
<button
|
||||
name="%(wizard_create_invoice_rma_action)d"
|
||||
type="action"
|
||||
string="Create Services Invoice"
|
||||
class="oe_highlight"
|
||||
attrs="{'invisible': ['|', ('invoice_policy', '!=', 'yes'), ('state', '=', 'draft')]}"
|
||||
/>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
|
||||
</data>
|
||||
</odoo>
|
||||
1
rma_invoice/wizard/__init__.py
Normal file
1
rma_invoice/wizard/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from . import wizard_create_invoice_rma
|
||||
82
rma_invoice/wizard/wizard_create_invoice_rma.py
Normal file
82
rma_invoice/wizard/wizard_create_invoice_rma.py
Normal file
@@ -0,0 +1,82 @@
|
||||
# Copyright 2022 ForgeFlow S.L.
|
||||
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html)
|
||||
|
||||
from odoo import _, api, fields, models
|
||||
from odoo.exceptions import UserError
|
||||
|
||||
|
||||
class WizardCreateInvoiceRma(models.TransientModel):
|
||||
|
||||
_name = "wizard.create.invoice.rma"
|
||||
_description = "Wizard to create Invoice From RMA"
|
||||
|
||||
journal_id = fields.Many2one(
|
||||
comodel_name="account.journal",
|
||||
string="Journal",
|
||||
required=True,
|
||||
)
|
||||
invoice_date = fields.Date(
|
||||
string="Invoice date",
|
||||
required=True,
|
||||
default=fields.Date.today(),
|
||||
)
|
||||
|
||||
@api.model
|
||||
def default_get(self, fields_list):
|
||||
values = super(WizardCreateInvoiceRma, self).default_get(fields_list)
|
||||
rma_model = self.env["rma.order.line"]
|
||||
journal_model = self.env["account.journal"]
|
||||
current_rmas = rma_model.browse(self.env.context.get("active_ids")).filtered(
|
||||
lambda x: x.state != "draft"
|
||||
)
|
||||
rma_type = current_rmas.mapped("type")[0]
|
||||
journal_type = (
|
||||
rma_type == "customer" and "sale" or rma_type == "supplier" and "purchase"
|
||||
)
|
||||
journal = journal_model.search([("type", "=", journal_type)], limit=1)
|
||||
if journal:
|
||||
values["journal_id"] = journal.id
|
||||
return values
|
||||
|
||||
def action_create_invoice(self):
|
||||
account_move_model = self.env["account.move"]
|
||||
rma_model = self.env["rma.order.line"]
|
||||
current_rmas = rma_model.browse(self.env.context.get("active_ids")).filtered(
|
||||
lambda x: x.state != "draft"
|
||||
)
|
||||
if len(current_rmas.mapped("partner_id")) != 1:
|
||||
raise UserError(_("You can't make service invoice with different partners"))
|
||||
rma_type = current_rmas.mapped("type")[0]
|
||||
journal_type = (
|
||||
rma_type == "customer"
|
||||
and "out_invoice"
|
||||
or rma_type == "supplier"
|
||||
and "in_invoice"
|
||||
)
|
||||
invoices = account_move_model.create(
|
||||
{
|
||||
"move_type": journal_type,
|
||||
"partner_id": current_rmas.mapped("partner_id").id,
|
||||
"rma_order_line_ids": [(6, 0, current_rmas.ids)],
|
||||
"invoice_origin": " / ".join(current_rmas.mapped("display_name")),
|
||||
"invoice_date": self.invoice_date,
|
||||
"journal_id": self.journal_id.id,
|
||||
}
|
||||
)
|
||||
if journal_type == "out_invoice":
|
||||
action = self.env["ir.actions.actions"]._for_xml_id(
|
||||
"account.action_move_out_invoice_type"
|
||||
)
|
||||
if journal_type == "in_invoice":
|
||||
action = self.env["ir.actions.actions"]._for_xml_id(
|
||||
"account.action_move_in_invoice_type"
|
||||
)
|
||||
form_view = [(self.env.ref("account.view_move_form").id, "form")]
|
||||
if "views" in action:
|
||||
action["views"] = form_view + [
|
||||
(state, view) for state, view in action["views"] if view != "form"
|
||||
]
|
||||
else:
|
||||
action["views"] = form_view
|
||||
action["res_id"] = invoices.id
|
||||
return action
|
||||
43
rma_invoice/wizard/wizard_create_invoice_rma_view.xml
Normal file
43
rma_invoice/wizard/wizard_create_invoice_rma_view.xml
Normal file
@@ -0,0 +1,43 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<odoo>
|
||||
<data>
|
||||
|
||||
<record id="wizard_create_invoice_rma_view_form" model="ir.ui.view">
|
||||
<field name="name">wizard_create_invoice_rma_view_form</field>
|
||||
<field name="model">wizard.create.invoice.rma</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="wizard_create_invoice_rma_form">
|
||||
<sheet>
|
||||
<group>
|
||||
<field name="journal_id" />
|
||||
<field name="invoice_date" />
|
||||
</group>
|
||||
</sheet>
|
||||
<footer>
|
||||
<button
|
||||
name="action_create_invoice"
|
||||
string="Create Invoice"
|
||||
type="object"
|
||||
class="btn-primary"
|
||||
/>
|
||||
<button
|
||||
string="Cancel"
|
||||
class="btn-secondary"
|
||||
special="cancel"
|
||||
/>
|
||||
</footer>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="wizard_create_invoice_rma_action" model="ir.actions.act_window">
|
||||
<field name="name">Create Service Invoices from RMA</field>
|
||||
<field name="type">ir.actions.act_window</field>
|
||||
<field name="res_model">wizard.create.invoice.rma</field>
|
||||
<field name="view_mode">form</field>
|
||||
<field name="target">new</field>
|
||||
<field name="binding_model_id" ref="rma.model_rma_order_line" />
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</odoo>
|
||||
1
setup/rma_invoice/odoo/addons/rma_invoice
Symbolic link
1
setup/rma_invoice/odoo/addons/rma_invoice
Symbolic link
@@ -0,0 +1 @@
|
||||
../../../../rma_invoice
|
||||
6
setup/rma_invoice/setup.py
Normal file
6
setup/rma_invoice/setup.py
Normal file
@@ -0,0 +1,6 @@
|
||||
import setuptools
|
||||
|
||||
setuptools.setup(
|
||||
setup_requires=['setuptools-odoo'],
|
||||
odoo_addon=True,
|
||||
)
|
||||
Reference in New Issue
Block a user