mirror of
https://github.com/OCA/stock-logistics-reporting.git
synced 2025-02-16 17:13:21 +02:00
[ADD] stock_valued_picking_report_triple_discount (#39)
This commit is contained in:
committed by
Pedro M. Baeza
parent
3df0547447
commit
acf693afa3
2
oca_dependencies.txt
Normal file
2
oca_dependencies.txt
Normal file
@@ -0,0 +1,2 @@
|
||||
sale-workflow
|
||||
|
||||
79
stock_valued_picking_report_triple_discount/README.rst
Normal file
79
stock_valued_picking_report_triple_discount/README.rst
Normal file
@@ -0,0 +1,79 @@
|
||||
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg
|
||||
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
|
||||
:alt: License: AGPL-3
|
||||
|
||||
===========================================
|
||||
Stock Valued Picking Report Triple Discount
|
||||
===========================================
|
||||
|
||||
Add triple discount information to valued Delivery Slip report for partners
|
||||
where the check to avoid valued picking is set.
|
||||
|
||||
Configuration
|
||||
=============
|
||||
|
||||
#. Go to *Customers > (select one of your choice) > Sales & Purchases*.
|
||||
#. Set *Valued picking* field on.
|
||||
#. Go to *Sales > Configuration > Settings*.
|
||||
#. Set *Allow discounts on sales order lines* field on.
|
||||
|
||||
Usage
|
||||
=====
|
||||
|
||||
To get the triple discount stock picking valued report:
|
||||
|
||||
#. Create a Sale Order with stockable products a *Valued picking* able
|
||||
customer.
|
||||
#. Create different discounts in sale order lines.
|
||||
#. Confirm the Sale Order.
|
||||
#. Click on *Deliveries* stat button.
|
||||
#. Go to *Print > Delivery Slip*.
|
||||
|
||||
|
||||
.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
|
||||
:alt: Try me on Runbot
|
||||
:target: https://runbot.odoo-community.org/runbot/151/10.0
|
||||
|
||||
Known issues / Roadmap
|
||||
======================
|
||||
|
||||
* If there are several sale order lines with same product but different
|
||||
price or taxes the picking value is not valid.
|
||||
|
||||
Bug Tracker
|
||||
===========
|
||||
|
||||
Bugs are tracked on `GitHub Issues
|
||||
<https://github.com/OCA/stock-logistics-reporting/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.
|
||||
|
||||
Credits
|
||||
=======
|
||||
|
||||
Images
|
||||
------
|
||||
|
||||
* Odoo Community Association: `Icon <https://github.com/OCA/maintainer-tools/blob/master/template/module/static/description/icon.svg>`_.
|
||||
|
||||
Contributors
|
||||
------------
|
||||
|
||||
* Luis M. Ontalba <luis.martinez@tecnativa.com>
|
||||
|
||||
Do not contact contributors directly about support or help with technical issues.
|
||||
|
||||
Maintainer
|
||||
----------
|
||||
|
||||
.. image:: https://odoo-community.org/logo.png
|
||||
:alt: Odoo Community Association
|
||||
:target: https://odoo-community.org
|
||||
|
||||
This module is maintained by the OCA.
|
||||
|
||||
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.
|
||||
|
||||
To contribute to this module, please visit https://odoo-community.org.
|
||||
3
stock_valued_picking_report_triple_discount/__init__.py
Normal file
3
stock_valued_picking_report_triple_discount/__init__.py
Normal file
@@ -0,0 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from . import models
|
||||
22
stock_valued_picking_report_triple_discount/__manifest__.py
Normal file
22
stock_valued_picking_report_triple_discount/__manifest__.py
Normal file
@@ -0,0 +1,22 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright 2017 Luis M. Ontalba - Tecnativa <luis.martinez@tecnativa.com>
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
{
|
||||
"name": "Stock Valued Picking Report Triple Discount",
|
||||
"summary": "Adding Triple Discount on Valued Picking Report",
|
||||
"version": "10.0.1.0.0",
|
||||
"author": "Tecnativa, "
|
||||
"Odoo Community Association (OCA)",
|
||||
"website": "https://github.com/OCA/stock-logistics-reporting",
|
||||
"category": "Warehouse Management",
|
||||
"license": "AGPL-3",
|
||||
"depends": [
|
||||
"sale_triple_discount",
|
||||
"stock_valued_picking_report",
|
||||
],
|
||||
"data": [
|
||||
'report/stock_valued_picking_report_triple_discount.xml',
|
||||
],
|
||||
"installable": True,
|
||||
}
|
||||
82
stock_valued_picking_report_triple_discount/i18n/es.po
Normal file
82
stock_valued_picking_report_triple_discount/i18n/es.po
Normal file
@@ -0,0 +1,82 @@
|
||||
# Translation of Odoo Server.
|
||||
# This file contains the translation of the following modules:
|
||||
# * stock_valued_picking_report_triple_discount
|
||||
#
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Odoo Server 10.0\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2017-10-09 11:11+0000\n"
|
||||
"PO-Revision-Date: 2017-10-09 11:11+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: stock_valued_picking_report_triple_discount
|
||||
#: model:ir.ui.view,arch_db:stock_valued_picking_report_triple_discount.valued_report_picking
|
||||
msgid "<span class=\"pull-left\">Lot/Serial Number</span>"
|
||||
msgstr "<span class=\"pull-left\">Número Lote/Serie</span>"
|
||||
|
||||
#. module: stock_valued_picking_report_triple_discount
|
||||
#: model:ir.ui.view,arch_db:stock_valued_picking_report_triple_discount.valued_report_picking
|
||||
msgid "<strong>Delivered Quantity</strong>"
|
||||
msgstr "<strong>Cantidad entregada</strong>"
|
||||
|
||||
#. module: stock_valued_picking_report_triple_discount
|
||||
#: model:ir.ui.view,arch_db:stock_valued_picking_report_triple_discount.valued_report_picking
|
||||
msgid "<strong>Disc.2(%)</strong>"
|
||||
msgstr "<strong>Dto.2(%)</strong>"
|
||||
|
||||
#. module: stock_valued_picking_report_triple_discount
|
||||
#: model:ir.ui.view,arch_db:stock_valued_picking_report_triple_discount.valued_report_picking
|
||||
msgid "<strong>Disc.3(%)</strong>"
|
||||
msgstr "<strong>Dto.3(%)</strong>"
|
||||
|
||||
#. module: stock_valued_picking_report_triple_discount
|
||||
#: model:ir.ui.view,arch_db:stock_valued_picking_report_triple_discount.valued_report_picking
|
||||
msgid "<strong>Discount(%)</strong>"
|
||||
msgstr "<strong>Descuento(%)</strong>"
|
||||
|
||||
#. module: stock_valued_picking_report_triple_discount
|
||||
#: model:ir.ui.view,arch_db:stock_valued_picking_report_triple_discount.valued_report_picking
|
||||
msgid "<strong>Ordered Quantity</strong>"
|
||||
msgstr "<strong>Cantidad pedida</strong>"
|
||||
|
||||
#. module: stock_valued_picking_report_triple_discount
|
||||
#: model:ir.ui.view,arch_db:stock_valued_picking_report_triple_discount.valued_report_picking
|
||||
msgid "<strong>Product</strong>"
|
||||
msgstr "<strong>Producto</strong>"
|
||||
|
||||
#. module: stock_valued_picking_report_triple_discount
|
||||
#: model:ir.ui.view,arch_db:stock_valued_picking_report_triple_discount.valued_report_picking
|
||||
msgid "<strong>Subtotal</strong>"
|
||||
msgstr "<strong>Subtotal</strong>"
|
||||
|
||||
#. module: stock_valued_picking_report_triple_discount
|
||||
#: model:ir.ui.view,arch_db:stock_valued_picking_report_triple_discount.valued_report_picking
|
||||
msgid "<strong>Taxes</strong>"
|
||||
msgstr "<strong>Impuestos</strong>"
|
||||
|
||||
#. module: stock_valued_picking_report_triple_discount
|
||||
#: model:ir.ui.view,arch_db:stock_valued_picking_report_triple_discount.valued_report_picking
|
||||
msgid "<strong>Unit Price</strong>"
|
||||
msgstr "<strong>Precio Unidad</strong>"
|
||||
|
||||
#. module: stock_valued_picking_report_triple_discount
|
||||
#: model:ir.model,name:stock_valued_picking_report_triple_discount.model_stock_pack_operation
|
||||
msgid "Packing Operation"
|
||||
msgstr "Operación de empaquetado"
|
||||
|
||||
#. module: stock_valued_picking_report_triple_discount
|
||||
#: model:ir.model.fields,field_description:stock_valued_picking_report_triple_discount.field_stock_pack_operation_sale_discount2
|
||||
msgid "Sale discount 2 (%)"
|
||||
msgstr "Descuento 2 de venta (%)"
|
||||
|
||||
#. module: stock_valued_picking_report_triple_discount
|
||||
#: model:ir.model.fields,field_description:stock_valued_picking_report_triple_discount.field_stock_pack_operation_sale_discount3
|
||||
msgid "Sale discount 3 (%)"
|
||||
msgstr "Descuento 3 de venta (%)"
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from . import stock_pack_operation
|
||||
@@ -0,0 +1,43 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright 2017 Luis M. Ontalba - Tecnativa <luis.martinez@tecnativa.com>
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from odoo import api, fields, models
|
||||
from odoo.addons import decimal_precision as dp
|
||||
|
||||
|
||||
class StockPackOperation(models.Model):
|
||||
_inherit = "stock.pack.operation"
|
||||
|
||||
sale_discount2 = fields.Float(
|
||||
compute='_compute_sale_order_line_fields',
|
||||
digits=dp.get_precision('Discount'),
|
||||
string="Sale discount 2 (%)")
|
||||
sale_discount3 = fields.Float(
|
||||
compute='_compute_sale_order_line_fields',
|
||||
digits=dp.get_precision('Discount'),
|
||||
string="Sale discount 3 (%)")
|
||||
|
||||
@api.multi
|
||||
def sale_lines_values(self, sale_lines):
|
||||
sum_qty = sum_discount2 = sum_discount3 = 0.0
|
||||
prev_price_unit = {}
|
||||
for sale_line in sale_lines:
|
||||
sum_qty += sale_line.product_uom_qty
|
||||
sum_discount2 += sale_line.discount2 * sale_line.product_uom_qty
|
||||
sum_discount3 += sale_line.discount3 * sale_line.product_uom_qty
|
||||
prev_price_unit['sale_line.id'] = sale_line.price_unit
|
||||
new_price = sale_line.price_unit * (
|
||||
1 - ((sale_line.discount2 or 0.0) / 100)) * (
|
||||
1 - ((sale_line.discount3 or 0.0) / 100))
|
||||
sale_line.update({
|
||||
'price_unit': new_price,
|
||||
})
|
||||
res = super(StockPackOperation, self).sale_lines_values(sale_lines)
|
||||
res['sale_discount2'] = sum_discount2 / (sum_qty or 1)
|
||||
res['sale_discount3'] = sum_discount3 / (sum_qty or 1)
|
||||
for sale_line in sale_lines:
|
||||
sale_line.update({
|
||||
'price_unit': prev_price_unit['sale_line.id']
|
||||
})
|
||||
return res
|
||||
@@ -0,0 +1,41 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
<template id="valued_report_picking" inherit_id="stock_valued_picking_report.valued_report_picking">
|
||||
|
||||
<xpath expr="//t[@t-set='has_serial_number']" position="after">
|
||||
<t t-set="has_discount2"
|
||||
t-value="o.pack_operation_ids.filtered('linked_move_operation_ids.move_id.procurement_id.sale_line_id.discount2')"/>
|
||||
<t t-set="has_discount3"
|
||||
t-value="o.pack_operation_ids.filtered('linked_move_operation_ids.move_id.procurement_id.sale_line_id.discount3')"/>
|
||||
</xpath>
|
||||
<xpath
|
||||
expr="//table[@t-if='o.pack_operation_ids']/thead/tr/t/th[@groups='sale.group_discount_per_so_line'/.]"
|
||||
position="after">
|
||||
<t t-if="has_discount2">
|
||||
<th class="text-right" groups="sale.group_discount_per_so_line">
|
||||
<strong>Disc.2(%)</strong>
|
||||
</th>
|
||||
</t>
|
||||
<t t-if="has_discount3">
|
||||
<th class="text-right" groups="sale.group_discount_per_so_line">
|
||||
<strong>Disc.3(%)</strong>
|
||||
</th>
|
||||
</t>
|
||||
</xpath>
|
||||
<xpath
|
||||
expr="//span[@t-field='pack_operation.sale_discount']/."
|
||||
position="after">
|
||||
<t t-if="has_discount2">
|
||||
<td class="text-right" groups="sale.group_discount_per_so_line">
|
||||
<span t-field="pack_operation.sale_discount2" />
|
||||
</td>
|
||||
</t>
|
||||
<t t-if="has_discount3">
|
||||
<td class="text-right" groups="sale.group_discount_per_so_line">
|
||||
<span t-field="pack_operation.sale_discount3" />
|
||||
</td>
|
||||
</t>
|
||||
</xpath>
|
||||
|
||||
</template>
|
||||
</odoo>
|
||||
@@ -0,0 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from . import test_stock_picking_valued_report_triple_discount
|
||||
@@ -0,0 +1,88 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright 2017 Luis M. Ontalba - Tecnativa <luis.martinez@tecnativa.com>
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from odoo.tests import common
|
||||
|
||||
|
||||
class TestStockPickingValuedTripleDiscount(common.SavepointCase):
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
super(TestStockPickingValuedTripleDiscount, cls).setUpClass()
|
||||
cls.partner = cls.env['res.partner'].create({
|
||||
'name': 'Mr. Odoo',
|
||||
})
|
||||
cls.product1 = cls.env['product.product'].create({
|
||||
'name': 'Test Product 1',
|
||||
})
|
||||
cls.product2 = cls.env['product.product'].create({
|
||||
'name': 'Test Product 2',
|
||||
})
|
||||
cls.tax = cls.env['account.tax'].create({
|
||||
'name': 'TAX 15%',
|
||||
'amount_type': 'percent',
|
||||
'type_tax_use': 'sale',
|
||||
'amount': 15.0,
|
||||
})
|
||||
cls.order = cls.env['sale.order'].create({
|
||||
'partner_id': cls.partner.id
|
||||
})
|
||||
so_line = cls.env['sale.order.line']
|
||||
cls.so_line1 = so_line.create({
|
||||
'order_id': cls.order.id,
|
||||
'product_id': cls.product1.id,
|
||||
'name': 'Line 1',
|
||||
'product_uom_qty': 1.0,
|
||||
'tax_id': [(6, 0, [cls.tax.id])],
|
||||
'price_unit': 600.0,
|
||||
})
|
||||
cls.so_line2 = so_line.create({
|
||||
'order_id': cls.order.id,
|
||||
'product_id': cls.product2.id,
|
||||
'name': 'Line 2',
|
||||
'product_uom_qty': 10.0,
|
||||
'tax_id': [(6, 0, [cls.tax.id])],
|
||||
'price_unit': 60.0,
|
||||
})
|
||||
|
||||
def test_valued_picking_classic_discount(self):
|
||||
""" Tests with single discount """
|
||||
self.so_line1.discount = 50.0
|
||||
self.so_line2.discount = 75.0
|
||||
self.assertEqual(self.so_line1.price_subtotal, 300.0)
|
||||
self.assertEqual(self.so_line2.price_subtotal, 150.0)
|
||||
self.assertEqual(self.order.amount_untaxed, 450.0)
|
||||
self.assertEqual(self.order.amount_tax, 67.5)
|
||||
self.order.action_confirm()
|
||||
self.assertTrue(len(self.order.picking_ids))
|
||||
for picking in self.order.picking_ids:
|
||||
self.assertEqual(picking.amount_untaxed, 450.0)
|
||||
self.assertEqual(picking.amount_tax, 67.5)
|
||||
self.assertEqual(picking.amount_total, 517.5)
|
||||
|
||||
def test_valued_picking_classic_discount_mix_taxed(self):
|
||||
""" Mix taxed and untaxed """
|
||||
self.so_line1.tax_id = False
|
||||
self.so_line1.discount = 50.0
|
||||
self.so_line2.discount = 75.0
|
||||
self.assertEqual(self.order.amount_tax, 22.5)
|
||||
self.order.action_confirm()
|
||||
self.assertTrue(len(self.order.picking_ids))
|
||||
for picking in self.order.picking_ids:
|
||||
self.assertEqual(picking.amount_tax, 22.5)
|
||||
|
||||
def test_valued_picking_triple_discount(self):
|
||||
""" Tests with triple discount """
|
||||
self.so_line1.discount = 50.0
|
||||
self.so_line1.discount2 = 50.0
|
||||
self.so_line1.discount3 = 50.0
|
||||
self.assertEqual(self.so_line1.price_subtotal, 75.0)
|
||||
self.assertEqual(self.order.amount_untaxed, 675.0)
|
||||
self.assertEqual(self.order.amount_tax, 101.25)
|
||||
self.order.action_confirm()
|
||||
self.assertTrue(len(self.order.picking_ids))
|
||||
for picking in self.order.picking_ids:
|
||||
self.assertEqual(picking.amount_untaxed, 675.0)
|
||||
self.assertEqual(picking.amount_tax, 101.25)
|
||||
self.assertEqual(picking.amount_total, 776.25)
|
||||
Reference in New Issue
Block a user