From 4b6bfad2c0bf81460c8be2ecdabb44e9442f1a83 Mon Sep 17 00:00:00 2001 From: Stefan Rijnhart Date: Mon, 5 Jun 2017 16:58:01 +0200 Subject: [PATCH] [MIG] product_supplierinfo_discount 10.0 --- product_supplierinfo_discount/README.rst | 7 +++++-- product_supplierinfo_discount/__manifest__.py | 2 +- product_supplierinfo_discount/models/procurement_order.py | 3 +-- .../models/product_supplierinfo.py | 7 ++++--- product_supplierinfo_discount/models/purchase_order.py | 3 +-- product_supplierinfo_discount/models/res_partner.py | 6 +++--- .../tests/test_product_supplierinfo_discount.py | 6 +++--- 7 files changed, 18 insertions(+), 16 deletions(-) diff --git a/product_supplierinfo_discount/README.rst b/product_supplierinfo_discount/README.rst index 124136d7cac..68eda03b857 100644 --- a/product_supplierinfo_discount/README.rst +++ b/product_supplierinfo_discount/README.rst @@ -50,11 +50,14 @@ the desired discount for that quantity. When you make a purchase order for that supplier and that product, discount will be put automatically. +.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas + :alt: Try me on Runbot + :target: https://runbot.odoo-community.org/runbot/142/10.0 + Known issues / Roadmap ====================== -* The discount is always applied, independently if you have based - your pricelist on other value than "Supplier Prices on the product form". +* ... Credits ======= diff --git a/product_supplierinfo_discount/__manifest__.py b/product_supplierinfo_discount/__manifest__.py index c8597b35363..9de8474c306 100644 --- a/product_supplierinfo_discount/__manifest__.py +++ b/product_supplierinfo_discount/__manifest__.py @@ -8,7 +8,7 @@ { "name": "Discounts in product supplier info", - "version": "9.0.1.0.0", + "version": "10.0.1.0.0", "author": "Tecnativa, " "GRAP, " "Odoo Community Association (OCA)", diff --git a/product_supplierinfo_discount/models/procurement_order.py b/product_supplierinfo_discount/models/procurement_order.py index be0999ac420..ef514467303 100644 --- a/product_supplierinfo_discount/models/procurement_order.py +++ b/product_supplierinfo_discount/models/procurement_order.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # © 2016 ACSONE SA/NV () # License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html -from openerp import models, api +from odoo import api, models class ProcurementOrder(models.Model): @@ -15,7 +15,6 @@ def _prepare_purchase_order_line(self, po, supplier): res = super(ProcurementOrder, self)._prepare_purchase_order_line( po, supplier) seller = self.product_id._select_seller( - self.product_id, partner_id=supplier.name, quantity=self.product_qty, date=po.date_order and po.date_order[:10], diff --git a/product_supplierinfo_discount/models/product_supplierinfo.py b/product_supplierinfo_discount/models/product_supplierinfo.py index 19d79b5558c..7aea177bd3a 100644 --- a/product_supplierinfo_discount/models/product_supplierinfo.py +++ b/product_supplierinfo_discount/models/product_supplierinfo.py @@ -4,19 +4,20 @@ # © 2016 ACSONE SA/NV () # License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html -from openerp import models, fields, api -import openerp.addons.decimal_precision as dp +from odoo import models, fields, api +import odoo.addons.decimal_precision as dp class ProductSupplierInfo(models.Model): _inherit = 'product.supplierinfo' discount = fields.Float( - string='Discount (%)', digits_compute=dp.get_precision('Discount')) + string='Discount (%)', digits=dp.get_precision('Discount')) @api.onchange('name') @api.multi def onchange_name(self): + """ Apply the default supplier discount of the selected supplier """ for supplierinfo in self.filtered('name'): supplierinfo.discount =\ supplierinfo.name.default_supplierinfo_discount diff --git a/product_supplierinfo_discount/models/purchase_order.py b/product_supplierinfo_discount/models/purchase_order.py index 20f388b659e..d160ad5554b 100644 --- a/product_supplierinfo_discount/models/purchase_order.py +++ b/product_supplierinfo_discount/models/purchase_order.py @@ -3,7 +3,7 @@ # Pedro M. Baeza # © 2016 ACSONE SA/NV () # License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html -from openerp import models, api +from odoo import models, api class PurchaseOrderLine(models.Model): @@ -18,7 +18,6 @@ def _onchange_quantity(self): res = super(PurchaseOrderLine, self)._onchange_quantity() if self.product_id: product_supplierinfo = self.product_id._select_seller( - self.product_id, partner_id=self.partner_id, quantity=self.product_qty, date=self.order_id.date_order and self.order_id.date_order[:10], diff --git a/product_supplierinfo_discount/models/res_partner.py b/product_supplierinfo_discount/models/res_partner.py index 7ac8c36649a..22c81df654a 100644 --- a/product_supplierinfo_discount/models/res_partner.py +++ b/product_supplierinfo_discount/models/res_partner.py @@ -3,8 +3,8 @@ # Sylvain LE GAL (https://twitter.com/legalsylvain) # License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html -from openerp import models, fields -import openerp.addons.decimal_precision as dp +from odoo import models, fields +from odoo.addons import decimal_precision as dp class ResPartner(models.Model): @@ -12,6 +12,6 @@ class ResPartner(models.Model): default_supplierinfo_discount = fields.Float( string='Default Supplier Discount (%)', - digits_compute=dp.get_precision('Discount'), + digits=dp.get_precision('Discount'), help="This value will be used as the default one, for each new" " supplierinfo line depending on that supplier.") diff --git a/product_supplierinfo_discount/tests/test_product_supplierinfo_discount.py b/product_supplierinfo_discount/tests/test_product_supplierinfo_discount.py index ac24dfeec77..18e568afc85 100644 --- a/product_supplierinfo_discount/tests/test_product_supplierinfo_discount.py +++ b/product_supplierinfo_discount/tests/test_product_supplierinfo_discount.py @@ -3,11 +3,11 @@ # Pedro M. Baeza # © 2016 ACSONE SA/NV () # License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html -import openerp.tests.common as common -from openerp import fields +from odoo.tests.common import TransactionCase +from odoo import fields -class TestProductSupplierinfoDiscount(common.TransactionCase): +class TestProductSupplierinfoDiscount(TransactionCase): def setUp(self): super(TestProductSupplierinfoDiscount, self).setUp()