mirror of
https://github.com/ForgeFlow/stock-rma.git
synced 2025-01-21 12:57:49 +02:00
[MIG]rma_account to v13
This commit is contained in:
@@ -3,11 +3,11 @@
|
|||||||
|
|
||||||
{
|
{
|
||||||
"name": "RMA Account",
|
"name": "RMA Account",
|
||||||
"version": "12.0.1.0.0",
|
"version": "13.0.1.0.0",
|
||||||
"license": "LGPL-3",
|
"license": "LGPL-3",
|
||||||
"category": "RMA",
|
"category": "RMA",
|
||||||
"summary": "Integrates RMA with Invoice Processing",
|
"summary": "Integrates RMA with Invoice Processing",
|
||||||
"author": "ForgeFlow, Odoo Community Association (OCA)",
|
"author": "ForgeFlow",
|
||||||
"website": "https://github.com/ForgeFlow/stock-rma",
|
"website": "https://github.com/ForgeFlow/stock-rma",
|
||||||
"depends": ["stock_account", "rma"],
|
"depends": ["stock_account", "rma"],
|
||||||
"demo": ["data/rma_operation.xml"],
|
"demo": ["data/rma_operation.xml"],
|
||||||
@@ -16,9 +16,9 @@
|
|||||||
"views/rma_order_view.xml",
|
"views/rma_order_view.xml",
|
||||||
"views/rma_operation_view.xml",
|
"views/rma_operation_view.xml",
|
||||||
"views/rma_order_line_view.xml",
|
"views/rma_order_line_view.xml",
|
||||||
"views/invoice_view.xml",
|
"views/account_move_view.xml",
|
||||||
"views/rma_account_menu.xml",
|
"views/rma_account_menu.xml",
|
||||||
"wizards/rma_add_invoice.xml",
|
"wizards/rma_add_account_move.xml",
|
||||||
"wizards/rma_refund.xml",
|
"wizards/rma_refund.xml",
|
||||||
],
|
],
|
||||||
"installable": True,
|
"installable": True,
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<?xml version="1.0"?>
|
<?xml version="1.0"?>
|
||||||
<odoo noupdate="0">
|
<odoo noupdate="1">
|
||||||
|
|
||||||
<record id="rma.rma_operation_customer_replace" model="rma.operation">
|
<record id="rma.rma_operation_customer_replace" model="rma.operation">
|
||||||
<field name="refund_policy">no</field>
|
<field name="refund_policy">no</field>
|
||||||
|
|||||||
@@ -4,4 +4,4 @@
|
|||||||
from . import rma_order
|
from . import rma_order
|
||||||
from . import rma_order_line
|
from . import rma_order_line
|
||||||
from . import rma_operation
|
from . import rma_operation
|
||||||
from . import invoice
|
from . import account_move
|
||||||
|
|||||||
@@ -5,13 +5,13 @@ from odoo import api, fields, models
|
|||||||
from odoo.tools.float_utils import float_compare
|
from odoo.tools.float_utils import float_compare
|
||||||
|
|
||||||
|
|
||||||
class AccountInvoice(models.Model):
|
class AccountMove(models.Model):
|
||||||
_inherit = "account.invoice"
|
_inherit = "account.move"
|
||||||
|
|
||||||
@api.depends("invoice_line_ids.rma_line_ids")
|
@api.depends("line_ids.rma_line_ids")
|
||||||
def _compute_rma_count(self):
|
def _compute_rma_count(self):
|
||||||
for inv in self:
|
for inv in self:
|
||||||
rmas = self.mapped("invoice_line_ids.rma_line_ids")
|
rmas = self.mapped("line_ids.rma_line_ids")
|
||||||
inv.rma_count = len(rmas)
|
inv.rma_count = len(rmas)
|
||||||
|
|
||||||
def _prepare_invoice_line_from_rma_line(self, line):
|
def _prepare_invoice_line_from_rma_line(self, line):
|
||||||
@@ -19,18 +19,17 @@ class AccountInvoice(models.Model):
|
|||||||
if float_compare(qty, 0.0, precision_rounding=line.uom_id.rounding) <= 0:
|
if float_compare(qty, 0.0, precision_rounding=line.uom_id.rounding) <= 0:
|
||||||
qty = 0.0
|
qty = 0.0
|
||||||
# Todo fill taxes from somewhere
|
# Todo fill taxes from somewhere
|
||||||
invoice_line = self.env["account.invoice.line"]
|
invoice_line = self.env["account.move.line"]
|
||||||
data = {
|
data = {
|
||||||
"purchase_line_id": line.id,
|
"purchase_line_id": line.id,
|
||||||
"name": line.name + ": " + line.name,
|
"name": line.name + ": " + line.name,
|
||||||
"origin": line.origin,
|
"product_uom_id": line.uom_id.id,
|
||||||
"uom_id": line.uom_id.id,
|
|
||||||
"product_id": line.product_id.id,
|
"product_id": line.product_id.id,
|
||||||
"account_id": invoice_line.with_context(
|
"account_id": invoice_line.with_context(
|
||||||
{"journal_id": self.journal_id.id, "type": "in_invoice"}
|
{"journal_id": self.journal_id.id, "type": "in_invoice"}
|
||||||
)._default_account(),
|
)._default_account(),
|
||||||
"price_unit": line.company_id.currency_id.with_context(
|
"price_unit": line.company_id.currency_id.with_context(
|
||||||
date=self.date_invoice
|
date=self.date
|
||||||
).compute(line.price_unit, self.currency_id, round=False),
|
).compute(line.price_unit, self.currency_id, round=False),
|
||||||
"quantity": qty,
|
"quantity": qty,
|
||||||
"discount": 0.0,
|
"discount": 0.0,
|
||||||
@@ -45,12 +44,12 @@ class AccountInvoice(models.Model):
|
|||||||
if not self.partner_id:
|
if not self.partner_id:
|
||||||
self.partner_id = self.add_rma_line_id.partner_id.id
|
self.partner_id = self.add_rma_line_id.partner_id.id
|
||||||
|
|
||||||
new_line = self.env["account.invoice.line"]
|
new_line = self.env["account.move.line"]
|
||||||
if self.add_rma_line_id not in (self.invoice_line_ids.mapped("rma_line_id")):
|
if self.add_rma_line_id not in (self.line_ids.mapped("rma_line_id")):
|
||||||
data = self._prepare_invoice_line_from_rma_line(self.add_rma_line_id)
|
data = self._prepare_invoice_line_from_rma_line(self.add_rma_line_id)
|
||||||
new_line = new_line.new(data)
|
new_line = new_line.new(data)
|
||||||
new_line._set_additional_fields(self)
|
new_line._set_additional_fields(self)
|
||||||
self.invoice_line_ids += new_line
|
self.line_ids += new_line
|
||||||
self.add_rma_line_id = False
|
self.add_rma_line_id = False
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
@@ -63,11 +62,10 @@ class AccountInvoice(models.Model):
|
|||||||
help="Create a refund in based on an existing rma_line",
|
help="Create a refund in based on an existing rma_line",
|
||||||
)
|
)
|
||||||
|
|
||||||
@api.multi
|
|
||||||
def action_view_rma_supplier(self):
|
def action_view_rma_supplier(self):
|
||||||
action = self.env.ref("rma.action_rma_supplier_lines")
|
action = self.env.ref("rma.action_rma_supplier_lines")
|
||||||
result = action.read()[0]
|
result = action.read()[0]
|
||||||
rma_ids = self.mapped("invoice_line_ids.rma_line_ids").ids
|
rma_ids = self.mapped("line_ids.rma_line_ids").ids
|
||||||
if rma_ids:
|
if rma_ids:
|
||||||
# choose the view_mode accordingly
|
# choose the view_mode accordingly
|
||||||
if len(rma_ids) > 1:
|
if len(rma_ids) > 1:
|
||||||
@@ -78,11 +76,10 @@ class AccountInvoice(models.Model):
|
|||||||
result["res_id"] = rma_ids[0]
|
result["res_id"] = rma_ids[0]
|
||||||
return result
|
return result
|
||||||
|
|
||||||
@api.multi
|
|
||||||
def action_view_rma_customer(self):
|
def action_view_rma_customer(self):
|
||||||
action = self.env.ref("rma.action_rma_customer_lines")
|
action = self.env.ref("rma.action_rma_customer_lines")
|
||||||
result = action.read()[0]
|
result = action.read()[0]
|
||||||
rma_ids = self.mapped("invoice_line_ids.rma_line_ids").ids
|
rma_ids = self.mapped("line_ids.rma_line_ids").ids
|
||||||
if rma_ids:
|
if rma_ids:
|
||||||
# choose the view_mode accordingly
|
# choose the view_mode accordingly
|
||||||
if len(rma_ids) > 1:
|
if len(rma_ids) > 1:
|
||||||
@@ -94,8 +91,8 @@ class AccountInvoice(models.Model):
|
|||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
class AccountInvoiceLine(models.Model):
|
class AccountMoveLine(models.Model):
|
||||||
_inherit = "account.invoice.line"
|
_inherit = "account.move.line"
|
||||||
|
|
||||||
@api.model
|
@api.model
|
||||||
def name_search(self, name, args=None, operator="ilike", limit=100):
|
def name_search(self, name, args=None, operator="ilike", limit=100):
|
||||||
@@ -104,7 +101,7 @@ class AccountInvoiceLine(models.Model):
|
|||||||
will make impossible to get the desired result."""
|
will make impossible to get the desired result."""
|
||||||
if not args:
|
if not args:
|
||||||
args = []
|
args = []
|
||||||
lines = self.search([("invoice_id.number", operator, name)] + args, limit=limit)
|
lines = self.search([("move_id.name", operator, name)] + args, limit=limit)
|
||||||
res = lines.name_get()
|
res = lines.name_get()
|
||||||
if limit:
|
if limit:
|
||||||
limit_rest = limit - len(lines)
|
limit_rest = limit - len(lines)
|
||||||
@@ -113,50 +110,48 @@ class AccountInvoiceLine(models.Model):
|
|||||||
limit_rest = limit
|
limit_rest = limit
|
||||||
if limit_rest or not limit:
|
if limit_rest or not limit:
|
||||||
args += [("id", "not in", lines.ids)]
|
args += [("id", "not in", lines.ids)]
|
||||||
res += super(AccountInvoiceLine, self).name_search(
|
res += super(AccountMoveLine, self).name_search(
|
||||||
name, args=args, operator=operator, limit=limit_rest
|
name, args=args, operator=operator, limit=limit_rest
|
||||||
)
|
)
|
||||||
return res
|
return res
|
||||||
|
|
||||||
@api.multi
|
|
||||||
def name_get(self):
|
def name_get(self):
|
||||||
res = []
|
res = []
|
||||||
if self.env.context.get("rma"):
|
if self.env.context.get("rma"):
|
||||||
for inv in self:
|
for inv in self:
|
||||||
if inv.invoice_id.reference:
|
if inv.move_id.ref:
|
||||||
res.append(
|
res.append(
|
||||||
(
|
(
|
||||||
inv.id,
|
inv.id,
|
||||||
"INV:%s | REF:%s | ORIG:%s | PART:%s | QTY:%s"
|
"INV:%s | REF:%s | ORIG:%s | PART:%s | QTY:%s"
|
||||||
% (
|
% (
|
||||||
inv.invoice_id.number or "",
|
inv.move_id.name or "",
|
||||||
inv.origin or "",
|
inv.move_id.invoice_origin or "",
|
||||||
inv.invoice_id.reference or "",
|
inv.move_id.ref or "",
|
||||||
inv.product_id.name,
|
inv.product_id.name,
|
||||||
inv.quantity,
|
inv.quantity,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
elif inv.invoice_id.number:
|
elif inv.move_id.name:
|
||||||
res.append(
|
res.append(
|
||||||
(
|
(
|
||||||
inv.id,
|
inv.id,
|
||||||
"INV:%s | ORIG:%s | PART:%s | QTY:%s"
|
"INV:%s | ORIG:%s | PART:%s | QTY:%s"
|
||||||
% (
|
% (
|
||||||
inv.invoice_id.number or "",
|
inv.move_id.name or "",
|
||||||
inv.origin or "",
|
inv.move_id.invoice_origin or "",
|
||||||
inv.product_id.name,
|
inv.product_id.name,
|
||||||
inv.quantity,
|
inv.quantity,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
res.append(super(AccountInvoiceLine, inv).name_get()[0])
|
res.append(super(AccountMoveLine, inv).name_get()[0])
|
||||||
return res
|
return res
|
||||||
else:
|
else:
|
||||||
return super(AccountInvoiceLine, self).name_get()
|
return super(AccountMoveLine, self).name_get()
|
||||||
|
|
||||||
@api.multi
|
|
||||||
def _compute_rma_count(self):
|
def _compute_rma_count(self):
|
||||||
for invl in self:
|
for invl in self:
|
||||||
rma_lines = invl.mapped("rma_line_ids")
|
rma_lines = invl.mapped("rma_line_ids")
|
||||||
@@ -165,7 +160,7 @@ class AccountInvoiceLine(models.Model):
|
|||||||
rma_line_count = fields.Integer(compute="_compute_rma_count", string="# of RMA")
|
rma_line_count = fields.Integer(compute="_compute_rma_count", string="# of RMA")
|
||||||
rma_line_ids = fields.One2many(
|
rma_line_ids = fields.One2many(
|
||||||
comodel_name="rma.order.line",
|
comodel_name="rma.order.line",
|
||||||
inverse_name="invoice_line_id",
|
inverse_name="account_move_line_id",
|
||||||
string="RMA",
|
string="RMA",
|
||||||
readonly=True,
|
readonly=True,
|
||||||
help="This will contain the RMA lines for the invoice line",
|
help="This will contain the RMA lines for the invoice line",
|
||||||
@@ -7,20 +7,18 @@ from odoo import api, fields, models
|
|||||||
class RmaOrder(models.Model):
|
class RmaOrder(models.Model):
|
||||||
_inherit = "rma.order"
|
_inherit = "rma.order"
|
||||||
|
|
||||||
@api.multi
|
|
||||||
def _compute_invoice_refund_count(self):
|
def _compute_invoice_refund_count(self):
|
||||||
for rec in self:
|
for rec in self:
|
||||||
invoices = rec.mapped("rma_line_ids.refund_line_ids.invoice_id")
|
invoices = rec.mapped("rma_line_ids.refund_line_ids.move_id")
|
||||||
rec.invoice_refund_count = len(invoices)
|
rec.invoice_refund_count = len(invoices)
|
||||||
|
|
||||||
@api.multi
|
|
||||||
def _compute_invoice_count(self):
|
def _compute_invoice_count(self):
|
||||||
for rec in self:
|
for rec in self:
|
||||||
invoices = rec.mapped("rma_line_ids.invoice_id")
|
invoices = rec.mapped("rma_line_ids.move_id")
|
||||||
rec.invoice_count = len(invoices)
|
rec.invoice_count = len(invoices)
|
||||||
|
|
||||||
add_invoice_id = fields.Many2one(
|
add_move_id = fields.Many2one(
|
||||||
comodel_name="account.invoice",
|
comodel_name="account.move",
|
||||||
string="Add Invoice",
|
string="Add Invoice",
|
||||||
ondelete="set null",
|
ondelete="set null",
|
||||||
readonly=True,
|
readonly=True,
|
||||||
@@ -44,30 +42,30 @@ class RmaOrder(models.Model):
|
|||||||
or self.rma_line_ids.product_id.categ_id.rma_supplier_operation_id
|
or self.rma_line_ids.product_id.categ_id.rma_supplier_operation_id
|
||||||
)
|
)
|
||||||
data = {
|
data = {
|
||||||
"invoice_line_id": line.id,
|
"account_move_line_id": line.id,
|
||||||
"product_id": line.product_id.id,
|
"product_id": line.product_id.id,
|
||||||
"name": line.name,
|
"name": line.name,
|
||||||
"origin": line.invoice_id.number,
|
"origin": line.move_id.name,
|
||||||
"uom_id": line.uom_id.id,
|
"uom_id": line.product_uom_id.id,
|
||||||
"operation_id": operation,
|
"operation_id": operation,
|
||||||
"product_qty": line.quantity,
|
"product_qty": line.quantity,
|
||||||
"price_unit": line.invoice_id.currency_id.compute(
|
"price_unit": line.move_id.currency_id.compute(
|
||||||
line.price_unit, line.currency_id, round=False
|
line.price_unit, line.currency_id, round=False
|
||||||
),
|
),
|
||||||
"rma_id": self.id,
|
"rma_id": self.id,
|
||||||
}
|
}
|
||||||
return data
|
return data
|
||||||
|
|
||||||
@api.onchange("add_invoice_id")
|
@api.onchange("add_move_id")
|
||||||
def on_change_invoice(self):
|
def on_change_invoice(self):
|
||||||
if not self.add_invoice_id:
|
if not self.add_move_id:
|
||||||
return {}
|
return {}
|
||||||
if not self.partner_id:
|
if not self.partner_id:
|
||||||
self.partner_id = self.add_invoice_id.partner_id.id
|
self.partner_id = self.add_move_id.partner_id.id
|
||||||
new_lines = self.env["rma.order.line"]
|
new_lines = self.env["rma.order.line"]
|
||||||
for line in self.add_invoice_id.invoice_line_ids:
|
for line in self.add_move_id.line_ids:
|
||||||
# Load a PO line only once
|
# Load a PO line only once
|
||||||
if line in self.rma_line_ids.mapped("invoice_line_id"):
|
if line in self.rma_line_ids.mapped("account_move_line_id"):
|
||||||
continue
|
continue
|
||||||
data = self._prepare_rma_line_from_inv_line(line)
|
data = self._prepare_rma_line_from_inv_line(line)
|
||||||
new_line = new_lines.new(data)
|
new_line = new_lines.new(data)
|
||||||
@@ -75,9 +73,9 @@ class RmaOrder(models.Model):
|
|||||||
|
|
||||||
self.rma_line_ids += new_lines
|
self.rma_line_ids += new_lines
|
||||||
self.date_rma = fields.Datetime.now()
|
self.date_rma = fields.Datetime.now()
|
||||||
self.delivery_address_id = self.add_invoice_id.partner_id.id
|
self.delivery_address_id = self.add_move_id.partner_id.id
|
||||||
self.invoice_address_id = self.add_invoice_id.partner_id.id
|
self.invoice_address_id = self.add_move_id.partner_id.id
|
||||||
self.add_invoice_id = False
|
self.add_move_id = False
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
@api.model
|
@api.model
|
||||||
@@ -92,36 +90,34 @@ class RmaOrder(models.Model):
|
|||||||
res["invoice_address_id"] = partner.id
|
res["invoice_address_id"] = partner.id
|
||||||
return res
|
return res
|
||||||
|
|
||||||
@api.multi
|
|
||||||
def action_view_invoice_refund(self):
|
def action_view_invoice_refund(self):
|
||||||
action = self.env.ref("account.action_invoice_tree2")
|
action = self.env.ref("account.action_invoice_tree2")
|
||||||
result = action.read()[0]
|
result = action.read()[0]
|
||||||
invoice_ids = self.mapped("rma_line_ids.refund_line_ids.invoice_id").ids
|
move_ids = self.mapped("rma_line_ids.refund_line_ids.move_id").ids
|
||||||
if invoice_ids:
|
if move_ids:
|
||||||
# choose the view_mode accordingly
|
# choose the view_mode accordingly
|
||||||
if len(invoice_ids) > 1:
|
if len(move_ids) > 1:
|
||||||
result["domain"] = [("id", "in", invoice_ids)]
|
result["domain"] = [("id", "in", move_ids)]
|
||||||
else:
|
else:
|
||||||
res = self.env.ref("account.invoice_supplier_form", False)
|
res = self.env.ref("account.move_supplier_form", False)
|
||||||
result["views"] = [(res and res.id or False, "form")]
|
result["views"] = [(res and res.id or False, "form")]
|
||||||
result["res_id"] = invoice_ids[0]
|
result["res_id"] = move_ids[0]
|
||||||
return result
|
return result
|
||||||
|
|
||||||
@api.multi
|
|
||||||
def action_view_invoice(self):
|
def action_view_invoice(self):
|
||||||
if self.type == "supplier":
|
if self.type == "supplier":
|
||||||
action = self.env.ref("account.action_invoice_tree2")
|
action = self.env.ref("account.action_invoice_tree2")
|
||||||
res = self.env.ref("account.invoice_supplier_form", False)
|
res = self.env.ref("account.move_supplier_form", False)
|
||||||
else:
|
else:
|
||||||
action = self.env.ref("account.action_invoice_tree")
|
action = self.env.ref("account.action_invoice_tree")
|
||||||
res = self.env.ref("account.invoice_form", False)
|
res = self.env.ref("account.view_move_form", False)
|
||||||
result = action.read()[0]
|
result = action.read()[0]
|
||||||
invoice_ids = self.mapped("rma_line_ids.invoice_id").ids
|
move_ids = self.mapped("rma_line_ids.move_id").ids
|
||||||
if invoice_ids:
|
if move_ids:
|
||||||
# choose the view_mode accordingly
|
# choose the view_mode accordingly
|
||||||
if len(invoice_ids) > 1:
|
if len(move_ids) > 1:
|
||||||
result["domain"] = [("id", "in", invoice_ids)]
|
result["domain"] = [("id", "in", move_ids)]
|
||||||
else:
|
else:
|
||||||
result["views"] = [(res and res.id or False, "form")]
|
result["views"] = [(res and res.id or False, "form")]
|
||||||
result["res_id"] = invoice_ids[0]
|
result["res_id"] = move_ids[0]
|
||||||
return result
|
return result
|
||||||
|
|||||||
@@ -17,21 +17,20 @@ class RmaOrderLine(models.Model):
|
|||||||
return self.env["res.partner"].browse(partner_id)
|
return self.env["res.partner"].browse(partner_id)
|
||||||
return self.env["res.partner"]
|
return self.env["res.partner"]
|
||||||
|
|
||||||
@api.multi
|
|
||||||
@api.depends(
|
@api.depends(
|
||||||
"refund_line_ids", "refund_line_ids.invoice_id.state", "refund_policy", "type"
|
"refund_line_ids", "refund_line_ids.move_id.state", "refund_policy", "type"
|
||||||
)
|
)
|
||||||
def _compute_qty_refunded(self):
|
def _compute_qty_refunded(self):
|
||||||
for rec in self:
|
for rec in self:
|
||||||
rec.qty_refunded = sum(
|
rec.qty_refunded = sum(
|
||||||
rec.refund_line_ids.filtered(
|
rec.refund_line_ids.filtered(
|
||||||
lambda i: i.invoice_id.state in ("open", "paid")
|
lambda i: i.move_id.state in ("open", "paid")
|
||||||
).mapped("quantity")
|
).mapped("quantity")
|
||||||
)
|
)
|
||||||
|
|
||||||
@api.depends(
|
@api.depends(
|
||||||
"refund_line_ids",
|
"refund_line_ids",
|
||||||
"refund_line_ids.invoice_id.state",
|
"refund_line_ids.move_id.state",
|
||||||
"refund_policy",
|
"refund_policy",
|
||||||
"move_ids",
|
"move_ids",
|
||||||
"move_ids.state",
|
"move_ids.state",
|
||||||
@@ -48,10 +47,9 @@ class RmaOrderLine(models.Model):
|
|||||||
qty = res.qty_delivered - res.qty_refunded
|
qty = res.qty_delivered - res.qty_refunded
|
||||||
res.qty_to_refund = qty
|
res.qty_to_refund = qty
|
||||||
|
|
||||||
@api.multi
|
|
||||||
def _compute_refund_count(self):
|
def _compute_refund_count(self):
|
||||||
for rec in self:
|
for rec in self:
|
||||||
rec.refund_count = len(rec.refund_line_ids.mapped("invoice_id"))
|
rec.refund_count = len(rec.refund_line_ids.mapped("move_id"))
|
||||||
|
|
||||||
invoice_address_id = fields.Many2one(
|
invoice_address_id = fields.Many2one(
|
||||||
"res.partner",
|
"res.partner",
|
||||||
@@ -64,8 +62,8 @@ class RmaOrderLine(models.Model):
|
|||||||
refund_count = fields.Integer(
|
refund_count = fields.Integer(
|
||||||
compute="_compute_refund_count", string="# of Refunds", default=0
|
compute="_compute_refund_count", string="# of Refunds", default=0
|
||||||
)
|
)
|
||||||
invoice_line_id = fields.Many2one(
|
account_move_line_id = fields.Many2one(
|
||||||
comodel_name="account.invoice.line",
|
comodel_name="account.move.line",
|
||||||
string="Originating Invoice Line",
|
string="Originating Invoice Line",
|
||||||
ondelete="restrict",
|
ondelete="restrict",
|
||||||
index=True,
|
index=True,
|
||||||
@@ -73,17 +71,17 @@ class RmaOrderLine(models.Model):
|
|||||||
states={"draft": [("readonly", False)]},
|
states={"draft": [("readonly", False)]},
|
||||||
)
|
)
|
||||||
refund_line_ids = fields.One2many(
|
refund_line_ids = fields.One2many(
|
||||||
comodel_name="account.invoice.line",
|
comodel_name="account.move.line",
|
||||||
inverse_name="rma_line_id",
|
inverse_name="rma_line_id",
|
||||||
string="Refund Lines",
|
string="Refund Lines",
|
||||||
copy=False,
|
copy=False,
|
||||||
index=True,
|
index=True,
|
||||||
readonly=True,
|
readonly=True,
|
||||||
)
|
)
|
||||||
invoice_id = fields.Many2one(
|
move_id = fields.Many2one(
|
||||||
"account.invoice",
|
"account.move",
|
||||||
string="Source",
|
string="Source",
|
||||||
related="invoice_line_id.invoice_id",
|
related="account_move_line_id.move_id",
|
||||||
index=True,
|
index=True,
|
||||||
readonly=True,
|
readonly=True,
|
||||||
)
|
)
|
||||||
@@ -125,15 +123,14 @@ class RmaOrderLine(models.Model):
|
|||||||
res["domain"] = {}
|
res["domain"] = {}
|
||||||
domain = [
|
domain = [
|
||||||
"|",
|
"|",
|
||||||
("invoice_id.partner_id", "=", self.partner_id.id),
|
("move_id.partner_id", "=", self.partner_id.id),
|
||||||
("invoice_id.partner_id", "child_of", self.partner_id.id),
|
("move_id.partner_id", "child_of", self.partner_id.id),
|
||||||
]
|
]
|
||||||
if self.product_id:
|
if self.product_id:
|
||||||
domain.append(("product_id", "=", self.product_id.id))
|
domain.append(("product_id", "=", self.product_id.id))
|
||||||
res["domain"]["invoice_line_id"] = domain
|
res["domain"]["account_move_line_id"] = domain
|
||||||
return res
|
return res
|
||||||
|
|
||||||
@api.multi
|
|
||||||
def _prepare_rma_line_from_inv_line(self, line):
|
def _prepare_rma_line_from_inv_line(self, line):
|
||||||
self.ensure_one()
|
self.ensure_one()
|
||||||
if not self.type:
|
if not self.type:
|
||||||
@@ -173,15 +170,15 @@ class RmaOrderLine(models.Model):
|
|||||||
)
|
)
|
||||||
data = {
|
data = {
|
||||||
"product_id": line.product_id.id,
|
"product_id": line.product_id.id,
|
||||||
"origin": line.invoice_id.number,
|
"origin": line.move_id.name,
|
||||||
"uom_id": line.uom_id.id,
|
"uom_id": line.product_uom_id.id,
|
||||||
"operation_id": operation.id,
|
"operation_id": operation.id,
|
||||||
"product_qty": line.quantity,
|
"product_qty": line.quantity,
|
||||||
"price_unit": line.invoice_id.currency_id.compute(
|
"price_unit": line.move_id.currency_id.compute(
|
||||||
line.price_unit, line.currency_id, round=False
|
line.price_unit, line.currency_id, round=False
|
||||||
),
|
),
|
||||||
"delivery_address_id": line.invoice_id.partner_id.id,
|
"delivery_address_id": line.move_id.partner_id.id,
|
||||||
"invoice_address_id": line.invoice_id.partner_id.id,
|
"invoice_address_id": line.move_id.partner_id.id,
|
||||||
"receipt_policy": operation.receipt_policy,
|
"receipt_policy": operation.receipt_policy,
|
||||||
"refund_policy": operation.refund_policy,
|
"refund_policy": operation.refund_policy,
|
||||||
"delivery_policy": operation.delivery_policy,
|
"delivery_policy": operation.delivery_policy,
|
||||||
@@ -198,21 +195,20 @@ class RmaOrderLine(models.Model):
|
|||||||
}
|
}
|
||||||
return data
|
return data
|
||||||
|
|
||||||
@api.onchange("invoice_line_id")
|
@api.onchange("account_move_line_id")
|
||||||
def _onchange_invoice_line_id(self):
|
def _onchange_account_move_line_id(self):
|
||||||
if not self.invoice_line_id:
|
if not self.account_move_line_id:
|
||||||
return
|
return
|
||||||
data = self._prepare_rma_line_from_inv_line(self.invoice_line_id)
|
data = self._prepare_rma_line_from_inv_line(self.account_move_line_id)
|
||||||
self.update(data)
|
self.update(data)
|
||||||
self._remove_other_data_origin("invoice_line_id")
|
self._remove_other_data_origin("account_move_line_id")
|
||||||
|
|
||||||
@api.multi
|
@api.constrains("account_move_line_id", "partner_id")
|
||||||
@api.constrains("invoice_line_id", "partner_id")
|
|
||||||
def _check_invoice_partner(self):
|
def _check_invoice_partner(self):
|
||||||
for rec in self:
|
for rec in self:
|
||||||
if (
|
if (
|
||||||
rec.invoice_line_id
|
rec.account_move_line_id
|
||||||
and rec.invoice_line_id.invoice_id.partner_id != rec.partner_id
|
and rec.account_move_line_id.move_id.partner_id != rec.partner_id
|
||||||
):
|
):
|
||||||
raise ValidationError(
|
raise ValidationError(
|
||||||
_(
|
_(
|
||||||
@@ -221,11 +217,10 @@ class RmaOrderLine(models.Model):
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
@api.multi
|
|
||||||
def _remove_other_data_origin(self, exception):
|
def _remove_other_data_origin(self, exception):
|
||||||
res = super(RmaOrderLine, self)._remove_other_data_origin(exception)
|
res = super(RmaOrderLine, self)._remove_other_data_origin(exception)
|
||||||
if not exception == "invoice_line_id":
|
if not exception == "account_move_line_id":
|
||||||
self.invoice_line_id = False
|
self.account_move_line_id = False
|
||||||
return res
|
return res
|
||||||
|
|
||||||
@api.onchange("operation_id")
|
@api.onchange("operation_id")
|
||||||
@@ -235,49 +230,45 @@ class RmaOrderLine(models.Model):
|
|||||||
self.refund_policy = self.operation_id.refund_policy or "no"
|
self.refund_policy = self.operation_id.refund_policy or "no"
|
||||||
return result
|
return result
|
||||||
|
|
||||||
@api.multi
|
@api.constrains("account_move_line_id")
|
||||||
@api.constrains("invoice_line_id")
|
|
||||||
def _check_duplicated_lines(self):
|
def _check_duplicated_lines(self):
|
||||||
for line in self:
|
for line in self:
|
||||||
matching_inv_lines = self.env["account.invoice.line"].search(
|
matching_inv_lines = self.env["account.move.line"].search(
|
||||||
[("id", "=", line.invoice_line_id.id)]
|
[("id", "=", line.account_move_line_id.id)]
|
||||||
)
|
)
|
||||||
if len(matching_inv_lines) > 1:
|
if len(matching_inv_lines) > 1:
|
||||||
raise UserError(
|
raise UserError(
|
||||||
_(
|
_(
|
||||||
"There's an rma for the invoice line %s "
|
"There's an rma for the invoice line %s "
|
||||||
"and invoice %s"
|
"and invoice %s"
|
||||||
% (line.invoice_line_id, line.invoice_line_id.invoice_id)
|
% (line.account_move_line_id, line.account_move_line_id.move_id)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
@api.multi
|
|
||||||
def action_view_invoice(self):
|
def action_view_invoice(self):
|
||||||
action = self.env.ref("account.action_invoice_tree")
|
action = self.env.ref("account.action_invoice_tree")
|
||||||
result = action.read()[0]
|
result = action.read()[0]
|
||||||
res = self.env.ref("account.invoice_form", False)
|
res = self.env.ref("account.view_move_form", False)
|
||||||
result["views"] = [(res and res.id or False, "form")]
|
result["views"] = [(res and res.id or False, "form")]
|
||||||
result["view_id"] = res and res.id or False
|
result["view_id"] = res and res.id or False
|
||||||
result["res_id"] = self.invoice_line_id.invoice_id.id
|
result["res_id"] = self.account_move_line_id.move_id.id
|
||||||
return result
|
return result
|
||||||
|
|
||||||
@api.multi
|
|
||||||
def action_view_refunds(self):
|
def action_view_refunds(self):
|
||||||
action = self.env.ref("account.action_invoice_tree2")
|
action = self.env.ref("account.action_invoice_tree2")
|
||||||
result = action.read()[0]
|
result = action.read()[0]
|
||||||
invoice_ids = self.mapped("refund_line_ids.invoice_id").ids
|
move_ids = self.mapped("refund_line_ids.move_id").ids
|
||||||
if invoice_ids:
|
if move_ids:
|
||||||
# choose the view_mode accordingly
|
# choose the view_mode accordingly
|
||||||
if len(invoice_ids) > 1:
|
if len(move_ids) > 1:
|
||||||
result["domain"] = [("id", "in", invoice_ids)]
|
result["domain"] = [("id", "in", move_ids)]
|
||||||
else:
|
else:
|
||||||
res = self.env.ref("account.invoice_supplier_form", False)
|
res = self.env.ref("account.move_supplier_form", False)
|
||||||
result["views"] = [(res and res.id or False, "form")]
|
result["views"] = [(res and res.id or False, "form")]
|
||||||
result["res_id"] = invoice_ids[0]
|
result["res_id"] = move_ids[0]
|
||||||
return result
|
return result
|
||||||
|
|
||||||
@api.multi
|
|
||||||
def name_get(self):
|
def name_get(self):
|
||||||
res = []
|
res = []
|
||||||
if self.env.context.get("rma"):
|
if self.env.context.get("rma"):
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
|
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
|
||||||
access_account_invoice_customer_user,access_account_invoice,account.model_account_invoice,rma.group_rma_customer_user,1,0,0,0
|
access_account_move_customer_user,access_account_move,account.model_account_move,rma.group_rma_customer_user,1,0,0,0
|
||||||
access_account_invoice_supplier_user,access_account_invoice,account.model_account_invoice,rma.group_rma_supplier_user,1,0,0,0
|
access_account_move_supplier_user,access_account_move,account.model_account_move,rma.group_rma_supplier_user,1,0,0,0
|
||||||
|
access_account_move_line_customer_user,access_account_move_line,account.model_account_move_line,rma.group_rma_customer_user,1,0,0,0
|
||||||
|
access_account_move_line_supplier_user,access_account_move_line,account.model_account_move_line,rma.group_rma_supplier_user,1,0,0,0
|
||||||
|
|||||||
|
@@ -15,8 +15,8 @@ class TestRmaAccount(common.SingleTransactionCase):
|
|||||||
cls.rma_add_invoice_wiz = cls.env["rma_add_invoice"]
|
cls.rma_add_invoice_wiz = cls.env["rma_add_invoice"]
|
||||||
cls.rma_refund_wiz = cls.env["rma.refund"]
|
cls.rma_refund_wiz = cls.env["rma.refund"]
|
||||||
cls.acc_obj = cls.env["account.account"]
|
cls.acc_obj = cls.env["account.account"]
|
||||||
cls.inv_obj = cls.env["account.invoice"]
|
cls.inv_obj = cls.env["account.move"]
|
||||||
cls.invl_obj = cls.env["account.invoice.line"]
|
cls.invl_obj = cls.env["account.move.line"]
|
||||||
cls.product_obj = cls.env["product.product"]
|
cls.product_obj = cls.env["product.product"]
|
||||||
cls.partner_obj = cls.env["res.partner"]
|
cls.partner_obj = cls.env["res.partner"]
|
||||||
|
|
||||||
@@ -89,7 +89,7 @@ class TestRmaAccount(common.SingleTransactionCase):
|
|||||||
"product_id": cls.product_1.id,
|
"product_id": cls.product_1.id,
|
||||||
"quantity": 12.0,
|
"quantity": 12.0,
|
||||||
"price_unit": 100.0,
|
"price_unit": 100.0,
|
||||||
"invoice_id": cls.inv_customer.id,
|
"move_id": cls.inv_customer.id,
|
||||||
"uom_id": cls.product_1.uom_id.id,
|
"uom_id": cls.product_1.uom_id.id,
|
||||||
"account_id": customer_account,
|
"account_id": customer_account,
|
||||||
}
|
}
|
||||||
@@ -100,7 +100,7 @@ class TestRmaAccount(common.SingleTransactionCase):
|
|||||||
"product_id": cls.product_2.id,
|
"product_id": cls.product_2.id,
|
||||||
"quantity": 15.0,
|
"quantity": 15.0,
|
||||||
"price_unit": 150.0,
|
"price_unit": 150.0,
|
||||||
"invoice_id": cls.inv_customer.id,
|
"move_id": cls.inv_customer.id,
|
||||||
"uom_id": cls.product_2.uom_id.id,
|
"uom_id": cls.product_2.uom_id.id,
|
||||||
"account_id": customer_account,
|
"account_id": customer_account,
|
||||||
}
|
}
|
||||||
@@ -122,7 +122,7 @@ class TestRmaAccount(common.SingleTransactionCase):
|
|||||||
"product_id": cls.product_3.id,
|
"product_id": cls.product_3.id,
|
||||||
"quantity": 17.0,
|
"quantity": 17.0,
|
||||||
"price_unit": 250.0,
|
"price_unit": 250.0,
|
||||||
"invoice_id": cls.inv_supplier.id,
|
"move_id": cls.inv_supplier.id,
|
||||||
"uom_id": cls.product_3.uom_id.id,
|
"uom_id": cls.product_3.uom_id.id,
|
||||||
"account_id": supplier_account,
|
"account_id": supplier_account,
|
||||||
}
|
}
|
||||||
@@ -133,7 +133,7 @@ class TestRmaAccount(common.SingleTransactionCase):
|
|||||||
"product_id": cls.product_4.id,
|
"product_id": cls.product_4.id,
|
||||||
"quantity": 9.0,
|
"quantity": 9.0,
|
||||||
"price_unit": 300.0,
|
"price_unit": 300.0,
|
||||||
"invoice_id": cls.inv_supplier.id,
|
"move_id": cls.inv_supplier.id,
|
||||||
"uom_id": cls.product_4.uom_id.id,
|
"uom_id": cls.product_4.uom_id.id,
|
||||||
"account_id": supplier_account,
|
"account_id": supplier_account,
|
||||||
}
|
}
|
||||||
@@ -147,7 +147,7 @@ class TestRmaAccount(common.SingleTransactionCase):
|
|||||||
"active_ids": self.rma_group_customer.id,
|
"active_ids": self.rma_group_customer.id,
|
||||||
"active_model": "rma.order",
|
"active_model": "rma.order",
|
||||||
}
|
}
|
||||||
).create({"invoice_line_ids": [(6, 0, self.inv_customer.invoice_line_ids.ids)]})
|
).create({"line_ids": [(6, 0, self.inv_customer.line_ids.ids)]})
|
||||||
add_inv.add_lines()
|
add_inv.add_lines()
|
||||||
self.assertEqual(len(self.rma_group_customer.rma_line_ids), 2)
|
self.assertEqual(len(self.rma_group_customer.rma_line_ids), 2)
|
||||||
for t in self.rma_group_supplier.rma_line_ids.mapped("type"):
|
for t in self.rma_group_supplier.rma_line_ids.mapped("type"):
|
||||||
@@ -169,7 +169,7 @@ class TestRmaAccount(common.SingleTransactionCase):
|
|||||||
"active_ids": self.rma_group_supplier.id,
|
"active_ids": self.rma_group_supplier.id,
|
||||||
"active_model": "rma.order",
|
"active_model": "rma.order",
|
||||||
}
|
}
|
||||||
).create({"invoice_line_ids": [(6, 0, self.inv_supplier.invoice_line_ids.ids)]})
|
).create({"line_ids": [(6, 0, self.inv_supplier.line_ids.ids)]})
|
||||||
add_inv.add_lines()
|
add_inv.add_lines()
|
||||||
self.assertEqual(len(self.rma_group_supplier.rma_line_ids), 2)
|
self.assertEqual(len(self.rma_group_supplier.rma_line_ids), 2)
|
||||||
for t in self.rma_group_supplier.rma_line_ids.mapped("type"):
|
for t in self.rma_group_supplier.rma_line_ids.mapped("type"):
|
||||||
@@ -206,7 +206,7 @@ class TestRmaAccount(common.SingleTransactionCase):
|
|||||||
{"customer": True, "active_ids": rma.ids, "active_model": "rma.order.line"}
|
{"customer": True, "active_ids": rma.ids, "active_model": "rma.order.line"}
|
||||||
).create({"description": "Test refund"})
|
).create({"description": "Test refund"})
|
||||||
make_refund.invoice_refund()
|
make_refund.invoice_refund()
|
||||||
rma.refund_line_ids.invoice_id.action_invoice_open()
|
rma.refund_line_ids.move_id.action_invoice_open()
|
||||||
rma._compute_refund_count()
|
rma._compute_refund_count()
|
||||||
self.assertEqual(rma.refund_count, 1)
|
self.assertEqual(rma.refund_count, 1)
|
||||||
self.assertEqual(rma.qty_to_refund, 0.0)
|
self.assertEqual(rma.qty_to_refund, 0.0)
|
||||||
@@ -217,10 +217,10 @@ class TestRmaAccount(common.SingleTransactionCase):
|
|||||||
rma = self.rma_line_obj.new(
|
rma = self.rma_line_obj.new(
|
||||||
{
|
{
|
||||||
"partner_id": self.inv_customer.partner_id.id,
|
"partner_id": self.inv_customer.partner_id.id,
|
||||||
"invoice_line_id": self.inv_line_1.id,
|
"account_move_line_id": self.inv_line_1.id,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
self.assertFalse(rma.product_id)
|
self.assertFalse(rma.product_id)
|
||||||
rma._onchange_invoice_line_id()
|
rma._onchange_account_move_line_id()
|
||||||
self.assertEqual(rma.product_id, self.product_1)
|
self.assertEqual(rma.product_id, self.product_1)
|
||||||
self.assertEqual(rma.product_qty, 12.0)
|
self.assertEqual(rma.product_qty, 12.0)
|
||||||
|
|||||||
69
rma_account/views/account_move_view.xml
Normal file
69
rma_account/views/account_move_view.xml
Normal file
@@ -0,0 +1,69 @@
|
|||||||
|
<?xml version="1.0"?>
|
||||||
|
<odoo>
|
||||||
|
<record id="invoice_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">
|
||||||
|
<field name="name" position="before">
|
||||||
|
<div class="oe_button_box" attrs="{'invisible': [('rma_count', '=', 0)]}">
|
||||||
|
<button type="object" name="action_view_rma_customer"
|
||||||
|
class="oe_stat_button"
|
||||||
|
icon="fa-eject"
|
||||||
|
groups="rma.group_rma_customer_user,rma.group_rma_supplier_user">
|
||||||
|
<field name="rma_count" widget="statinfo"
|
||||||
|
string="RMA"/>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</field>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
|
||||||
|
<record id="view_invoice_line_form" model="ir.ui.view">
|
||||||
|
<field name="name">rma.invoice.line.form</field>
|
||||||
|
<field name="model">account.move.line</field>
|
||||||
|
<field name="inherit_id" ref="account.view_move_line_form"/>
|
||||||
|
<field eval="16" name="priority"/>
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<data>
|
||||||
|
<field name="name" position="after">
|
||||||
|
<field name="rma_line_count" invisible="1"/>
|
||||||
|
<field name="rma_line_id"
|
||||||
|
string="RMA line originated"/>
|
||||||
|
<notebook attrs="{'invisible': [('rma_line_count', '=', 0)]}">
|
||||||
|
<page string="RMA Lines">
|
||||||
|
<field name="rma_line_ids"/>
|
||||||
|
</page>
|
||||||
|
</notebook>
|
||||||
|
</field>
|
||||||
|
</data>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
|
||||||
|
<record id="view_invoice_customer_rma_form" model="ir.ui.view">
|
||||||
|
<field name="name">account.move.customer.rma</field>
|
||||||
|
<field name="model">account.move</field>
|
||||||
|
<field name="inherit_id" ref="account.view_move_form"/>
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<field name="invoice_vendor_bill_id" position="after">
|
||||||
|
<field name="add_rma_line_id"
|
||||||
|
context="{'rma': True}"
|
||||||
|
domain="[('type', '=', 'customer'),
|
||||||
|
('partner_id', '=', partner_id)]"
|
||||||
|
attrs="{'readonly': [('state','not in',['draft'])],
|
||||||
|
'invisible': ['|', ('state', '=', 'paid'),
|
||||||
|
('type', '=', 'in_invoice')]}" class="oe_edit_only"
|
||||||
|
options="{'no_create': True}"/>
|
||||||
|
</field>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<record id="action_invoice_line" model="ir.actions.act_window">
|
||||||
|
<field name="name">Invoice Line</field>
|
||||||
|
<field name="res_model">account.move.line</field>
|
||||||
|
<field name="view_mode">form</field>
|
||||||
|
<field name="view_id" ref="account.view_move_line_form"/>
|
||||||
|
</record>
|
||||||
|
</odoo>
|
||||||
@@ -1,105 +0,0 @@
|
|||||||
<?xml version="1.0"?>
|
|
||||||
<odoo>
|
|
||||||
<record id="invoice_form" model="ir.ui.view">
|
|
||||||
<field name="name">account.invoice.form</field>
|
|
||||||
<field name="model">account.invoice</field>
|
|
||||||
<field name="inherit_id" ref="account.invoice_form"/>
|
|
||||||
<field name="arch" type="xml">
|
|
||||||
<field name="number" position="before">
|
|
||||||
<div class="oe_button_box" attrs="{'invisible': [('rma_count', '=', 0)]}">
|
|
||||||
<button type="object" name="action_view_rma_customer"
|
|
||||||
class="oe_stat_button"
|
|
||||||
icon="fa-eject"
|
|
||||||
groups="rma.group_rma_customer_user,rma.group_rma_supplier_user">
|
|
||||||
<field name="rma_count" widget="statinfo"
|
|
||||||
string="RMA"/>
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</field>
|
|
||||||
</field>
|
|
||||||
</record>
|
|
||||||
|
|
||||||
<record id="invoice_supplier_form" model="ir.ui.view">
|
|
||||||
<field name="name">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">
|
|
||||||
<field name="number" position="before">
|
|
||||||
<div class="oe_button_box" attrs="{'invisible': [('rma_count', '=', 0)]}">
|
|
||||||
<button type="object" name="action_view_rma_supplier"
|
|
||||||
class="oe_stat_button"
|
|
||||||
icon="fa-eject"
|
|
||||||
groups="rma.group_rma_customer_user,rma.group_rma_supplier_user">
|
|
||||||
<field name="rma_count" widget="statinfo"
|
|
||||||
string="RMA"/>
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</field>
|
|
||||||
</field>
|
|
||||||
</record>
|
|
||||||
|
|
||||||
<record id="view_invoice_line_form" model="ir.ui.view">
|
|
||||||
<field name="name">rma.invoice.line.form</field>
|
|
||||||
<field name="model">account.invoice.line</field>
|
|
||||||
<field name="inherit_id" ref="account.view_invoice_line_form"/>
|
|
||||||
<field eval="16" name="priority"/>
|
|
||||||
<field name="arch" type="xml">
|
|
||||||
<data>
|
|
||||||
<field name="name" position="after">
|
|
||||||
<field name="rma_line_count" invisible="1"/>
|
|
||||||
<field name="rma_line_id"
|
|
||||||
string="RMA line originated"/>
|
|
||||||
<notebook attrs="{'invisible': [('rma_line_count', '=', 0)]}">
|
|
||||||
<page string="RMA Lines">
|
|
||||||
<field name="rma_line_ids"/>
|
|
||||||
</page>
|
|
||||||
</notebook>
|
|
||||||
</field>
|
|
||||||
</data>
|
|
||||||
</field>
|
|
||||||
</record>
|
|
||||||
|
|
||||||
<record id="view_invoice_supplier_rma_form" model="ir.ui.view">
|
|
||||||
<field name="name">account.invoice.supplier.rma</field>
|
|
||||||
<field name="model">account.invoice</field>
|
|
||||||
<field name="inherit_id" ref="account.invoice_supplier_form"/>
|
|
||||||
<field name="arch" type="xml">
|
|
||||||
<field name="reference" position="after">
|
|
||||||
<field name="add_rma_line_id"
|
|
||||||
context="{'rma': True}"
|
|
||||||
domain="[('type', '=', 'supplier'),
|
|
||||||
('partner_id', '=', partner_id)]"
|
|
||||||
attrs="{'readonly': [('state','not in',['draft'])],
|
|
||||||
'invisible': ['|', ('state', '=', 'paid'),
|
|
||||||
('type', '=', 'out_invoice')]}" class="oe_edit_only"
|
|
||||||
options="{'no_create': True}"/>
|
|
||||||
</field>
|
|
||||||
</field>
|
|
||||||
</record>
|
|
||||||
|
|
||||||
<record id="view_invoice_customer_rma_form" model="ir.ui.view">
|
|
||||||
<field name="name">account.invoice.customer.rma</field>
|
|
||||||
<field name="model">account.invoice</field>
|
|
||||||
<field name="inherit_id" ref="account.invoice_form"/>
|
|
||||||
<field name="arch" type="xml">
|
|
||||||
<field name="payment_term_id" position="after">
|
|
||||||
<field name="add_rma_line_id"
|
|
||||||
context="{'rma': True}"
|
|
||||||
domain="[('type', '=', 'customer'),
|
|
||||||
('partner_id', '=', partner_id)]"
|
|
||||||
attrs="{'readonly': [('state','not in',['draft'])],
|
|
||||||
'invisible': ['|', ('state', '=', 'paid'),
|
|
||||||
('type', '=', 'in_invoice')]}" class="oe_edit_only"
|
|
||||||
options="{'no_create': True}"/>
|
|
||||||
</field>
|
|
||||||
</field>
|
|
||||||
</record>
|
|
||||||
|
|
||||||
<record id="action_invoice_line" model="ir.actions.act_window">
|
|
||||||
<field name="name">Invoice Line</field>
|
|
||||||
<field name="res_model">account.invoice.line</field>
|
|
||||||
<field name="view_type">form</field>
|
|
||||||
<field name="view_mode">form</field>
|
|
||||||
<field name="view_id" ref="account.view_invoice_line_form"/>
|
|
||||||
</record>
|
|
||||||
</odoo>
|
|
||||||
@@ -8,7 +8,6 @@
|
|||||||
<field name="res_model">rma.order.line</field>
|
<field name="res_model">rma.order.line</field>
|
||||||
<field name="domain">[('type','=', 'customer')]</field>
|
<field name="domain">[('type','=', 'customer')]</field>
|
||||||
<field name="context">{"search_default_to_refund":1}</field>
|
<field name="context">{"search_default_to_refund":1}</field>
|
||||||
<field name="view_type">form</field>
|
|
||||||
<field name="view_mode">tree,form</field>
|
<field name="view_mode">tree,form</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
@@ -17,11 +16,32 @@
|
|||||||
<field name="res_model">rma.order.line</field>
|
<field name="res_model">rma.order.line</field>
|
||||||
<field name="domain">[('type','=', 'supplier')]</field>
|
<field name="domain">[('type','=', 'supplier')]</field>
|
||||||
<field name="context">{"search_default_to_refund":1, "supplier":1}</field>
|
<field name="context">{"search_default_to_refund":1, "supplier":1}</field>
|
||||||
<field name="view_type">form</field>
|
|
||||||
<field name="view_mode">tree,form</field>
|
<field name="view_mode">tree,form</field>
|
||||||
<field name="view_id" ref="rma.view_rma_line_supplier_tree"/>
|
<field name="view_id" ref="rma.view_rma_line_supplier_tree"/>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
|
<!-- Accountants menu RMA -->
|
||||||
|
<menuitem id="menu_rma_account"
|
||||||
|
name="Accounting"
|
||||||
|
groups="account.group_account_user"
|
||||||
|
sequence="32"
|
||||||
|
parent="rma.menu_rma_root"/>
|
||||||
|
|
||||||
|
<menuitem id="menu_rma_customer_refunds"
|
||||||
|
name="Customer RMA to Refund"
|
||||||
|
sequence="20"
|
||||||
|
parent="rma_account.menu_rma_account"
|
||||||
|
groups="rma.group_rma_customer_user"
|
||||||
|
action="action_rma_account_customer_lines"/>
|
||||||
|
|
||||||
|
<menuitem id="menu_rma_line_supplier_refunds"
|
||||||
|
name="Supplier RMA to Refund"
|
||||||
|
sequence="20"
|
||||||
|
parent="rma_account.menu_rma_account"
|
||||||
|
groups="rma.group_rma_customer_user"
|
||||||
|
action="action_rma_supplier_lines"/>
|
||||||
|
|
||||||
|
|
||||||
<menuitem id="menu_rma_line_account_customer"
|
<menuitem id="menu_rma_line_account_customer"
|
||||||
name="Customer RMA to Refund"
|
name="Customer RMA to Refund"
|
||||||
sequence="20"
|
sequence="20"
|
||||||
|
|||||||
@@ -6,7 +6,12 @@
|
|||||||
<field name="inherit_id" ref="rma.view_rma_line_supplier_form"/>
|
<field name="inherit_id" ref="rma.view_rma_line_supplier_form"/>
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<button name="action_view_out_shipments" position="after">
|
<button name="action_view_out_shipments" position="after">
|
||||||
<button type="object" name="action_view_refunds"
|
<button type="object" name="action_view_invoice"
|
||||||
|
class="oe_stat_button"
|
||||||
|
icon="fa-pencil-square-o"
|
||||||
|
string="Origin Inv">
|
||||||
|
</button>
|
||||||
|
<button type="object" name="action_view_refunds"
|
||||||
class="oe_stat_button"
|
class="oe_stat_button"
|
||||||
icon="fa-pencil-square-o"
|
icon="fa-pencil-square-o"
|
||||||
groups="account.group_account_user">
|
groups="account.group_account_user">
|
||||||
@@ -15,12 +20,12 @@
|
|||||||
</button>
|
</button>
|
||||||
</button>
|
</button>
|
||||||
<group name="main_info" position="inside">
|
<group name="main_info" position="inside">
|
||||||
<field name="invoice_line_id"
|
<field name="account_move_line_id"
|
||||||
options="{'no_create': True}"
|
options="{'no_create': True}"
|
||||||
context="{'rma': True}"
|
context="{'rma': True}"
|
||||||
domain="['|',
|
domain="['|',
|
||||||
('invoice_id.partner_id', '=', partner_id),
|
('move_id.partner_id', '=', partner_id),
|
||||||
('invoice_id.partner_id', 'child_of', partner_id)]"/>
|
('move_id.partner_id', 'child_of', partner_id)]"/>
|
||||||
</group>
|
</group>
|
||||||
<field name="operation_id" position="after">
|
<field name="operation_id" position="after">
|
||||||
<field name="refund_policy"/>
|
<field name="refund_policy"/>
|
||||||
@@ -49,6 +54,11 @@
|
|||||||
<field name="inherit_id" ref="rma.view_rma_line_form"/>
|
<field name="inherit_id" ref="rma.view_rma_line_form"/>
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<button name="action_view_out_shipments" position="after">
|
<button name="action_view_out_shipments" position="after">
|
||||||
|
<button type="object" name="action_view_invoice"
|
||||||
|
class="oe_stat_button"
|
||||||
|
icon="fa-pencil-square-o"
|
||||||
|
string="Origin Inv">
|
||||||
|
</button>
|
||||||
<button type="object" name="action_view_refunds"
|
<button type="object" name="action_view_refunds"
|
||||||
class="oe_stat_button"
|
class="oe_stat_button"
|
||||||
icon="fa-pencil-square-o"
|
icon="fa-pencil-square-o"
|
||||||
@@ -58,12 +68,12 @@
|
|||||||
</button>
|
</button>
|
||||||
</button>
|
</button>
|
||||||
<group name="main_info" position="inside">
|
<group name="main_info" position="inside">
|
||||||
<field name="invoice_line_id"
|
<field name="account_move_line_id"
|
||||||
options="{'no_create': True}"
|
options="{'no_create': True}"
|
||||||
context="{'rma': True}"
|
context="{'rma': True}"
|
||||||
domain="['|',
|
domain="['|',
|
||||||
('invoice_id.partner_id', '=', partner_id),
|
('move_id.partner_id', '=', partner_id),
|
||||||
('invoice_id.partner_id', 'child_of', partner_id)]"/>
|
('move_id.partner_id', 'child_of', partner_id)]"/>
|
||||||
</group>
|
</group>
|
||||||
<field name="operation_id" position="after">
|
<field name="operation_id" position="after">
|
||||||
<field name="refund_policy"/>
|
<field name="refund_policy"/>
|
||||||
|
|||||||
@@ -25,7 +25,7 @@
|
|||||||
<!--
|
<!--
|
||||||
<xpath expr="//field[@name='rma_line_ids']/tree/field[@name='price_unit']"
|
<xpath expr="//field[@name='rma_line_ids']/tree/field[@name='price_unit']"
|
||||||
position="after">
|
position="after">
|
||||||
<field name="invoice_line_id" invisible="True"/>
|
<field name="account_move_line_id" invisible="True"/>
|
||||||
</xpath>
|
</xpath>
|
||||||
-->
|
-->
|
||||||
</field>
|
</field>
|
||||||
@@ -56,7 +56,7 @@
|
|||||||
<!--
|
<!--
|
||||||
<xpath expr="//field[@name='rma_line_ids']/tree"
|
<xpath expr="//field[@name='rma_line_ids']/tree"
|
||||||
position="inside">
|
position="inside">
|
||||||
<field name="invoice_line_id" invisible="True"/>
|
<field name="account_move_line_id" invisible="True"/>
|
||||||
</xpath>
|
</xpath>
|
||||||
-->
|
-->
|
||||||
</field>
|
</field>
|
||||||
|
|||||||
@@ -2,5 +2,5 @@
|
|||||||
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html)
|
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html)
|
||||||
|
|
||||||
from . import rma_refund
|
from . import rma_refund
|
||||||
from . import rma_add_invoice
|
from . import rma_add_account_move
|
||||||
from . import rma_order_line_make_supplier_rma
|
from . import rma_order_line_make_supplier_rma
|
||||||
|
|||||||
@@ -5,8 +5,8 @@ from odoo import _, api, fields, models
|
|||||||
from odoo.exceptions import ValidationError
|
from odoo.exceptions import ValidationError
|
||||||
|
|
||||||
|
|
||||||
class RmaAddInvoice(models.TransientModel):
|
class RmaAddAccountMove(models.TransientModel):
|
||||||
_name = "rma_add_invoice"
|
_name = "rma_add_account_move"
|
||||||
_description = "Wizard to add rma lines"
|
_description = "Wizard to add rma lines"
|
||||||
|
|
||||||
@api.model
|
@api.model
|
||||||
@@ -21,7 +21,7 @@ class RmaAddInvoice(models.TransientModel):
|
|||||||
rma = rma_obj.browse(rma_id)
|
rma = rma_obj.browse(rma_id)
|
||||||
res["rma_id"] = rma.id
|
res["rma_id"] = rma.id
|
||||||
res["partner_id"] = rma.partner_id.id
|
res["partner_id"] = rma.partner_id.id
|
||||||
res["invoice_line_ids"] = False
|
res["line_ids"] = False
|
||||||
return res
|
return res
|
||||||
|
|
||||||
rma_id = fields.Many2one(
|
rma_id = fields.Many2one(
|
||||||
@@ -30,11 +30,11 @@ class RmaAddInvoice(models.TransientModel):
|
|||||||
partner_id = fields.Many2one(
|
partner_id = fields.Many2one(
|
||||||
comodel_name="res.partner", string="Partner", readonly=True
|
comodel_name="res.partner", string="Partner", readonly=True
|
||||||
)
|
)
|
||||||
invoice_line_ids = fields.Many2many(
|
line_ids = fields.Many2many(
|
||||||
"account.invoice.line",
|
"account.move.line",
|
||||||
"rma_add_invoice_add_line_rel",
|
"rma_add_account_move_add_line_rel",
|
||||||
"invoice_line_id",
|
"account_move_line_id",
|
||||||
"rma_add_invoice_id",
|
"rma_add_move_id",
|
||||||
string="Invoice Lines",
|
string="Invoice Lines",
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -76,17 +76,17 @@ class RmaAddInvoice(models.TransientModel):
|
|||||||
)
|
)
|
||||||
data = {
|
data = {
|
||||||
"partner_id": self.partner_id.id,
|
"partner_id": self.partner_id.id,
|
||||||
"invoice_line_id": line.id,
|
"account_move_line_id": line.id,
|
||||||
"product_id": line.product_id.id,
|
"product_id": line.product_id.id,
|
||||||
"origin": line.invoice_id.number,
|
"origin": line.move_id.name,
|
||||||
"uom_id": line.uom_id.id,
|
"uom_id": line.product_uom_id.id,
|
||||||
"operation_id": operation.id,
|
"operation_id": operation.id,
|
||||||
"product_qty": line.quantity,
|
"product_qty": line.quantity,
|
||||||
"price_unit": line.invoice_id.currency_id.compute(
|
"price_unit": line.move_id.currency_id.compute(
|
||||||
line.price_unit, line.currency_id, round=False
|
line.price_unit, line.currency_id, round=False
|
||||||
),
|
),
|
||||||
"delivery_address_id": line.invoice_id.partner_id.id,
|
"delivery_address_id": line.move_id.partner_id.id,
|
||||||
"invoice_address_id": line.invoice_id.partner_id.id,
|
"invoice_address_id": line.move_id.partner_id.id,
|
||||||
"rma_id": self.rma_id.id,
|
"rma_id": self.rma_id.id,
|
||||||
"receipt_policy": operation.receipt_policy,
|
"receipt_policy": operation.receipt_policy,
|
||||||
"refund_policy": operation.refund_policy,
|
"refund_policy": operation.refund_policy,
|
||||||
@@ -112,14 +112,13 @@ class RmaAddInvoice(models.TransientModel):
|
|||||||
def _get_existing_invoice_lines(self):
|
def _get_existing_invoice_lines(self):
|
||||||
existing_invoice_lines = []
|
existing_invoice_lines = []
|
||||||
for rma_line in self.rma_id.rma_line_ids:
|
for rma_line in self.rma_id.rma_line_ids:
|
||||||
existing_invoice_lines.append(rma_line.invoice_line_id)
|
existing_invoice_lines.append(rma_line.account_move_line_id)
|
||||||
return existing_invoice_lines
|
return existing_invoice_lines
|
||||||
|
|
||||||
@api.multi
|
|
||||||
def add_lines(self):
|
def add_lines(self):
|
||||||
rma_line_obj = self.env["rma.order.line"]
|
rma_line_obj = self.env["rma.order.line"]
|
||||||
existing_invoice_lines = self._get_existing_invoice_lines()
|
existing_invoice_lines = self._get_existing_invoice_lines()
|
||||||
for line in self.invoice_line_ids:
|
for line in self.line_ids:
|
||||||
# Load a PO line only once
|
# Load a PO line only once
|
||||||
if line not in existing_invoice_lines:
|
if line not in existing_invoice_lines:
|
||||||
data = self._prepare_rma_line_from_inv_line(line)
|
data = self._prepare_rma_line_from_inv_line(line)
|
||||||
@@ -2,9 +2,9 @@
|
|||||||
|
|
||||||
<odoo>
|
<odoo>
|
||||||
|
|
||||||
<record id="view_rma_add_invoice" model="ir.ui.view">
|
<record id="view_rma_add_account_move" model="ir.ui.view">
|
||||||
<field name="name">rma.add.invoice</field>
|
<field name="name">rma.add.invoice</field>
|
||||||
<field name="model">rma_add_invoice</field>
|
<field name="model">rma_add_account_move</field>
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<form string="Select Invoice from customer">
|
<form string="Select Invoice from customer">
|
||||||
<group>
|
<group>
|
||||||
@@ -13,15 +13,16 @@
|
|||||||
string="Customer"/>
|
string="Customer"/>
|
||||||
</group>
|
</group>
|
||||||
<separator string="Select Invoices lines to add"/>
|
<separator string="Select Invoices lines to add"/>
|
||||||
<field name="invoice_line_ids"
|
<field name="line_ids"
|
||||||
domain="[('invoice_id.partner_id', '=', partner_id),
|
domain="[('move_id.partner_id', '=', partner_id),
|
||||||
('invoice_id.type', '=', 'out_invoice')]">
|
('move_id.type', '=', 'out_invoice')]">
|
||||||
<tree string="Invoice Lines">
|
<tree string="Invoice Lines">
|
||||||
<field name="invoice_id"/>
|
<field name="move_id"/>
|
||||||
<field name="name"/>
|
<field name="name"/>
|
||||||
<field name="account_id" groups="account.group_account_user"/>
|
<field name="account_id" groups="account.group_account_user"/>
|
||||||
<field name="quantity"/>
|
<field name="quantity"/>
|
||||||
<field name="uom_id" groups="uom.group_uom"/>
|
<field name="product_id"/>
|
||||||
|
<field name="product_uom_id"/>
|
||||||
<field name="price_unit"/>
|
<field name="price_unit"/>
|
||||||
<field name="discount" groups="base.group_no_one"/>
|
<field name="discount" groups="base.group_no_one"/>
|
||||||
<field name="price_subtotal"/>
|
<field name="price_subtotal"/>
|
||||||
@@ -41,9 +42,9 @@
|
|||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
<record id="view_rma_add_invoice_supplier" model="ir.ui.view">
|
<record id="view_rma_add_account_move_supplier" model="ir.ui.view">
|
||||||
<field name="name">rma.add.invoice.supplier</field>
|
<field name="name">rma.add.invoice.supplier</field>
|
||||||
<field name="model">rma_add_invoice</field>
|
<field name="model">rma_add_account_move</field>
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<form string="Select Invoice from supplier">
|
<form string="Select Invoice from supplier">
|
||||||
<group>
|
<group>
|
||||||
@@ -52,15 +53,16 @@
|
|||||||
string="Supplier"/>
|
string="Supplier"/>
|
||||||
</group>
|
</group>
|
||||||
<separator string="Select Invoices lines to add"/>
|
<separator string="Select Invoices lines to add"/>
|
||||||
<field name="invoice_line_ids"
|
<field name="line_ids"
|
||||||
domain="[('invoice_id.partner_id', '=', partner_id),
|
domain="[('move_id.partner_id', '=', partner_id),
|
||||||
('invoice_id.type', '=', 'in_invoice')]">
|
('move_id.type', '=', 'in_invoice')]">
|
||||||
<tree string="Invoice Lines">
|
<tree string="Invoice Lines">
|
||||||
<field name="invoice_id"/>
|
<field name="move_id"/>
|
||||||
<field name="name"/>
|
<field name="name"/>
|
||||||
<field name="account_id" groups="account.group_account_user"/>
|
<field name="account_id" groups="account.group_account_user"/>
|
||||||
<field name="quantity"/>
|
<field name="quantity"/>
|
||||||
<field name="uom_id" groups="uom.group_uom"/>
|
<field name="product_id"/>
|
||||||
|
<field name="product_uom_id"/>
|
||||||
<field name="price_unit"/>
|
<field name="price_unit"/>
|
||||||
<field name="discount" groups="base.group_no_one"/>
|
<field name="discount" groups="base.group_no_one"/>
|
||||||
<field name="price_subtotal"/>
|
<field name="price_subtotal"/>
|
||||||
@@ -80,50 +82,47 @@
|
|||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
<record id="action_rma_add_invoice" model="ir.actions.act_window">
|
<record id="action_rma_add_account_move" model="ir.actions.act_window">
|
||||||
<field name="name">Add Invoice</field>
|
<field name="name">Add Invoice</field>
|
||||||
<field name="type">ir.actions.act_window</field>
|
<field name="type">ir.actions.act_window</field>
|
||||||
<field name="res_model">rma_add_invoice</field>
|
<field name="res_model">rma_add_account_move</field>
|
||||||
<field name="src_model">rma.order</field>
|
|
||||||
<field name="view_type">form</field>
|
|
||||||
<field name="view_mode">form</field>
|
<field name="view_mode">form</field>
|
||||||
<field name="target">new</field>
|
<field name="target">new</field>
|
||||||
<field name="view_id" ref="view_rma_add_invoice"/>
|
<field name="view_id" ref="view_rma_add_account_move"/>
|
||||||
<field name="groups_id" eval="[(4, ref('rma.group_rma_customer_user'))]"/>
|
<field name="groups_id" eval="[(4, ref('rma.group_rma_customer_user'))]"/>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
<record id="action_rma_add_invoice_supplier" model="ir.actions.act_window">
|
<record id="action_rma_add_account_move_supplier" model="ir.actions.act_window">
|
||||||
<field name="name">Add Invoice</field>
|
<field name="name">Add Invoice</field>
|
||||||
<field name="type">ir.actions.act_window</field>
|
<field name="type">ir.actions.act_window</field>
|
||||||
<field name="res_model">rma_add_invoice</field>
|
<field name="res_model">rma_add_account_move</field>
|
||||||
<field name="src_model">rma.order</field>
|
<field name="binding_model_id" ref="rma.model_rma_order_line"/>
|
||||||
<field name="view_type">form</field>
|
|
||||||
<field name="view_mode">form</field>
|
<field name="view_mode">form</field>
|
||||||
<field name="target">new</field>
|
<field name="target">new</field>
|
||||||
<field name="view_id" ref="view_rma_add_invoice_supplier"/>
|
<field name="view_id" ref="view_rma_add_account_move_supplier"/>
|
||||||
<field name="groups_id" eval="[(4, ref('rma.group_rma_supplier_user'))]"/>
|
<field name="groups_id" eval="[(4, ref('rma.group_rma_supplier_user'))]"/>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
<record id="view_rma_add_invoice_form" model="ir.ui.view">
|
<record id="view_rma_add_account_move_form" model="ir.ui.view">
|
||||||
<field name="name">rma.order.form - invoice wizard</field>
|
<field name="name">rma.order.form - invoice wizard</field>
|
||||||
<field name="model">rma.order</field>
|
<field name="model">rma.order</field>
|
||||||
<field name="inherit_id" ref="rma.view_rma_form"/>
|
<field name="inherit_id" ref="rma.view_rma_form"/>
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<xpath expr="//header" position="inside">
|
<xpath expr="//header" position="inside">
|
||||||
<button name="%(action_rma_add_invoice)d"
|
<button name="%(action_rma_add_account_move)d"
|
||||||
string="Add From Invoice"
|
string="Add From Invoice"
|
||||||
type="action"/>
|
type="action"/>
|
||||||
</xpath>
|
</xpath>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
<record id="view_rma_add_invoice_button_form" model="ir.ui.view">
|
<record id="view_rma_add_account_move_button_form" model="ir.ui.view">
|
||||||
<field name="name">rma.order.supplier.form - invoice wizard</field>
|
<field name="name">rma.order.supplier.form - invoice wizard</field>
|
||||||
<field name="model">rma.order</field>
|
<field name="model">rma.order</field>
|
||||||
<field name="inherit_id" ref="rma.view_rma_supplier_form"/>
|
<field name="inherit_id" ref="rma.view_rma_supplier_form"/>
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<xpath expr="//header" position="inside">
|
<xpath expr="//header" position="inside">
|
||||||
<button name="%(action_rma_add_invoice_supplier)d"
|
<button name="%(action_rma_add_account_move_supplier)d"
|
||||||
string="Add From Invoice"
|
string="Add From Invoice"
|
||||||
type="action"/>
|
type="action"/>
|
||||||
</xpath>
|
</xpath>
|
||||||
@@ -20,6 +20,7 @@ class RmaRefund(models.TransientModel):
|
|||||||
def _prepare_item(self, line):
|
def _prepare_item(self, line):
|
||||||
values = {
|
values = {
|
||||||
"product_id": line.product_id.id,
|
"product_id": line.product_id.id,
|
||||||
|
"product": line.product_id.id,
|
||||||
"name": line.name,
|
"name": line.name,
|
||||||
"product_qty": line.product_qty,
|
"product_qty": line.product_qty,
|
||||||
"uom_id": line.uom_id.id,
|
"uom_id": line.uom_id.id,
|
||||||
@@ -64,7 +65,9 @@ class RmaRefund(models.TransientModel):
|
|||||||
date_invoice = fields.Date(
|
date_invoice = fields.Date(
|
||||||
string="Refund Date", default=fields.Date.context_today, required=True
|
string="Refund Date", default=fields.Date.context_today, required=True
|
||||||
)
|
)
|
||||||
date = fields.Date(string="Accounting Date")
|
date = fields.Date(
|
||||||
|
string="Accounting Date", default=fields.Date.context_today, required=True
|
||||||
|
)
|
||||||
description = fields.Char(
|
description = fields.Char(
|
||||||
string="Reason", required=True, default=lambda self: self._get_reason()
|
string="Reason", required=True, default=lambda self: self._get_reason()
|
||||||
)
|
)
|
||||||
@@ -72,18 +75,16 @@ class RmaRefund(models.TransientModel):
|
|||||||
comodel_name="rma.refund.item", inverse_name="wiz_id", string="Items"
|
comodel_name="rma.refund.item", inverse_name="wiz_id", string="Items"
|
||||||
)
|
)
|
||||||
|
|
||||||
@api.multi
|
|
||||||
def compute_refund(self):
|
def compute_refund(self):
|
||||||
for wizard in self:
|
for wizard in self:
|
||||||
first = self.item_ids[0]
|
first = self.item_ids[0]
|
||||||
values = self._prepare_refund(wizard, first.line_id)
|
values = self._prepare_refund(wizard, first.line_id)
|
||||||
new_refund = self.env["account.invoice"].create(values)
|
new_refund = self.env["account.move"].create(values)
|
||||||
for item in self.item_ids:
|
for item in self.item_ids:
|
||||||
refund_line_values = self.prepare_refund_line(item, new_refund)
|
refund_line_values = self.prepare_refund_line(item, new_refund)
|
||||||
self.env["account.invoice.line"].create(refund_line_values)
|
self.env["account.move.line"].create(refund_line_values)
|
||||||
return new_refund
|
return new_refund
|
||||||
|
|
||||||
@api.multi
|
|
||||||
def invoice_refund(self):
|
def invoice_refund(self):
|
||||||
rma_line_ids = self.env["rma.order.line"].browse(self.env.context["active_ids"])
|
rma_line_ids = self.env["rma.order.line"].browse(self.env.context["active_ids"])
|
||||||
for line in rma_line_ids:
|
for line in rma_line_ids:
|
||||||
@@ -100,7 +101,7 @@ class RmaRefund(models.TransientModel):
|
|||||||
else "action_invoice_in_refund"
|
else "action_invoice_in_refund"
|
||||||
)
|
)
|
||||||
result = self.env.ref("account.%s" % action).read()[0]
|
result = self.env.ref("account.%s" % action).read()[0]
|
||||||
form_view = self.env.ref("account.invoice_supplier_form", False)
|
form_view = self.env.ref("account.move_supplier_form", False)
|
||||||
result["views"] = [(form_view and form_view.id or False, "form")]
|
result["views"] = [(form_view and form_view.id or False, "form")]
|
||||||
result["res_id"] = new_invoice.id
|
result["res_id"] = new_invoice.id
|
||||||
return result
|
return result
|
||||||
@@ -116,14 +117,15 @@ class RmaRefund(models.TransientModel):
|
|||||||
raise ValidationError(_("Accounts are not configured for this product."))
|
raise ValidationError(_("Accounts are not configured for this product."))
|
||||||
values = {
|
values = {
|
||||||
"name": item.line_id.name or item.rma_id.name,
|
"name": item.line_id.name or item.rma_id.name,
|
||||||
"origin": item.line_id.name or item.rma_id.name,
|
|
||||||
"account_id": account.id,
|
"account_id": account.id,
|
||||||
|
"debit": item.line_id.price_unit, # todo fix
|
||||||
|
"credit": item.line_id.price_unit,
|
||||||
"price_unit": item.line_id.price_unit,
|
"price_unit": item.line_id.price_unit,
|
||||||
"uom_id": item.line_id.uom_id.id,
|
"product_uom_id": item.line_id.uom_id.id,
|
||||||
"product_id": item.product_id.id,
|
"product_id": item.product_id.id,
|
||||||
"rma_line_id": item.line_id.id,
|
"rma_line_id": item.line_id.id,
|
||||||
"quantity": item.qty_to_refund,
|
"quantity": item.qty_to_refund,
|
||||||
"invoice_id": refund.id,
|
"move_id": refund.id,
|
||||||
}
|
}
|
||||||
return values
|
return values
|
||||||
|
|
||||||
@@ -140,17 +142,15 @@ class RmaRefund(models.TransientModel):
|
|||||||
)
|
)
|
||||||
values = {
|
values = {
|
||||||
"name": rma_line.rma_id.name or rma_line.name,
|
"name": rma_line.rma_id.name or rma_line.name,
|
||||||
"origin": rma_line.rma_id.name or rma_line.name,
|
"invoice_origin": rma_line.rma_id.name or rma_line.name,
|
||||||
"reference": False,
|
"ref": False,
|
||||||
# 'account_id': account.id,
|
|
||||||
"journal_id": journal.id,
|
"journal_id": journal.id,
|
||||||
"currency_id": rma_line.partner_id.company_id.currency_id.id,
|
"currency_id": rma_line.partner_id.company_id.currency_id.id,
|
||||||
"payment_term_id": False,
|
|
||||||
"fiscal_position_id": rma_line.partner_id.property_account_position_id.id,
|
"fiscal_position_id": rma_line.partner_id.property_account_position_id.id,
|
||||||
"state": "draft",
|
"state": "draft",
|
||||||
"number": False,
|
"currency_id": rma_line.currency_id.id,
|
||||||
"date": wizard.date,
|
"date": wizard.date,
|
||||||
"date_invoice": wizard.date_invoice,
|
"invoice_date": wizard.date_invoice,
|
||||||
"partner_id": rma_line.invoice_address_id.id or rma_line.partner_id.id,
|
"partner_id": rma_line.invoice_address_id.id or rma_line.partner_id.id,
|
||||||
}
|
}
|
||||||
if self.env.registry.models.get("crm.team", False):
|
if self.env.registry.models.get("crm.team", False):
|
||||||
|
|||||||
@@ -11,12 +11,12 @@
|
|||||||
</group>
|
</group>
|
||||||
<group>
|
<group>
|
||||||
<field name="date_invoice"/>
|
<field name="date_invoice"/>
|
||||||
<field name="date" groups="base.group_no_one"/>
|
<field name="date"/>
|
||||||
</group>
|
</group>
|
||||||
</group>
|
</group>
|
||||||
<field name="item_ids">
|
<field name="item_ids">
|
||||||
<tree string="RMA Lines" editable="bottom">
|
<tree string="RMA Lines" editable="bottom">
|
||||||
<field name="rma_id"/>
|
<field name="rma_id" invisible="1"/>
|
||||||
<field name="product_id" invisible="1"/>
|
<field name="product_id" invisible="1"/>
|
||||||
<field name="product"/>
|
<field name="product"/>
|
||||||
<field name="name"/>
|
<field name="name"/>
|
||||||
@@ -36,9 +36,9 @@
|
|||||||
<record id="action_rma_refund" model="ir.actions.act_window">
|
<record id="action_rma_refund" model="ir.actions.act_window">
|
||||||
<field name="name">Create Refund</field>
|
<field name="name">Create Refund</field>
|
||||||
<field name="res_model">rma.refund</field>
|
<field name="res_model">rma.refund</field>
|
||||||
<field name="view_type">form</field>
|
|
||||||
<field name="view_mode">tree,form</field>
|
<field name="view_mode">tree,form</field>
|
||||||
<field name="view_id" ref="view_rma_refund"/>
|
<field name="view_id" ref="view_rma_refund"/>
|
||||||
|
<field name="binding_model_id" ref="rma.model_rma_order_line"/>
|
||||||
<field name="groups_id"
|
<field name="groups_id"
|
||||||
eval="[(4, ref('account.group_account_invoice'))]"/>
|
eval="[(4, ref('account.group_account_invoice'))]"/>
|
||||||
<field name="target">new</field>
|
<field name="target">new</field>
|
||||||
|
|||||||
Reference in New Issue
Block a user