Merge branch 'master-upstream-patch-28102022' into 'master'

[PATCH] Upstream patch - 28102022

See merge request flectra-hq/flectra!839
This commit is contained in:
Parthiv Patel committed 2022-10-28 12:08:54 +00:00
commit 8c3e8659ff
21 files changed
+390 -104

No files matched your search

+2 -2
View File
@@ -816,5 +816,5 @@ class AccountJournal(models.Model):
'''
self.ensure_one()
last_statement_domain = (domain or []) + [('journal_id', '=', self.id)]
last_st_line = self.env['account.bank.statement.line'].search(last_statement_domain, order='date desc, id desc', limit=1)
return last_st_line.statement_id
last_statement = self.env['account.bank.statement'].search(last_statement_domain, order='date desc, id desc', limit=1)
return last_statement
@@ -99,7 +99,7 @@ class account_journal(models.Model):
locale = get_lang(self.env).code
#starting point of the graph is the last statement
last_stmt = self._get_last_bank_statement(domain=[('move_id.state', '=', 'posted')])
last_stmt = self._get_last_bank_statement(domain=[('state', 'in', ['posted', 'confirm'])])
last_balance = last_stmt and last_stmt.balance_end_real or 0
data.append(build_graph_data(today, last_balance))
@@ -233,7 +233,7 @@ class account_journal(models.Model):
sum_draft = sum_waiting = sum_late = 0.0
if self.type in ('bank', 'cash'):
last_statement = self._get_last_bank_statement(
domain=[('move_id.state', '=', 'posted')])
domain=[('state', 'in', ['posted', 'confirm'])])
last_balance = last_statement.balance_end
has_at_least_one_statement = bool(last_statement)
bank_account_balance, nb_lines_bank_account_balance = self._get_journal_bank_account_balance(
+1 -1
View File
@@ -3205,7 +3205,7 @@ class AccountMoveLine(models.Model):
sequence = fields.Integer(default=10)
name = fields.Char(string='Label', tracking=True)
quantity = fields.Float(string='Quantity',
default=1.0, digits='Product Unit of Measure',
default=lambda self: 0 if self._context.get('default_display_type') else 1.0, digits='Product Unit of Measure',
help="The optional quantity expressed by this line, eg: number of product sold. "
"The quantity is not a legal requirement but is very useful for some reports.")
price_unit = fields.Float(string='Unit Price', digits='Product Price')
@@ -92,3 +92,106 @@ class TestAccountJournalDashboard(AccountTestInvoicingCommon):
dashboard_data = journal.get_journal_dashboard_datas()
self.assertEqual(dashboard_data['number_late'], 2)
self.assertIn('78.42', dashboard_data['sum_late'])
def test_last_statement(self):
bank_journal = self.company_data['default_journal_bank']
invoices = self.env['account.move'].create([
{
'move_type': 'out_invoice',
'partner_id': self.partner_a.id,
'invoice_date': '2022-05-17',
'date': '2022-05-17',
'invoice_line_ids': [(0, 0, {
'product_id': self.product_a.id,
'quantity': 1.0,
'name': 'product test 1',
'price_unit': 500.0,
})]
},
{
'move_type': 'out_invoice',
'partner_id': self.partner_a.id,
'invoice_date': '2022-05-18',
'date': '2022-05-18',
'invoice_line_ids': [(0, 0, {
'product_id': self.product_a.id,
'quantity': 1.0,
'name': 'product test 1',
'price_unit': 700.0,
})]
},
{
'move_type': 'out_invoice',
'partner_id': self.partner_a.id,
'invoice_date': '2022-05-17',
'date': '2022-05-17',
'invoice_line_ids': [(0, 0, {
'product_id': self.product_a.id,
'quantity': 1.0,
'name': 'product test 1',
'price_unit': 900.0,
})]
},
])
invoices.action_post()
payments = self.env['account.payment'].create([
{
'amount': 500.0,
'payment_type': 'inbound',
'partner_type': 'customer',
'partner_id': self.partner_a.id,
'journal_id': bank_journal.id,
'date': '2022-05-17',
},
{
'amount': 700.0,
'payment_type': 'inbound',
'partner_type': 'customer',
'partner_id': self.partner_a.id,
'journal_id': bank_journal.id,
'date': '2022-05-18',
},
{
'amount': 500.0,
'payment_type': 'inbound',
'partner_type': 'customer',
'partner_id': self.partner_a.id,
'journal_id': bank_journal.id,
'date': '2022-05-17',
},
])
payments.action_post()
for invoice, payment in zip(invoices, payments):
(invoice + payment.move_id).line_ids\
.filtered(lambda line: line.account_internal_type == 'receivable')\
.reconcile()
# Create statements in bank journal.
statements = self.env['account.bank.statement'].create([
{
'name': 'BNK1_1',
'date': '2022-05-17',
'journal_id': bank_journal.id,
'line_ids': [
(0, 0, {'date': '2022-05-17', 'payment_ref': invoices[0].name, 'amount': 500.0}),
(0, 0, {'date': '2022-05-18', 'payment_ref': invoices[1].name, 'amount': 700.0}),
],
'balance_end_real': 1200.0,
},
{
'name': 'BNK1_2',
'date': '2022-05-17',
'journal_id': bank_journal.id,
'line_ids': [(0, 0, {'date': '2022-05-17', 'payment_ref': invoices[2].name, 'amount': 900.0})],
'balance_end_real': 2100.0,
}
])
statements.button_post()
dashboard = bank_journal.get_journal_dashboard_datas()
self.assertTrue(dashboard['last_balance'] == dashboard['account_balance'])
+104 -72
View File
@@ -5,8 +5,8 @@
<!-- ### Domestic:sales:goods -->
<record id="tax_dom_sales_goods_24" model="account.tax.template">
<field name="chart_template_id" ref="fi_chart_template"/>
<field name="name">VAT 24%</field>
<field name="description">VAT 24%</field>
<field name="name">24%</field>
<field name="description">24%</field>
<field name="amount">24.0</field>
<field name="tax_group_id" ref="tax_group_24"/>
<field name="type_tax_use">sale</field>
@@ -38,11 +38,12 @@
</record>
<record id="tax_dom_sales_goods_14" model="account.tax.template">
<field name="chart_template_id" ref="fi_chart_template"/>
<field name="name">VAT 14%</field>
<field name="description">VAT 14%</field>
<field name="name">14%</field>
<field name="description">14%</field>
<field name="amount">14.0</field>
<field name="tax_group_id" ref="tax_group_14"/>
<field name="type_tax_use">sale</field>
<field name="active" eval="False"/>
<field name="amount_type">percent</field>
<field name="invoice_repartition_line_ids" eval="[(5, 0, 0),
(0,0, {
@@ -71,11 +72,12 @@
</record>
<record id="tax_dom_sales_goods_10" model="account.tax.template">
<field name="chart_template_id" ref="fi_chart_template"/>
<field name="name">VAT 10%</field>
<field name="description">VAT 10%</field>
<field name="name">10%</field>
<field name="description">10%</field>
<field name="amount">10.0</field>
<field name="tax_group_id" ref="tax_group_10"/>
<field name="type_tax_use">sale</field>
<field name="active" eval="False"/>
<field name="amount_type">percent</field>
<field name="invoice_repartition_line_ids" eval="[(5, 0, 0),
@@ -105,8 +107,8 @@
</record>
<record id="tax_dom_sales_goods_0" model="account.tax.template">
<field name="chart_template_id" ref="fi_chart_template"/>
<field name="name">VAT 0%</field>
<field name="description">VAT 0%</field>
<field name="name">0%</field>
<field name="description">0%</field>
<field name="amount">0.0</field>
<field name="tax_group_id" ref="tax_group_0"/>
<field name="type_tax_use">sale</field>
@@ -139,8 +141,8 @@
<!-- ### Domestic:sales:service -->
<record id="tax_dom_sales_service_24" model="account.tax.template">
<field name="chart_template_id" ref="fi_chart_template"/>
<field name="name">VAT 24% Service</field>
<field name="description">VAT 24% Service</field>
<field name="name">24% S</field>
<field name="description">24%</field>
<field name="amount">24.0</field>
<field name="tax_group_id" ref="tax_group_24"/>
<field name="type_tax_use">sale</field>
@@ -173,11 +175,12 @@
</record>
<record id="tax_dom_sales_service_14" model="account.tax.template">
<field name="chart_template_id" ref="fi_chart_template"/>
<field name="name">VAT 14% Service</field>
<field name="description">VAT 14% Service</field>
<field name="name">14% S</field>
<field name="description">14%</field>
<field name="amount">14.0</field>
<field name="tax_group_id" ref="tax_group_14"/>
<field name="type_tax_use">sale</field>
<field name="active" eval="False"/>
<field name="amount_type">percent</field>
<field name="invoice_repartition_line_ids" eval="[(5, 0, 0),
@@ -207,11 +210,12 @@
</record>
<record id="tax_dom_sales_service_10" model="account.tax.template">
<field name="chart_template_id" ref="fi_chart_template"/>
<field name="name">VAT 10% Service</field>
<field name="description">VAT 10% Service</field>
<field name="name">10% S</field>
<field name="description">10%</field>
<field name="amount">10.0</field>
<field name="tax_group_id" ref="tax_group_10"/>
<field name="type_tax_use">sale</field>
<field name="active" eval="False"/>
<field name="amount_type">percent</field>
<field name="invoice_repartition_line_ids" eval="[(5, 0, 0),
(0,0, {
@@ -244,8 +248,8 @@
<!-- ### Domestic:purchase:goods -->
<record id="tax_dom_purchase_goods_24" model="account.tax.template">
<field name="chart_template_id" ref="fi_chart_template"/>
<field name="name">Purchase 24%</field>
<field name="description">Purchase 24%</field>
<field name="name">24%</field>
<field name="description">24%</field>
<field name="amount">24.0</field>
<field name="tax_group_id" ref="tax_group_24"/>
<field name="type_tax_use">purchase</field>
@@ -277,11 +281,12 @@
</record>
<record id="tax_dom_purchase_goods_14" model="account.tax.template">
<field name="chart_template_id" ref="fi_chart_template"/>
<field name="name">Purchase 14%</field>
<field name="description">Purchase 14%</field>
<field name="name">14%</field>
<field name="description">14%</field>
<field name="amount">14.0</field>
<field name="tax_group_id" ref="tax_group_14"/>
<field name="type_tax_use">purchase</field>
<field name="active" eval="False"/>
<field name="amount_type">percent</field>
<field name="invoice_repartition_line_ids" eval="[(5, 0, 0),
(0,0, {
@@ -310,11 +315,12 @@
</record>
<record id="tax_dom_purchase_goods_10" model="account.tax.template">
<field name="chart_template_id" ref="fi_chart_template"/>
<field name="name">Purchase 10%</field>
<field name="description">Purchase 10%</field>
<field name="name">10%</field>
<field name="description">10%</field>
<field name="amount">10.0</field>
<field name="tax_group_id" ref="tax_group_10"/>
<field name="type_tax_use">purchase</field>
<field name="active" eval="False"/>
<field name="amount_type">percent</field>
<field name="invoice_repartition_line_ids" eval="[(5, 0, 0),
(0,0, {
@@ -345,8 +351,8 @@
<!-- ### Domestic:purchase:service -->
<record id="tax_dom_purchase_service_24" model="account.tax.template">
<field name="chart_template_id" ref="fi_chart_template"/>
<field name="name">Purchase 24% Service</field>
<field name="description">Purchase 24% Service</field>
<field name="name">24% S</field>
<field name="description">24%</field>
<field name="amount">24.0</field>
<field name="tax_group_id" ref="tax_group_24"/>
<field name="type_tax_use">purchase</field>
@@ -378,11 +384,12 @@
</record>
<record id="tax_dom_purchase_service_14" model="account.tax.template">
<field name="chart_template_id" ref="fi_chart_template"/>
<field name="name">Purchase 14% Service</field>
<field name="description">Purchase 14% Service</field>
<field name="name">14% S</field>
<field name="description">14%</field>
<field name="amount">14.0</field>
<field name="tax_group_id" ref="tax_group_14"/>
<field name="type_tax_use">purchase</field>
<field name="active" eval="False"/>
<field name="amount_type">percent</field>
<field name="invoice_repartition_line_ids" eval="[(5, 0, 0),
(0,0, {
@@ -411,11 +418,12 @@
</record>
<record id="tax_dom_purchase_service_10" model="account.tax.template">
<field name="chart_template_id" ref="fi_chart_template"/>
<field name="name">Purchase 10% Service</field>
<field name="description">Purchase 10% Service</field>
<field name="name">10% S</field>
<field name="description">10%</field>
<field name="amount">10.0</field>
<field name="tax_group_id" ref="tax_group_10"/>
<field name="type_tax_use">purchase</field>
<field name="active" eval="False"/>
<field name="amount_type">percent</field>
<field name="invoice_repartition_line_ids" eval="[(5, 0, 0),
(0,0, {
@@ -446,11 +454,14 @@
<!-- ### Domestic:purchase:brutto -->
<record id="tax_dom_purchase_brutto_24" model="account.tax.template">
<field name="chart_template_id" ref="fi_chart_template"/>
<field name="name">Purchase 24% (brutto)</field>
<field name="description">Purchase 24% (brutto)</field>
<field name="name">24% incl</field>
<field name="description">24% incl</field>
<field name="price_include" eval="1" />
<field name="include_base_amount" eval="1" />
<field name="amount">24.0</field>
<field name="tax_group_id" ref="tax_group_24"/>
<field name="type_tax_use">purchase</field>
<field name="active" eval="False"/>
<field name="amount_type">percent</field>
<field name="invoice_repartition_line_ids" eval="[(5, 0, 0),
(0,0, {
@@ -479,11 +490,14 @@
</record>
<record id="tax_dom_purchase_brutto_14" model="account.tax.template">
<field name="chart_template_id" ref="fi_chart_template"/>
<field name="name">Purchase 14% (brutto)</field>
<field name="description">Purchase 14% (brutto)</field>
<field name="name">14% incl</field>
<field name="description">14% incl</field>
<field name="price_include" eval="1" />
<field name="include_base_amount" eval="1" />
<field name="amount">14.0</field>
<field name="tax_group_id" ref="tax_group_14"/>
<field name="type_tax_use">purchase</field>
<field name="active" eval="False"/>
<field name="amount_type">percent</field>
<field name="invoice_repartition_line_ids" eval="[(5, 0, 0),
(0,0, {
@@ -512,11 +526,14 @@
</record>
<record id="tax_dom_purchase_brutto_10" model="account.tax.template">
<field name="chart_template_id" ref="fi_chart_template"/>
<field name="name">Purchase 10% (brutto)</field>
<field name="description">Purchase 10% (brutto)</field>
<field name="name">10% incl</field>
<field name="description">10% incl</field>
<field name="price_include" eval="1" />
<field name="include_base_amount" eval="1" />
<field name="amount">10.0</field>
<field name="tax_group_id" ref="tax_group_10"/>
<field name="type_tax_use">purchase</field>
<field name="active" eval="False"/>
<field name="amount_type">percent</field>
<field name="invoice_repartition_line_ids" eval="[(5, 0, 0),
(0,0, {
@@ -547,8 +564,8 @@
<!-- ### Domestic:purchase:no_category -->
<record id="tax_dom_purchase_0" model="account.tax.template">
<field name="chart_template_id" ref="fi_chart_template"/>
<field name="name">Purchase 0%</field>
<field name="description">Purchase 0%</field>
<field name="name">0%</field>
<field name="description">0%</field>
<field name="amount">0.0</field>
<field name="tax_group_id" ref="tax_group_0"/>
<field name="type_tax_use">purchase</field>
@@ -560,8 +577,8 @@
<!-- ### Europe:sales:goods -->
<record id="tax_eu_sales_goods_0" model="account.tax.template">
<field name="chart_template_id" ref="fi_chart_template"/>
<field name="name">VAT 0% EU Goods</field>
<field name="description">VAT 0% EU Goods</field>
<field name="name">0% EU G</field>
<field name="description">0%</field>
<field name="amount">0.0</field>
<field name="tax_group_id" ref="tax_group_0"/>
<field name="type_tax_use">sale</field>
@@ -593,8 +610,8 @@
<!-- ### Europe:sales:service -->
<record id="tax_eu_sales_service_0" model="account.tax.template">
<field name="chart_template_id" ref="fi_chart_template"/>
<field name="name">VAT 0% EU Service</field>
<field name="description">VAT 0% EU Service</field>
<field name="name">0% EU S</field>
<field name="description">0%</field>
<field name="amount">0.0</field>
<field name="tax_group_id" ref="tax_group_0"/>
<field name="type_tax_use">sale</field>
@@ -627,8 +644,8 @@
<!-- ### Europe:purchase:goods -->
<record id="tax_eu_purchase_goods_24" model="account.tax.template">
<field name="chart_template_id" ref="fi_chart_template"/>
<field name="name">Purchase 24% EU Goods</field>
<field name="description">Purchase 24% EU Goods</field>
<field name="name">24% EU G</field>
<field name="description">24%</field>
<field name="amount">24.0</field>
<field name="tax_group_id" ref="tax_group_24"/>
<field name="type_tax_use">purchase</field>
@@ -672,11 +689,12 @@
</record>
<record id="tax_eu_purchase_goods_14" model="account.tax.template">
<field name="chart_template_id" ref="fi_chart_template"/>
<field name="name">Purchase 14% EU Goods</field>
<field name="description">Purchase 14% EU Goods</field>
<field name="name">14% EU</field>
<field name="description">14%</field>
<field name="amount">14.0</field>
<field name="tax_group_id" ref="tax_group_14"/>
<field name="type_tax_use">purchase</field>
<field name="active" eval="False"/>
<field name="amount_type">percent</field>
<field name="invoice_repartition_line_ids" eval="[(5, 0, 0),
(0,0, {
@@ -717,11 +735,12 @@
</record>
<record id="tax_eu_purchase_goods_10" model="account.tax.template">
<field name="chart_template_id" ref="fi_chart_template"/>
<field name="name">Purchase 10% EU Goods</field>
<field name="description">Purchase 10% EU Goods</field>
<field name="name">10% EU G</field>
<field name="description">10%</field>
<field name="amount">10.0</field>
<field name="tax_group_id" ref="tax_group_10"/>
<field name="type_tax_use">purchase</field>
<field name="active" eval="False"/>
<field name="amount_type">percent</field>
<field name="invoice_repartition_line_ids" eval="[(5, 0, 0),
(0,0, {
@@ -764,8 +783,8 @@
<!-- ### Europe:purchase:service -->
<record id="tax_eu_purchase_service_24" model="account.tax.template">
<field name="chart_template_id" ref="fi_chart_template"/>
<field name="name">Purchase 24% EU Service</field>
<field name="description">Purchase 24% EU Service</field>
<field name="name">24% EU S</field>
<field name="description">24%</field>
<field name="amount">24.0</field>
<field name="tax_group_id" ref="tax_group_24"/>
<field name="type_tax_use">purchase</field>
@@ -809,11 +828,12 @@
</record>
<record id="tax_eu_purchase_service_14" model="account.tax.template">
<field name="chart_template_id" ref="fi_chart_template"/>
<field name="name">Purchase 14% EU Service</field>
<field name="description">Purchase 14% EU Service</field>
<field name="name">14% EU S</field>
<field name="description">14%</field>
<field name="amount">14.0</field>
<field name="tax_group_id" ref="tax_group_14"/>
<field name="type_tax_use">purchase</field>
<field name="active" eval="False"/>
<field name="amount_type">percent</field>
<field name="invoice_repartition_line_ids" eval="[(5, 0, 0),
(0,0, {
@@ -854,11 +874,12 @@
</record>
<record id="tax_eu_purchase_service_10" model="account.tax.template">
<field name="chart_template_id" ref="fi_chart_template"/>
<field name="name">Purchase 10% EU Service</field>
<field name="description">Purchase 10% EU Service</field>
<field name="name">10% EU S</field>
<field name="description">10%</field>
<field name="amount">10.0</field>
<field name="tax_group_id" ref="tax_group_10"/>
<field name="type_tax_use">purchase</field>
<field name="active" eval="False"/>
<field name="amount_type">percent</field>
<field name="invoice_repartition_line_ids" eval="[(5, 0, 0),
(0,0, {
@@ -901,11 +922,12 @@
<!-- # TRIANGULATION -->
<record id="vat0triangulation" model="account.tax.template">
<field name="chart_template_id" ref="fi_chart_template"/>
<field name="name">VAT 0% Triangulation</field>
<field name="description">VAT 0% Triangulation</field>
<field name="name">0% ABC</field>
<field name="description">0%</field>
<field name="amount">0.0</field>
<field name="tax_group_id" ref="tax_group_0"/>
<field name="type_tax_use">sale</field>
<field name="active" eval="False"/>
<field name="amount_type">percent</field>
<field name="invoice_repartition_line_ids" eval="[(5, 0, 0),
(0,0, {
@@ -930,11 +952,12 @@
</record>
<record id="triangulation_purchase" model="account.tax.template">
<field name="chart_template_id" ref="fi_chart_template"/>
<field name="name">Triangulation Purchase</field>
<field name="description">Triangulation Purchase</field>
<field name="name">ABC</field>
<field name="description">ABC</field>
<field name="amount">0.0</field>
<field name="tax_group_id" ref="tax_group_0"/>
<field name="type_tax_use">purchase</field>
<field name="active" eval="False"/>
<field name="amount_type">percent</field>
<field name="invoice_repartition_line_ids" eval="[(5, 0, 0),
(0,0, {
@@ -963,11 +986,12 @@
<!-- # Construct -->
<record id="tax_construct_sales_0" model="account.tax.template">
<field name="chart_template_id" ref="fi_chart_template"/>
<field name="name">Construct 0%</field>
<field name="description">Construct 0%</field>
<field name="name">0% Construct</field>
<field name="description">0%</field>
<field name="amount">0.0</field>
<field name="tax_group_id" ref="tax_group_0"/>
<field name="type_tax_use">sale</field>
<field name="active" eval="False"/>
<field name="amount_type">percent</field>
<field name="invoice_repartition_line_ids" eval="[(5, 0, 0),
(0,0, {
@@ -994,11 +1018,12 @@
</record>
<record id="tax_construct_purchase_24" model="account.tax.template">
<field name="chart_template_id" ref="fi_chart_template"/>
<field name="name">Purchase 24% Construct</field>
<field name="description">Purchase 24% Construct</field>
<field name="name">24% Construct</field>
<field name="description">24%</field>
<field name="amount">24.0</field>
<field name="tax_group_id" ref="tax_group_24"/>
<field name="type_tax_use">purchase</field>
<field name="active" eval="False"/>
<field name="amount_type">percent</field>
<field name="invoice_repartition_line_ids" eval="[(5, 0, 0),
(0,0, {
@@ -1027,11 +1052,12 @@
</record>
<record id="tax_construct_purchase_24_finland" model="account.tax.template">
<field name="chart_template_id" ref="fi_chart_template"/>
<field name="name">Purchase 24% FI Construct</field>
<field name="description">Purchase 24% FI Construct</field>
<field name="name">24% FI Construct</field>
<field name="description">24%</field>
<field name="tax_group_id" ref="tax_group_24"/>
<field name="amount">24.0</field>
<field name="type_tax_use">purchase</field>
<field name="active" eval="False"/>
<field name="amount_type">percent</field>
<field name="invoice_repartition_line_ids" eval="[(5, 0, 0),
(0,0, {
@@ -1077,11 +1103,12 @@
<!-- ## Aland:sales -->
<record id="aland_sales_0" model="account.tax.template">
<field name="chart_template_id" ref="fi_chart_template"/>
<field name="name">Aland 0%</field>
<field name="description">Aland 0%</field>
<field name="name">0% Aland</field>
<field name="description">0%</field>
<field name="amount">0.0</field>
<field name="tax_group_id" ref="tax_group_0"/>
<field name="type_tax_use">sale</field>
<field name="active" eval="False"/>
<field name="amount_type">percent</field>
<field name="invoice_repartition_line_ids" eval="[(5, 0, 0),
(0,0, {
@@ -1112,11 +1139,12 @@
<!-- ## Non EU:purchase:goods -->
<record id="tax_non_eu_purchase_goods_24" model="account.tax.template">
<field name="chart_template_id" ref="fi_chart_template"/>
<field name="name">Purchase 24% Non EU Goods</field>
<field name="description">Purchase 24% Non EU Goods</field>
<field name="name">24% EX G</field>
<field name="description">24%</field>
<field name="amount">24.0</field>
<field name="tax_group_id" ref="tax_group_24"/>
<field name="type_tax_use">purchase</field>
<field name="active" eval="False"/>
<field name="amount_type">percent</field>
<field name="invoice_repartition_line_ids" eval="[(5, 0, 0),
(0,0, {
@@ -1157,11 +1185,12 @@
</record>
<record id="tax_non_eu_purchase_goods_14" model="account.tax.template">
<field name="chart_template_id" ref="fi_chart_template"/>
<field name="name">Purchase 14% Non EU Goods</field>
<field name="description">Purchase 14% Non EU Goods</field>
<field name="name">14% EX G</field>
<field name="description">14%</field>
<field name="amount">14.0</field>
<field name="tax_group_id" ref="tax_group_14"/>
<field name="type_tax_use">purchase</field>
<field name="active" eval="False"/>
<field name="amount_type">percent</field>
<field name="invoice_repartition_line_ids" eval="[(5, 0, 0),
(0,0, {
@@ -1202,11 +1231,12 @@
</record>
<record id="tax_non_eu_purchase_goods_10" model="account.tax.template">
<field name="chart_template_id" ref="fi_chart_template"/>
<field name="name">Purchase 10% Non EU Goods</field>
<field name="description">Purchase 10% Non EU Goods</field>
<field name="name">10% EX G</field>
<field name="description">10%</field>
<field name="amount">10.0</field>
<field name="tax_group_id" ref="tax_group_10"/>
<field name="type_tax_use">purchase</field>
<field name="active" eval="False"/>
<field name="amount_type">percent</field>
<field name="invoice_repartition_line_ids" eval="[(5, 0, 0),
(0,0, {
@@ -1249,8 +1279,8 @@
<!-- ## Non EU:others -->
<record id="vat0export" model="account.tax.template">
<field name="chart_template_id" ref="fi_chart_template"/>
<field name="name">VAT 0% Export</field>
<field name="description">VAT 0% Export</field>
<field name="name">0% EX</field>
<field name="description">0% EX</field>
<field name="amount">0.0</field>
<field name="tax_group_id" ref="tax_group_0"/>
<field name="type_tax_use">sale</field>
@@ -1281,11 +1311,12 @@
</record>
<record id="import_pay24" model="account.tax.template">
<field name="chart_template_id" ref="fi_chart_template"/>
<field name="name">Import Pay24</field>
<field name="name">24% Import Pay</field>
<field name="description">24%</field>
<field name="amount">24.0</field>
<field name="tax_group_id" ref="tax_group_24"/>
<field name="type_tax_use">purchase</field>
<field name="active" eval="False"/>
<field name="amount_type">percent</field>
<field name="invoice_repartition_line_ids" eval="[(5, 0, 0),
(0,0, {
@@ -1316,11 +1347,12 @@
</record>
<record id="import_deduct24" model="account.tax.template">
<field name="chart_template_id" ref="fi_chart_template"/>
<field name="name">Import Deduct24</field>
<field name="name">24% Import Deduct</field>
<field name="description">24%</field>
<field name="amount">24.0</field>
<field name="tax_group_id" ref="tax_group_24"/>
<field name="type_tax_use">purchase</field>
<field name="active" eval="False"/>
<field name="amount_type">percent</field>
<field name="invoice_repartition_line_ids" eval="[(5, 0, 0),
(0,0, {
@@ -212,7 +212,7 @@ class AccountEdiFormat(models.Model):
def _l10n_it_document_type_mapping(self):
return {
'TD01': dict(move_types=['out_invoice'], import_type='in_invoice'),
'TD01': dict(move_types=['out_invoice'], import_type='in_invoice', downpayment=False),
'TD02': dict(move_types=['out_invoice'], import_type='in_invoice', downpayment=True),
'TD04': dict(move_types=['out_refund'], import_type='in_refund'),
'TD07': dict(move_types=['out_invoice'], import_type='in_invoice', simplified=True),
@@ -234,7 +234,9 @@ class AccountEdiFormat(models.Model):
info_partner_in_eu = infos.get('partner_in_eu', False)
if all([
invoice.move_type in infos.get('move_types', False),
invoice._is_downpayment() == infos.get('downpayment', False),
# Only check downpayment if the key is specified in the document_type_mapping entry
# If it's not specified, the get() will return None and the condition will be True
infos.get('downpayment') in (None, invoice._is_downpayment()),
is_self_invoice == infos.get('self_invoice', False),
is_simplified == infos.get('simplified', False),
info_services_or_goods in ("both", services_or_goods),
@@ -242,6 +244,7 @@ class AccountEdiFormat(models.Model):
goods_in_italy == infos.get('goods_in_italy', False),
]):
return code
return None
def _l10n_it_is_simplified_document_type(self, document_type):
+1 -1
View File
@@ -72,7 +72,7 @@ class ProductProduct(models.Model):
duration_expected = (
opt.workcenter_id.time_start +
opt.workcenter_id.time_stop +
opt.time_cycle)
opt.time_cycle * 100 / opt.workcenter_id.time_efficiency)
total += (duration_expected / 60) * opt.workcenter_id.costs_hour
for line in bom.bom_line_ids:
if line._skip_bom_line(self):
+16 -15
View File
@@ -3,6 +3,7 @@
from flectra.exceptions import UserError
from flectra.tests import common, Form
from flectra.tools.float_utils import float_round, float_compare
@@ -109,11 +110,11 @@ class TestBom(common.TransactionCase):
"""Test calcuation of bom cost with operations."""
workcenter_from1 = Form(self.env['mrp.workcenter'])
workcenter_from1.name = 'Workcenter'
workcenter_from1.time_efficiency = 100
workcenter_from1.time_efficiency = 80
workcenter_from1.capacity = 2
workcenter_from1.oee_target = 100
workcenter_from1.time_start = 0
workcenter_from1.time_stop = 0
workcenter_from1.time_start = 15
workcenter_from1.time_stop = 15
workcenter_from1.costs_hour = 100
workcenter_1 = workcenter_from1.save()
@@ -173,11 +174,11 @@ class TestBom(common.TransactionCase):
# Dinning Table Operation Cost(1 Unit)
# -----------------------------------------------------------------
# Operation cost calculate for 1 units
# Cutting (20 / 60) * 100 = 33.33
# Drilling (25 / 60) * 100 = 41.67
# Fitting (30 / 60) * 100 = 50.00
# Cutting (15 + 15 + (20 * 100/80) / 60) * 100 = 91.67
# Drilling (15 + 15 + (25 * 100/80) / 60) * 100 = 102.08
# Fitting (15 + 15 + (30 * 100/80) / 60) * 100 = 112.50
# ----------------------------------------
# Operation Cost 1 unit = 125
# Operation Cost 1 unit = 306.25
# -----------------------------------------------------------------
@@ -185,18 +186,18 @@ class TestBom(common.TransactionCase):
# Table Head Operation Cost (1 Dozen)
# --------------------------------------------------------------------------
# Operation cost calculate for 1 dozens
# Cutting (20 * 1 / 60) * 100 = 33,33
# Drilling (25 * 1 / 60) * 100 = 41,67
# Fitting (30 * 1 / 60) * 100 = 50
# Cutting (15 + 15 + (20 * 1 * 100/80) / 60) * 100 = 91.67
# Drilling (15 + 15 + (25 * 1 * 100/80) / 60) * 100 = 102.08
# Fitting (15 + 15 + (30 * 1 * 100/80) / 60) * 100 = 112.50
# ----------------------------------------
# Operation Cost 1 dozen (125 per dozen) and 10.42 for 1 Unit
# Operation Cost 1 dozen (306.25 per dozen) and 25.52 for 1 Unit
# --------------------------------------------------------------------------
self.assertEqual(self.dining_table.standard_price, 1000, "Initial price of the Product should be 1000")
self.dining_table.button_bom_cost()
# Total cost of Dining Table = (550) + Total cost of operations (125) = 675.0
self.assertEqual(float_round(self.dining_table.standard_price, precision_digits=2), 675.0, "After computing price from BoM price should be 612.5")
# Total cost of Dining Table = (550) + Total cost of operations (306.25) = 856.25
self.assertEqual(float_round(self.dining_table.standard_price, precision_digits=2), 856.25, "After computing price from BoM price should be 856.25")
self.Product.browse([self.dining_table.id, self.table_head.id]).action_bom_cost()
# Total cost of Dining Table = (718.75) + Total cost of all operations (125 + 10.42) = 854.17
self.assertEqual(float_compare(self.dining_table.standard_price, 854.17, precision_digits=2), 0, "After computing price from BoM price should be 786.46")
# Total cost of Dining Table = (718.75) + Total cost of all operations (306.25 + 25.52) = 1050.52
self.assertEqual(float_compare(self.dining_table.standard_price, 1050.52, precision_digits=2), 0, "After computing price from BoM price should be 1050.52")
+1 -1
View File
@@ -475,7 +475,7 @@ class PurchaseOrderLine(models.Model):
return {
# truncate to 2000 to avoid triggering index limit error
# TODO: remove index in master?
'name': (self.name or '')[:2000],
'name': (self.product_id.display_name or '')[:2000],
'product_id': self.product_id.id,
'date': date_planned,
'date_deadline': date_planned + relativedelta(days=self.order_id.company_id.po_lead),
@@ -496,3 +496,63 @@ class TestSaleMrpKitBom(TransactionCase):
for move in ship.move_line_ids:
self.assertEqual(move.product_uom_qty, move.qty_done, "Quantity done should be equal to the quantity reserved in the move line")
def test_kit_in_delivery_slip(self):
"""
Suppose this structure:
Sale order:
- Kit 1 with a sales description("test"):
|- Compo 1
- Product 1
This test ensures that, when delivering a Kit product with a sales description,
the delivery report is correctly printed with all the products.
"""
kit_1, component_1, product_1 = self.env['product.product'].create([{
'name': n,
'type': 'product',
} for n in ['Kit 1', 'Compo 1', 'Product 1']])
kit_1.description_sale = "test"
self.env['mrp.bom'].create([{
'product_tmpl_id': kit_1.product_tmpl_id.id,
'product_qty': 1,
'type': 'phantom',
'bom_line_ids': [
(0, 0, {'product_id': component_1.id, 'product_qty': 1}),
],
}])
customer = self.env['res.partner'].create({
'name': 'customer',
})
so = self.env['sale.order'].create({
'partner_id': customer.id,
'order_line': [
(0, 0, {
'product_id': kit_1.id,
'product_uom_qty': 1.0,
}),
(0, 0, {
'product_id': product_1.id,
'product_uom_qty': 1.0,
})],
})
so.action_confirm()
picking = so.picking_ids
self.assertEqual(len(so.picking_ids.move_ids_without_package), 2)
picking.move_lines.quantity_done = 1
picking.button_validate()
self.assertEqual(picking.state, 'done')
report = self.env['ir.actions.report']._get_report_from_name('stock.report_deliveryslip')
html_report = report._render_qweb_html(picking.ids)[0].decode('utf-8').split('\n')
keys = [
"Kit 1", "Compo 1",
"Products not associated with a kit", "Product 1",
]
for line in html_report:
if not keys:
break
if keys[0] in line:
keys = keys[1:]
self.assertFalse(keys, "All keys should be in the report with the defined order")
+1 -1
View File
@@ -601,7 +601,7 @@ class SaleOrderLine(models.Model):
procurements.append(self.env['procurement.group'].Procurement(
line.product_id, product_qty, procurement_uom,
line.order_id.partner_shipping_id.property_stock_customer,
line.name, line.order_id.name, line.order_id.company_id, values))
line.product_id.display_name, line.order_id.name, line.order_id.company_id, values))
if procurements:
self.env['procurement.group'].run(procurements)
return True
@@ -19,7 +19,7 @@ class StockMoveLine(models.Model):
continue
move = move_line.move_id
rounding = move.product_id.uom_id.rounding
diff = move_line.qty_done
diff = move.product_uom._compute_quantity(move_line.qty_done, move.product_id.uom_id)
if float_is_zero(diff, precision_rounding=rounding):
continue
self._create_correction_svl(move, diff)
@@ -32,7 +32,7 @@ class StockMoveLine(models.Model):
continue
move = move_line.move_id
rounding = move.product_id.uom_id.rounding
diff = vals['qty_done'] - move_line.qty_done
diff = move.product_uom._compute_quantity(vals['qty_done'] - move_line.qty_done, move.product_id.uom_id)
if float_is_zero(diff, precision_rounding=rounding):
continue
self._create_correction_svl(move, diff)
@@ -3831,3 +3831,36 @@ class TestStockValuation(SavepointCase):
self.assertEqual(move.stock_valuation_layer_ids.value, 10)
self.assertEqual(move.stock_valuation_layer_ids.account_move_id.amount_total, 10)
def test_create_svl_different_uom(self):
"""
Create a transfer and use in the move a different unit of measure than
the one set on the product form and ensure that when the qty done is changed
and the picking is already validated, an svl is created in the uom set in the product.
"""
uom_dozen = self.env.ref('uom.product_uom_dozen')
receipt = self.env['stock.picking'].create({
'location_id': self.supplier_location.id,
'location_dest_id': self.stock_location.id,
'picking_type_id': self.env.ref('stock.picking_type_in').id,
'owner_id': self.env.company.partner_id.id,
})
move = self.env['stock.move'].create({
'picking_id': receipt.id,
'name': 'test',
'location_id': self.supplier_location.id,
'location_dest_id': self.stock_location.id,
'product_id': self.product1.id,
'product_uom': uom_dozen.id,
'product_uom_qty': 1.0,
'price_unit': 10,
})
receipt.action_confirm()
move.quantity_done = 1
receipt.button_validate()
self.assertEqual(self.product1.uom_name, 'Units')
self.assertEqual(self.product1.quantity_svl, 12)
move.quantity_done = 2
self.assertEqual(self.product1.quantity_svl, 24)
@@ -305,6 +305,7 @@ var RTEWidget = Widget.extend({
$('.o_not_editable').attr('contentEditable', false);
var $editable = this.editable();
this.__$editable = $editable;
// When a undo/redo is performed, the whole DOM is changed so we have
// to prepare for it (website will restart animations for example)
@@ -2,6 +2,7 @@ flectra.define('website.rte.summernote', function (require) {
'use strict';
var core = require('web.core');
const rte = require('web_editor.rte');
require('web_editor.rte.summernote');
var eventHandler = $.summernote.eventHandler;
@@ -56,4 +57,22 @@ eventHandler.modules.popover.button.update = function ($container, oStyle) {
.toggleClass('active', $(oStyle.image).is('[style*="transform"]'))
.toggleClass('d-none', !$(oStyle.image).is('img'));
};
rte.Class.include({
/**
* @override
*/
async start() {
const res = await this._super(...arguments);
// TODO review in master. This stable fix restores the possibility to
// edit the company team snippet images on subsequent editions. Indeed
// this badly relies on the contenteditable="true" attribute being on
// those images but it is rightfully lost after the first save.
// grep: COMPANY_TEAM_CONTENTEDITABLE
this.__$editable.find('.s_company_team .o_not_editable img').prop('contenteditable', true);
return res;
},
});
});
+4 -2
View File
@@ -1114,11 +1114,13 @@ function _clonePage(pageId) {
title: _t("Duplicate Page"),
$content: $(qweb.render('website.duplicate_page_action_dialog')),
confirm_callback: function () {
var new_page_name = this.$('#page_name').val();
return self._rpc({
model: 'website.page',
method: 'clone_page',
args: [pageId, new_page_name],
args: [
pageId,
this.$content.find('#page_name').val(),
],
}).then(function (path) {
window.location.href = path;
}).guardedCatch(reject);
@@ -75,6 +75,7 @@
<span/>
</label>
</div>
<p>Adding a font requires a reload of the page. This will save all your changes.</p>
</div>
<t t-name="website.delete_google_font_btn">
<i t-if="!local" role="button" class="text-info ms-2 fa fa-cloud" title="This font is hosted and served to your visitors by Google servers"/>
@@ -1,6 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<flectra>
<!--
TODO review in master: this snippet's images use contenteditable="true" to be
editable, their parent being o_not_editable/contenteditable="false" to prevent
adding text by mistake. After the first save, contenteditable="true" are lost,
so this is a bad practice / requires a better system to do this in the future.
Meanwhile, this is fixed in JS (see COMPANY_TEAM_CONTENTEDITABLE).
-->
<template id="s_company_team" name="Team">
<section class="s_company_team pt48 pb48">
<div class="container">
+21 -1
View File
@@ -1,6 +1,7 @@
# -*- coding: utf-8 -*-
# Part of Odoo, Flectra. See LICENSE file for full copyright and licensing details.
import re
import werkzeug
import itertools
import pytz
@@ -100,7 +101,7 @@ class WebsiteBlog(http.Controller):
first_post = BlogPost
if not blog:
first_post = BlogPost.search(domain + [('website_published', '=', True)], order="post_date desc, id asc", limit=1)
if use_cover and not fullwidth_cover:
if use_cover and not fullwidth_cover and not tags and not date_begin and not date_end:
offset += 1
if search:
@@ -159,6 +160,25 @@ class WebsiteBlog(http.Controller):
], type='http', auth="public", website=True, sitemap=True)
def blog(self, blog=None, tag=None, page=1, search=None, **opt):
Blog = request.env['blog.blog']
# TODO adapt in master. This is a fix for templates wrongly using the
# 'blog_url' QueryURL which is defined below. Indeed, in the case where
# we are rendering a blog page where no specific blog is selected we
# define(d) that as `QueryURL('/blog', ['tag'], ...)` but then some
# parts of the template used it like this: `blog_url(blog=XXX)` thus
# generating an URL like "/blog?blog=blog.blog(2,)". Adding "blog" to
# the list of params would not be right as would create "/blog/blog/2"
# which is still wrong as we want "/blog/2". And of course the "/blog"
# prefix in the QueryURL definition is needed in case we only specify a
# tag via `blog_url(tab=X)` (we expect /blog/tag/X). Patching QueryURL
# or making blog_url a custom function instead of a QueryURL instance
# could be a solution but it was judged not stable enough. We'll do that
# in master. Here we only support "/blog?blog=blog.blog(2,)" URLs.
if isinstance(blog, str):
blog = Blog.browse(int(re.search(r'\d+', blog)[0]))
if not blog.exists():
raise werkzeug.exceptions.NotFound()
if blog and not blog.can_access_from_current_website():
raise werkzeug.exceptions.NotFound()
@@ -44,7 +44,7 @@
<t t-esc="tag.name"/>
<a t-attf-href="#{blog_url(tag=tags_list(active_tag_ids, tag.id))}" class="btn border-0 py-1 post_link" t-att-rel="len(active_tag_ids) and 'nofollow'">&#215;</a>
</span>
<a t-elif="showInactive" t-attf-href="#{blog_url(tag=tags_list(active_tag_ids, tag.id))}" t-attf-class="badge mb-2 mw-100 text-truncate #{tag.id in active_tag_ids and 'badge-primary' or 'border'} post_link" t-attf-rel="len(active_tag_ids) and 'nofollow'" t-esc="tag.name"/>
<a t-elif="showInactive" t-attf-href="#{blog_url(tag=tags_list(active_tag_ids, tag.id))}" t-attf-class="badge mb-2 mw-100 text-truncate #{tag.id in active_tag_ids and 'badge-primary' or 'border'} post_link" t-att-rel="len(active_tag_ids) and 'nofollow'" t-esc="tag.name"/>
</t>
</t>
</t>
+5 -1
View File
@@ -251,7 +251,11 @@ class WebsiteForm(http.Controller):
}
attachment_id = request.env['ir.attachment'].sudo().create(attachment_value)
if attachment_id and not custom_field:
record.sudo()[file.field_name] = [(4, attachment_id.id)]
record_sudo = record.sudo()
value = [(4, attachment_id.id)]
if record_sudo._fields[file.field_name].type == 'many2one':
value = attachment_id.id
record_sudo[file.field_name] = value
else:
orphan_attachment_ids.append(attachment_id.id)