mirror of
https://github.com/OCA/stock-logistics-reporting.git
synced 2025-02-16 17:13:21 +02:00
@@ -4,11 +4,8 @@
|
||||
# Copyright 2016-2022 Tecnativa - Carlos Dauden
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from functools import partial
|
||||
|
||||
from odoo import fields, models
|
||||
from odoo.tools import float_compare
|
||||
from odoo.tools.misc import formatLang
|
||||
|
||||
|
||||
class StockMoveLine(models.Model):
|
||||
@@ -99,50 +96,3 @@ class StockMoveLine(models.Model):
|
||||
"sale_price_unit": valued_line.price_unit,
|
||||
}
|
||||
)
|
||||
|
||||
def _get_aggregated_product_quantities(self, **kwargs):
|
||||
result = super()._get_aggregated_product_quantities(**kwargs)
|
||||
if self.env.context.get("bypass_modification_valued_report"):
|
||||
return result
|
||||
result = self._get_aggregated_product_quantities_delivery_price(result)
|
||||
return result
|
||||
|
||||
def _get_aggregated_product_quantities_delivery_price(self, aggregated_move_lines):
|
||||
# sale order can have sold products under different prices
|
||||
# currently lines on stock.picking will consider only first price
|
||||
# so total on sale.order and stock.picking will differ
|
||||
# consider riding of aggregating of lines for stock.picking
|
||||
fmt = partial(
|
||||
formatLang,
|
||||
self.with_context(lang=self.picking_id.partner_id.lang).env,
|
||||
currency_obj=self.picking_id.currency_id,
|
||||
)
|
||||
|
||||
for line in aggregated_move_lines:
|
||||
product = aggregated_move_lines[line]["product"]
|
||||
uom = aggregated_move_lines[line]["product_uom"]
|
||||
sml = self._find_sml(product, uom)
|
||||
qty = aggregated_move_lines[line]["qty_done"] or sml.move_id.product_uom_qty
|
||||
aggregated_move_lines[line].update(
|
||||
{
|
||||
"unit_price": fmt(sml.sale_price_unit),
|
||||
"tax": ", ".join(
|
||||
map(
|
||||
lambda x: (x.description or x.name),
|
||||
sml.sale_tax_id,
|
||||
)
|
||||
),
|
||||
"total": (sml.sale_price_unit * qty),
|
||||
}
|
||||
)
|
||||
return aggregated_move_lines
|
||||
|
||||
def _find_sml(self, product, uom_name):
|
||||
line = fields.first(
|
||||
self.filtered(
|
||||
lambda sml: sml.product_id == product
|
||||
and sml.product_uom_id.name == uom_name
|
||||
)
|
||||
)
|
||||
|
||||
return line
|
||||
|
||||
@@ -1,2 +1 @@
|
||||
* If the picking is not reserved, values aren't computed.
|
||||
* Add tax printing by group
|
||||
|
||||
@@ -6,27 +6,19 @@
|
||||
expr="//table[@t-if="o.move_line_ids and o.state=='done'"]/thead/tr"
|
||||
position="inside"
|
||||
>
|
||||
<t t-if="o.picking_type_id.code == 'outgoing'">
|
||||
<t t-if="o.valued and o.sale_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" name="unit_price"><strong
|
||||
>Unit Price</strong></th>
|
||||
<th
|
||||
class="text-right"
|
||||
name="discount"
|
||||
groups="product.group_discount_per_so_line"
|
||||
>
|
||||
<strong>Discount</strong>
|
||||
</th>
|
||||
<th class="text-right" name="subtotal"><strong
|
||||
>Subtotal</strong></th>
|
||||
<th class="text-right" name="taxes"><strong>Taxes</strong></th>
|
||||
<t t-if="o.valued and o.sale_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>
|
||||
<th class="text-right"><strong>Taxes</strong></th>
|
||||
</t>
|
||||
</xpath>
|
||||
<!-- <xpath
|
||||
<xpath
|
||||
expr="//t[@t-foreach='packages']//t[@t-if='has_serial_number']"
|
||||
position="attributes"
|
||||
>
|
||||
@@ -55,39 +47,34 @@
|
||||
add="or (o.valued and o.sale_id and o.move_line_ids)"
|
||||
separator=" "
|
||||
/>
|
||||
</xpath> -->
|
||||
</xpath>
|
||||
<xpath
|
||||
expr="//table[@t-if="o.move_line_ids and o.state=='done'"]"
|
||||
position="after"
|
||||
>
|
||||
<t t-if="o.picking_type_id.code == 'outgoing'">
|
||||
<t t-if="o.valued and o.sale_id and o.move_line_ids">
|
||||
<table class="table table-sm mt32" name="totals">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="text-right" name="am_untaxed"><strong
|
||||
>Untaxed Amount</strong></th>
|
||||
<th class="text-right" name="taxes"><strong
|
||||
>Taxes</strong></th>
|
||||
<th class="text-right" name="subtotal"><strong
|
||||
>Total</strong></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td class="text-right" name="am_untaxed">
|
||||
<span t-field="o.amount_untaxed" />
|
||||
</td>
|
||||
<td class="text-right" name="taxes">
|
||||
<span t-field="o.amount_tax" />
|
||||
</td>
|
||||
<td class="text-right" name="subtotal">
|
||||
<span t-field="o.amount_total" />
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</t>
|
||||
<t t-if="o.valued and o.sale_id and o.move_line_ids">
|
||||
<table class="table table-sm mt32">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="text-right"><strong>Untaxed Amount</strong></th>
|
||||
<th class="text-right"><strong>Taxes</strong></th>
|
||||
<th class="text-right"><strong>Total</strong></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td class="text-right">
|
||||
<span t-field="o.amount_untaxed" />
|
||||
</td>
|
||||
<td class="text-right">
|
||||
<span t-field="o.amount_tax" />
|
||||
</td>
|
||||
<td class="text-right">
|
||||
<span t-field="o.amount_total" />
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</t>
|
||||
</xpath>
|
||||
</template>
|
||||
@@ -97,58 +84,22 @@
|
||||
inherit_id="stock.stock_report_delivery_has_serial_move_line"
|
||||
>
|
||||
<xpath expr="//span[@t-field='move_line.qty_done']/.." position="after">
|
||||
<t t-if="o.picking_type_id.code == 'outgoing'">
|
||||
<t t-if="o.valued and o.sale_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" name="unit_price"><span
|
||||
t-field="move_line.sale_price_unit"
|
||||
/></td>
|
||||
<td
|
||||
class="text-right"
|
||||
name="discount"
|
||||
groups="product.group_discount_per_so_line"
|
||||
>
|
||||
<span t-field="move_line.sale_discount" />
|
||||
</td>
|
||||
<td class="text-right" name="subtotal"><span
|
||||
t-field="move_line.sale_price_subtotal"
|
||||
/></td>
|
||||
<td class="text-right" name="taxes"><span
|
||||
t-field="move_line.sale_tax_description"
|
||||
/></td>
|
||||
<t t-if="o.valued and o.sale_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>
|
||||
</t>
|
||||
</xpath>
|
||||
</template>
|
||||
|
||||
<template id="aggregated_move_lines_price_part">
|
||||
<td class="text-right" name="move_line_aggregated_price">
|
||||
<span t-esc="aggregated_lines[line]['unit_price']" />
|
||||
</td>
|
||||
<td class="text-right" name="move_line_aggregated_taxl">
|
||||
<span t-esc="aggregated_lines[line]['tax']" />
|
||||
</td>
|
||||
<td class="text-right" name="move_line_aggregated_total">
|
||||
<span
|
||||
t-esc="aggregated_lines[line]['total']"
|
||||
t-options='{"widget": "monetary", "display_currency": o.currency_id}'
|
||||
/>
|
||||
</td>
|
||||
</template>
|
||||
|
||||
<template
|
||||
id="stock_report_delivery_aggregated_move_lines"
|
||||
inherit_id="stock.stock_report_delivery_aggregated_move_lines"
|
||||
>
|
||||
<xpath expr="//td[last()]" position="after">
|
||||
<t t-if="o.picking_type_id.code == 'outgoing'">
|
||||
<t
|
||||
t-call="stock_picking_report_valued.aggregated_move_lines_price_part"
|
||||
/>
|
||||
<td class="text-right"><span t-field="move_line.sale_price_unit" /></td>
|
||||
<td class="text-right" groups="product.group_discount_per_so_line">
|
||||
<span t-field="move_line.sale_discount" />
|
||||
</td>
|
||||
<td class="text-right"><span
|
||||
t-field="move_line.sale_price_subtotal"
|
||||
/></td>
|
||||
<td class="text-right"><span
|
||||
t-field="move_line.sale_tax_description"
|
||||
/></td>
|
||||
</t>
|
||||
</xpath>
|
||||
</template>
|
||||
|
||||
Reference in New Issue
Block a user