From 922d1727533d9436c0b530db5128501ed888a66a Mon Sep 17 00:00:00 2001 From: David Date: Tue, 27 Aug 2019 14:14:16 +0200 Subject: [PATCH 01/34] [ADD][11.0] purchase_order_general_discount: New Module --- purchase_order_general_discount/README.rst | 120 +++++ purchase_order_general_discount/__init__.py | 1 + .../__manifest__.py | 22 + purchase_order_general_discount/i18n/es.po | 107 ++++ .../i18n/purchase_order_general_discount.pot | 101 ++++ .../models/__init__.py | 4 + .../models/purchase_order.py | 73 +++ .../models/res_company.py | 32 ++ .../models/res_config_settings.py | 13 + .../models/res_partner.py | 15 + .../readme/CONFIGURE.rst | 21 + .../readme/CONTRIBUTORS.rst | 5 + .../readme/DESCRIPTION.rst | 5 + .../readme/USAGE.rst | 10 + .../static/description/icon.png | Bin 0 -> 9455 bytes .../static/description/index.html | 468 ++++++++++++++++++ .../tests/__init__.py | 1 + .../test_purchase_order_general_discount.py | 71 +++ .../views/purchase_order_view.xml | 20 + .../views/res_config_view.xml | 30 ++ .../views/res_partner_view.xml | 17 + 21 files changed, 1136 insertions(+) create mode 100644 purchase_order_general_discount/README.rst create mode 100644 purchase_order_general_discount/__init__.py create mode 100644 purchase_order_general_discount/__manifest__.py create mode 100644 purchase_order_general_discount/i18n/es.po create mode 100644 purchase_order_general_discount/i18n/purchase_order_general_discount.pot create mode 100644 purchase_order_general_discount/models/__init__.py create mode 100644 purchase_order_general_discount/models/purchase_order.py create mode 100644 purchase_order_general_discount/models/res_company.py create mode 100644 purchase_order_general_discount/models/res_config_settings.py create mode 100644 purchase_order_general_discount/models/res_partner.py create mode 100644 purchase_order_general_discount/readme/CONFIGURE.rst create mode 100644 purchase_order_general_discount/readme/CONTRIBUTORS.rst create mode 100644 purchase_order_general_discount/readme/DESCRIPTION.rst create mode 100644 purchase_order_general_discount/readme/USAGE.rst create mode 100644 purchase_order_general_discount/static/description/icon.png create mode 100644 purchase_order_general_discount/static/description/index.html create mode 100644 purchase_order_general_discount/tests/__init__.py create mode 100644 purchase_order_general_discount/tests/test_purchase_order_general_discount.py create mode 100644 purchase_order_general_discount/views/purchase_order_view.xml create mode 100644 purchase_order_general_discount/views/res_config_view.xml create mode 100644 purchase_order_general_discount/views/res_partner_view.xml diff --git a/purchase_order_general_discount/README.rst b/purchase_order_general_discount/README.rst new file mode 100644 index 00000000000..8d530815245 --- /dev/null +++ b/purchase_order_general_discount/README.rst @@ -0,0 +1,120 @@ +=============================== +Purchase Order General 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%2Fpurchase--workflow-lightgray.png?logo=github + :target: https://github.com/OCA/purchase-workflow/tree/11.0/purchase_order_general_discount + :alt: OCA/purchase-workflow +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/purchase-workflow-11-0/purchase-workflow-11-0-purchase_order_general_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/142/11.0 + :alt: Try me on Runbot + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module allows to set a general discount in a purchase order. This general +discount is applied to each line order. + +You can also set a default general discount on suppliers and configure to wich +line field the discount will be applied. + +**Table of contents** + +.. contents:: + :local: + +Configuration +============= + +You can set in settings another discount field to be applied. +For example, if we had `purchase_triple_discount`, we could set the general +discount in discount3 to be applied after all other discounts. + +To do so: + +#. Go to *Purchases > Configuration > Settings* and *Purchase Discount Field* +#. Select the discount you'd wish to use. `purchase_triple_discount` fields + will appear when the module is installed. + +There's a method at `res.company` called `_get_purchase_discount_fields` that +can be used to extend more line discount fields. For example, if we had the +field `discount4`, we could extend it like this: + +.. code-block:: python + + @api.model + def _get_purchase_discount_fields(self): + discount_fields = super()._get_purchase_discount_fields() + discount_fields += [('discount4', _('Discount 4'))] + return discount_fields + +Usage +===== + +To set a partner default general discount you need to: + +#. Go to a partner and set the general discount in *Sales & Purchases* tab. + +To set a general discount in a purchase order you need to: + +#. Create a purchase order. +#. Either select a partner with a purchase general discount defined or set one + in the summary section of the order. +#. This discount will be applied to every line. + +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 +~~~~~~~ + +* Tecnativa + +Contributors +~~~~~~~~~~~~ + +* `Tecnativa `_: + + * David Vidal + * Pedro M. Baeza + * Rafael Blasco + +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/purchase-workflow `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/purchase_order_general_discount/__init__.py b/purchase_order_general_discount/__init__.py new file mode 100644 index 00000000000..0650744f6bc --- /dev/null +++ b/purchase_order_general_discount/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/purchase_order_general_discount/__manifest__.py b/purchase_order_general_discount/__manifest__.py new file mode 100644 index 00000000000..409f62900c7 --- /dev/null +++ b/purchase_order_general_discount/__manifest__.py @@ -0,0 +1,22 @@ +# Copyright 2019 Tecnativa - David Vidal +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +{ + 'name': 'Purchase Order General Discount', + 'summary': 'General discount per purchase order', + 'version': '11.0.1.0.0', + 'category': 'Purchases', + 'website': 'https://github.com/OCA/purchase-workflow', + 'author': 'Tecnativa, ' + 'Odoo Community Association (OCA)', + 'license': 'AGPL-3', + 'application': False, + 'installable': True, + 'depends': [ + 'purchase_discount', + ], + 'data': [ + 'views/purchase_order_view.xml', + 'views/res_partner_view.xml', + 'views/res_config_view.xml', + ], +} diff --git a/purchase_order_general_discount/i18n/es.po b/purchase_order_general_discount/i18n/es.po new file mode 100644 index 00000000000..a4aebf055be --- /dev/null +++ b/purchase_order_general_discount/i18n/es.po @@ -0,0 +1,107 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * purchase_order_general_discount +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 11.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2019-08-28 12:50+0000\n" +"PO-Revision-Date: 2019-08-28 12:50+0000\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: purchase_order_general_discount +#: model:ir.ui.view,arch_db:purchase_order_general_discount.res_config_settings_view_form_purchase +msgid "" +msgstr "" + +#. module: purchase_order_general_discount +#: model:ir.model,name:purchase_order_general_discount.model_res_company +msgid "Companies" +msgstr "Compañías" + +#. module: purchase_order_general_discount +#: model:ir.model,name:purchase_order_general_discount.model_res_partner +msgid "Contact" +msgstr "Contacto" + +#. module: purchase_order_general_discount +#: code:addons/purchase_order_general_discount/models/res_company.py:22 +#, python-format +msgid "Discount" +msgstr "Descuento" + +#. module: purchase_order_general_discount +#: code:addons/purchase_order_general_discount/models/res_company.py:27 +#, python-format +msgid "Discount 2" +msgstr "Descuento 2" + +#. module: purchase_order_general_discount +#: code:addons/purchase_order_general_discount/models/res_company.py:28 +#, python-format +msgid "Discount 3" +msgstr "Descuento 3" + +#. module: purchase_order_general_discount +#: sql_constraint:purchase.order:0 +msgid "Discount must be lower than 100%." +msgstr "El descuento debe ser menor del 100%." + +#. module: purchase_order_general_discount +#: model:ir.ui.view,arch_db:purchase_order_general_discount.res_config_settings_view_form_purchase +msgid "Field" +msgstr "Campo" + +#. module: purchase_order_general_discount +#: model:ir.model.fields,field_description:purchase_order_general_discount.field_purchase_order_general_discount +msgid "Gen. Disc. (%)" +msgstr "Desc. Gen. (%)" + +#. module: purchase_order_general_discount +#: model:ir.model.fields,field_description:purchase_order_general_discount.field_res_company_purchase_general_discount_field +#: model:ir.model.fields,field_description:purchase_order_general_discount.field_res_config_settings_purchase_general_discount_field +msgid "Purchase Discount Field" +msgstr "Campo para Descuento General de compra" + +#. module: purchase_order_general_discount +#: model:ir.model.fields,field_description:purchase_order_general_discount.field_res_partner_purchase_general_discount +#: model:ir.model.fields,field_description:purchase_order_general_discount.field_res_users_purchase_general_discount +msgid "Purchase General Discount (%)" +msgstr "Descuento General de Compra (%)" + +#. module: purchase_order_general_discount +#: model:ir.model,name:purchase_order_general_discount.model_purchase_order +msgid "Purchase Order" +msgstr "Pedido de compra" + +#. module: purchase_order_general_discount +#: model:ir.model,name:purchase_order_general_discount.model_purchase_order_line +msgid "Purchase Order Line" +msgstr "Línea de pedido de compra" + +#. module: purchase_order_general_discount +#: model:ir.ui.view,arch_db:purchase_order_general_discount.res_config_settings_view_form_purchase +msgid "Select to which purchase line field will the purchase general discount be propagated." +msgstr "Escoja a qué campo del descuento de la línea de pedido se propagará el descuento general." + +#. module: purchase_order_general_discount +#: model:ir.model.fields,help:purchase_order_general_discount.field_res_company_purchase_general_discount_field +#: model:ir.model.fields,help:purchase_order_general_discount.field_res_config_settings_purchase_general_discount_field +msgid "Set the purchase line discount field in wich the discounts will be applied." +msgstr "Establecer el campo de descuento de la línea de pedido en el que se aplicará el descuento." + +#. module: purchase_order_general_discount +#: model:ir.ui.view,arch_db:purchase_order_general_discount.purchase_order_form +msgid "Update general discounts" +msgstr "Actualizar descuento general" + +#. module: purchase_order_general_discount +#: model:ir.model,name:purchase_order_general_discount.model_res_config_settings +msgid "res.config.settings" +msgstr "res.config.settings" diff --git a/purchase_order_general_discount/i18n/purchase_order_general_discount.pot b/purchase_order_general_discount/i18n/purchase_order_general_discount.pot new file mode 100644 index 00000000000..960a61de366 --- /dev/null +++ b/purchase_order_general_discount/i18n/purchase_order_general_discount.pot @@ -0,0 +1,101 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * purchase_order_general_discount +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 11.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: purchase_order_general_discount +#: model:ir.ui.view,arch_db:purchase_order_general_discount.res_config_settings_view_form_purchase +msgid "" +msgstr "" + +#. module: purchase_order_general_discount +#: model:ir.model,name:purchase_order_general_discount.model_res_company +msgid "Companies" +msgstr "" + +#. module: purchase_order_general_discount +#: model:ir.model,name:purchase_order_general_discount.model_res_partner +msgid "Contact" +msgstr "" + +#. module: purchase_order_general_discount +#: code:addons/purchase_order_general_discount/models/res_company.py:22 +#, python-format +msgid "Discount" +msgstr "" + +#. module: purchase_order_general_discount +#: code:addons/purchase_order_general_discount/models/res_company.py:26 +#, python-format +msgid "Discount 2" +msgstr "" + +#. module: purchase_order_general_discount +#: code:addons/purchase_order_general_discount/models/res_company.py:30 +#, python-format +msgid "Discount 3" +msgstr "" + +#. module: purchase_order_general_discount +#: sql_constraint:purchase.order:0 +msgid "Discount must be lower than 100%." +msgstr "" + +#. module: purchase_order_general_discount +#: model:ir.ui.view,arch_db:purchase_order_general_discount.res_config_settings_view_form_purchase +msgid "Field" +msgstr "" + +#. module: purchase_order_general_discount +#: model:ir.model.fields,field_description:purchase_order_general_discount.field_purchase_order_general_discount +msgid "Gen. Disc. (%)" +msgstr "" + +#. module: purchase_order_general_discount +#: model:ir.model.fields,field_description:purchase_order_general_discount.field_res_company_purchase_general_discount_field +#: model:ir.model.fields,field_description:purchase_order_general_discount.field_res_config_settings_purchase_general_discount_field +msgid "Purchase Discount Field" +msgstr "" + +#. module: purchase_order_general_discount +#: model:ir.model.fields,field_description:purchase_order_general_discount.field_res_partner_purchase_general_discount +#: model:ir.model.fields,field_description:purchase_order_general_discount.field_res_users_purchase_general_discount +msgid "Purchase General Discount (%)" +msgstr "" + +#. module: purchase_order_general_discount +#: model:ir.model,name:purchase_order_general_discount.model_purchase_order +msgid "Purchase Order" +msgstr "" + +#. module: purchase_order_general_discount +#: model:ir.ui.view,arch_db:purchase_order_general_discount.res_config_settings_view_form_purchase +msgid "Select to which purchase line field will the purchase general discount be propagated." +msgstr "" + +#. module: purchase_order_general_discount +#: model:ir.model.fields,help:purchase_order_general_discount.field_res_company_purchase_general_discount_field +#: model:ir.model.fields,help:purchase_order_general_discount.field_res_config_settings_purchase_general_discount_field +msgid "Set the purchase line discount field in wich the discounts will be applied." +msgstr "" + +#. module: purchase_order_general_discount +#: model:ir.ui.view,arch_db:purchase_order_general_discount.purchase_order_form +msgid "Update general discounts" +msgstr "" + +#. module: purchase_order_general_discount +#: model:ir.model,name:purchase_order_general_discount.model_res_config_settings +msgid "res.config.settings" +msgstr "" + diff --git a/purchase_order_general_discount/models/__init__.py b/purchase_order_general_discount/models/__init__.py new file mode 100644 index 00000000000..eba22b70df1 --- /dev/null +++ b/purchase_order_general_discount/models/__init__.py @@ -0,0 +1,4 @@ +from . import purchase_order +from . import res_company +from . import res_config_settings +from . import res_partner diff --git a/purchase_order_general_discount/models/purchase_order.py b/purchase_order_general_discount/models/purchase_order.py new file mode 100644 index 00000000000..01c125e7da6 --- /dev/null +++ b/purchase_order_general_discount/models/purchase_order.py @@ -0,0 +1,73 @@ +# Copyright 2019 Tecnativa - David Vidal +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +from odoo import api, fields, models +from odoo.addons import decimal_precision as dp +from lxml import etree + + +class PurchaseOrder(models.Model): + _inherit = 'purchase.order' + + general_discount = fields.Float( + digits=dp.get_precision('Discount'), + string='Gen. Disc. (%)', + ) + + _sql_constraints = [ + ('general_discount_limit', 'CHECK (general_discount <= 100.0)', + 'Discount must be lower than 100%.'), + ] + + @api.onchange('partner_id') + def onchange_partner_id(self): + super().onchange_partner_id() + self.general_discount = ( + self.partner_id.commercial_partner_id.purchase_general_discount) + + def _get_general_discount_field(self): + """We can set in settings another discount field to be applied + For example, if we had purchase_triple_dicount, we could set the + general discount in discount3 to be applied after all other + discounts""" + discount_field = self.company_id.purchase_general_discount_field + return discount_field or 'discount' + + @api.onchange('general_discount') + def onchange_general_discount(self): + discount_field = self._get_general_discount_field() + self.mapped('order_line').update({ + discount_field: self.general_discount, + }) + + def action_update_general_discount(self): + for order in self: + order.onchange_general_discount() + + @api.model + def fields_view_get(self, view_id=None, view_type='form', toolbar=False, + submenu=False): + """The purpose of this is to write a context on "order_line" field + respecting other contexts on this field. + There is a PR (https://github.com/odoo/odoo/pull/26607) to odoo for + avoiding this. If merged, remove this method and add the attribute + in the field. + """ + res = super().fields_view_get( + view_id=view_id, view_type=view_type, toolbar=toolbar, + submenu=submenu, + ) + if view_type == 'form': + discount_field = self._get_general_discount_field() + order_xml = etree.XML(res['arch']) + order_line_fields = order_xml.xpath("//field[@name='order_line']") + if order_line_fields: + order_line_field = order_line_fields[0] + context = order_line_field.attrib.get("context", "{}").replace( + "{", + "{{'default_{}': general_discount, ".format( + discount_field), + 1, + ) + order_line_field.attrib['context'] = context + res['arch'] = etree.tostring(order_xml) + return res diff --git a/purchase_order_general_discount/models/res_company.py b/purchase_order_general_discount/models/res_company.py new file mode 100644 index 00000000000..bde95519c1a --- /dev/null +++ b/purchase_order_general_discount/models/res_company.py @@ -0,0 +1,32 @@ +# Copyright 2019 Tecnativa - David Vidal +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +from odoo import _, api, fields, models + + +class ResCompany(models.Model): + _inherit = "res.company" + + purchase_general_discount_field = fields.Selection( + selection='_get_purchase_discount_fields', + string='Purchase Discount Field', + default='discount', + help='Set the purchase line discount field in wich the ' + 'discounts will be applied.', + ) + + @api.model + def _get_purchase_discount_fields(self): + """Extensible method to add possible discounts. We offer in advance + the posibility of using purchase_triple_discount so no bridge + module is needed """ + discount_fields = [('discount', _('Discount'))] + purchase_line_fields = self.env['purchase.order.line']._fields.keys() + if 'discount2' in purchase_line_fields: + discount_fields += [ + ('discount2', _('Discount 2')), + ] + if 'discount3' in purchase_line_fields: + discount_fields += [ + ('discount3', _('Discount 3')), + ] + return discount_fields diff --git a/purchase_order_general_discount/models/res_config_settings.py b/purchase_order_general_discount/models/res_config_settings.py new file mode 100644 index 00000000000..2f8512d639e --- /dev/null +++ b/purchase_order_general_discount/models/res_config_settings.py @@ -0,0 +1,13 @@ +# Copyright 2019 Tecnativa - David Vidal +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +from odoo import fields, models + + +class ResConfigSettings(models.TransientModel): + _inherit = 'res.config.settings' + + purchase_general_discount_field = fields.Selection( + related='company_id.purchase_general_discount_field', + default='discount', + readonly=False, + ) diff --git a/purchase_order_general_discount/models/res_partner.py b/purchase_order_general_discount/models/res_partner.py new file mode 100644 index 00000000000..68b04b0cd31 --- /dev/null +++ b/purchase_order_general_discount/models/res_partner.py @@ -0,0 +1,15 @@ +# Copyright 2019 Tecnativa - David Vidal +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo import fields, models +from odoo.addons import decimal_precision as dp + + +class ResPartner(models.Model): + _inherit = 'res.partner' + + purchase_general_discount = fields.Float( + digits=dp.get_precision('Discount'), + string='Purchase General Discount (%)', + company_dependent=True, + ) diff --git a/purchase_order_general_discount/readme/CONFIGURE.rst b/purchase_order_general_discount/readme/CONFIGURE.rst new file mode 100644 index 00000000000..db68567f6e1 --- /dev/null +++ b/purchase_order_general_discount/readme/CONFIGURE.rst @@ -0,0 +1,21 @@ +You can set in settings another discount field to be applied. +For example, if we had `purchase_triple_discount`, we could set the general +discount in discount3 to be applied after all other discounts. + +To do so: + +#. Go to *Purchases > Configuration > Settings* and *Purchase Discount Field* +#. Select the discount you'd wish to use. `purchase_triple_discount` fields + will appear when the module is installed. + +There's a method at `res.company` called `_get_purchase_discount_fields` that +can be used to extend more line discount fields. For example, if we had the +field `discount4`, we could extend it like this: + +.. code-block:: python + + @api.model + def _get_purchase_discount_fields(self): + discount_fields = super()._get_purchase_discount_fields() + discount_fields += [('discount4', _('Discount 4'))] + return discount_fields diff --git a/purchase_order_general_discount/readme/CONTRIBUTORS.rst b/purchase_order_general_discount/readme/CONTRIBUTORS.rst new file mode 100644 index 00000000000..e338bbfbb64 --- /dev/null +++ b/purchase_order_general_discount/readme/CONTRIBUTORS.rst @@ -0,0 +1,5 @@ +* `Tecnativa `_: + + * David Vidal + * Pedro M. Baeza + * Rafael Blasco diff --git a/purchase_order_general_discount/readme/DESCRIPTION.rst b/purchase_order_general_discount/readme/DESCRIPTION.rst new file mode 100644 index 00000000000..f4907d504df --- /dev/null +++ b/purchase_order_general_discount/readme/DESCRIPTION.rst @@ -0,0 +1,5 @@ +This module allows to set a general discount in a purchase order. This general +discount is applied to each line order. + +You can also set a default general discount on suppliers and configure to wich +line field the discount will be applied. diff --git a/purchase_order_general_discount/readme/USAGE.rst b/purchase_order_general_discount/readme/USAGE.rst new file mode 100644 index 00000000000..6abfbb84d86 --- /dev/null +++ b/purchase_order_general_discount/readme/USAGE.rst @@ -0,0 +1,10 @@ +To set a partner default general discount you need to: + +#. Go to a partner and set the general discount in *Sales & Purchases* tab. + +To set a general discount in a purchase order you need to: + +#. Create a purchase order. +#. Either select a partner with a purchase general discount defined or set one + in the summary section of the order. +#. This discount will be applied to every line. diff --git a/purchase_order_general_discount/static/description/icon.png b/purchase_order_general_discount/static/description/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..3a0328b516c4980e8e44cdb63fd945757ddd132d GIT binary patch literal 9455 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TB(G`PTZaDiGBo5o(tp)qli|NeV( z@H_=R8V39rt5J5YB2Ky?4eJJ#b`_iBe2ot~6%7mLt5t8Vwi^Jy7|jWXqa3amOIoRb zOr}WVFP--DsS`1WpN%~)t3R!arKF^Q$e12KEqU36AWwnCBICpH4XCsfnyrHr>$I$4 z!DpKX$OKLWarN7nv@!uIA+~RNO)l$$w}p(;b>mx8pwYvu;dD_unryX_NhT8*Tj>BTrTTL&!?O+%Rv;b?B??gSzdp?6Uug9{ zd@V08Z$BdI?fpoCS$)t4mg4rT8Q_I}h`0d-vYZ^|dOB*Q^S|xqTV*vIg?@fVFSmMpaw0qtTRbx} z({Pg?#{2`sc9)M5N$*N|4;^t$+QP?#mov zGVC@I*lBVrOU-%2y!7%)fAKjpEFsgQc4{amtiHb95KQEwvf<(3T<9-Zm$xIew#P22 zc2Ix|App^>v6(3L_MCU0d3W##AB0M~3D00EWoKZqsJYT(#@w$Y_H7G22M~ApVFTRHMI_3be)Lkn#0F*V8Pq zc}`Cjy$bE;FJ6H7p=0y#R>`}-m4(0F>%@P|?7fx{=R^uFdISRnZ2W_xQhD{YuR3t< z{6yxu=4~JkeA;|(J6_nv#>Nvs&FuLA&PW^he@t(UwFFE8)|a!R{`E`K`i^ZnyE4$k z;(749Ix|oi$c3QbEJ3b~D_kQsPz~fIUKym($a_7dJ?o+40*OLl^{=&oq$<#Q(yyrp z{J-FAniyAw9tPbe&IhQ|a`DqFTVQGQ&Gq3!C2==4x{6EJwiPZ8zub-iXoUtkJiG{} zPaR&}_fn8_z~(=;5lD-aPWD3z8PZS@AaUiomF!G8I}Mf>e~0g#BelA-5#`cj;O5>N Xviia!U7SGha1wx#SCgwmn*{w2TRX*I literal 0 HcmV?d00001 diff --git a/purchase_order_general_discount/static/description/index.html b/purchase_order_general_discount/static/description/index.html new file mode 100644 index 00000000000..8bd91aa68af --- /dev/null +++ b/purchase_order_general_discount/static/description/index.html @@ -0,0 +1,468 @@ + + + + + + +Purchase Order General Discount + + + +
+

Purchase Order General Discount

+ + +

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

+

This module allows to set a general discount in a purchase order. This general +discount is applied to each line order.

+

You can also set a default general discount on suppliers and configure to wich +line field the discount will be applied.

+

Table of contents

+ +
+

Configuration

+

You can set in settings another discount field to be applied. +For example, if we had purchase_triple_discount, we could set the general +discount in discount3 to be applied after all other discounts.

+

To do so:

+
    +
  1. Go to Purchases > Configuration > Settings and Purchase Discount Field
  2. +
  3. Select the discount you’d wish to use. purchase_triple_discount fields +will appear when the module is installed.
  4. +
+

There’s a method at res.company called _get_purchase_discount_fields that +can be used to extend more line discount fields. For example, if we had the +field discount4, we could extend it like this:

+
+@api.model
+def _get_purchase_discount_fields(self):
+    discount_fields = super()._get_purchase_discount_fields()
+    discount_fields += [('discount4', _('Discount 4'))]
+    return discount_fields
+
+
+
+

Usage

+

To set a partner default general discount you need to:

+
    +
  1. Go to a partner and set the general discount in Sales & Purchases tab.
  2. +
+

To set a general discount in a purchase order you need to:

+
    +
  1. Create a purchase order.
  2. +
  3. Either select a partner with a purchase general discount defined or set one +in the summary section of the order.
  4. +
  5. This discount will be applied to every line.
  6. +
+
+
+

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

+
    +
  • Tecnativa
  • +
+
+
+

Contributors

+
    +
  • Tecnativa:

    +
    +
      +
    • David Vidal
    • +
    • Pedro M. Baeza
    • +
    • Rafael Blasco
    • +
    +
    +
  • +
+
+
+

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/purchase-workflow project on GitHub.

+

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

+
+
+
+ + diff --git a/purchase_order_general_discount/tests/__init__.py b/purchase_order_general_discount/tests/__init__.py new file mode 100644 index 00000000000..f51e1fb3d51 --- /dev/null +++ b/purchase_order_general_discount/tests/__init__.py @@ -0,0 +1 @@ +from . import test_purchase_order_general_discount diff --git a/purchase_order_general_discount/tests/test_purchase_order_general_discount.py b/purchase_order_general_discount/tests/test_purchase_order_general_discount.py new file mode 100644 index 00000000000..6bf44e3d672 --- /dev/null +++ b/purchase_order_general_discount/tests/test_purchase_order_general_discount.py @@ -0,0 +1,71 @@ +# Copyright 2019 Tecnativa - David Vidal +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +from odoo.tests import SavepointCase +from odoo import fields +from lxml import etree + + +class TestPurchaseOrderLineInput(SavepointCase): + + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.partner = cls.env['res.partner'].create({ + 'name': 'Test', + 'purchase_general_discount': 10.0, + }) + cls.product = cls.env['product.product'].create({ + 'name': 'test_product', + 'type': 'service', + }) + cls.order = cls.env['purchase.order'].create({ + 'partner_id': cls.partner.id, + 'order_line': [(0, 0, { + 'date_planned': fields.Datetime.now(), + 'name': cls.product.name, + 'product_id': cls.product.id, + 'product_qty': 1, + 'product_uom': cls.product.uom_id.id, + 'price_unit': 1000.00, + })], + }) + cls.View = cls.env['ir.ui.view'] + + def test_01_default_partner_discount(self): + self.order.onchange_partner_id() + self.assertEqual(self.order.general_discount, + self.partner.purchase_general_discount) + + def test_02_sale_order_values(self): + self.order.general_discount = 10 + self.order.action_update_general_discount() + self.assertEqual(self.order.order_line.price_subtotal, 900.00) + + def _get_ctx_from_view(self, res): + order_xml = etree.XML(res['arch']) + order_line_path = "//field[@name='order_line']" + order_line_field = order_xml.xpath(order_line_path)[0] + return order_line_field.attrib.get("context", "{}") + + def test_03_default_line_discount_value(self): + res = self.order.fields_view_get( + view_id=self.env.ref('purchase_order_general_discount.' + 'purchase_order_form').id, + view_type='form') + ctx = self._get_ctx_from_view(res) + self.assertTrue('default_discount' in ctx) + view = self.View.create({ + 'name': "test", + 'type': "form", + 'model': 'purchase.order', + 'arch': """ + + + + + """ + }) + res = self.order.fields_view_get(view_id=view.id, view_type='form') + ctx = self._get_ctx_from_view(res) + self.assertTrue('default_discount' in ctx) diff --git a/purchase_order_general_discount/views/purchase_order_view.xml b/purchase_order_general_discount/views/purchase_order_view.xml new file mode 100644 index 00000000000..bea8f7e9a23 --- /dev/null +++ b/purchase_order_general_discount/views/purchase_order_view.xml @@ -0,0 +1,20 @@ + + + + + + purchase.order + + + + + + + + + + diff --git a/purchase_order_general_discount/views/res_config_view.xml b/purchase_order_general_discount/views/res_config_view.xml new file mode 100644 index 00000000000..fe90ea03b99 --- /dev/null +++ b/purchase_order_general_discount/views/res_config_view.xml @@ -0,0 +1,30 @@ + + + + + + res.config.settings + + + +
+
+
+
+
+
+
+ +
diff --git a/purchase_order_general_discount/views/res_partner_view.xml b/purchase_order_general_discount/views/res_partner_view.xml new file mode 100644 index 00000000000..bb844174ce5 --- /dev/null +++ b/purchase_order_general_discount/views/res_partner_view.xml @@ -0,0 +1,17 @@ + + + + + + res.partner + + + + + + + + + From 225efcf19d462ef6d7532bd011d050ac9c440965 Mon Sep 17 00:00:00 2001 From: David Date: Wed, 4 Sep 2019 17:42:03 +0200 Subject: [PATCH 02/34] [FIX] purchase_order_general_discount: ui fixes - Update icon - Place before amount untaxed --- .../__manifest__.py | 2 +- purchase_order_general_discount/i18n/es.po | 38 ++++++++++++------- .../views/purchase_order_view.xml | 6 +-- 3 files changed, 28 insertions(+), 18 deletions(-) diff --git a/purchase_order_general_discount/__manifest__.py b/purchase_order_general_discount/__manifest__.py index 409f62900c7..19e621431cd 100644 --- a/purchase_order_general_discount/__manifest__.py +++ b/purchase_order_general_discount/__manifest__.py @@ -3,7 +3,7 @@ { 'name': 'Purchase Order General Discount', 'summary': 'General discount per purchase order', - 'version': '11.0.1.0.0', + 'version': '11.0.1.1.0', 'category': 'Purchases', 'website': 'https://github.com/OCA/purchase-workflow', 'author': 'Tecnativa, ' diff --git a/purchase_order_general_discount/i18n/es.po b/purchase_order_general_discount/i18n/es.po index a4aebf055be..6c742964c85 100644 --- a/purchase_order_general_discount/i18n/es.po +++ b/purchase_order_general_discount/i18n/es.po @@ -1,6 +1,6 @@ # Translation of Odoo Server. # This file contains the translation of the following modules: -# * purchase_order_general_discount +# * purchase_order_general_discount # msgid "" msgstr "" @@ -10,6 +10,7 @@ msgstr "" "PO-Revision-Date: 2019-08-28 12:50+0000\n" "Last-Translator: <>\n" "Language-Team: \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: \n" @@ -17,8 +18,12 @@ msgstr "" #. module: purchase_order_general_discount #: model:ir.ui.view,arch_db:purchase_order_general_discount.res_config_settings_view_form_purchase -msgid "" -msgstr "" +msgid "" +"" +msgstr "" +"" #. module: purchase_order_general_discount #: model:ir.model,name:purchase_order_general_discount.model_res_company @@ -37,13 +42,13 @@ msgid "Discount" msgstr "Descuento" #. module: purchase_order_general_discount -#: code:addons/purchase_order_general_discount/models/res_company.py:27 +#: code:addons/purchase_order_general_discount/models/res_company.py:26 #, python-format msgid "Discount 2" msgstr "Descuento 2" #. module: purchase_order_general_discount -#: code:addons/purchase_order_general_discount/models/res_company.py:28 +#: code:addons/purchase_order_general_discount/models/res_company.py:30 #, python-format msgid "Discount 3" msgstr "Descuento 3" @@ -80,21 +85,23 @@ msgstr "Descuento General de Compra (%)" msgid "Purchase Order" msgstr "Pedido de compra" -#. module: purchase_order_general_discount -#: model:ir.model,name:purchase_order_general_discount.model_purchase_order_line -msgid "Purchase Order Line" -msgstr "Línea de pedido de compra" - #. module: purchase_order_general_discount #: model:ir.ui.view,arch_db:purchase_order_general_discount.res_config_settings_view_form_purchase -msgid "Select to which purchase line field will the purchase general discount be propagated." -msgstr "Escoja a qué campo del descuento de la línea de pedido se propagará el descuento general." +msgid "" +"Select to which purchase line field will the purchase general discount be " +"propagated." +msgstr "" +"Escoja a qué campo del descuento de la línea de pedido se propagará el " +"descuento general." #. module: purchase_order_general_discount #: model:ir.model.fields,help:purchase_order_general_discount.field_res_company_purchase_general_discount_field #: model:ir.model.fields,help:purchase_order_general_discount.field_res_config_settings_purchase_general_discount_field -msgid "Set the purchase line discount field in wich the discounts will be applied." -msgstr "Establecer el campo de descuento de la línea de pedido en el que se aplicará el descuento." +msgid "" +"Set the purchase line discount field in wich the discounts will be applied." +msgstr "" +"Establecer el campo de descuento de la línea de pedido en el que se aplicará " +"el descuento." #. module: purchase_order_general_discount #: model:ir.ui.view,arch_db:purchase_order_general_discount.purchase_order_form @@ -105,3 +112,6 @@ msgstr "Actualizar descuento general" #: model:ir.model,name:purchase_order_general_discount.model_res_config_settings msgid "res.config.settings" msgstr "res.config.settings" + +#~ msgid "Purchase Order Line" +#~ msgstr "Línea de pedido de compra" diff --git a/purchase_order_general_discount/views/purchase_order_view.xml b/purchase_order_general_discount/views/purchase_order_view.xml index bea8f7e9a23..2b998185617 100644 --- a/purchase_order_general_discount/views/purchase_order_view.xml +++ b/purchase_order_general_discount/views/purchase_order_view.xml @@ -7,10 +7,10 @@ purchase.order - - From 1a3c8d12ae2b62e74e12d50b975f41750ec488f4 Mon Sep 17 00:00:00 2001 From: Jose Zambudio Bernabeu Date: Tue, 25 Oct 2022 10:11:25 +0200 Subject: [PATCH 14/34] [IMP] purchase_order_general_discount: black, isort, prettier --- .../models/purchase_order.py | 30 ++++++++++++------- .../models/res_company.py | 4 +-- .../models/res_config_settings.py | 3 +- 3 files changed, 23 insertions(+), 14 deletions(-) diff --git a/purchase_order_general_discount/models/purchase_order.py b/purchase_order_general_discount/models/purchase_order.py index 663fa97be9d..8bf5d82f18d 100644 --- a/purchase_order_general_discount/models/purchase_order.py +++ b/purchase_order_general_discount/models/purchase_order.py @@ -8,7 +8,10 @@ class PurchaseOrder(models.Model): _inherit = "purchase.order" - general_discount = fields.Float(digits="Discount", string="Gen. Disc. (%)",) + general_discount = fields.Float( + digits="Discount", + string="Gen. Disc. (%)", + ) _sql_constraints = [ ( @@ -27,9 +30,9 @@ def onchange_partner_id(self): def _get_general_discount_field(self): """We can set in settings another discount field to be applied - For example, if we had purchase_triple_dicount, we could set the - general discount in discount3 to be applied after all other - discounts""" + For example, if we had purchase_triple_dicount, we could set the + general discount in discount3 to be applied after all other + discounts""" discount_field = self.company_id.purchase_general_discount_field return discount_field or "discount" @@ -47,13 +50,16 @@ def fields_view_get( self, view_id=None, view_type="form", toolbar=False, submenu=False ): """The purpose of this is to write a context on "order_line" field - respecting other contexts on this field. - There is a PR (https://github.com/odoo/odoo/pull/26607) to odoo for - avoiding this. If merged, remove this method and add the attribute - in the field. - """ + respecting other contexts on this field. + There is a PR (https://github.com/odoo/odoo/pull/26607) to odoo for + avoiding this. If merged, remove this method and add the attribute + in the field. + """ res = super().fields_view_get( - view_id=view_id, view_type=view_type, toolbar=toolbar, submenu=submenu, + view_id=view_id, + view_type=view_type, + toolbar=toolbar, + submenu=submenu, ) if view_type == "form": discount_field = self._get_general_discount_field() @@ -62,7 +68,9 @@ def fields_view_get( if order_line_fields: order_line_field = order_line_fields[0] context = order_line_field.attrib.get("context", "{}").replace( - "{", "{{'default_{}': general_discount, ".format(discount_field), 1, + "{", + "{{'default_{}': general_discount, ".format(discount_field), + 1, ) order_line_field.attrib["context"] = context res["arch"] = etree.tostring(order_xml) diff --git a/purchase_order_general_discount/models/res_company.py b/purchase_order_general_discount/models/res_company.py index dc9cbc507be..789d4ac4c17 100644 --- a/purchase_order_general_discount/models/res_company.py +++ b/purchase_order_general_discount/models/res_company.py @@ -17,8 +17,8 @@ class ResCompany(models.Model): @api.model def _get_purchase_discount_fields(self): """Extensible method to add possible discounts. We offer in advance - the posibility of using purchase_triple_discount so no bridge - module is needed """ + the posibility of using purchase_triple_discount so no bridge + module is needed""" discount_fields = [("discount", _("Discount"))] purchase_line_fields = self.env["purchase.order.line"]._fields.keys() if "discount2" in purchase_line_fields: diff --git a/purchase_order_general_discount/models/res_config_settings.py b/purchase_order_general_discount/models/res_config_settings.py index 728ea23ca8c..55e163949b1 100644 --- a/purchase_order_general_discount/models/res_config_settings.py +++ b/purchase_order_general_discount/models/res_config_settings.py @@ -7,5 +7,6 @@ class ResConfigSettings(models.TransientModel): _inherit = "res.config.settings" purchase_general_discount_field = fields.Selection( - related="company_id.purchase_general_discount_field", readonly=False, + related="company_id.purchase_general_discount_field", + readonly=False, ) From c374f99a08a7048d9e91db8ff557017f5afce7da Mon Sep 17 00:00:00 2001 From: Jose Zambudio Bernabeu Date: Tue, 25 Oct 2022 10:22:15 +0200 Subject: [PATCH 15/34] [MIG] purchase_order_general_discount: Migration to 14.0 --- purchase_order_general_discount/README.rst | 9 +- .../__manifest__.py | 4 +- purchase_order_general_discount/i18n/es.po | 2 +- purchase_order_general_discount/i18n/pt.po | 2 +- .../i18n/purchase_order_general_discount.pot | 2 +- .../models/res_company.py | 2 +- .../readme/CONTRIBUTORS.rst | 5 + .../readme/DESCRIPTION.rst | 2 +- .../static/description/index.html | 1130 ++++++++++------- .../test_purchase_order_general_discount.py | 2 +- .../views/res_config_view.xml | 9 +- 11 files changed, 720 insertions(+), 449 deletions(-) diff --git a/purchase_order_general_discount/README.rst b/purchase_order_general_discount/README.rst index 52b8c25a6cf..92271d5a280 100644 --- a/purchase_order_general_discount/README.rst +++ b/purchase_order_general_discount/README.rst @@ -23,12 +23,12 @@ Purchase Order General Discount :target: https://runbot.odoo-community.org/runbot/142/13.0 :alt: Try me on Runbot -|badge1| |badge2| |badge3| |badge4| |badge5| +|badge1| |badge2| |badge3| |badge4| |badge5| This module allows to set a general discount in a purchase order. This general discount is applied to each line order. -You can also set a default general discount on suppliers and configure to wich +You can also set a default general discount on suppliers and configure to which line field the discount will be applied. **Table of contents** @@ -103,6 +103,11 @@ Contributors * Rafael Blasco * Carlos Roca +* `Aures TIC `_: + + * Jose Zambudio + * Anna Martinez + Maintainers ~~~~~~~~~~~ diff --git a/purchase_order_general_discount/__manifest__.py b/purchase_order_general_discount/__manifest__.py index 8c1c2e6d0f0..82e7bc1bc12 100644 --- a/purchase_order_general_discount/__manifest__.py +++ b/purchase_order_general_discount/__manifest__.py @@ -3,10 +3,10 @@ { "name": "Purchase Order General Discount", "summary": "General discount per purchase order", - "version": "13.0.1.0.0", + "version": "14.0.1.0.0", "category": "Purchases", "website": "https://github.com/OCA/purchase-workflow", - "author": "Tecnativa, " "Odoo Community Association (OCA)", + "author": "Tecnativa, Odoo Community Association (OCA)", "license": "AGPL-3", "application": False, "installable": True, diff --git a/purchase_order_general_discount/i18n/es.po b/purchase_order_general_discount/i18n/es.po index da94cca08c1..1e4879fd979 100644 --- a/purchase_order_general_discount/i18n/es.po +++ b/purchase_order_general_discount/i18n/es.po @@ -98,7 +98,7 @@ msgstr "" #: model:ir.model.fields,help:purchase_order_general_discount.field_res_company__purchase_general_discount_field #: model:ir.model.fields,help:purchase_order_general_discount.field_res_config_settings__purchase_general_discount_field msgid "" -"Set the purchase line discount field in wich the discounts will be applied." +"Set the purchase line discount field in which the discounts will be applied." msgstr "" "Establecer el campo de descuento de la línea de pedido en el que se aplicará " "el descuento." diff --git a/purchase_order_general_discount/i18n/pt.po b/purchase_order_general_discount/i18n/pt.po index 2daccd900cb..9ba20369062 100644 --- a/purchase_order_general_discount/i18n/pt.po +++ b/purchase_order_general_discount/i18n/pt.po @@ -93,7 +93,7 @@ msgstr "" #. module: purchase_order_general_discount #: model:ir.model.fields,help:purchase_order_general_discount.field_res_company__purchase_general_discount_field #: model:ir.model.fields,help:purchase_order_general_discount.field_res_config_settings__purchase_general_discount_field -msgid "Set the purchase line discount field in wich the discounts will be applied." +msgid "Set the purchase line discount field in which the discounts will be applied." msgstr "" "Defina o campo de desconto de linha de compra ao qual serão aplicados os " "descontos." diff --git a/purchase_order_general_discount/i18n/purchase_order_general_discount.pot b/purchase_order_general_discount/i18n/purchase_order_general_discount.pot index a2670064ba5..2f3d2428d91 100644 --- a/purchase_order_general_discount/i18n/purchase_order_general_discount.pot +++ b/purchase_order_general_discount/i18n/purchase_order_general_discount.pot @@ -91,7 +91,7 @@ msgstr "" #: model:ir.model.fields,help:purchase_order_general_discount.field_res_company__purchase_general_discount_field #: model:ir.model.fields,help:purchase_order_general_discount.field_res_config_settings__purchase_general_discount_field msgid "" -"Set the purchase line discount field in wich the discounts will be applied." +"Set the purchase line discount field in which the discounts will be applied." msgstr "" #. module: purchase_order_general_discount diff --git a/purchase_order_general_discount/models/res_company.py b/purchase_order_general_discount/models/res_company.py index 789d4ac4c17..7c644db50cd 100644 --- a/purchase_order_general_discount/models/res_company.py +++ b/purchase_order_general_discount/models/res_company.py @@ -10,7 +10,7 @@ class ResCompany(models.Model): selection="_get_purchase_discount_fields", string="Purchase Discount Field", default="discount", - help="Set the purchase line discount field in wich the " + help="Set the purchase line discount field in which the " "discounts will be applied.", ) diff --git a/purchase_order_general_discount/readme/CONTRIBUTORS.rst b/purchase_order_general_discount/readme/CONTRIBUTORS.rst index 6459c223a45..e528af06c26 100644 --- a/purchase_order_general_discount/readme/CONTRIBUTORS.rst +++ b/purchase_order_general_discount/readme/CONTRIBUTORS.rst @@ -4,3 +4,8 @@ * Pedro M. Baeza * Rafael Blasco * Carlos Roca + +* `Aures TIC `_: + + * Jose Zambudio + * Anna Martinez diff --git a/purchase_order_general_discount/readme/DESCRIPTION.rst b/purchase_order_general_discount/readme/DESCRIPTION.rst index f4907d504df..064290a3c67 100644 --- a/purchase_order_general_discount/readme/DESCRIPTION.rst +++ b/purchase_order_general_discount/readme/DESCRIPTION.rst @@ -1,5 +1,5 @@ This module allows to set a general discount in a purchase order. This general discount is applied to each line order. -You can also set a default general discount on suppliers and configure to wich +You can also set a default general discount on suppliers and configure to which line field the discount will be applied. diff --git a/purchase_order_general_discount/static/description/index.html b/purchase_order_general_discount/static/description/index.html index 83ca9988714..79939977f09 100644 --- a/purchase_order_general_discount/static/description/index.html +++ b/purchase_order_general_discount/static/description/index.html @@ -1,13 +1,15 @@ - - - -Purchase Order General Discount - - - -
-

Purchase Order General Discount

- - -

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

-

This module allows to set a general discount in a purchase order. This general -discount is applied to each line order.

-

You can also set a default general discount on suppliers and configure to wich -line field the discount will be applied.

-

Table of contents

- -
-

Configuration

-

You can set in settings another discount field to be applied. -For example, if we had purchase_triple_discount, we could set the general -discount in discount3 to be applied after all other discounts.

-

To do so:

-
    -
  1. Go to Purchases > Configuration > Settings and Purchase Discount Field
  2. -
  3. Select the discount you’d wish to use. purchase_triple_discount fields -will appear when the module is installed.
  4. -
-

There’s a method at res.company called _get_purchase_discount_fields that -can be used to extend more line discount fields. For example, if we had the -field discount4, we could extend it like this:

-
+      

+ Beta + License: AGPL-3 + OCA/purchase-workflow + Translate me on Weblate + Try me on Runbot +

+

+ This module allows to set a general discount in a purchase order. This general + discount is applied to each line order. +

+

+ You can also set a default general discount on suppliers and configure to which + line field the discount will be applied. +

+

Table of contents

+
+ +
+
+

Configuration

+

+ You can set in settings another discount field to be applied. For example, if + we had purchase_triple_discount, we could set the general + discount in discount3 to be applied after all other discounts. +

+

To do so:

+
    +
  1. + Go to Purchases > Configuration > Settings and + Purchase Discount Field +
  2. +
  3. + Select the discount you’d wish to use. + purchase_triple_discount fields will appear when the module is + installed. +
  4. +
+

+ There’s a method at res.company called + _get_purchase_discount_fields that can be used to extend more + line discount fields. For example, if we had the field discount4, + we could extend it like this: +

+
 @api.model
 def _get_purchase_discount_fields(self):
     discount_fields = super()._get_purchase_discount_fields()
     discount_fields += [('discount4', _('Discount 4'))]
     return discount_fields
 
-
-
-

Usage

-

To set a partner default general discount you need to:

-
    -
  1. Go to a partner and set the general discount in Sales & Purchases tab.
  2. -
-

To set a general discount in a purchase order you need to:

-
    -
  1. Create a purchase order.
  2. -
  3. Either select a partner with a purchase general discount defined or set one -in the summary section of the order.
  4. -
  5. This discount will be applied to every line.
  6. -
-
-
-

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

-
    -
  • Tecnativa
  • -
-
-
-

Contributors

-
    -
  • Tecnativa:

    -
    -
      -
    • David Vidal
    • -
    • Pedro M. Baeza
    • -
    • Rafael Blasco
    • -
    • Carlos Roca
    • -
    -
    -
  • -
-
-
-

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/purchase-workflow project on GitHub.

-

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

-
-
-
- +
+
+

Usage

+

To set a partner default general discount you need to:

+
    +
  1. + Go to a partner and set the general discount in + Sales & Purchases tab. +
  2. +
+

To set a general discount in a purchase order you need to:

+
    +
  1. Create a purchase order.
  2. +
  3. + Either select a partner with a purchase general discount defined or set one + in the summary section of the order. +
  4. +
  5. This discount will be applied to every line.
  6. +
+
+
+

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

+
    +
  • Tecnativa
  • +
+
+
+

Contributors

+
    +
  • +

    + Tecnativa: +

    +
    +
      +
    • David Vidal
    • +
    • Pedro M. Baeza
    • +
    • Rafael Blasco
    • +
    • Carlos Roca
    • +
    +
    +
  • +
  • +

    + Aures TIC: +

    +
    +
      +
    • Jose Zambudio
    • +
    • Anna Martinez
    • +
    +
    +
  • +
+
+
+

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/purchase-workflow + project on GitHub. +

+

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

+
+
+ + diff --git a/purchase_order_general_discount/tests/test_purchase_order_general_discount.py b/purchase_order_general_discount/tests/test_purchase_order_general_discount.py index 62242100508..4fe92e7fccc 100644 --- a/purchase_order_general_discount/tests/test_purchase_order_general_discount.py +++ b/purchase_order_general_discount/tests/test_purchase_order_general_discount.py @@ -57,7 +57,7 @@ def _get_ctx_from_view(self, res): def test_03_default_line_discount_value(self): res = self.order.fields_view_get( view_id=self.env.ref( - "purchase_order_general_discount." "purchase_order_form" + "purchase_order_general_discount.purchase_order_form" ).id, view_type="form", ) diff --git a/purchase_order_general_discount/views/res_config_view.xml b/purchase_order_general_discount/views/res_config_view.xml index 360448438b1..927b415b4f7 100644 --- a/purchase_order_general_discount/views/res_config_view.xml +++ b/purchase_order_general_discount/views/res_config_view.xml @@ -26,13 +26,8 @@
Select to which purchase line field will the purchase general discount be propagated.
-
-
- -
+
+
From 445ea9530ac482788c269e9da56782d673f1bb7b Mon Sep 17 00:00:00 2001 From: oca-ci Date: Thu, 27 Oct 2022 09:10:46 +0000 Subject: [PATCH 16/34] [UPD] Update purchase_order_general_discount.pot --- .../i18n/purchase_order_general_discount.pot | 26 ++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/purchase_order_general_discount/i18n/purchase_order_general_discount.pot b/purchase_order_general_discount/i18n/purchase_order_general_discount.pot index 2f3d2428d91..56debb285b5 100644 --- a/purchase_order_general_discount/i18n/purchase_order_general_discount.pot +++ b/purchase_order_general_discount/i18n/purchase_order_general_discount.pot @@ -4,7 +4,7 @@ # msgid "" msgstr "" -"Project-Id-Version: Odoo Server 13.0\n" +"Project-Id-Version: Odoo Server 14.0\n" "Report-Msgid-Bugs-To: \n" "Last-Translator: \n" "Language-Team: \n" @@ -53,11 +53,35 @@ msgstr "" msgid "Discount must be lower than 100%." msgstr "" +#. module: purchase_order_general_discount +#: model:ir.model.fields,field_description:purchase_order_general_discount.field_purchase_order__display_name +#: model:ir.model.fields,field_description:purchase_order_general_discount.field_res_company__display_name +#: model:ir.model.fields,field_description:purchase_order_general_discount.field_res_config_settings__display_name +#: model:ir.model.fields,field_description:purchase_order_general_discount.field_res_partner__display_name +msgid "Display Name" +msgstr "" + #. module: purchase_order_general_discount #: model:ir.model.fields,field_description:purchase_order_general_discount.field_purchase_order__general_discount msgid "Gen. Disc. (%)" msgstr "" +#. module: purchase_order_general_discount +#: model:ir.model.fields,field_description:purchase_order_general_discount.field_purchase_order__id +#: model:ir.model.fields,field_description:purchase_order_general_discount.field_res_company__id +#: model:ir.model.fields,field_description:purchase_order_general_discount.field_res_config_settings__id +#: model:ir.model.fields,field_description:purchase_order_general_discount.field_res_partner__id +msgid "ID" +msgstr "" + +#. module: purchase_order_general_discount +#: model:ir.model.fields,field_description:purchase_order_general_discount.field_purchase_order____last_update +#: model:ir.model.fields,field_description:purchase_order_general_discount.field_res_company____last_update +#: model:ir.model.fields,field_description:purchase_order_general_discount.field_res_config_settings____last_update +#: model:ir.model.fields,field_description:purchase_order_general_discount.field_res_partner____last_update +msgid "Last Modified on" +msgstr "" + #. module: purchase_order_general_discount #: model:ir.model,name:purchase_order_general_discount.model_res_config_settings msgid "Procurement purchase grouping settings" From 092543e2a7f816c66925459518508e0090058de2 Mon Sep 17 00:00:00 2001 From: OCA-git-bot Date: Thu, 27 Oct 2022 09:19:03 +0000 Subject: [PATCH 17/34] [UPD] README.rst --- purchase_order_general_discount/README.rst | 14 +- .../static/description/index.html | 1138 +++++++---------- 2 files changed, 447 insertions(+), 705 deletions(-) diff --git a/purchase_order_general_discount/README.rst b/purchase_order_general_discount/README.rst index 92271d5a280..c5269fcc1f0 100644 --- a/purchase_order_general_discount/README.rst +++ b/purchase_order_general_discount/README.rst @@ -14,16 +14,16 @@ Purchase Order General Discount :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html :alt: License: AGPL-3 .. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fpurchase--workflow-lightgray.png?logo=github - :target: https://github.com/OCA/purchase-workflow/tree/13.0/purchase_order_general_discount + :target: https://github.com/OCA/purchase-workflow/tree/14.0/purchase_order_general_discount :alt: OCA/purchase-workflow .. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png - :target: https://translation.odoo-community.org/projects/purchase-workflow-13-0/purchase-workflow-13-0-purchase_order_general_discount + :target: https://translation.odoo-community.org/projects/purchase-workflow-14-0/purchase-workflow-14-0-purchase_order_general_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/142/13.0 + :target: https://runbot.odoo-community.org/runbot/142/14.0 :alt: Try me on Runbot -|badge1| |badge2| |badge3| |badge4| |badge5| +|badge1| |badge2| |badge3| |badge4| |badge5| This module allows to set a general discount in a purchase order. This general discount is applied to each line order. @@ -81,7 +81,7 @@ 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 `_. +`feedback `_. Do not contact contributors directly about support or help with technical issues. @@ -103,7 +103,7 @@ Contributors * Rafael Blasco * Carlos Roca -* `Aures TIC `_: +* `Aures TIC `_: * Jose Zambudio * Anna Martinez @@ -121,6 +121,6 @@ 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/purchase-workflow `_ project on GitHub. +This module is part of the `OCA/purchase-workflow `_ project on GitHub. You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/purchase_order_general_discount/static/description/index.html b/purchase_order_general_discount/static/description/index.html index 79939977f09..deb9fee9dd0 100644 --- a/purchase_order_general_discount/static/description/index.html +++ b/purchase_order_general_discount/static/description/index.html @@ -1,15 +1,13 @@ - - - - Purchase Order General Discount - - - -
-

Purchase Order General Discount

- - -

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

-

- This module allows to set a general discount in a purchase order. This general - discount is applied to each line order. -

-

- You can also set a default general discount on suppliers and configure to which - line field the discount will be applied. -

-

Table of contents

-
- -
-
-

Configuration

-

- You can set in settings another discount field to be applied. For example, if - we had purchase_triple_discount, we could set the general - discount in discount3 to be applied after all other discounts. -

-

To do so:

-
    -
  1. - Go to Purchases > Configuration > Settings and - Purchase Discount Field -
  2. -
  3. - Select the discount you’d wish to use. - purchase_triple_discount fields will appear when the module is - installed. -
  4. -
-

- There’s a method at res.company called - _get_purchase_discount_fields that can be used to extend more - line discount fields. For example, if we had the field discount4, - we could extend it like this: -

-
+

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

+

This module allows to set a general discount in a purchase order. This general +discount is applied to each line order.

+

You can also set a default general discount on suppliers and configure to which +line field the discount will be applied.

+

Table of contents

+ +
+

Configuration

+

You can set in settings another discount field to be applied. +For example, if we had purchase_triple_discount, we could set the general +discount in discount3 to be applied after all other discounts.

+

To do so:

+
    +
  1. Go to Purchases > Configuration > Settings and Purchase Discount Field
  2. +
  3. Select the discount you’d wish to use. purchase_triple_discount fields +will appear when the module is installed.
  4. +
+

There’s a method at res.company called _get_purchase_discount_fields that +can be used to extend more line discount fields. For example, if we had the +field discount4, we could extend it like this:

+
 @api.model
 def _get_purchase_discount_fields(self):
     discount_fields = super()._get_purchase_discount_fields()
     discount_fields += [('discount4', _('Discount 4'))]
     return discount_fields
 
-
-
-

Usage

-

To set a partner default general discount you need to:

-
    -
  1. - Go to a partner and set the general discount in - Sales & Purchases tab. -
  2. -
-

To set a general discount in a purchase order you need to:

-
    -
  1. Create a purchase order.
  2. -
  3. - Either select a partner with a purchase general discount defined or set one - in the summary section of the order. -
  4. -
  5. This discount will be applied to every line.
  6. -
-
-
-

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

-
    -
  • Tecnativa
  • -
-
-
-

Contributors

-
    -
  • -

    - Tecnativa: -

    -
    -
      -
    • David Vidal
    • -
    • Pedro M. Baeza
    • -
    • Rafael Blasco
    • -
    • Carlos Roca
    • -
    -
    -
  • -
  • -

    - Aures TIC: -

    -
    -
      -
    • Jose Zambudio
    • -
    • Anna Martinez
    • -
    -
    -
  • -
-
-
-

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/purchase-workflow - project on GitHub. -

-

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

-
-
-
- +
+
+

Usage

+

To set a partner default general discount you need to:

+
    +
  1. Go to a partner and set the general discount in Sales & Purchases tab.
  2. +
+

To set a general discount in a purchase order you need to:

+
    +
  1. Create a purchase order.
  2. +
  3. Either select a partner with a purchase general discount defined or set one +in the summary section of the order.
  4. +
  5. This discount will be applied to every line.
  6. +
+
+
+

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

+
    +
  • Tecnativa
  • +
+
+
+

Contributors

+
    +
  • Tecnativa:

    +
    +
      +
    • David Vidal
    • +
    • Pedro M. Baeza
    • +
    • Rafael Blasco
    • +
    • Carlos Roca
    • +
    +
    +
  • +
  • Aures TIC:

    +
    +
      +
    • Jose Zambudio
    • +
    • Anna Martinez
    • +
    +
    +
  • +
+
+
+

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/purchase-workflow project on GitHub.

+

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

+
+
+ + From e23c8c2e4314fdbe26d79d334973fb5524a4fcf1 Mon Sep 17 00:00:00 2001 From: pilarvargas-tecnativa Date: Thu, 22 Dec 2022 09:35:55 +0100 Subject: [PATCH 18/34] [MIG] purchase_order_general_discount: Migration to version 15.0 TT38331 --- purchase_order_general_discount/README.rst | 15 +++++---- .../__manifest__.py | 2 +- .../models/purchase_order.py | 3 +- .../readme/CONTRIBUTORS.rst | 1 + .../static/description/index.html | 9 +++--- .../test_purchase_order_general_discount.py | 32 ++++++------------- .../views/purchase_order_view.xml | 11 +++---- 7 files changed, 31 insertions(+), 42 deletions(-) diff --git a/purchase_order_general_discount/README.rst b/purchase_order_general_discount/README.rst index c5269fcc1f0..8af4d34bd97 100644 --- a/purchase_order_general_discount/README.rst +++ b/purchase_order_general_discount/README.rst @@ -14,14 +14,14 @@ Purchase Order General Discount :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html :alt: License: AGPL-3 .. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fpurchase--workflow-lightgray.png?logo=github - :target: https://github.com/OCA/purchase-workflow/tree/14.0/purchase_order_general_discount + :target: https://github.com/OCA/purchase-workflow/tree/15.0/purchase_order_general_discount :alt: OCA/purchase-workflow .. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png - :target: https://translation.odoo-community.org/projects/purchase-workflow-14-0/purchase-workflow-14-0-purchase_order_general_discount + :target: https://translation.odoo-community.org/projects/purchase-workflow-15-0/purchase-workflow-15-0-purchase_order_general_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/142/14.0 - :alt: Try me on Runbot +.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png + :target: https://runboat.odoo-community.org/webui/builds.html?repo=OCA/purchase-workflow&target_branch=15.0 + :alt: Try me on Runboat |badge1| |badge2| |badge3| |badge4| |badge5| @@ -81,7 +81,7 @@ 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 `_. +`feedback `_. Do not contact contributors directly about support or help with technical issues. @@ -102,6 +102,7 @@ Contributors * Pedro M. Baeza * Rafael Blasco * Carlos Roca + * Pilar Vargas * `Aures TIC `_: @@ -121,6 +122,6 @@ 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/purchase-workflow `_ project on GitHub. +This module is part of the `OCA/purchase-workflow `_ project on GitHub. You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/purchase_order_general_discount/__manifest__.py b/purchase_order_general_discount/__manifest__.py index 82e7bc1bc12..3c16c15c844 100644 --- a/purchase_order_general_discount/__manifest__.py +++ b/purchase_order_general_discount/__manifest__.py @@ -3,7 +3,7 @@ { "name": "Purchase Order General Discount", "summary": "General discount per purchase order", - "version": "14.0.1.0.0", + "version": "15.0.1.0.0", "category": "Purchases", "website": "https://github.com/OCA/purchase-workflow", "author": "Tecnativa, Odoo Community Association (OCA)", diff --git a/purchase_order_general_discount/models/purchase_order.py b/purchase_order_general_discount/models/purchase_order.py index 8bf5d82f18d..025a800a384 100644 --- a/purchase_order_general_discount/models/purchase_order.py +++ b/purchase_order_general_discount/models/purchase_order.py @@ -23,10 +23,11 @@ class PurchaseOrder(models.Model): @api.onchange("partner_id") def onchange_partner_id(self): - super().onchange_partner_id() + res = super().onchange_partner_id() self.general_discount = ( self.partner_id.commercial_partner_id.purchase_general_discount ) + return res def _get_general_discount_field(self): """We can set in settings another discount field to be applied diff --git a/purchase_order_general_discount/readme/CONTRIBUTORS.rst b/purchase_order_general_discount/readme/CONTRIBUTORS.rst index e528af06c26..219be9f3e40 100644 --- a/purchase_order_general_discount/readme/CONTRIBUTORS.rst +++ b/purchase_order_general_discount/readme/CONTRIBUTORS.rst @@ -4,6 +4,7 @@ * Pedro M. Baeza * Rafael Blasco * Carlos Roca + * Pilar Vargas * `Aures TIC `_: diff --git a/purchase_order_general_discount/static/description/index.html b/purchase_order_general_discount/static/description/index.html index deb9fee9dd0..d741bd30af0 100644 --- a/purchase_order_general_discount/static/description/index.html +++ b/purchase_order_general_discount/static/description/index.html @@ -3,7 +3,7 @@ - + Purchase Order General Discount