mirror of
https://github.com/bringout/oca-ocb-l10n_me-africa.git
synced 2026-04-27 21:42:01 +02:00
19.0 vanilla
This commit is contained in:
parent
c5006a6999
commit
80293571e7
420 changed files with 21812 additions and 44297 deletions
5
odoo-bringout-oca-ocb-l10n_tr/l10n_tr/models/__init__.py
Normal file
5
odoo-bringout-oca-ocb-l10n_tr/l10n_tr/models/__init__.py
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
from . import account_journal
|
||||
from . import account_move_line
|
||||
from . import product
|
||||
from . import template_tr
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
from odoo import api, models, fields
|
||||
|
||||
|
||||
class AccountJournal(models.Model):
|
||||
_inherit = 'account.journal'
|
||||
|
||||
l10n_tr_default_sales_return_account_id = fields.Many2one(
|
||||
comodel_name='account.account',
|
||||
readonly=False,
|
||||
store=True,
|
||||
compute='_compute_l10n_tr_default_sales_return_account_id',
|
||||
check_company=True,
|
||||
)
|
||||
|
||||
@api.depends('type', 'company_id.country_code')
|
||||
def _compute_l10n_tr_default_sales_return_account_id(self):
|
||||
for journal in self:
|
||||
if journal.l10n_tr_default_sales_return_account_id:
|
||||
continue
|
||||
|
||||
if journal.country_code == 'TR' and journal.type == 'sale':
|
||||
ChartTemplate = self.env['account.chart.template'].with_company(journal.company_id)
|
||||
return_account = ChartTemplate.ref('tr610', raise_if_not_found=False)
|
||||
journal.l10n_tr_default_sales_return_account_id = return_account
|
||||
else:
|
||||
journal.l10n_tr_default_sales_return_account_id = False
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
from odoo import models
|
||||
|
||||
|
||||
class AccountMoveLine(models.Model):
|
||||
_inherit = 'account.move.line'
|
||||
|
||||
def _compute_account_id(self):
|
||||
# OVERRIDE
|
||||
super()._compute_account_id()
|
||||
|
||||
for line in self.filtered(lambda l: l.company_id.country_code == 'TR'
|
||||
and l.move_id.move_type == 'out_refund'
|
||||
and l.display_type == 'product'
|
||||
):
|
||||
if (product := line.product_id) and product.with_company(line.company_id).l10n_tr_default_sales_return_account_id:
|
||||
line.account_id = product.with_company(line.company_id).l10n_tr_default_sales_return_account_id
|
||||
elif (journal := line.move_id.journal_id) and journal.l10n_tr_default_sales_return_account_id:
|
||||
line.account_id = journal.l10n_tr_default_sales_return_account_id
|
||||
22
odoo-bringout-oca-ocb-l10n_tr/l10n_tr/models/product.py
Normal file
22
odoo-bringout-oca-ocb-l10n_tr/l10n_tr/models/product.py
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
from odoo import api, models, fields
|
||||
|
||||
|
||||
class ProductTemplate(models.Model):
|
||||
_inherit = "product.template"
|
||||
|
||||
l10n_tr_default_sales_return_account_id = fields.Many2one(
|
||||
comodel_name="account.account",
|
||||
company_dependent=True,
|
||||
)
|
||||
|
||||
@api.model_create_multi
|
||||
def create(self, vals_list):
|
||||
products = super().create(vals_list)
|
||||
|
||||
for product in products:
|
||||
if product.company_id.country_code == 'TR':
|
||||
ChartTemplate = self.env['account.chart.template'].with_company(product.company_id)
|
||||
return_account = ChartTemplate.ref('tr610', raise_if_not_found=False)
|
||||
product.l10n_tr_default_sales_return_account_id = return_account
|
||||
|
||||
return products
|
||||
58
odoo-bringout-oca-ocb-l10n_tr/l10n_tr/models/template_tr.py
Normal file
58
odoo-bringout-oca-ocb-l10n_tr/l10n_tr/models/template_tr.py
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
from odoo import _, models
|
||||
from odoo.addons.account.models.chart_template import template
|
||||
|
||||
|
||||
class AccountChartTemplate(models.AbstractModel):
|
||||
_inherit = 'account.chart.template'
|
||||
|
||||
@template('tr')
|
||||
def _get_tr_template_data(self):
|
||||
return {
|
||||
'property_account_receivable_id': 'tr120',
|
||||
'property_account_payable_id': 'tr320',
|
||||
'code_digits': '6',
|
||||
}
|
||||
|
||||
@template('tr', 'res.company')
|
||||
def _get_tr_res_company(self):
|
||||
return {
|
||||
self.env.company.id: {
|
||||
'account_fiscal_country_id': 'base.tr',
|
||||
'bank_account_code_prefix': '102',
|
||||
'cash_account_code_prefix': '100',
|
||||
'transfer_account_code_prefix': '103',
|
||||
'account_default_pos_receivable_account_id': 'tr123',
|
||||
'income_currency_exchange_account_id': 'tr646',
|
||||
'expense_currency_exchange_account_id': 'tr656',
|
||||
'account_journal_suspense_account_id': 'tr102999',
|
||||
'account_sale_tax_id': 'tr_s_20',
|
||||
'account_purchase_tax_id': 'tr_p_20',
|
||||
'deferred_expense_account_id': 'tr180',
|
||||
'deferred_revenue_account_id': 'tr380',
|
||||
'expense_account_id': 'tr150',
|
||||
'income_account_id': 'tr600',
|
||||
'tax_calculation_rounding_method': 'round_per_line',
|
||||
'account_stock_journal_id': 'inventory_valuation',
|
||||
'account_stock_valuation_id': 'tr150',
|
||||
},
|
||||
}
|
||||
|
||||
@template('tr', 'account.journal')
|
||||
def _get_tr_account_journal(self):
|
||||
return {
|
||||
'cash': {
|
||||
'name': _("Cash"),
|
||||
'type': 'cash',
|
||||
'show_on_dashboard': True,
|
||||
},
|
||||
}
|
||||
|
||||
@template('tr', 'account.account')
|
||||
def _get_tr_account_account(self):
|
||||
return {
|
||||
'tr150': {
|
||||
'account_stock_expense_id': 'tr710',
|
||||
'account_stock_variation_id': 'tr713',
|
||||
},
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue