Skip to content

Commit

Permalink
[ADD] grap_custom_import_purchase_triple_discount
Browse files Browse the repository at this point in the history
  • Loading branch information
legalsylvain committed Nov 22, 2024
1 parent 1bc50e1 commit e2c946f
Show file tree
Hide file tree
Showing 14 changed files with 99 additions and 66 deletions.
64 changes: 0 additions & 64 deletions grap_custom_import_purchase_discount/README.rst
Original file line number Diff line number Diff line change
@@ -1,64 +0,0 @@
====================================================================
GRAP - Custom Import Product Supplierinfo Quantity Multiplier Module
====================================================================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:9b8df078c1fb893b68650c2ee64e375d840edd6d1f8f7bfdb0f1a4da37012215
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |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-grap%2Fgrap--odoo--import-lightgray.png?logo=github
:target: https://github.com/grap/grap-odoo-import/tree/16.0/grap_custom_import_product_supplierinfo_qty_multiplier
:alt: grap/grap-odoo-import

|badge1| |badge2| |badge3|

This module improve the "import" features provided by Odoo.

* ``product.product``:

* Allow to recover ``multiplier_qty`` field in the supplier info level.

**Table of contents**

.. contents::
:local:

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/grap/grap-odoo-import/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
`feedback <https://github.com/grap/grap-odoo-import/issues/new?body=module:%20grap_custom_import_product_supplierinfo_qty_multiplier%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

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

Credits
=======

Authors
~~~~~~~

* GRAP

Contributors
~~~~~~~~~~~~

* Sylvain LE GAL <https://twitter.com/legalsylvain>

Maintainers
~~~~~~~~~~~

This module is part of the `grap/grap-odoo-import <https://github.com/grap/grap-odoo-import/tree/16.0/grap_custom_import_product_supplierinfo_qty_multiplier>`_ project on GitHub.

You are welcome to contribute.
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ class CustomImportProductMixin(models.AbstractModel):

def _custom_import_prepare_supplierinfo_vals(self, partner, vals):
res = super()._custom_import_prepare_supplierinfo_vals(partner, vals)
res["discount"] = vals.get("grap_import_supplier_discount_1") * 100
res["discount"] = (vals.get("grap_import_supplier_discount_1") or 0.0) * 100
return res
2 changes: 1 addition & 1 deletion grap_custom_import_purchase_discount/tests/test_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@


@tagged("post_install", "-at_install")
class TestModuleProductSupplierinfoQtyMultiplier(TestModuleProduct):
class TestModulePurchaseDiscount(TestModuleProduct):
@classmethod
def setUpClass(cls):
super().setUpClass()
Expand Down
Empty file.
1 change: 1 addition & 0 deletions grap_custom_import_purchase_triple_discount/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
17 changes: 17 additions & 0 deletions grap_custom_import_purchase_triple_discount/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Copyright (C) 2019 - Today: GRAP (http://www.grap.coop)
# @author: Sylvain LE GAL (https://twitter.com/legalsylvain)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

{
"name": "GRAP - Custom Product Import - Purchase Triple Discount Module",
"summary": "Extra GRAP Tools to import product data for"
" Purchase Triple Discount module",
"version": "16.0.1.0.0",
"category": "Tools",
"author": "GRAP",
"website": "https://github.com/grap/grap-odoo-import",
"license": "AGPL-3",
"depends": ["grap_custom_import_purchase_discount", "purchase_triple_discount"],
"auto_install": True,
"installable": True,
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import custom_import_product_mixin
from . import product_template
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Copyright (C) 2024 - Today: GRAP (http://www.grap.coop)
# @author: Sylvain LE GAL (https://twitter.com/legalsylvain)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from odoo import models


class CustomImportProductMixin(models.AbstractModel):
_name = "custom.import.product.mixin"
_inherit = ["custom.import.product.mixin"]

def _custom_import_prepare_supplierinfo_vals(self, partner, vals):
res = super()._custom_import_prepare_supplierinfo_vals(partner, vals)
res["discount2"] = (vals.get("grap_import_supplier_discount_2") or 0.0) * 100
res["discount3"] = (vals.get("grap_import_supplier_discount_3") or 0.0) * 100
return res
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Copyright (C) 2024 - Today: GRAP (http://www.grap.coop)
# @author: Sylvain LE GAL (https://twitter.com/legalsylvain)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from odoo import fields, models


class ProductTemplate(models.Model):
_inherit = "product.template"

grap_import_supplier_discount_2 = fields.Float(
string="Supplier Discount 2 (For import)", store=False
)

grap_import_supplier_discount_3 = fields.Float(
string="Supplier Discount 3 (For import)", store=False
)
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* Sylvain LE GAL <https://twitter.com/legalsylvain>
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
This module improve the "import" features provided by Odoo.

* ``product.product``:

* Allow to recover ``discount2`` and ``discount3`` fields
in the supplier info level.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import test_module
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
name,uom_id,categ_id,grap_import_supplier_name,grap_import_supplier_discount_1,grap_import_supplier_discount_2,grap_import_supplier_discount_3
Mention Good (Late chocolate),Units,All / Saleable,Ready Mat,0.33,0.22,0.11
34 changes: 34 additions & 0 deletions grap_custom_import_purchase_triple_discount/tests/test_module.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Copyright (C) 2024 - Today: GRAP (http://www.grap.coop)
# @author: Sylvain LE GAL (https://twitter.com/legalsylvain)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from odoo.tests import tagged

from odoo.addons.grap_custom_import_product.tests.test_module import TestModuleProduct


@tagged("post_install", "-at_install")
class TestModulePurchaseTripleDiscount(TestModuleProduct):
@classmethod
def setUpClass(cls):
super().setUpClass()
cls.ProductProduct = cls.env["product.product"]

def _test_import_purchase_discount(self, model):
products, messages = self._test_import_file(
"grap_custom_import_purchase_triple_discount",
model,
"product.csv",
folder="product",
)
self.assertFalse(messages)
self.assertEqual(len(products), 1)
self.assertEqual(products.seller_ids.discount, 33.0)
self.assertEqual(products.seller_ids.discount2, 22.0)
self.assertEqual(products.seller_ids.discount3, 11.0)

def test_01_import_purchase_discount_product(self):
self._test_import_purchase_discount("product.product")

def test_02_import_purchase_discount_template(self):
self._test_import_purchase_discount("product.template")

0 comments on commit e2c946f

Please sign in to comment.