diff --git a/repair_discount/README.rst b/repair_discount/README.rst new file mode 100644 index 000000000..1176ce77f --- /dev/null +++ b/repair_discount/README.rst @@ -0,0 +1,78 @@ +=================== +MRP Repair Discount +=================== + +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! 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_discount + :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_discount + :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 extends the functionality of mrp repair adding +new field discount on operations lines + +**Table of contents** + +.. contents:: + :local: + +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 +~~~~~~~ + +* Agile Business Group +* Tecnativa + +Contributors +~~~~~~~~~~~~ + +* Nicola Malcontenti +* Pedro M. Baeza +* Lorenzo Battistini +* María Asunción Daza + +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_discount/__init__.py b/repair_discount/__init__.py new file mode 100644 index 000000000..1fd09b272 --- /dev/null +++ b/repair_discount/__init__.py @@ -0,0 +1,4 @@ +# Copyright 2015 Nicola Malcontenti - Agile Business Group +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from . import models diff --git a/repair_discount/__manifest__.py b/repair_discount/__manifest__.py new file mode 100644 index 000000000..1d6258ff7 --- /dev/null +++ b/repair_discount/__manifest__.py @@ -0,0 +1,17 @@ +# Copyright 2015 Nicola Malcontenti - Agile Business Group +# Copyright 2016 Pedro M. Baeza +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +{ + "name": "Repair Discount", + "version": "12.0.1.0.0", + "category": "Manufacturing", + "license": "AGPL-3", + "author": "Agile Business Group, " + "Tecnativa, " + "Odoo Community Association (OCA)", + "website": "http://www.agilebg.com", + 'depends': ['repair'], + "data": ["views/mrp_repair_view.xml"], + "installable": True, +} diff --git a/repair_discount/i18n/de.po b/repair_discount/i18n/de.po new file mode 100644 index 000000000..99d37bcc3 --- /dev/null +++ b/repair_discount/i18n/de.po @@ -0,0 +1,38 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * mrp_repair_discount +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 10.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2018-12-10 11:58+0000\n" +"Last-Translator: Maria Sparenberg \n" +"Language-Team: none\n" +"Language: de\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=n != 1;\n" +"X-Generator: Weblate 3.3\n" + +#. module: mrp_repair_discount +#: model:ir.model.fields,field_description:mrp_repair_discount.field_mrp_repair_fee_discount +#: model:ir.model.fields,field_description:mrp_repair_discount.field_mrp_repair_line_discount +msgid "Discount (%)" +msgstr "Rabatt (%)" + +#. module: mrp_repair_discount +#: model:ir.model,name:mrp_repair_discount.model_mrp_repair_fee +msgid "Repair Fees Line" +msgstr "Reparaturgebührenzeile" + +#. module: mrp_repair_discount +#: model:ir.model,name:mrp_repair_discount.model_mrp_repair_line +msgid "Repair Line" +msgstr "Reparaturzeile" + +#. module: mrp_repair_discount +#: model:ir.model,name:mrp_repair_discount.model_mrp_repair +msgid "Repair Order" +msgstr "Reparaturauftrag" diff --git a/repair_discount/i18n/es.po b/repair_discount/i18n/es.po new file mode 100644 index 000000000..967b2c71e --- /dev/null +++ b/repair_discount/i18n/es.po @@ -0,0 +1,40 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * mrp_repair_discount +# +# Translators: +# enjolras , 2018 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 10.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2018-02-12 03:48+0000\n" +"PO-Revision-Date: 2018-02-12 03:48+0000\n" +"Last-Translator: enjolras , 2018\n" +"Language-Team: Spanish (https://www.transifex.com/oca/teams/23907/es/)\n" +"Language: es\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#. module: mrp_repair_discount +#: model:ir.model.fields,field_description:mrp_repair_discount.field_mrp_repair_fee_discount +#: model:ir.model.fields,field_description:mrp_repair_discount.field_mrp_repair_line_discount +msgid "Discount (%)" +msgstr "Descuento (%)" + +#. module: mrp_repair_discount +#: model:ir.model,name:mrp_repair_discount.model_mrp_repair_fee +msgid "Repair Fees Line" +msgstr "Línea de tarifa de reparación" + +#. module: mrp_repair_discount +#: model:ir.model,name:mrp_repair_discount.model_mrp_repair_line +msgid "Repair Line" +msgstr "Línea de reparación" + +#. module: mrp_repair_discount +#: model:ir.model,name:mrp_repair_discount.model_mrp_repair +msgid "Repair Order" +msgstr "Pedido de reparación" diff --git a/repair_discount/i18n/fr.po b/repair_discount/i18n/fr.po new file mode 100644 index 000000000..9c1f633b7 --- /dev/null +++ b/repair_discount/i18n/fr.po @@ -0,0 +1,41 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * mrp_repair_discount +# +# Translators: +# Quentin THEURET , 2017 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 10.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-11-28 03:44+0000\n" +"PO-Revision-Date: 2018-09-26 08:27+0000\n" +"Last-Translator: William Olhasque \n" +"Language-Team: French (https://www.transifex.com/oca/teams/23907/fr/)\n" +"Language: fr\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=n > 1;\n" +"X-Generator: Weblate 3.1.1\n" + +#. module: mrp_repair_discount +#: model:ir.model.fields,field_description:mrp_repair_discount.field_mrp_repair_fee_discount +#: model:ir.model.fields,field_description:mrp_repair_discount.field_mrp_repair_line_discount +msgid "Discount (%)" +msgstr "Remise (%)" + +#. module: mrp_repair_discount +#: model:ir.model,name:mrp_repair_discount.model_mrp_repair_fee +msgid "Repair Fees Line" +msgstr "Ligne de frais de réparation" + +#. module: mrp_repair_discount +#: model:ir.model,name:mrp_repair_discount.model_mrp_repair_line +msgid "Repair Line" +msgstr "Ligne de réparation" + +#. module: mrp_repair_discount +#: model:ir.model,name:mrp_repair_discount.model_mrp_repair +msgid "Repair Order" +msgstr "Ordre de réparation" diff --git a/repair_discount/i18n/hr.po b/repair_discount/i18n/hr.po new file mode 100644 index 000000000..0b8dbd4c9 --- /dev/null +++ b/repair_discount/i18n/hr.po @@ -0,0 +1,41 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * mrp_repair_discount +# +# Translators: +# Bole , 2018 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 10.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2018-02-12 03:48+0000\n" +"PO-Revision-Date: 2018-02-12 03:48+0000\n" +"Last-Translator: Bole , 2018\n" +"Language-Team: Croatian (https://www.transifex.com/oca/teams/23907/hr/)\n" +"Language: hr\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=3; plural=n%10==1 && n%100!=11 ? 0 : n%10>=2 && n" +"%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2;\n" + +#. module: mrp_repair_discount +#: model:ir.model.fields,field_description:mrp_repair_discount.field_mrp_repair_fee_discount +#: model:ir.model.fields,field_description:mrp_repair_discount.field_mrp_repair_line_discount +msgid "Discount (%)" +msgstr "" + +#. module: mrp_repair_discount +#: model:ir.model,name:mrp_repair_discount.model_mrp_repair_fee +msgid "Repair Fees Line" +msgstr "" + +#. module: mrp_repair_discount +#: model:ir.model,name:mrp_repair_discount.model_mrp_repair_line +msgid "Repair Line" +msgstr "" + +#. module: mrp_repair_discount +#: model:ir.model,name:mrp_repair_discount.model_mrp_repair +msgid "Repair Order" +msgstr "Nalog za popravak" diff --git a/repair_discount/i18n/hr_HR.po b/repair_discount/i18n/hr_HR.po new file mode 100644 index 000000000..6ded97874 --- /dev/null +++ b/repair_discount/i18n/hr_HR.po @@ -0,0 +1,42 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * mrp_repair_discount +# +# Translators: +# Bole , 2017 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 10.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-11-28 03:44+0000\n" +"PO-Revision-Date: 2017-11-28 03:44+0000\n" +"Last-Translator: Bole , 2017\n" +"Language-Team: Croatian (Croatia) (https://www.transifex.com/oca/teams/23907/" +"hr_HR/)\n" +"Language: hr_HR\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=3; plural=n%10==1 && n%100!=11 ? 0 : n%10>=2 && n" +"%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2;\n" + +#. module: mrp_repair_discount +#: model:ir.model.fields,field_description:mrp_repair_discount.field_mrp_repair_fee_discount +#: model:ir.model.fields,field_description:mrp_repair_discount.field_mrp_repair_line_discount +msgid "Discount (%)" +msgstr "" + +#. module: mrp_repair_discount +#: model:ir.model,name:mrp_repair_discount.model_mrp_repair_fee +msgid "Repair Fees Line" +msgstr "" + +#. module: mrp_repair_discount +#: model:ir.model,name:mrp_repair_discount.model_mrp_repair_line +msgid "Repair Line" +msgstr "" + +#. module: mrp_repair_discount +#: model:ir.model,name:mrp_repair_discount.model_mrp_repair +msgid "Repair Order" +msgstr "Nalog za popravak" diff --git a/repair_discount/i18n/it.po b/repair_discount/i18n/it.po new file mode 100644 index 000000000..2ba4ffabe --- /dev/null +++ b/repair_discount/i18n/it.po @@ -0,0 +1,40 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * mrp_repair_discount +# +# Translators: +# OCA Transbot , 2017 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 10.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-11-28 03:44+0000\n" +"PO-Revision-Date: 2017-11-28 03:44+0000\n" +"Last-Translator: OCA Transbot , 2017\n" +"Language-Team: Italian (https://www.transifex.com/oca/teams/23907/it/)\n" +"Language: it\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#. module: mrp_repair_discount +#: model:ir.model.fields,field_description:mrp_repair_discount.field_mrp_repair_fee_discount +#: model:ir.model.fields,field_description:mrp_repair_discount.field_mrp_repair_line_discount +msgid "Discount (%)" +msgstr "" + +#. module: mrp_repair_discount +#: model:ir.model,name:mrp_repair_discount.model_mrp_repair_fee +msgid "Repair Fees Line" +msgstr "" + +#. module: mrp_repair_discount +#: model:ir.model,name:mrp_repair_discount.model_mrp_repair_line +msgid "Repair Line" +msgstr "" + +#. module: mrp_repair_discount +#: model:ir.model,name:mrp_repair_discount.model_mrp_repair +msgid "Repair Order" +msgstr "Ordine di riparazione" diff --git a/repair_discount/i18n/lt.po b/repair_discount/i18n/lt.po new file mode 100644 index 000000000..bfaea9f73 --- /dev/null +++ b/repair_discount/i18n/lt.po @@ -0,0 +1,41 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * mrp_repair_discount +# +# Translators: +# Viktoras Norkus , 2018 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 10.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2018-01-16 08:02+0000\n" +"PO-Revision-Date: 2018-01-16 08:02+0000\n" +"Last-Translator: Viktoras Norkus , 2018\n" +"Language-Team: Lithuanian (https://www.transifex.com/oca/teams/23907/lt/)\n" +"Language: lt\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && (n" +"%100<10 || n%100>=20) ? 1 : 2);\n" + +#. module: mrp_repair_discount +#: model:ir.model.fields,field_description:mrp_repair_discount.field_mrp_repair_fee_discount +#: model:ir.model.fields,field_description:mrp_repair_discount.field_mrp_repair_line_discount +msgid "Discount (%)" +msgstr "Nuolaida (%)" + +#. module: mrp_repair_discount +#: model:ir.model,name:mrp_repair_discount.model_mrp_repair_fee +msgid "Repair Fees Line" +msgstr "" + +#. module: mrp_repair_discount +#: model:ir.model,name:mrp_repair_discount.model_mrp_repair_line +msgid "Repair Line" +msgstr "" + +#. module: mrp_repair_discount +#: model:ir.model,name:mrp_repair_discount.model_mrp_repair +msgid "Repair Order" +msgstr "Remonto užsakymas" diff --git a/repair_discount/i18n/mrp_repair_discount.pot b/repair_discount/i18n/mrp_repair_discount.pot new file mode 100644 index 000000000..30e129885 --- /dev/null +++ b/repair_discount/i18n/mrp_repair_discount.pot @@ -0,0 +1,36 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * mrp_repair_discount +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 10.0\n" +"Report-Msgid-Bugs-To: \n" +"Last-Translator: <>\n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: mrp_repair_discount +#: model:ir.model.fields,field_description:mrp_repair_discount.field_mrp_repair_fee_discount +#: model:ir.model.fields,field_description:mrp_repair_discount.field_mrp_repair_line_discount +msgid "Discount (%)" +msgstr "" + +#. module: mrp_repair_discount +#: model:ir.model,name:mrp_repair_discount.model_mrp_repair_fee +msgid "Repair Fees Line" +msgstr "" + +#. module: mrp_repair_discount +#: model:ir.model,name:mrp_repair_discount.model_mrp_repair_line +msgid "Repair Line" +msgstr "" + +#. module: mrp_repair_discount +#: model:ir.model,name:mrp_repair_discount.model_mrp_repair +msgid "Repair Order" +msgstr "" + diff --git a/repair_discount/i18n/nl_NL.po b/repair_discount/i18n/nl_NL.po new file mode 100644 index 000000000..fe21ba410 --- /dev/null +++ b/repair_discount/i18n/nl_NL.po @@ -0,0 +1,41 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * mrp_repair_discount +# +# Translators: +# Peter Hageman , 2017 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 10.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-11-28 03:44+0000\n" +"PO-Revision-Date: 2017-11-28 03:44+0000\n" +"Last-Translator: Peter Hageman , 2017\n" +"Language-Team: Dutch (Netherlands) (https://www.transifex.com/oca/" +"teams/23907/nl_NL/)\n" +"Language: nl_NL\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#. module: mrp_repair_discount +#: model:ir.model.fields,field_description:mrp_repair_discount.field_mrp_repair_fee_discount +#: model:ir.model.fields,field_description:mrp_repair_discount.field_mrp_repair_line_discount +msgid "Discount (%)" +msgstr "" + +#. module: mrp_repair_discount +#: model:ir.model,name:mrp_repair_discount.model_mrp_repair_fee +msgid "Repair Fees Line" +msgstr "" + +#. module: mrp_repair_discount +#: model:ir.model,name:mrp_repair_discount.model_mrp_repair_line +msgid "Repair Line" +msgstr "" + +#. module: mrp_repair_discount +#: model:ir.model,name:mrp_repair_discount.model_mrp_repair +msgid "Repair Order" +msgstr "Reparatieorder" diff --git a/repair_discount/models/__init__.py b/repair_discount/models/__init__.py new file mode 100644 index 000000000..a36a7886c --- /dev/null +++ b/repair_discount/models/__init__.py @@ -0,0 +1,4 @@ +# Copyright 2015 Nicola Malcontenti - Agile Business Group +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from . import mrp_repair diff --git a/repair_discount/models/mrp_repair.py b/repair_discount/models/mrp_repair.py new file mode 100644 index 000000000..071347914 --- /dev/null +++ b/repair_discount/models/mrp_repair.py @@ -0,0 +1,125 @@ +# Copyright 2015 Nicola Malcontenti - Agile Business Group +# Copyright 2016 Pedro M. Baeza +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from odoo import api, fields, models +import odoo.addons.decimal_precision as dp + + +class RepairFee(models.Model): + _inherit = 'repair.fee' + + @api.depends( + 'invoiced', + 'price_unit', + 'repair_id', + 'product_uom_qty', + 'product_id') + def _compute_price_subtotal(self): + for record in self: + taxes = self.env['account.tax'].compute_all( + record.price_unit, record.repair_id.pricelist_id.currency_id, + record.product_uom_qty, record.product_id, + record.repair_id.partner_id + ) + + record.price_subtotal = ( + taxes['total_excluded'] * (1 - (record.discount or 0.0) / 100.0) + ) + + discount = fields.Float(string='Discount (%)') + price_subtotal = fields.Float( + 'Subtotal', + compute='_compute_price_subtotal', + digits=dp.get_precision('Account')) + + +class RepairLine(models.Model): + _inherit = 'repair.line' + + @api.depends( + 'invoiced', + 'price_unit', + 'repair_id', + 'product_uom_qty', + 'product_id') + def _compute_price_subtotal(self): + for repair_line in self: + taxes = self.env['account.tax'].compute_all( + repair_line.price_unit, + repair_line.repair_id.pricelist_id.currency_id, + repair_line.product_uom_qty, repair_line.product_id, + repair_line.repair_id.partner_id + ) + repair_line.price_subtotal = ( + taxes['total_excluded'] * (1 - (repair_line.discount or 0.0) / 100.0) + ) + + discount = fields.Float(string='Discount (%)') + price_subtotal = fields.Float( + 'Subtotal', + compute='_compute_price_subtotal', + digits=dp.get_precision('Account')) + + +class RepairOrder(models.Model): + _inherit = 'repair.order' + + @api.multi + def action_invoice_create(self, group=False): + res = super(RepairOrder, self).action_invoice_create(group) + for repair in self.filtered( + lambda _repair: _repair.invoice_method != 'none' + ): + operations = repair.operations + fees_lines = repair.fees_lines + + for op in operations.filtered( + lambda item: item.invoice_line_id + ): + op.invoice_line_id.discount = op.discount + if operations: + repair.invoice_id.compute_taxes() + + for fee_lines in fees_lines.filtered( + lambda item: item.invoice_line_id + ): + fee_lines.invoice_line_id.discount = fee_lines.discount + if fees_lines: + repair.invoice_id.compute_taxes() + + return res + + def _calculate_line_base_price(self, line): + return line.price_unit * (1 - (line.discount or 0.0) / 100.0) + + @api.depends('operations', 'fees_lines', 'operations.invoiced', + 'fees_lines.invoiced') + def _amount_tax(self): + for repair in self: + taxed_amount = 0.0 + currency = repair.pricelist_id.currency_id + + for line in repair.operations: + tax_calculate = line.tax_id.compute_all( + self._calculate_line_base_price(line), + self.pricelist_id.currency_id, + line.product_uom_qty, + line.product_id, + repair.partner_id + ) + + for c in tax_calculate['taxes']: + taxed_amount += c['amount'] + + for line in repair.fees_lines: + tax_calculate = line.tax_id.compute_all( + self._calculate_line_base_price(line), + self.pricelist_id.currency_id, + line.product_uom_qty, + line.product_id, + repair.partner_id) + for c in tax_calculate['taxes']: + taxed_amount += c['amount'] + + repair.amount_tax = currency.round(taxed_amount) diff --git a/repair_discount/readme/CONTRIBUTORS.rst b/repair_discount/readme/CONTRIBUTORS.rst new file mode 100644 index 000000000..0ed494164 --- /dev/null +++ b/repair_discount/readme/CONTRIBUTORS.rst @@ -0,0 +1,5 @@ +* Nicola Malcontenti +* Pedro M. Baeza +* Lorenzo Battistini +* Ignacio Ales López +* María Asunción Daza diff --git a/repair_discount/readme/DESCRIPTION.rst b/repair_discount/readme/DESCRIPTION.rst new file mode 100644 index 000000000..f30da6f96 --- /dev/null +++ b/repair_discount/readme/DESCRIPTION.rst @@ -0,0 +1,2 @@ +This module extends the functionality of mrp repair adding +new field discount on operations lines diff --git a/repair_discount/static/description/icon.png b/repair_discount/static/description/icon.png new file mode 100644 index 000000000..3a0328b51 Binary files /dev/null and b/repair_discount/static/description/icon.png differ diff --git a/repair_discount/static/description/index.html b/repair_discount/static/description/index.html new file mode 100644 index 000000000..4bb4ebe7d --- /dev/null +++ b/repair_discount/static/description/index.html @@ -0,0 +1,424 @@ + + + + + + +MRP Repair Discount + + + +
+

MRP Repair Discount

+ + +

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

+

This module extends the functionality of mrp repair adding +new field discount on operations lines

+

Table of contents

+ +
+

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

+
    +
  • Agile Business Group
  • +
  • Tecnativa
  • +
+
+
+

Contributors

+ +
+
+

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_discount/tests/__init__.py b/repair_discount/tests/__init__.py new file mode 100644 index 000000000..ebd10d3b0 --- /dev/null +++ b/repair_discount/tests/__init__.py @@ -0,0 +1,3 @@ +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from . import test_mrp_repair_discount diff --git a/repair_discount/tests/test_mrp_repair_discount.py b/repair_discount/tests/test_mrp_repair_discount.py new file mode 100644 index 000000000..66738fca4 --- /dev/null +++ b/repair_discount/tests/test_mrp_repair_discount.py @@ -0,0 +1,76 @@ +# Copyright 2016 Pedro M. Baeza +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from odoo.tests import common + + +class TestMrpRepairDiscount(common.SavepointCase): + @classmethod + def setUpClass(cls): + super(TestMrpRepairDiscount, cls).setUpClass() + cls.product = cls.env['product.product'].create({ + 'name': 'Test product', + 'standard_price': 10, + 'list_price': 20, + }) + cls.product_service = cls.env['product.product'].create({ + 'name': 'Test product service', + 'standard_price': 10, + 'list_price': 20, + }) + # cls.partner = cls.env['res.partner'].create({ + # 'name': 'Test partner', + # }) + 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': 'b4repair', + }) + 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': 20, + 'discount': 50, + }) + + cls.repair_fee = cls.env['repair.fee'].create({ + 'repair_id': cls.repair.id, + 'name': 'Test Service', + 'product_id': cls.product_service.id, + 'product_uom_qty': 1, + 'product_uom': cls.product_service.uom_id.id, + 'price_unit': 20, + 'discount': 50, + }) + + def test_discount(self): + self.assertAlmostEqual( + self.repair_line.price_subtotal, 10) + self.assertAlmostEqual( + self.repair_fee.price_subtotal, 10) + self.assertAlmostEqual( + self.repair.amount_total, 20) + + def test_invoice_create(self): + self.repair.state = '2binvoiced' + res = self.repair.action_invoice_create() + invoice = self.env['account.invoice'].browse(res.values())[0] + invoice_line = invoice.invoice_line_ids[0] + self.assertEqual(invoice_line.discount, 50) + self.assertAlmostEqual( + invoice_line.price_subtotal, 10) diff --git a/repair_discount/views/mrp_repair_view.xml b/repair_discount/views/mrp_repair_view.xml new file mode 100644 index 000000000..ed7d01a16 --- /dev/null +++ b/repair_discount/views/mrp_repair_view.xml @@ -0,0 +1,16 @@ + + + + repair.discount.form + repair.order + + + + + + + + + + +