diff options
| author | stephanchrst <stephanchrst@gmail.com> | 2022-05-10 21:51:50 +0700 |
|---|---|---|
| committer | stephanchrst <stephanchrst@gmail.com> | 2022-05-10 21:51:50 +0700 |
| commit | 3751379f1e9a4c215fb6eb898b4ccc67659b9ace (patch) | |
| tree | a44932296ef4a9b71d5f010906253d8c53727726 /addons/sale_stock/report | |
| parent | 0a15094050bfde69a06d6eff798e9a8ddf2b8c21 (diff) | |
initial commit 2
Diffstat (limited to 'addons/sale_stock/report')
| -rw-r--r-- | addons/sale_stock/report/__init__.py | 6 | ||||
| -rw-r--r-- | addons/sale_stock/report/report_stock_forecasted.py | 32 | ||||
| -rw-r--r-- | addons/sale_stock/report/report_stock_forecasted.xml | 12 | ||||
| -rw-r--r-- | addons/sale_stock/report/report_stock_rule.py | 15 | ||||
| -rw-r--r-- | addons/sale_stock/report/sale_order_report_templates.xml | 20 | ||||
| -rw-r--r-- | addons/sale_stock/report/sale_report.py | 15 | ||||
| -rw-r--r-- | addons/sale_stock/report/stock_report_deliveryslip.xml | 13 |
7 files changed, 113 insertions, 0 deletions
diff --git a/addons/sale_stock/report/__init__.py b/addons/sale_stock/report/__init__.py new file mode 100644 index 00000000..4109cd49 --- /dev/null +++ b/addons/sale_stock/report/__init__.py @@ -0,0 +1,6 @@ +# -*- coding: utf-8 -*- +# Part of Odoo. See LICENSE file for full copyright and licensing details. + +from . import sale_report +from . import report_stock_forecasted +from . import report_stock_rule diff --git a/addons/sale_stock/report/report_stock_forecasted.py b/addons/sale_stock/report/report_stock_forecasted.py new file mode 100644 index 00000000..be66eed9 --- /dev/null +++ b/addons/sale_stock/report/report_stock_forecasted.py @@ -0,0 +1,32 @@ +# -*- coding: utf-8 -*- +# Part of Odoo. See LICENSE file for full copyright and licensing details. + +from odoo import models + + +class ReplenishmentReport(models.AbstractModel): + _inherit = 'report.stock.report_product_product_replenishment' + + 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'].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['qty']['out'] += out_sum + return res + + def _product_sale_domain(self, product_template_ids, product_variant_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.context.get('warehouse', False) + if warehouse_id: + domain += [('warehouse_id', '=', warehouse_id)] + return domain diff --git a/addons/sale_stock/report/report_stock_forecasted.xml b/addons/sale_stock/report/report_stock_forecasted.xml new file mode 100644 index 00000000..996b3396 --- /dev/null +++ b/addons/sale_stock/report/report_stock_forecasted.xml @@ -0,0 +1,12 @@ +<?xml version="1.0" encoding="utf-8"?> +<odoo> + <template id="sale_report_product_product_replenishment" inherit_id="stock.report_product_product_replenishment"> + <xpath expr="//tr[@name='draft_picking_out']" position="after"> + <tr t-if="docs['draft_sale_qty']" name="draft_so_out"> + <td colspan="2">Draft SO</td> + <td t-esc="-docs['draft_sale_qty']" class="text-right"/> + <td t-esc="docs['uom']" groups="uom.group_uom"/> + </tr> + </xpath> + </template> +</odoo> diff --git a/addons/sale_stock/report/report_stock_rule.py b/addons/sale_stock/report/report_stock_rule.py new file mode 100644 index 00000000..6feab379 --- /dev/null +++ b/addons/sale_stock/report/report_stock_rule.py @@ -0,0 +1,15 @@ +# -*- coding: utf-8 -*- +# Part of Odoo. See LICENSE file for full copyright and licensing details. + +from odoo import api, models + + +class ReportStockRule(models.AbstractModel): + _inherit = 'report.stock.report_stock_rule' + + @api.model + def _get_routes(self, data): + res = super(ReportStockRule, self)._get_routes(data) + if data.get('so_route_ids'): + res = self.env['stock.location.route'].browse(data['so_route_ids']) | res + return res diff --git a/addons/sale_stock/report/sale_order_report_templates.xml b/addons/sale_stock/report/sale_order_report_templates.xml new file mode 100644 index 00000000..ebb3418c --- /dev/null +++ b/addons/sale_stock/report/sale_order_report_templates.xml @@ -0,0 +1,20 @@ +<?xml version="1.0"?> +<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-3" t-if="doc.incoterm" groups="sale_stock.group_display_incoterm"> + <strong>Incoterm:</strong> + <p t-field="doc.incoterm.code"/> + </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 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> + </xpath> + </template> +</odoo> diff --git a/addons/sale_stock/report/sale_report.py b/addons/sale_stock/report/sale_report.py new file mode 100644 index 00000000..3c62a279 --- /dev/null +++ b/addons/sale_stock/report/sale_report.py @@ -0,0 +1,15 @@ +# -*- coding: utf-8 -*- +# Part of Odoo. See LICENSE file for full copyright and licensing details. + +from odoo import fields, models + + +class SaleReport(models.Model): + _inherit = "sale.report" + + warehouse_id = fields.Many2one('stock.warehouse', 'Warehouse', readonly=True) + + def _query(self, with_clause='', fields={}, groupby='', from_clause=''): + fields['warehouse_id'] = ", s.warehouse_id as warehouse_id" + groupby += ', s.warehouse_id' + return super(SaleReport, self)._query(with_clause, fields, groupby, from_clause) diff --git a/addons/sale_stock/report/stock_report_deliveryslip.xml b/addons/sale_stock/report/stock_report_deliveryslip.xml new file mode 100644 index 00000000..47bd0ec3 --- /dev/null +++ b/addons/sale_stock/report/stock_report_deliveryslip.xml @@ -0,0 +1,13 @@ +<?xml version="1.0" encoding="utf-8"?> +<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 class="row justify-content-end" t-if="o.sudo().sale_id.client_order_ref"> + <div class="col-auto"> + <strong>Customer Reference:</strong> + <p t-field="o.sudo().sale_id.client_order_ref"/> + </div> + </div> + </xpath> + </template> +</odoo> |
