Skip to content

Commit

Permalink
[MIG] l10n_ro_account_report_invoice: Migration to 17.0
Browse files Browse the repository at this point in the history
  • Loading branch information
razvanioan committed Jan 30, 2024
1 parent 5e38082 commit d76becb
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 48 deletions.
2 changes: 1 addition & 1 deletion l10n_ro_account_report_invoice/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
{
"name": "Romania - Invoice Report",
"summary": "Romania - Invoice Report",
"version": "16.0.1.2.0",
"version": "17.0.1.0.0",
"category": "Localization",
"author": "NextERP Romania," "Odoo Community Association (OCA)",
"website": "https://github.com/OCA/l10n-romania",
Expand Down
24 changes: 12 additions & 12 deletions l10n_ro_account_report_invoice/init_hook.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
logger = logging.getLogger(__name__)


def pre_init_hook(cr):
def pre_init_hook(env):
"""
The objective of this hook is to speed up the installation
of the module on an existing Odoo instance.
Expand All @@ -19,33 +19,33 @@ def pre_init_hook(cr):
l10n_ro_currency_rate so that it is not computed by the install.
"""
store_field_l10n_ro_currency_rate(cr)
store_field_l10n_ro_currency_rate(env)


def store_field_l10n_ro_currency_rate(cr):
def store_field_l10n_ro_currency_rate(env):
# pylint: disable=sql-injection
cr.execute(
env.cr.execute(
"""SELECT column_name
FROM information_schema.columns
WHERE table_name='account_move' AND column_name='l10n_ro_currency_rate'"""
)
if not cr.fetchone():
cr.execute(
if not env.cr.fetchone():
env.cr.execute(
"""
ALTER TABLE account_move ADD COLUMN l10n_ro_currency_rate numeric;
COMMENT ON COLUMN account_move.l10n_ro_currency_rate IS 'Ro Currency Rate';
"""
)

logger.info("Computing field l10n_ro_currency_rate on account.move")
cr.execute(
env.cr.execute(
"""
select id from res_country where code = 'RO';
"""
)
ro_country = cr.fetchone()
ro_country = env.cr.fetchone()
if ro_country:
cr.execute(
env.cr.execute(
"""
SELECT res_company.id
FROM res_company
Expand All @@ -54,10 +54,10 @@ def store_field_l10n_ro_currency_rate(cr):
"""
% ro_country
)
ro_companies = cr.fetchall()
ro_companies = env.cr.fetchall()
if ro_companies:
ro_companies = [x[0] for x in ro_companies]
cr.execute(
env.cr.execute(
r"""
WITH currency_rate
(currency_id, company_id, rate, date_start, date_end) AS (
Expand Down Expand Up @@ -87,7 +87,7 @@ def store_field_l10n_ro_currency_rate(cr):
""",
{"ids": tuple(ro_companies)},
)
cr.execute(
env.cr.execute(
r"""
UPDATE account_move acc_move
SET l10n_ro_currency_rate = 1
Expand Down
4 changes: 4 additions & 0 deletions l10n_ro_account_report_invoice/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,8 @@

* Fekete Mihai <feketemihai@nexterp.ro>

* `QDev Web Labs <https://qdev.ro>`_:

* Anastasescu Răzvan-Ioan <razvan@qdev.ro>

Do not contact contributors directly about support or help with technical issues.
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
Expand Down
7 changes: 3 additions & 4 deletions l10n_ro_account_report_invoice/views/account_invoice_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@
<label
for="l10n_ro_currency_rate"
groups="account.group_account_readonly"
invisible="context.get('default_journal_id') and context.get('move_type', 'entry') != 'entry'"
attrs="{'invisible': [('is_l10n_ro_record','=',False)]}"
invisible="not is_l10n_ro_record or (context.get('default_journal_id') and context.get('move_type', 'entry') != 'entry')"
/>
<div
name="currency_rate_div"
Expand All @@ -23,15 +22,15 @@
<field
name="l10n_ro_currency_rate"
digits="[16, 4]"
attrs="{'invisible': [('is_l10n_ro_record','=',False)]}"
invisible="not is_l10n_ro_record"
/>
</div>
</div>
<group name="accounting_info_group" position="after">
<group
string="Amounts in company currency"
groups="base.group_multi_currency"
attrs="{'invisible': [('is_l10n_ro_record','=',False)]}"
invisible="not is_l10n_ro_record"
>
<field name="amount_untaxed_signed" string="Tax Excluded" />
<field name="amount_tax_signed" string="Tax" />
Expand Down
11 changes: 9 additions & 2 deletions l10n_ro_account_report_invoice/views/invoice_report.xml
Original file line number Diff line number Diff line change
Expand Up @@ -113,15 +113,22 @@
</t>
</table>

<!-- fix floating of totals section -->
<div id="right-elements" position="before">
<div id="right-elements-wrapper" class="clearfix"/>
</div>

<div id="right-elements-wrapper" position="inside">
<div id="right-elements" position="move"/>
</div>

<xpath expr="//p[@name='note']" position="after">
<t t-if="o.is_l10n_ro_record">
<p t-if="o.company_id.l10n_ro_no_signature_text" id="sign_info">
<span t-field="o.company_id.l10n_ro_no_signature_text" />
</p>
</t>
</xpath>


</template>
<template
id="l10n_ro_report_invoice_document_tax_totals"
Expand Down
36 changes: 8 additions & 28 deletions l10n_ro_account_report_invoice/views/res_config_settings_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,35 +5,15 @@
<field name="model">res.config.settings</field>
<field name="inherit_id" ref="account.res_config_settings_view_form" />
<field name="arch" type="xml">
<div id="invoicing_settings" position="inside">
<block id="invoicing_settings" position="inside">
<field name="is_l10n_ro_record" invisible="1" />
<div
class="col-12 col-lg-6 o_setting_box"
attrs="{'invisible': [('is_l10n_ro_record','=',False)]}"
>
<div class="o_setting_left_pane">
</div>
<div class="o_setting_right_pane">
<label for="l10n_ro_no_signature_text" />
<span
class="fa fa-lg fa-building-o"
title="Values set here are company-specific."
aria-label="Values set here are company-specific."
groups="base.group_multi_company"
role="img"
/>
<div class="text-muted">Invoices without stamp text</div>
<div class="content-group">
<div class="mt16">
<field
name="l10n_ro_no_signature_text"
placeholder="Insert your invoice without stamp text here..."
/>
</div>
</div>
</div>
</div>
</div>
<setting id="l10n_ro_no_signature_text" help="Invoices without stamp text" company_dependent="1" invisible="not is_l10n_ro_record">
<field
name="l10n_ro_no_signature_text"
placeholder="Insert your invoice without stamp text here..."
/>
</setting>
</block>
</field>
</record>
</odoo>

0 comments on commit d76becb

Please sign in to comment.