[PATCH] Upstream patch - 26112021

This commit is contained in:
Parthiv Patel
2021-11-26 10:15:40 +00:00
parent 97e11e4686
commit 3b396ee6c2
9 changed files with 101 additions and 16 deletions
+1 -1
View File
@@ -2,7 +2,7 @@
# Part of Odoo, Flectra. See LICENSE file for full copyright and licensing details.
{
'name': 'Argentina - Accounting',
'version': "3.4",
'version': "3.5",
'description': """
Functional
----------
+8
View File
@@ -241,6 +241,14 @@
</div>
</xpath>
<!-- Show total amount in letters for MiPyMEs document types according to the law
http://biblioteca.afip.gob.ar/dcp/LEY_C_027440_2018_05_09 article 5.f -->
<xpath expr="//div[@id='total']/div/table" position="after">
<t t-if="o.l10n_latam_document_type_id.code in ['201', '202', '203', '206', '207', '208', '211', '212', '213']">
<strong>Son: </strong><span t-esc="o.currency_id.with_context(lang='es_AR').amount_to_text(o.amount_total)"/>
</t>
</xpath>
<!-- RG 5003: Add legend for 'A' documents that have a Monotribuista receptor -->
<p name="comment" position="after">
<p t-if="o.partner_id.l10n_ar_afip_responsibility_type_id.code in ['6', '13'] and o.l10n_latam_document_type_id.l10n_ar_letter == 'A'" >
+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_wizard
+59
View File
@@ -0,0 +1,59 @@
# -*- coding: utf-8 -*-
# Part of Odoo, Flectra. See LICENSE file for full copyright and licensing details.
import base64
from datetime import timedelta
from flectra.addons.account.tests.common import AccountTestInvoicingCommon
from flectra.tests import tagged
from flectra import fields
@tagged('post_install', '-at_install')
class TestAccountFrFec(AccountTestInvoicingCommon):
@classmethod
def setUpClass(cls, chart_template_ref=None):
super().setUpClass(chart_template_ref=chart_template_ref)
company = cls.company_data['company']
cls.env.user.company_id = company
company.vat = 'FR13542107651'
lines_data = [(1437.12, 'Hello\tDarkness'), (1676.64, 'my\rold\nfriend'), (3353.28, '\t\t\r')]
today = fields.Date.today().strftime('%Y-%m-%d')
cls.invoice_a = cls.env['account.move'].create({
'move_type': 'out_invoice',
'partner_id': cls.partner_a.id,
'date': today,
'invoice_date': today,
'currency_id': cls.company_data['company'].currency_id.id,
'invoice_line_ids': [(0, None, {
'name': name,
'product_id': cls.product_a.id,
'quantity': 1,
'tax_ids': [(6, 0, [cls.tax_sale_a.id])],
'price_unit': price_unit,
}) for price_unit, name in lines_data]
})
cls.invoice_a.action_post()
cls.wizard = cls.env['account.fr.fec'].create({
'date_from': fields.Date.today() - timedelta(days=1),
'date_to': fields.Date.today(),
'export_type': 'official'
})
def test_generate_fec_sanitize_pieceref(self):
self.wizard.generate_fec()
today = fields.Date.today().strftime('%Y%m%d')
expected_content = (
"JournalCode|JournalLib|EcritureNum|EcritureDate|CompteNum|CompteLib|CompAuxNum|CompAuxLib|PieceRef|PieceDate|EcritureLib|Debit|Credit|EcritureLet|DateLet|ValidDate|Montantdevise|Idevise\r\n"
f"INV|Customer Invoices|INV/2021/11/0001|{today}|400000|Product Sales|||-|{today}|Hello Darkness|0,00| 000000000001437,12|||{today}|-000000000001437,12|USD\r\n"
f"INV|Customer Invoices|INV/2021/11/0001|{today}|400000|Product Sales|||-|{today}|my old friend|0,00| 000000000001676,64|||{today}|-000000000001676,64|USD\r\n"
f"INV|Customer Invoices|INV/2021/11/0001|{today}|400000|Product Sales|||-|{today}|/|0,00| 000000000003353,28|||{today}|-000000000003353,28|USD\r\n"
f"INV|Customer Invoices|INV/2021/11/0001|{today}|251000|Tax Received|||-|{today}|Tax 15.00%|0,00| 000000000000970,06|||{today}|-000000000000970,06|USD\r\n"
f"INV|Customer Invoices|INV/2021/11/0001|{today}|121000|Account Receivable|{self.partner_a.id}|partner_a|-|{today}|INV/2021/11/0001| 000000000007437,10|0,00|||{today}| 000000000007437,10|USD"
)
content = base64.b64decode(self.wizard.fec_data).decode()
self.assertEqual(expected_content, content)
+8 -8
View File
@@ -304,12 +304,12 @@ class AccountFrFec(models.TransientModel):
# LINES
sql_query = '''
SELECT
replace(replace(aj.code, '|', '/'), '\t', '') AS JournalCode,
replace(replace(COALESCE(aj__name.value, aj.name), '|', '/'), '\t', '') AS JournalLib,
replace(replace(am.name, '|', '/'), '\t', '') AS EcritureNum,
REGEXP_REPLACE(replace(aj.code, '|', '/'), '[\\t\\r\\n]', ' ', 'g') AS JournalCode,
REGEXP_REPLACE(replace(COALESCE(aj__name.value, aj.name), '|', '/'), '[\\t\\r\\n]', ' ', 'g') AS JournalLib,
REGEXP_REPLACE(replace(am.name, '|', '/'), '[\\t\\r\\n]', ' ', 'g') AS EcritureNum,
TO_CHAR(am.date, 'YYYYMMDD') AS EcritureDate,
aa.code AS CompteNum,
replace(replace(aa.name, '|', '/'), '\t', '') AS CompteLib,
REGEXP_REPLACE(replace(aa.name, '|', '/'), '[\\t\\r\\n]', ' ', 'g') AS CompteLib,
CASE WHEN aat.type IN ('receivable', 'payable')
THEN
CASE WHEN rp.ref IS null OR rp.ref = ''
@@ -320,18 +320,18 @@ class AccountFrFec(models.TransientModel):
END
AS CompAuxNum,
CASE WHEN aat.type IN ('receivable', 'payable')
THEN COALESCE(replace(replace(rp.name, '|', '/'), '\t', ''), '')
THEN COALESCE(REGEXP_REPLACE(replace(rp.name, '|', '/'), '[\\t\\r\\n]', ' ', 'g'), '')
ELSE ''
END AS CompAuxLib,
CASE WHEN am.ref IS null OR am.ref = ''
THEN '-'
ELSE replace(replace(am.ref, '|', '/'), '\t', '')
ELSE REGEXP_REPLACE(replace(am.ref, '|', '/'), '[\\t\\r\\n]', ' ', 'g')
END
AS PieceRef,
TO_CHAR(am.date, 'YYYYMMDD') AS PieceDate,
CASE WHEN aml.name IS NULL OR aml.name = '' THEN '/'
WHEN aml.name SIMILAR TO '[\t|\s|\n]*' THEN '/'
ELSE replace(replace(replace(replace(aml.name, '|', '/'), '\t', ''), '\n', ''), '\r', '') END AS EcritureLib,
WHEN aml.name SIMILAR TO '[\\t|\\s|\\n]*' THEN '/'
ELSE REGEXP_REPLACE(replace(aml.name, '|', '/'), '[\\t\\n\\r]', ' ', 'g') END AS EcritureLib,
replace(CASE WHEN aml.debit = 0 THEN '0,00' ELSE to_char(aml.debit, '000000000000000D99') END, '.', ',') AS Debit,
replace(CASE WHEN aml.credit = 0 THEN '0,00' ELSE to_char(aml.credit, '000000000000000D99') END, '.', ',') AS Credit,
CASE WHEN rec.name IS NULL THEN '' ELSE rec.name END AS EcritureLet,
+12 -5
View File
@@ -2125,11 +2125,18 @@ exports.Orderline = Backbone.Model.extend({
else
var price_include = !price_exclude;
if (tax.amount_type === 'fixed') {
var sign_base_amount = Math.sign(base_amount) || 1;
// Since base amount has been computed with quantity
// we take the abs of quantity
// Same logic as bb72dea98de4dae8f59e397f232a0636411d37ce
return tax.amount * sign_base_amount * Math.abs(quantity);
// Use sign on base_amount and abs on quantity to take into account the sign of the base amount,
// which includes the sign of the quantity and the sign of the price_unit
// Amount is the fixed price for the tax, it can be negative
// Base amount included the sign of the quantity and the sign of the unit price and when
// a product is returned, it can be done either by changing the sign of quantity or by changing the
// sign of the price unit.
// When the price unit is equal to 0, the sign of the quantity is absorbed in base_amount then
// a "else" case is needed.
if (base_amount)
return Math.sign(base_amount) * Math.abs(quantity) * tax.amount;
else
return quantity * tax.amount;
}
if (tax.amount_type === 'percent' && !price_include){
return base_amount * tax.amount / 100;
+7 -1
View File
@@ -1222,11 +1222,17 @@ class Task(models.Model):
self.ensure_one()
project_user_group_id = self.env.ref('project.group_project_user').id
project_manager_group_id = self.env.ref('project.group_project_manager').id
group_func = lambda pdata: pdata['type'] == 'user' and project_user_group_id in pdata['groups']
if self.project_id.privacy_visibility == 'followers':
allowed_user_ids = self.project_id.allowed_internal_user_ids.partner_id.ids
group_func = lambda pdata: pdata['type'] == 'user' and project_user_group_id in pdata['groups'] and pdata['id'] in allowed_user_ids
group_func = lambda pdata:\
pdata['type'] == 'user'\
and (
project_manager_group_id in pdata['groups']\
or (project_user_group_id in pdata['groups'] and pdata['id'] in allowed_user_ids)
)
new_group = ('group_project_user', group_func, {})
if not self.user_id and not self.stage_id.fold:
+1 -1
View File
@@ -239,7 +239,7 @@ class SaleOrderLine(models.Model):
if supplierinfo:
price_unit = self.env['account.tax'].sudo()._fix_tax_included_price_company(supplierinfo.price, self.product_id.supplier_taxes_id, taxes, self.company_id)
if purchase_order.currency_id and supplierinfo.currency_id != purchase_order.currency_id:
price_unit = supplierinfo.currency_id.compute(price_unit, purchase_order.currency_id)
price_unit = supplierinfo.currency_id._convert(price_unit, purchase_order.currency_id, purchase_order.company_id, fields.datetime.today())
return {
'name': '[%s] %s' % (self.product_id.default_code, self.name) if self.product_id.default_code else self.name,
@@ -4,6 +4,7 @@ flectra.define('website.tour.carousel_content_removal', function (require) {
const tour = require('web_tour.tour');
tour.register("carousel_content_removal", {
test: true,
url: "/",
}, [{
trigger: "a[data-action=edit]",