mirror of
https://github.com/bringout/oca-ocb-accounting.git
synced 2026-04-24 20:22:02 +02:00
19.0 vanilla
This commit is contained in:
parent
ba20ce7443
commit
768b70e05e
2357 changed files with 1057103 additions and 712486 deletions
|
|
@ -0,0 +1,2 @@
|
|||
from . import mrp_report_mo_overview
|
||||
from . import stock_valuation_report
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from odoo import models
|
||||
|
||||
|
||||
class ReportMrpReport_Mo_Overview(models.AbstractModel):
|
||||
_inherit = 'report.mrp.report_mo_overview'
|
||||
|
||||
def _get_unit_cost(self, move):
|
||||
if move.state == 'done':
|
||||
price_unit = move._get_price_unit()
|
||||
return move.product_id.uom_id._compute_price(price_unit, move.product_uom)
|
||||
return super()._get_unit_cost(move)
|
||||
|
|
@ -0,0 +1,80 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
|
||||
<template id="mrp_account.report_wip">
|
||||
<t t-call="web.html_container">
|
||||
<t t-call="web.external_layout">
|
||||
<div class="page">
|
||||
<div class="oe_structure"/>
|
||||
<div class="row mt8">
|
||||
<div class="col-lg-12">
|
||||
<h2>
|
||||
<span>WIP Report for
|
||||
<t t-out="', '.join(docs.account_id.mapped('name'))">Acme Corp.</t>
|
||||
</span>
|
||||
</h2>
|
||||
</div>
|
||||
</div>
|
||||
<div class="oe_structure"/>
|
||||
<div class="row mt8">
|
||||
<div class="col-12">
|
||||
<table class="table table-borderless">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="text-start align-middle"><span>Date</span></th>
|
||||
<th class="text-start align-middle"><span>Ref.</span></th>
|
||||
<th class="text-start align-middle"><span>Product</span></th>
|
||||
<th class="text-start align-middle"><span>Quantity</span></th>
|
||||
<th class="text-start align-middle"><span>Unit of Measure</span></th>
|
||||
<th class="text-end"><span>Amount</span></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr t-foreach="docs" t-as="line" t-att-style="'background-color: #F1F1F1;' if line_index % 2 == 0 else ''">
|
||||
<td class="align-middle">
|
||||
<span t-field="line.date">2023-08-15</span>
|
||||
</td>
|
||||
<td class="align-middle">
|
||||
<span t-field="line.ref">REF123</span>
|
||||
</td>
|
||||
<td class="align-middle">
|
||||
<span t-field="line.product_id">Laptop</span>
|
||||
</td>
|
||||
<td class="align-middle">
|
||||
<span t-field="line.unit_amount">5</span>
|
||||
</td>
|
||||
<td class="align-middle">
|
||||
<span t-field="line.product_uom_id">Units</span>
|
||||
</td>
|
||||
<td class="text-end align-middle">
|
||||
<span t-field="line.amount">$1000</span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="text-end" t-attf-colspan="6">
|
||||
<strong>
|
||||
<span style="margin-right: 15px;">Total</span>
|
||||
<span t-out="sum(docs.mapped('amount'))">$5000</span>
|
||||
</strong>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<div class="oe_structure"/>
|
||||
</div>
|
||||
</t>
|
||||
</t>
|
||||
</template>
|
||||
|
||||
<record id="wip_report" model="ir.actions.report">
|
||||
<field name="name">WIP report</field>
|
||||
<field name="model">account.analytic.line</field>
|
||||
<field name="report_type">qweb-pdf</field>
|
||||
<field name="report_name">mrp_account.report_wip</field>
|
||||
<field name="report_file">report_wip</field>
|
||||
<field name="binding_model_id" ref="model_account_analytic_line"/>
|
||||
<field name="binding_type">report</field>
|
||||
</record>
|
||||
</odoo>
|
||||
|
|
@ -0,0 +1,46 @@
|
|||
from collections import defaultdict
|
||||
|
||||
from odoo import _, models
|
||||
|
||||
|
||||
class StockValuationReport(models.AbstractModel):
|
||||
_inherit = 'stock_account.stock.valuation.report'
|
||||
|
||||
def _get_report_data(self, date=False, product_category=False, warehouse=False):
|
||||
report_data = super()._get_report_data(date=date, product_category=product_category, warehouse=warehouse)
|
||||
if not self._must_include_cost_of_production():
|
||||
return report_data
|
||||
production_locations_valuation_vals = self.env.company._get_location_valuation_vals(
|
||||
location_domain=[('usage', '=', 'production')]
|
||||
)
|
||||
cost_of_production = {
|
||||
'label': _("Cost of Production"),
|
||||
'value': 0,
|
||||
}
|
||||
lines_by_account_id = defaultdict(lambda: {
|
||||
'debit': 0,
|
||||
'credit': 0,
|
||||
'lines': [],
|
||||
})
|
||||
for vals in production_locations_valuation_vals:
|
||||
account = self.env['account.account'].browse(vals['account_id'])
|
||||
if account:
|
||||
account_vals = account.read(['name', 'code', 'display_name'])[0]
|
||||
report_data['accounts_by_id'][account.id] = account_vals
|
||||
cost_of_production['value'] -= vals['debit']
|
||||
lines_by_account_id[account.id]['debit'] += vals['debit']
|
||||
lines_by_account_id[account.id]['credit'] += vals['credit']
|
||||
lines_by_account_id[account.id]['lines'].append(vals)
|
||||
cost_of_production['lines'] = [{
|
||||
'account_id': account_id,
|
||||
'debit': vals['debit'],
|
||||
'credit': vals['credit'],
|
||||
} for (account_id, vals) in lines_by_account_id.items()]
|
||||
report_data['cost_of_production'] = cost_of_production
|
||||
return report_data
|
||||
|
||||
def _must_include_cost_of_production(self):
|
||||
return bool(self.env['stock.location'].search_count([
|
||||
('usage', '=', 'production'),
|
||||
('valuation_account_id', '!=', False),
|
||||
], limit=1))
|
||||
Loading…
Add table
Add a link
Reference in a new issue