mirror of
https://github.com/OCA/stock-logistics-reporting.git
synced 2025-02-16 17:13:21 +02:00
Revert "14.0 stock_picking_report_valued"
This commit is contained in:
@@ -4,11 +4,8 @@
|
|||||||
# Copyright 2016-2022 Tecnativa - Carlos Dauden
|
# Copyright 2016-2022 Tecnativa - Carlos Dauden
|
||||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||||
|
|
||||||
from functools import partial
|
|
||||||
|
|
||||||
from odoo import fields, models
|
from odoo import fields, models
|
||||||
from odoo.tools import float_compare
|
from odoo.tools import float_compare
|
||||||
from odoo.tools.misc import formatLang
|
|
||||||
|
|
||||||
|
|
||||||
class StockMoveLine(models.Model):
|
class StockMoveLine(models.Model):
|
||||||
@@ -99,50 +96,3 @@ class StockMoveLine(models.Model):
|
|||||||
"sale_price_unit": valued_line.price_unit,
|
"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.
|
* 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"
|
expr="//table[@t-if="o.move_line_ids and o.state=='done'"]/thead/tr"
|
||||||
position="inside"
|
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.valued and o.sale_id and o.move_line_ids">
|
||||||
<t t-if="o.state != 'done'">
|
<t t-if="o.state != 'done'">
|
||||||
<th class="text-right"><strong>Qty Reserved</strong></th>
|
<th class="text-right"><strong>Qty Reserved</strong></th>
|
||||||
</t>
|
</t>
|
||||||
<th class="text-right" name="unit_price"><strong
|
<th class="text-right"><strong>Unit Price</strong></th>
|
||||||
>Unit Price</strong></th>
|
<th class="text-right" groups="product.group_discount_per_so_line">
|
||||||
<th
|
|
||||||
class="text-right"
|
|
||||||
name="discount"
|
|
||||||
groups="product.group_discount_per_so_line"
|
|
||||||
>
|
|
||||||
<strong>Discount</strong>
|
<strong>Discount</strong>
|
||||||
</th>
|
</th>
|
||||||
<th class="text-right" name="subtotal"><strong
|
<th class="text-right"><strong>Subtotal</strong></th>
|
||||||
>Subtotal</strong></th>
|
<th class="text-right"><strong>Taxes</strong></th>
|
||||||
<th class="text-right" name="taxes"><strong>Taxes</strong></th>
|
|
||||||
</t>
|
|
||||||
</t>
|
</t>
|
||||||
</xpath>
|
</xpath>
|
||||||
<!-- <xpath
|
<xpath
|
||||||
expr="//t[@t-foreach='packages']//t[@t-if='has_serial_number']"
|
expr="//t[@t-foreach='packages']//t[@t-if='has_serial_number']"
|
||||||
position="attributes"
|
position="attributes"
|
||||||
>
|
>
|
||||||
@@ -55,40 +47,35 @@
|
|||||||
add="or (o.valued and o.sale_id and o.move_line_ids)"
|
add="or (o.valued and o.sale_id and o.move_line_ids)"
|
||||||
separator=" "
|
separator=" "
|
||||||
/>
|
/>
|
||||||
</xpath> -->
|
</xpath>
|
||||||
<xpath
|
<xpath
|
||||||
expr="//table[@t-if="o.move_line_ids and o.state=='done'"]"
|
expr="//table[@t-if="o.move_line_ids and o.state=='done'"]"
|
||||||
position="after"
|
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="o.valued and o.sale_id and o.move_line_ids">
|
||||||
<table class="table table-sm mt32" name="totals">
|
<table class="table table-sm mt32">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th class="text-right" name="am_untaxed"><strong
|
<th class="text-right"><strong>Untaxed Amount</strong></th>
|
||||||
>Untaxed Amount</strong></th>
|
<th class="text-right"><strong>Taxes</strong></th>
|
||||||
<th class="text-right" name="taxes"><strong
|
<th class="text-right"><strong>Total</strong></th>
|
||||||
>Taxes</strong></th>
|
|
||||||
<th class="text-right" name="subtotal"><strong
|
|
||||||
>Total</strong></th>
|
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
<tr>
|
||||||
<td class="text-right" name="am_untaxed">
|
<td class="text-right">
|
||||||
<span t-field="o.amount_untaxed" />
|
<span t-field="o.amount_untaxed" />
|
||||||
</td>
|
</td>
|
||||||
<td class="text-right" name="taxes">
|
<td class="text-right">
|
||||||
<span t-field="o.amount_tax" />
|
<span t-field="o.amount_tax" />
|
||||||
</td>
|
</td>
|
||||||
<td class="text-right" name="subtotal">
|
<td class="text-right">
|
||||||
<span t-field="o.amount_total" />
|
<span t-field="o.amount_total" />
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</t>
|
</t>
|
||||||
</t>
|
|
||||||
</xpath>
|
</xpath>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -97,59 +84,23 @@
|
|||||||
inherit_id="stock.stock_report_delivery_has_serial_move_line"
|
inherit_id="stock.stock_report_delivery_has_serial_move_line"
|
||||||
>
|
>
|
||||||
<xpath expr="//span[@t-field='move_line.qty_done']/.." position="after">
|
<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="o.valued and o.sale_id and o.move_line_ids">
|
||||||
<t t-if="move_line.picking_id.state != 'done'">
|
<t t-if="move_line.picking_id.state != 'done'">
|
||||||
<td class="text-right">
|
<td class="text-right">
|
||||||
<span t-field="move_line.product_uom_qty" />
|
<span t-field="move_line.product_uom_qty" />
|
||||||
<span t-field="move_line.product_uom_id" /></td>
|
<span t-field="move_line.product_uom_id" /></td>
|
||||||
</t>
|
</t>
|
||||||
<td class="text-right" name="unit_price"><span
|
<td class="text-right"><span t-field="move_line.sale_price_unit" /></td>
|
||||||
t-field="move_line.sale_price_unit"
|
<td class="text-right" groups="product.group_discount_per_so_line">
|
||||||
/></td>
|
|
||||||
<td
|
|
||||||
class="text-right"
|
|
||||||
name="discount"
|
|
||||||
groups="product.group_discount_per_so_line"
|
|
||||||
>
|
|
||||||
<span t-field="move_line.sale_discount" />
|
<span t-field="move_line.sale_discount" />
|
||||||
</td>
|
</td>
|
||||||
<td class="text-right" name="subtotal"><span
|
<td class="text-right"><span
|
||||||
t-field="move_line.sale_price_subtotal"
|
t-field="move_line.sale_price_subtotal"
|
||||||
/></td>
|
/></td>
|
||||||
<td class="text-right" name="taxes"><span
|
<td class="text-right"><span
|
||||||
t-field="move_line.sale_tax_description"
|
t-field="move_line.sale_tax_description"
|
||||||
/></td>
|
/></td>
|
||||||
</t>
|
</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"
|
|
||||||
/>
|
|
||||||
</t>
|
|
||||||
</xpath>
|
</xpath>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user