Skip to content

Commit

Permalink
[MIG] product_supplierinfo_discount 10.0
Browse files Browse the repository at this point in the history
  • Loading branch information
StefanRijnhart committed Oct 31, 2017
1 parent 87e22fe commit 4b6bfad
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 16 deletions.
7 changes: 5 additions & 2 deletions product_supplierinfo_discount/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
=======
Expand Down
2 changes: 1 addition & 1 deletion product_supplierinfo_discount/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)",
Expand Down
3 changes: 1 addition & 2 deletions product_supplierinfo_discount/models/procurement_order.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
# © 2016 ACSONE SA/NV (<http://acsone.eu>)
# 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):
Expand All @@ -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],
Expand Down
7 changes: 4 additions & 3 deletions product_supplierinfo_discount/models/product_supplierinfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,20 @@
# © 2016 ACSONE SA/NV (<http://acsone.eu>)
# 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
3 changes: 1 addition & 2 deletions product_supplierinfo_discount/models/purchase_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Pedro M. Baeza <[email protected]>
# © 2016 ACSONE SA/NV (<http://acsone.eu>)
# 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):
Expand All @@ -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],
Expand Down
6 changes: 3 additions & 3 deletions product_supplierinfo_discount/models/res_partner.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
# 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):
_inherit = "res.partner"

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.")
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
# Pedro M. Baeza <[email protected]>
# © 2016 ACSONE SA/NV (<http://acsone.eu>)
# 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()
Expand Down

0 comments on commit 4b6bfad

Please sign in to comment.