diff --git a/repair_purchase_return/README.rst b/repair_purchase_return/README.rst new file mode 100644 index 00000000..6d683cc0 --- /dev/null +++ b/repair_purchase_return/README.rst @@ -0,0 +1,106 @@ +====================== +Repair Purchase Return +====================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:98b3537e74e31e79bd228a2bcd31227949424adb0cec58b0f5e4168559e53de3 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Alpha-red.png + :target: https://odoo-community.org/page/development-status + :alt: Alpha +.. |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%2Frepair-lightgray.png?logo=github + :target: https://github.com/OCA/repair/tree/16.0/repair_purchase_return + :alt: OCA/repair +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/repair-16-0/repair-16-0-repair_purchase_return + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png + :target: https://runboat.odoo-community.org/builds?repo=OCA/repair&target_branch=16.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +The purpose of this module is to add the possibility of create a purchase return order for some repair components products and operations directly from repair order. + +.. IMPORTANT:: + This is an alpha version, the data model and design can change at any time without warning. + Only for development or testing purpose, do not use in production. + `More details on development status `_ + +**Table of contents** + +.. contents:: + :local: + +Description +=========== + +The purpose of this module is to add the possibility of create a purchase return order for some repair components products and operations directly from repair order. + +Usage +===== + +#. Go to *Repair > Repair Orders > New* and create a new repair order. Add at least one line in *Parts* (with type *Add* and positive *Quantity*) and *Operations* (with positive *Quantity*). + +#. Click *Create Purchase Return* button. + +#. On the wizard, choose a valid vendor and click *Create And View Purchase Return* button. + +In the *Purchase Return Order*, *Unit Price* of each product line would be the cost price of the product. + +Bug Tracker +=========== + +Bugs are tracked on `GitHub Issues `_. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us to smash it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +~~~~~~~ + +* ForgeFlow + +Contributors +~~~~~~~~~~~~ + +* Mateu Griful +* Lois Rilo + +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-JordiBForgeFlow| image:: https://github.com/JordiBForgeFlow.png?size=40px + :target: https://github.com/JordiBForgeFlow + :alt: JordiBForgeFlow + +Current `maintainer `__: + +|maintainer-JordiBForgeFlow| + +This module is part of the `OCA/repair `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/repair_purchase_return/__init__.py b/repair_purchase_return/__init__.py new file mode 100644 index 00000000..aee8895e --- /dev/null +++ b/repair_purchase_return/__init__.py @@ -0,0 +1,2 @@ +from . import models +from . import wizards diff --git a/repair_purchase_return/__manifest__.py b/repair_purchase_return/__manifest__.py new file mode 100644 index 00000000..416650e6 --- /dev/null +++ b/repair_purchase_return/__manifest__.py @@ -0,0 +1,23 @@ +# Copyright (C) 2021 ForgeFlow S.L. +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html) + +{ + "name": "Repair Purchase Return", + "version": "16.0.1.0.0", + "development_status": "Alpha", + "license": "LGPL-3", + "category": "Repair", + "summary": "Create a Purchase Return from a Repair", + "author": "ForgeFlow, Odoo Community Association (OCA)", + "website": "https://github.com/OCA/repair", + "depends": ["repair", "purchase_return"], + "data": [ + "security/ir.model.access.csv", + "wizards/repair_purchase_return_wiz_views.xml", + "views/repair_order_views.xml", + "views/purchase_return_order_views.xml", + ], + "maintainers": ["JordiBForgeFlow"], + "installable": True, + "application": False, +} diff --git a/repair_purchase_return/models/__init__.py b/repair_purchase_return/models/__init__.py new file mode 100644 index 00000000..03a614c8 --- /dev/null +++ b/repair_purchase_return/models/__init__.py @@ -0,0 +1,5 @@ +from . import repair_order +from . import repair_line +from . import repair_fee +from . import purchase_return_order_line +from . import purchase_return_order diff --git a/repair_purchase_return/models/purchase_return_order.py b/repair_purchase_return/models/purchase_return_order.py new file mode 100644 index 00000000..019bd7ef --- /dev/null +++ b/repair_purchase_return/models/purchase_return_order.py @@ -0,0 +1,48 @@ +# Copyright (C) 2021 ForgeFlow S.L. +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html) + +from odoo import api, fields, models + + +class PurchaseReturnOrder(models.Model): + _inherit = "purchase.return.order" + + repair_order_count = fields.Integer( + compute="_compute_repair_orders", + string="Repair Orders Count", + ) + repair_order_ids = fields.Many2many( + comodel_name="repair.order", + compute="_compute_repair_orders", + ) + + @api.depends( + "order_line.repair_line_ids.repair_id", + "order_line.repair_fee_ids.repair_id", + ) + def _compute_repair_orders(self): + for rec in self: + repair_orders = rec.order_line.mapped("repair_line_ids.repair_id") + repair_orders |= rec.order_line.mapped("repair_fee_ids.repair_id") + rec.repair_order_ids = repair_orders + rec.repair_order_count = len(repair_orders) + + def action_view_repair_orders(self): + repair_orders = self.mapped("repair_order_ids") + action = self.env["ir.actions.actions"]._for_xml_id( + "repair.action_repair_order_tree" + ) + if len(repair_orders) > 1: + action["domain"] = [("id", "in", repair_orders.ids)] + elif len(repair_orders) == 1: + form_view = [(self.env.ref("repair.view_repair_order_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"] = repair_orders.id + else: + action = {"type": "ir.actions.act_window_close"} + return action diff --git a/repair_purchase_return/models/purchase_return_order_line.py b/repair_purchase_return/models/purchase_return_order_line.py new file mode 100644 index 00000000..04a16fc1 --- /dev/null +++ b/repair_purchase_return/models/purchase_return_order_line.py @@ -0,0 +1,11 @@ +# Copyright (C) 2021 ForgeFlow S.L. +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html) + +from odoo import fields, models + + +class PurchaseReturnOrderLine(models.Model): + _inherit = "purchase.return.order.line" + + repair_line_ids = fields.Many2many(comodel_name="repair.line", copy=False) + repair_fee_ids = fields.Many2many(comodel_name="repair.fee", copy=False) diff --git a/repair_purchase_return/models/repair_fee.py b/repair_purchase_return/models/repair_fee.py new file mode 100644 index 00000000..de8751eb --- /dev/null +++ b/repair_purchase_return/models/repair_fee.py @@ -0,0 +1,46 @@ +# Copyright (C) 2021 ForgeFlow S.L. +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html) + +from odoo import api, fields, models + + +class RepairFee(models.Model): + _inherit = "repair.fee" + + purchase_return_line_ids = fields.Many2many( + comodel_name="purchase.return.order.line", copy=False + ) + + @api.model + def _get_purchase_return_line_onchange_product_fields(self): + return ["price_unit", "taxes_id", "refund_only"] + + @api.model + def _execute_purchase_return_line_onchange(self, vals): + cls = self.env["purchase.return.order.line"] + onchanges_dict = { + "onchange_product_id": self._get_purchase_return_line_onchange_product_fields() + } + for onchange_method, changed_fields in onchanges_dict.items(): + if any(f not in vals for f in changed_fields): + obj = cls.new(vals) + getattr(obj, onchange_method)() + for field in changed_fields: + vals[field] = obj._fields[field].convert_to_write(obj[field], obj) + + @api.model + def _prepare_purchase_order_line_vals(self, pro): + vals = { + "name": self.name, + "order_id": pro.id, + "product_id": self.product_id.id, + "product_uom": self.product_uom.id, + "price_unit": 0.0, + "product_qty": self.product_uom_qty, + "repair_fee_ids": [(4, self.id)], + "date_planned": fields.Datetime.now(), + "refund_only": True, + "display_type": "product", + } + self._execute_purchase_return_line_onchange(vals) + return vals diff --git a/repair_purchase_return/models/repair_line.py b/repair_purchase_return/models/repair_line.py new file mode 100644 index 00000000..7a79ef32 --- /dev/null +++ b/repair_purchase_return/models/repair_line.py @@ -0,0 +1,46 @@ +# Copyright (C) 2021 ForgeFlow S.L. +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html) + +from odoo import api, fields, models + + +class RepairLine(models.Model): + _inherit = "repair.line" + + purchase_return_line_ids = fields.Many2many( + comodel_name="purchase.return.order.line", copy=False + ) + + @api.model + def _get_purchase_return_line_onchange_product_fields(self): + return ["price_unit", "taxes_id", "refund_only"] + + @api.model + def _execute_purchase_return_line_onchange(self, vals): + cls = self.env["purchase.return.order.line"] + onchanges_dict = { + "onchange_product_id": self._get_purchase_return_line_onchange_product_fields() + } + for onchange_method, changed_fields in onchanges_dict.items(): + if any(f not in vals for f in changed_fields): + obj = cls.new(vals) + getattr(obj, onchange_method)() + for field in changed_fields: + vals[field] = obj._fields[field].convert_to_write(obj[field], obj) + + @api.model + def _prepare_purchase_order_line_vals(self, pro): + vals = { + "name": self.name, + "order_id": pro.id, + "product_id": self.product_id.id, + "product_uom": self.product_uom.id, + "price_unit": 0.0, + "product_qty": self.product_uom_qty, + "repair_line_ids": [(4, self.id)], + "date_planned": fields.Datetime.now(), + "refund_only": True, + "display_type": "product", + } + self._execute_purchase_return_line_onchange(vals) + return vals diff --git a/repair_purchase_return/models/repair_order.py b/repair_purchase_return/models/repair_order.py new file mode 100644 index 00000000..fda9ab73 --- /dev/null +++ b/repair_purchase_return/models/repair_order.py @@ -0,0 +1,109 @@ +# Copyright (C) 2021 ForgeFlow S.L. +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html) + +from odoo import api, fields, models + + +class RepairOrder(models.Model): + _inherit = "repair.order" + + purchase_return_ids = fields.Many2many( + comodel_name="purchase.return.order", + compute="_compute_purchase_returns", + copy=False, + store=True, + ) + purchase_return_count = fields.Integer( + compute="_compute_purchase_returns", + string="Return Purchase Count", + copy=False, + default=0, + store=True, + ) + purchase_return_notes = fields.Text("Return Purchase Notes") + + @api.depends( + "operations.purchase_return_line_ids", + "operations.purchase_return_line_ids.order_id", + "fees_lines.purchase_return_line_ids", + "fees_lines.purchase_return_line_ids.order_id", + ) + def _compute_purchase_returns(self): + for order in self: + pros = order.mapped("operations.purchase_return_line_ids.order_id") + pros |= order.mapped("fees_lines.purchase_return_line_ids.order_id") + order.purchase_return_ids = pros + order.purchase_return_count = len(pros) + + def _prepare_purchase_return_values(self, vendor): + fp = vendor.with_company(self.company_id).property_account_position_id + currency = vendor.with_company(self.company_id).property_purchase_currency_id + vals = { + "origin": self.name, + "partner_id": vendor.id, + "fiscal_position_id": fp and fp.id or False, + "company_id": self.company_id.id, + "notes": self.purchase_return_notes, + } + if currency: + vals["currency_id"] = currency.id + return vals + + @api.model + def _select_operations_to_return(self, operations): + return operations.filtered(lambda o: o.type == "add") + + @api.model + def _select_fees_to_return(self, fees): + return fees + + def _create_purchase_return(self, vendor): + pro_line_obj = self.env["purchase.return.order.line"] + pr_vals = self._prepare_purchase_return_values(vendor) + pro = ( + self.env["purchase.return.order"] + .sudo() + .create(pr_vals) + .with_user(self.env.uid) + ) + for operation in self._select_operations_to_return(self.operations): + pr_line_vals = operation._prepare_purchase_order_line_vals(pro) + pro_line_obj.create(pr_line_vals) + for fee in self._select_fees_to_return(self.fees_lines): + pr_line_vals = fee._prepare_purchase_order_line_vals(pro) + pro_line_obj.create(pr_line_vals) + return pro + + def action_view_purchase_returns(self): + purchase_returns = self.mapped("purchase_return_ids") + action = self.env["ir.actions.actions"]._for_xml_id( + "purchase_return.purchase_return_form_action" + ) + if len(purchase_returns) > 1: + action["domain"] = [("id", "in", purchase_returns.ids)] + elif len(purchase_returns) == 1: + form_view = [ + (self.env.ref("purchase_return.purchase_return_order_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"] = purchase_returns.id + else: + action = {"type": "ir.actions.act_window_close"} + + context = { + "default_move_type": "out_invoice", + } + if len(self) == 1: + context.update( + { + "default_partner_id": self.partner_id.id, + "default_user_id": self.user_id.id, + } + ) + action["context"] = context + return action diff --git a/repair_purchase_return/readme/CONTRIBUTORS.rst b/repair_purchase_return/readme/CONTRIBUTORS.rst new file mode 100644 index 00000000..087dd292 --- /dev/null +++ b/repair_purchase_return/readme/CONTRIBUTORS.rst @@ -0,0 +1,2 @@ +* Mateu Griful +* Lois Rilo diff --git a/repair_purchase_return/readme/DESCRIPTION.rst b/repair_purchase_return/readme/DESCRIPTION.rst new file mode 100644 index 00000000..a88f5f9c --- /dev/null +++ b/repair_purchase_return/readme/DESCRIPTION.rst @@ -0,0 +1 @@ +The purpose of this module is to add the possibility of create a purchase return order for some repair components products and operations directly from repair order. diff --git a/repair_purchase_return/readme/USAGE.rst b/repair_purchase_return/readme/USAGE.rst new file mode 100644 index 00000000..4f8de837 --- /dev/null +++ b/repair_purchase_return/readme/USAGE.rst @@ -0,0 +1,7 @@ +#. Go to *Repair > Repair Orders > New* and create a new repair order. Add at least one line in *Parts* (with type *Add* and positive *Quantity*) and *Operations* (with positive *Quantity*). + +#. Click *Create Purchase Return* button. + +#. On the wizard, choose a valid vendor and click *Create And View Purchase Return* button. + +In the *Purchase Return Order*, *Unit Price* of each product line would be the cost price of the product. diff --git a/repair_purchase_return/security/ir.model.access.csv b/repair_purchase_return/security/ir.model.access.csv new file mode 100644 index 00000000..1bcd7179 --- /dev/null +++ b/repair_purchase_return/security/ir.model.access.csv @@ -0,0 +1,2 @@ +id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink +access_repair_purchase_return_wiz,repair.purchase.return.wiz,model_repair_purchase_return_wiz,purchase.group_purchase_user,1,1,1,1 diff --git a/repair_purchase_return/static/description/icon.png b/repair_purchase_return/static/description/icon.png new file mode 100644 index 00000000..3a0328b5 Binary files /dev/null and b/repair_purchase_return/static/description/icon.png differ diff --git a/repair_purchase_return/static/description/index.html b/repair_purchase_return/static/description/index.html new file mode 100644 index 00000000..a458550b --- /dev/null +++ b/repair_purchase_return/static/description/index.html @@ -0,0 +1,439 @@ + + + + + +Repair Purchase Return + + + +
+

Repair Purchase Return

+ + +

Alpha License: LGPL-3 OCA/repair Translate me on Weblate Try me on Runboat

+

The purpose of this module is to add the possibility of create a purchase return order for some repair components products and operations directly from repair order.

+
+

Important

+

This is an alpha version, the data model and design can change at any time without warning. +Only for development or testing purpose, do not use in production. +More details on development status

+
+

Table of contents

+ +
+

Usage

+
    +
  1. Go to Repair > Repair Orders > New and create a new repair order. Add at least one line in Parts (with type Add and positive Quantity) and Operations (with positive Quantity).
  2. +
  3. Click Create Purchase Return button.
  4. +
  5. On the wizard, choose a valid vendor and click Create And View Purchase Return button.
  6. +
+

In the Purchase Return Order, Unit Price of each product line would be the cost price of the product.

+
+
+

Bug Tracker

+

Bugs are tracked on GitHub Issues. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us to smash it by providing a detailed and welcomed +feedback.

+

Do not contact contributors directly about support or help with technical issues.

+
+
+

Credits

+
+

Authors

+
    +
  • ForgeFlow
  • +
+
+ +
+

Maintainers

+

This module is maintained by the OCA.

+Odoo Community Association +

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.

+

Current maintainer:

+

JordiBForgeFlow

+

This module is part of the OCA/repair project on GitHub.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+
+
+
+ + diff --git a/repair_purchase_return/tests/__init__.py b/repair_purchase_return/tests/__init__.py new file mode 100644 index 00000000..4170f994 --- /dev/null +++ b/repair_purchase_return/tests/__init__.py @@ -0,0 +1 @@ +from . import test_repair_purchase_return_order diff --git a/repair_purchase_return/tests/test_repair_purchase_return_order.py b/repair_purchase_return/tests/test_repair_purchase_return_order.py new file mode 100644 index 00000000..557f711e --- /dev/null +++ b/repair_purchase_return/tests/test_repair_purchase_return_order.py @@ -0,0 +1,96 @@ +from odoo.tests import tagged + +from odoo.addons.account.tests.common import AccountTestInvoicingCommon + + +@tagged("-at_install", "post_install") +class TestRepairPurchaseReturnOrder(AccountTestInvoicingCommon): + @classmethod + def setUpClass(cls): + super(TestRepairPurchaseReturnOrder, cls).setUpClass() + cls.product = cls.env["product.product"].create( + { + "name": "Test product", + "standard_price": 10, + "list_price": 20, + } + ) + + cls.service = cls.env["product.product"].create( + { + "name": "Test Fee", + "standard_price": 30, + "list_price": 50, + } + ) + + cls.partner = cls.env.ref("base.res_partner_address_1") + cls.location = cls.env["stock.location"].create( + { + "name": "Test location", + } + ) + cls.repair = cls.env["repair.order"].create( + { + "product_id": cls.product.id, + "partner_id": cls.partner.id, + "partner_invoice_id": cls.partner.id, + "product_uom": cls.product.uom_id.id, + "location_id": cls.location.id, + "invoice_method": "none", + } + ) + domain_location = [("usage", "=", "production")] + stock_location_id = cls.env["stock.location"].search(domain_location, limit=1) + cls.repair_line = cls.env["repair.line"].create( + { + "repair_id": cls.repair.id, + "type": "add", + "product_id": cls.product.id, + "product_uom": cls.product.uom_id.id, + "name": "Test line", + "location_id": cls.repair.location_id.id, + "location_dest_id": stock_location_id.id, + "product_uom_qty": 1, + "price_unit": cls.product.list_price, + } + ) + + cls.fees_lines = cls.env["repair.fee"].create( + { + "repair_id": cls.repair.id, + "product_id": cls.service.id, + "product_uom": cls.service.uom_id.id, + "name": "Test Fee", + "product_uom_qty": 1, + "price_unit": cls.service.list_price, + } + ) + + cls.repair["operations"] = cls.repair_line + cls.repair["fees_lines"] = cls.fees_lines + + cls.journal = cls.env["account.journal"].create( + { + "name": "Test Journal", + "code": "test", + "type": "sale", + "invoice_reference_type": "invoice", + "invoice_reference_model": "odoo", + } + ) + + cls.vendor = cls.env["res.partner"].create( + { + "name": "Vendor1", + } + ) + + def test_repair_purchase_return(self): + pro = self.repair._create_purchase_return(self.vendor) + pro.action_view_repair_orders() + + # Check that purchase return order is caching the two lines and using the product cost + self.assertEqual(pro.order_line[0].price_unit, 10) + + self.assertEqual(pro.order_line[1].price_unit, 30) diff --git a/repair_purchase_return/views/purchase_return_order_views.xml b/repair_purchase_return/views/purchase_return_order_views.xml new file mode 100644 index 00000000..20bfcebc --- /dev/null +++ b/repair_purchase_return/views/purchase_return_order_views.xml @@ -0,0 +1,28 @@ + + + + + purchase.return.order.form + purchase.return.order + + +
+ +
+
+
+ +
diff --git a/repair_purchase_return/views/repair_order_views.xml b/repair_purchase_return/views/repair_order_views.xml new file mode 100644 index 00000000..85df9e49 --- /dev/null +++ b/repair_purchase_return/views/repair_order_views.xml @@ -0,0 +1,42 @@ + + + + + repair.order.form - repair_stock_move + repair.order + + +
+
+
+ +
+ + + + +
+ +
diff --git a/repair_purchase_return/wizards/__init__.py b/repair_purchase_return/wizards/__init__.py new file mode 100644 index 00000000..73706688 --- /dev/null +++ b/repair_purchase_return/wizards/__init__.py @@ -0,0 +1 @@ +from . import repair_purchase_return_wiz diff --git a/repair_purchase_return/wizards/repair_purchase_return_wiz.py b/repair_purchase_return/wizards/repair_purchase_return_wiz.py new file mode 100644 index 00000000..8cbc8222 --- /dev/null +++ b/repair_purchase_return/wizards/repair_purchase_return_wiz.py @@ -0,0 +1,41 @@ +# Copyright (C) 2021 ForgeFlow S.L. +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html) + +from odoo import api, fields, models + + +class RepairPurchaseReturnWiz(models.TransientModel): + _name = "repair.purchase.return.wiz" + _description = "RepairPurchaseReturnWizard" + + vendor_id = fields.Many2one("res.partner", required=True) + + @api.model + def default_get(self, fields): + vals = super(RepairPurchaseReturnWiz, self).default_get(fields) + repair_ids = self.env.context["active_ids"] or [] + active_model = self.env.context["active_model"] + + if not repair_ids: + return vals + assert active_model == "repair.order", "Bad context propagation" + + repairs = self.env["repair.order"].browse(repair_ids) + vendors = self.env["res.partner"] + for repair in repairs: + vendors |= ( + repair.product_id.mapped("seller_ids") + .filtered(lambda s: s.company_id == repair.company_id) + .partner_id + ) + if len(vendors) >= 1: + vals["vendor_id"] = vendors[0].id + return vals + + def create_purchase_returns(self): + repairs = self.env["repair.order"].browse(self._context.get("active_ids", [])) + for repair in repairs: + repair._create_purchase_return(self.vendor_id) + if self._context.get("open_purchase_returns", False): + return repairs.action_view_purchase_returns() + return {"type": "ir.actions.act_window_close"} diff --git a/repair_purchase_return/wizards/repair_purchase_return_wiz_views.xml b/repair_purchase_return/wizards/repair_purchase_return_wiz_views.xml new file mode 100644 index 00000000..f0108913 --- /dev/null +++ b/repair_purchase_return/wizards/repair_purchase_return_wiz_views.xml @@ -0,0 +1,50 @@ + + + + Create Purchase Returns + repair.purchase.return.wiz + +
+

+ Purchase Returns will be created in draft so that you + can review them before validation. +

+ + + +
+
+
+
+
+ + + Create Purchase Return Orders + ir.actions.act_window + repair.purchase.return.wiz + form + new + + list + + +
diff --git a/setup/repair_purchase_return/odoo/addons/repair_purchase_return b/setup/repair_purchase_return/odoo/addons/repair_purchase_return new file mode 120000 index 00000000..6983fec7 --- /dev/null +++ b/setup/repair_purchase_return/odoo/addons/repair_purchase_return @@ -0,0 +1 @@ +../../../../repair_purchase_return \ No newline at end of file diff --git a/setup/repair_purchase_return/setup.py b/setup/repair_purchase_return/setup.py new file mode 100644 index 00000000..28c57bb6 --- /dev/null +++ b/setup/repair_purchase_return/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +) diff --git a/test-requirements.txt b/test-requirements.txt new file mode 100644 index 00000000..e69de29b