diff --git a/repair_payment_term/README.rst b/repair_payment_term/README.rst new file mode 100644 index 000000000..2a6a99456 --- /dev/null +++ b/repair_payment_term/README.rst @@ -0,0 +1,95 @@ +=================== +Repair Payment Term +=================== + +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png + :target: https://odoo-community.org/page/development-status + :alt: Beta +.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 +.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fmanufacture-lightgray.png?logo=github + :target: https://github.com/OCA/manufacture/tree/12.0/repair_payment_term + :alt: OCA/manufacture +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/manufacture-12-0/manufacture-12-0-repair_payment_term + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png + :target: https://runbot.odoo-community.org/runbot/129/12.0 + :alt: Try me on Runbot + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module adds a new field *Payment Term* on Repair Orders, that is copied to +generated invoice. + +**Table of contents** + +.. contents:: + :local: + +Configuration +============= + +To configure this module, you need to do noting + +Usage +===== + +When you select a partner, the partner payment term is copied to the repair order, if you want you can change it. + +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 smashing it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +~~~~~~~ + +* KMEE + +Contributors +~~~~~~~~~~~~ + +* Luis Felipe Mileo + +Other credits +~~~~~~~~~~~~~ + +[ This file is optional and contains additional credits, other than + authors, contributors, and maintainers. ] + +The development of this module has been financially supported by: + +* KMEE + + +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. + +This module is part of the `OCA/manufacture `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/repair_payment_term/__init__.py b/repair_payment_term/__init__.py new file mode 100644 index 000000000..0650744f6 --- /dev/null +++ b/repair_payment_term/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/repair_payment_term/__manifest__.py b/repair_payment_term/__manifest__.py new file mode 100644 index 000000000..633dcc626 --- /dev/null +++ b/repair_payment_term/__manifest__.py @@ -0,0 +1,22 @@ +# Copyright 2021 KMEE +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +{ + 'name': 'Repair Payment Term', + 'summary': """ + This module add to Repair Orders the *Payment Term* field""", + 'version': '12.0.1.0.0', + 'license': 'AGPL-3', + 'author': 'KMEE,Odoo Community Association (OCA)', + 'website': 'https://github.com/oca/manufacture', + 'maintainers': ['mileo'], + 'depends': [ + 'repair', + ], + 'data': [ + 'views/repair_order.xml', + 'report/repair_report_templates.xml', + ], + 'demo': [ + ], +} diff --git a/repair_payment_term/models/__init__.py b/repair_payment_term/models/__init__.py new file mode 100644 index 000000000..2251f67dd --- /dev/null +++ b/repair_payment_term/models/__init__.py @@ -0,0 +1 @@ +from . import repair_order diff --git a/repair_payment_term/models/repair_order.py b/repair_payment_term/models/repair_order.py new file mode 100644 index 000000000..ba0417092 --- /dev/null +++ b/repair_payment_term/models/repair_order.py @@ -0,0 +1,33 @@ +# Copyright 2021 KMEE +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo import api, fields, models + + +class RepairOrder(models.Model): + + _inherit = 'repair.order' + + payment_term_id = fields.Many2one( + comodel_name='account.payment.term', + string='Payment Term', + ) + + @api.onchange('partner_id') + def onchange_partner_id(self): + res = super().onchange_partner_id() + if self.partner_id: + self.payment_term_id = self.partner_id.with_context( + force_company=self.company_id.id + ).property_payment_term_id + else: + self.payment_term_id = False + return res + + @api.multi + def action_invoice_create(self, group=False): + res = super().action_invoice_create(group) + for record in self: + if record.invoice_id and record.payment_term_id: + record.invoice_id.payment_term_id = record.payment_term_id + return res diff --git a/repair_payment_term/readme/CONFIGURE.rst b/repair_payment_term/readme/CONFIGURE.rst new file mode 100644 index 000000000..27f653181 --- /dev/null +++ b/repair_payment_term/readme/CONFIGURE.rst @@ -0,0 +1 @@ +To configure this module, you need to do noting diff --git a/repair_payment_term/readme/CONTRIBUTORS.rst b/repair_payment_term/readme/CONTRIBUTORS.rst new file mode 100644 index 000000000..930c23505 --- /dev/null +++ b/repair_payment_term/readme/CONTRIBUTORS.rst @@ -0,0 +1 @@ +* Luis Felipe Mileo diff --git a/repair_payment_term/readme/CREDITS.rst b/repair_payment_term/readme/CREDITS.rst new file mode 100644 index 000000000..b6f19e5cf --- /dev/null +++ b/repair_payment_term/readme/CREDITS.rst @@ -0,0 +1,7 @@ +[ This file is optional and contains additional credits, other than + authors, contributors, and maintainers. ] + +The development of this module has been financially supported by: + +* KMEE + diff --git a/repair_payment_term/readme/DESCRIPTION.rst b/repair_payment_term/readme/DESCRIPTION.rst new file mode 100644 index 000000000..8cbd97e2f --- /dev/null +++ b/repair_payment_term/readme/DESCRIPTION.rst @@ -0,0 +1,2 @@ +This module adds a new field *Payment Term* on Repair Orders, that is copied to +generated invoice. diff --git a/repair_payment_term/readme/USAGE.rst b/repair_payment_term/readme/USAGE.rst new file mode 100644 index 000000000..db5bba284 --- /dev/null +++ b/repair_payment_term/readme/USAGE.rst @@ -0,0 +1 @@ +When you select a partner, the partner payment term is copied to the repair order, if you want you can change it. \ No newline at end of file diff --git a/repair_payment_term/report/repair_report_templates.xml b/repair_payment_term/report/repair_report_templates.xml new file mode 100644 index 000000000..4b06c5e84 --- /dev/null +++ b/repair_payment_term/report/repair_report_templates.xml @@ -0,0 +1,18 @@ + + + + + + diff --git a/repair_payment_term/static/description/icon.png b/repair_payment_term/static/description/icon.png new file mode 100644 index 000000000..3a0328b51 Binary files /dev/null and b/repair_payment_term/static/description/icon.png differ diff --git a/repair_payment_term/static/description/index.html b/repair_payment_term/static/description/index.html new file mode 100644 index 000000000..bd52dbc82 --- /dev/null +++ b/repair_payment_term/static/description/index.html @@ -0,0 +1,442 @@ + + + + + + +Repair Payment Term + + + +
+

Repair Payment Term

+ + +

Beta License: AGPL-3 OCA/manufacture Translate me on Weblate Try me on Runbot

+

This module adds a new field Payment Term on Repair Orders, that is copied to +generated invoice.

+

Table of contents

+ +
+

Configuration

+

To configure this module, you need to do noting

+
+
+

Usage

+

When you select a partner, the partner payment term is copied to the repair order, if you want you can change it.

+
+
+

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 smashing it by providing a detailed and welcomed +feedback.

+

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

+
+
+

Credits

+
+

Authors

+
    +
  • KMEE
  • +
+
+
+

Contributors

+ +
+
+

Other credits

+
+
[ This file is optional and contains additional credits, other than
+
authors, contributors, and maintainers. ]
+
+

The development of this module has been financially supported by:

+
    +
  • KMEE
  • +
+
+
+

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.

+

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

+

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

+
+
+
+ + diff --git a/repair_payment_term/tests/__init__.py b/repair_payment_term/tests/__init__.py new file mode 100644 index 000000000..570dd9636 --- /dev/null +++ b/repair_payment_term/tests/__init__.py @@ -0,0 +1 @@ +from . import test_repair diff --git a/repair_payment_term/tests/test_repair.py b/repair_payment_term/tests/test_repair.py new file mode 100644 index 000000000..a8f1f278d --- /dev/null +++ b/repair_payment_term/tests/test_repair.py @@ -0,0 +1,67 @@ +# Copyright 2021 KMEE +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo.addons.repair.tests.test_repair import TestRepair +from odoo.tests import tagged + + +@tagged('post_install', '-at_install') +class PaymentTestRepair(TestRepair): + + def test_00_repair_payment_term(self): + partner_12 = self.env.ref('base.res_partner_12') + payment_term_id = self.env.ref('account.account_payment_term') + partner_12.property_payment_term_id = payment_term_id + + repair = self._create_simple_repair_order('after_repair') + repair.onchange_partner_id() + self.assertEqual( + repair.payment_term_id, + payment_term_id, + 'Repair onchange payment term not working.' + ) + self._create_simple_operation( + repair_id=repair.id, qty=1.0, price_unit=50.0) + # I confirm Repair order taking Invoice Method 'After Repair'. + repair.sudo(self.res_repair_user.id).action_repair_confirm() + + # I check the state is in "Confirmed". + self.assertEqual(repair.state, "confirmed", + 'Repair order should be in "Confirmed" state.') + repair.action_repair_start() + + # I check the state is in "Under Repair". + self.assertEqual(repair.state, "under_repair", + 'Repair order should be in "Under_repair" state.') + + # Repairing process for product is in Done state and I end + # Repair process by clicking on "End Repair" button. + repair.action_repair_end() + + # I define Invoice Method 'After Repair' + # option in this Repair order.so I create + # invoice by clicking on "Make Invoice" wizard. + make_invoice = self.RepairMakeInvoice.create({ + 'group': True}) + # I click on "Create Invoice" button of this wizard to make invoice. + context = { + "active_model": 'repair_order', + "active_ids": [repair.id], + "active_id": repair.id + } + make_invoice.with_context(context).make_invoices() + + # I check that invoice is created for this Repair order. + self.assertEqual( + len(repair.invoice_id), 1, + "No invoice exists for this repair order" + ) + self.assertEqual( + repair.invoice_id.payment_term_id, + repair.payment_term_id, + "Repair Payment Term and Invoice is not the same" + ) + self.assertEqual( + len(repair.move_id.move_line_ids[0].consume_line_ids), + 1, "Consume lines should be set" + ) diff --git a/repair_payment_term/views/repair_order.xml b/repair_payment_term/views/repair_order.xml new file mode 100644 index 000000000..c35972864 --- /dev/null +++ b/repair_payment_term/views/repair_order.xml @@ -0,0 +1,18 @@ + + + + + + + repair.order.form (in repair_payment_term) + repair.order + + + + + + + + +