mirror of
https://gitlab.com/flectra-hq/flectra.git
synced 2025-02-25 18:55:21 -06:00
[PATCH] Upstream patch - 09022023
This commit is contained in:
@@ -22,7 +22,7 @@ class AccountAccountTag(models.Model):
|
||||
"""
|
||||
escaped_tag_name = tag_name.replace('\\', '\\\\').replace('%', '\%').replace('_', '\_')
|
||||
domain = [('name', '=like', '_' + escaped_tag_name), ('country_id', '=', country_id), ('applicability', '=', 'taxes')]
|
||||
return self.env['account.account.tag'].with_context(active_test=True).search(domain)
|
||||
return self.env['account.account.tag'].with_context(active_test=False).search(domain)
|
||||
|
||||
@api.constrains('country_id', 'applicability')
|
||||
def _validate_tag_country(self):
|
||||
|
||||
@@ -29,13 +29,13 @@ class AccountTaxReport(models.Model):
|
||||
|
||||
new_tags = tags_cache[cache_key]
|
||||
|
||||
if new_tags:
|
||||
if len(new_tags) == 2:
|
||||
line._remove_tags_used_only_by_self()
|
||||
line.write({'tag_ids': [(6, 0, new_tags.ids)]})
|
||||
|
||||
elif line.mapped('tag_ids.tax_report_line_ids.report_id').filtered(lambda x: x not in self):
|
||||
line._remove_tags_used_only_by_self()
|
||||
line.write({'tag_ids': [(5, 0, 0)] + line._get_tags_create_vals(line.tag_name, vals['country_id'])})
|
||||
line.write({'tag_ids': [(5, 0, 0)] + line._get_tags_create_vals(line.tag_name, vals['country_id'], existing_tag=new_tags)})
|
||||
tags_cache[cache_key] = line.tag_ids
|
||||
|
||||
else:
|
||||
@@ -118,17 +118,23 @@ class AccountTaxReportLine(models.Model):
|
||||
|
||||
existing_tags = self.env['account.account.tag']._get_tax_tags(tag_name, country.id)
|
||||
|
||||
if existing_tags:
|
||||
if len(existing_tags) < 2:
|
||||
# We create new one(s)
|
||||
# We can have only one tag in case we archived it and deleted its unused complement sign
|
||||
vals['tag_ids'] = self._get_tags_create_vals(tag_name, country.id, existing_tag=existing_tags)
|
||||
else:
|
||||
# We connect the new report line to the already existing tags
|
||||
vals['tag_ids'] = [(6, 0, existing_tags.ids)]
|
||||
else:
|
||||
# We create new ones
|
||||
vals['tag_ids'] = self._get_tags_create_vals(tag_name, country.id)
|
||||
|
||||
return super(AccountTaxReportLine, self).create(vals)
|
||||
|
||||
@api.model
|
||||
def _get_tags_create_vals(self, tag_name, country_id):
|
||||
def _get_tags_create_vals(self, tag_name, country_id, existing_tag=None):
|
||||
"""
|
||||
We create the plus and minus tags with tag_name.
|
||||
In case there is an existing_tag (which can happen if we deleted its unused complement sign)
|
||||
we only recreate the missing sign.
|
||||
"""
|
||||
minus_tag_vals = {
|
||||
'name': '-' + tag_name,
|
||||
'applicability': 'taxes',
|
||||
@@ -141,7 +147,12 @@ class AccountTaxReportLine(models.Model):
|
||||
'tax_negate': False,
|
||||
'country_id': country_id,
|
||||
}
|
||||
return [(0, 0, minus_tag_vals), (0, 0, plus_tag_vals)]
|
||||
res = []
|
||||
if not existing_tag or not existing_tag.tax_negate:
|
||||
res.append((0, 0, minus_tag_vals))
|
||||
if not existing_tag or existing_tag.tax_negate:
|
||||
res.append((0, 0, plus_tag_vals))
|
||||
return res
|
||||
|
||||
def write(self, vals):
|
||||
# If tag_name was set, but not tag_ids, we postpone the write of
|
||||
@@ -188,12 +199,12 @@ class AccountTaxReportLine(models.Model):
|
||||
records_to_link = records
|
||||
tags_to_remove = self.env['account.account.tag']
|
||||
|
||||
if not existing_tags and records_to_link:
|
||||
# If the tag does not exist yet, we first create it by
|
||||
# linking it to the first report line of the record set
|
||||
if len(existing_tags) < 2 and records_to_link:
|
||||
# If the tag does not exist yet (or if we only have one of the two +/-),
|
||||
# we first create it by linking it to the first report line of the record set
|
||||
first_record = records_to_link[0]
|
||||
tags_to_remove += first_record.tag_ids
|
||||
first_record.write({**postponed_vals, 'tag_ids': [(5, 0, 0)] + self._get_tags_create_vals(tag_name_postponed, country_id)})
|
||||
first_record.write({**postponed_vals, 'tag_ids': [(5, 0, 0)] + self._get_tags_create_vals(tag_name_postponed, country_id, existing_tag=existing_tags)})
|
||||
existing_tags = first_record.tag_ids
|
||||
records_to_link -= first_record
|
||||
|
||||
@@ -278,8 +289,8 @@ class AccountTaxReportLine(models.Model):
|
||||
neg_tags = record.tag_ids.filtered(lambda x: x.tax_negate)
|
||||
pos_tags = record.tag_ids.filtered(lambda x: not x.tax_negate)
|
||||
|
||||
if (len(neg_tags) != 1 or len(pos_tags) != 1):
|
||||
raise ValidationError(_("If tags are defined for a tax report line, only two are allowed on it: a positive and a negative one."))
|
||||
if (len(neg_tags) > 1 or len(pos_tags) > 1):
|
||||
raise ValidationError(_("If tags are defined for a tax report line, only two are allowed on it: a positive and/or a negative one."))
|
||||
|
||||
if neg_tags.name != '-'+record.tag_name or pos_tags.name != '+'+record.tag_name:
|
||||
if (neg_tags and neg_tags.name != '-'+record.tag_name) or (pos_tags and pos_tags.name != '+'+record.tag_name):
|
||||
raise ValidationError(_("The tags linked to a tax report line should always match its tag name."))
|
||||
|
||||
@@ -284,7 +284,10 @@ class TaxReportTest(AccountTestInvoicingCommon):
|
||||
check_tags_unlink('01', self.tax_report_line_1_1, False, "Unlinking one line sharing its tags with others should keep the tags")
|
||||
check_tags_unlink('100', self.tax_report_line_1_6 + self.tax_report_line_2_6, True, "Unlinkink all the lines sharing the same tags should also unlink them")
|
||||
|
||||
def test_unlink_report_line_tags_archive(self):
|
||||
def test_unlink_report_line_tags_used_by_amls(self):
|
||||
"""
|
||||
Deletion of a report line whose tags are still referenced by an aml should archive tags and not delete them.
|
||||
"""
|
||||
test_tax = self.env['account.tax'].create({
|
||||
'name': "Test tax",
|
||||
'amount_type': 'percent',
|
||||
@@ -299,7 +302,7 @@ class TaxReportTest(AccountTestInvoicingCommon):
|
||||
(0, 0, {
|
||||
'factor_percent': 100,
|
||||
'repartition_type': 'tax',
|
||||
'tag_ids': [(6, 0, self.tax_report_line_1_55.tag_ids[0].ids)],
|
||||
'tag_ids': [(6, 0, self.tax_report_line_1_55.tag_ids.filtered(lambda tag: not tag.tax_negate).ids)],
|
||||
}),
|
||||
],
|
||||
'refund_repartition_line_ids': [
|
||||
@@ -324,14 +327,48 @@ class TaxReportTest(AccountTestInvoicingCommon):
|
||||
],
|
||||
})
|
||||
test_invoice.action_post()
|
||||
self.assertTrue(any(line.tax_tag_ids == self.tax_report_line_1_55.tag_ids[0] for line in test_invoice.line_ids),
|
||||
"The test invoice should contain a tax line with tag 55")
|
||||
|
||||
tag_name = self.tax_report_line_1_55.tag_name
|
||||
tags_before = self._get_tax_tags(tag_name=tag_name, active_test=False)
|
||||
tags_archived_before = tags_before.filtered(lambda tag: not tag.active)
|
||||
self.tax_report_line_1_55.unlink()
|
||||
tags_after = self._get_tax_tags(tag_name=tag_name, active_test=False)
|
||||
# only the +tag_name should be kept (and archived), -tag_name should be unlinked
|
||||
self.assertEqual(tags_after.mapped('tax_negate'), [False], "Unlinking a report line should keep the tag if it was used on move lines, and unlink it otherwise.")
|
||||
self.assertEqual(tags_after.mapped('active'), [False], "Unlinking a report line should archive the tag if it was used on move lines, and unlink it otherwise.")
|
||||
self.assertEqual(len(test_tax.invoice_repartition_line_ids.tag_ids), 0, "After a tag is archived it shouldn't be on tax repartition lines.")
|
||||
|
||||
def test_unlink_report_line_tags_used_by_other_report_line(self):
|
||||
"""
|
||||
Deletion of a report line whose tags are still referenced in other report line should not delete nor archive tags.
|
||||
"""
|
||||
tag_name = self.tax_report_line_1_1.tag_name # tag "O1" is used in both line 1.1 and line 2.1
|
||||
tags_before = self._get_tax_tags(tag_name=tag_name, active_test=False)
|
||||
tags_archived_before = tags_before.filtered(lambda tag: not tag.active)
|
||||
self.tax_report_line_1_1.unlink()
|
||||
tags_after = self._get_tax_tags(tag_name=tag_name, active_test=False)
|
||||
tags_archived_after = tags_after.filtered(lambda tag: not tag.active)
|
||||
# only the + tag will survive, - will be deleted as it's not on a move.line
|
||||
self.assertEqual(len(tags_after), len(tags_before) - 1, "Unlinking a report line whose tags are used on move lines should not delete them.")
|
||||
self.assertEqual(len(tags_archived_after), len(tags_archived_before) + 1, "Unlinking a report line whose tags are used on move lines should archive them.")
|
||||
self.assertEqual(len(tags_after), len(tags_before), "Unlinking a report line whose tags are used by another line should not delete them.")
|
||||
self.assertEqual(len(tags_archived_after), len(tags_archived_before), "Unlinking a report line whose tags are used by another line should not archive them.")
|
||||
|
||||
def test_tag_recreation_archived(self):
|
||||
"""
|
||||
In a situation where we have only one of the two (+ and -) sign that exist
|
||||
we want only the missing sign to be re-created if we try to reuse the same tag name.
|
||||
(We can get into this state when only one of the signs was used by aml: then we archived it and deleted the complement.)
|
||||
"""
|
||||
tag_name = self.tax_report_line_1_55.tag_name
|
||||
tags_before = self._get_tax_tags(tag_name=tag_name, active_test=False)
|
||||
tags_before[0].unlink() # we unlink one and archive the other, doesn't matter which one
|
||||
tags_before[1].active = False
|
||||
self.env['account.tax.report.line'].create({
|
||||
'name': "[55] Line 55 bis",
|
||||
'tag_name': tag_name,
|
||||
'report_id': self.tax_report_1.id,
|
||||
'sequence': 9,
|
||||
})
|
||||
tags_after = self._get_tax_tags(tag_name=tag_name, active_test=False)
|
||||
self.assertEqual(len(tags_after), 2, "When creating a tax report line with an archived tag and its complement doesn't exist, it should be re-created.")
|
||||
self.assertEqual(
|
||||
tags_after.mapped('name'), ['+' + tag_name, '-' + tag_name],
|
||||
"After creating a tax report line with an archived tag and when its complement doesn't exist, both a negative and a positive tag should "
|
||||
"exist (the missing one being recreated)."
|
||||
)
|
||||
|
||||
@@ -186,7 +186,7 @@ class AccountEdiDocument(models.Model):
|
||||
move = document.move_id
|
||||
move_result = edi_result.get(move, {})
|
||||
if move_result.get('success') is True:
|
||||
old_attachment = document.attachment_id
|
||||
old_attachment = document.sudo().attachment_id
|
||||
document.write({
|
||||
'state': 'cancelled',
|
||||
'error': False,
|
||||
@@ -215,7 +215,7 @@ class AccountEdiDocument(models.Model):
|
||||
|
||||
# Attachments that are not explicitly linked to a business model could be removed because they are not
|
||||
# supposed to have any traceability from the user.
|
||||
attachments_to_unlink.unlink()
|
||||
attachments_to_unlink.sudo().unlink()
|
||||
|
||||
test_mode = self._context.get('edi_test_mode', False)
|
||||
|
||||
|
||||
@@ -1,18 +1,4 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<flectra>
|
||||
|
||||
<!-- Add action entry in the Action Menu for Events -->
|
||||
<record id="calendar_event_act_window_sms_composer_single" model="ir.actions.act_window">
|
||||
<field name="name">Send SMS to attendees</field>
|
||||
<field name="res_model">sms.composer</field>
|
||||
<field name="view_mode">form</field>
|
||||
<field name="target">new</field>
|
||||
<field name="context">{
|
||||
'sms_composition_mode': 'guess',
|
||||
'default_res_id': active_id,
|
||||
'default_res_ids': active_ids,
|
||||
}</field>
|
||||
<field name="binding_model_id" ref="model_calendar_event"/>
|
||||
</record>
|
||||
|
||||
</flectra>
|
||||
|
||||
@@ -10,8 +10,8 @@
|
||||
<field name="property_stock_account_input_categ_id" ref="chart6111"/>
|
||||
<field name="property_stock_account_output_categ_id" ref="chart69111"/>
|
||||
<field name="property_stock_valuation_account_id" ref="chart20111"/>
|
||||
<field name="income_currency_exchange_account_id" ref="chart676"/>
|
||||
<field name="expense_currency_exchange_account_id" ref="chart776"/>
|
||||
<field name="income_currency_exchange_account_id" ref="chart776"/>
|
||||
<field name="expense_currency_exchange_account_id" ref="chart676"/>
|
||||
</record>
|
||||
|
||||
<!-- transfer_account_code_prefix-->
|
||||
|
||||
@@ -22,6 +22,14 @@ $spacer: 1rem !default; // Need to predefine as used below
|
||||
//
|
||||
// Settings for the `<body>` element.
|
||||
|
||||
// Bootstrap uses $body-bg as default value for multiple variables but also in
|
||||
// the creation of CSS rules (not controlled by variables), which is wrong in
|
||||
// case of Flectra boxed layouts. In stable versions, this is fixed for default
|
||||
// variable values of critical components only. In 16.0, the problem increased
|
||||
// as $body-bg was even more used in BS 5.1.3. That will be fixed entirely in a
|
||||
// slightly less stable way: $body-bg will now be the boxed-layout color instead
|
||||
// of the behind-the-box color. In future bootstrap version (> 5.1.3), this
|
||||
// changed again so this logic may change again too.
|
||||
$body-bg: if(o-website-value('layout') != 'full', o-color('body'), o-color('o-cc1-bg')) !default;
|
||||
$body-color: o-color('o-cc1-text') or color-yiq(o-color('o-cc1-bg')) !default;
|
||||
|
||||
@@ -107,6 +115,10 @@ $input-border-radius: o-website-value('input-border-radius') !default;
|
||||
$input-border-radius-lg: o-website-value('input-border-radius-lg') !default;
|
||||
$input-border-radius-sm: o-website-value('input-border-radius-sm') !default;
|
||||
|
||||
// Navs
|
||||
|
||||
$nav-tabs-link-active-bg: o-color('o-cc1-bg') !default;
|
||||
|
||||
// Navbar
|
||||
|
||||
// Increase default navbar padding for some navbar styles
|
||||
|
||||
Reference in New Issue
Block a user