Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[13.0][ADD] purchase_stock_picking_report_valued_slv #20

Draft
wants to merge 2 commits into
base: 13.0
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions purchase_stock_picking_report_valued_slv/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
19 changes: 19 additions & 0 deletions purchase_stock_picking_report_valued_slv/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# © 2021 Solvos Consultoría Informática (<http://www.solvos.es>)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

{
"name": "Purchase Valued Picking Report",
"summary": "Adding Valued Picking on Delivery Slip report",
"version": "13.0.1.1.0",
"author": "Solvos, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/stock-logistics-reporting",
"category": "Warehouse Management",
"license": "AGPL-3",
"depends": [
"stock_picking_report_valued",
"purchase_discount",
"stock"
],
"data": ["report/purchase_stock_picking_report_valued.xml"],
"installable": True,
}
2 changes: 2 additions & 0 deletions purchase_stock_picking_report_valued_slv/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import stock_move_line
from . import stock_picking
66 changes: 66 additions & 0 deletions purchase_stock_picking_report_valued_slv/models/stock_move_line.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# © 2021 Solvos Consultoría Informática (<http://www.solvos.es>)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import fields, models


class StockMoveLine(models.Model):
_inherit = "stock.move.line"

purchase_line = fields.Many2one(
related="move_id.purchase_line_id",
readonly=True,
string="Related order line"
)
purchase_currency_id = fields.Many2one(
related="purchase_line.currency_id",
readonly=True,
string="Purchase Currency"
)
purchase_tax_id = fields.Many2many(
related="purchase_line.taxes_id",
readonly=True,
string="Purchase Tax"
)
purchase_price_unit = fields.Float(
related="purchase_line.price_unit",
readonly=True,
string="Purchase price unit"
)
purchase_discount = fields.Float(
related="purchase_line.discount",
readonly=True,
string="Purchase discount (%)"
)
purchase_price_subtotal = fields.Monetary(
currency_field="purchase_currency_id",
compute="_compute_purchase_order_line_fields",
string="Price subtotal",
compute_sudo=True
)

def _compute_purchase_order_line_fields(self):
for line in self:
purchase_line = line.purchase_line
price_unit = (
purchase_line.price_subtotal / purchase_line.product_uom_qty
if purchase_line.product_uom_qty
else purchase_line._get_discounted_price_unit()
)
taxes = line.purchase_tax_id.compute_all(
price_unit=price_unit,
currency=line.purchase_currency_id,
quantity=line.qty_done or line.product_qty,
product=line.product_id,
partner=purchase_line.order_id.dest_address_id,
)

line.update(
{
"purchase_price_subtotal": taxes["total_excluded"],
}
)

def get_purchase_name(self):
self.ensure_one()
return '%s %s' % (self.origin, self.display_name)
43 changes: 43 additions & 0 deletions purchase_stock_picking_report_valued_slv/models/stock_picking.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# © 2021 Solvos Consultoría Informática (<http://www.solvos.es>)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import fields, models


class StockPicking(models.Model):
_inherit = "stock.picking"

purchase_currency_id = fields.Many2one(
related="purchase_id.currency_id",
readonly=True,
string="Currency",
related_sudo=True
)
purchase_amount_untaxed = fields.Monetary(
currency_field="purchase_currency_id",
compute="_compute_purchase_amount_all",
compute_sudo=True
)
purchase_amount_total = fields.Monetary(
currency_field="purchase_currency_id",
compute="_compute_purchase_amount_all",
compute_sudo=True
)

def _compute_purchase_amount_all(self):

for pick in self:
purchase_amount_untaxed = sum(
line.purchase_price_subtotal for line in pick.move_line_ids
)
purchase_amount_total = 0
for line in pick.move_line_ids:
purchase_amount_total += (
line.purchase_price_subtotal - (line.purchase_price_subtotal * (line.purchase_line.discount / 100))
)
pick.update(
{
"purchase_amount_untaxed": purchase_amount_untaxed,
"purchase_amount_total": purchase_amount_total,
}
)
2 changes: 2 additions & 0 deletions purchase_stock_picking_report_valued_slv/readme/CONFIGURE.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#. Go to *Customers > (select one of your choice) > Sales & Purchases*.
#. Set *Valued picking* field on.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
* `Solvos <https://www.solvos.es>`_:

* Christian Santamaría
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Add amount information to Delivery Slip report.
You can select at partner level if picking list report must be valued or not.
If the picking is done it's valued with quantity done, otherwise the picking
is valued with reserved quantity.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* If the picking is not reserved, values aren't computed.
7 changes: 7 additions & 0 deletions purchase_stock_picking_report_valued_slv/readme/USAGE.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
To get the stock picking valued report:

#. Create a Purchase Order with stockable products a *Valued picking* able
customer.
#. Confirm the Purchase Order.
#. Click on *Delivery* stat button.
#. Go to *Print > Delivery Slip*.
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>

<template id="valued_report_picking_purchase" inherit_id="stock.report_delivery_document">
<xpath expr="//thead/tr/th[@name=&apos;th_sm_product&apos;]" position="before">
<t t-if="o.purchase_id and o.move_line_ids">
<th name="th_sm_code"><strong>Code</strong></th>
</t>
</xpath>
<xpath expr="//table[@t-if=&quot;o.move_line_ids and o.state==&apos;done&apos;&quot;]/thead/tr"
position="inside">
<t t-if="o.purchase_id and o.move_line_ids">
<t t-if="o.state != 'done'">
<th class="text-right"><strong>Qty Reserved</strong></th>
</t>
<th class="text-right"><strong>Unit Price</strong></th>
<th class="text-right" groups="product.group_discount_per_so_line">
<strong>Discount</strong>
</th>
<th class="text-right"><strong>Subtotal</strong></th>
</t>
</xpath>
<xpath expr="//tbody/tr[@t-foreach='lines']/td" position="before">
<t t-if="o.purchase_id and o.move_line_ids">
<td>
<span t-field="move_line.product_id.default_code"/>
</td>
</t>
</xpath>
<xpath expr="//span[@t-field='move.product_id']" position="before">
<t t-if="o.purchase_id and o.move_line_ids">
<span t-field="move_line.origin"/>
</t>
</xpath>
<xpath expr="//span[@t-field='move_line.qty_done']/.." position="after">
<t t-if="o.purchase_id and o.move_line_ids">
<t t-if="move_line.picking_id.state != 'done'">
<td class="text-right">
<span t-field="move_line.product_uom_qty"/>
<span t-field="move_line.product_uom_id"/></td>
</t>
<td class="text-right"><span
t-field="move_line.purchase_price_unit" /></td>
<td class="text-right" groups="product.group_discount_per_so_line">
<span t-field="move_line.move_id.purchase_line_id.discount" />
</td>
<td class="text-right">
<span t-field="move_line.purchase_price_subtotal" /></td>
</t>
</xpath>
<xpath expr="//table[@t-if=&quot;o.move_line_ids and o.state==&apos;done&apos;&quot;]" position="after">
<t t-if="o.purchase_id and o.move_line_ids">
<table class="table table-sm mt32">
<thead>
<tr>
<th class="text-right"><strong>Net</strong></th>
<th class="text-right"><strong>Total</strong></th>
</tr>
</thead>
<tbody>
<tr>
<td class="text-right">
<span t-field="o.purchase_amount_untaxed"/>
</td>
<td class="text-right">
<span t-field="o.purchase_amount_total"/>
</td>
</tr>
</tbody>
</table>
</t>
</xpath>
</template>
</odoo>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading