mirror of
https://github.com/ForgeFlow/stock-rma.git
synced 2025-01-21 12:57:49 +02:00
[IMP] rma_account: add test
This commit is contained in:
@@ -58,12 +58,15 @@ class AccountMove(models.Model):
|
||||
self._post_process_invoice_line_from_rma_line(
|
||||
new_line, self.add_rma_line_id
|
||||
)
|
||||
line = new_line._convert_to_write(
|
||||
{name: new_line[name] for name in new_line._cache}
|
||||
)
|
||||
# Compute invoice_origin.
|
||||
origins = set(self.line_ids.mapped("rma_line_id.name"))
|
||||
self.invoice_origin = ",".join(list(origins))
|
||||
self.add_rma_line_id = False
|
||||
self._onchange_currency()
|
||||
return {}
|
||||
return line
|
||||
|
||||
rma_count = fields.Integer(compute="_compute_rma_count", string="# of RMA")
|
||||
|
||||
|
||||
@@ -263,3 +263,29 @@ class TestRmaAccount(common.SingleTransactionCase):
|
||||
self.assertEqual(
|
||||
self.operation_1.refund_journal_id, rma.refund_line_ids.journal_id
|
||||
)
|
||||
|
||||
def test_07_add_lines_from_rma(self):
|
||||
"""Test adding line from rma to supplier refund"""
|
||||
add_inv = self.rma_add_invoice_wiz.with_context(
|
||||
{
|
||||
"supplier": True,
|
||||
"active_ids": self.rma_group_supplier.id,
|
||||
"active_model": "rma.order",
|
||||
}
|
||||
).create({"line_ids": [(6, 0, self.inv_supplier.line_ids.ids)]})
|
||||
add_inv.add_lines()
|
||||
rma_1 = self.rma_group_supplier.rma_line_ids.filtered(
|
||||
lambda r: r.product_id == self.product_1
|
||||
)
|
||||
inv = self.inv_obj.with_context(
|
||||
{
|
||||
"default_move_type": "in_refund",
|
||||
"default_partner_id": self.inv_supplier.partner_id,
|
||||
}
|
||||
).create({"add_rma_line_id": rma_1})
|
||||
line = inv.on_change_add_rma_line_id()
|
||||
inv.invoice_line_ids = [(0, 0, line)]
|
||||
inv_product = inv.invoice_line_ids.filtered(
|
||||
lambda x: x.product_id == self.product_1
|
||||
).mapped("product_id")
|
||||
self.assertEqual(rma_1.product_id.id, inv_product.id)
|
||||
|
||||
Reference in New Issue
Block a user