[PATCH] Upstream patch - 30042023

This commit is contained in:
Parthiv Patel committed 2023-04-30 08:34:49 +00:00
1 parent 2de5398f04
commit 548132474e
33 files changed
+6260 -401

No files matched your search

+6
View File
@@ -132,6 +132,12 @@ class AccountTax(models.Model):
@api.constrains('invoice_repartition_line_ids', 'refund_repartition_line_ids')
def _validate_repartition_lines(self):
for record in self:
# if the tax is an aggregation of its sub-taxes (group) it can have no repartition lines
if record.amount_type == 'group' and \
not record.invoice_repartition_line_ids and \
not record.refund_repartition_line_ids:
continue
invoice_repartition_line_ids = record.invoice_repartition_line_ids.sorted()
refund_repartition_line_ids = record.refund_repartition_line_ids.sorted()
record._check_repartition_lines(invoice_repartition_line_ids)
+26 -6
View File
@@ -67,7 +67,7 @@ def update_taxes_from_templates(cr, chart_template_xmlid):
if xml_id:
_remove_xml_id(xml_id)
_avoid_name_conflict()
chart_template.create_record_with_xmlid(company, template, 'account.tax', template_vals)
return chart_template.create_record_with_xmlid(company, template, 'account.tax', template_vals)
def _update_tax_from_template(template, tax):
""" Update the tax's tags (and only tags!) based on template values. """
@@ -153,6 +153,21 @@ def update_taxes_from_templates(cr, chart_template_xmlid):
}))
chart_template._create_records_with_xmlid('account.fiscal.position.tax', tax_template_vals, company)
def _process_taxes_translations(chart_template, new_template_x_taxes):
"""
Retrieve translations for newly created taxes' name and description
for languages of the chart_template.
Those languages are the intersection of the spoken_languages of the chart_template
and installed languages.
"""
langs = chart_template._get_langs()
if langs:
template_ids, tax_ids = zip(*new_template_x_taxes)
in_ids = env['account.tax.template'].browse(template_ids)
out_ids = env['account.tax'].browse(tax_ids)
chart_template.process_translations(langs, 'name', in_ids, out_ids)
chart_template.process_translations(langs, 'description', in_ids, out_ids)
def _notify_accountant_managers(taxes_to_check):
accountant_manager_group = env.ref("account.group_account_manager")
partner_managers_ids = accountant_manager_group.users.partner_id.ids
@@ -173,26 +188,31 @@ def update_taxes_from_templates(cr, chart_template_xmlid):
)
env = api.Environment(cr, SUPERUSER_ID, {})
chart_template_id = env['ir.model.data'].xmlid_to_res_id(chart_template_xmlid)
companies = env['res.company'].search(['|', ('chart_template_id', '=', chart_template_id), ('chart_template_id', 'child_of', chart_template_id)])
chart_template = env.ref(chart_template_xmlid)
companies = env['res.company'].search(['|', ('chart_template_id', '=', chart_template.id), ('chart_template_id', 'child_of', chart_template.id)])
outdated_taxes = []
new_taxes_template = []
new_template2tax = []
for company in companies:
template_to_tax = _get_template_to_real_xmlid_mapping(company, 'account.tax')
templates = env['account.tax.template'].with_context(active_test=False).search([('chart_template_id', '=', chart_template_id)])
templates = env['account.tax.template'].with_context(active_test=False).search([('chart_template_id', '=', chart_template.id)])
for template in templates:
tax = env['account.tax'].browse(template_to_tax.get(template.id))
if not tax or not _is_tax_and_template_same(template, tax):
_create_tax_from_template(company, template, old_tax=tax)
new_tax_id = _create_tax_from_template(company, template, old_tax=tax)
new_template2tax.append((template.id, new_tax_id))
if tax:
outdated_taxes.append(tax)
else:
new_taxes_template.append(template)
else:
_update_tax_from_template(template, tax)
_update_fiscal_positions_from_templates(company, chart_template_id, new_taxes_template)
_update_fiscal_positions_from_templates(company, chart_template.id, new_taxes_template)
if outdated_taxes:
_notify_accountant_managers(outdated_taxes)
if hasattr(chart_template, 'spoken_languages') and chart_template.spoken_languages:
_process_taxes_translations(chart_template, new_template2tax)
return new_template2tax
# ---------------------------------------------------------------
# Account Templates: Account, Tax, Tax Code and chart. + Wizard
+3 -1
View File
@@ -25,7 +25,7 @@ Here is how it works:
- Printing the invoice will trigger the download of two files: the invoice, and its ISR
- Clicking the 'Send by mail' button will attach two files to your draft mail : the invoice, and the corresponding ISR.
""",
'version': '11.0',
'version': '11.1',
'category': 'Accounting/Localizations/Account Charts',
'depends': ['account', 'l10n_multilang', 'base_iban'],
@@ -37,7 +37,9 @@ Here is how it works:
'data/account_data.xml',
'data/account_tax_report_data.xml',
'data/account_vat2011_data.xml',
'data/account_tax_template_data_2024.xml',
'data/account_fiscal_position_data.xml',
'data/account_fiscal_position_data_2024.xml',
'data/account_chart_template_data.xml',
'report/isr_report.xml',
'report/swissqr_report.xml',
+13 -5
View File
@@ -2,7 +2,7 @@
<flectra>
<data noupdate="1">
<!-- Account Tax Group -->
<!-- Account Tax Group (pre-2024 rates change) -->
<record id="tax_group_tva_0" model="account.tax.group">
<field name="name">TVA 0%</field>
</record>
@@ -15,12 +15,20 @@
<record id="tax_group_tva_77" model="account.tax.group">
<field name="name">TVA 7.7%</field>
</record>
</data>
<data>
<record id="tax_group_tva_100" model="account.tax.group">
<field name="name">TVA 100%</field>
</record>
<!-- Account Tax Group (post-2024 rates change) -->
<record id="tax_group_vat_26" model="account.tax.group">
<field name="name">VAT 2.6%</field>
</record>
<record id="tax_group_vat_38" model="account.tax.group">
<field name="name">VAT 3.8%</field>
</record>
<record id="tax_group_vat_81" model="account.tax.group">
<field name="name">VAT 8.1%</field>
</record>
</data>
</flectra>
@@ -16,6 +16,7 @@
<field name="auto_apply" eval="True"/>
</record>
<!-- Fiscal Position Tax Templates (pre-2024 rates change) -->
<record id="fiscal_position_tax_template_3" model="account.fiscal.position.tax.template">
<field name="position_id" ref="fiscal_position_template_import" />
<field name="tax_src_id" ref="vat_25_purchase" />
@@ -0,0 +1,59 @@
<?xml version="1.0" encoding="utf-8"?>
<flectra>
<data noupdate="1">
<!-- Fiscal Position Tax Templates (post-2024 rates change) -->
<record id="fiscal_position_tax_template_1_2024" model="account.fiscal.position.tax.template">
<field name="position_id" ref="fiscal_position_template_import"/>
<field name="tax_src_id" ref="vat_purchase_26"/>
<field name="tax_dest_id" ref="vat_O_import"/>
</record>
<record id="fiscal_position_tax_template_2_2024" model="account.fiscal.position.tax.template">
<field name="position_id" ref="fiscal_position_template_import"/>
<field name="tax_src_id" ref="vat_purchase_26_invest"/>
<field name="tax_dest_id" ref="vat_O_import"/>
</record>
<record id="fiscal_position_tax_template_3_2024" model="account.fiscal.position.tax.template">
<field name="position_id" ref="fiscal_position_template_import"/>
<field name="tax_src_id" ref="vat_purchase_38"/>
<field name="tax_dest_id" ref="vat_O_import"/>
</record>
<record id="fiscal_position_tax_template_4_2024" model="account.fiscal.position.tax.template">
<field name="position_id" ref="fiscal_position_template_import"/>
<field name="tax_src_id" ref="vat_purchase_38_invest"/>
<field name="tax_dest_id" ref="vat_O_import"/>
</record>
<record id="fiscal_position_tax_template_5_2024" model="account.fiscal.position.tax.template">
<field name="position_id" ref="fiscal_position_template_import"/>
<field name="tax_src_id" ref="vat_purchase_81_reverse"/>
<field name="tax_dest_id" ref="vat_O_import"/>
</record>
<record id="fiscal_position_tax_template_6_2024" model="account.fiscal.position.tax.template">
<field name="position_id" ref="fiscal_position_template_import"/>
<field name="tax_src_id" ref="vat_purchase_81_invest"/>
<field name="tax_dest_id" ref="vat_O_import"/>
</record>
<record id="fiscal_position_tax_template_7_2024" model="account.fiscal.position.tax.template">
<field name="position_id" ref="fiscal_position_template_import"/>
<field name="tax_src_id" ref="vat_sale_26"/>
<field name="tax_dest_id" ref="vat_XO"/>
</record>
<record id="fiscal_position_tax_template_8_2024" model="account.fiscal.position.tax.template">
<field name="position_id" ref="fiscal_position_template_import"/>
<field name="tax_src_id" ref="vat_sale_38"/>
<field name="tax_dest_id" ref="vat_XO"/>
</record>
<record id="fiscal_position_tax_template_9_2024" model="account.fiscal.position.tax.template">
<field name="position_id" ref="fiscal_position_template_import"/>
<field name="tax_src_id" ref="vat_sale_81"/>
<field name="tax_dest_id" ref="vat_XO"/>
</record>
</data>
</flectra>
+77 -10
View File
@@ -15,7 +15,7 @@
<record id="account_tax_report_line_chtax_200" model="account.tax.report.line">
<field name="name">200 Chiffre d'affaires</field>
<field name="formula">tax_ch_302a + tax_ch_312a + tax_ch_342a + tax_ch_289</field>
<field name="formula">tax_ch_302a + tax_ch_303a + tax_ch_312a + tax_ch_313a + tax_ch_342a + tax_ch_343a + tax_ch_289</field>
<field name="report_id" ref="tax_report"/>
<field name="sequence" eval="1"/>
<field name="parent_id" ref="account_tax_report_line_chiffre_af"/>
@@ -81,7 +81,7 @@
<field name="name">299 Chiffre d'affaires imposable (ch.200 moins ch.289)</field>
<field name="report_id" ref="tax_report"/>
<field name="sequence" eval="2"/>
<field name="formula">tax_ch_302a + tax_ch_312a + tax_ch_342a</field>
<field name="formula">tax_ch_302a + tax_ch_303a + tax_ch_312a + tax_ch_313a + tax_ch_342a + tax_ch_343a</field>
</record>
<record id="account_tax_report_line_calc_impot" model="account.tax.report.line">
@@ -99,7 +99,7 @@
</record>
<record id="account_tax_report_line_chtax_302a" model="account.tax.report.line">
<field name="name">302a Chiffre d'affaires imposable a 7.7% (TS)</field>
<field name="name">302a Chiffre d'affaires imposable a 7.7% (TS) jusqu'au 31.12.2023</field>
<field name="tag_name">302a</field>
<field name="code">tax_ch_302a</field>
<field name="report_id" ref="tax_report"/>
@@ -107,8 +107,17 @@
<field name="parent_id" ref="account_tax_report_line_calc_impot_chiffre"/>
</record>
<record id="account_tax_report_line_chtax_303a" model="account.tax.report.line">
<field name="name">303a Chiffre d'affaires imposable a 8.1% (TS) dès le 01.01.2024</field>
<field name="tag_name">303a</field>
<field name="code">tax_ch_303a</field>
<field name="report_id" ref="tax_report"/>
<field name="sequence" eval="1"/>
<field name="parent_id" ref="account_tax_report_line_calc_impot_chiffre"/>
</record>
<record id="account_tax_report_line_chtax_312a" model="account.tax.report.line">
<field name="name">312a Chiffre d'affaires imposable a 2.5% (TR)</field>
<field name="name">312a Chiffre d'affaires imposable a 2.5% (TR) jusqu'au 31.12.2023</field>
<field name="tag_name">312a</field>
<field name="code">tax_ch_312a</field>
<field name="report_id" ref="tax_report"/>
@@ -116,8 +125,17 @@
<field name="parent_id" ref="account_tax_report_line_calc_impot_chiffre"/>
</record>
<record id="account_tax_report_line_chtax_313a" model="account.tax.report.line">
<field name="name">313a Chiffre d'affaires imposable a 2.6% (TR) dès le 01.01.2024</field>
<field name="tag_name">313a</field>
<field name="code">tax_ch_313a</field>
<field name="report_id" ref="tax_report"/>
<field name="sequence" eval="2"/>
<field name="parent_id" ref="account_tax_report_line_calc_impot_chiffre"/>
</record>
<record id="account_tax_report_line_chtax_342a" model="account.tax.report.line">
<field name="name">342a Chiffre d'affaires imposable a 3.7% (TS)</field>
<field name="name">342a Chiffre d'affaires imposable a 3.7% (TS) jusqu'au 31.12.2023</field>
<field name="tag_name">342a</field>
<field name="code">tax_ch_342a</field>
<field name="report_id" ref="tax_report"/>
@@ -125,6 +143,15 @@
<field name="parent_id" ref="account_tax_report_line_calc_impot_chiffre"/>
</record>
<record id="account_tax_report_line_chtax_343a" model="account.tax.report.line">
<field name="name">343a Chiffre d'affaires imposable a 3.8% (TS) dès le 01.01.2024</field>
<field name="tag_name">343a</field>
<field name="code">tax_ch_343a</field>
<field name="report_id" ref="tax_report"/>
<field name="sequence" eval="3"/>
<field name="parent_id" ref="account_tax_report_line_calc_impot_chiffre"/>
</record>
<record id="account_tax_report_line_calc_impot_base" model="account.tax.report.line">
<field name="name">Base Impôt sur acquisitions de services</field>
<field name="report_id" ref="tax_report"/>
@@ -141,13 +168,21 @@
</record>
<record id="account_tax_report_line_chtax_382a" model="account.tax.report.line">
<field name="name">382a Impots sur les acquisitions</field>
<field name="name">382a Impots sur les acquisitions jusqu'au 31.12.2023</field>
<field name="tag_name">382a</field>
<field name="report_id" ref="tax_report"/>
<field name="sequence" eval="2"/>
<field name="parent_id" ref="account_tax_report_line_calc_impot_base"/>
</record>
<record id="account_tax_report_line_chtax_383a" model="account.tax.report.line">
<field name="name">383a Impots sur les acquisitions dès le 01.01.2024</field>
<field name="tag_name">383a</field>
<field name="report_id" ref="tax_report"/>
<field name="sequence" eval="2"/>
<field name="parent_id" ref="account_tax_report_line_calc_impot_base"/>
</record>
<record id="account_tax_report_line_chtax_399" model="account.tax.report.line">
<field name="name">399 TVA Due </field>
<field name="code">tax_ch_399</field>
@@ -157,29 +192,53 @@
</record>
<record id="account_tax_report_line_chtax_302b" model="account.tax.report.line">
<field name="name">302b TVA due a 7.7% (TS)</field>
<field name="name">302b TVA due a 7.7% (TS) jusqu'au 31.12.2023</field>
<field name="tag_name">302b</field>
<field name="report_id" ref="tax_report"/>
<field name="sequence" eval="1"/>
<field name="parent_id" ref="account_tax_report_line_chtax_399"/>
</record>
<record id="account_tax_report_line_chtax_303b" model="account.tax.report.line">
<field name="name">303b TVA due a 8.1% (TS) dès le 01.01.2024</field>
<field name="tag_name">303b</field>
<field name="report_id" ref="tax_report"/>
<field name="sequence" eval="1"/>
<field name="parent_id" ref="account_tax_report_line_chtax_399"/>
</record>
<record id="account_tax_report_line_chtax_312b" model="account.tax.report.line">
<field name="name">312b TVA due a 2.5% (TR)</field>
<field name="name">312b TVA due a 2.5% (TR) jusqu'au 31.12.2023</field>
<field name="tag_name">312b</field>
<field name="report_id" ref="tax_report"/>
<field name="sequence" eval="2"/>
<field name="parent_id" ref="account_tax_report_line_chtax_399"/>
</record>
<record id="account_tax_report_line_chtax_313b" model="account.tax.report.line">
<field name="name">313b TVA due a 2.6% (TR) dès le 01.01.2024</field>
<field name="tag_name">313b</field>
<field name="report_id" ref="tax_report"/>
<field name="sequence" eval="2"/>
<field name="parent_id" ref="account_tax_report_line_chtax_399"/>
</record>
<record id="account_tax_report_line_chtax_342b" model="account.tax.report.line">
<field name="name">342b TVA due a 3.7% (TS)</field>
<field name="name">342b TVA due a 3.7% (TS) jusqu'au 31.12.2024</field>
<field name="tag_name">342b</field>
<field name="report_id" ref="tax_report"/>
<field name="sequence" eval="3"/>
<field name="parent_id" ref="account_tax_report_line_chtax_399"/>
</record>
<record id="account_tax_report_line_chtax_343b" model="account.tax.report.line">
<field name="name">343b TVA due a 3.8% (TS) dès le 01.01.2024</field>
<field name="tag_name">343b</field>
<field name="report_id" ref="tax_report"/>
<field name="sequence" eval="3"/>
<field name="parent_id" ref="account_tax_report_line_chtax_399"/>
</record>
<record id="account_tax_report_line_chtax_381b" model="account.tax.report.line">
<field name="name">381b Impots sur les acquisitions </field>
<field name="tag_name">381b</field>
@@ -189,13 +248,21 @@
</record>
<record id="account_tax_report_line_chtax_382b" model="account.tax.report.line">
<field name="name">382b Impots sur les acquisitions </field>
<field name="name">382b Impots sur les acquisitions jusqu'au 31.12.2023</field>
<field name="tag_name">382b</field>
<field name="report_id" ref="tax_report"/>
<field name="sequence" eval="5"/>
<field name="parent_id" ref="account_tax_report_line_chtax_399"/>
</record>
<record id="account_tax_report_line_chtax_383b" model="account.tax.report.line">
<field name="name">383b Impots sur les acquisitions dès le 01.01.2024</field>
<field name="tag_name">383b</field>
<field name="report_id" ref="tax_report"/>
<field name="sequence" eval="5"/>
<field name="parent_id" ref="account_tax_report_line_chtax_399"/>
</record>
<record id="account_tax_report_line_chtax_479" model="account.tax.report.line">
<field name="name">479 TVA préalable</field>
<field name="report_id" ref="tax_report"/>
@@ -0,0 +1,707 @@
<?xml version="1.0" encoding="utf-8"?>
<flectra>
<!-- Account Tax Templates (post-2024 rates change) -->
<record model="account.tax.template" id="vat_sale_26">
<field name="name">TVA due a 2.6% (TR)</field>
<field name="description">2.6%</field>
<field name="amount" eval="2.6"/>
<field name="amount_type">percent</field>
<field name="chart_template_id" ref="l10nch_chart_template"/>
<field name="type_tax_use">sale</field>
<field name="tax_group_id" ref="tax_group_vat_26"/>
<field name="active" eval="False"/>
<field name="invoice_repartition_line_ids" eval="[(5, 0, 0),
(0,0, {
'factor_percent': 100,
'repartition_type': 'base',
'plus_report_line_ids': [ref('account_tax_report_line_chtax_313a')],
}),
(0,0, {
'factor_percent': 100,
'repartition_type': 'tax',
'account_id': ref('ch_coa_2200'),
'plus_report_line_ids': [ref('account_tax_report_line_chtax_313b')],
}),
]"/>
<field name="refund_repartition_line_ids" eval="[(5, 0, 0),
(0,0, {
'factor_percent': 100,
'repartition_type': 'base',
'minus_report_line_ids': [ref('account_tax_report_line_chtax_313a')],
}),
(0,0, {
'factor_percent': 100,
'repartition_type': 'tax',
'account_id': ref('ch_coa_2200'),
'minus_report_line_ids': [ref('account_tax_report_line_chtax_313b')],
}),
]"/>
</record>
<record model="account.tax.template" id="vat_sale_26_incl">
<field name="name">TVA due à 2.6% (Incl. TR)</field>
<field name="description">2.6% Incl.</field>
<field name="price_include" eval="1"/>
<field name="amount" eval="2.6"/>
<field name="amount_type">percent</field>
<field name="chart_template_id" ref="l10nch_chart_template"/>
<field name="type_tax_use">sale</field>
<field name="tax_group_id" ref="tax_group_vat_26"/>
<field name="active" eval="False"/>
<field name="invoice_repartition_line_ids" eval="[(5, 0, 0),
(0,0, {
'factor_percent': 100,
'repartition_type': 'base',
'plus_report_line_ids': [ref('account_tax_report_line_chtax_313a')],
}),
(0,0, {
'factor_percent': 100,
'repartition_type': 'tax',
'account_id': ref('ch_coa_2200'),
'plus_report_line_ids': [ref('account_tax_report_line_chtax_313b')],
}),
]"/>
<field name="refund_repartition_line_ids" eval="[(5, 0, 0),
(0,0, {
'factor_percent': 100,
'repartition_type': 'base',
'minus_report_line_ids': [ref('account_tax_report_line_chtax_313a')],
}),
(0,0, {
'factor_percent': 100,
'repartition_type': 'tax',
'account_id': ref('ch_coa_2200'),
'minus_report_line_ids': [ref('account_tax_report_line_chtax_313b')],
}),
]"/>
</record>
<record model="account.tax.template" id="vat_purchase_26">
<field name="name">TVA 2.6% sur achat B&amp;S (TR)</field>
<field name="description">2.6% achat</field>
<field name="amount" eval="2.6"/>
<field name="amount_type">percent</field>
<field name="chart_template_id" ref="l10nch_chart_template"/>
<field name="type_tax_use">purchase</field>
<field name="tax_group_id" ref="tax_group_vat_26"/>
<field name="active" eval="False"/>
<field name="invoice_repartition_line_ids" eval="[(5, 0, 0),
(0,0, {
'factor_percent': 100,
'repartition_type': 'base',
}),
(0,0, {
'factor_percent': 100,
'repartition_type': 'tax',
'account_id': ref('ch_coa_1170'),
'plus_report_line_ids': [ref('account_tax_report_line_chtax_400')],
}),
]"/>
<field name="refund_repartition_line_ids" eval="[(5, 0, 0),
(0,0, {
'factor_percent': 100,
'repartition_type': 'base',
}),
(0,0, {
'factor_percent': 100,
'repartition_type': 'tax',
'account_id': ref('ch_coa_1170'),
'minus_report_line_ids': [ref('account_tax_report_line_chtax_400')],
}),
]"/>
</record>
<record model="account.tax.template" id="vat_purchase_26_incl">
<field name="name">TVA 2.6% sur achat B&amp;S (Incl. TR)</field>
<field name="description">2.6% achat Incl.</field>
<field name="price_include" eval="1"/>
<field name="amount" eval="2.6"/>
<field name="amount_type">percent</field>
<field name="chart_template_id" ref="l10nch_chart_template"/>
<field name="type_tax_use">purchase</field>
<field name="tax_group_id" ref="tax_group_vat_26"/>
<field name="active" eval="False"/>
<field name="invoice_repartition_line_ids" eval="[(5, 0, 0),
(0,0, {
'factor_percent': 100,
'repartition_type': 'base',
}),
(0,0, {
'factor_percent': 100,
'repartition_type': 'tax',
'account_id': ref('ch_coa_1170'),
'plus_report_line_ids': [ref('account_tax_report_line_chtax_400')],
}),
]"/>
<field name="refund_repartition_line_ids" eval="[(5, 0, 0),
(0,0, {
'factor_percent': 100,
'repartition_type': 'base',
}),
(0,0, {
'factor_percent': 100,
'repartition_type': 'tax',
'account_id': ref('ch_coa_1170'),
'minus_report_line_ids': [ref('account_tax_report_line_chtax_400')],
}),
]"/>
</record>
<record model="account.tax.template" id="vat_purchase_26_invest">
<field name="name">TVA 2.6% sur invest. et autres ch. (TR)</field>
<field name="description">2.6% invest.</field>
<field name="amount" eval="2.6"/>
<field name="amount_type">percent</field>
<field name="chart_template_id" ref="l10nch_chart_template"/>
<field name="type_tax_use">purchase</field>
<field name="tax_group_id" ref="tax_group_vat_26"/>
<field name="active" eval="False"/>
<field name="invoice_repartition_line_ids" eval="[(5, 0, 0),
(0,0, {
'factor_percent': 100,
'repartition_type': 'base',
}),
(0,0, {
'factor_percent': 100,
'repartition_type': 'tax',
'account_id': ref('ch_coa_1171'),
'plus_report_line_ids': [ref('account_tax_report_line_chtax_405')],
}),
]"/>
<field name="refund_repartition_line_ids" eval="[(5, 0, 0),
(0,0, {
'factor_percent': 100,
'repartition_type': 'base',
}),
(0,0, {
'factor_percent': 100,
'repartition_type': 'tax',
'account_id': ref('ch_coa_1171'),
'minus_report_line_ids': [ref('account_tax_report_line_chtax_405')],
}),
]"/>
</record>
<record model="account.tax.template" id="vat_purchase_26_invest_incl">
<field name="name">TVA 2.6% sur invest. et autres ch. (Incl. TR)</field>
<field name="description">2.6% invest. Incl.</field>
<field name="price_include" eval="1"/>
<field name="amount" eval="2.6"/>
<field name="amount_type">percent</field>
<field name="chart_template_id" ref="l10nch_chart_template"/>
<field name="type_tax_use">purchase</field>
<field name="tax_group_id" ref="tax_group_vat_26"/>
<field name="active" eval="False"/>
<field name="invoice_repartition_line_ids" eval="[(5, 0, 0),
(0,0, {
'factor_percent': 100,
'repartition_type': 'base',
}),
(0,0, {
'factor_percent': 100,
'repartition_type': 'tax',
'account_id': ref('ch_coa_1171'),
'plus_report_line_ids': [ref('account_tax_report_line_chtax_405')],
}),
]"/>
<field name="refund_repartition_line_ids" eval="[(5, 0, 0),
(0,0, {
'factor_percent': 100,
'repartition_type': 'base',
}),
(0,0, {
'factor_percent': 100,
'repartition_type': 'tax',
'account_id': ref('ch_coa_1171'),
'minus_report_line_ids': [ref('account_tax_report_line_chtax_405')],
}),
]"/>
</record>
<record model="account.tax.template" id="vat_sale_38">
<field name="name">TVA due a 3.8% (TS)</field>
<field name="description">3.8%</field>
<field name="amount" eval="3.8"/>
<field name="amount_type">percent</field>
<field name="chart_template_id" ref="l10nch_chart_template"/>
<field name="type_tax_use">sale</field>
<field name="tax_group_id" ref="tax_group_vat_38"/>
<field name="active" eval="False"/>
<field name="invoice_repartition_line_ids" eval="[(5, 0, 0),
(0,0, {
'factor_percent': 100,
'repartition_type': 'base',
'plus_report_line_ids': [ref('account_tax_report_line_chtax_343a')],
}),
(0,0, {
'factor_percent': 100,
'repartition_type': 'tax',
'account_id': ref('ch_coa_2200'),
'plus_report_line_ids': [ref('account_tax_report_line_chtax_343b')],
}),
]"/>
<field name="refund_repartition_line_ids" eval="[(5, 0, 0),
(0,0, {
'factor_percent': 100,
'repartition_type': 'base',
'minus_report_line_ids': [ref('account_tax_report_line_chtax_343a')],
}),
(0,0, {
'factor_percent': 100,
'repartition_type': 'tax',
'account_id': ref('ch_coa_2200'),
'minus_report_line_ids': [ref('account_tax_report_line_chtax_343b')],
}),
]"/>
</record>
<record model="account.tax.template" id="vat_sale_38_incl">
<field name="name">TVA due à 3.8% (Incl. TS)</field>
<field name="description">3.8% Incl.</field>
<field name="price_include" eval="1"/>
<field name="amount" eval="3.8"/>
<field name="amount_type">percent</field>
<field name="chart_template_id" ref="l10nch_chart_template"/>
<field name="type_tax_use">sale</field>
<field name="tax_group_id" ref="tax_group_vat_38"/>
<field name="active" eval="False"/>
<field name="invoice_repartition_line_ids" eval="[(5, 0, 0),
(0,0, {
'factor_percent': 100,
'repartition_type': 'base',
'plus_report_line_ids': [ref('account_tax_report_line_chtax_343a')],
}),
(0,0, {
'factor_percent': 100,
'repartition_type': 'tax',
'account_id': ref('ch_coa_2200'),
'plus_report_line_ids': [ref('account_tax_report_line_chtax_343b')],
}),
]"/>
<field name="refund_repartition_line_ids" eval="[(5, 0, 0),
(0,0, {
'factor_percent': 100,
'repartition_type': 'base',
'minus_report_line_ids': [ref('account_tax_report_line_chtax_343a')],
}),
(0,0, {
'factor_percent': 100,
'repartition_type': 'tax',
'account_id': ref('ch_coa_2200'),
'minus_report_line_ids': [ref('account_tax_report_line_chtax_343b')],
}),
]"/>
</record>
<record model="account.tax.template" id="vat_purchase_38">
<field name="name">TVA 3.8% sur achat B&amp;S (TS)</field>
<field name="description">3.8% achat</field>
<field name="amount" eval="3.8"/>
<field name="amount_type">percent</field>
<field name="chart_template_id" ref="l10nch_chart_template"/>
<field name="type_tax_use">purchase</field>
<field name="tax_group_id" ref="tax_group_vat_38"/>
<field name="active" eval="False"/>
<field name="invoice_repartition_line_ids" eval="[(5, 0, 0),
(0,0, {
'factor_percent': 100,
'repartition_type': 'base',
}),
(0,0, {
'factor_percent': 100,
'repartition_type': 'tax',
'account_id': ref('ch_coa_1170'),
'plus_report_line_ids': [ref('account_tax_report_line_chtax_400')],
}),
]"/>
<field name="refund_repartition_line_ids" eval="[(5, 0, 0),
(0,0, {
'factor_percent': 100,
'repartition_type': 'base',
}),
(0,0, {
'factor_percent': 100,
'repartition_type': 'tax',
'account_id': ref('ch_coa_1170'),
'minus_report_line_ids': [ref('account_tax_report_line_chtax_400')],
}),
]"/>
</record>
<record model="account.tax.template" id="vat_purchase_38_incl">
<field name="name">TVA 3.8% sur achat B&amp;S (Incl. TS)</field>
<field name="description">3.8% achat Incl.</field>
<field name="price_include" eval="1"/>
<field name="amount" eval="3.8"/>
<field name="amount_type">percent</field>
<field name="chart_template_id" ref="l10nch_chart_template"/>
<field name="type_tax_use">purchase</field>
<field name="tax_group_id" ref="tax_group_vat_38"/>
<field name="active" eval="False"/>
<field name="invoice_repartition_line_ids" eval="[(5, 0, 0),
(0,0, {
'factor_percent': 100,
'repartition_type': 'base',
}),
(0,0, {
'factor_percent': 100,
'repartition_type': 'tax',
'account_id': ref('ch_coa_1170'),
'plus_report_line_ids': [ref('account_tax_report_line_chtax_400')],
}),
]"/>
<field name="refund_repartition_line_ids" eval="[(5, 0, 0),
(0,0, {
'factor_percent': 100,
'repartition_type': 'base',
}),
(0,0, {
'factor_percent': 100,
'repartition_type': 'tax',
'account_id': ref('ch_coa_1170'),
'minus_report_line_ids': [ref('account_tax_report_line_chtax_400')],
}),
]"/>
</record>
<record model="account.tax.template" id="vat_purchase_38_invest">
<field name="name">TVA 3.8% sur invest. et autres ch. (TS)</field>
<field name="description">3.8% invest</field>
<field name="amount" eval="3.8"/>
<field name="amount_type">percent</field>
<field name="chart_template_id" ref="l10nch_chart_template"/>
<field name="type_tax_use">purchase</field>
<field name="tax_group_id" ref="tax_group_vat_38"/>
<field name="active" eval="False"/>
<field name="invoice_repartition_line_ids" eval="[(5, 0, 0),
(0,0, {
'factor_percent': 100,
'repartition_type': 'base',
}),
(0,0, {
'factor_percent': 100,
'repartition_type': 'tax',
'account_id': ref('ch_coa_1171'),
'plus_report_line_ids': [ref('account_tax_report_line_chtax_405')],
}),
]"/>
<field name="refund_repartition_line_ids" eval="[(5, 0, 0),
(0,0, {
'factor_percent': 100,
'repartition_type': 'base',
}),
(0,0, {
'factor_percent': 100,
'repartition_type': 'tax',
'account_id': ref('ch_coa_1171'),
'minus_report_line_ids': [ref('account_tax_report_line_chtax_405')],
}),
]"/>
</record>
<record model="account.tax.template" id="vat_purchase_38_invest_incl">
<field name="name">TVA 3.8% sur invest. et autres ch. (Incl. TS)</field>
<field name="description">3.8% invest Incl.</field>
<field name="price_include" eval="1"/>
<field name="amount" eval="3.8"/>
<field name="amount_type">percent</field>
<field name="chart_template_id" ref="l10nch_chart_template"/>
<field name="type_tax_use">purchase</field>
<field name="tax_group_id" ref="tax_group_vat_38"/>
<field name="active" eval="False"/>
<field name="invoice_repartition_line_ids" eval="[(5, 0, 0),
(0,0, {
'factor_percent': 100,
'repartition_type': 'base',
}),
(0,0, {
'factor_percent': 100,
'repartition_type': 'tax',
'account_id': ref('ch_coa_1171'),
'plus_report_line_ids': [ref('account_tax_report_line_chtax_405')],
}),
]"/>
<field name="refund_repartition_line_ids" eval="[(5, 0, 0),
(0,0, {
'factor_percent': 100,
'repartition_type': 'base',
}),
(0,0, {
'factor_percent': 100,
'repartition_type': 'tax',
'account_id': ref('ch_coa_1171'),
'minus_report_line_ids': [ref('account_tax_report_line_chtax_405')],
}),
]"/>
</record>
<record model="account.tax.template" id="vat_sale_81">
<field name="name">TVA due a 8.1% (TN)</field>
<field name="description">8.1%</field>
<field name="amount" eval="8.1"/>
<field name="sequence" eval="0"/>
<field name="amount_type">percent</field>
<field name="chart_template_id" ref="l10nch_chart_template"/>
<field name="type_tax_use">sale</field>
<field name="tax_group_id" ref="tax_group_vat_81"/>
<field name="active" eval="False"/>
<field name="invoice_repartition_line_ids" eval="[(5, 0, 0),
(0,0, {
'factor_percent': 100,
'repartition_type': 'base',
'plus_report_line_ids': [ref('account_tax_report_line_chtax_303a')],
}),
(0,0, {
'factor_percent': 100,
'repartition_type': 'tax',
'account_id': ref('ch_coa_2200'),
'plus_report_line_ids': [ref('account_tax_report_line_chtax_303b')],
}),
]"/>
<field name="refund_repartition_line_ids" eval="[(5, 0, 0),
(0,0, {
'factor_percent': 100,
'repartition_type': 'base',
'minus_report_line_ids': [ref('account_tax_report_line_chtax_303a')],
}),
(0,0, {
'factor_percent': 100,
'repartition_type': 'tax',
'account_id': ref('ch_coa_2200'),
'minus_report_line_ids': [ref('account_tax_report_line_chtax_303b')],
}),
]"/>
</record>
<record model="account.tax.template" id="vat_sale_81_incl">
<field name="name">TVA due à 8.1% (Incl. TN)</field>
<field name="description">8.1% Incl.</field>
<field name="price_include" eval="1"/>
<field name="amount" eval="8.1"/>
<field name="sequence" eval="0"/>
<field name="amount_type">percent</field>
<field name="chart_template_id" ref="l10nch_chart_template"/>
<field name="type_tax_use">sale</field>
<field name="tax_group_id" ref="tax_group_vat_81"/>
<field name="active" eval="False"/>
<field name="invoice_repartition_line_ids" eval="[(5, 0, 0),
(0,0, {
'factor_percent': 100,
'repartition_type': 'base',
'plus_report_line_ids': [ref('account_tax_report_line_chtax_303a')],
}),
(0,0, {
'factor_percent': 100,
'repartition_type': 'tax',
'account_id': ref('ch_coa_2200'),
'plus_report_line_ids': [ref('account_tax_report_line_chtax_303b')],
}),
]"/>
<field name="refund_repartition_line_ids" eval="[(5, 0, 0),
(0,0, {
'factor_percent': 100,
'repartition_type': 'base',
'minus_report_line_ids': [ref('account_tax_report_line_chtax_303a')],
}),
(0,0, {
'factor_percent': 100,
'repartition_type': 'tax',
'account_id': ref('ch_coa_2200'),
'minus_report_line_ids': [ref('account_tax_report_line_chtax_303b')],
}),
]"/>
</record>
<record model="account.tax.template" id="vat_purchase_81">
<field name="name">TVA 8.1% sur achat B&amp;S (TN)</field>
<field name="description">8.1% achat</field>
<field name="amount" eval="8.1"/>
<field name="amount_type">percent</field>
<field name="sequence" eval="0"/>
<field name="chart_template_id" ref="l10nch_chart_template"/>
<field name="type_tax_use">purchase</field>
<field name="tax_group_id" ref="tax_group_vat_81"/>
<field name="active" eval="False"/>
<field name="invoice_repartition_line_ids" eval="[(5, 0, 0),
(0,0, {
'factor_percent': 100,
'repartition_type': 'base',
}),
(0,0, {
'factor_percent': 100,
'repartition_type': 'tax',
'account_id': ref('ch_coa_1170'),
'plus_report_line_ids': [ref('account_tax_report_line_chtax_400')],
}),
]"/>
<field name="refund_repartition_line_ids" eval="[(5, 0, 0),
(0,0, {
'factor_percent': 100,
'repartition_type': 'base',
}),
(0,0, {
'factor_percent': 100,
'repartition_type': 'tax',
'account_id': ref('ch_coa_1170'),
'minus_report_line_ids': [ref('account_tax_report_line_chtax_400')],
}),
]"/>
</record>
<record model="account.tax.template" id="vat_purchase_81_incl">
<field name="name">TVA 8.1% sur achat B&amp;S (Incl. TN)</field>
<field name="description">8.1% achat Incl.</field>
<field name="price_include" eval="1"/>
<field name="amount" eval="8.1"/>
<field name="amount_type">percent</field>
<field name="sequence" eval="0"/>
<field name="chart_template_id" ref="l10nch_chart_template"/>
<field name="type_tax_use">purchase</field>
<field name="tax_group_id" ref="tax_group_vat_81"/>
<field name="active" eval="False"/>
<field name="invoice_repartition_line_ids" eval="[(5, 0, 0),
(0,0, {
'factor_percent': 100,
'repartition_type': 'base',
}),
(0,0, {
'factor_percent': 100,
'repartition_type': 'tax',
'account_id': ref('ch_coa_1170'),
'plus_report_line_ids': [ref('account_tax_report_line_chtax_400')],
}),
]"/>
<field name="refund_repartition_line_ids" eval="[(5, 0, 0),
(0,0, {
'factor_percent': 100,
'repartition_type': 'base',
}),
(0,0, {
'factor_percent': 100,
'repartition_type': 'tax',
'account_id': ref('ch_coa_1170'),
'minus_report_line_ids': [ref('account_tax_report_line_chtax_400')],
}),
]"/>
</record>
<record model="account.tax.template" id="vat_purchase_81_invest">
<field name="name">TVA 8.1% sur invest. et autres ch. (TN)</field>
<field name="description">8.1% invest.</field>
<field name="amount" eval="8.1"/>
<field name="amount_type">percent</field>
<field name="chart_template_id" ref="l10nch_chart_template"/>
<field name="type_tax_use">purchase</field>
<field name="tax_group_id" ref="tax_group_vat_81"/>
<field name="active" eval="False"/>
<field name="invoice_repartition_line_ids" eval="[(5, 0, 0),
(0,0, {
'factor_percent': 100,
'repartition_type': 'base',
}),
(0,0, {
'factor_percent': 100,
'repartition_type': 'tax',
'account_id': ref('ch_coa_1171'),
'plus_report_line_ids': [ref('account_tax_report_line_chtax_405')],
}),
]"/>
<field name="refund_repartition_line_ids" eval="[(5, 0, 0),
(0,0, {
'factor_percent': 100,
'repartition_type': 'base',
}),
(0,0, {
'factor_percent': 100,
'repartition_type': 'tax',
'account_id': ref('ch_coa_1171'),
'minus_report_line_ids': [ref('account_tax_report_line_chtax_405')],
}),
]"/>
</record>
<record model="account.tax.template" id="vat_purchase_81_invest_incl">
<field name="name">TVA 8.1% sur invest. et autres ch. (Incl. TN)</field>
<field name="description">8.1% invest. Incl.</field>
<field name="price_include" eval="1"/>
<field name="amount" eval="8.1"/>
<field name="amount_type">percent</field>
<field name="chart_template_id" ref="l10nch_chart_template"/>
<field name="type_tax_use">purchase</field>
<field name="tax_group_id" ref="tax_group_vat_81"/>
<field name="active" eval="False"/>
<field name="invoice_repartition_line_ids" eval="[(5, 0, 0),
(0,0, {
'factor_percent': 100,
'repartition_type': 'base',
}),
(0,0, {
'factor_percent': 100,
'repartition_type': 'tax',
'account_id': ref('ch_coa_1171'),
'plus_report_line_ids': [ref('account_tax_report_line_chtax_405')],
}),
]"/>
<field name="refund_repartition_line_ids" eval="[(5, 0, 0),
(0,0, {
'factor_percent': 100,
'repartition_type': 'base',
}),
(0,0, {
'factor_percent': 100,
'repartition_type': 'tax',
'account_id': ref('ch_coa_1171'),
'minus_report_line_ids': [ref('account_tax_report_line_chtax_405')],
}),
]"/>
</record>
<record model="account.tax.template" id="vat_purchase_81_return">
<field name="name">TVA due a 8.1% (TN) (return)</field>
<field name="description">8.1% achat (return)</field>
<field name="amount" eval="-8.1"/>
<field name="amount_type">percent</field>
<field name="sequence" eval="0"/>
<field name="chart_template_id" ref="l10nch_chart_template"/>
<field name="type_tax_use">purchase</field>
<field name="active" eval="False"/>
<field name="invoice_repartition_line_ids" eval="[(5, 0, 0),
(0,0, {
'factor_percent': 100,
'repartition_type': 'base',
'minus_report_line_ids': [ref('account_tax_report_line_chtax_383a')],
}),
(0,0, {
'factor_percent': 100,
'repartition_type': 'tax',
'account_id': ref('ch_coa_1170'),
'minus_report_line_ids': [ref('account_tax_report_line_chtax_383b')],
}),
]"/>
<field name="refund_repartition_line_ids" eval="[(5, 0, 0),
(0,0, {
'factor_percent': 100,
'repartition_type': 'base',
'plus_report_line_ids': [ref('account_tax_report_line_chtax_383a')],
}),
(0,0, {
'factor_percent': 100,
'repartition_type': 'tax',
'account_id': ref('ch_coa_1170'),
'plus_report_line_ids': [ref('account_tax_report_line_chtax_383b')],
}),
]"/>
</record>
<!--# for reverse charge or VAT on Acquisition (group of taxes)-->
<record model="account.tax.template" id="vat_purchase_81_reverse">
<field name="name">TVA 8.1% sur achat service a l'etranger (reverse charge)</field>
<field name="description">8.1% achat</field>
<field name="amount_type">group</field>
<field name="type_tax_use">purchase</field>
<field name="tax_group_id" ref="tax_group_vat_81"/>
<field name="chart_template_id" ref="l10nch_chart_template"/>
<field name="active" eval="False"/>
<field name="children_tax_ids" eval="[(6, 0, [ref('vat_purchase_81'), ref('vat_purchase_81_return')])]"/>
</record>
</flectra>
+21 -1
View File
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<flectra>
<!--
# TVA - Taxe sur la Valeur Ajoutée
# TVA - Taxe sur la Valeur Ajoutée (pre-2024 rates change)
-->
<record model="account.tax.template" id="vat_25">
<field name="name">TVA due a 2.5% (TR)</field>
@@ -677,6 +677,26 @@
<field name="chart_template_id" ref="l10nch_chart_template"/>
<field name="type_tax_use">purchase</field>
<field name="tax_group_id" ref="tax_group_tva_0"/>
<field name="invoice_repartition_line_ids" eval="[(5, 0, 0),
(0,0, {
'factor_percent': 100,
'repartition_type': 'base',
}),
(0,0, {
'factor_percent': 100,
'repartition_type': 'tax',
}),
]"/>
<field name="refund_repartition_line_ids" eval="[(5, 0, 0),
(0,0, {
'factor_percent': 100,
'repartition_type': 'base',
}),
(0,0, {
'factor_percent': 100,
'repartition_type': 'tax',
}),
]"/>
</record>
<record model="account.tax.template" id="vat_100_import">
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,10 @@
# Part of Odoo, Flectra. See LICENSE file for full copyright and licensing details.
from flectra import api, SUPERUSER_ID
from flectra.addons.account.models.chart_template import update_taxes_from_templates
def migrate(cr, version):
new_template_to_tax = update_taxes_from_templates(cr, 'l10n_ch.l10nch_chart_template')
_, new_tax_ids = zip(*new_template_to_tax)
env = api.Environment(cr, SUPERUSER_ID, {})
env['account.tax'].browse(new_tax_ids).active = True
+3 -1
View File
@@ -43,7 +43,9 @@ class AccountMove(models.Model):
def _compute_l10n_de_addresses(self):
for record in self:
record.l10n_de_addresses = data = []
if record.partner_shipping_id == record.partner_id:
if 'partner_shipping_id' not in record._fields:
data.append((_("Invoicing Address:"), record.partner_id))
elif record.partner_shipping_id == record.partner_id:
data.append((_("Invoicing and Shipping Address:"), record.partner_shipping_id))
elif record.move_type in ("in_invoice", "in_refund"):
data.append((_("Invoicing and Shipping Address:"), record.partner_id))
+3 -1
View File
@@ -117,7 +117,9 @@ class Company(models.Model):
return self.env.ref(f'l10n_eu_service.oss_tax_account_company_{self.id}')
def _get_oss_tags(self):
[chart_template_xml_id] = self.chart_template_id.parent_id.get_xml_id().values() or self.chart_template_id.get_xml_id().values()
chart_template_xml_id = ''
if self.chart_template_id:
[chart_template_xml_id] = self.chart_template_id.parent_id.get_external_id().values() or self.chart_template_id.get_external_id().values()
tag_for_country = EU_TAG_MAP.get(chart_template_xml_id, {
'invoice_base_tag': None,
'invoice_tax_tag': None,
@@ -0,0 +1,6 @@
# Part of Odoo, Flectra. See LICENSE file for full copyright and licensing details.
from flectra.addons.account.models.chart_template import update_taxes_from_templates
def migrate(cr, version):
update_taxes_from_templates(cr, 'l10n_lu.lu_2011_chart_1')
+7 -2
View File
@@ -292,8 +292,13 @@ class WebsitePayment(http.Controller):
'type': 'form_save' if acquirer.save_token != 'none' and partner_id else 'form',
}
render_values = {}
if order_id:
values['sale_order_ids'] = [(6, 0, [order_id])]
order = request.env['sale.order'].sudo().browse(order_id)
render_values.update({
'billing_partner_id': order.partner_invoice_id.id,
})
elif invoice_id:
values['invoice_ids'] = [(6, 0, [invoice_id])]
@@ -308,10 +313,10 @@ class WebsitePayment(http.Controller):
PaymentProcessing.add_payment_transaction(tx)
render_values = {
render_values.update({
'partner_id': partner_id,
'type': tx.type,
}
})
return acquirer.sudo().render(tx.reference, float(amount), int(currency_id), values=render_values)
+2 -2
View File
@@ -1042,8 +1042,8 @@ Reason(s) of this behavior could be:
raise ValidationError(_('A transaction can\'t be linked to sales orders having different currencies.'))
# Ensure the partner are the same.
partner = self[0].partner_id
if any(so.partner_id != partner for so in self):
partner = self[0].partner_invoice_id
if any(so.partner_invoice_id != partner for so in self):
raise ValidationError(_('A transaction can\'t be linked to sales orders having different partners.'))
# Try to retrieve the acquirer. However, fallback to the token's acquirer.
+1
View File
@@ -5,3 +5,4 @@ from . import sale
from . import account_move
from . import mrp_production
from . import stock_move
from . import mrp_bom
+37
View File
@@ -0,0 +1,37 @@
# -*- coding: utf-8 -*-
# Part of Odoo, Flectra. See LICENSE file for full copyright and licensing details.
from flectra import _, models
from flectra.exceptions import UserError
class MrpBom(models.Model):
_inherit = 'mrp.bom'
def toggle_active(self):
self.filtered(lambda bom: bom.active)._ensure_bom_is_free()
return super().toggle_active()
def unlink(self):
self._ensure_bom_is_free()
return super().unlink()
def _ensure_bom_is_free(self):
product_ids = []
for bom in self:
if bom.type != 'phantom':
continue
product_ids += bom.product_id.ids or bom.product_tmpl_id.product_variant_ids.ids
if not product_ids:
return
lines = self.env['sale.order.line'].search([
('state', 'in', ('sale', 'done')),
('invoice_status', 'in', ('no', 'to invoice')),
('product_id', 'in', product_ids),
('move_ids.state', '!=', 'cancel'),
])
if lines:
product_names = ', '.join(lines.product_id.mapped('name'))
raise UserError(_('As long as there are some sale order lines that must be delivered/invoiced and are '
'related to these bills of materials, you can not remove them.\n'
'The error concerns these products: %s', product_names))
@@ -2551,3 +2551,43 @@ class TestSaleMrpFlow(ValuationReconciliationTestCommon):
{'account_id': self.company_data['default_account_stock_out'].id, 'debit': 0, 'credit': 30},
{'account_id': self.company_data['default_account_expense'].id, 'debit': 30, 'credit': 0},
])
def test_avoid_removing_kit_bom_in_use(self):
so = self.env['sale.order'].create({
'partner_id': self.partner_a.id,
'order_line': [
(0, 0, {
'name': self.kit_1.name,
'product_id': self.kit_1.id,
'product_uom_qty': 1.0,
'product_uom': self.kit_1.uom_id.id,
'price_unit': 5,
'tax_id': False,
})],
})
self.bom_kit_1.toggle_active()
self.bom_kit_1.toggle_active()
so.action_confirm()
with self.assertRaises(UserError):
self.bom_kit_1.toggle_active()
with self.assertRaises(UserError):
self.bom_kit_1.unlink()
for move in so.order_line.move_ids:
move.quantity_done = move.product_uom_qty
so.picking_ids.button_validate()
self.assertEqual(so.picking_ids.state, 'done')
with self.assertRaises(UserError):
self.bom_kit_1.toggle_active()
with self.assertRaises(UserError):
self.bom_kit_1.unlink()
invoice = so._create_invoices()
invoice.action_post()
self.assertEqual(invoice.state, 'posted')
self.bom_kit_1.toggle_active()
self.bom_kit_1.toggle_active()
self.bom_kit_1.unlink()
@@ -114,8 +114,15 @@ class SnailmailLetter(models.Model):
'notification_status': 'ready',
})
letter.attachment_id.check('read')
return letter
def write(self, vals):
res = super().write(vals)
if 'attachment_id' in vals:
self.attachment_id.check('read')
return res
def _fetch_attachment(self):
"""
This method will check if we have any existent attachement matching the model
+4
View File
@@ -0,0 +1,4 @@
# -*- coding: utf-8 -*-
# Part of Odoo, Flectra. See LICENSE file for full copyright and licensing details.
from . import test_attachment_access
@@ -0,0 +1,104 @@
# -*- coding: utf-8 -*-
# Part of Odoo, Flectra. See LICENSE file for full copyright and licensing details.
import base64
from flectra.exceptions import AccessError
from flectra.tests import SavepointCase
class testAttachmentAccess(SavepointCase):
@classmethod
def setUpClass(cls):
super().setUpClass()
cls.user = cls.env['res.users'].create({
'name': "foo",
'login': "foo",
'email': "foo@bar.com",
'groups_id': [(6, 0, [
cls.env.ref('base.group_user').id,
cls.env.ref('base.group_partner_manager').id,
])]
})
cls.letter_defaults = {
'model': cls.user.partner_id._name,
'res_id': cls.user.partner_id.id,
'partner_id': cls.user.partner_id.id,
}
def test_user_letter_attachment_without_res_fields(self):
"""Test an employee can create a letter linked to an attachment without res_model/res_id"""
env_user = self.env(user=self.user)
# As user, create an attachment without res_model/res_id
attachment = env_user['ir.attachment'].create({'name': 'foo', 'datas': base64.b64encode(b'foo')})
# As user, create a snailmail.letter linked to that attachment
letter = env_user['snailmail.letter'].create({'attachment_id': attachment.id, **self.letter_defaults})
# As user, ensure the content of the attachment can be read through the letter
self.assertEqual(base64.b64decode(letter.attachment_datas), b'foo')
# As user, create another attachment without res_model/res_id
attachment_2 = env_user['ir.attachment'].create({'name': 'foo', 'datas': base64.b64encode(b'bar')})
# As user, change the attachment of the letter to this second attachment
letter.write({'attachment_id': attachment_2.id})
# As user, ensure the content of this second attachment can be read through the letter
self.assertEqual(base64.b64decode(letter.attachment_datas), b'bar')
def test_user_letter_attachment_without_res_fields_created_by_admin(self):
"""Test an employee can read the content of the letter's attachment created by another user, the admin,
and the attachment does not have a res_model/res_id
"""
# As admin, create an attachment without res_model/res_id
attachment = self.env['ir.attachment'].create({'name': 'foo', 'datas': base64.b64encode(b'foo')})
# As admin, create a snailmail.letter linked to that attachment
letter = self.env['snailmail.letter'].create({'attachment_id': attachment.id, **self.letter_defaults})
# As user, ensure the attachment itself cannot be read
attachment.invalidate_cache()
with self.assertRaises(AccessError):
attachment.with_user(self.user).datas
# But, as user, the content of the attachment can be read through the letter
self.assertEqual(base64.b64decode(letter.with_user(self.user).attachment_datas), b'foo')
# As admin, create a second attachment without res_model/res_id
attachment = self.env['ir.attachment'].create({'name': 'bar', 'datas': base64.b64encode(b'bar')})
# As admin, link this second attachment to the previously created letter (write instead of create)
letter.write({'attachment_id': attachment.id})
# As user ensure the attachment itself cannot be read
attachment.invalidate_cache()
with self.assertRaises(AccessError):
self.assertEqual(base64.b64decode(attachment.with_user(self.user).datas), b'bar')
# But, as user, the content of the attachment can be read through the letter
self.assertEqual(base64.b64decode(letter.with_user(self.user).attachment_datas), b'bar')
def test_user_read_unallowed_attachment(self):
"""Test a user cannot access an attachment he is not supposed to through a snailmail.letter"""
# As admin, create an attachment for which you require the settings group to access
base_module = self.env.ref('base.module_base')
attachment_forbidden = self.env['ir.attachment'].create({
'name': 'foo', 'datas': base64.b64encode(b'foo'),
'res_model': base_module._name, 'res_id': base_module.id,
})
# As user, make sure this is indeed not possible to access that attachment data directly
attachment_forbidden.invalidate_cache()
with self.assertRaises(AccessError):
attachment_forbidden.with_user(self.user).datas
# As user, create a letter pointing to that attachment
# and make sure it raises an access error
with self.assertRaises(AccessError):
letter = self.env['snailmail.letter'].with_user(self.user).create({
'attachment_id': attachment_forbidden.id,
**self.letter_defaults,
})
letter.attachment_datas
# As user, update the attachment of an existing letter to the unallowed attachment
# and make sure it raises an access error
attachment_tmp = self.env['ir.attachment'].with_user(self.user).create({
'name': 'bar', 'datas': base64.b64encode(b'bar'),
})
letter = self.env['snailmail.letter'].with_user(self.user).create({
'attachment_id': attachment_tmp.id,
**self.letter_defaults,
})
with self.assertRaises(AccessError):
letter.write({'attachment_id': attachment_forbidden.id})
letter.attachment_datas
@@ -1849,6 +1849,8 @@ var SnippetsMenu = Widget.extend({
var selectors = [];
var $styles = $html.find('[data-selector]');
const snippetAdditionDropIn = $styles.filter('#so_snippet_addition').data('drop-in');
const oldFooterSnippetsSelector = 'footer .oe_structure > *';
const newFooterSnippetsSelector = 'footer #footer.oe_structure > *:not(.s_popup)';
$styles.each(function () {
var $style = $(this);
var selector = $style.data('selector');
@@ -1865,6 +1867,34 @@ var SnippetsMenu = Widget.extend({
$style[0].dataset.dropIn = dropInPatch.join(', ');
}
// Fix in stable: we have removed the option for setting the
// background color for snippets in the footer. However, this should
// not affect the snippets in the "All pages" popup which is also
// located in the footer.
if (($style[0].dataset.js === 'ColoredLevelBackground') && exclude) {
exclude = exclude
.split(', ')
.map(selector => selector === oldFooterSnippetsSelector ? newFooterSnippetsSelector : selector)
.join(', ');
}
if (($style[0].dataset.js === 'BackgroundToggler')) {
selector = selector
.split(', ')
.map(selector => selector === oldFooterSnippetsSelector ? newFooterSnippetsSelector : selector)
.join(', ');
}
// Fix in stable: before this, modifying a snippet's "bg_filter"
// also impacted its child snippets (e.g. Carousel with a
// "bg_filter" that contains a snippet with also a "bg_filter").
if ($style[0].dataset.optionName === "colorFilter") {
const weColorPickerEl = $style[0].querySelector('we-colorpicker');
weColorPickerEl.dataset.applyTo = weColorPickerEl.dataset.applyTo
.split(', ')
.map(selector => selector === '.o_we_bg_filter' ? '> .o_we_bg_filter' : selector)
.join(', ');
}
var target = $style.data('target');
var noCheck = $style.data('no-check');
var optionID = $style.data('js') || $style.data('option-name'); // used in tour js as selector
@@ -3731,7 +3731,7 @@ registry.BackgroundToggler = SnippetOptionWidget.extend({
this.$target.prepend(bgFilterEl);
}
} else {
this.$target.find('.o_we_bg_filter').remove();
this.$target.find('> .o_we_bg_filter').remove();
}
},
@@ -69,6 +69,41 @@ var AttributeTranslateDialog = Dialog.extend({
}
});
// Used to translate the text of `<select/>` options since it should not be
// possible to interact with the content of `.o_translation_select` elements.
const SelectTranslateDialog = Dialog.extend({
/**
* @constructor
*/
init: function (parent, options) {
this._super(parent, {
...options,
title: _t("Translate Selection Option"),
buttons: [
{text: _t("Close"), click: this.save}
],
});
this.optionEl = this.options.targetEl;
this.translationObject = this.optionEl.closest('[data-oe-translation-id]');
},
/**
* @override
*/
start: function () {
const inputEl = document.createElement('input');
inputEl.className = 'form-control my-3';
inputEl.value = this.optionEl.textContent;
inputEl.addEventListener('keyup', () => {
this.optionEl.textContent = inputEl.value;
const translationUpdated = inputEl.value !== this.optionEl.dataset.initialTranslationValue;
this.translationObject.classList.toggle('o_dirty', translationUpdated);
this.optionEl.classList.add('o_option_translated');
});
this.el.appendChild(inputEl);
return this._super(...arguments);
},
});
var WysiwygTranslate = WysiwygMultizone.extend({
custom_events: _.extend({}, WysiwygMultizone.prototype.custom_events || {}, {
ready_to_save: '_onSave',
@@ -101,8 +136,9 @@ var WysiwygTranslate = WysiwygMultizone.extend({
return promise.then(function () {
self._relocateEditorBar();
var attrs = ['placeholder', 'title', 'alt'];
const $editable = self._getEditableArea();
_.each(attrs, function (attr) {
self._getEditableArea().filter('[' + attr + '*="data-oe-translation-id="]').filter(':empty, input, select, textarea, img').each(function () {
$editable.filter('[' + attr + '*="data-oe-translation-id="]').filter(':empty, input, select, textarea, img').each(function () {
var $node = $(this);
var translation = $node.data('translation') || {};
var trans = $node.attr(attr);
@@ -125,6 +161,25 @@ var WysiwygTranslate = WysiwygMultizone.extend({
});
});
// Hack: we add a temporary element to handle option's text
// translations from the linked <select/>. The final values are
// copied to the original element right before save.
$editable.filter('[data-oe-translation-id] > select').each((index, select) => {
// Keep the default width of the translation `<span/>`.
select.parentElement.classList.remove('o_is_inline_editable');
const selectTranslationEl = document.createElement('div');
selectTranslationEl.className = 'o_translation_select';
const optionNames = [...select.options].map(option => option.text);
optionNames.forEach(option => {
const optionEl = document.createElement('div');
optionEl.textContent = option;
optionEl.dataset.initialTranslationValue = option;
optionEl.className = 'o_translation_select_option';
selectTranslationEl.appendChild(optionEl);
});
select.before(selectTranslationEl);
});
self.translations = [];
self.$editables_attr = self._getEditableArea().filter('.o_translatable_attribute');
self.$editables_attribute = $('.o_editable_translatable_attribute');
@@ -274,18 +329,25 @@ var WysiwygTranslate = WysiwygMultizone.extend({
});
});
this.$editables_attr.prependEvent('mousedown.translator click.translator mouseup.translator', function (ev) {
if (ev.ctrlKey) {
return;
}
ev.preventDefault();
ev.stopPropagation();
if (ev.type !== 'mousedown') {
return;
}
this.$editables_attr
.add(this._getEditableArea().filter('.o_translation_select_option'))
.prependEvent('mousedown.translator click.translator mouseup.translator', function (ev) {
if (ev.ctrlKey) {
return;
}
ev.preventDefault();
ev.stopPropagation();
if (ev.type !== 'mousedown') {
return;
}
new AttributeTranslateDialog(self, {}, ev.target).open();
});
const targetEl = ev.target;
if (targetEl.closest('.o_translation_select')) {
new SelectTranslateDialog(self, {size: 'medium', targetEl}).open();
} else {
new AttributeTranslateDialog(self, {}, targetEl).open();
}
});
},
//--------------------------------------------------------------------------
@@ -294,6 +356,19 @@ var WysiwygTranslate = WysiwygMultizone.extend({
_onSave: function (ev) {
ev.stopPropagation();
// Adapt translation values for `select` > `options`s and remove all
// temporary `.o_translation_select` elements.
for (const optionsEl of this.el.querySelectorAll('.o_translation_select')) {
const selectEl = optionsEl.nextElementSibling;
const translatedOptions = optionsEl.children;
const selectOptions = selectEl.tagName === 'SELECT' ? [...selectEl.options] : [];
if (selectOptions.length === translatedOptions.length) {
selectOptions.map((option, i) => {
option.text = translatedOptions[i].textContent;
});
}
optionsEl.remove();
}
},
});
@@ -281,6 +281,10 @@ $-header-nav-link-height: $nav-link-height;
.o_footer_copyright {
@include o-apply-colors('copyright', $background: o-color('footer'));
}
.s_popup {
// The colors of the footer must not impact the "all pages" popup.
@include o-apply-colors(1);
}
}
h2, h3, h4, h5, h6 {
@@ -1551,3 +1555,18 @@ $ribbon-padding: 100px;
opacity: 0;
}
}
[data-oe-translation-id] {
> .o_translation_select {
border: $input-border-width solid $input-border-color;
@include border-radius($input-border-radius, 0);
// Hide translatable `<select/>`s since we use `.o_translation_select`
// elements to handle translations.
& + select {
display: none !important;
}
> div:not(:last-child) {
border-bottom: inherit;
}
}
}
@@ -81,13 +81,17 @@
}
html[lang] > body.editor_enable [data-oe-translation-state] {
background: rgba($o-we-content-to-translate-color, 0.5) !important;
&[data-oe-translation-state="translated"] {
background: rgba($o-we-translated-content-color, 0.5) !important;
&, & .o_translation_select_option {
background: rgba($o-we-content-to-translate-color, 0.5) !important;
}
&.o_dirty {
&[data-oe-translation-state="translated"] {
&, & .o_translation_select_option {
background: rgba($o-we-translated-content-color, 0.5) !important;
}
}
&.o_dirty, & .o_option_translated {
background: rgba($o-we-translated-content-color, 0.25) !important;
}
}
@@ -239,6 +239,11 @@ $o-wblog-loader-size: 50px;
animation: o-wblog-fade-In 1s cubic-bezier(.02, .01, .47, 1);
}
// "Read next article" (with "Regular Cover")
#o_wblog_post_footer a.w-25 {
flex: 0 0 auto;
}
// Blog Index Pages
// ==============================================
#o_wblog_posts_loop {
@@ -9,7 +9,7 @@ var timeout;
publicWidget.registry.websiteSaleCartLink = publicWidget.Widget.extend({
// TODO in master: remove the second selector.
selector: '#top a[href$="/shop/cart"], #top_menu a[href$="/shop/cart"]',
selector: '#top a[href$="/shop/cart"]:not(.js_change_lang), #top_menu a[href$="/shop/cart"]:not(.js_change_lang)',
events: {
'mouseenter': '_onMouseEnter',
'mouseleave': '_onMouseLeave',