Skip to content

Commit

Permalink
[IMP] purchase_discount: Use hooks + tests + icon
Browse files Browse the repository at this point in the history
  • Loading branch information
pedrobaeza committed Sep 1, 2015
1 parent 10513e4 commit 276e53b
Show file tree
Hide file tree
Showing 11 changed files with 3,002 additions and 196 deletions.
26 changes: 21 additions & 5 deletions purchase_discount/README.rst
Original file line number Diff line number Diff line change
@@ -1,18 +1,28 @@
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg
:alt: License AGPL-3
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License AGPL-3

===========================
Discount in purchase orders
===========================

This module allows to define a discount per line in the purchase orders. This
discount can be also negative, interpreting it as an increment.

Known issues / Roadmap
======================
It also modifies the purchase order report to include the discount field in it.

Installation
============

You need an Odoo/OCB installation updated up to at least on 27 august of 2015,
containing revision `617ef49 <https://github.com/odoo/odoo/commit/617ef49959d027fab52e2be74aa4c0dc3ce60e30>`_

* This module can be incompatible with other modules that modify purchase
prices, because it overwrites computation methods.
Usage
=====

.. 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/8.0

Bug Tracker
===========
Expand All @@ -33,6 +43,12 @@ Contributors
* Ignacio Ibeas <ignacio@acysos.com>
* Pedro M. Baeza <pedro.baeza@serviciosbaeza.com>

Icon
----

* Original Odoo purchase module icon
* https://openclipart.org/detail/159937/clothing-label-with-rope

Maintainer
----------

Expand Down
7 changes: 6 additions & 1 deletion purchase_discount/i18n/es.po
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ msgstr ""
"X-Launchpad-Export-Date: 2014-06-22 05:57+0000\n"
"X-Generator: Launchpad (build 17058)\n"

#. module: purchase_discount
#: view:website:purchase.report_purchaseorder_document
msgid "Disc.(%)"
msgstr "Desc.(%)"

#. module: purchase_discount
#: model:ir.model,name:purchase_discount.model_purchase_order
msgid "Purchase Order"
Expand All @@ -29,7 +34,7 @@ msgstr "Albarán"
#. module: purchase_discount
#: sql_constraint:purchase.order.line:0
msgid "Discount must be lower than 100%."
msgstr "El desduento debe ser menor al 100%."
msgstr "El descuento debe ser menor al 100%."

#. module: purchase_discount
#: model:ir.model,name:purchase_discount.model_purchase_order_line
Expand Down
43 changes: 0 additions & 43 deletions purchase_discount/i18n/es_ES.po

This file was deleted.

25 changes: 15 additions & 10 deletions purchase_discount/i18n/purchase_discount.pot
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# Translation of OpenERP Server.
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * purchase_discount
#
msgid ""
msgstr ""
"Project-Id-Version: OpenERP Server 7.0\n"
"Project-Id-Version: Odoo Server 8.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2013-11-07 01:07+0000\n"
"PO-Revision-Date: 2013-11-07 01:07+0000\n"
"POT-Creation-Date: 2015-09-01 00:42+0000\n"
"PO-Revision-Date: 2015-09-01 00:42+0000\n"
"Last-Translator: <>\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
Expand All @@ -16,27 +16,32 @@ msgstr ""
"Plural-Forms: \n"

#. module: purchase_discount
#: model:ir.model,name:purchase_discount.model_purchase_order
msgid "Purchase Order"
#: view:website:purchase.report_purchaseorder_document
msgid "Disc.(%)"
msgstr ""

#. module: purchase_discount
#: model:ir.model,name:purchase_discount.model_stock_picking
msgid "Picking List"
#: field:purchase.order.line,discount:0
msgid "Discount (%)"
msgstr ""

#. module: purchase_discount
#: sql_constraint:purchase.order.line:0
msgid "Discount must be lower than 100%."
msgstr ""

#. module: purchase_discount
#: model:ir.model,name:purchase_discount.model_purchase_order
msgid "Purchase Order"
msgstr ""

#. module: purchase_discount
#: model:ir.model,name:purchase_discount.model_purchase_order_line
msgid "Purchase Order Line"
msgstr ""

#. module: purchase_discount
#: field:purchase.order.line,discount:0
msgid "Discount (%)"
#: model:ir.model,name:purchase_discount.model_stock_move
msgid "Stock Move"
msgstr ""

2 changes: 1 addition & 1 deletion purchase_discount/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from . import purchase_discount
from . import purchase_order
from . import stock_move
136 changes: 0 additions & 136 deletions purchase_discount/models/purchase_discount.py

This file was deleted.

50 changes: 50 additions & 0 deletions purchase_discount/models/purchase_order.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from openerp import models, fields, api
import openerp.addons.decimal_precision as dp


class PurchaseOrderLine(models.Model):
_inherit = "purchase.order.line"

@api.model
def _calc_line_base_price(self, line):
res = super(PurchaseOrderLine, self)._calc_line_base_price(line)
return res * (1 - line.discount / 100.0)

discount = fields.Float(
string='Discount (%)', digits_compute=dp.get_precision('Discount'))

_sql_constraints = [
('discount_limit', 'CHECK (discount <= 100.0)',
'Discount must be lower than 100%.'),
]


class PurchaseOrder(models.Model):
_inherit = "purchase.order"

@api.model
def _prepare_inv_line(self, account_id, order_line):
result = super(PurchaseOrder, self)._prepare_inv_line(
account_id, order_line)
result['discount'] = order_line.discount or 0.0
return result
Binary file modified purchase_discount/static/description/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 276e53b

Please sign in to comment.