19.0 vanilla

This commit is contained in:
Ernad Husremovic 2026-03-09 09:30:07 +01:00
parent ba20ce7443
commit 768b70e05e
2357 changed files with 1057103 additions and 712486 deletions

View file

@ -1,37 +1,54 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import api, models, _
import logging
_logger = logging.getLogger(__name__)
from odoo import models, _
from odoo.addons.account.models.chart_template import template
class AccountChartTemplate(models.Model):
class AccountChartTemplate(models.AbstractModel):
_inherit = "account.chart.template"
@api.model
def generate_journals(self, acc_template_ref, company, journals_dict=None):
journal_to_add = (journals_dict or []) + [{'name': _('Inventory Valuation'), 'type': 'general', 'code': 'STJ', 'favorite': False, 'sequence': 8}]
return super(AccountChartTemplate, self).generate_journals(acc_template_ref=acc_template_ref, company=company, journals_dict=journal_to_add)
def _get_stock_account_res_company(self, template_code):
return {
company_id: filtered_vals
for company_id, vals in self._get_chart_template_model_data(template_code, 'res.company').items()
if (filtered_vals := {
fname: value
for fname, value in vals.items()
if fname in [
'account_stock_journal_id',
'account_stock_valuation_id',
'account_production_wip_account_id',
'account_production_wip_overhead_account_id',
]
})
}
def generate_properties(self, acc_template_ref, company, property_list=None):
res = super(AccountChartTemplate, self).generate_properties(acc_template_ref=acc_template_ref, company=company)
PropertyObj = self.env['ir.property'] # Property Stock Journal
value = self.env['account.journal'].search([('company_id', '=', company.id), ('code', '=', 'STJ'), ('type', '=', 'general')], limit=1)
if value:
PropertyObj._set_default("property_stock_journal", "product.category", value, company)
def _get_stock_account_account(self, template_code):
return {
xmlid: filtered_vals
for xmlid, vals in self._get_chart_template_model_data(template_code, 'account.account').items()
if (filtered_vals := {
fname: value
for fname, value in vals.items()
if fname in ['account_stock_expense_id', 'account_stock_variation_id']
})
}
todo_list = [ # Property Stock Accounts
'property_stock_account_input_categ_id',
'property_stock_account_output_categ_id',
'property_stock_valuation_account_id',
]
categ_values = {category.id: False for category in self.env['product.category'].search([])}
for field in todo_list:
account = self[field]
value = acc_template_ref[account].id if account else False
PropertyObj._set_default(field, "product.category", value, company)
PropertyObj._set_multi(field, "product.category", categ_values, True)
@template(model='account.journal')
def _get_stock_account_journal(self, template_code):
return {
'inventory_valuation': {
'name': _('Inventory Valuation'),
'code': 'STJ',
'type': 'general',
'sequence': 10,
'show_on_dashboard': False,
},
}
return res
@template()
def _get_stock_template_data(self, template_code):
return {
'stock_journal': 'inventory_valuation',
}