diff --git a/rma_account/__manifest__.py b/rma_account/__manifest__.py index d09316bd..602c560e 100644 --- a/rma_account/__manifest__.py +++ b/rma_account/__manifest__.py @@ -3,12 +3,12 @@ { "name": "RMA Account", - "version": "13.0.1.0.0", + "version": "14.0.1.0.0", "license": "LGPL-3", "category": "RMA", "summary": "Integrates RMA with Invoice Processing", "author": "ForgeFlow", - "website": "https://github.com/OCA/account-budgeting", + "website": "https://github.com/OCA/https://github.com/ForgeFlow/stock-rma", "depends": ["stock_account", "rma"], "data": [ "security/ir.model.access.csv", diff --git a/rma_account/models/rma_order.py b/rma_account/models/rma_order.py index 7680c7f2..747316c2 100644 --- a/rma_account/models/rma_order.py +++ b/rma_account/models/rma_order.py @@ -103,7 +103,6 @@ class RmaOrder(models.Model): "domain": [("id", "in", move_ids)], "name": "Refunds", "res_model": "account.move", - "type": "ir.actions.act_window", "views": [(tree_view_ref.id, "tree"), (form_view_ref.id, "form")], } @@ -116,6 +115,5 @@ class RmaOrder(models.Model): "domain": [("id", "in", move_ids)], "name": "Originating Invoice", "res_model": "account.move", - "type": "ir.actions.act_window", "views": [(tree_view_ref.id, "tree"), (form_view_ref.id, "form")], } diff --git a/rma_account/models/rma_order_line.py b/rma_account/models/rma_order_line.py index 1f871392..64b1f0b8 100644 --- a/rma_account/models/rma_order_line.py +++ b/rma_account/models/rma_order_line.py @@ -119,18 +119,26 @@ class RmaOrderLine(models.Model): res = super(RmaOrderLine, self)._onchange_product_id() if not res.get("domain"): res["domain"] = {} - domain = [ - "&", - "&", - ("rma_line_id", "=", False), - ("exclude_from_invoice_tab", "=", False), - "|", - ("move_id.partner_id", "=", self.partner_id.id), - ("move_id.partner_id", "child_of", self.partner_id.id), - ] - # if self.product_id: - # domain.insert(2, ("product_id", "=", self.product_id.id)) - res["domain"]["account_move_line_id"] = domain + if not self.product_id: + domain = [ + "&", + "|", + ("move_id.partner_id", "=", self.partner_id.id), + ("move_id.partner_id", "child_of", self.partner_id.id), + ("exclude_from_invoice_tab", "=", False), + ] + res["domain"]["account_move_line_id"] = domain + else: + domain = [ + "&", + "&", + "|", + ("move_id.partner_id", "=", self.partner_id.id), + ("move_id.partner_id", "child_of", self.partner_id.id), + ("exclude_from_invoice_tab", "=", False), + ("product_id", "=", self.product_id.id), + ] + res["domain"]["account_move_line_id"] = domain return res def _prepare_rma_line_from_inv_line(self, line): diff --git a/rma_account/security/ir.model.access.csv b/rma_account/security/ir.model.access.csv index 74b1c356..75b11edf 100644 --- a/rma_account/security/ir.model.access.csv +++ b/rma_account/security/ir.model.access.csv @@ -3,3 +3,9 @@ access_account_move_customer_user,access_account_move,account.model_account_move 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 +access_rma_refund_customer_user_item,rma.refund.customer.user,model_rma_refund,rma.group_rma_customer_user,1,1,1,1 +access_rma_refund_supplier_user_item,rma.refund.supplier.user,model_rma_refund,rma.group_rma_supplier_user,1,1,1,1 +access_rma_refund_item_customer_user_item,rma.refund.item.customer.user,model_rma_refund_item,rma.group_rma_customer_user,1,1,1,1 +access_rma_refund_item_supplier_user_item,rma.refund.item.supplier.user,model_rma_refund_item,rma.group_rma_supplier_user,1,1,1,1 +access_rma_add_account_move_customer_user_item,rma.add.account.move.customer.user,model_rma_add_account_move,rma.group_rma_customer_user,1,1,1,1 +access_rma_add_account_move_supplier_user_item,rma.add.account.move.supplier.user,model_rma_add_account_move,rma.group_rma_supplier_user,1,1,1,1 diff --git a/rma_account/tests/test_rma_account.py b/rma_account/tests/test_rma_account.py index ab237287..c6ffc803 100644 --- a/rma_account/tests/test_rma_account.py +++ b/rma_account/tests/test_rma_account.py @@ -78,7 +78,7 @@ class TestRmaAccount(common.SingleTransactionCase): cls.invoices = cls.env["account.move"].create( [ { - "type": "out_invoice", + "move_type": "out_invoice", "partner_id": customer1.id, "invoice_date": fields.Date.from_string("2016-01-01"), "currency_id": cls.currency_id.id, @@ -106,7 +106,7 @@ class TestRmaAccount(common.SingleTransactionCase): ], }, { - "type": "in_invoice", + "move_type": "in_invoice", "partner_id": supplier1.id, "invoice_date": fields.Date.from_string("2016-01-01"), "currency_id": cls.currency_id.id, diff --git a/rma_account/views/account_move_view.xml b/rma_account/views/account_move_view.xml index 553f8559..19c96358 100644 --- a/rma_account/views/account_move_view.xml +++ b/rma_account/views/account_move_view.xml @@ -55,11 +55,10 @@ diff --git a/rma_account/views/rma_order_line_view.xml b/rma_account/views/rma_order_line_view.xml index c6671dcf..20bc2aef 100644 --- a/rma_account/views/rma_order_line_view.xml +++ b/rma_account/views/rma_order_line_view.xml @@ -29,7 +29,7 @@ name="account_move_line_id" options="{'no_create': True}" context="{'rma': True}" - domain="['|', + domain="[('move_id.move_type', 'not in', ['entry','out_invoice','out_refund']), '|', ('move_id.partner_id', '=', partner_id), ('move_id.partner_id', 'child_of', partner_id)]" /> @@ -86,7 +86,7 @@ name="account_move_line_id" options="{'no_create': True}" context="{'rma': True}" - domain="['|', + domain="[('move_id.move_type', '!=', 'entry'), '|', ('move_id.partner_id', '=', partner_id), ('move_id.partner_id', 'child_of', partner_id)]" /> diff --git a/rma_account/wizards/rma_add_account_move.xml b/rma_account/wizards/rma_add_account_move.xml index 70047ed8..fbc0ba11 100644 --- a/rma_account/wizards/rma_add_account_move.xml +++ b/rma_account/wizards/rma_add_account_move.xml @@ -7,17 +7,12 @@
- + @@ -57,17 +52,12 @@ - + diff --git a/rma_account/wizards/rma_refund.py b/rma_account/wizards/rma_refund.py index b61ccc73..7a2553f2 100644 --- a/rma_account/wizards/rma_refund.py +++ b/rma_account/wizards/rma_refund.py @@ -70,7 +70,10 @@ class RmaRefund(models.TransientModel): string="Reason", required=True, default=lambda self: self._get_reason() ) item_ids = fields.One2many( - comodel_name="rma.refund.item", inverse_name="wiz_id", string="Items" + comodel_name="rma.refund.item", + inverse_name="wiz_id", + string="Items", + required=True, ) def compute_refund(self): @@ -92,7 +95,7 @@ class RmaRefund(models.TransientModel): new_invoice = self.compute_refund() action = ( "action_move_out_refund_type" - if (new_invoice.type in ["out_refund", "out_invoice"]) + if (new_invoice.move_type in ["out_refund", "out_invoice"]) else "action_move_in_refund_type" ) result = self.env.ref("account.%s" % action).read()[0] @@ -103,7 +106,7 @@ class RmaRefund(models.TransientModel): @api.model def prepare_refund_line(self, item): - accounts = item.product_id.product_tmpl_id._get_product_accounts() + accounts = item.product.product_tmpl_id._get_product_accounts() if item.line_id.type == "customer": account = accounts["stock_output"] else: @@ -116,7 +119,7 @@ class RmaRefund(models.TransientModel): "account_id": account.id, "price_unit": item.line_id.price_unit, "product_uom_id": item.line_id.uom_id.id, - "product_id": item.product_id.id, + "product_id": item.product.id, "rma_line_id": item.line_id.id, "quantity": item.qty_to_refund, } @@ -135,10 +138,10 @@ class RmaRefund(models.TransientModel): ) values = { "name": rma_line.rma_id.name or rma_line.name, - "invoice_payment_ref": rma_line.rma_id.name or rma_line.name, + "payment_reference": rma_line.rma_id.name or rma_line.name, "invoice_origin": rma_line.rma_id.name or rma_line.name, "ref": False, - "type": "in_refund" if rma_line.type == "supplier" else "out_refund", + "move_type": "in_refund" if rma_line.type == "supplier" else "out_refund", "journal_id": journal.id, "fiscal_position_id": rma_line.partner_id.property_account_position_id.id, "state": "draft", @@ -163,9 +166,9 @@ class RmaRefund(models.TransientModel): if team_id: values["team_id"] = team_id.id if rma_line.type == "customer": - values["type"] = "out_refund" + values["move_type"] = "out_refund" else: - values["type"] = "in_refund" + values["move_type"] = "in_refund" return values @api.constrains("item_ids") @@ -187,20 +190,16 @@ class RmaRefundItem(models.TransientModel): "rma.order.line", string="RMA order Line", required=True, - readonly=True, ondelete="cascade", ) - rma_id = fields.Many2one( - "rma.order", related="line_id.rma_id", string="RMA", readonly=True - ) + rma_id = fields.Many2one("rma.order", related="line_id.rma_id", string="RMA") product_id = fields.Many2one("product.product", string="Product (Technical)") - product = fields.Many2one("product.product", string="Product", readonly=True) + product = fields.Many2one("product.product", string="Product", required=True) name = fields.Char(string="Description", required=True) product_qty = fields.Float( string="Quantity Ordered", copy=False, digits="Product Unit of Measure", - readonly=True, ) invoice_address_id = fields.Many2one( comodel_name="res.partner", string="Invoice Address" @@ -208,7 +207,7 @@ class RmaRefundItem(models.TransientModel): qty_to_refund = fields.Float( string="Quantity To Refund", digits="Product Unit of Measure" ) - uom_id = fields.Many2one("uom.uom", string="Unit of Measure", readonly=True) + uom_id = fields.Many2one("uom.uom", string="Unit of Measure") refund_policy = fields.Selection( selection=[ ("no", "Not required"), diff --git a/rma_account/wizards/rma_refund.xml b/rma_account/wizards/rma_refund.xml index 8cf80e8e..64b76089 100644 --- a/rma_account/wizards/rma_refund.xml +++ b/rma_account/wizards/rma_refund.xml @@ -16,12 +16,13 @@ - - + + - - + + +