Skip to content

Commit

Permalink
[MIG] account_ux: Migration to 17.0
Browse files Browse the repository at this point in the history
  • Loading branch information
jjscarafia committed Nov 21, 2023
1 parent 4748c46 commit f32990f
Show file tree
Hide file tree
Showing 11 changed files with 77 additions and 44 deletions.
1 change: 1 addition & 0 deletions account_ux/README.rst
Expand Up @@ -27,6 +27,7 @@ Several Improvements to accounting:
#. Add delete number in cancelled customer invoices
#. Add options on accounts to require analytic distribution on journal entries posting
#. Adds a button "Match Payments" in the customer & suppliers form view to allow to start the matching of invoices & payments for that partner.
#. Create a "Bank and Cash menu" to grop submenus of future modules as checks and others. Also creates an specific submenu for internal transfers.
#. Do not allow to set same Company Currency on Journals or Accounts (enforce to keep empty if that is the cases)
#. On accounts only allow to choose account groups without children groups (last group on the hierarchy).
#. Allow to set more than one default tax for sales/purchases, useful for multicompany but also for perceptions or similar tax applied together with vat's.
Expand Down
5 changes: 3 additions & 2 deletions account_ux/__manifest__.py
Expand Up @@ -19,7 +19,7 @@
##############################################################################
{
'name': 'Account UX',
'version': "16.0.1.4.0",
'version': "17.0.1.0.0",
'category': 'Accounting',
'sequence': 14,
'summary': '',
Expand All @@ -45,10 +45,11 @@
'views/account_partial_reconcile_views.xml',
'views/account_account_views.xml',
'views/account_move_views.xml',
'views/account_payment_views.xml',
],
'demo': [
],
'installable': False,
'installable': True,
# lo hacemos auto install porque este repo no lo podemos agregar en otros
# por build de travis (ej sipreco) y queremos que para runbot se auto
# instale
Expand Down
1 change: 1 addition & 0 deletions account_ux/models/__init__.py
Expand Up @@ -14,3 +14,4 @@
from . import account_move
from . import account_bank_statement_line
from . import chart_template
from . import account_payment
4 changes: 0 additions & 4 deletions account_ux/models/account_move.py
Expand Up @@ -10,10 +10,6 @@ class AccountMove(models.Model):
internal_notes = fields.Html(
'Internal Notes'
)
reversed_entry_id = fields.Many2one(
'account.move',
states={'draft': [('readonly', False)]},
)
other_currency = fields.Boolean(compute='_compute_other_currency')

def get_invoice_report(self):
Expand Down
10 changes: 10 additions & 0 deletions account_ux/models/account_payment.py
@@ -0,0 +1,10 @@
from odoo import models


class AccountPayment(models.Model):
_inherit = "account.payment"

def _compute_is_internal_transfer(self):
super()._compute_is_internal_transfer()
if self._context.get('is_internal_transfer_menu'):
self.is_internal_transfer = True
6 changes: 3 additions & 3 deletions account_ux/models/chart_template.py
@@ -1,11 +1,11 @@
from odoo import models


class AccountChartTemplate(models.Model):
class AccountChartTemplate(models.AbstractModel):
_inherit = "account.chart.template"

def _load(self, company):
res = super()._load(company)
def _load(self, template_code, company, install_demo):
res = super()._load(template_code, company, install_demo)
self.env['res.config.settings']._set_default_tax('sale', company.account_sale_tax_id, company)
self.env['res.config.settings']._set_default_tax('purchase', company.account_purchase_tax_id, company)
return res
20 changes: 11 additions & 9 deletions account_ux/views/account_move_views.xml
Expand Up @@ -18,38 +18,39 @@
</field>

<button name="button_draft" position="after">
<button name="delete_number" string="Delete Number" attrs="{'invisible':['|', ('state','!=','cancel'),'|',('name','=',False), ('name','=','/')]}" type="object" help="Deleting the number will allow you to delete this invoice or to get a new number if you re-validate it. If this invoice represents a voided invoice, then you should not clean it." confirm="Warning! This can't be undone. Deleting the number will allow you to delete this invoice or to get a new number if you re-validate it. If this invoice represents a voided invoice, then you should not clean it. Do you want to continue?" groups="account.group_account_manager"/>
<button name="delete_number" string="Delete Number" invisible="state != 'cancel' or not name or name == '/'" type="object" help="Deleting the number will allow you to delete this invoice or to get a new number if you re-validate it. If this invoice represents a voided invoice, then you should not clean it." confirm="Warning! This can't be undone. Deleting the number will allow you to delete this invoice or to get a new number if you re-validate it. If this invoice represents a voided invoice, then you should not clean it. Do you want to continue?" groups="account.group_account_manager"/>
</button>

<field name="narration" position="after">
<field name="internal_notes" colspan="2" nolabel="1" height="50" placeholder="Add an internal note..."/>
</field>

<!-- odoo la hace visible o no segun una clave de contexto view_no_maturity, nosotros la queremos siempre visible (pero con opcional) -->
<xpath expr="//field[@name='line_ids']//field[@name='date_maturity']" position="attributes">
<attribute name="invisible"/>
<attribute name="column_invisible"/>
<attribute name="optional">hide</attribute>
</xpath>

<!-- similar modification to these are don on l10n_ar_ux for debit_origin_id -->
<!-- odoo deja modificar el origen pero si el usuario lo borra ya no lo ve mas y no se puede revertir. ademas nos parece practico que pueda completarlo para, por ej, vincular factura creada manualmente a una OV -->
<!-- es readonly por python, lo hacemos editable -->
<field name="invoice_origin" position="attributes">
<attribute name="attrs"></attribute>
<!-- es readonly por python, lo hacemos editable -->
<attribute name="invisible"/>
<attribute name="readonly">False</attribute>
</field>
<!-- we only show for supplier invoices -->
<field name="invoice_source_email" position="after">
<field name="invoice_origin" force_save="1" string="Source Document" readonly="False" attrs="{'invisible': [('move_type', 'not in', ('in_invoice', 'in_refund'))]}"/>
<field name="invoice_origin" force_save="1" string="Source Document" readonly="False" invisible="move_type not in ('in_invoice', 'in_refund')"/>
</field>
<!-- permitimos modificar "Reversion de" para poder vincular NC creadas a mano -->
<field name="reversed_entry_id" position="attributes">
<attribute name="attrs"></attribute>
<attribute name="invisible"/>
<!-- domain only for customer invoices because on supplier bills for now is not visible -->
<attribute name="domain">move_type == 'out_refund' and [('move_type', '=', 'out_invoice'), ('partner_id.commercial_partner_id', '=', commercial_partner_id), ('state', '=', 'posted')] or []</attribute>
</field>
<!-- agregamos demas reversed_entry_id en tab other info de facturas porque si no solo esta visible para asientos -->
<field name="invoice_origin" position="after">
<field name="reversed_entry_id" attrs="{'invisible': [('move_type', '!=', 'out_refund')]}"/>
<field name="reversed_entry_id" invisible="move_type != 'out_refund'" readonly="state != 'draft'"/>
</field>

<xpath expr="//div[@name='journal_div']/field[@name='currency_id']" position="attributes">
Expand All @@ -58,7 +59,7 @@
</xpath>

<xpath expr="//div[@name='journal_div']/field[@name='currency_id']" position="after">
<button name="%(action_account_change_currency)d" type="action" attrs="{'invisible':[('state','!=','draft')]}" icon="fa-pencil" class="btn-link" title="Change Currency" groups="base.group_multi_currency" />
<button name="%(action_account_change_currency)d" type="action" invisible="state != 'draft'" icon="fa-pencil" class="btn-link" title="Change Currency" groups="base.group_multi_currency" />
<field name="other_currency" invisible="1"/>
</xpath>

Expand All @@ -73,7 +74,8 @@

<!-- permitimos modificar "Factura origne de la ND" para poder vincular ND creadas a mano -->
<xpath expr="//group[@name='sale_info_group']/field[@name='debit_origin_id']" position="attributes">
<attribute name="attrs">{'invisible': [('move_type', '!=', 'out_invoice')], 'readonly': [('state', '!=', 'draft')]}</attribute>
<attribute name="invisible">move_type != 'out_invoice'</attribute>
<attribute name="readonly">state != 'draft'</attribute>
<attribute name="domain">[('move_type', 'in', ('out_invoice', 'out_refund')), ('partner_id.commercial_partner_id', '=', commercial_partner_id), ('state', '=', 'posted')]</attribute>
</xpath>
</field>
Expand Down
8 changes: 4 additions & 4 deletions account_ux/views/account_partial_reconcile_views.xml
Expand Up @@ -27,7 +27,7 @@
<field name="credit_move_id"/>
<field name="full_reconcile_id"/>
<field name="amount"/>
<field name="company_currency_id" invisible="1"/>
<field name="company_currency_id" column_invisible="True"/>
</tree>
</field>
</record>
Expand All @@ -41,9 +41,9 @@
<group>
<field name="debit_move_id" readonly="1"/>
<field name="credit_move_id" readonly="1"/>
<field name="amount" attrs="{'readonly': [('full_reconcile_id', '!=', False)]}"/>
<field name="credit_amount_currency" attrs="{'readonly': [('full_reconcile_id', '!=', False)]}"/>
<field name="debit_amount_currency" attrs="{'readonly': [('full_reconcile_id', '!=', False)]}"/>
<field name="amount" readonly="full_reconcile_id"/>
<field name="credit_amount_currency" readonly="full_reconcile_id"/>
<field name="debit_amount_currency" readonly="full_reconcile_id"/>
<field name="debit_currency_id" invisible="1"/>
<field name="credit_currency_id" invisible="1"/>
</group>
Expand Down
31 changes: 31 additions & 0 deletions account_ux/views/account_payment_views.xml
@@ -0,0 +1,31 @@
<odoo>

<record id="view_account_payment_form" model="ir.ui.view">
<field name="name">account.payment.form</field>
<field name="model">account.payment</field>
<field name="inherit_id" ref="account.view_account_payment_form"/>
<field name="arch" type="xml">
<field name="is_internal_transfer" position="attributes">
<attribute name="invisible">1</attribute>
</field>
</field>
</record>

<record id="action_account_payments_transfer" model="ir.actions.act_window">
<field name="name">Transfers</field>
<field name="res_model">account.payment</field>
<field name="view_mode">tree,form,graph</field>
<field name="context">{'default_payment_type': 'outbound', 'is_internal_transfer_menu': True, 'default_move_journal_types': ('bank', 'cash'), 'display_account_trust': True, }</field>
<field name="domain">[('is_internal_transfer', '=', 'transfer')]</field>
<field name="help" type="html">
<p class="oe_view_nocontent_create">
Click to register a transfer between liquidity journals
</p>
</field>
</record>

<menuitem id="menu_finance_bank_and_cash" parent="account.menu_finance" sequence="4" groups="account.group_account_user" name="Bank and Cash"/>

<menuitem action="action_account_payments_transfer" id="menu_action_account_payments_transfer" parent="menu_finance_bank_and_cash" sequence="30" groups="account.group_account_user"/>

</odoo>
2 changes: 1 addition & 1 deletion account_ux/wizards/account_change_currency_views.xml
Expand Up @@ -10,7 +10,7 @@
<field name="currency_from_id"/>
<field name="currency_to_id" domain="[('id', '!=', currency_from_id)]"/>
<field name="change_type" widget="radio"/>
<field name="currency_rate" groups="!account_ux.group_restrict_change_currency_exchange" attrs="{'invisible':[('change_type', '=', 'currency')]}"/>
<field name="currency_rate" groups="!account_ux.group_restrict_change_currency_exchange" invisible="change_type == 'currency'"/>
<field name="currency_rate" groups="account_ux.group_restrict_change_currency_exchange" readonly="1"/>
</group>
<footer>
Expand Down
33 changes: 12 additions & 21 deletions account_ux/wizards/res_config_settings_views.xml
Expand Up @@ -5,41 +5,32 @@
<field name="model">res.config.settings</field>
<field name="inherit_id" ref="account.res_config_settings_view_form"/>
<field name="arch" type="xml">
<div name="main_currency_setting_container" position="inside">
<div class="col-xs-12 col-md-6 o_setting_box" id="reconcile_on_company_currency">
<div class="o_setting_left_pane">
<field name="reconcile_on_company_currency"/>
</div>
<div class="o_setting_right_pane" name="reconcile_on_company_currency_right_pane">
<label for="reconcile_on_company_currency"/>
<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">
When reconciling debt with secondary currency, if the account doesn't have a currency configured, then reconcile on company currency. This will avoid all the automatic exchange rates journal entries by forcing same rate of the original document being reconcile.
IMPORTANT: If you change this setting if you reconcile any previous item and re-reconcile it, it will be reconciled with the new mechanism
</div>
</div>
</div>
</div>
<block name="main_currency_setting_container">
<setting string="This option enables open documents in the payment report" help="When reconciling debt with secondary currency, if the account doesn't have a currency configured, then reconcile on company currency. This will avoid all the automatic exchange rates journal entries by forcing same rate of the original document being reconcile. IMPORTANT: If you change this setting if you reconcile any previous item and re-reconcile it, it will be reconciled with the new mechanism">
<field name="reconcile_on_company_currency"/>
</setting>
</block>

<!-- on sale we use xpath because website_sale adds same field -->
<xpath expr="//div[@data-key='account']//label[@for='sale_tax_id']" position="attributes">
<xpath expr="//block[@name='default_taxes_setting_container']//label[@for='sale_tax_id']" position="attributes">
<attribute name="for">sale_tax_ids</attribute>
</xpath>
<xpath expr="//div[@data-key='account']//field[@name='sale_tax_id']" position="attributes">
<xpath expr="//block[@name='default_taxes_setting_container']//field[@name='sale_tax_id']" position="attributes">
<attribute name="name">sale_tax_ids</attribute>
<attribute name="domain">[('type_tax_use', 'in', ('sale', 'all')), ('company_id', 'child_of', company_id)]</attribute>
<attribute name="widget">many2many_tags</attribute>
<attribute name="options">{'no_create': True, 'no_open': True}</attribute>
</xpath>

<label for="purchase_tax_id" position="attributes">
<xpath expr="//block[@name='default_taxes_setting_container']//label[@for='purchase_tax_id']" position="attributes">
<attribute name="for">purchase_tax_ids</attribute>
</label>
<field name="purchase_tax_id" position="attributes">
</xpath>
<xpath expr="//block[@name='default_taxes_setting_container']//field[@name='purchase_tax_id']" position="attributes">
<attribute name="name">purchase_tax_ids</attribute>
<attribute name="domain">[('type_tax_use', 'in', ('purchase', 'all')), ('company_id', 'child_of', company_id)]</attribute>
<attribute name="widget">many2many_tags</attribute>
<attribute name="options">{'no_create': True, 'no_open': True}</attribute>
</field>
</xpath>
</field>
</record>
</odoo>

0 comments on commit f32990f

Please sign in to comment.