mirror of
https://github.com/bringout/oca-ocb-sale.git
synced 2026-04-27 23:32:00 +02:00
19.0 vanilla
This commit is contained in:
parent
79f83631d5
commit
73afc09215
6267 changed files with 1534193 additions and 1130106 deletions
|
|
@ -1,6 +1,5 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from . import report_stock_rule
|
||||
from . import sale_report
|
||||
from . import stock_forecasted
|
||||
from . import report_stock_rule
|
||||
|
|
|
|||
|
|
@ -1,5 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
<template id="sale_report_product_product_replenishment" inherit_id="stock.report_product_product_replenishment">
|
||||
</template>
|
||||
</odoo>
|
||||
|
|
@ -4,12 +4,12 @@
|
|||
from odoo import api, models
|
||||
|
||||
|
||||
class ReportStockRule(models.AbstractModel):
|
||||
class ReportStockReport_Stock_Rule(models.AbstractModel):
|
||||
_inherit = 'report.stock.report_stock_rule'
|
||||
|
||||
@api.model
|
||||
def _get_routes(self, data):
|
||||
res = super(ReportStockRule, self)._get_routes(data)
|
||||
res = super()._get_routes(data)
|
||||
if data.get('so_route_ids'):
|
||||
res = self.env['stock.route'].browse(data['so_route_ids']) | res
|
||||
return res
|
||||
|
|
|
|||
|
|
@ -2,19 +2,13 @@
|
|||
<odoo>
|
||||
<template id="report_saleorder_document_inherit_sale_stock" inherit_id="sale.report_saleorder_document">
|
||||
<xpath expr="//div[@name='expiration_date']" position="after">
|
||||
<div class="col-auto col-3 mw-100 mb-2" t-if="doc.incoterm">
|
||||
<strong>Incoterm:</strong>
|
||||
<p t-if="doc.incoterm_location" t-out="'%s %s' % (doc.incoterm.code, doc.incoterm_location)" class="m-0"/>
|
||||
<p t-else="" t-field="doc.incoterm.code" class="m-0"/>
|
||||
</div>
|
||||
</xpath>
|
||||
</template>
|
||||
|
||||
<template id="report_invoice_document_inherit_sale_stock" inherit_id="account.report_invoice_document">
|
||||
<xpath expr="//div[@name='reference']" position="after">
|
||||
<div class="col-auto col-3 mw-100 mb-2" t-if="o.invoice_incoterm_id" groups="sale_stock.group_display_incoterm" name="invoice_incoterm_id">
|
||||
<strong>Incoterm:</strong>
|
||||
<p class="m-0" t-field="o.invoice_incoterm_id.code"/>
|
||||
<div class="col" t-if="doc.incoterm">
|
||||
<strong>Incoterm</strong>
|
||||
<div t-if="doc.incoterm_location">
|
||||
<span t-field="doc.incoterm.code"/> <br/>
|
||||
<span t-field="doc.incoterm_location"/>
|
||||
</div>
|
||||
<div t-else="" t-field="doc.incoterm.code"/>
|
||||
</div>
|
||||
</xpath>
|
||||
</template>
|
||||
|
|
|
|||
|
|
@ -4,52 +4,52 @@
|
|||
from odoo import models
|
||||
|
||||
|
||||
class ReplenishmentReport(models.AbstractModel):
|
||||
_inherit = 'report.stock.report_product_product_replenishment'
|
||||
class StockForecasted_Product_Product(models.AbstractModel):
|
||||
_inherit = 'stock.forecasted_product_product'
|
||||
|
||||
def _serialize_docs(self, docs, product_template_ids=False, product_variant_ids=False):
|
||||
res = super()._serialize_docs(docs, product_template_ids, product_variant_ids)
|
||||
res['draft_sale_orders'] = docs['draft_sale_orders'].read(fields=['id', 'name'])
|
||||
for i in range(len(docs['lines'])):
|
||||
if not docs['lines'][i]['move_out'] or not docs['lines'][i]['move_out']['picking_id'] or not docs['lines'][i]['move_out']['picking_id']['sale_id']:
|
||||
continue
|
||||
picking = docs['lines'][i]['move_out']['picking_id']
|
||||
res['lines'][i]['move_out'].update({
|
||||
'picking_id' : {
|
||||
'id' : picking.id,
|
||||
'priority' : picking.priority,
|
||||
'sale_id' : {
|
||||
'id' : picking.sale_id.id,
|
||||
'amount_untaxed' : picking.sale_id.amount_untaxed,
|
||||
'currency_id' : picking.sale_id.currency_id.read(fields=['id', 'name'])[0],
|
||||
'partner_id' : picking.sale_id.partner_id.read(fields=['id', 'name'])[0],
|
||||
def _prepare_report_line(self, quantity, move_out=None, move_in=None, replenishment_filled=True, product=False, reserved_move=False, in_transit=False, read=True):
|
||||
line = super()._prepare_report_line(quantity, move_out, move_in, replenishment_filled, product, reserved_move, in_transit, read)
|
||||
|
||||
if not move_out or not move_out.picking_id or not move_out.picking_id.sale_id:
|
||||
return line
|
||||
|
||||
picking = move_out.picking_id
|
||||
# If read is False, line['move_out'] is a stock.move record and will trigger a record update
|
||||
if read:
|
||||
line['move_out'].update({
|
||||
'picking_id': {
|
||||
'id': picking.id,
|
||||
'priority': picking.priority,
|
||||
'sale_id': {
|
||||
'id': picking.sale_id.id,
|
||||
'amount_untaxed': picking.sale_id.amount_untaxed,
|
||||
'currency_id': picking.sale_id.currency_id.read(fields=['id', 'name'])[0],
|
||||
'partner_id': picking.sale_id.partner_id.read(fields=['id', 'display_name'])[0],
|
||||
}
|
||||
}
|
||||
})
|
||||
return line
|
||||
|
||||
def _get_report_header(self, product_template_ids, product_ids, wh_location_ids):
|
||||
res = super()._get_report_header(product_template_ids, product_ids, wh_location_ids)
|
||||
domain = self._product_sale_domain(product_template_ids, product_ids)
|
||||
so_lines = self.env['sale.order.line'].sudo().search(domain).grouped('product_id')
|
||||
out_qty = {k.id: sum(v.mapped(lambda line: line.product_uom_id._compute_quantity(line.product_uom_qty, line.product_id.uom_id))) for k, v in so_lines.items()}
|
||||
self._add_product_quantities(res, product_template_ids, product_ids, 'draft_sale_qty', qty_out=out_qty)
|
||||
for product in self._get_products(product_template_ids, product_ids):
|
||||
if product not in so_lines:
|
||||
continue
|
||||
res['product'][product.id]['draft_sale_orders'] = so_lines[product].mapped("order_id").sorted(key=lambda so: so.name).read(fields=['id', 'name'])
|
||||
res['product'][product.id]['draft_sale_orders_matched'] = self.env.context.get('sale_line_to_match_id') in so_lines[product].ids
|
||||
return res
|
||||
|
||||
def _compute_draft_quantity_count(self, product_template_ids, product_variant_ids, wh_location_ids):
|
||||
res = super()._compute_draft_quantity_count(product_template_ids, product_variant_ids, wh_location_ids)
|
||||
domain = self._product_sale_domain(product_template_ids, product_variant_ids)
|
||||
so_lines = self.env['sale.order.line'].sudo().search(domain)
|
||||
out_sum = 0
|
||||
if so_lines:
|
||||
product_uom = so_lines[0].product_id.uom_id
|
||||
quantities = so_lines.mapped(lambda line: line.product_uom._compute_quantity(line.product_uom_qty, product_uom))
|
||||
out_sum = sum(quantities)
|
||||
res['draft_sale_qty'] = out_sum
|
||||
res['draft_sale_orders'] = so_lines.mapped("order_id").sorted(key=lambda so: so.name)
|
||||
res['draft_sale_orders_matched'] = self.env.context.get('sale_line_to_match_id') in so_lines.ids
|
||||
res['qty']['out'] += out_sum
|
||||
return res
|
||||
|
||||
def _product_sale_domain(self, product_template_ids, product_variant_ids):
|
||||
def _product_sale_domain(self, product_template_ids, product_ids):
|
||||
domain = [('state', 'in', ['draft', 'sent'])]
|
||||
if product_template_ids:
|
||||
domain += [('product_template_id', 'in', product_template_ids)]
|
||||
elif product_variant_ids:
|
||||
domain += [('product_id', 'in', product_variant_ids)]
|
||||
warehouse_id = self.env['stock.warehouse']._get_warehouse_id_from_context()
|
||||
elif product_ids:
|
||||
domain += [('product_id', 'in', product_ids)]
|
||||
warehouse_id = self.env.context.get('warehouse_id', False)
|
||||
if warehouse_id:
|
||||
domain += [('warehouse_id', '=', warehouse_id)]
|
||||
return domain
|
||||
|
|
|
|||
|
|
@ -2,9 +2,14 @@
|
|||
<odoo>
|
||||
<template id="report_delivery_document_inherit_sale_stock" inherit_id="stock.report_delivery_document">
|
||||
<xpath expr="//div[@name='div_sched_date']" position="after">
|
||||
<div t-if="o.sudo().sale_id.client_order_ref" class="col-auto col-3 mw-100 mb-2">
|
||||
<strong>Customer Reference:</strong>
|
||||
<p t-field="o.sudo().sale_id.client_order_ref" class="m-0"/>
|
||||
<div class="col col-3 mw-100 mb-2" t-if="o.sudo().sale_id.client_order_ref">
|
||||
<strong>Customer Reference</strong>
|
||||
<div t-field="o.sudo().sale_id.client_order_ref" class="m-0">Customer reference</div>
|
||||
</div>
|
||||
<div class="col col-3" t-if="o.sudo().sale_id.incoterm">
|
||||
<strong>Incoterm</strong>
|
||||
<div t-if="o.sudo().sale_id.incoterm_location" t-out="'%s %s' % (o.sudo().sale_id.incoterm.code, o.sudo().sale_id.incoterm_location)">Incoterm details</div>
|
||||
<div t-else="" t-field="o.sudo().sale_id.incoterm.display_name">Incoterm details</div>
|
||||
</div>
|
||||
</xpath>
|
||||
</template>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,40 @@
|
|||
from odoo import models
|
||||
|
||||
|
||||
class StockValuationReport(models.AbstractModel):
|
||||
_inherit = 'stock_account.stock.valuation.report'
|
||||
|
||||
# TODO remove in master
|
||||
def _compute_goods_delivered_not_invoiced(self, date=False, product_category=False):
|
||||
""" Compute valuation for already delivered but not invoiced yet goods,.
|
||||
sale order by sale order."""
|
||||
domain = [('qty_to_invoice', '!=', 0)]
|
||||
if product_category:
|
||||
domain += [('product_id.categ_id', '=', product_category.id)]
|
||||
if date:
|
||||
domain += [('order_id.date_order', '<=', date)]
|
||||
sol_by_order = self.env['sale.order.line']._read_group(
|
||||
domain=domain,
|
||||
groupby=['order_id'],
|
||||
aggregates=['id:recordset']
|
||||
)
|
||||
not_invoiced_delivered_lines = []
|
||||
total = 0
|
||||
for order, order_lines in sol_by_order:
|
||||
value = 0
|
||||
for order_line in order_lines:
|
||||
confirmed_invoice_lines = order_line.invoice_lines.filtered(
|
||||
lambda aml: aml.move_id.state == 'posted'
|
||||
)
|
||||
invoiced_value = sum(confirmed_invoice_lines.mapped('amount_currency'), 0)
|
||||
value += order_line.price_subtotal + invoiced_value
|
||||
not_invoiced_delivered_lines.append({
|
||||
'id': order.id,
|
||||
'display_name': order.display_name,
|
||||
'value': value,
|
||||
})
|
||||
total += value
|
||||
return {
|
||||
'lines': not_invoiced_delivered_lines,
|
||||
'value': total,
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue